Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
boosts.c
Go to the documentation of this file.
1/* FIGHTSTG's stat boosts, the technique gauge's gain and the techniques' MP
2 cost. */
3
5
6/* the stat of BattleStats.stats that each of BattleFighter.boosts adds to */
8 0x0000, 0x0001, 0x0004, 0x0000,
9};
10
11/* Changes a fighter's stat boost by percent 128ths of the stat without it,
12 between minus half the stat and the stat; nothing for an empty or
13 knocked-out fighter */
14void FIGHTSTG_changeBoost(u8 side, s32 index, s32 stat, s32 percent) {
15 BattleStats *stats;
16 BattleFighter *fighter;
17 s32 value;
18 s32 min;
19
20 if (side == 0) {
21 stats = FIGHTSTG_computeStats(SIDE_PLAYER, 0, index);
22 fighter = &FIGHTSTG_battle.state.fighters[0][index];
23 } else {
24 stats = FIGHTSTG_computeStats(SIDE_ENEMY, 0, index);
25 fighter = &FIGHTSTG_battle.state.fighters[1][index];
26 }
27 if (fighter->id == 0 || fighter->hp == 0) {
28 return;
29 }
30 if (fighter->boosts[stat] != 0) {
31 stats->stats[FIGHTSTG_boostStats[stat]] -= fighter->boosts[stat];
32 }
33 value = stats->stats[FIGHTSTG_boostStats[stat]];
34 min = -(value / 2);
35 fighter->boosts[stat] += value * percent / 128;
36 if (fighter->boosts[stat] < min) {
37 fighter->boosts[stat] = min;
38 }
39 if (fighter->boosts[stat] > value) {
40 fighter->boosts[stat] = value;
41 }
42}
43
44/* What the partner's damage adds to the gauge: the square of its percent of
45 the max HP over 20, more with accessories 0x149 and 0x14A, at most 1000 */
47 PartnerStats *partner;
48 s32 ratio;
49 BattleFighter *fighter;
50 s32 value;
51 s32 i;
52 s16 *acc;
53
55 ratio = damage * 100 / fighter->maxHp;
56 value = ratio * ratio / 20;
58 acc = &partner->equip[4];
59 for (i = 0; i < 2; i++) {
60 if (acc[i] == 0x149) {
61 value += value / 5;
62 } else if (acc[i] == 0x14A) {
63 value += value * 4 / 10;
64 }
65 }
66 if (value > 1000) {
67 value = 1000;
68 }
69 return value;
70}
71
72/* A technique's MP cost; accessories 0x143 and 0x144 cut the player's, to no
73 less than 1 */
75 PartnerStats *partner;
76 s32 cost;
77 s32 extra;
78 s16 item;
79
80 cost = TECHS[(id & 0x1FFF) - 1].mp;
81 if (side != 0) {
82 return cost;
83 }
85 item = 0;
86 if (partner->equip[4] == 0x143 || partner->equip[4] == 0x144) {
87 item = partner->equip[4];
88 }
89 if (partner->equip[5] == 0x143 || partner->equip[5] == 0x144) {
90 item = partner->equip[5];
91 }
92 if (item != 0) {
93 /* the game reads this amount signed */
94 cost -= (s16)ITEM_FUNCS.get(item)->data.acc->amount;
95 if (cost <= 0) {
96 cost = 1;
97 }
98 }
99 if (id & 0x4000) {
100 extra = cost / 5;
101 if (extra != 0) {
102 cost += extra;
103 } else {
104 cost++;
105 }
106 }
107 return cost;
108}
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
Definition battle.c:16
#define SIDE_PLAYER
The battle's sides, as the functions that take a side want them: side >> 4 is its row of FIGHTSTG_bat...
Definition battle.h:177
#define SIDE_ENEMY
Definition battle.h:178
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.
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
s16 FIGHTSTG_boostStats[]
the stat of BattleStats.stats that each of BattleFighter.boosts adds to
Definition boosts.c:7
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned char u8
Definition common.h:8
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
ItemFuncs ITEM_FUNCS
Definition items.c:890
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
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
s16 id
the Digimon (DIGIMON_DATA)
Definition battle.h:192
s16 boosts[4]
added to the stats FIGHTSTG_boostStats picks
Definition battle.h:200
s32 active[2]
each side's fighter
Definition battle.h:226
BattleFighter fighters[2][3]
Definition battle.h:227
A side's stats as FIGHTSTG_computeStats works them out.
Definition battle.h:305
s16 stats[5]
with the fighter's boosts
Definition battle.h:307
BattleState state
Definition battle.h:240
struct PartnerStats *(* getPartnerStats)(s32 partner)
Definition game_state.h:38
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
GameFuncs funcs
Definition game_state.h:582
struct ItemInfo *(* get)(s32 item)
getItem
Definition game_state.h:670
ItemRecord data
the type's record, or the usable items' effect
Definition game_state.h:226
A partner Digimon from its name on (Partner.info), as getPartnerStats gives it.
Definition game_state.h:303
AccessoryData * acc
Definition game_state.h:214