Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
rolls.c
Go to the documentation of this file.
1/* FIGHTSTG's random rolls: hits, criticals, statuses and the other effects,
2 running away and the statuses' own tests. */
3
5
6/* Whether a physical hit is critical: a chance of 4 in 128 with the
7 technique's critical boost or the accessory's, more against the target's
8 family and while the target is paralyzed, asleep or confused */
10 BattleStats *atk;
11 BattleStats *def;
12 TechData *entry;
13 BattleFighter *fighter;
14 s32 chance;
15 s32 i;
16 s32 j;
17 s32 k;
18
19 if (side == 0) {
22 } else {
25 }
26 chance = 4;
29 entry = &TECHS[id - 1];
30 if (entry->effect >= TECH_EFFECT_FIRST) {
31 if (entry->effect == TECH_EFFECT_CRITICAL) {
32 chance += entry->effectPower;
33 }
34 } else if (atk->criticalBonus != 0) {
35 k = side != 0;
37 if (fighter->special) {
38 chance = atk->criticalBonus * 2 + 4;
39 } else {
40 chance = atk->criticalBonus + 4;
41 }
42 }
43 if (entry->family >= FAMILY_FIRST) {
44 if (entry->family == def->family) {
45 chance += 0x3C;
46 }
47 } else {
48 for (i = 0; i < 3; i++) {
49 if (atk->weaponFamilies[i] >= FAMILY_FIRST && atk->weaponFamilies[i] == def->family) {
50 chance += 0x10;
51 break;
52 }
53 }
54 }
55 j = side == 0;
57 if (fighter->flags & FIGHTER_PARALYZED) {
58 chance += fighter->paralysis >> 3;
59 }
60 if (fighter->flags & FIGHTER_ASLEEP) {
61 chance += fighter->sleep >> 3;
62 }
63 if (fighter->flags & FIGHTER_CONFUSED) {
64 chance += fighter->confusion >> 1;
65 }
66 return (RANDOM.next() & 0x7F) < chance;
67}
68
69/* Whether a magic hit is critical: a chance from the technique's element
70 power against the target's resistance, more against the target's family
71 and while the target is paralyzed, asleep or confused */
73 BattleStats *def;
74 TechData *entry;
75 BattleFighter *fighter;
76 s32 value;
77 s32 chance;
78 s32 j;
79
80#if VERSION_US
81 if (side == 0) {
84 } else {
87 }
88#elif VERSION_EU || VERSION_JP
89 if (side == 0) {
91 } else {
93 }
94#endif
96 entry = &TECHS[id - 1];
97 value = entry->elementPower * 100 / def->resist[entry->element - ELEMENT_FIRST];
98 if (value > 0x40) {
99 value = 0x40;
100 }
101 chance = value + 4;
102 if (entry->family >= FAMILY_FIRST && entry->family == def->family) {
103 chance = value + 0x40;
104 }
105 j = side == 0;
107 if (fighter->flags & FIGHTER_PARALYZED) {
108 chance += fighter->paralysis >> 3;
109 }
110 if (fighter->flags & FIGHTER_ASLEEP) {
111 chance += fighter->sleep >> 3;
112 }
113 if (fighter->flags & FIGHTER_CONFUSED) {
114 chance += fighter->confusion >> 1;
115 }
116 return (RANDOM.next() & 0x7F) < chance;
117}
118
119/* Whether a physical hit lands: the technique's accuracy with the speed and
120 level differences and the accuracy and evasion accessories (the critical
121 accessory costs the player some); the enemy hits at least 1 in 4, the
122 player in BATTLE_KIND_FINAL_LAST 2 in 3 */
124 BattleStats *atk;
125 BattleStats *def;
126 TechData *entry;
127 s32 chance;
128 s32 level;
129 s32 diff;
130
131 if (side == 0) {
134 } else {
137 }
138 atk = &FIGHTSTG_battleFuncs.stats[0];
139 def = &FIGHTSTG_battleFuncs.stats[1];
140 entry = &TECHS[id - 1];
141 if (side == 0) {
143 return (RANDOM.next() & 0x7F) >= 0x2B;
144 }
145 diff = atk->stats[BATTLE_STAT_SPEED] + atk->accuracy - def->stats[BATTLE_STAT_SPEED];
146 level = atk->level - def->level;
147 if (entry->effect < TECH_EFFECT_FIRST) {
148 chance = entry->accuracy + entry->accuracy * (diff / 8 + (level - atk->criticalBonus)) / 128;
149 } else {
150 chance = entry->accuracy + entry->accuracy * (diff / 8 + level) / 128;
151 }
152 } else {
153 level = atk->level - def->level;
154 diff = atk->stats[BATTLE_STAT_SPEED] - def->stats[BATTLE_STAT_SPEED] - def->evasion;
155 chance = entry->accuracy + entry->accuracy * (diff / 8 + level) / 128;
156 if (chance < 0x20) {
157 chance = 0x20;
158 }
159 }
160 return (RANDOM.next() & 0x7F) < chance;
161}
162
163/* Whether a magic hit lands: the technique's accuracy with the wisdom and
164 level differences; the player in BATTLE_KIND_FINAL_LAST hits 2 in 3 */
166 BattleStats *atk;
167 BattleStats *def;
168 TechData *entry;
169 s32 chance;
170 s32 level;
171 s32 diff;
172
173 if (side == 0) {
176 } else {
179 }
180 atk = &FIGHTSTG_battleFuncs.stats[0];
181 def = &FIGHTSTG_battleFuncs.stats[1];
182 entry = &TECHS[id - 1];
183 if (side == 0 && FIGHTSTG_battle.state.kind == BATTLE_KIND_FINAL_LAST) {
184 return (RANDOM.next() & 0x7F) >= 0x2B;
185 }
187 level = atk->level - def->level;
188 chance = entry->accuracy + entry->accuracy * (diff / 8 + level) / 128;
189 return (RANDOM.next() & 0x7F) < chance;
190}
191
192/* The poison a hit inflicts, or 0: the technique's or the accessory's chance
193 and an eighth of the user's wisdom, less the target's resistances and
194 wisdom (BATTLE_BLOCK_POISON keeps the player from it) */
196 BattleStats *atk;
197 BattleStats *def;
198 TechData *entry;
199 s32 chance;
200 s32 result;
201 s32 base;
202
203 if (side == 0) {
205 return 0;
206 }
209 } else {
212 }
213 atk = &FIGHTSTG_battleFuncs.stats[0];
214 def = &FIGHTSTG_battleFuncs.stats[1];
215 entry = &TECHS[id - 1];
216 if (entry->effect < TECH_EFFECT_FIRST) {
217 result = atk->statuses[HIT_POISON].power;
218 base = atk->statuses[HIT_POISON].chance + atk->stats[BATTLE_STAT_WISDOM] / 8;
219 } else {
220 result = entry->effectPower;
221 base = entry->effectChance + atk->stats[BATTLE_STAT_WISDOM] / 8;
222 }
223 chance = base - (def->resist[RESIST_POISON] + def->resist[1] + def->stats[BATTLE_STAT_WISDOM] / 2) / 8;
224 if (chance <= 0) {
225 chance = 1;
226 }
227 if (chance >= 0x80) {
228 chance = 0x7F;
229 }
230 if ((RANDOM.next() & 0x7F) < chance) {
231 return result;
232 }
233 return 0;
234}
235
236/* Whether a hit inflicts status, like rollPoison without its power: BLOCK
237 keeps the player from it, and the target resists it with RESIST and the
238 resistance to ELEMENT */
239static inline s32 rollStatus(u8 side, s32 id, s32 block, s32 status, s32 resist, s32 element) {
240 BattleStats *atk;
241 BattleStats *def;
242 TechData *entry;
243 s32 chance;
244 s32 base;
245
246 if (side == 0) {
247 if (BATTLE_SETUP.blocks[block]) {
248 return 0;
249 }
252 } else {
255 }
256 atk = &FIGHTSTG_battleFuncs.stats[0];
257 def = &FIGHTSTG_battleFuncs.stats[1];
258 entry = &TECHS[id - 1];
259 if (entry->effect < TECH_EFFECT_FIRST) {
260 base = atk->statuses[status].chance + atk->stats[BATTLE_STAT_WISDOM] / 8;
261 } else {
262 base = entry->effectChance + atk->stats[BATTLE_STAT_WISDOM] / 8;
263 }
264 chance = base - (def->resist[resist] + def->resist[element] + def->stats[BATTLE_STAT_WISDOM] / 2) / 8;
265 if (chance <= 0) {
266 chance = 1;
267 }
268 if (chance >= 0x80) {
269 chance = 0x7F;
270 }
271 return (RANDOM.next() & 0x7F) < chance;
272}
273
274/* Whether a hit paralyzes, like rollPoison (BATTLE_BLOCK_PARALYSIS keeps the
275 player from it) */
279
280/* Whether a hit confuses, like rollPoison (BATTLE_BLOCK_CONFUSION keeps the
281 player from it) */
285
286/* Whether a hit puts the target to sleep, like rollPoison with the
287 technique's chance (BATTLE_BLOCK_SLEEP keeps the player from it) */
289 BattleStats *atk;
290 BattleStats *def;
291 TechData *entry;
292 s32 chance;
293
294 if (side == 0) {
296 return 0;
297 }
300 } else {
303 }
304 atk = &FIGHTSTG_battleFuncs.stats[0];
305 def = &FIGHTSTG_battleFuncs.stats[1];
306 entry = &TECHS[id - 1];
307 chance = entry->effectChance + atk->stats[BATTLE_STAT_WISDOM] / 8 - (def->resist[RESIST_SLEEP] + def->resist[2] + def->stats[BATTLE_STAT_WISDOM] / 2) / 8;
308 if (chance <= 0) {
309 chance = 1;
310 }
311 if (chance >= 0x80) {
312 chance = 0x7F;
313 }
314 return (RANDOM.next() & 0x7F) < chance;
315}
316
317/* Whether a hit knocks the target out, like rollPoison
318 (BATTLE_BLOCK_KNOCK_OUT keeps the player from it) */
322
323/* Whether the player steals the enemy's item: its itemChance in 1024 by the
324 speed ratio (at most twice) and the technique's and the accessory's chance */
326 BattleStats *atk;
327 BattleStats *def;
328 TechData *entry;
329 s32 ratio;
330 s32 chance;
331 s32 power;
332 s32 roll;
333
334 if (side == 0) {
336 return 0;
337 }
339 return 0;
340 }
343 } else {
346 }
347 if (side == 0) {
348 atk = &FIGHTSTG_battleFuncs.stats[0];
349 def = &FIGHTSTG_battleFuncs.stats[1];
350 ratio = atk->stats[BATTLE_STAT_SPEED] * 100 / def->stats[BATTLE_STAT_SPEED];
351 entry = &TECHS[id - 1];
352 if (ratio > 200) {
353 ratio = 200;
354 }
355 power = (entry->effectChance + atk->stealBonus) * 100 / 64;
357 roll = RANDOM.next() % 1024;
358 if (roll < chance) {
359 return 1;
360 }
361 }
362 return 0;
363}
364
365/* Whether a hit drains HP: the technique's chance, or the accessory's for a
366 technique without an effect */
368 BattleStats *stats;
369 TechData *entry;
370 s32 chance;
371
372 if (side == 0 && BATTLE_SETUP.blocks[BATTLE_BLOCK_DRAIN] != 0) {
373 return 0;
374 }
375#if VERSION_US
376 stats = &FIGHTSTG_battleFuncs.stats[0];
377#elif VERSION_EU || VERSION_JP
378 stats = FIGHTSTG_computeStats(side, 1, FIGHTSTG_battle.state.active[side >> 4]);
379#endif
380 entry = &TECHS[id - 1];
381 if (entry->effect < TECH_EFFECT_FIRST) {
382 chance = stats->statuses[HIT_DRAIN].chance;
383 } else {
384 chance = entry->effectChance;
385 }
386 return (RANDOM.next() & 0x7F) < chance;
387}
388
389/* Rolls a technique's effect chance (TechData.effectChance, in 128ths) */
390static inline s32 rollTechChance(s32 id) {
391 TechData *entry = &TECHS[id - 1];
392 s32 chance = entry->effectChance;
393
394 return (RANDOM.next() & 0x7F) < chance;
395}
396
397/* Whether a technique turns the player's fighter back: never when it is one
398 of the partners' own Digimon (DIGIMON_DATA's first PARTNER_COUNT, as
399 initNewGameData reads them), otherwise the technique's chance */
401 s32 i;
402
403 for (i = 0; i < PARTNER_COUNT; i++) {
405 return 0;
406 }
407 }
408 return rollTechChance(id);
409}
410
411/* Whether a status raise works: the technique's chance and an eighth of
412 what the enemy's wisdom has over the partner's */
414 TechData *entry;
415 s32 chance;
416
419 entry = &TECHS[id - 1];
421 return (RANDOM.next() & 0x7F) < chance;
422}
423
424/* Whether TECH_EFFECT_NO_SWITCH works: the technique's chance */
426 return rollTechChance(id);
427}
428
429/* Whether TECH_EFFECT_NO_DIGIVOLVE works: the technique's chance */
431 return rollTechChance(id);
432}
433
434#if VERSION_EU || VERSION_JP
435/* FIGHTSTG_battleFuncs.rollCounter: a random test, likelier the bigger damage is next
436 to the player's fighter's max HP; side is not used */
439 s32 chance = (damage << 6) / fighter->maxHp + 32;
440
441 return (RANDOM.next() & 0x7F) < chance;
442}
443#endif
444
445/* FIGHTSTG_battleFuncs.testRunAway: a random test for side running away, from
446 both sides' stats; the player can't while BATTLE_BLOCK_RUN_AWAY is set, and
447 in the European version neither can the enemy while its fighter is asleep.
448 The match depends on the battle's runAttempts being read through a pointer
449 to its state, taken before side is tested again, and on the flags being
450 tested with family as a halfword. */
452 BattleStats *atk;
453 BattleStats *def;
454 s32 chance;
455 BattleState *state;
456
457 if (side == 0) {
460 } else {
463 }
464 state = &FIGHTSTG_battle.state;
465 atk = &FIGHTSTG_battleFuncs.stats[0];
466 def = &FIGHTSTG_battleFuncs.stats[1];
467 if (side == 0) {
469 return 0;
470 }
471 /* a halfword load (flags and paralysis) whose mask takes flags' bits only */
472 if (*(u16 *)&atk->flags & (FIGHTER_ASLEEP | FIGHTER_NO_SWITCH)) {
473 return 0;
474 }
475 chance = (state->runAttempts + 1) * 8;
476 if (atk->flags & FIGHTER_PARALYZED) {
477 chance >>= 1;
478 }
479 if (atk->level > def->level) {
480 chance += atk->level - def->level;
481 }
483 chance += (atk->stats[BATTLE_STAT_SPEED] - def->stats[BATTLE_STAT_SPEED]) / 10;
484 }
485 chance += atk->runAwayBonus;
486 } else {
487#if VERSION_EU || VERSION_JP
488 if (atk->flags & FIGHTER_ASLEEP) {
489 return 0;
490 }
491#endif
492 if (def->runAwayGuard) {
493 chance = 0x20;
494 } else {
495 chance = 0x40;
496 }
497 if (atk->flags & FIGHTER_PARALYZED) {
498 chance >>= 1;
499 }
500 chance += (atk->stats[BATTLE_STAT_SPEED] - def->stats[BATTLE_STAT_SPEED]) / 10;
501 }
502 return (RANDOM.next() & 0x7F) < chance;
503}
504
505/* FIGHTSTG_battleFuncs.testWakeUp: whether a hit of value wakes side's
506 fighter up, likelier the bigger value is next to the fighter's defense,
507 less likely the stronger its sleep and the later its end (EVENT_STATUS_END
508 + 2) is due. The match depends on the 64 being set apart from sleep's half and on the sum being
509 written in one statement. */
511 s32 team;
512 s32 index;
513 s32 chance;
514 s16 delay;
515 s32 luck;
516 BattleStats *def;
517
518 if (side == 0) {
520 } else {
522 }
523 team = side != 0;
524 def = &FIGHTSTG_battleFuncs.stats[1];
526 chance = (value << 7) / def->stats[BATTLE_STAT_DEFENSE];
527 delay = FIGHTSTG_events.events[index].time / 100;
528 luck = 64;
530 chance = chance + luck - delay;
531 return (RANDOM.next() & 0x7F) < chance;
532}
533
534/* FIGHTSTG_battleFuncs.testConfusion: a random test of side's confusion
535 against its resists 9 and 3 */
537 BattleStats *stats;
538 s32 other;
539 s32 flag;
540 s32 fighter;
541 s32 chance;
542
543 if (side == 0) {
544 fighter = FIGHTSTG_battle.state.active[0];
545 flag = SIDE_PLAYER;
546 } else {
547 flag = SIDE_ENEMY;
548 fighter = FIGHTSTG_battle.state.active[1];
549 }
550 FIGHTSTG_computeStats(flag, 0, fighter);
551 stats = &FIGHTSTG_battleFuncs.stats[1];
552 other = side != 0;
553 chance = FIGHTSTG_battle.state.fighters[other][FIGHTSTG_battle.state.active[other]].confusion - (stats->resist[RESIST_CONFUSION] + stats->resist[3]) / 8;
554 return (RANDOM.next() & 0x7F) < chance;
555}
556
557/* FIGHTSTG_battleFuncs.testParalysis: whether side's paralysis costs it the
558 turn, a random test of its strength against resists 8 and 4 (at least a
559 chance of 32 in 128) */
561 BattleStats *stats;
562 s32 other;
563 s32 flag;
564 s32 fighter;
565 s32 chance;
566
567 if (side == 0) {
568 fighter = FIGHTSTG_battle.state.active[0];
569 flag = SIDE_PLAYER;
570 } else {
571 flag = SIDE_ENEMY;
572 fighter = FIGHTSTG_battle.state.active[1];
573 }
574 FIGHTSTG_computeStats(flag, 0, fighter);
575 stats = &FIGHTSTG_battleFuncs.stats[1];
576 other = side != 0;
577 chance = FIGHTSTG_battle.state.fighters[other][FIGHTSTG_battle.state.active[other]].paralysis - (stats->resist[RESIST_PARALYSIS] + stats->resist[4]) / 8;
578 if (chance < 0x20) {
579 chance = 0x20;
580 }
581 return (RANDOM.next() & 0x7F) < chance;
582}
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
Definition battle.c:16
BattleFuncs FIGHTSTG_battleFuncs
the battle's stats and the functions that compute with them
Definition battle.c:25
#define HIT_CONFUSION
Definition battle.h:291
#define RESIST_KNOCK_OUT
Definition battle.h:51
#define FIGHTER_PARALYZED
loses turns at random (FIGHTSTG_battleFuncs.testParalysis)
Definition battle.h:183
#define HIT_DRAIN
its power is in 128ths of the damage
Definition battle.h:293
#define TECH_EFFECT_FIRST
A technique's effect (TechData.effect), which FIGHTSTG_applyTechEffect carries out when its hit lands...
Definition battle.h:251
#define FIGHTER_NO_SWITCH
can't switch out or run away (TECH_EFFECT_NO_SWITCH)
Definition battle.h:186
#define BATTLE_STAT_SPEED
physical accuracy, evasion and running away
Definition battle.h:33
#define FAMILY_FIRST
Definition battle.h:39
#define HIT_POISON
The statuses a weapon's hits can inflict (BattleStats.statuses)
Definition battle.h:289
#define RESIST_POISON
BattleStats.resist's indices: against the elements (element - ELEMENT_FIRST), then against the status...
Definition battle.h:47
#define HIT_KNOCK_OUT
its power is read by nothing
Definition battle.h:292
#define EVENT_STATUS_END
10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP
Definition battle.h:90
#define BATTLE_KIND_FINAL_LAST
its third enemy; winning plays the ending
Definition battle.h:130
#define BATTLE_STAT_WISDOM
magic accuracy, statuses and heals
Definition battle.h:32
#define BATTLE_STAT_DEFENSE
against it
Definition battle.h:30
#define RESIST_PARALYSIS
Definition battle.h:48
#define HIT_PARALYSIS
Definition battle.h:290
#define FIGHTER_ASLEEP
can't act or run away; a hit may wake it up
Definition battle.h:185
#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 RESIST_SLEEP
Definition battle.h:50
#define SIDE_ENEMY
Definition battle.h:178
#define RESIST_CONFUSION
Definition battle.h:49
#define ELEMENT_FIRST
The elements (TechData.element, BattleStats.element) and the families (TechData.family,...
Definition battle.h:37
#define FIGHTER_CONFUSED
Definition battle.h:184
#define TECH_EFFECT_CRITICAL
raises the critical hit chance
Definition battle.h:260
EventQueue FIGHTSTG_events
the battle's events and their functions
Definition events.c:43
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
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
unsigned char u8
Definition common.h:8
DigimonData DIGIMON_DATA[55]
55 entries: the 52 Digimon, then three placeholders (0x1D4-0x1D6)
Definition digimon.c:7
#define BATTLE_BLOCK_SLEEP
Definition game_state.h:367
#define BATTLE_BLOCK_RUN_AWAY
Definition game_state.h:374
#define BATTLE_BLOCK_STEAL
Definition game_state.h:370
#define BATTLE_BLOCK_POISON
BattleSetup.blocks' indices: the encounter keeps the player from inflicting a status,...
Definition game_state.h:364
#define BATTLE_BLOCK_CONFUSION
Definition game_state.h:366
#define BATTLE_BLOCK_KNOCK_OUT
Definition game_state.h:368
#define BATTLE_BLOCK_PARALYSIS
Definition game_state.h:365
#define BATTLE_BLOCK_DRAIN
Definition game_state.h:369
@ PARTNER_COUNT
Definition game_state.h:472
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
BattleSetup BATTLE_SETUP
Definition items.c:886
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
static s32 rollStatus(u8 side, s32 id, s32 block, s32 status, s32 resist, s32 element)
Whether a hit inflicts status, like rollPoison without its power: BLOCK keeps the player from it,...
Definition rolls.c:239
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
static s32 rollTechChance(s32 id)
Rolls a technique's effect chance (TechData.effectChance, in 128ths)
Definition rolls.c:390
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_rollCritical(u8 side, s32 id)
Whether a physical hit is critical: a chance of 4 in 128 with the technique's critical boost or the a...
Definition rolls.c:9
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
s32 FIGHTSTG_rollMagicCritical(u8 side, s32 id)
Whether a magic hit is critical: a chance from the technique's element power against the target's res...
Definition rolls.c:72
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 paralysis
FIGHTER_PARALYZED's strength.
Definition battle.h:205
u8 flags
FIGHTER_*.
Definition battle.h:204
s16 item
an enemy's
Definition battle.h:201
s16 id
the Digimon (DIGIMON_DATA)
Definition battle.h:192
u8 sleep
FIGHTER_ASLEEP's.
Definition battle.h:206
u8 confusion
FIGHTER_CONFUSED's.
Definition battle.h:207
u8 special
the partner's special state (EVENT_SPECIAL_END): doubles its effects
Definition battle.h:203
BattleStats stats[2]
the player's, then the enemy's
Definition battle.h:330
u8 blocks[12]
by BATTLE_BLOCK_*: what the player can't do in the battle
Definition game_state.h:389
What a battle starts from: WFIGHTMN_start zeroes it as one block, and FIGHTSTG_testRunAway reads runA...
Definition battle.h:225
s16 runAttempts
the player's, each of which makes running away likelier (FIGHTSTG_testRunAway)
Definition battle.h:229
s32 active[2]
each side's fighter
Definition battle.h:226
BattleFighter fighters[2][3]
Definition battle.h:227
s16 kind
the kind of battle
Definition battle.h:230
A side's stats as FIGHTSTG_computeStats works them out.
Definition battle.h:305
u8 weaponFamilies[3]
from the equipment, as are the ones after
Definition battle.h:313
s16 stats[5]
with the fighter's boosts
Definition battle.h:307
u8 runAwayGuard
halves the enemy's chance to run away
Definition battle.h:323
u8 runAwayBonus
to the player's chance to run away
Definition battle.h:322
u8 criticalBonus
to plain techniques' critical chance, off their accuracy
Definition battle.h:318
s16 resist[12]
Definition battle.h:308
s16 level
Definition battle.h:306
u8 accuracy
Definition battle.h:320
u8 flags
the fighter's
Definition battle.h:309
HitStatus statuses[5]
by HIT_*, from the weapon
Definition battle.h:316
u8 stealBonus
Definition battle.h:324
s16 itemChance
in 1024ths, less one
Definition battle.h:61
BattleState state
Definition battle.h:240
s32(* find)(s32 type, u8 side, s32 fighter)
Definition battle.h:146
EventQueueFuncs funcs
Definition battle.h:171
QueuedEvent events[99]
Definition battle.h:165
u8 chance
in 128ths
Definition battle.h:298
u8 power
Definition battle.h:299
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 effectChance
Definition game_state.h:120
u8 effect
TECH_EFFECT_* (fightstg/battle.h), under TECH_EFFECT_FIRST none.
Definition game_state.h:119
u8 family
FAMILY_FIRST and up, under it none.
Definition game_state.h:118
u8 effectPower
the effect's strength (a boost's amount, a drain's 128ths)
Definition game_state.h:121
u8 element
ELEMENT_FIRST and up, under it none.
Definition game_state.h:116
u8 elementPower
how much the element adds, against the target's resistance
Definition game_state.h:117