Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
menu.c File Reference

The battle menu: its task, the states that run the turn's events (the player's commands, the battle's end, recoveries, damage and statuses, the blast, knock-outs and the last enemy), its main state and WFIGHTMN's entry point. More...

Include dependency graph for menu.c:

Go to the source code of this file.

Functions

static void setBattleKind (void)
 Sets the battle's kind from the mode it came from and the battle: the escape, UNK2, no-damage and final battles, or a normal one.
 
static void addFighters (BattleMenu *task, BattleMenuChildren *children)
 Adds the partner's Digimon (its battle digivolution, but not after an ambush) and the enemy, the partner weak when its HP is low.
 
static void queueFirstTurns (BattleMenu *task, BattleMenuChildren *children)
 Queues the first turns: the enemy's first after an ambush, with its message, or by a roll on the fighters' speeds.
 
static void switchConfusionMusic (BattleMenu *task)
 Plays MUSIC_CONFUSION once a partner is confused, and the battle's music again once none is.
 
void WFIGHTMN_updateMenu (BattleMenu *task, BattleMenuChildren *children)
 The battle menu's task: sets up the battle (its music, FIGHTSTG's tasks, setBattleKind, the fighters' models in addFighters and queueFirstTurns), then runs the menu (WFIGHTMN_runTurn), playing MUSIC_CONFUSION once a partner is confused and the battle's music again after (switchConfusionMusic)
 
void WFIGHTMN_cancelBlast (void)
 Ends the current partner's temporary Digimon and the actions that go with it.
 
void WFIGHTMN_runCommand (BattleMenu *task, BattleMenuChildren *children)
 The player's turn (EVENT_PLAYER_TURN): drops the partner's queued technique and running away, then loses the turn to FIGHTER_PARALYZED, goes on to WFIGHTMN_runConfusedCommand when FIGHTER_CONFUSED, or lets the player pick a command and starts the state or the task that runs it.
 
void WFIGHTMN_digivolve (BattleMenu *task, BattleMenuChildren *children)
 The state that changes the current partner's Digimon to the one picked (commands->digimon), then says so.
 
void WFIGHTMN_tag (BattleMenu *task, BattleMenuChildren *children)
 Swaps the partner on the field for the one picked (children->commands): message 0x38, then the swap effect with current[0] set to the new partner's slot for it, then the switch itself and message 0x39.
 
void WFIGHTMN_pairTech (BattleMenu *task, BattleMenuChildren *children)
 State 6, the pair technique (the player turn's action 6): the outgoing and incoming partners do commands->pairTech, then the incoming one tags in (state 5, past its message) while an enemy is left; otherwise the turn ends with the partner marked as fought.
 
void WFIGHTMN_endBattle (BattleMenu *task, BattleMenuChildren *children)
 After a won battle, picks the enemy whose item the player may get; saves the partners' HP and MP, fades out and requests the next mode.
 
void WFIGHTMN_runAway (BattleMenu *task, BattleMenuChildren *children)
 Asks FIGHTSTG (FIGHTSTG_battleFuncs.testRunAway) whether the current action's actor gets away; if so shows message 0x43 (a partner) or 0x5F (an enemy) and waits for the window to close, otherwise sets the event's time from getDelay.
 
void WFIGHTMN_endAutoRecover (BattleMenu *task, BattleMenuChildren *children)
 Removes the current action's EVENT_RECOVERY event, unless the partner it is for has WFIGHTMN_RECOVERY_ITEM equipped.
 
void WFIGHTMN_recover (BattleMenu *task, BattleMenuChildren *children)
 A fighter's recovery (EVENT_RECOVERY): unless its HP is full, plays technique 0xBD on it when it is the side's active fighter, shows message 0xA with the amount and adds it, up to the maximum.
 
void WFIGHTMN_clearField (BattleMenu *task, BattleMenuChildren *children)
 EVENT_CLEAR_FIELD: shows message 0x6A and ends the element boost (FIGHTSTG_battle.state.boost.element)
 
void WFIGHTMN_takeDamage (BattleMenu *task, BattleMenuChildren *children)
 Carries out the current action's damage (FIGHTSTG_battleFuncs.getDamage) on its unit.
 
void WFIGHTMN_cureStatus (BattleMenu *task, BattleMenuChildren *children)
 States 13-15: end the current action's unit's paralysis, confusion or sleep.
 
void WFIGHTMN_endBoost (BattleMenu *task, BattleMenuChildren *children)
 Clears the boost (BattleFighter.boosts) that the current action ends.
 
void WFIGHTMN_runConfusedCommand (BattleMenu *task, BattleMenuChildren *children)
 A confused partner's turn (FIGHTER_CONFUSED): the player's turn at step 3, where only an attack does anything.
 
void WFIGHTMN_endRestriction (BattleMenu *task, BattleMenuChildren *children)
 Clears the restriction that the current action ends (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE) from its unit.
 
void WFIGHTMN_blast (BattleMenu *task, BattleMenuChildren *children)
 Digivolves the current partner for the battle, to the Digimon its level reaches (DigimonData.blastForms), and heals it when the change ends.
 
void WFIGHTMN_endBlast (BattleMenu *task, BattleMenuChildren *children)
 Turns the current partner back into the Digimon it was (prevId)
 
static void announceKnockOut (BattleMenu *task, BattleMenuChildren *children, QueuedEvent *action)
 Takes the fallen fighter's event off the queue, shows message 0x50 or 0x51 and clears its status, ending the partner's special.
 
static void endBattleOnKnockOut (BattleMenu *task, BattleMenuChildren *children, QueuedEvent *event)
 With no fighter left on the side, ends the battle: lost (message 0x53) or won (message 0x52, the partner's motion 0xD and, but in BATTLE_KIND_FINAL_LAST, the win jingle)
 
static void bringSecondEnemy (BattleMenu *task, BattleMenuChildren *children)
 In BATTLE_KIND_FINAL, brings in the enemy's second fighter in place of the first, then lets the enemy's turn come at once.
 
void WFIGHTMN_knockOut (BattleMenu *task, BattleMenuChildren *children)
 EVENT_KNOCK_OUT (substate 0x15), a fighter's fall: case 0 takes its event off the queue, shows message 0x50 or 0x51 and clears its status (announceKnockOut); case 1 looks for the side's next fighter standing.
 
void WFIGHTMN_endSpecial (BattleMenu *task, BattleMenuChildren *children)
 The end of the partner's special state (EVENT_SPECIAL_END): clears it and shows message 0x59.
 
void WFIGHTMN_digidevolve (BattleMenu *task, BattleMenuChildren *children)
 EVENT_DIGIDEVOLVE: the partner goes back to its own form, its blast and its queued technique are dropped, and it comes in again with message 0x47.
 
void WFIGHTMN_showWon (BattleMenu *task, BattleMenuChildren *children)
 Shows the won message (from WFIGHTMN_knockOut) for its time, then closes it.
 
void WFIGHTMN_bringLastEnemy (BattleMenu *task, BattleMenuChildren *children)
 The enemy's third fighter comes in (BATTLE_KIND_FINAL_LAST), takes the first's place, and technique 440 is made from 443 with FIGHTSTG_battle.state.tech's effect (its look from WFIGHTMN_effectVisuals) and element (from WFIGHTMN_elementVisuals) before message 0x16 names it (?)
 
void WFIGHTMN_restoreEnemy (BattleMenu *task, BattleMenuChildren *children)
 The end of the enemy's weakness (EVENT_WEAKNESS_END): its lowered stats come back and it takes its turn first.
 
void WFIGHTMN_runTurn (BattleMenu *task)
 The battle menu's main state: waits for FIGHTSTG's turn (FIGHTSTG_events.funcs.pop), then runs the state of the command it gets (WFIGHTMN_states)
 
Task * WFIGHTMN_start (void)
 WFIGHTMN's entry point: creates the battle menu, and zeroes FIGHTSTG_battle's state and BATTLE_RESULT.
 

Detailed Description

The battle menu: its task, the states that run the turn's events (the player's commands, the battle's end, recoveries, damage and statuses, the blast, knock-outs and the last enemy), its main state and WFIGHTMN's entry point.

The states stay in one module: a cut between them moves a jump table off its 8-byte place.

Definition in file menu.c.

Function Documentation

◆ setBattleKind()

static void setBattleKind ( void  )
inlinestatic

Sets the battle's kind from the mode it came from and the battle: the escape, UNK2, no-damage and final battles, or a normal one.

< the enemy runs away under a tenth of its HP

< the enemy keeps an eleventh of its HP

< the partner's hits do no damage

< battle 0x144, the last one: its first enemy

Definition at line 11 of file menu.c.

Referenced by WFIGHTMN_updateMenu().

Here is the caller graph for this function:

◆ addFighters()

static void addFighters ( BattleMenu *  task,
BattleMenuChildren *  children 
)
inlinestatic

Adds the partner's Digimon (its battle digivolution, but not after an ambush) and the enemy, the partner weak when its HP is low.

Definition at line 33 of file menu.c.

Referenced by WFIGHTMN_updateMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ queueFirstTurns()

static void queueFirstTurns ( BattleMenu *  task,
BattleMenuChildren *  children 
)
inlinestatic

Queues the first turns: the enemy's first after an ambush, with its message, or by a roll on the fighters' speeds.

< physical accuracy, evasion and running away

< physical accuracy, evasion and running away

Definition at line 61 of file menu.c.

Referenced by WFIGHTMN_updateMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switchConfusionMusic()

static void switchConfusionMusic ( BattleMenu *  task)
inlinestatic

Plays MUSIC_CONFUSION once a partner is confused, and the battle's music again once none is.

< COM_CNFS: in a battle while a partner is confused (WFIGHTMN switchConfusionMusic)

Definition at line 90 of file menu.c.

Referenced by WFIGHTMN_updateMenu().

Here is the caller graph for this function:

◆ WFIGHTMN_updateMenu()

void WFIGHTMN_updateMenu ( BattleMenu *  task,
BattleMenuChildren *  children 
)

The battle menu's task: sets up the battle (its music, FIGHTSTG's tasks, setBattleKind, the fighters' models in addFighters and queueFirstTurns), then runs the menu (WFIGHTMN_runTurn), playing MUSIC_CONFUSION once a partner is confused and the battle's music again after (switchConfusionMusic)

menu.c

< the battle camera's and the lights'

< the battle camera's and the lights'

Definition at line 124 of file menu.c.

Referenced by WFIGHTMN_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WFIGHTMN_cancelBlast()

void WFIGHTMN_cancelBlast ( void  )

Ends the current partner's temporary Digimon and the actions that go with it.

< a technique of the partner's, run as its command

Definition at line 211 of file menu.c.

Referenced by WFIGHTMN_digidevolve(), WFIGHTMN_digivolve(), WFIGHTMN_endBattle(), WFIGHTMN_endBlast(), and WFIGHTMN_tag().

Here is the caller graph for this function:

◆ WFIGHTMN_runCommand()

void WFIGHTMN_runCommand ( BattleMenu *  task,
BattleMenuChildren *  children 
)

The player's turn (EVENT_PLAYER_TURN): drops the partner's queued technique and running away, then loses the turn to FIGHTER_PARALYZED, goes on to WFIGHTMN_runConfusedCommand when FIGHTER_CONFUSED, or lets the player pick a command and starts the state or the task that runs it.

The states in WFIGHTMN_states.

< a technique of the partner's, run as its command

< loses turns at random (FIGHTSTG_battleFuncs.testParalysis)

Definition at line 233 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_digivolve()

void WFIGHTMN_digivolve ( BattleMenu *  task,
BattleMenuChildren *  children 
)

The state that changes the current partner's Digimon to the one picked (commands->digimon), then says so.

Definition at line 320 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_tag()

void WFIGHTMN_tag ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Swaps the partner on the field for the one picked (children->commands): message 0x38, then the swap effect with current[0] set to the new partner's slot for it, then the switch itself and message 0x39.

Definition at line 350 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_pairTech()

void WFIGHTMN_pairTech ( BattleMenu *  task,
BattleMenuChildren *  children 
)

State 6, the pair technique (the player turn's action 6): the outgoing and incoming partners do commands->pairTech, then the incoming one tags in (state 5, past its message) while an enemy is left; otherwise the turn ends with the partner marked as fought.

Definition at line 428 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_endBattle()

void WFIGHTMN_endBattle ( BattleMenu *  task,
BattleMenuChildren *  children 
)

After a won battle, picks the enemy whose item the player may get; saves the partners' HP and MP, fades out and requests the next mode.

< a side ran away

< a side ran away

< its third enemy; winning plays the ending

< STFGTREP

< STDWTITL's title screen; its movies follow

Definition at line 456 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_runAway()

void WFIGHTMN_runAway ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Asks FIGHTSTG (FIGHTSTG_battleFuncs.testRunAway) whether the current action's actor gets away; if so shows message 0x43 (a partner) or 0x5F (an enemy) and waits for the window to close, otherwise sets the event's time from getDelay.

< a side ran away

Definition at line 569 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_endAutoRecover()

void WFIGHTMN_endAutoRecover ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Removes the current action's EVENT_RECOVERY event, unless the partner it is for has WFIGHTMN_RECOVERY_ITEM equipped.

Definition at line 606 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_recover()

void WFIGHTMN_recover ( BattleMenu *  task,
BattleMenuChildren *  children 
)

A fighter's recovery (EVENT_RECOVERY): unless its HP is full, plays technique 0xBD on it when it is the side's active fighter, shows message 0xA with the amount and adds it, up to the maximum.

Definition at line 637 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_clearField()

void WFIGHTMN_clearField ( BattleMenu *  task,
BattleMenuChildren *  children 
)

EVENT_CLEAR_FIELD: shows message 0x6A and ends the element boost (FIGHTSTG_battle.state.boost.element)

Definition at line 681 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_takeDamage()

void WFIGHTMN_takeDamage ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Carries out the current action's damage (FIGHTSTG_battleFuncs.getDamage) on its unit.

Definition at line 692 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_cureStatus()

void WFIGHTMN_cureStatus ( BattleMenu *  task,
BattleMenuChildren *  children 
)

States 13-15: end the current action's unit's paralysis, confusion or sleep.

< loses turns at random (FIGHTSTG_battleFuncs.testParalysis)

< can't act or run away; a hit may wake it up

Definition at line 754 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_endBoost()

void WFIGHTMN_endBoost ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Clears the boost (BattleFighter.boosts) that the current action ends.

Definition at line 790 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_runConfusedCommand()

void WFIGHTMN_runConfusedCommand ( BattleMenu *  task,
BattleMenuChildren *  children 
)

A confused partner's turn (FIGHTER_CONFUSED): the player's turn at step 3, where only an attack does anything.

Definition at line 816 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_endRestriction()

void WFIGHTMN_endRestriction ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Clears the restriction that the current action ends (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE) from its unit.

Definition at line 839 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_blast()

void WFIGHTMN_blast ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Digivolves the current partner for the battle, to the Digimon its level reaches (DigimonData.blastForms), and heals it when the change ends.

< the fighters'

< 10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP

Definition at line 865 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_endBlast()

void WFIGHTMN_endBlast ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Turns the current partner back into the Digimon it was (prevId)

Definition at line 933 of file menu.c.

Here is the call graph for this function:

◆ announceKnockOut()

static void announceKnockOut ( BattleMenu *  task,
BattleMenuChildren *  children,
QueuedEvent *  action 
)
inlinestatic

Takes the fallen fighter's event off the queue, shows message 0x50 or 0x51 and clears its status, ending the partner's special.

Definition at line 959 of file menu.c.

Referenced by WFIGHTMN_knockOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endBattleOnKnockOut()

static void endBattleOnKnockOut ( BattleMenu *  task,
BattleMenuChildren *  children,
QueuedEvent *  event 
)
inlinestatic

With no fighter left on the side, ends the battle: lost (message 0x53) or won (message 0x52, the partner's motion 0xD and, but in BATTLE_KIND_FINAL_LAST, the win jingle)

< GAMEOVER: a battle lost (WFIGHTMN endBattleOnKnockOut)

< its third enemy; winning plays the ending

< W_JINGLE: a battle won

< the fighters'

Definition at line 998 of file menu.c.

Referenced by WFIGHTMN_knockOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bringSecondEnemy()

static void bringSecondEnemy ( BattleMenu *  task,
BattleMenuChildren *  children 
)
inlinestatic

In BATTLE_KIND_FINAL, brings in the enemy's second fighter in place of the first, then lets the enemy's turn come at once.

< its second enemy

Definition at line 1025 of file menu.c.

Referenced by WFIGHTMN_knockOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WFIGHTMN_knockOut()

void WFIGHTMN_knockOut ( BattleMenu *  task,
BattleMenuChildren *  children 
)

EVENT_KNOCK_OUT (substate 0x15), a fighter's fall: case 0 takes its event off the queue, shows message 0x50 or 0x51 and clears its status (announceKnockOut); case 1 looks for the side's next fighter standing.

The player's side picks one (FIGHTSTG_setPlayerTurnStep(4)), the enemy's brings in the first; with none left the battle ends (endBattleOnKnockOut: 0x53 lost, 0x52 won). Case 5 brings in the enemy's second fighter in BATTLE_KIND_FINAL (bringSecondEnemy).

< battle 0x144, the last one: its first enemy

Definition at line 1064 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_endSpecial()

void WFIGHTMN_endSpecial ( BattleMenu *  task,
BattleMenuChildren *  children 
)

The end of the partner's special state (EVENT_SPECIAL_END): clears it and shows message 0x59.

Definition at line 1150 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_digidevolve()

void WFIGHTMN_digidevolve ( BattleMenu *  task,
BattleMenuChildren *  children 
)

EVENT_DIGIDEVOLVE: the partner goes back to its own form, its blast and its queued technique are dropped, and it comes in again with message 0x47.

< a technique of the partner's, run as its command

Definition at line 1166 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_showWon()

void WFIGHTMN_showWon ( BattleMenu *  task,
BattleMenuChildren *  children 
)

Shows the won message (from WFIGHTMN_knockOut) for its time, then closes it.

Definition at line 1204 of file menu.c.

◆ WFIGHTMN_bringLastEnemy()

void WFIGHTMN_bringLastEnemy ( BattleMenu *  task,
BattleMenuChildren *  children 
)

The enemy's third fighter comes in (BATTLE_KIND_FINAL_LAST), takes the first's place, and technique 440 is made from 443 with FIGHTSTG_battle.state.tech's effect (its look from WFIGHTMN_effectVisuals) and element (from WFIGHTMN_elementVisuals) before message 0x16 names it (?)

< its third enemy; winning plays the ending

< under it, the technique has none

< does nothing but for the enemy whose battle table entry lists it first

< the enemy's item

< under it, the technique has none

Definition at line 1230 of file menu.c.

Here is the call graph for this function:

◆ WFIGHTMN_restoreEnemy()

void WFIGHTMN_restoreEnemy ( BattleMenu *  task,
BattleMenuChildren *  children 
)

The end of the enemy's weakness (EVENT_WEAKNESS_END): its lowered stats come back and it takes its turn first.

Definition at line 1315 of file menu.c.

◆ WFIGHTMN_runTurn()

void WFIGHTMN_runTurn ( BattleMenu *  task)

The battle menu's main state: waits for FIGHTSTG's turn (FIGHTSTG_events.funcs.pop), then runs the state of the command it gets (WFIGHTMN_states)

< FIGHTSTG_endBattle

< its second enemy

< its third enemy; winning plays the ending

< the damage of a poisoned fighter (FIGHTER_POISONED)

< 10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP

< 10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP

< 10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP

< 13-15: the end of a boost, by the stat

< 13-15: the end of a boost, by the stat

< 13-15: the end of a boost, by the stat

< 16-17: the end of a restriction (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE)

< 16-17: the end of a restriction (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE)

< the partner's digivolution for the battle

< the end of the partner's special state

< the last battle's third enemy comes in

< the end of the enemy's weakness (BATTLE_KIND_FINAL_LAST)

Definition at line 1333 of file menu.c.

Referenced by WFIGHTMN_updateMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WFIGHTMN_start()

Task * WFIGHTMN_start ( void  )

WFIGHTMN's entry point: creates the battle menu, and zeroes FIGHTSTG_battle's state and BATTLE_RESULT.

< WFIGHTMN's battle menu

Definition at line 1455 of file menu.c.

Referenced by FIGHTSTG_updateRoot().

Here is the call graph for this function:
Here is the caller graph for this function: