22 if (fighter->
boosts[0] != 0) {
26 fighter->
boosts[0] -= atk - def;
27 if (fighter->
boosts[0] < min) {
36 if (fighter->
boosts[1] != 0) {
40#if VERSION_EU || VERSION_JP
41 fighter->
boosts[1] -= def - atk;
43 fighter->
boosts[1] -= atk - def;
45 if (fighter->
boosts[1] < min) {
55 }
else if (task->
lowered == 2) {
128 if (task->
item >= 0x2B && task->
item < 0x2F) {
130 }
else if (task->
item == 0x47) {
142 switch (task->
step) {
147 switch (task->
item) {
200 if (task->
item == 0x5A) {
208 if (children[0].script ==
NULL) {
221 if (children[0].script ==
NULL) {
238 { 0x2B, 0x21, 0x1F },
239 { 0x2C, 0x21, 0x1F },
240 { 0x2D, 0x21, 0x1F },
241 { 0x2E, 0x21, 0x1F },
242 { 0x42, 0x22, 0x1F },
243 { 0x43, 0x22, 0x1F },
244 { 0x44, 0x22, 0x1F },
245 { 0x45, 0x22, 0x1F },
246 { 0x46, 0x23, 0x1F },
247 { 0x47, 0x21, 0x1F },
248 { 0x48, 0x28, 0x1F },
249 { 0x49, 0x24, 0x1F },
250 { 0x4A, 0x26, 0x1F },
251 { 0x4B, 0x2E, 0x1E },
252 { 0x4C, 0x2E, 0x1E },
264 if (fighter->
maxHp == fighter->
hp) {
266 task->
lines[0] = 0x2F;
275 heal = fighter->
maxHp - fighter->
hp;
280 task->
lines[1] = heal;
292 switch (task->
item) {
309 fighter->
flags &= ~cure->flag;
315 task->
lines[0] = 0x2F;
326 switch (task->
step) {
335 if (children[0].task ==
NULL) {
336 for (i = 0; i < 3; i++) {
346 if (children[0].task ==
NULL) {
361 if (fighter->
hp != fighter->
maxHp || fighter->
mp != fighter->
maxMp) {
365 half = fighter->
maxHp / 2;
366 halfMp = fighter->
maxMp / 2;
367 if (fighter->
hp + half >= fighter->
maxHp) {
372 if (fighter->
maxMp <= fighter->
mp + halfMp) {
375 fighter->
mp += halfMp;
377 task->
lines[0] = 0x3B;
381 task->
lines[0] = 0x2F;
398 if (fighter->
boosts[2] != 0) {
403 if (fighter->
boosts[2] > max) {
408 task->
lines[0] = 0x32;
426 if (fighter->
boosts[0] != 0) {
429 if (fighter->
boosts[1] != 0) {
434 if (fighter->
boosts[0] > max) {
439 if (fighter->
boosts[1] < min) {
445 task->
lines[0] = 0x3C;
462 if (fighter->
boosts[0] != 0) {
465 if (fighter->
boosts[1] != 0) {
470 if (fighter->
boosts[1] > max) {
475 if (fighter->
boosts[0] < min) {
481 task->
lines[0] = 0x3D;
495 task->
lines[0] = 0x3E;
513 task->
lines[0] = 0x3F;
548 task->
lines[0] = 0x10;
551 if (fighter->
hp - task->
damage <= 0) {
560 if (fighter->
hp > fighter->
maxHp) {
566 task->
lines[0] = 0x2F;
582 switch (task->
step) {
588 task->
lines[0] = 0x20;
589 task->
lines[1] = 0x10;
599 task->
lines[0] = 0x2F;
605 if (children[0].task ==
NULL) {
609 task->
lines[0] = 0x20;
632 if (enemy->
boosts[0] != 0) {
635 if (enemy->
boosts[1] != 0) {
638 enemy->
boosts[0] += atk * 3 / 10;
639 enemy->
boosts[1] -= def / 2;
641 if (enemy->
boosts[0] > max) {
650 task->
lines[0] = 0x40;
651 task->
lines[1] = 0x10;
657 task->
lines[0] = 0x2F;
668 task->
lines[0] = 0x33;
669 task->
lines[1] = 0x10;
676 task->
lines[0] = 0x34;
677 task->
lines[1] = 0x10;
683 task->
lines[0] = 0x2F;
702 if (enemy->
boosts[2] != 0) {
707 if (enemy->
boosts[2] < min) {
712 task->
lines[0] = 0x35;
713 task->
lines[1] = 0x10;
720 task->
lines[0] = 0x2F;
731 task->
lines[0] = 0x10;
735 if (enemy->
hp - task->
damage <= 0) {
743 task->
lines[0] = 0x1D;
744 task->
lines[1] = 0x10;
762 switch (task->
state) {
785 if (children[0].task ==
NULL) {
790 switch (task->
item) {
846 if (children[0].task ==
NULL) {
857 if (children[0].task ==
NULL) {
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
void FIGHTSTG_queueSpecialEnd(void)
Queues the end of the partner's special state (event 21): the USA version pushes back the one already...
BattleFuncs FIGHTSTG_battleFuncs
the battle's stats and the functions that compute with them
void FIGHTSTG_queueKnockOut(u8 side)
Queues the fall of side's active fighter (event 20), first.
#define BATTLE_STAT_ATTACK
BattleStats.stats' indices: the partner's first five battle stats.
#define BATTLE_STAT_SPEED
physical accuracy, evasion and running away
#define ACTIVE_FIGHTER(side)
SIDE's active fighter as its row plus the index, which GCC adds with the row's address first.
#define BATTLE_KIND_FINAL_LAST
its third enemy; winning plays the ending
#define BATTLE_STAT_DEFENSE
against it
#define SIDE_PLAYER
The battle's sides, as the functions that take a side want them: side >> 4 is its row of FIGHTSTG_bat...
#define ELEMENT_FIRST
The elements (TechData.element, BattleStats.element) and the families (TechData.family,...
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_queueClearField(s32 time)
Queues the field's clearing in time (at most 0x7FFF), or moves the one already queued to it.
EventQueue FIGHTSTG_events
the battle's events and their functions
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.
BattleScript * FIGHTSTG_createBattleScript(void)
Creates a battle script, which plays a technique (FIGHTSTG_updateBattleScript)
EnemyAttack * FIGHTSTG_startEnemyAttack(s32 kind, s32 noKnockout)
Starts an attack on the player's active fighter (FIGHTSTG_updateEnemyAttack): kind 0 for the enemy's ...
GameState GAME
The save data, the game mode and the methods.
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
#define BATTLE_BLOCK_LOWER_ATTACK
to 10: attack, defense, speed (a technique's boost stat + 8)
#define BATTLE_BLOCK_LOWER_SPEED
#define BATTLE_BLOCK_CONFUSION
#define BATTLE_BLOCK_LOWER_DEFENSE
#define BATTLE_BLOCK_DRAIN
static void lowerEnemyStat(BattleItem *task, BattleChild *children)
Item 0x58's setup: lowers the higher of the enemy's attack and defense (when that is the defense,...
static void boostRandomElement(BattleItem *task, BattleChild *children)
Item 0x54: boosts the element its script picked at random on the field.
static void boostDefense(BattleItem *task, BattleChild *children)
Item 0x4A: raises the partner's defense and lowers its attack.
s32 FIGHTSTG_runItemScript(BattleItem *task, BattleChild *children)
An item's script (FIGHTSTG_updateItem): step 0 sets it up and deals the damage (lowerEnemyStat,...
static void setUpDrain(BattleItem *task, BattleChild *children)
Item 0x55's setup: its drain of 20 percent of the enemy's max HP, unless the battle blocks draining.
BattleItem * FIGHTSTG_startItem(s32 item)
Starts an item's script (FIGHTSTG_updateItem)
static void boostAttack(BattleItem *task, BattleChild *children)
Item 0x49: raises the partner's attack and lowers its defense.
static void confuseFighters(BattleItem *task, BattleChild *children)
Item 0x56: confuses the enemy half of the time, unless the battle blocks it, and then the partner a q...
StatusCure FIGHTSTG_itemCures[4]
what items 0x42-0x45 cure (FIGHTSTG_updateItem, below)
static void fillGauge(BattleItem *task, BattleChild *children)
Item 0x4C: fills the partner's gauge by the item's amount, up to 999.
static void showLoweredStat(BattleItem *task, BattleChild *children)
Item 0x58: says which of the enemy's stats its script lowered.
ItemScript FIGHTSTG_itemScripts[]
the items' script settings (FIGHTSTG_runItemScript, above)
static void setItemScript(BattleItem *task, BattleChild *children)
The other items' setup: their effect and sound from FIGHTSTG_itemScripts, and the partner's idle moti...
static void drainEnemy(BattleItem *task, BattleChild *children)
Item 0x55: drains the damage from the enemy to the partner, or says it does nothing when the battle b...
static void boostElement(BattleItem *task, BattleChild *children)
Items 0x4D-0x53: boost one element on the field.
void FIGHTSTG_updateItem(BattleItem *task, BattleChild *children)
An item used in battle (FIGHTSTG_startItem): its message, FIGHTSTG_runItemScript's script,...
static void cureStatus(BattleItem *task, BattleChild *children)
Items 0x42-0x45: cure the partner of what FIGHTSTG_itemCures says, or say they do nothing.
static void weakenEnemyDefense(BattleItem *task, BattleChild *children)
Item 0x57: raises the enemy's attack and lowers its defense, or says it does nothing when the battle ...
static void reviveParty(BattleItem *task, BattleChild *children)
Item 0x46: revives the partners knocked out to their max HP, then is taken from the bag and ends the ...
static void restoreHalfHpMp(BattleItem *task, BattleChild *children)
Item 0x47: restores half the partner's max HP and MP, or says it does nothing when both are full.
static void setUpItemTech(BattleItem *task, BattleChild *children)
Item 0x5A's setup: the script of technique 0x89 and its magic damage to the enemy.
static void lowerEnemySpeed(BattleItem *task, BattleChild *children)
Item 0x59: lowers the enemy's speed, or says it does nothing when the battle blocks it.
static void damageEnemy(BattleItem *task, BattleChild *children)
Item 0x5A: deals its technique's damage to the enemy.
static void healPartner(BattleItem *task, BattleChild *children)
Items 0x2B-0x41: heal the partner by the item's amount, up to its max HP.
static void boostSpeed(BattleItem *task, BattleChild *children)
Item 0x48: raises the partner's speed by the item's amount in 128ths, up to double.
static void startSpecial(BattleItem *task, BattleChild *children)
Item 0x4B: puts the partner in its special state, which doubles its effects.
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
BattleMessageBox * FIGHTSTG_createMessage(void)
Creates a battle message box (FIGHTSTG_updateMessage)
void WFIGHTMN_checkEquip(s32 member)
Queues a recovery (FIGHTSTG_queueRecovery) for party member MEMBER's partner when it has WFIGHTMN_REC...
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
s16 boosts[4]
added to the stats FIGHTSTG_boostStats picks
s32(* computeMagicDamage)(u8 side, s32 id)
BattleStats *(* computeStats)(u8 side, s32 which, s32 index)
FIGHTSTG_updateItem's task: an item used in battle, FIGHTSTG_runItemScript its script.
void(* nextState)(struct BattleItem *task)
void(* nextSubstate)(struct BattleItem *task)
s32 element
item 0x54's element, 2-8
void(* setState)(struct BattleItem *task, s32 state)
s32 lines[8]
FIGHTSTG_updateMessage's, 0 ends them.
void(* nextStep)(struct BattleItem *task)
s32 lowered
item 0x58's: 1 it lowered the enemy's first stat, 2 its second
void(* show)()
FIGHTSTG_showMessage: (task, type, data)
s32 enemy
the script is the enemy's (nonzero) or the partner's
s32 sound
what the sound commands' 0x62 and 0x63 stand for on a hit
s32 effect
the sprite effect the effect command's 9999 stands for
s32 hits[4]
0 a hit, 3 a miss; [3] how it ended
s32 index
the script, in the fighter's archive
s32 stage
what the stage command's 0x38 stands for
s16 gauges[8]
filled in battle, up to 1000
u8 blocks[12]
by BATTLE_BLOCK_*: what the player can't do in the battle
s32 active[2]
each side's fighter
BattleFighter fighters[2][3]
s16 kind
the kind of battle
A side's stats as FIGHTSTG_computeStats works them out.
s16 stats[5]
with the fighter's boosts
s16 element
under ELEMENT_FIRST: none
s32(* getDelay)(u8 side, s32 kind)
FIGHTSTG_getEventDelay: when an event of side's runs.
void(* cureStatus)(u8 side, s32 fighter, s32 item)
FIGHTSTG_cureStatus: an item's cure.
s32(* getPartyMember)(u32 index)
s8 items[0x193]
counts, up to 99
What a usable item does (its ItemInfo.data, an ITEM_EFFECT_*)
u16 amount
the HP it heals, the gauge it fills, a boost in 128ths
struct ItemInfo *(* get)(s32 item)
getItem
ItemRecord data
the type's record, or the usable items' effect
An item's script settings (FIGHTSTG_itemScripts, ended by -1)
s16 effect
BattleScript's.
s32(* next)(void)
0 to RANDOM_COUNT - 1
What an item cures (FIGHTSTG_itemCures, items 0x42-0x45)
s16 flag
in BattleFighter.flags
s32 item
FIGHTSTG_events.funcs.cureStatus's.
Any task, seen through its header.
A technique (TECHS, from 1: technique n is TECHS[n - 1])
u8 scriptSound
its script's hit sound (BattleScript.sound)
u8 scriptEffect
its script's sprite effect (BattleScript.effect)
u8 scriptStage
its script's stage (BattleScript.stage)
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
s32 WFIGHTMN_limitDamage(u8 side, s32 damage, s32 hits)
In BATTLE_KIND_ESCAPE and BATTLE_KIND_UNK2, cuts the damage that the partner's hits do so that the en...
void WFIGHTMN_countHit(u8 side, s32 damage)
In BATTLE_KIND_FINAL_LAST, the partner's third hit that does damage weakens the enemy (FIGHTSTG's FIG...
void WFIGHTMN_endWeakness(u8 side)
In BATTLE_KIND_FINAL_LAST, anything the partner does but an attack ends the enemy's weakness (FIGHTST...
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...
BattleMessageBox * message
FIGHTSTG_createMessage.
BattleScript * script
a technique's (FIGHTSTG_createBattleScript)
EnemyAttack * enemyAttack
an attack on the player's fighter (FIGHTSTG_startEnemyAttack)