21 if (enemies[0].hp != 0) {
29 if (enemies[1].hp != 0) {
37 if (enemies[2].hp != 0) {
46 for (i = 0; i < 3; i++) {
48 if (active != i && enemies->
id != 0 && enemies->
hp != 0) {
74 task->
lines[0] = 0x5F;
75 task->
lines[1] = 0x10;
98 task->
lines[0] = 0x60;
99 task->
lines[1] = 0x10;
126 if (fighter->
mp >= tech->
mp) {
128 fighter->
mp -= tech->
mp;
131 task->
lines[0] = 0x8D;
132 task->
lines[1] = 0x10;
156 task->
lines[0] = 0x4D;
161 task->
lines[0] = 0x8E;
162 task->
lines[1] = 0x10;
180 switch (task->
state) {
217 task->
lines[0] = message;
218 task->
lines[1] = 0x10;
237 }
else if (task->
target < 0) {
243 task->
lines[0] = 0x5E;
244 task->
lines[1] = 0x10;
323 percent = arg * 100 / 128;
324 if (fighter->
hp < (
s16)(fighter->
maxHp / 100) * percent) {
329 percent = arg * 100 / 128;
330 if (fighter->
hp >= (
s16)(fighter->
maxHp / 100) * percent) {
335 if (fighter->
mp < arg) {
340 if (fighter->
mp >= arg) {
346 percent = arg * 100 / 128;
347 if (fighter->
hp < (
s16)(fighter->
maxHp / 100) * percent) {
353 percent = arg * 100 / 128;
354 if (fighter->
hp >= (
s16)(fighter->
maxHp / 100) * percent) {
360 for (i = 0, digimon =
DIGIMON_DATA; i < 8; i++, digimon++) {
361 if (fighter->
id == digimon->
id) {
376 for (j = 0; j < 3; j++) {
383 for (j = 0; j < 3; j++) {
407 if (fighter->
charge != 0) {
412 if (fighter->
boosts[0] < 0) {
417 if (fighter->
boosts[1] < 0) {
422 if (fighter->
boosts[2] < 0) {
427 if (fighter->
turns % arg == 0) {
448 value = entry->
techs[1];
451 value = entry->
techs[2];
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
BattleFuncs FIGHTSTG_battleFuncs
the battle's stats and the functions that compute with them
#define FIGHTER_PARALYZED
loses turns at random (FIGHTSTG_battleFuncs.testParalysis)
#define BATTLE_KIND_ESCAPE
the enemy runs away under a tenth of its HP
#define BATTLE_FLED
How a battle ends (FIGHTSTG_endBattle)
#define BATTLE_TABLE_FALLBACK
BattleTableEntry.actions' last one, which the enemy takes when none of the others' conditions holds: ...
#define FIGHTER_ASLEEP
can't act or run away; a hit may wake it up
void FIGHTSTG_endBattle(s32 result)
Ends the battle: queues event 1 ahead of the others, with how it ended (BATTLE_FLED,...
void FIGHTSTG_queueRunAway(u8 side)
Queues side's attempt to run away (event 4)
EventQueue FIGHTSTG_events
the battle's events and their functions
void FIGHTSTG_queueEnemyTurn(s32 delay)
Queues the enemy's turn (event 3) in delay.
FIGHTSTG.PRO: the battle.
BattleTableEntry *(* FIGHTSTG_battleTableFunc)(s32 id)
how the fight stage and WFIGHTMN read the battle table
DigimonData DIGIMON_DATA[55]
55 entries: the 52 Digimon, then three placeholders (0x1D4-0x1D6)
s32 FIGHTSTG_getEnemyAction(u8 kind)
What an enemy's action target makes it do (EnemyTurn.target): 1 its first technique,...
s32 FIGHTSTG_testEnemyCondition(u8 condition, s16 arg)
Whether the condition of an enemy's action holds (BattleTableAction): always, a chance in 128,...
void FIGHTSTG_updateEnemyTurn(EnemyTurn *task, BattleChild *children)
The enemy's turn: a message when its HP is under a tenth, then one when it is asleep,...
static void useEnemyTech(EnemyTurn *task, BattleChild *children)
Starts the enemy's attack (target 1) or technique TARGET, paying its MP, or shows the message for an ...
s32 FIGHTSTG_pickEnemySwitch(EnemyTurn *task)
The enemy that the enemy's turn (FIGHTSTG_updateEnemyTurn) switches to: task->target's,...
static void switchEnemyOut(EnemyTurn *task, BattleChild *children)
Picks the enemy to switch in (FIGHTSTG_pickEnemySwitch) and shows the switch's message,...
static void showRunAway(EnemyTurn *task, BattleChild *children)
Shows the enemy's run-away event, if it has one, and clears it before its turn goes on.
static void showEnemyName(EnemyTurn *task, BattleChild *children)
Says the name of the enemy that came in.
static void fleeWhenWeak(EnemyTurn *task, BattleChild *children)
In BATTLE_KIND_ESCAPE, the enemy flees once its HP is under a tenth; otherwise its turn goes on to th...
EnemyTurn * FIGHTSTG_startEnemyTurn(void)
Starts the enemy's turn (FIGHTSTG_updateEnemyTurn)
Entrance * FIGHTSTG_startEntrance(s32 id, s32 side, s32 weak)
Starts a fighter's entrance: Digimon id on the player's side (side 0) or the enemy's.
FirstTech * FIGHTSTG_startFirstTech(s32 side)
Starts side's first technique (FIGHTSTG_updateFirstTech)
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
BattleMessageBox * FIGHTSTG_createMessage(void)
Creates a battle message box (FIGHTSTG_updateMessage)
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
s16 charge
added in 64ths to its next technique's damage, which uses it up
s16 id
the Digimon (DIGIMON_DATA)
s16 boosts[4]
added to the stats FIGHTSTG_boostStats picks
s16 turns
an enemy's, for its battle table's conditions
s32(* testParalysis)(u8 side)
whether side's paralysis costs it the turn
void(* show)()
FIGHTSTG_showMessage: (task, type, data)
s32 battle
the battle (BattleResult.battle)
u8 encounterKind
Encounter.kind; only the enemies' condition 13 reads it.
s32 active[2]
each side's fighter
BattleFighter fighters[2][3]
s16 kind
the kind of battle
s16 nameId
string in file 0x4F
BattleTableAction actions[3+1]
the first whose condition holds (FIGHTSTG_testEnemyCondition)
s16 techs[3]
its first, then those of FIGHTSTG_getEnemyAction's kinds 2 and 3
Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners)
s16 element
under ELEMENT_FIRST: none
FIGHTSTG_startEnemyTurn's task.
void(* nextSubstate)(struct EnemyTurn *task)
void(* setSubstate)(struct EnemyTurn *task, s32 substate)
void(* nextState)(struct EnemyTurn *task)
s32 lines[10]
FIGHTSTG_updateMessage's, 0 ends them.
s32 switchTo
the enemy fighter it brings in (FIGHTSTG_pickEnemySwitch)
s32 target
-2 to -4 for an enemy, else any but the active one
s32(* getDelay)(u8 side, s32 kind)
FIGHTSTG_getEventDelay: when an event of side's runs.
s32(* find)(s32 type, u8 side, s32 fighter)
s16 type
0 for a free entry
s32(* next)(void)
0 to RANDOM_COUNT - 1
Any task, seen through its header.
A technique (TECHS, from 1: technique n is TECHS[n - 1])
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
TechAction * FIGHTSTG_startTechAction(s32 side, s32 tech)
Starts side's (0 or 0x10) technique or item tech.
s32 WFIGHTMN_setIdleMotion(u8 id, s32 damage)
Sets the idle motion of side id >> 4's fighter: 1 (weak) if damage leaves it with a quarter of its HP...
A turn's or a counterattack's one child, and what WFIGHTMN's battle menu waits for (NULL when it is d...
Entrance * entrance
a fighter's (FIGHTSTG_startEntrance)
BattleMessageBox * message
FIGHTSTG_createMessage.
FirstTech * attack
FIGHTSTG_startFirstTech.
TechAction * tech
a technique or an item (FIGHTSTG_startTechAction)