Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
battle.c
Go to the documentation of this file.
1/* FIGHTSTG's battle state (FIGHTSTG_action, FIGHTSTG_battle and
2 FIGHTSTG_battleFuncs) and the events of the partner's special techniques. */
3
5
6/* the event types of FIGHTSTG_startRestriction, by whether the technique's effect is TECH_EFFECT_NO_DIGIVOLVE */
10
11/* the command being carried out */
13 { 0 }, 0, 0, 0, 0, { 0 }, 0, 0, { 0 }, { 0 }, FIGHTSTG_startAction,
14};
15/* the battle: its fighters, speed and drawing functions */
17 0, 0, { { 0 }, { { { 0 } } }, { 0, 0 }, 0, 0, 0, 0, 0 }, { 0, 0 },
19};
20/* the fighters' data, loaded one at a time */
24/* the battle's stats and the functions that compute with them */
38
39/* Restricts the partner with technique tech: sets FIGHTER_NO_SWITCH or
40 FIGHTER_NO_DIGIVOLVE by the technique's effect, and queues the
41 restriction's end (by its effectPower) or pushes back the one already
42 queued */
44 TechData *entry = &TECHS[tech - 1];
45 s32 kind;
46 s32 fighter;
47 s32 i;
48 s32 time;
49 BattleFighter *target;
50
51 kind = 0;
52 if (entry->effect != TECH_EFFECT_NO_SWITCH) {
53 kind = entry->effect == TECH_EFFECT_NO_DIGIVOLVE;
54 }
55 fighter = FIGHTSTG_battle.state.active[0];
56 i = FIGHTSTG_findEvent(FIGHTSTG_techEvents[kind], 0, fighter);
57 time = (RANDOM.next() % 101 + 100) * entry->effectPower;
58
59 if (i >= 0) {
61
62 queued->time = time;
63 } else {
67 FIGHTSTG_newEvent.args[1] = fighter;
68 FIGHTSTG_newEvent.args[2] = kind;
70 }
71 target = &FIGHTSTG_battle.state.fighters[0][fighter];
72 if (kind == 0) {
73 target->flags |= FIGHTER_NO_SWITCH;
74 } else {
75 target->flags |= FIGHTER_NO_DIGIVOLVE;
76 }
77}
78
79/* Queues the partner's technique tech, to run as its command */
88
89/* Queues the partner's digivolution for the battle (event 18), now */
95
96/* Queues the end of the partner's digivolution for the battle (event 19),
97 after delay kind + 3 */
105
106/* Queues the fall of side's active fighter (event 20), first */
114
115/* Queues the end of the partner's special state (event 21): the USA version
116 pushes back the one already queued */
118#if VERSION_US
120 s32 time = FIGHTSTG_getEventDelay(0, 8);
121
122 if (i >= 0) {
123 QueuedEvent *queued = &FIGHTSTG_events.events[i];
124
125 queued->time = time;
126 } else {
129 FIGHTSTG_newEvent.args[0] = 0;
132 }
133#elif VERSION_EU || VERSION_JP
136 FIGHTSTG_newEvent.args[0] = 0;
139#endif
140}
141
142/* Queues the partner's digidevolution, first */
150
151/* Queues the coming in of the last battle's third enemy, first */
157
158/* Weakens the enemy in BATTLE_KIND_FINAL_LAST: halves its boosts of stats 1 and 2
159 and queues the end (event 24) in 3000 */
171
172/* Ends the enemy's weakness now: its queued event 24 runs next */
175
176 if (i >= 0) {
178 }
179}
FighterCache FIGHTSTG_fighterCache
the fighters' data, loaded one at a time
Definition battle.c:21
s32 FIGHTSTG_techEvents[]
the event types of FIGHTSTG_startRestriction, by whether the technique's effect is TECH_EFFECT_NO_DIG...
Definition battle.c:7
void FIGHTSTG_queueBlast(void)
Queues the partner's digivolution for the battle (event 18), now.
Definition battle.c:90
BattleAction FIGHTSTG_action
the command being carried out
Definition battle.c:12
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
Definition battle.c:16
void FIGHTSTG_weakenEnemy(void)
Weakens the enemy in BATTLE_KIND_FINAL_LAST: halves its boosts of stats 1 and 2 and queues the end (e...
Definition battle.c:160
void FIGHTSTG_startRestriction(s32 tech)
Restricts the partner with technique tech: sets FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE by the tech...
Definition battle.c:43
void FIGHTSTG_queueSpecialEnd(void)
Queues the end of the partner's special state (event 21): the USA version pushes back the one already...
Definition battle.c:117
BattleFuncs FIGHTSTG_battleFuncs
the battle's stats and the functions that compute with them
Definition battle.c:25
void FIGHTSTG_queueDigidevolve(void)
Queues the partner's digidevolution, first.
Definition battle.c:143
void FIGHTSTG_queueLastEnemy(void)
Queues the coming in of the last battle's third enemy, first.
Definition battle.c:152
void FIGHTSTG_queueKnockOut(u8 side)
Queues the fall of side's active fighter (event 20), first.
Definition battle.c:107
void FIGHTSTG_endEnemyWeakness(void)
Ends the enemy's weakness now: its queued event 24 runs next.
Definition battle.c:173
void FIGHTSTG_queueBlastEnd(s32 kind)
Queues the end of the partner's digivolution for the battle (event 19), after delay kind + 3.
Definition battle.c:98
void FIGHTSTG_queuePartnerTech(s32 tech)
Queues the partner's technique tech, to run as its command.
Definition battle.c:80
#define EVENT_KNOCK_OUT
Definition battle.h:95
#define TECH_EFFECT_NO_DIGIVOLVE
FIGHTER_NO_DIGIVOLVE for a while.
Definition battle.h:263
#define EVENT_WEAKNESS_END
the end of the enemy's weakness (BATTLE_KIND_FINAL_LAST)
Definition battle.h:99
#define FIGHTER_NO_SWITCH
can't switch out or run away (TECH_EFFECT_NO_SWITCH)
Definition battle.h:186
#define EVENT_DIGIDEVOLVE
Definition battle.h:97
#define EVENT_LAST_ENEMY
the last battle's third enemy comes in
Definition battle.h:98
#define EVENT_BLAST_END
Definition battle.h:94
#define FIGHTER_NO_DIGIVOLVE
can't digivolve or use a switch-in technique (TECH_EFFECT_NO_DIGIVOLVE)
Definition battle.h:187
#define EVENT_SPECIAL_END
the end of the partner's special state
Definition battle.h:96
#define EVENT_PARTNER_TECH
a technique of the partner's, run as its command
Definition battle.h:88
#define EVENT_BLAST
the partner's digivolution for the battle
Definition battle.h:93
#define TECH_EFFECT_NO_SWITCH
FIGHTER_NO_SWITCH for a while.
Definition battle.h:262
#define EVENT_RESTRICTION_END
16-17: the end of a restriction (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE)
Definition battle.h:92
void FIGHTSTG_pushEventFirst(BattleEvent *event)
FIGHTSTG_events.funcs.pushFirst: queues an event ahead of all the others, which wait its delay longer...
Definition events.c:54
s32 FIGHTSTG_getEventDelay(u8 side, s32 kind)
FIGHTSTG_events.funcs.getDelay: the time until side's next event of kind (FIGHTSTG_eventDelays): rand...
Definition events.c:224
void FIGHTSTG_pushEvent(BattleEvent *event)
FIGHTSTG_events.funcs.push: queues an event in the first free one of the 99 slots,...
Definition events.c:11
EventQueue FIGHTSTG_events
the battle's events and their functions
Definition events.c:43
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.
Definition events.c:187
BattleStats * FIGHTSTG_computeStats(u8 side, s32 which, s32 index)
Works out a side's stats into its BattleStats: the partner's totals with the fighter's boosts,...
Definition stats.c:42
FIGHTSTG.PRO: the battle.
BattleTableEntry *(* FIGHTSTG_battleTableFunc)(s32 id)
how the fight stage and WFIGHTMN read the battle table
void FIGHTSTG_changeBoost(u8 side, s32 index, s32 stat, s32 percent)
Changes a fighter's stat boost by percent 128ths of the stat without it, between minus half the stat ...
Definition boosts.c:14
s32 FIGHTSTG_getGaugeGain(s32 damage)
What the partner's damage adds to the gauge: the square of its percent of the max HP over 20,...
Definition boosts.c:46
s32 FIGHTSTG_getTechCost(u8 side, s32 id)
A technique's MP cost; accessories 0x143 and 0x144 cut the player's, to no less than 1.
Definition boosts.c:74
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned char u8
Definition common.h:8
s32 FIGHTSTG_getHeal(u8 side, s32 index, s32 big)
The HP a fighter regains: 8 to 16 128ths of its max HP when big, 4 to 8 otherwise.
Definition damage.c:306
s32 FIGHTSTG_getDamage(s32 *args)
getDamage: the damage of an event (args: the side, the fighter and the base damage) to the fighter if...
Definition damage.c:196
s32 FIGHTSTG_computeDamage(u8 side, s32 id)
A technique's power from the user's attack against the target's defense (an enemy's scaled by its unk...
Definition damage.c:89
s32 FIGHTSTG_computeMagicDamage(u8 side, s32 id)
A magic technique's damage: its power by the user's spirit against the target's (half to twice as muc...
Definition damage.c:122
s32 FIGHTSTG_computeHeal(u8 side, s32 id)
The HP a healing technique restores: 64 times its power, and an eighth of it per point of the user's ...
Definition damage.c:272
s32 FIGHTSTG_computeCounterDamage(u8 side, s32 id, s32 value)
The damage of a counterattack on value: the partner's first skill deals it as one hit (the triple hit...
Definition damage.c:232
void FIGHTSTG_drawBlendedQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors)
A Gouraud-shaded quad on a layer, blended.
Definition draw.c:69
void FIGHTSTG_drawQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors)
A Gouraud-shaded quad on a layer.
Definition draw.c:64
void FIGHTSTG_projectPoint(Layer *layer, SVECTOR *pos, ShortVec3 *out)
Projects pos to the screen: its x and y, and its depth in the layer's ordering table.
Definition draw.c:8
void FIGHTSTG_cacheFighter(s32 index)
Loads entry index of the fighters file into FIGHTSTG_fighterCache: its id and kind,...
FaceRect * FIGHTSTG_getFighterFace(s32 id)
Fighter id's face parts (FaceRect), in the fighters file.
FighterInfo * FIGHTSTG_getFighterInfo(s32 id)
the match depends on reaching the cache through the symbol until a fighter is found,...
void FIGHTSTG_getFighterRange(u32 enemy, s32 *min, s32 *max)
The first and last entries of the fighters file that are enemies (enemy set) or partners.
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
BattleEvent FIGHTSTG_newEvent
what FIGHTSTG_pushEvent is given
Random RANDOM
Definition random.c:533
s32 FIGHTSTG_testWakeUp(u8 side, s32 value)
FIGHTSTG_battleFuncs.testWakeUp: whether a hit of value wakes side's fighter up, likelier the bigger ...
Definition rolls.c:510
s32 FIGHTSTG_rollCounter(s32 side, s32 damage)
FIGHTSTG_battleFuncs.rollCounter: a random test, likelier the bigger damage is next to the player's f...
Definition rolls.c:437
s32 FIGHTSTG_rollSleep(u8 side, s32 id)
Whether a hit puts the target to sleep, like rollPoison with the technique's chance (BATTLE_BLOCK_SLE...
Definition rolls.c:288
s32 FIGHTSTG_rollNoSwitch(s32 actor, s32 id)
Whether TECH_EFFECT_NO_SWITCH works: the technique's chance.
Definition rolls.c:425
s32 FIGHTSTG_rollMagicHit(u8 side, s32 id)
Whether a magic hit lands: the technique's accuracy with the wisdom and level differences; the player...
Definition rolls.c:165
s32 FIGHTSTG_rollDrain(u8 side, s32 id)
Whether a hit drains HP: the technique's chance, or the accessory's for a technique without an effect...
Definition rolls.c:367
s32 FIGHTSTG_rollNoDigivolve(s32 actor, s32 id)
Whether TECH_EFFECT_NO_DIGIVOLVE works: the technique's chance.
Definition rolls.c:430
s32 FIGHTSTG_rollDedigivolve(s32 actor, s32 id)
Whether a technique turns the player's fighter back: never when it is one of the partners' own Digimo...
Definition rolls.c:400
s32 FIGHTSTG_testParalysis(u8 side)
FIGHTSTG_battleFuncs.testParalysis: whether side's paralysis costs it the turn, a random test of its ...
Definition rolls.c:560
s32 FIGHTSTG_rollSteal(u8 side, s32 id)
Whether the player steals the enemy's item: its itemChance in 1024 by the speed ratio (at most twice)...
Definition rolls.c:325
s32 FIGHTSTG_rollHit(u8 side, s32 id)
Whether a physical hit lands: the technique's accuracy with the speed and level differences and the a...
Definition rolls.c:123
s32 FIGHTSTG_rollParalysis(u8 side, s32 id)
Whether a hit paralyzes, like rollPoison (BATTLE_BLOCK_PARALYSIS keeps the player from it)
Definition rolls.c:276
s32 FIGHTSTG_rollPoison(u8 side, s32 id)
The poison a hit inflicts, or 0: the technique's or the accessory's chance and an eighth of the user'...
Definition rolls.c:195
s32 FIGHTSTG_testRunAway(u8 side)
FIGHTSTG_battleFuncs.testRunAway: a random test for side running away, from both sides' stats; the pl...
Definition rolls.c:451
s32 FIGHTSTG_rollStatusRaise(s32 actor, s32 id)
Whether a status raise works: the technique's chance and an eighth of what the enemy's wisdom has ove...
Definition rolls.c:413
s32 FIGHTSTG_testConfusion(u8 side)
FIGHTSTG_battleFuncs.testConfusion: a random test of side's confusion against its resists 9 and 3.
Definition rolls.c:536
s32 FIGHTSTG_rollKnockOut(u8 side, s32 id)
Whether a hit knocks the target out, like rollPoison (BATTLE_BLOCK_KNOCK_OUT keeps the player from it...
Definition rolls.c:319
s32 FIGHTSTG_rollConfusion(u8 side, s32 id)
Whether a hit confuses, like rollPoison (BATTLE_BLOCK_CONFUSION keeps the player from it)
Definition rolls.c:282
void FIGHTSTG_countFrames(void)
How many frames the battle moves on this frame by its speed mode: as many as went by,...
Definition speed.c:7
void FIGHTSTG_setSpeed(s32 mode)
Sets the battle's speed mode and counts this frame again.
Definition speed.c:35
FIGHTSTG_action: the technique being carried out.
Definition battle.h:274
s32 delay
Definition battle.h:104
s32 args[6]
Definition battle.h:105
s32 type
EVENT_END_BATTLE...
Definition battle.h:103
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
Definition battle.h:191
u8 flags
FIGHTER_*.
Definition battle.h:204
s16 boosts[4]
added to the stats FIGHTSTG_boostStats picks
Definition battle.h:200
FIGHTSTG_battleFuncs.
Definition battle.h:329
s32 active[2]
each side's fighter
Definition battle.h:226
BattleFighter fighters[2][3]
Definition battle.h:227
u8 weakened
BATTLE_KIND_FINAL_LAST: the enemy is weakened (FIGHTSTG_weakenEnemy)
Definition battle.h:233
s16 stats[5]
by BATTLE_STAT_*, scaled by the enemy's strength / 16
Definition battle.h:64
FIGHTSTG_battle: the battle.
Definition battle.h:237
BattleState state
Definition battle.h:240
s32(* first)(s32 type)
Definition battle.h:144
EventQueueFuncs funcs
Definition battle.h:171
QueuedEvent events[99]
Definition battle.h:165
FIGHTSTG_fighterCache: the last fighter getInfo found, and the fighters' file's functions.
Definition model.h:265
A queued event: its time counts down to when it runs.
Definition battle.h:109
s32(* next)(void)
0 to RANDOM_COUNT - 1
Definition random.h:15
A technique (TECHS, from 1: technique n is TECHS[n - 1])
Definition game_state.h:110
u8 effect
TECH_EFFECT_* (fightstg/battle.h), under TECH_EFFECT_FIRST none.
Definition game_state.h:119
u8 effectPower
the effect's strength (a boost's amount, a drain's 128ths)
Definition game_state.h:121
void FIGHTSTG_startAction(u8 side, s32 tech)
Starts side's technique: rolls its hits and damage, then its effect or, for the player's plain techni...