Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
battle.c
Go to the documentation of this file.
1/* The battles that start on the field: the steps to the next one and the
2 battles of the map's areas */
3
4#include "field/field_mode.h"
5
6/* Rolls the steps to the next battle (GAME.battleSteps): under 0x100, or 0x100 to 0x4FF */
8 s32 value = RANDOM.next() % 2304;
9
10 if (value < 0x100) {
11 GAME.battleSteps = value;
12 } else {
13 GAME.battleSteps = (value + 0x100) / 2;
14 }
15}
16
17/* Starts one of the eight battles of the player's battle area, at random */
20 Vec2 tile;
21 s32 area;
22 s32 index;
23 AreaBattle *battle;
24
25 tile = actor->tile;
26 area = (u8)FIELDSTG_map.getCell(FIELD_MAP_AREAS, &tile) - 1;
27 index = RANDOM.next() & 7;
28 battle = FIELDSTG_state.battles->battles[area]->battles[index];
30}
31
32/* Counts down to the next battle at each step by the area's rate
33 (FIELDSTG_battleRates), unless the field is busy, and starts it when they
34 run out */
36 Actor *actor;
37 Vec2 tile;
38 s32 area;
39 s32 rate;
40
44 tile = actor->tile;
45 area = (u8)FIELDSTG_map.getCell(FIELD_MAP_AREAS, &tile);
46 if (area != 0) {
47 area--;
49 GAME.battleSteps -= rate;
50 if (GAME.battleSteps <= 0) {
51 if (BATTLE_SETUP.randomBattles != 0) {
53 }
55 }
56 }
57 }
58}
59
60/* Starts battle index of the fourth area, the one events start */
62 AreaBattle *battle;
63
65 battle = FIELDSTG_state.battles->battles[3]->battles[index];
67 }
68}
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned char u8
Definition common.h:8
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
void FIELDSTG_countBattleSteps(void)
Counts down to the next battle at each step by the area's rate (FIELDSTG_battleRates),...
Definition battle.c:35
void FIELDSTG_rollBattleSteps(void)
Rolls the steps to the next battle (GAME.battleSteps): under 0x100, or 0x100 to 0x4FF.
Definition battle.c:7
void FIELDSTG_startEventBattle(s32 index)
Starts battle index of the fourth area, the one events start.
Definition battle.c:61
void FIELDSTG_startAreaBattle(void)
Starts one of the eight battles of the player's battle area, at random.
Definition battle.c:18
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
#define FIELD_MAP_AREAS
a cell's value: its battle area (FieldBattles), or 0
Definition field_map.h:87
FIELDSTG.PRO: the field mode, where the player walks around the map.
static void FIELDSTG_startBattle(AreaBattle *battle)
Starts a battle: its fight stage, its music and its encounter.
FieldMap FIELDSTG_map
Definition fieldstg.c:3660
s32 FIELDSTG_battleRates[]
how much each area lowers GAME.battleSteps, the steps to the next battle
Definition fieldstg.c:3656
FieldState FIELDSTG_state
Definition fieldstg.c:2641
BattleSetup BATTLE_SETUP
Definition items.c:886
Random RANDOM
Definition random.c:533
TaskRegistry TASK_REGISTRY
Definition registry.c:122
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
Vec2 tile
Definition field_map.h:337
A battle of an area's BattleList, which can start on the field (see FIELDSTG_startEncounter); FIGHTST...
Definition field_map.h:402
s32 count
how often they come: an index of FIELDSTG_battleRates
Definition field_map.h:412
AreaBattle * battles[8]
Definition field_map.h:413
s32 randomBattles
the field starts random battles; the stage select toggles it (Select)
Definition game_state.h:380
BattleList * battles[4]
Definition field_map.h:426
s32 files[8]
the file entry of each map, set by setFile
Definition field_map.h:91
s32(* getCell)(s32 index, Vec2 *pos)
FIELDSTG_getMapCell.
Definition field_map.h:101
s32 frozen
no control, triggers or encounters for the player: while the area name banner shows (FIELDSTG_createB...
Definition field_map.h:466
s32 busy
an event, a warp, a launch or a battle has the player
Definition field_map.h:468
s32 battleStarting
an encounter started (FIELDSTG_startEncounter)
Definition field_map.h:469
FieldBattles * battles
Definition field_map.h:450
s32 acting
the player talks, climbs, slides or searches
Definition field_map.h:470
s32 battleSteps
to the next random battle, which each step lowers
Definition game_state.h:502
s32(* next)(void)
0 to RANDOM_COUNT - 1
Definition random.h:15
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
Definition gfx.h:352