Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
tech_action.c
Go to the documentation of this file.
1/* FIGHTSTG's technique action: the task that plays a technique, its messages
2 and the boosts and statuses it gives. */
3
5
6/* the techniques that boost a stat of a fighter (FIGHTSTG_updateTechAction): the user's,
7 or the enemy's for an amount below 0 */
9 { 0xC6, 1, 0, 0x30 },
10 { 0xC8, 1, 1, 0x31 },
11 { 0xCA, 1, 2, 0x32 },
12 { 0xCC, -1, 0, 0x33 },
13 { 0xCD, -1, 1, 0x34 },
14 { 0xCE, -1, 1, 0x34 },
15 { 0xCF, -1, 2, 0x35 },
16 { 0xD0, -1, 2, 0x35 },
17 { -1, 0, 0, 0 },
18};
19/* and the ones that boost a stat of all the user's side */
21 { 0xC7, 1, 0, 0x30 },
22 { 0xC9, 1, 1, 0x31 },
23 { 0xCB, 1, 2, 0x32 },
24 { -1, 0, 0, 0 },
25};
26/* techniques 0xBE-0xC5's four kinds of status (FIGHTSTG_updateTechAction): the flag of
27 each in BattleFighter.flags, */
31/* the event types that the European version's FIGHTSTG_reviveFighter clears */
32#if VERSION_EU || VERSION_JP
37#endif
38/* the argument of message 9, which the odd techniques show, */
40 1, 2, 3, 4,
41};
42/* and the message shown when the target has the status */
44 40, 41, 42, 44,
45};
46
47/* Starts the technique: its action for a physical or magic one, its message,
48 and whether the other side's fighter is asleep */
49static inline void announceTech(TechAction *task, BattleChild *children) {
50 TechData *tech = &TECHS[task->tech - 1];
51
52 if (tech->icon == TECH_PHYSICAL || tech->icon == TECH_MAGIC) {
53 FIGHTSTG_action.start(task->side, task->tech);
54 } else {
56 }
57 children[0].message = FIGHTSTG_createMessage();
58 if (tech->script == 0xC) {
59 task->lines[0] = 0x3A;
60 task->lines[1] = task->side;
61 children[0].message->show(children[0].message, 2, task->lines);
62 } else {
63 task->lines[0] = task->side;
64 task->lines[1] = task->tech;
65 children[0].message->show(children[0].message, 3, task->lines);
66 }
67 {
68 s32 other = 1 - (task->side >> 4);
70
71 if (fighter->flags & FIGHTER_ASLEEP) {
72 task->asleep = 1;
73 }
74 }
75 task->nextState(task);
76}
77
78/* Once the message is gone, starts the technique's script and spends the
79 user's charge, or for an enemy-only effect ends the user's weakness */
80static inline void startTechScript(TechAction *task, BattleChild *children) {
81 if (children[0].task == NULL) {
83 children[0].script = WFIGHTMN_startTech(task->side, task->tech);
84 {
86
87 if (task->side != 0) {
88 fighters = FIGHTSTG_battle.state.fighters[1];
89 }
90 fighters[FIGHTSTG_battle.state.active[task->side != 0]].charge = 0;
91 }
92 } else {
94 }
95 task->substate++;
96 }
97}
98
99/* A physical or magic technique: deals its damage to the other side's fighter
100 (or its hits', or knocks it out), or says it missed; one with
101 TECH_EFFECT_ENEMY_ONLY is queued as the partner's technique instead */
102static inline void dealTechDamage(TechAction *task, BattleChild *children) {
103 s32 other;
104
105 children[0].message = FIGHTSTG_createMessage();
106 other = task->side == 0;
109 task->state = 3;
110 return;
111 }
113 if (TECHS[task->tech - 1].effect == TECH_EFFECT_DOUBLE_MAGIC) {
115 task->lines[0] = other << 4;
116 task->lines[1] = task->damage;
117 children[0].message->show(children[0].message, 4, task->lines);
118 } else {
119#if VERSION_US
121#endif
122 task->lines[0] = other << 4;
123 task->lines[1] = FIGHTSTG_action.damage;
125 children[0].message->show(children[0].message, 0x10, task->lines);
126#if VERSION_EU || VERSION_JP
128 if (task->damage >= 10000) {
129 task->damage = 9999;
130 }
131#endif
132 }
134 FIGHTSTG_getActiveFighter(other)->hp = 0;
135 FIGHTSTG_queueKnockOut(other << 4);
136 children[0].task->state = 3;
137 } else if (FIGHTSTG_action.hits[0]) {
138 task->lines[0] = other << 4;
139 task->lines[1] = FIGHTSTG_action.damage;
140 children[0].message->show(children[0].message, 4, task->lines);
142 } else {
143 task->lines[0] = 0x1D;
144 task->lines[1] = other << 4;
145 children[0].message->show(children[0].message, 2, task->lines);
146 }
147 if (task->damage != 0) {
149
150 fighter->hp -= task->damage;
151 if (fighter->hp <= 0) {
152 fighter->hp = 0;
153 FIGHTSTG_queueKnockOut(other << 4);
154 task->step = 1;
155 }
156 }
157 task->substate++;
158}
159
160/* Techniques 0xBE-0xC5: cure one of the four kinds of status
161 (FIGHTSTG_statusTechFlags), the odd ones on the user's whole side */
162static inline void cureStatusTech(TechAction *task, BattleChild *children) {
163 s32 other;
164 s32 kind;
165 BattleFighter *fighters;
166 s32 i;
167
168 other = task->side != 0;
169 switch (task->tech) {
170 case 0xBE:
171 case 0xBF:
172 default:
173 kind = 0;
174 break;
175 case 0xC0:
176 case 0xC1:
177 kind = 1;
178 break;
179 case 0xC2:
180 case 0xC3:
181 kind = 2;
182 break;
183 case 0xC4:
184 case 0xC5:
185 kind = 3;
186 break;
187 }
188 fighters = FIGHTSTG_battle.state.fighters[other];
189 switch (task->step) {
190 case 0:
191 default:
192 children[0].message = FIGHTSTG_createMessage();
193 if (task->tech & 1) {
194 task->lines[0] = task->side;
195 task->lines[1] = FIGHTSTG_statusTechArgs[kind];
196 children[0].message->show(children[0].message, 9, task->lines);
197 task->step = 1;
198 task->counter = 3;
199 return;
200 }
201 if (fighters[FIGHTSTG_battle.state.active[other]].flags & FIGHTSTG_statusTechFlags[kind]) {
202 task->lines[0] = FIGHTSTG_statusTechLines[kind];
203 task->lines[1] = task->side;
204 task->lines[2] = FIGHTSTG_battle.state.active[0];
205 children[0].message->show(children[0].message, 2, task->lines);
206 task->step = 1;
207 task->counter = 1;
208 return;
209 }
210 task->lines[0] = 0x2F;
211 children[0].message->show(children[0].message, 1, task->lines);
212 break;
213 case 1:
214 for (i = 0; i < task->counter; i++) {
215 FIGHTSTG_events.funcs.cureStatus(task->side, i, task->tech);
216 }
217 break;
218 }
219 task->nextSubstate(task);
220}
221
222/* Technique 0x64: revives the partners knocked out to their max HP */
223static inline void reviveSide(TechAction *task, BattleChild *children) {
224 BattleFighter *fighter;
225 s32 i;
226
227 fighter = FIGHTSTG_battle.state.fighters[0];
228 switch (task->step) {
229 case 0:
230 default:
231 children[0].message = FIGHTSTG_createMessage();
232 task->lines[0] = 0;
233 task->lines[1] = 5;
234 children[0].message->show(children[0].message, 9, task->lines);
235 task->step++;
236 return;
237 case 1:
238 for (i = 0; i < 3; i++) {
239 if (fighter[i].id != 0 && fighter[i].hp == 0) {
240 fighter[i].hp = fighter[i].maxHp;
242 }
243 }
244 break;
245 }
246 task->nextSubstate(task);
247}
248
249/* Technique 0x177: revives the partners and restores them whole, statuses
250 included */
251static inline void restoreSide(TechAction *task, BattleChild *children) {
252#if VERSION_US
253 BattleFighter *fighter;
254#endif
255 s32 i;
256
257#if VERSION_US
258 fighter = FIGHTSTG_battle.state.fighters[0];
259#endif
260 switch (task->step) {
261 case 0:
262 default:
263 children[0].message = FIGHTSTG_createMessage();
264 task->lines[0] = 0;
265 task->lines[1] = 6;
266 children[0].message->show(children[0].message, 9, task->lines);
267 task->step++;
268 return;
269 case 1:
270#if VERSION_US
271 for (i = 0; i < 3; i++) {
272 if (fighter[i].id != 0) {
273 if (fighter[i].hp == 0) {
275 }
276 fighter[i].flags = 0;
277 fighter[i].hp = fighter[i].maxHp;
279 }
280 }
281#else
282 for (i = 0; i < 3; i++) {
283 FIGHTSTG_reviveFighter(0x177, i);
284 }
285#endif
286 break;
287 }
288 task->nextSubstate(task);
289}
290
291/* The other item techniques: heal the user, or its whole side for 0xBB and
292 above, by FIGHTSTG_computeHeal, or say they do nothing */
293static inline void healWithTech(TechAction *task, BattleChild *children) {
294 BattleFighter *fighters;
295 s32 kind;
296
297 fighters = FIGHTSTG_battle.state.fighters[0];
298 if (task->side != 0) {
299 fighters = FIGHTSTG_battle.state.fighters[1];
300 }
301 switch (task->step) {
302 case 0:
303 default: {
304 s32 i;
305 s32 most;
306
307 kind = -1;
308 task->heal = FIGHTSTG_battleFuncs.computeHeal(task->side, task->tech);
309 most = 0;
310 if (task->tech >= 0xBB) {
311 for (i = 0; i < 3; i++) {
312 if (fighters[i].id != 0 && fighters[i].hp != 0) {
313 s32 lost = fighters[i].maxHp - fighters[i].hp;
314
315 if (most < lost) {
316 most = lost;
317 }
318 }
319 }
320 if (most != 0) {
321 kind = 9;
322 if (task->heal < most) {
323 most = task->heal;
324 }
325 task->lines[1] = 0;
326 task->lines[2] = most;
327 }
328 } else {
329 s32 lost;
330
331 i = FIGHTSTG_battle.state.active[task->side != 0];
332 lost = fighters[i].maxHp - fighters[i].hp;
333 if (most < lost) {
334 most = lost;
335 }
336 if (most != 0) {
337 kind = 8;
338 if (task->heal < most) {
339 most = task->heal;
340 }
341 task->heal = most;
342 task->lines[1] = most;
343 }
344 }
345 children[0].message = FIGHTSTG_createMessage();
346 task->lines[0] = task->side;
347 if (kind != -1) {
348 s32 i;
349
350 children[0].message->show(children[0].message, kind, task->lines);
351 if (task->tech >= 0xBB) {
352 for (i = 0; i < 3; i++) {
353 if (fighters[i].id != 0 && fighters[i].hp != 0) {
354 if (fighters[i].hp + task->heal > fighters[i].maxHp) {
355 fighters[i].hp = fighters[i].maxHp;
356 } else {
357 fighters[i].hp += task->heal;
358 }
359 }
360 }
361 } else {
362 i = FIGHTSTG_battle.state.active[task->side != 0];
363 if (fighters[i].hp + task->heal > fighters[i].maxHp) {
364 fighters[i].hp = fighters[i].maxHp;
365 } else {
366 fighters[i].hp += task->heal;
367 }
368 }
369 task->nextSubstate(task);
370 } else {
371 task->lines[0] = 0x2F;
372 task->lines[1] = task->side;
373 children[0].message->show(children[0].message, 2, task->lines);
374 task->nextSubstate(task);
375 }
376 break;
377 }
378 case 1:
379 return;
380 }
381}
382
383/* An item technique: an auto-recovery, a cure, a revival or a heal */
384static inline void useItemTech(TechAction *task, BattleChild *children) {
385 task->lines[0] = task->side;
386 switch (task->tech) {
387 case 0xBD:
390 children[0].message = FIGHTSTG_createMessage();
391 task->lines[0] = 0x27;
392 task->lines[1] = task->side;
393 children[0].message->show(children[0].message, 2, task->lines);
394 task->nextSubstate(task);
395 break;
396 case 0xBE:
397 case 0xBF:
398 case 0xC0:
399 case 0xC1:
400 case 0xC2:
401 case 0xC3:
402 case 0xC4:
403 case 0xC5:
404 cureStatusTech(task, children);
405 break;
406 case 0x64:
407 reviveSide(task, children);
408 break;
409 case 0x177:
410 restoreSide(task, children);
411 break;
412 default:
413 healWithTech(task, children);
414 break;
415 }
416}
417
418/* Techniques 0xC6-0xD0 (FIGHTSTG_techBoosts): boost a stat of the user, or
419 lower the other side's, which the battle can block for the partner's */
420static inline void boostFighterStat(TechAction *task, BattleChild *children, TechData *tech) {
421 TechBoost *boost;
422 s32 other;
423 s32 ok;
424
425 for (boost = FIGHTSTG_techBoosts; boost->tech != -1; boost++) {
426 if (boost->tech == task->tech) {
427 break;
428 }
429 }
430 ok = 1;
431 other = task->side >> 4;
432 if (boost->amount <= 0) {
433 other ^= 1;
434 if (task->side == 0 && BATTLE_SETUP.blocks[boost->stat + BATTLE_BLOCK_LOWER_ATTACK]) {
435 task->lines[0] = 0x2F;
436 children[0].message->show(children[0].message, ok, task->lines);
437 ok = 0;
438 }
439 }
440 if (ok == 0) {
441 return;
442 }
443 FIGHTSTG_battleFuncs.changeBoost(other << 4, FIGHTSTG_battle.state.active[other], boost->stat, boost->amount * tech->effectPower);
444 FIGHTSTG_queueBoostEnd(other << 4, FIGHTSTG_battle.state.active[other], boost->stat, task->tech);
445 task->lines[0] = boost->line;
446 task->lines[1] = other << 4;
447 task->lines[2] = FIGHTSTG_battle.state.active[other];
448 children[0].message->show(children[0].message, 2, task->lines);
449}
450
451/* Techniques 0xC7, 0xC9 and 0xCB (FIGHTSTG_sideBoosts): boost a stat of all
452 the user's side */
453static inline void boostSideStat(TechAction *task, BattleChild *children, TechData *tech) {
454 TechBoost *boost;
455 s32 i;
456
457 for (boost = FIGHTSTG_sideBoosts; boost->tech != -1; boost++) {
458 if (boost->tech == task->tech) {
459 break;
460 }
461 }
462 for (i = 0; i < 3; i++) {
463 if (FIGHTSTG_battle.state.fighters[task->side >> 4][i].id != 0 && FIGHTSTG_battle.state.fighters[task->side >> 4][i].hp > 0) {
464 FIGHTSTG_battleFuncs.changeBoost(task->side, i, boost->stat, boost->amount * tech->effectPower);
465 FIGHTSTG_queueBoostEnd(task->side, i, boost->stat, task->tech);
466 }
467 }
468 task->lines[0] = task->side;
469 switch (boost->stat) {
470 case 0:
471 task->lines[1] = 7;
472 break;
473 case 1:
474 task->lines[1] = 8;
475 break;
476 case 2:
477 task->lines[1] = 9;
478 break;
479 }
480 children[0].message->show(children[0].message, 9, task->lines);
481}
482
483/* Techniques 0xD1 and 0xD2: charge the user by the technique's power */
484static inline void chargeUser(TechAction *task, BattleChild *children, TechData *tech) {
485 s32 other = task->side >> 4;
486
488 task->lines[0] = 0x36;
489 task->lines[1] = task->side;
490 children[0].message->show(children[0].message, 2, task->lines);
491}
492
493/* Technique 0x188: the enemy drains the partner's MP by the technique's power
494 in 128ths of its max MP */
495static inline void drainMp(TechAction *task, BattleChild *children, TechData *tech) {
498 s32 amount;
499
500 if (from->mp != 0) {
501 amount = from->maxMp * tech->effectPower / 128;
502 if (from->mp < amount) {
503 amount = from->mp;
504 }
505 to->mp += amount;
506 from->mp -= amount;
507 if (to->mp > to->maxMp) {
508 to->mp = to->maxMp;
509 }
510 if (from->mp < 0) {
511 from->mp = 0;
512 }
513 task->lines[0] = 0x10;
514 task->lines[1] = amount;
515 task->lines[2] = 1;
516 children[0].message->show(children[0].message, 0x12, task->lines);
517 } else {
518 task->lines[0] = 0x2F;
519 task->lines[1] = 0x10;
520 children[0].message->show(children[0].message, 2, task->lines);
521 }
522}
523
524/* Technique 0x190: heals the enemy by FIGHTSTG_computeHeal and charges it */
525static inline void healEnemy(TechAction *task, BattleChild *children) {
527
528 task->heal = FIGHTSTG_battleFuncs.computeHeal(task->side, 0x190);
529 fighter->hp += task->heal;
530 if (fighter->hp > fighter->maxHp) {
531 fighter->hp = fighter->maxHp;
532 }
533 fighter->charge = 0x20;
534 task->lines[0] = 0x46;
535 task->lines[1] = 0x10;
536 children[0].message->show(children[0].message, 2, task->lines);
537}
538
539/* A support technique: a boost, a charge, a restriction or digidevolving the
540 enemy, or the enemy's drain of MP or heal */
541static inline void useSupportTech(TechAction *task, BattleChild *children, TechData *tech) {
542 children[0].message = FIGHTSTG_createMessage();
543 switch (task->tech) {
544 case 0xC6:
545 case 0xC8:
546 case 0xCA:
547 case 0xCC:
548 case 0xCD:
549 case 0xCE:
550 case 0xCF:
551 case 0xD0:
552 boostFighterStat(task, children, tech);
553 break;
554 case 0xC7:
555 case 0xC9:
556 case 0xCB:
557 boostSideStat(task, children, tech);
558 break;
559 case 0xD1:
560 case 0xD2:
561 chargeUser(task, children, tech);
562 break;
563 case 0xD3:
566 task->lines[0] = 0x44;
567 task->lines[1] = 0;
568 children[0].message->show(children[0].message, 2, task->lines);
569 } else {
570 task->lines[0] = 0x2F;
571 children[0].message->show(children[0].message, 1, task->lines);
572 }
573 break;
574 case 0xD4:
577 task->lines[0] = 0x45;
578 task->lines[1] = 0;
579 children[0].message->show(children[0].message, 2, task->lines);
580 } else {
581 task->lines[0] = 0x2F;
582 children[0].message->show(children[0].message, 1, task->lines);
583 }
584 break;
585 case 0x187:
588 children[0].task->state = 3;
589 } else {
590 task->lines[0] = 0x2F;
591 children[0].message->show(children[0].message, 1, task->lines);
592 }
593 break;
594 case 0x188:
595 drainMp(task, children, tech);
596 break;
597 case 0x190:
598 healEnemy(task, children);
599 break;
600 }
601 task->nextSubstate(task);
602}
603
604/* Icon 6's techniques: set the field's boosted element and its amount (the
605 user's spirit / 10 plus the technique's power, at most 0x7F), cleared after
606 a time set by the spirit. The element boosted is the technique's icon, so
607 always 6, while the message names the technique's own element. */
608static inline void boostFieldElement(TechAction *task, BattleChild *children, TechData *tech) {
609 BattleStats *stats;
610 s16 spiritBonus;
611 s32 amount;
612
613 children[0].message = FIGHTSTG_createMessage();
614 stats = FIGHTSTG_battleFuncs.computeStats(task->side, 1, FIGHTSTG_battle.state.active[task->side == 0x10]);
616 spiritBonus = stats->stats[BATTLE_STAT_SPIRIT] / 10;
617 amount = spiritBonus + tech->effectPower;
618 if (amount >= 0x80) {
619 amount = 0x7F;
620 }
623 task->lines[0] = tech->element + 0x61;
624 children[0].message->show(children[0].message, 1, task->lines);
625 task->nextSubstate(task);
626}
627
628/* After the technique: wakes the other side's fighter when it was asleep and
629 the damage wakes it (or ends), else starts the motion of the damage */
630static inline void wakeUpOrCounter(TechAction *task, BattleChild *children) {
631 s32 other = task->side == 0;
633 TechData *tech;
634
635 tech = &TECHS[task->tech - 1];
636 if (fighter->flags & FIGHTER_ASLEEP) {
637 if (task->asleep != 0 && FIGHTSTG_battleFuncs.testWakeUp(other << 4, task->damage) != 0) {
638 task->lines[0] = 0x2B;
639 task->lines[1] = SIDE_ENEMY - task->side;
640 task->lines[2] = FIGHTSTG_battle.state.active[other];
641 children[0].message = FIGHTSTG_createMessage();
642 children[0].message->show(children[0].message, 7, task->lines);
643 fighter->flags &= ~FIGHTER_ASLEEP;
644 {
646
647 if (event >= 0) {
648 FIGHTSTG_events.events[event].type = 0;
649 }
650 }
651 task->substate = 9;
652 } else {
653 task->state = 3;
654 }
655 } else if (tech->icon == TECH_PHYSICAL) {
656 children[0].counter = FIGHTSTG_startCounterattack((task->side == 0) << 4, task->damage, tech->script == 0xC);
657 task->substate = 6;
658 } else {
659 task->substate = 5;
660 }
661}
662
663/* A side's technique or item (FIGHTSTG_startTechAction): state 0 shows its
664 message (announceTech), substate 1 does what it does by its kind (2 and 3
665 deal damage (dealTechDamage), 4 is an item's cure, revival or healing
666 (useItemTech), 5 a boost, a drain or a heal of the enemy (useSupportTech),
667 6 a boost of the field's element (boostFieldElement)), then
668 the wake-up when the other side's fighter is asleep (substate 4,
669 wakeUpOrCounter) and the motion of the damage
670 (FIGHTSTG_startCounterattack). The match depends on the other side's
671 fighter being found as its row's offset added as an int to its slot (as
672 in FIGHTSTG_updateFirstTech), on each case's variables being its own, on substate
673 1's cases advancing substate themselves (case 5 once, after its switch)
674 and on the heal tests being written hp + heal > maxHp. */
676 TechData *tech;
677
678 switch (task->state) {
679 case TASK_INIT:
680 default:
681 announceTech(task, children);
682 break;
683 case TASK_RUN:
684 switch (task->substate) {
685 case 0:
686 default:
687 startTechScript(task, children);
688 break;
689 case 1:
690 if (children[0].task != NULL) {
691 break;
692 }
693 tech = &TECHS[task->tech - 1];
694 switch (tech->icon) {
695 default:
696 return;
697 case TECH_PHYSICAL:
698 case TECH_MAGIC:
699 dealTechDamage(task, children);
700 return;
701 case 4:
702 useItemTech(task, children);
703 break;
704 case 5:
705 useSupportTech(task, children, tech);
706 break;
707 case 6:
708 boostFieldElement(task, children, tech);
709 return;
710 }
711 break;
712 case 2:
713 if (children[0].task == NULL) {
714 TechData *tech = &TECHS[task->tech - 1];
715
716 if ((tech->icon == TECH_PHYSICAL || tech->icon == TECH_MAGIC) && task->step == 0) {
717 if (task->damage == 0) {
719 task->setSubstate(task, 7);
720 break;
721 }
722 } else {
723 children[0].events = FIGHTSTG_startActionEvents(task->side);
724 task->nextSubstate(task);
725 break;
726 }
727 }
728 task->state = 3;
729 }
730 break;
731 case 3:
732 if (children[0].task == NULL) {
733 task->substate++;
734 }
735 break;
736 case 4:
737 wakeUpOrCounter(task, children);
738 break;
739 case 6:
740 if (children[0].task != NULL) {
741 if (children[0].task->state != 2) {
742 break;
743 }
744 case 5:
745 WFIGHTMN_chargeGauge(task->side, task->damage);
746 }
747 task->state = 3;
748 break;
749 case 7:
750 if (children[0].task == NULL) {
751 TechData *tech = &TECHS[task->tech - 1];
752
753 children[0].enemyAttack = FIGHTSTG_startEnemyAttack(1, tech->script == 0xC);
754 task->substate++;
755 }
756 break;
757 case 8:
758 if (children[0].task == NULL) {
759 task->setState(task, 3);
760 }
761 break;
762 case 9:
763 if (children[0].task == NULL) {
764 TechData *tech = &TECHS[task->tech - 1];
765
766 if (tech->icon == TECH_PHYSICAL) {
767 children[0].counter = FIGHTSTG_startCounterattack((task->side == 0) << 4, task->damage, tech->script == 0xC);
768 task->substate = 6;
769 } else {
770 task->substate = 5;
771 }
772 }
773 break;
774 }
775 break;
776 case 2:
777 case 3:
778 break;
779 }
780}
781
782/* Starts side's (0 or 0x10) technique or item tech */
785
786 task->side = side;
787 task->tech = tech;
788 return task;
789}
ActionEvents * FIGHTSTG_startActionEvents(s32 side)
Starts running the current action's events for SIDE (FIGHTSTG_updateActionEvents)
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_startRestriction(s32 tech)
Restricts the partner with technique tech: sets FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE by the tech...
Definition battle.c:43
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_queueKnockOut(u8 side)
Queues the fall of side's active fighter (event 20), first.
Definition battle.c:107
void FIGHTSTG_queuePartnerTech(s32 tech)
Queues the partner's technique tech, to run as its command.
Definition battle.c:80
static BattleFighter * FIGHTSTG_getActiveFighter(s32 row)
Row's active fighter (FIGHTSTG_battle.state.fighters[row][active[row]]), as the row's offset in bytes...
Definition battle.h:497
#define BATTLE_ACTION_STATE_SIZE
FIGHTSTG_action's bytes before start, which a new action clears.
Definition battle.h:386
#define TECH_EFFECT_DOUBLE_MAGIC
two magic hits, as techniques 0x1B9 and 0x1BA
Definition battle.h:267
#define FIGHTER_PARALYZED
loses turns at random (FIGHTSTG_battleFuncs.testParalysis)
Definition battle.h:183
#define TECH_EFFECT_MULTI_HIT
Definition battle.h:258
#define EVENT_STATUS_DAMAGE
the damage of a poisoned fighter (FIGHTER_POISONED)
Definition battle.h:89
#define FIGHTER_POISONED
BattleFighter.flags: the statuses, which the techniques give (FIGHTSTG_inflict*) and events of type E...
Definition battle.h:182
#define TECH_MAGIC
FIGHTSTG_rollMagicHit and FIGHTSTG_computeMagicDamage.
Definition battle.h:43
#define TECH_EFFECT_ENEMY_ONLY
does nothing but for the enemy whose battle table entry lists it first
Definition battle.h:259
#define TECH_EFFECT_KNOCK_OUT
Definition battle.h:256
#define BATTLE_STAT_SPIRIT
magic damage, and against it
Definition battle.h:31
#define TECH_PHYSICAL
TechData.icon's kinds of attack.
Definition battle.h:42
#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 EVENT_RESTRICTION_END
16-17: the end of a restriction (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE)
Definition battle.h:92
#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 SIDE_ENEMY
Definition battle.h:178
#define FIGHTER_CONFUSED
Definition battle.h:184
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 ...
Definition events.c:417
void FIGHTSTG_queueAutoRecoverEnd(u8 side)
Queues the end of side's automatic recovery (item 0xBD), or pushes back the one already queued.
Definition events.c:396
void FIGHTSTG_queueClearField(s32 time)
Queues the field's clearing in time (at most 0x7FFF), or moves the one already queued to it.
Definition events.c:436
EventQueue FIGHTSTG_events
the battle's events and their functions
Definition events.c:43
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 ...
Definition events.c:565
FIGHTSTG.PRO: the battle.
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned char u8
Definition common.h:8
Counterattack * FIGHTSTG_startCounterattack(s32 side, s32 received, s32 noKnockOutEvent)
Starts SIDE's counterattack (FIGHTSTG_updateCounterattack) to RECEIVED damage; NOKNOCKOUTEVENT keeps ...
void FIGHTSTG_reviveFighter(s32 tech, s32 fighter)
Revives one of the player's fighters at full HP, clearing its status events, and raises its defense b...
EnemyAttack * FIGHTSTG_startEnemyAttack(s32 kind, s32 noKnockout)
Starts an attack on the player's active fighter (FIGHTSTG_updateEnemyAttack): kind 0 for the enemy's ...
#define TASK_RUN
Definition task.h:35
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define BATTLE_BLOCK_LOWER_ATTACK
to 10: attack, defense, speed (a technique's boost stat + 8)
Definition game_state.h:371
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
BattleSetup BATTLE_SETUP
Definition items.c:886
BattleMessageBox * FIGHTSTG_createMessage(void)
Creates a battle message box (FIGHTSTG_updateMessage)
Definition message.c:440
void WFIGHTMN_checkEquip(s32 member)
Queues a recovery (FIGHTSTG_queueRecovery) for party member MEMBER's partner when it has WFIGHTMN_REC...
Definition setup.c:81
u8 effects[0x28]
by TECH_EFFECT_*: what each one does, 0 for none
Definition battle.h:283
void(* start)(u8 side, s32 tech)
FIGHTSTG_startAction.
Definition battle.h:285
s16 hitsLanded
Definition battle.h:281
s32 damage
per hit
Definition battle.h:278
u8 hits[4]
whether each hit lands
Definition battle.h:280
s32 hitDamage[2]
TECH_EFFECT_DOUBLE_MAGIC's.
Definition battle.h:284
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 charge
added in 64ths to its next technique's damage, which uses it up
Definition battle.h:199
s16 id
the Digimon (DIGIMON_DATA)
Definition battle.h:192
s32(* testWakeUp)(u8 side, s32 value)
Definition battle.h:356
void(* changeBoost)(u8 side, s32 index, s32 stat, s32 percent)
changes a fighter's stat boost
Definition battle.h:359
s32(* rollNoSwitch)(s32 actor, s32 id)
Definition battle.h:349
s32(* rollNoDigivolve)(s32 actor, s32 id)
Definition battle.h:350
s32(* computeHeal)(u8 side, s32 id)
Definition battle.h:336
s32(* rollDedigivolve)(s32 actor, s32 id)
Definition battle.h:347
BattleStats *(* computeStats)(u8 side, s32 which, s32 index)
Definition battle.h:331
void(* show)()
FIGHTSTG_showMessage: (task, type, data)
Definition menu.h:182
u8 blocks[12]
by BATTLE_BLOCK_*: what the player can't do in the battle
Definition game_state.h:389
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
ElementBoost boost
Definition battle.h:228
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
s16 amount
in 128ths
Definition battle.h:220
s16 element
under ELEMENT_FIRST: none
Definition battle.h:219
void(* cureStatus)(u8 side, s32 fighter, s32 item)
FIGHTSTG_cureStatus: an item's cure.
Definition battle.h:149
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
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
s16 type
0 for a free entry
Definition battle.h:110
Any task, seen through its header.
Definition task.h:62
s32 state
Definition task.h:63
void(* nextState)(struct TechAction *task)
Definition action.h:68
void(* nextSubstate)(struct TechAction *task)
Definition action.h:68
void(* setSubstate)(struct TechAction *task, s32 substate)
Definition action.h:68
s32 heal
the HP an item heals
Definition action.h:72
s32 state
Definition action.h:68
s32 lines[8]
FIGHTSTG_updateMessage's.
Definition action.h:74
s32 counter
Definition action.h:68
u8 side
the side that uses it, 0 or 0x10
Definition action.h:69
s32 step
Definition action.h:68
s32 damage
Definition action.h:71
s32 asleep
whether the other side's fighter was asleep
Definition action.h:73
s32 substate
Definition action.h:68
s32 tech
the technique or item
Definition action.h:70
void(* setState)(struct TechAction *task, s32 state)
Definition action.h:68
A technique's boost (FIGHTSTG_techBoosts and FIGHTSTG_sideBoosts, each ended by -1)
Definition action.h:40
s16 tech
Definition action.h:41
s16 stat
Definition action.h:43
s16 amount
times the technique's effectPower, below 0 for the other side
Definition action.h:42
s16 line
the message
Definition action.h:44
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
u8 element
ELEMENT_FIRST and up, under it none.
Definition game_state.h:116
u8 icon
a frame of the menu sprites, from 0x37
Definition game_state.h:113
u8 script
its script in the user's archive (BattleScript.index); 5 and 12 are special
Definition game_state.h:125
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
static void healEnemy(TechAction *task, BattleChild *children)
Technique 0x190: heals the enemy by FIGHTSTG_computeHeal and charges it.
static void healWithTech(TechAction *task, BattleChild *children)
The other item techniques: heal the user, or its whole side for 0xBB and above, by FIGHTSTG_computeHe...
static void boostSideStat(TechAction *task, BattleChild *children, TechData *tech)
Techniques 0xC7, 0xC9 and 0xCB (FIGHTSTG_sideBoosts): boost a stat of all the user's side.
static void reviveSide(TechAction *task, BattleChild *children)
Technique 0x64: revives the partners knocked out to their max HP.
static void boostFighterStat(TechAction *task, BattleChild *children, TechData *tech)
Techniques 0xC6-0xD0 (FIGHTSTG_techBoosts): boost a stat of the user, or lower the other side's,...
TechBoost FIGHTSTG_sideBoosts[]
and the ones that boost a stat of all the user's side
Definition tech_action.c:20
s32 FIGHTSTG_clearIds[]
the event types that the European version's FIGHTSTG_reviveFighter clears
Definition tech_action.c:33
s32 FIGHTSTG_statusTechArgs[]
the argument of message 9, which the odd techniques show,
Definition tech_action.c:39
static void useSupportTech(TechAction *task, BattleChild *children, TechData *tech)
A support technique: a boost, a charge, a restriction or digidevolving the enemy, or the enemy's drai...
void FIGHTSTG_updateTechAction(TechAction *task, BattleChild *children)
A side's technique or item (FIGHTSTG_startTechAction): state 0 shows its message (announceTech),...
s32 FIGHTSTG_statusTechLines[]
and the message shown when the target has the status
Definition tech_action.c:43
static void chargeUser(TechAction *task, BattleChild *children, TechData *tech)
Techniques 0xD1 and 0xD2: charge the user by the technique's power.
static void restoreSide(TechAction *task, BattleChild *children)
Technique 0x177: revives the partners and restores them whole, statuses included.
static void wakeUpOrCounter(TechAction *task, BattleChild *children)
After the technique: wakes the other side's fighter when it was asleep and the damage wakes it (or en...
static void announceTech(TechAction *task, BattleChild *children)
Starts the technique: its action for a physical or magic one, its message, and whether the other side...
Definition tech_action.c:49
TechBoost FIGHTSTG_techBoosts[]
the techniques that boost a stat of a fighter (FIGHTSTG_updateTechAction): the user's,...
Definition tech_action.c:8
static void drainMp(TechAction *task, BattleChild *children, TechData *tech)
Technique 0x188: the enemy drains the partner's MP by the technique's power in 128ths of its max MP.
static void dealTechDamage(TechAction *task, BattleChild *children)
A physical or magic technique: deals its damage to the other side's fighter (or its hits',...
static void boostFieldElement(TechAction *task, BattleChild *children, TechData *tech)
Icon 6's techniques: set the field's boosted element and its amount (the user's spirit / 10 plus the ...
u8 FIGHTSTG_statusTechFlags[]
techniques 0xBE-0xC5's four kinds of status (FIGHTSTG_updateTechAction): the flag of each in BattleFi...
Definition tech_action.c:28
TechAction * FIGHTSTG_startTechAction(s32 side, s32 tech)
Starts side's (0 or 0x10) technique or item tech.
static void startTechScript(TechAction *task, BattleChild *children)
Once the message is gone, starts the technique's script and spends the user's charge,...
Definition tech_action.c:80
static void useItemTech(TechAction *task, BattleChild *children)
An item technique: an auto-recovery, a cure, a revival or a heal.
static void cureStatusTech(TechAction *task, BattleChild *children)
Techniques 0xBE-0xC5: cure one of the four kinds of status (FIGHTSTG_statusTechFlags),...
BattleScript * WFIGHTMN_startTech(u8 actor, s32 id)
Starts the effect of actor's move id (FIGHTSTG's FIGHTSTG_createBattleScript): its kind and motions f...
Definition techs.c:150
void WFIGHTMN_chargeGauge(u8 side, s32 damage)
Adds what damage gives to the current partner's gauge (BATTLE_SETUP.gauges), up to 1000.
Definition techs.c:35
void WFIGHTMN_endWeakness(u8 side)
In BATTLE_KIND_FINAL_LAST, anything the partner does but an attack ends the enemy's weakness (FIGHTST...
Definition techs.c:312
A turn's or a counterattack's one child, and what WFIGHTMN's battle menu waits for (NULL when it is d...
Definition task.h:16
Counterattack * counter
a counterattack (FIGHTSTG_startCounterattack)
Definition task.h:32
ActionEvents * events
the queued events (FIGHTSTG_startActionEvents)
Definition task.h:33
BattleMessageBox * message
FIGHTSTG_createMessage.
Definition task.h:18
Task * task
Definition task.h:17
BattleScript * script
a technique's (FIGHTSTG_createBattleScript)
Definition task.h:19
EnemyAttack * enemyAttack
an attack on the player's fighter (FIGHTSTG_startEnemyAttack)
Definition task.h:25