24 for (i = 0; i < 6; i++) {
44 { { 0 } }, { 0 }, 0, 0, 0, 0,
58 if (event->
delay <= 0) {
61#elif VERSION_EU || VERSION_JP
62 if (event->
delay < 2) {
66 for (i = 0; i < 99; i++) {
73#elif VERSION_EU || VERSION_JP
88#if VERSION_EU || VERSION_JP
93 for (i = 0; i < 99; i++) {
95#if VERSION_EU || VERSION_JP
113 for (i = 0; i < 99; i++) {
132#elif VERSION_EU || VERSION_JP
135 for (i = 0; i < 99; i++) {
163 if (type < 1 || type > 24) {
166 for (i =
start; i < 99; i++) {
206 for (i = 0; i < 99; i++) {
215 { 1000, 707, 1414 }, { 250, 176, 353 }, { 2001, 1001, 0 }, { 2000, 0, 0 },
216 { 2500, 0, 0 }, { 3000, 0, 0 }, { 3500, 0, 0 }, { 4000, 0, 0 },
217 { 0, 2000, 6000 }, { 500, 1000, 0 }, { 500, 1000, 0 }, { 500, 500, 0 },
282 for (i = 0; i < 10; i++) {
283 root = (root + square / root) / 2;
339 if (fighters[fighter].
id == 0) {
342 fighters[fighter].
flags &= ~FIGHTSTG_statusFlags[kind];
350 for (i = 0; i < 6; i++) {
397 s32 other = side != 0;
423 queued->
args[2] = 0xBD;
464 queued->
args[2] = damage;
482 s32 other = side != 0;
507 s32 other = side != 0;
536 s32 other = side != 0;
553 entry->
sleep = strength;
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 EVENT_AUTO_RECOVER_END
#define EVENT_STATUS_DAMAGE
the damage of a poisoned fighter (FIGHTER_POISONED)
#define EVENT_END_BATTLE
The types of the battle's events: WFIGHTMN runs a state for each (WFIGHTMN_runTurn)
#define FIGHTER_POISONED
BattleFighter.flags: the statuses, which the techniques give (FIGHTSTG_inflict*) and events of type E...
#define BATTLE_STAT_SPEED
physical accuracy, evasion and running away
#define EVENT_CLEAR_FIELD
#define EVENT_PLAYER_TURN
#define EVENT_BOOST_END
13-15: the end of a boost, by the stat
#define BATTLE_STAT_SPIRIT
magic damage, and against it
#define EVENT_STATUS_END
10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP
#define EVENT_RESTRICTION_END
16-17: the end of a restriction (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE)
#define FIGHTER_ASLEEP
can't act or run away; a hit may wake it up
s32 FIGHTSTG_findNextEvent(void)
FIGHTSTG_events.funcs.next: the next queued event of the same type, or -1.
void FIGHTSTG_cureStatus(u8 side, s32 fighter, s32 item)
An item's cure (FIGHTSTG_events.funcs.cureStatus): items 0xBE-0xC5 clear a status of the fighter and ...
EventDelay FIGHTSTG_eventDelays[]
the delay ranges of FIGHTSTG_getEventDelay's kinds
void FIGHTSTG_inflictConfusion(u8 side, s32 fromTech, u8 strength)
Confuses side's active fighter (FIGHTER_CONFUSED) with a strength, and queues its end (put off by the...
void FIGHTSTG_queueRecovery(u8 side, s32 fighter, s32 big)
Queues a fighter's recovery of HP (event 6, with what getHeal takes as big), or sets the one already ...
void FIGHTSTG_queueAutoRecoverEnd(u8 side)
Queues the end of side's automatic recovery (item 0xBD), or pushes back the one already queued.
void FIGHTSTG_queueClearField(s32 time)
Queues the field's clearing in time (at most 0x7FFF), or moves the one already queued to it.
void FIGHTSTG_pushEventFirst(BattleEvent *event)
FIGHTSTG_events.funcs.pushFirst: queues an event ahead of all the others, which wait its delay longer...
void FIGHTSTG_inflictParalysis(u8 side, s32 unused, u8 strength)
Paralyzes side's active fighter (FIGHTER_PARALYZED) with a strength, and queues its end,...
s32 FIGHTSTG_boostEvents[]
the event types of FIGHTSTG_queueBoostEnd, by the stat boosted
void FIGHTSTG_inflictPoison(u8 side, s32 fighter, s32 damage)
Poisons a fighter (FIGHTER_POISONED), and queues its damage or updates the one already queued.
void FIGHTSTG_removeEvents(EventKey *key)
FIGHTSTG_events.funcs.remove: drops every queued event of key's side and fighter.
u8 FIGHTSTG_statusFlags[]
and the flags it clears with them (all six for kind 3)
s32 FIGHTSTG_eventPopModes[]
per event type, whether FIGHTSTG_popEvent takes (1), peeks at (-1) or drops (0) it
s32 FIGHTSTG_getEventDelay(u8 side, s32 kind)
FIGHTSTG_events.funcs.getDelay: the time until side's next event of kind (FIGHTSTG_eventDelays): rand...
void FIGHTSTG_inflictSleep(u8 side, s32 unused, u8 strength)
Puts side's active fighter to sleep (FIGHTER_ASLEEP) with a strength, and queues its end,...
void FIGHTSTG_endBattle(s32 result)
Ends the battle: queues event 1 ahead of the others, with how it ended (BATTLE_FLED,...
void FIGHTSTG_pushEvent(BattleEvent *event)
FIGHTSTG_events.funcs.push: queues an event in the first free one of the 99 slots,...
void FIGHTSTG_queuePlayerTurn(s32 delay)
Queues the player's turn (event 2) in delay.
void FIGHTSTG_queueRunAway(u8 side)
Queues side's attempt to run away (event 4)
EventQueue FIGHTSTG_events
the battle's events and their functions
u8 FIGHTSTG_statusEvents[]
the status events FIGHTSTG_cureStatus clears, by kind of status,
s32 FIGHTSTG_findEventFrom(s32 start)
The first queued event from slot start of the type being looked for (FIGHTSTG_events....
s32 FIGHTSTG_findEvent(s32 type, u8 side, s32 fighter)
FIGHTSTG_events.funcs.find: the first queued event of type for side's fighter, or -1.
s32 FIGHTSTG_findFirstEvent(s32 type)
FIGHTSTG_events.funcs.first: the first queued event of type, or -1.
s32 FIGHTSTG_popEvent(void)
Pops the next event: the one due soonest (in EU, events of types 2 and 3 give way to any due no later...
void FIGHTSTG_queueEnemyTurn(s32 delay)
Queues the enemy's turn (event 3) in delay.
void FIGHTSTG_queueBoostEnd(u8 side, s32 fighter, s32 kind, s32 tech)
Queues the end of a fighter's boost of stat kind, 12 frames on when a technique (tech) gave it and 8 ...
FIGHTSTG.PRO: the battle.
BattleEvent FIGHTSTG_newEvent
what FIGHTSTG_pushEvent is given
Task * start(void)
The mode's entry point (MODE_ENTRY_POINTS): starts its root task (update_scene.inc....
An event of the battle, as it is queued (FIGHTSTG_pushEvent)
s32 type
EVENT_END_BATTLE...
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
u8 paralysis
FIGHTER_PARALYZED's strength.
u8 sleep
FIGHTER_ASLEEP's.
u8 confusion
FIGHTER_CONFUSED's.
BattleStats *(* computeStats)(u8 side, s32 which, s32 index)
s32 active[2]
each side's fighter
BattleFighter fighters[2][3]
A side's stats as FIGHTSTG_computeStats works them out.
s16 stats[5]
with the fighter's boosts
An event kind's delay range (FIGHTSTG_eventDelays, by kind): FIGHTSTG_getEventDelay adds a random par...
What FIGHTSTG_removeEvents removes the events of: an event's first two args, as FIGHTSTG_queueRecover...
s32 fighter
its index in the side's fighters
u8 side
SIDE_PLAYER or SIDE_ENEMY.
u8 statusStrength
getDelay's, for the end of a status (kinds 9 to 11)
u8 result
the battle's, for WFIGHTMN (BATTLE_FLED...)
s32(* find)(s32 type, u8 side, s32 fighter)
The battle's events (FIGHTSTG_events)
s8 curIndex
and where it is
s8 findType
what first and next look for, 1-24
s8 curType
the type of the event popped last
s8 found
the event they found, or -1
A queued event: its time counts down to when it runs.
s16 type
0 for a free entry
s32(* next)(void)
0 to RANDOM_COUNT - 1