Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
btl_states_actions.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "ld_addrs.h"
4#include "effects.h"
5#include "hud_element.h"
6#include "battle/battle.h"
7#include "model.h"
8#include "game_modes.h"
9#include "dx/debug_menu.h"
10
11#if VERSION_JP
12extern Addr btl_states_menus_ROM_START;
13extern Addr btl_states_menus_ROM_END;
14extern Addr btl_states_menus_VRAM;
15#endif
16
18
19extern s16 D_802809F6;
20extern s16 DemoBattleBeginDelay;
21extern s32 BattleScreenFadeAmt;
23extern s32 bActorsIgnoreDuringCount[];
26
29BSS s32 BattleSubStateDelay; // generic delay time usable for various substates
37
38b32 dispatch_damage_tick_event_player(s32 damageAmount, s32 event);
39
41
43 BattleStatus* battleStatus = &gBattleStatus;
44 EncounterStatus* currentEncounter = &gCurrentEncounter;
45 PlayerData* playerData = &gPlayerData;
46
50 && playerData->merleeCastsLeft > 0
51 ) {
52 if (playerData->merleeTurnCount <= 0) {
53 s32 temp = rand_int(100);
54
55 if (currentEncounter->curEnemy != NULL) {
56 if (currentEncounter->curEnemy->flags & ACTOR_FLAG_NO_HEALTH_BAR) {
57 // 46/101 ≈ 45.5%
58 if (temp <= 45) {
60 } else if (temp <= 90) { // 45/101 ≈ 44.6%
62 } else { // 10/101 ≈ 9.9%
64 }
65 } else if (temp <= 30) { // 31/101 ≈ 30.7%
67 } else if (temp <= 60) { // 30/101 ≈ 29.7%
69 } else if (temp <= 80) { // 20/101 ≈ 19.8%
71 } else { // 20/101 ≈ 19.8%
73 }
74 } else if (temp <= 30) { // 31/101 ≈ 30.7%
76 } else if (temp <= 60) { // 30/101 ≈ 29.7%
78 } else if (temp <= 80) { // 20/101 ≈ 19.8%
80 } else { // 20/101 ≈ 19.8%
82 }
83
84 temp = rand_int(10) + 6;
85 playerData->merleeTurnCount = temp;
86 }
87
88 if (playerData->merleeTurnCount >= 2) {
89 playerData->merleeTurnCount--;
90 } else {
91 playerData->merleeTurnCount = 0;
92 battleStatus->nextMerleeSpellType = playerData->merleeSpellType;
93 playerData->merleeCastsLeft--;
94 }
95 }
96}
97
99 BattleStatus* battleStatus = &gBattleStatus;
100 EncounterStatus* currentEncounter = &gCurrentEncounter;
101 PlayerData* playerData = &gPlayerData;
102
106 && playerData->merleeCastsLeft > 0)
107 {
108 if (playerData->merleeTurnCount <= 0) {
109 s32 temp = rand_int(100);
110
111 if (currentEncounter->curEnemy != NULL) {
112 if (currentEncounter->curEnemy->flags & ACTOR_FLAG_NO_HEALTH_BAR) {
113 // 46/101 ≈ 45.5%
114 if (temp <= 45) {
116 } else if (temp <= 90) { // 45/101 ≈ 44.6%
118 } else { // 10/101 ≈ 9.9%
120 }
121 } else if (temp <= 30) { // 31/101 ≈ 30.7%
123 } else if (temp <= 60) { // 30/101 ≈ 29.7%
125 } else if (temp <= 80) { // 20/101 ≈ 19.8%
127 } else { // 20/101 ≈ 19.8%
129 }
130 } else if (temp <= 30) { // 31/101 ≈ 30.7%
132 } else if (temp <= 60) { // 30/101 ≈ 29.7%
134 } else if (temp <= 80) { // 20/101 ≈ 19.8%
136 } else { // 20/101 ≈ 19.8%
138 }
139
140 if (playerData->merleeSpellType != MERLEE_SPELL_COIN_BOOST) {
141 // same outcome either way. has to be written like this, and the check does exist in the code. bug?
142 if (playerData->merleeTurnCount == -1) {
143 temp = rand_int(5) + 5;
144 } else {
145 temp = rand_int(5) + 5;
146
147 }
148 } else {
149 temp = rand_int(8) + 5;
150 }
151 playerData->merleeTurnCount = temp;
152 }
153
155 if (playerData->merleeTurnCount >= 2) {
156 playerData->merleeTurnCount--;
157 } else {
158 battleStatus->nextMerleeSpellType = playerData->merleeSpellType;
159 playerData->merleeTurnCount = 0;
160 playerData->merleeCastsLeft--;
161 }
162 }
163 }
164}
165
166void btl_set_state(s32 battleState) {
168 gBattleState = battleState;
170
172 if (flags) {
173 switch (battleState) {
175 battleState = BATTLE_STATE_TWINK_MENU;
176 break;
178 battleState = BATTLE_STATE_PEACH_MENU;
179 break;
182 break;
184 battleState = BATTLE_STATE_BEGIN_PLAYER_TURN;
185 break;
186 }
187 gBattleState = battleState;
188 }
189}
190
192 BattleStatus* battleStatus = &gBattleStatus;
193 EncounterStatus* currentEncounter = &gCurrentEncounter;
194 Battle* battle;
195 Stage* stage;
196 s32 size;
197 StatusBar* statusBar;
198 void* compressedAsset;
199 ModelNode* rootModel;
200 s32 texturesOffset;
201 Actor* actor;
202 Evt* script;
203 s32 enemyNotDone;
204 s32 type;
205 s32 i;
206 s32 j;
207
208 s32* types;
209
210 battle = gCurrentBattlePtr;
211 if (gOverrideBattlePtr != NULL) {
212 battle = gOverrideBattlePtr;
213 }
214
215 if (gCurrentStagePtr == NULL) {
216 stage = battle->stage;
217 } else {
218 stage = gCurrentStagePtr->stage;
219 }
220
221 battleStatus->curStage = stage;
222 switch (gBattleSubState) {
224 #if DX_DEBUG_MENU
225 dx_debug_set_battle_info(gCurrentBattleID << 16 | (gCurrentStageID & 0xFFFF), stage->shape);
226 #endif
227
230 compressedAsset = load_asset_by_name(stage->shape, &size);
231 decode_yay0(compressedAsset, &gMapShapeData);
232 general_heap_free(compressedAsset);
233
234 ASSERT(size <= 0x8000);
235
236 rootModel = gMapShapeData.header.root;
237 texturesOffset = get_asset_offset(stage->texture, &size);
238 if (rootModel != NULL) {
239 load_data_for_models(rootModel, texturesOffset, size);
240 }
242
243 if (stage->bg != NULL) {
244 load_map_bg(stage->bg);
246 }
247
250 }
251
252 battleStatus->controlScript = NULL;
253 battleStatus->camMovementScript = NULL;
254 battleStatus->unk_90 = 0;
255 battleStatus->preUpdateCallback = NULL;
256 battleStatus->initBattleCallback = NULL;
257 battleStatus->curSubmenu = 0;
258 battleStatus->unk_49 = 0;
259 battleStatus->curPartnerSubmenu = 0;
260 battleStatus->unk_4B = 0;
261 battleStatus->totalStarPoints = 0;
262 battleStatus->pendingStarPoints = 0;
263 battleStatus->incrementStarPointDelay = 0;
264 battleStatus->damageTaken = 0;
272 }
273 battleStatus->actionSuccess = 0;
274 battleStatus->unk_82 = 0;
275 battleStatus->enabledMenusFlags = -1;
276 battleStatus->enabledStarPowersFlags = -1;
277 battleStatus->itemUsesLeft = 0;
278 battleStatus->hammerCharge = 0;
279 battleStatus->jumpCharge = 0;
280 battleStatus->unk_98 = 0;
281 battleStatus->hpDrainCount = 0;
283 if (currentEncounter->forbidFleeing) {
284 gBattleStatus.flags2 &= ~BS_FLAGS2_CAN_FLEE;
285 }
286 battleStatus->endBattleFadeOutRate = 10;
287 battleStatus->waitForState = BATTLE_STATE_0;
288 battleStatus->hammerLossTurns = -1;
289 battleStatus->jumpLossTurns = -1;
290 battleStatus->itemLossTurns = -1;
291 battleStatus->outtaSightActive = 0;
292 battleStatus->waterBlockTurnsLeft = 0;
293 battleStatus->waterBlockAmount = 0;
294 battleStatus->waterBlockEffect = NULL;
295 battleStatus->cloudNineTurnsLeft = 0;
296 battleStatus->cloudNineDodgeChance = 0;
297 battleStatus->cloudNineEffect = NULL;
298 battleStatus->reflectFlags = 0;
299 battleStatus->turboChargeTurnsLeft = 0;
300 battleStatus->turboChargeAmount = 0;
301 battleStatus->stateFreezeCount = 0;
302 battleStatus->merleeAttackBoost = 0;
303 battleStatus->merleeDefenseBoost = 0;
305 battleStatus->unk_433 = -1;
306 battleStatus->hustleTurns = 0;
307 battleStatus->unk_93 = 0;
308 battleStatus->unk_94 = 0;
309 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
310 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
311 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
312 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
313 gBattleStatus.flags2 &= ~BS_FLAGS2_STORED_TURBO_CHARGE_TURN;
314 gBattleStatus.flags2 &= ~BS_FLAGS2_DOING_JUMP_TUTORIAL;
315
316 for (i = 0; i < ARRAY_COUNT(battleStatus->varTable); i++) {
317 battleStatus->varTable[i] = 0;
318 }
319
321 battleStatus->inputBitmask = 0xFFFFF & ~(BUTTON_START | 0xC0);
322 battleStatus->buffEffect = fx_partner_buff(0, 0.0f, 0.0f, 0.0f, 0.0f, 0);
326 battleStatus->camMovementScript = script;
327 battleStatus->camMovementScriptID = script->id;
329 break;
331 statusBar = &gStatusBar;
332 if (does_script_exist(battleStatus->camMovementScriptID)) {
333 break;
334 }
335
336 if (stage->preBattle != NULL) {
337 script = start_script(stage->preBattle, EVT_PRIORITY_A, 0);
338 battleStatus->controlScript = script;
339 battleStatus->controlScriptID = script->id;
340 }
341
342 statusBar->hidden = FALSE;
344
345 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
346 battleStatus->enemyActors[i] = NULL;
347 }
348 battleStatus->initialEnemyCount = 0;
349
350 for (i = 0; i < BattleEnemiesCreated; i++) {
351 create_actor(&(*battle->formation)[i]);
353 actor = battleStatus->enemyActors[i];
354
355 while (TRUE) {
356 type = *types;
357 if (type == -1) {
358 battleStatus->initialEnemyCount++;
359 break;
360 } else if (actor->actorType == type) {
361 break;
362 }
363 types++;
364 }
365
366 actor->instigatorValue = 0;
367 if (i == 0) {
368 actor->instigatorValue = currentEncounter->instigatorValue;
369 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
371 }
372 }
373 }
374
375 if (stage->stageEnemyCount != 0) {
376 if (stage->stageEnemyChance == 0 || (stage->stageEnemyChance > 0 && (rand_int(stage->stageEnemyChance) == 0))) {
378 for (j = 0; i < BattleEnemiesCreated; i++, j++) {
379 create_actor(&(*stage->stageFormation)[j]);
380 actor = battleStatus->enemyActors[i];
381 actor->instigatorValue = 0;
382 if (i == 0) {
383 actor->instigatorValue = 0;
384 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
386 }
387 }
388
389 }
390 }
391 }
392
394 actor = battleStatus->playerActor;
397 } else {
399 }
400 actor->takeTurnScript = script;
401 actor->takeTurnScriptID = script->id;
402 script->owner1.actorID = ACTOR_PLAYER;
405 break;
407 enemyNotDone = FALSE;
408 for (i = 0; i < BattleEnemiesCreated; i++) {
409 actor = battleStatus->enemyActors[i];
411 enemyNotDone = TRUE;
412 break;
413 } else {
414 actor->takeTurnScript = NULL;
415 }
416 }
417 if (enemyNotDone) {
418 break;
419 }
420
421 actor = battleStatus->playerActor;
423 break;
424 }
425 actor->takeTurnScript = NULL;
426
427 actor = battleStatus->partnerActor;
428 if (actor != NULL) {
430 break;
431 }
432 actor->takeTurnScript = NULL;
433 }
434
435 if (battle->onBattleStart != NULL) {
436 script = start_script(battle->onBattleStart, EVT_PRIORITY_A, 0);
437 battleStatus->controlScript = script;
438 battleStatus->controlScriptID = script->id;
439 }
440 if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) {
443 }
445 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
446 }
447
448 switch (currentEncounter->firstStrikeType) {
451 break;
454 break;
455 default:
457 actor = battleStatus->playerActor;
460 } else {
462 }
463 actor->takeTurnScript = script;
464 actor->takeTurnScriptID = script->id;
465 script->owner1.actorID = ACTOR_PLAYER;
466 }
467
468 if (currentEncounter->curEnemy != NULL
469 && currentEncounter->curEnemy->encountered == ENCOUNTER_TRIGGER_SPIN
471 ) {
472 actor = battleStatus->enemyActors[0];
474 actor->takeTurnScript = script;
475 actor->takeTurnScriptID = script->id;
476 script->owner1.enemyID = ACTOR_ENEMY0;
477 }
478
482 break;
483 }
484 break;
486 if (BattleScreenFadeAmt == 0) {
488 break;
489 }
490
492 if (BattleSubStateDelay == 15) {
494 }
495
498 } else {
500 }
501
502 if (BattleScreenFadeAmt < 0) {
504 }
505 break;
507 if (battleStatus->stateFreezeCount == 0) {
510 }
511 break;
512 }
513}
514
524
526 BattleStatus* battleStatus = &gBattleStatus;
527 PlayerData* playerData = &gPlayerData;
528 Actor* partner = battleStatus->partnerActor;
529 Actor* player = battleStatus->playerActor;
530 Actor* enemy;
531 Actor* enemy1;
532 Actor* enemy2;
533 Evt* script;
534 Evt* script2;
535 s32 cond;
536 u16 id1;
537 u16 id2;
538 s32 numEnemyActors;
539 s32 i;
540 s32 j;
541 s16* enemyIDs;
542
544 battleStatus->flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
545 battleStatus->flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
546 battleStatus->flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
547 battleStatus->flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
548 battleStatus->merleeAttackBoost = 0;
549 battleStatus->merleeDefenseBoost = 0;
550 battleStatus->flags2 &= ~BS_FLAGS2_IS_FIRST_STRIKE;
551
553 player->disableDismissTimer = 0;
554 if (partner != NULL) {
556 partner->disableDismissTimer = 0;
557 }
558
559 if (battleStatus->hustleTurns != 0) {
561 }
562
563 numEnemyActors = 0;
564 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
565 enemy = battleStatus->enemyActors[i];
566 if (enemy != NULL) {
567 battleStatus->enemyIDs[numEnemyActors] = i | ACTOR_ENEMY0;
568 numEnemyActors++;
569 }
570 }
571 battleStatus->numEnemyActors = numEnemyActors;
572
573 // sort enemies by x-position or turn priority
574 enemyIDs = battleStatus->enemyIDs;
575 for (i = 0; i < numEnemyActors - 1; i++) {
576 for (j = i + 1; j < numEnemyActors; j++) {
577 id1 = enemyIDs[i];
578 id2 = enemyIDs[j];
579 enemy1 = battleStatus->enemyActors[id1 & 0xFF];
580 enemy2 = battleStatus->enemyActors[id2 & 0xFF];
582 if (enemy1->homePos.x > enemy2->homePos.x) {
583 enemyIDs[i] = id2;
584 enemyIDs[j] = id1;
585 }
586 } else if (enemy1->turnPriority < enemy2->turnPriority) {
587 enemyIDs[i] = id2;
588 enemyIDs[j] = id1;
589 }
590 }
591 }
592 battleStatus->nextEnemyIndex = 0;
593
595
596 // clear rush flags to initialize
597 battleStatus->rushFlags = RUSH_FLAG_NONE;
598 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH;
599
600 // set rush flags based on danger/peril status
604 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
605 }
607 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
609 battleStatus->rushFlags |= RUSH_FLAG_POWER;
610 }
611 }
612 }
613
615 battleStatus->jumpCharge = 0;
616 }
617
619 battleStatus->hammerCharge = 0;
620 }
621
624 return;
625 }
626
628 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
629 enemy = battleStatus->enemyActors[i];
630 if (enemy != NULL && enemy->handleEventSource != NULL) {
631 Evt* script = start_script(enemy->handleEventSource, EVT_PRIORITY_A, 0);
632
633 enemy->handleEventScript = script;
634 script->owner1.actorID = i | ACTOR_ENEMY0;
635 enemy->handleEventScriptID = script->id;
636 enemy->lastEventType = EVENT_DEATH;
637 }
638 }
640 } else {
641 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
642 enemy = battleStatus->enemyActors[i];
643 if (enemy != NULL && enemy->handlePhaseSource != NULL) {
644 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
645 script = start_script(enemy->handlePhaseSource, EVT_PRIORITY_A, 0);
646 enemy->handlePhaseScript = script;
647 enemy->handleBatttlePhaseScriptID = script->id;
648 script->owner1.actorID = i | ACTOR_ENEMY0;
649 }
650 }
651
652 partner = battleStatus->partnerActor;
653 if (partner != NULL) {
654 if (partner->handlePhaseSource != NULL) {
655 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
656 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
657 partner->handlePhaseScript = script;
658 partner->handleBatttlePhaseScriptID = script->id;
659 script->owner1.actorID = ACTOR_PARTNER;
660 }
661 }
663 }
664 }
665
667 cond = FALSE;
668 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
669 enemy = battleStatus->enemyActors[i];
670 if (enemy != NULL && enemy->handlePhaseSource != NULL && does_script_exist(enemy->handleBatttlePhaseScriptID)) {
671 cond = TRUE;
672 }
673 }
674 if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) {
675 cond = TRUE;
676 }
677
678 if (!cond) {
681 }
682 return;
683 }
684 }
685
687 cond = FALSE;
688 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
689 enemy = battleStatus->enemyActors[i];
690 if (enemy != NULL && enemy->handleEventSource != NULL && does_script_exist(enemy->handleEventScriptID)) {
691 cond = TRUE;
692 }
693 }
694
695 if (!cond) {
698 }
699 }
700 }
701}
702
705
707 BattleStatus* battleStatus = &gBattleStatus;
708 PlayerData* playerData = &gPlayerData;
709 Actor* player = battleStatus->playerActor;
710 Actor* partner = battleStatus->partnerActor;
711 ActorPart* part = &player->partsTable[0];
712 Evt* script;
713 s32 i;
714
715 s8 debuffDuration;
716 s32 koDuration;
717 s32 temp;
718
721 btl_cam_move(5);
723 }
724
725 switch (gBattleSubState) {
728 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
730 battleStatus->actionResult = ACTION_RESULT_NONE;
731 battleStatus->blockResult = BLOCK_RESULT_NONE;
732 battleStatus->selectedMoveID = 0;
734 gBattleStatus.flags2 &= ~BS_FLAGS2_IS_FIRST_STRIKE;
735 player->disableDismissTimer = 0;
737
738 if (partner != NULL) {
740 partner->disableDismissTimer = 0;
741 }
742
743 battleStatus->stateFreezeCount = 0;
744 D_8029F254 = FALSE;
745 D_8029F258 = 0;
746
747 if (battleStatus->outtaSightActive == 0) {
749 } else {
750 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
751 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
752 partner->handlePhaseScript = script;
754 partner->handleBatttlePhaseScriptID = script->id;
755 script->owner1.actorID = ACTOR_PARTNER;
756 }
757 }
758 break;
761 battleStatus->outtaSightActive = 0;
764 }
765 break;
766 }
767
768 switch (gBattleSubState) {
770 if (battleStatus->stateFreezeCount == 0) {
771 if (battleStatus->waterBlockTurnsLeft != 0) {
772 battleStatus->waterBlockTurnsLeft--;
774 if (battleStatus->waterBlockTurnsLeft <= 0) {
776 fx_water_block(FX_WATER_BLOCK_DESTROY, player->curPos.x, player->curPos.y + 18.0f, player->curPos.z + 5.0f, 1.5f, 10);
777 fx_water_splash(0, player->curPos.x - 10.0f, player->curPos.y + 5.0f, player->curPos.z + 5.0f, 1.0f, 24);
778 fx_water_splash(0, player->curPos.x - 15.0f, player->curPos.y + 32.0f, player->curPos.z + 5.0f, 1.0f, 24);
779 fx_water_splash(1, player->curPos.x + 15.0f, player->curPos.y + 22.0f, player->curPos.z + 5.0f, 1.0f, 24);
780 battleStatus->waterBlockEffect = NULL;
784 } else {
786 }
787 } else {
789 }
790 }
791 break;
793 if (!btl_is_popup_displayed()) {
795 }
796 break;
797 }
798
799 switch (gBattleSubState) {
801 if (battleStatus->cloudNineTurnsLeft != 0) {
802 battleStatus->cloudNineTurnsLeft--;
804
805 if (battleStatus->cloudNineTurnsLeft <= 0) {
806 remove_effect(battleStatus->cloudNineEffect);
807 battleStatus->cloudNineEffect = NULL;
810 } else {
812 }
813 } else {
815 }
816 break;
818 if (!btl_is_popup_displayed()) {
820 }
821 break;
822 }
823
824 switch (gBattleSubState) {
826 if (battleStatus->turboChargeTurnsLeft != 0) {
828 gBattleStatus.flags2 &= ~BS_FLAGS2_STORED_TURBO_CHARGE_TURN;
830 } else {
831 battleStatus->turboChargeTurnsLeft--;
833 if (battleStatus->turboChargeTurnsLeft <= 0) {
836 } else {
838 }
839 }
840 } else {
842 }
843 break;
845 if (!btl_is_popup_displayed()) {
847 }
848 break;
849 }
850
852 if (player->debuff == STATUS_KEY_POISON && player->stoneStatus == 0) {
855 }
856
857 // clear rush flags to initialize
858 battleStatus->rushFlags = RUSH_FLAG_NONE;
859 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH;
860
861 // set rush flags based on danger/peril status
865 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
866 }
868 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
870 battleStatus->rushFlags |= RUSH_FLAG_POWER;
871 }
872 }
873 }
875 }
876
878 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
879 player->handleEventScript = NULL;
881 return;
882 }
883
884 D_8029F254 = FALSE;
885 player->disableDismissTimer = 0;
887
889 if (player->debuff != 0) {
890 player->debuffDuration = 1;
891 }
892 if (player->staticStatus != 0) {
893 player->staticDuration = 1;
894 }
895 if (player->stoneStatus != 0) {
896 player->stoneDuration = 1;
897 }
898 if (player->koStatus != 0) {
899 player->koDuration = 1;
900 }
901 if (player->transparentStatus != 0) {
902 player->transparentDuration = 1;
903 }
904 }
905
906 if (player->stoneStatus != 0) {
907 player->stoneDuration--;
908 if (player->stoneDuration <= 0) {
909 player->stoneStatus = 0;
911 }
912 } else {
913 if (!is_ability_active(ABILITY_ZAP_TAP) && player->staticStatus != 0) {
914 player->staticDuration--;
915 if (player->staticDuration <= 0) {
916 player->staticStatus = 0;
918 }
919 }
920 if (player->transparentStatus != 0) {
921 player->transparentDuration--;
923 if (player->transparentDuration <= 0) {
924 player->transparentStatus = 0;
925 part->flags &= ~ACTOR_PART_FLAG_TRANSPARENT;
927 }
928 }
929
930 if (player->debuff != 0) {
931 if (player->debuff < 9) {
932 D_8029F254 = TRUE;
933 }
934 D_8029F258 = 20;
935 player->debuffDuration--;
936 if (player->debuffDuration <= 0) {
937 if (player->debuff == STATUS_KEY_FROZEN) {
940 player->icePillarEffect = NULL;
942 } else {
944 }
945 player->debuff = 0;
946 player->debuffDuration = 0;
948 }
949 }
950
951 debuffDuration = player->debuffDuration;
952 temp = player->koDuration;
953 player->koDuration = debuffDuration;
954 if (debuffDuration > 0) {
955 player->koStatus = STATUS_KEY_DAZE;
956 player->disableEffect->data.disableX->koDuration = player->koDuration;
957 } else if (temp != debuffDuration) {
958 player->koStatus = 0;
959 player->koDuration = 0;
961 }
962 }
963
964 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
965 Actor* enemy = battleStatus->enemyActors[i];
966
967 if (enemy != NULL) {
969 if (enemy->chillOutTurns != 0) {
970 enemy->chillOutTurns--;
971 if (enemy->chillOutTurns == 0) {
972 enemy->chillOutAmount = 0;
974 D_8029F258 = 20;
975 }
976 }
977 }
978 }
980 }
981 }
982
985 return;
986 }
987 temp = 1;
988 battleStatus->stateFreezeCount = 0;
989 if (battleStatus->hammerLossTurns >= 0) {
990 battleStatus->hammerLossTurns--;
991 if (battleStatus->hammerLossTurns == -1) {
993 player->takeTurnScript = script;
994 player->takeTurnScriptID = script->id;
995 script->owner1.actorID = ACTOR_PLAYER;
996 script->varTable[0] = temp;
997 temp += 8; // temp here should be named itemSpawnOffsetX
998 script->varTable[10] = BTL_MENU_TYPE_SMASH;
999 battleStatus->stateFreezeCount = 1;
1000 }
1001 }
1002
1003 if (battleStatus->jumpLossTurns >= 0) {
1004 battleStatus->jumpLossTurns--;
1005 if (battleStatus->jumpLossTurns == -1) {
1007 player->takeTurnScript = script;
1008 player->takeTurnScriptID = script->id;
1009 script->owner1.actorID = ACTOR_PLAYER;
1010 script->varTable[0] = temp;
1011 temp += 8;
1012 script->varTable[10] = BTL_MENU_TYPE_JUMP;
1013 battleStatus->stateFreezeCount = 1;
1014 }
1015 }
1016
1017 if (battleStatus->itemLossTurns >= 0) {
1018 battleStatus->itemLossTurns--;
1019 if (battleStatus->itemLossTurns == -1) {
1021 player->takeTurnScript = script;
1022 player->takeTurnScriptID = script->id;
1023 script->owner1.actorID = ACTOR_PLAYER;
1024 script->varTable[0] = temp;
1025 temp += 8;
1026 script->varTable[10] = BTL_MENU_TYPE_ITEMS;
1027 battleStatus->stateFreezeCount = 1;
1028 }
1029 }
1031 }
1032
1034 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
1035 player->handleEventScript = NULL;
1036
1038 return;
1039 }
1040
1041 if (D_8029F258 != 0) {
1042 D_8029F258--;
1043 return;
1044 }
1045
1046 if (!D_8029F254) {
1048 } else{
1051 }
1052 }
1053 }
1054}
1055
1058
1061 Actor* partner = gBattleStatus.partnerActor;
1062 s32 i;
1063
1065 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
1067 gBattleStatus.selectedMoveID = MOVE_NONE;
1072 if (partner != NULL) {
1074 }
1075
1076 for (i = 0; i < ARRAY_COUNT(gBattleStatus.enemyActors); i++) {
1077 Actor* enemy = gBattleStatus.enemyActors[i];
1078
1079 if (enemy != NULL) {
1082 }
1083 }
1084
1086 }
1087}
1088
1091
1093 BattleStatus* battleStatus = &gBattleStatus;
1094 Actor* partner = battleStatus->partnerActor;
1095 Actor* enemy;
1096 Evt* script;
1097 s32 i;
1098
1100 if (partner == NULL) {
1101 D_8029F254 = TRUE;
1104 if (!(partner->flags & ACTOR_FLAG_NO_ATTACK)) {
1106 btl_cam_move(5);
1108 } else {
1110 return;
1111 }
1112 } else {
1114 return;
1115 }
1116 }
1117
1119 if (btl_cam_is_moving_done()) {
1120 D_8029F258 = 0;
1122 partner = battleStatus->partnerActor;
1123 battleStatus->actionResult = ACTION_RESULT_NONE;
1124 battleStatus->blockResult = BLOCK_RESULT_NONE;
1125 D_8029F254 = FALSE;
1129
1130 if (partner->koStatus != 0) {
1131 partner->koDuration--;
1132 D_8029F254 = TRUE;
1133 D_8029F258 = 20;
1134 if (partner->koDuration > 0) {
1135 partner->disableEffect->data.disableX->koDuration = partner->koDuration;
1136 } else {
1137 partner->koStatus = 0;
1139 partner->disableEffect->data.disableX->koDuration = 0;
1141 }
1142 }
1143
1144 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1145 enemy = battleStatus->enemyActors[i];
1146 if (enemy != NULL) {
1148 }
1149 }
1151 }
1152 }
1153
1155 if (partner != NULL) {
1156 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1157 goto WAITING;
1158 }
1159 partner->handleEventScript = NULL;
1160 }
1161
1162 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1164 return;
1165 }
1167 }
1168 WAITING:
1169
1171 if (partner->handlePhaseSource != NULL) {
1172 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
1173 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
1174 partner->handlePhaseScript = script;
1175 partner->handleBatttlePhaseScriptID = script->id;
1176 script->owner1.actorID = ACTOR_PARTNER;
1177 }
1179 }
1180
1182 if (partner->handlePhaseSource == NULL || !does_script_exist(partner->handleBatttlePhaseScriptID)) {
1184 }
1185 }
1186
1188 if (D_8029F258 != 0) {
1189 D_8029F258--;
1190 return;
1191 }
1192 gBattleStatus.flags2 &= ~BS_FLAGS2_NO_PLAYER_PAL_ADJUST;
1193 if (!D_8029F254) {
1195 } else {
1198 }
1199 }
1200}
1201
1204
1231
1234
1236 BattleStatus* battleStatus = &gBattleStatus;
1237 Actor* player = battleStatus->playerActor;
1238 Actor* partner = battleStatus->partnerActor;
1239 Actor* actor;
1240 ActorState* state;
1241 Evt* script;
1242 s32 waitingForScript;
1243 s32 i;
1244
1245 s32 oldKoDuration;
1246
1250 return;
1251 }
1252
1253 if (partner != NULL) {
1256 return;
1257 }
1258 }
1259
1260 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1262 if (partner != NULL) {
1263 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1265 }
1266
1268 D_8029F258 = 0;
1269 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1270 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1271 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1272 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1273 }
1274
1276 waitingForScript = FALSE;
1277 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1278 actor = battleStatus->enemyActors[i];
1279 if (actor != NULL && actor->handleEventScript != NULL) {
1281 waitingForScript = TRUE;
1282 } else {
1283 actor->handleEventScript = NULL;
1284 }
1285 }
1286 }
1287
1288 if (!waitingForScript) {
1290
1291 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1292 actor = battleStatus->enemyActors[i];
1293 if (actor != NULL) {
1295 actor->flags &= ~ACTOR_FLAG_SKIP_TURN;
1296
1297 if (actor->debuff != 0) {
1298 if (actor->debuff == STATUS_KEY_FEAR
1299 || actor->debuff == STATUS_KEY_DIZZY
1300 || actor->debuff == STATUS_KEY_PARALYZE
1301 || actor->debuff == STATUS_KEY_SLEEP
1302 || actor->debuff == STATUS_KEY_FROZEN
1303 || actor->debuff == STATUS_KEY_STOP
1304 ) {
1305 actor->flags |= ACTOR_FLAG_SKIP_TURN;
1306 }
1307 actor->debuffDuration--;
1308 if (actor->debuffDuration <= 0) {
1309 actor->debuff = 0;
1312 D_8029F258 = 20;
1313 }
1314 }
1315
1316 if (actor->staticStatus != 0) {
1317 actor->staticDuration--;
1318 if (actor->staticDuration <= 0) {
1319 actor->staticStatus = 0;
1321 D_8029F258 = 20;
1322 }
1323 }
1324
1325 if (actor->transparentStatus != 0) {
1326 actor->transparentDuration--;
1327 if (actor->transparentDuration <= 0) {
1328 actor->transparentStatus = 0;
1330 D_8029F258 = 20;
1331 }
1332 }
1333
1334 if (actor->stoneStatus != 0) {
1335 actor->stoneDuration--;
1336 if (actor->stoneDuration <= 0) {
1337 actor->stoneStatus = 0;
1338 D_8029F258 = 20;
1339 }
1340 }
1341
1342 oldKoDuration = actor->koDuration;
1343 actor->koDuration = actor->debuffDuration;
1344 if (actor->koDuration > 0) {
1345 actor->koStatus = STATUS_KEY_DAZE;
1347 } else if (oldKoDuration != actor->koDuration) {
1348 actor->koStatus = 0;
1350 }
1351 if (actor->debuff == STATUS_KEY_POISON) {
1354 D_8029F258 = 20;
1355 }
1356 }
1357 }
1359 }
1360 }
1361
1363 // wait for player HandleEvent script to finish
1364 if(player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
1365 goto WAITING;
1366 }
1367 player->handleEventScript = NULL;
1368
1369 // wait for partner HandleEvent script to finish
1370 if (partner != NULL) {
1371 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1372 goto WAITING;
1373 }
1374 partner->handleEventScript = NULL;
1375 }
1376
1377 // wait for all enemy HandleEvent scripts to finish
1378 waitingForScript = FALSE;
1379
1380 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1381 actor = battleStatus->enemyActors[i];
1382 if (actor != NULL && actor->handleEventScript != NULL) {
1384 waitingForScript = TRUE;
1385 } else {
1386 actor->handleEventScript = NULL;
1387 }
1388 }
1389 }
1390
1391 if (waitingForScript) {
1392 goto WAITING;
1393 }
1394
1396 return;
1397 }
1398
1400 if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_PLAYER_IN_BACK)) {
1404 } else {
1405 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1406 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1409 state = &partner->state;
1410 if (!battleStatus->outtaSightActive) {
1411 partner->state.curPos.x = partner->homePos.x;
1412 partner->state.curPos.z = partner->homePos.z;
1413 partner->state.goalPos.x = player->homePos.x;
1414 partner->state.goalPos.z = player->homePos.z;
1415 } else {
1416 partner->state.curPos.x = partner->homePos.x;
1417 partner->state.curPos.z = partner->homePos.z;
1418 partner->state.goalPos.x = partner->homePos.x;
1419 partner->state.goalPos.z = partner->homePos.z + 5.0f;
1420 partner->homePos.x = player->homePos.x;
1421 partner->homePos.z = player->homePos.z;
1422 }
1423 state->moveTime = 4;
1424 state->angle = 0.0f;
1426 }
1427 }
1428 WAITING:
1429
1431 if (partner->state.moveTime != 0) {
1432 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
1433 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
1434 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
1435 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
1436 }
1437 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1438 partner->yaw = clamp_angle(partner->state.angle);
1439 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1440 player->yaw = clamp_angle(partner->state.angle);
1441 partner->state.angle += 90.0f;
1442
1443 if (partner->state.moveTime != 0) {
1444 partner->state.moveTime--;
1445 } else {
1446 partner->curPos.x = partner->state.goalPos.x;
1447 partner->curPos.z = partner->state.goalPos.z;
1448 player->curPos.x = partner->state.curPos.x;
1449 player->curPos.z = partner->state.curPos.z;
1450 if (!battleStatus->outtaSightActive) {
1451 partner->homePos.x = partner->curPos.x;
1452 partner->homePos.z = partner->curPos.z;
1453 player->homePos.x = player->curPos.x;
1454 player->homePos.z = player->curPos.z;
1455 } else {
1456 player->homePos.x = player->curPos.x;
1457 player->homePos.z = player->curPos.z;
1458 }
1460 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
1461 }
1462 }
1463
1465 if (D_8029F258 != 0) {
1466 D_8029F258--;
1467 } else {
1468 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_DEF_BOOST) {
1469 battleStatus->merleeDefenseBoost = 3;
1470 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
1473 player->takeTurnScript = script;
1474 player->takeTurnScriptID = script->id;
1475 script->owner1.actorID = ACTOR_PLAYER;
1476 }
1477 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
1478 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1480 if (partner != NULL) {
1481 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1483 }
1485 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1486 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1487 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1488 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1489 }
1490 }
1491
1493 if (player->takeTurnScript == NULL || (does_script_exist(player->takeTurnScriptID) == 0)) {
1494 player->takeTurnScript = NULL;
1495
1496 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1497 actor = battleStatus->enemyActors[i];
1498 if (actor != NULL && actor->handlePhaseSource != NULL) {
1499 battleStatus->battlePhase = PHASE_PLAYER_END;
1500 script = start_script(actor->handlePhaseSource, EVT_PRIORITY_A, 0);
1501 actor->handlePhaseScript = script;
1502 actor->handleBatttlePhaseScriptID = script->id;
1503 script->owner1.enemyID = i | ACTOR_CLASS_ENEMY;
1504 }
1505 }
1507 }
1508 }
1509
1510 waitingForScript = FALSE;
1512 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1513 actor = battleStatus->enemyActors[i];
1514 if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handleBatttlePhaseScriptID)) {
1515 waitingForScript = TRUE;
1516 }
1517 }
1518 if (!waitingForScript) {
1520 }
1521 }
1522
1525 }
1526}
1527
1529}
1530
1556
1559
1561 BattleStatus* battleStatus = &gBattleStatus;
1562 PlayerData* playerData = &gPlayerData;
1563 Actor* player = battleStatus->playerActor;
1564 Actor* partner = battleStatus->partnerActor;
1565 Actor* actor;
1566 Evt* script;
1567 s32 i;
1568
1570 s32 cond = FALSE;
1571
1572 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1573 actor = battleStatus->enemyActors[i];
1574 if (actor != NULL && actor->handleEventScript != NULL) {
1576 cond = TRUE;
1577 } else {
1578 actor->handleEventScript = NULL;
1579 }
1580 }
1581 }
1582
1583 if (!cond) {
1584 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1585 actor = battleStatus->enemyActors[i];
1586 if (actor != NULL && actor->takeTurnScript != NULL) {
1587 if (does_script_exist(actor->takeTurnScriptID)) {
1588 cond = TRUE;
1589 } else {
1590 actor->takeTurnScript = NULL;
1591 }
1592 }
1593 }
1594
1595 if (!cond) {
1598 }
1599 }
1600 }
1601
1607 } else {
1608 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1609 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1612 partner->state.curPos.x = partner->homePos.x;
1613 partner->state.curPos.z = partner->homePos.z;
1614 partner->state.goalPos.x = player->homePos.x;
1615 partner->state.goalPos.z = player->homePos.z;
1616 partner->state.moveTime = 4;
1617 partner->state.angle = 0.0f;
1619 }
1620 }
1621
1623 if (partner->state.moveTime != 0) {
1624 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
1625 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
1626 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
1627 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
1628 }
1629 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1630 partner->yaw = clamp_angle(partner->state.angle);
1631 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1632 player->yaw = clamp_angle(partner->state.angle);
1633 partner->state.angle += 90.0f;
1634 if (partner->state.moveTime != 0) {
1635 partner->state.moveTime--;
1636 } else {
1637 partner->curPos.x = partner->state.goalPos.x;
1638 partner->curPos.z = partner->state.goalPos.z;
1639 player->curPos.x = partner->state.curPos.x;
1640 player->curPos.z = partner->state.curPos.z;
1641 partner->homePos.x = partner->curPos.x;
1642 partner->homePos.z = partner->curPos.z;
1643 player->homePos.x = player->curPos.x;
1644 player->homePos.z = player->curPos.z;
1649 } else {
1650 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
1651 }
1653 }
1654 }
1655
1657 gBattleStatus.flags2 &= ~BS_FLAGS2_HIDE_BUFF_COUNTERS;
1658 player->disableDismissTimer = 0;
1660 if (partner != NULL) {
1662 partner->disableDismissTimer = 0;
1663 }
1664
1666 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_DEFENDING;
1667 playerData->starPower += SP_PER_SEG;
1668 if (playerData->starPower > playerData->maxStarPower * SP_PER_BAR) {
1669 playerData->starPower = playerData->maxStarPower * SP_PER_BAR;
1670 }
1671
1672 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1673 actor = battleStatus->enemyActors[i];
1674 if (actor != NULL && actor->handlePhaseSource != NULL) {
1675 battleStatus->battlePhase = PHASE_ENEMY_END;
1676 script = start_script(actor->handlePhaseSource, EVT_PRIORITY_A, 0);
1677 actor->handlePhaseScript = script;
1678 actor->handleBatttlePhaseScriptID = script->id;
1679 script->owner1.enemyID = i | ACTOR_ENEMY0;
1680 }
1681 }
1682
1683 if (partner != NULL && partner->handlePhaseSource != NULL) {
1684 battleStatus->battlePhase = PHASE_ENEMY_END;
1685 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
1686 partner->handlePhaseScript = script;
1687 partner->handleBatttlePhaseScriptID = script->id;
1688 script->owner1.actorID = ACTOR_PARTNER;
1689 }
1691 }
1692
1693 // wait for all end turn scripts to finish executing
1695 s32 cond = FALSE;
1696
1697 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1698 actor = battleStatus->enemyActors[i];
1699 if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handleBatttlePhaseScriptID)) {
1700 cond = TRUE;
1701 }
1702 }
1703
1704 if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) {
1705 cond = TRUE;
1706 }
1707
1708 if (!cond) {
1711 }
1712 }
1713
1714 // proceed to next turn
1715 switch (gBattleSubState) {
1719 break;
1720 }
1721}
1722
1724}
1725
1730
1732}
1733
1735 BattleStatus* battleStatus = &gBattleStatus;
1736 EncounterStatus* currentEncounter = &gCurrentEncounter;
1737 PlayerData* playerData = &gPlayerData;
1738 Actor* player = battleStatus->playerActor;
1739 Actor* partner = battleStatus->partnerActor;
1740 Evt* script;
1741
1742 switch (gBattleSubState) {
1745 if (partner != NULL) {
1747 }
1748
1749 battleStatus->stateFreezeCount = 0;
1750 if (battleStatus->outtaSightActive == 0) {
1752 } else {
1753 if (battleStatus->outtaSightActive > 0) {
1754 D_8029F254 = TRUE;
1755 }
1756 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
1757 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
1758 partner->handlePhaseScript = script;
1759 partner->handleBatttlePhaseScriptID = script->id;
1760 script->owner1.actorID = ACTOR_PARTNER;
1762 }
1763
1764 break;
1767 battleStatus->outtaSightActive = 0;
1769 }
1770 break;
1771 }
1772
1773 switch (gBattleSubState) {
1776 if (partner != NULL) {
1778 }
1780 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1781 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1782 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1783 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1784
1785 gBattleStatus.flags1 &= ~BS_FLAGS1_SHOW_PLAYER_DECORATIONS;
1786 if (player->koStatus == STATUS_KEY_DAZE) {
1789 }
1790 player->debuff = 0;
1791 player->staticStatus = 0;
1792 player->stoneStatus = 0;
1793 player->transparentStatus = 0;
1794 player->koStatus = 0;
1795 player->koDuration = 0;
1796 player->disableEffect->data.disableX->koDuration = 0;
1797
1798 if (partner != NULL) {
1799 if (partner->koStatus == STATUS_KEY_DAZE) {
1802 }
1803 partner->debuff = 0;
1804 partner->staticStatus = 0;
1805 partner->stoneStatus = 0;
1806 partner->transparentStatus = 0;
1807 partner->koStatus = 0;
1808 partner->koDuration = 0;
1809 partner->disableEffect->data.disableX->koDuration = 0;
1810 }
1811 break;
1813 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
1814 break;
1815 }
1816 player->handleEventScript = NULL;
1817
1818 if (partner != NULL) {
1819 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1820 break;
1821 }
1822 partner->handleEventScript = NULL;
1823 }
1825 break;
1826 }
1827
1829 if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_PLAYER_IN_BACK)) {
1831 } else {
1832 partner->state.curPos.x = partner->curPos.x;
1833 partner->state.curPos.z = partner->curPos.z;
1834 partner->state.goalPos.x = player->curPos.x;
1835 partner->state.goalPos.z = player->curPos.z;
1836 partner->state.moveTime = 4;
1837 partner->state.angle = 0.0f;
1839 }
1840 }
1841
1843 if (partner->state.moveTime != 0) {
1844 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
1845 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
1846 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
1847 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
1848 }
1849 partner->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1850 partner->yaw = clamp_angle(-partner->state.angle);
1851 player->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1852 player->yaw = clamp_angle(-partner->state.angle);
1853 partner->state.angle += 90.0f;
1854
1855 if (partner->state.moveTime != 0) {
1856 partner->state.moveTime--;
1857 } else {
1858 partner->curPos.x = partner->state.goalPos.x;
1859 partner->curPos.z = partner->state.goalPos.z;
1860 player->curPos.x = partner->state.curPos.x;
1861 player->curPos.z = partner->state.curPos.z;
1862 partner->homePos.x = partner->curPos.x;
1863 partner->homePos.z = partner->curPos.z;
1864 player->homePos.x = player->curPos.x;
1865 player->homePos.z = player->curPos.z;
1867 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
1868 }
1869 }
1870
1873 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_EXP_BOOST) {
1874 if (battleStatus->totalStarPoints == 0) {
1875 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
1876 playerData->merleeTurnCount = 0;
1877 playerData->merleeCastsLeft++;
1878 } else {
1879 battleStatus->battlePhase = PHASE_MERLEE_EXP_BONUS;
1881 player->takeTurnScript = script;
1882 player->takeTurnScriptID = script->id;
1883 script->owner1.actorID = ACTOR_PLAYER;
1884 }
1885 }
1888 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
1889 }
1890
1892 if (BattleSubStateDelay != 0) {
1894 } else {
1895 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
1896 player->takeTurnScript = NULL;
1897 if (battleStatus->nextMerleeSpellType != MERLEE_SPELL_EXP_BOOST) {
1899 } else {
1900 battleStatus->incrementStarPointDelay = 20;
1901 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
1903 battleStatus->pendingStarPoints = battleStatus->totalStarPoints
1904 + battleStatus->pendingStarPoints + battleStatus->pendingStarPoints;
1905 }
1906 }
1907 }
1908 }
1909
1911 if (battleStatus->pendingStarPoints <= 0) {
1913 gBattleStatus.flags1 &= ~BS_FLAGS1_BATTLE_FLED;
1914 }
1915 if (playerData->battlesWon < 9999) {
1916 playerData->battlesWon++;
1917 }
1919 currentEncounter->battleOutcome = OUTCOME_ENEMY_FLED;
1920 } else {
1921 currentEncounter->battleOutcome = OUTCOME_PLAYER_WON;
1922 }
1925 bgm_set_song(0, -1, 0, 1500, 8);
1926 }
1928 } else {
1930 }
1931 }
1932 }
1933}
1934
1936}
1937
1939 BattleStatus* battleStatus = &gBattleStatus;
1940 PlayerData* playerData = &gPlayerData;
1941 EncounterStatus* encounterStatus = &gCurrentEncounter;
1943 Actor* partner = gBattleStatus.partnerActor;
1944 Evt* script;
1945
1946 switch (gBattleSubState) {
1949 if (partner != NULL) {
1951 }
1953 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1954 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1955 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1956 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1957
1958 if (player->koStatus == STATUS_KEY_DAZE) {
1961 }
1962 player->debuff = 0;
1963 player->staticStatus = 0;
1964 player->stoneStatus = 0;
1965 player->transparentStatus = 0;
1966 player->koStatus = 0;
1967 player->koDuration = 0;
1968 player->disableEffect->data.disableX->koDuration = 0;
1969 if (partner != NULL) {
1970 if (partner->koStatus == STATUS_KEY_DAZE) {
1973 }
1974 partner->debuff = 0;
1975 partner->staticStatus = 0;
1976 partner->stoneStatus = 0;
1977 partner->transparentStatus = 0;
1978 partner->koStatus = 0;
1979 partner->koDuration = 0;
1980 partner->disableEffect->data.disableX->koDuration = 0;
1981 }
1982 break;
1984 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
1985 break;
1986 }
1987 player->handleEventScript = NULL;
1988
1989 if (partner != NULL) {
1990 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1991 break;
1992 }
1993 partner->handleEventScript = NULL;
1994 }
1995
1997 break;
1998 }
1999
2000 switch (gBattleSubState) {
2002 battleStatus->stateFreezeCount = 0;
2003 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
2004 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
2005 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
2006 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
2007
2008 if (!battleStatus->outtaSightActive) {
2010 } else {
2011 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
2012 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
2013 partner->handlePhaseScript = script;
2014 partner->handleBatttlePhaseScriptID = script->id;
2015 script->owner1.actorID = ACTOR_PARTNER;
2017 }
2018 break;
2021 battleStatus->outtaSightActive = FALSE;
2023 }
2024 break;
2025 }
2026
2027 switch (gBattleSubState) {
2032 break;
2034 if (BattleSubStateDelay != 0) {
2036 return;
2037 }
2038 if (playerData->trainingsDone < 9999) {
2039 playerData->trainingsDone++;
2040 }
2041 encounterStatus->battleOutcome = OUTCOME_ENEMY_FLED;
2043 bgm_set_song(0, -1, 0, 1500, 8);
2044 }
2046 break;
2047 }
2048}
2049
2052
2054 EncounterStatus* encounterStatus = &gCurrentEncounter;
2055 BattleStatus* battleStatus = &gBattleStatus;
2056 Battle* battle = gCurrentBattlePtr;
2057 Stage* stage;
2058 Evt* script;
2059 s32 i;
2060
2061 switch (gBattleSubState) {
2065 BattleScreenFadeAmt = 255;
2066 }
2072 }
2074 break;
2076 if (BattleScreenFadeAmt == 255) {
2078 break;
2079 }
2081 if (BattleScreenFadeAmt > 255) {
2082 BattleScreenFadeAmt = 255;
2083 }
2084 break;
2086 BattleScreenFadeAmt = 255;
2087 gBattleStatus.flags1 &= ~BS_FLAGS1_ACTORS_VISIBLE;
2088 if (gCurrentStagePtr == NULL) {
2089 stage = battle->stage;
2090 } else {
2091 stage = gCurrentStagePtr->stage;
2092 }
2093 if (stage->postBattle == NULL) {
2095 return;
2096 }
2097 script = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
2098 battleStatus->controlScript = script;
2099 battleStatus->controlScriptID = script->id;
2101 break;
2103 if (does_script_exist(battleStatus->controlScriptID)) {
2104 break;
2105 }
2107 // fallthrough
2110 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2111 if (battleStatus->enemyActors[i] != NULL) {
2112 btl_delete_actor(battleStatus->enemyActors[i]);
2113 }
2114 }
2115 if (battleStatus->partnerActor != NULL) {
2116 btl_delete_actor(battleStatus->partnerActor);
2117 }
2118
2119 btl_delete_player_actor(battleStatus->playerActor);
2120
2121 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_COIN_BOOST) {
2122 encounterStatus->hasMerleeCoinBonus = TRUE;
2123 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
2124 }
2125
2126 encounterStatus->damageTaken = battleStatus->damageTaken;
2127
2129 encounterStatus->dropWhackaBump = TRUE;
2130 }
2131
2134
2137 }
2138
2139 if (encounterStatus->battleOutcome == OUTCOME_PLAYER_LOST &&
2141 {
2142 s16 areaID;
2143 s16 mapID;
2144
2147 get_map_IDs_by_name_checked("gv_01", &areaID, &mapID);
2148 gGameStatusPtr->areaID = areaID;
2149 gGameStatusPtr->mapID = mapID;
2152 } else {
2155 func_8003E514(1);
2157 }
2158 break;
2159 }
2160}
2161
2172
2175 Evt* script;
2176
2177 switch (gBattleSubState) {
2182 player->takeTurnScriptID = script->id;
2184 script->owner1.actorID = ACTOR_PLAYER;
2185 break;
2189 }
2190 break;
2191 }
2192}
2193
2195}
2196
2198 BattleStatus* battleStatus = &gBattleStatus;
2199 PlayerData* playerData = &gPlayerData;
2200 EncounterStatus* currentEncounter = &gCurrentEncounter;
2201 Actor* player = battleStatus->playerActor;
2202 Actor* partner = battleStatus->partnerActor;
2203 Actor* enemy;
2204 s32 enemyCount;
2205 f32 totalEscapeChance;
2206 Evt* script;
2207 s32 i;
2208
2209 switch (gBattleSubState) {
2211 battleStatus->stateFreezeCount = 0;
2212 gBattleStatus.flags1 &= ~BS_FLAGS1_BATTLE_FLED;
2217
2218 playerData->fleeAttempts++;
2221
2222 // calculate average escape chance
2223 enemyCount = 0;
2224 totalEscapeChance = 0.0f;
2225
2226 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2227 enemy = battleStatus->enemyActors[i];
2228 if (enemy != NULL) {
2229 if (!(enemy->flags & ACTOR_FLAG_TARGET_ONLY)) {
2230 if (!(enemy->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
2231 f32 escapeChance = enemy->actorBlueprint->escapeChance;
2232
2233
2234 if (enemy->debuff == STATUS_KEY_FEAR ||
2235 enemy->debuff == STATUS_KEY_DIZZY ||
2236 enemy->debuff == STATUS_KEY_PARALYZE ||
2237 enemy->debuff == STATUS_KEY_SLEEP ||
2238 enemy->debuff == STATUS_KEY_FROZEN ||
2239 enemy->debuff == STATUS_KEY_STOP)
2240 {
2241 escapeChance = 100.0f;
2242 }
2243 totalEscapeChance += escapeChance;
2244 enemyCount += 1;
2245 }
2246 }
2247 }
2248 }
2249 player->state.varTable[0] = totalEscapeChance / enemyCount;
2250
2252 player->state.varTable[0] = 100;
2253 }
2254
2255 battleStatus->battlePhase = PHASE_RUN_AWAY_START;
2257 player->takeTurnScript = script;
2258 player->takeTurnScriptID = script->id;
2259 script->owner1.actorID = ACTOR_PLAYER;
2260 if (partner != NULL && partner->koStatus == 0) {
2261 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
2262 partner->takeTurnScript = script;
2263 partner->takeTurnScriptID = script->id;
2264 script->owner1.actorID = ACTOR_PARTNER;
2265 }
2267 break;
2269 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
2270 break;
2271 }
2274 } else {
2275 currentEncounter->battleOutcome = OUTCOME_PLAYER_FLED;
2278 } else {
2280 func_8023E104();
2281 D_8029F264 = 0;
2282 D_8029F24C = 0;
2284 // divide reward into 20 increments
2285 RunAwayRewardTotal = battleStatus->totalStarPoints * 100;
2286 RunAwayRewardStep = 20;
2289 }
2290 }
2291 break;
2292 }
2293
2295 if (battleStatus->totalStarPoints != 0) {
2296 s32 deltaSP;
2297 s32 prevSP;
2298
2300 prevSP = battleStatus->totalStarPoints;
2301 battleStatus->totalStarPoints = RunAwayRewardTotal / 100;
2302 deltaSP = prevSP - battleStatus->totalStarPoints;
2303
2304 if (deltaSP > 0) {
2306 }
2307 playerData->starPoints += deltaSP;
2309 if (RunAwayRewardStep == 0 && battleStatus->totalStarPoints != 0) {
2310 playerData->starPoints++;
2311 }
2312 }
2313 if (playerData->starPoints >= 99) {
2314 playerData->starPoints = 99;
2315 }
2316 if (battleStatus->totalStarPoints == 0) {
2317 if (RunAwayRewardStep != 0) {
2319 } else {
2321 func_8023E11C();
2323 }
2324 }
2325 }
2326
2328 playerData->battlesFled++;
2330 bgm_set_song(0, -1, 0, 1500, 8);
2331 }
2333 }
2334
2335 switch (gBattleSubState) {
2337 battleStatus->battlePhase = PHASE_RUN_AWAY_FAIL;
2339 player->takeTurnScript = script;
2340 player->takeTurnScriptID = script->id;
2341 script->owner1.actorID = ACTOR_PLAYER;
2342 if (partner != NULL && partner->koStatus == 0) {
2343 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
2344 partner->takeTurnScript = script;
2345 partner->takeTurnScriptID = script->id;
2346 script->owner1.actorID = ACTOR_PARTNER;
2347 }
2349 break;
2351 if (BattleSubStateDelay != 0) {
2353 return;
2354 }
2356 && (partner == NULL || !does_script_exist(partner->takeTurnScriptID))
2357 && battleStatus->stateFreezeCount == 0
2358 ) {
2360 }
2361 break;
2362 }
2363}
2364
2366}
2367
2369 BattleStatus* battleStatus = &gBattleStatus;
2370 EncounterStatus* currentEncounter = &gCurrentEncounter;
2371 Actor* player = battleStatus->playerActor;
2372 Actor* partner = battleStatus->partnerActor;
2373 Evt* script;
2374
2375 switch (gBattleSubState) {
2377 battleStatus->flags1 &= ~BS_FLAGS1_SHOW_PLAYER_DECORATIONS;
2378 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
2379 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
2380 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
2381 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
2382 battleStatus->stateFreezeCount = 0;
2383
2384 if (player->debuff != 0) {
2385 if (player->debuff == STATUS_KEY_FROZEN) {
2388 player->icePillarEffect = NULL;
2389 }
2390 player->debuff = 0;
2391 player->debuffDuration = 0;
2393 player->koStatus = 0;
2394 player->koDuration = 0;
2395 player->disableEffect->data.disableX->koDuration = 0;
2396 }
2397
2400 battleStatus->battlePhase = PHASE_DEATH;
2402 player->takeTurnScript = script;
2403 player->takeTurnScriptID = script->id;
2404 script->owner1.actorID = ACTOR_PLAYER;
2405
2406 if (partner != NULL) {
2407 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
2408 partner->takeTurnScript = script;
2409 partner->takeTurnScriptID = script->id;
2410 script->owner1.actorID = ACTOR_PARTNER;
2411 }
2413 break;
2415 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
2416 break;
2417 }
2418 if (find_item(ITEM_LIFE_SHROOM) >= 0) {
2419 battleStatus->battlePhase = PHASE_USE_LIFE_SHROOM;
2421 player->takeTurnScript = script;
2422 player->takeTurnScriptID = script->id;
2423 script->owner1.actorID = ACTOR_PLAYER;
2425 } else {
2427 }
2428 break;
2430 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
2431 break;
2432 }
2433 // never reached if life shroom is successful. its item script calls RestorePreDefeatState,
2434 // resetting the state to BATTLE_STATE_ENEMY_MOVE (based on the value of gDefeatedBattleState)
2436 break;
2437 }
2438
2440 currentEncounter->battleOutcome = OUTCOME_PLAYER_LOST;
2442 bgm_set_song(0, -1, 0, 1500, 8);
2443 }
2445 }
2446}
2447
2449}
2450
2451API_CALLABLE(EnablePartnerBlur) {
2453 return ApiStatus_DONE2;
2454}
2455
2456API_CALLABLE(DisablePartnerBlur) {
2458 return ApiStatus_DONE2;
2459}
2460
2462 BattleStatus* battleStatus = &gBattleStatus;
2463 Actor* player = battleStatus->playerActor;
2464 Actor* partner = battleStatus->partnerActor;
2465 ActorState* state = &player->state;
2466 PlayerData* playerData = &gPlayerData;
2467 Actor* enemyActor;
2468 Evt* script;
2469 s32 i;
2470
2471 switch (gBattleSubState) {
2473 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2474 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2475 battleStatus->stateFreezeCount = 0;
2478 btl_cam_set_target_pos(-89.0, 40.0, -99.0);
2479 btl_cam_set_zoom(372);
2481 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2482
2483 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2484 enemyActor = battleStatus->enemyActors[i];
2485 if (enemyActor != NULL) {
2486 enemyActor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2487 enemyActor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2488 }
2489 }
2490
2491 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] = -1;
2494
2496 if (BattleSubStateDelay != 0) {
2498 break;
2499 }
2502 battleStatus->controlScript = script;
2503 battleStatus->controlScriptID = script->id;
2504 script->owner1.actorID = ACTOR_PARTNER;
2505 state->unk_18.x = partner->curPos.x;
2506 state->unk_18.y = 0.0f;
2507 state->unk_18.z = partner->curPos.z;
2509 break;
2511 if (does_script_exist(battleStatus->controlScriptID)) {
2512 break;
2513 }
2514 btl_delete_actor(partner);
2515 playerData->curPartner = battleStatus->unk_1AC;
2517 partner = battleStatus->partnerActor;
2518 partner->scale.x = 0.1f;
2519 partner->scale.y = 0.1f;
2520 partner->scale.z = 0.1f;
2521 partner->state.goalPos.x = state->unk_18.x;
2522 partner->state.goalPos.y = partner->curPos.y;
2523 partner->state.goalPos.z = state->unk_18.z;
2524 partner->curPos.x = player->curPos.x;
2525 partner->curPos.y = player->curPos.y + 25.0f;
2526 partner->curPos.z = player->curPos.z;
2528 break;
2530 partner = battleStatus->partnerActor;
2531 if (partner != NULL) {
2532 if (does_script_exist(partner->takeTurnScriptID)) {
2533 break;
2534 }
2535 partner->takeTurnScript = NULL;
2536 }
2537
2539 battleStatus->controlScript = script;
2540 battleStatus->controlScriptID = script->id;
2541 script->owner1.actorID = ACTOR_PARTNER;
2543 break;
2545 if (does_script_exist(battleStatus->controlScriptID)) {
2546 break;
2547 }
2548 partner = battleStatus->partnerActor;
2549 if (partner != NULL) {
2550 if (partner->handlePhaseSource != NULL) {
2551 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
2552 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
2553 partner->handlePhaseScript = script;
2554 partner->handleBatttlePhaseScriptID = script->id;
2555 script->owner1.actorID = ACTOR_PARTNER;
2556 }
2557 }
2559 break;
2561 partner = battleStatus->partnerActor;
2562 if (partner != NULL) {
2563 if (partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) {
2564 break;
2565 }
2566 }
2569 break;
2571 if (battleStatus->stateFreezeCount != 0) {
2572 break;
2573 }
2574 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
2578 } else {
2580 }
2581 } else {
2584 } else {
2586 }
2587 }
2588 break;
2589 }
2590}
2591
2594
2596 BattleStatus* battleStatus = &gBattleStatus;
2597 Actor* player = battleStatus->playerActor;
2598 Actor* partner = battleStatus->partnerActor;
2599 s32 messageIndex;
2600 Actor* actor;
2601 Evt* script;
2602 s32 enemyNotDone;
2603 s8 tipIndex;
2604 s32 i;
2605
2607 battleStatus->stateFreezeCount = 0;
2608 battleStatus->actionResult = ACTION_RESULT_NONE;
2609 battleStatus->blockResult = BLOCK_RESULT_NONE;
2610 battleStatus->lastAttackDamage = 0;
2611 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
2612 gBattleStatus.flags1 &= ~BS_FLAGS1_AUTO_SUCCEED_ACTION;
2613 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2615 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2616 if (partner != NULL) {
2617 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2618 }
2620 gBattleStatus.flags1 &= ~BS_FLAGS1_SHOW_PLAYER_DECORATIONS;
2621 player->statusAfflicted = 0;
2623 gBattleStatus.flags1 &= ~BS_FLAGS1_YIELD_TURN;
2624
2625 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2626 actor = battleStatus->enemyActors[i];
2627 if (actor != NULL) {
2628 actor->statusAfflicted = 0;
2629 }
2630 }
2631
2632 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2633 actor = battleStatus->enemyActors[i];
2634 if (actor != NULL) {
2635 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2636 actor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2637 }
2638 }
2639
2640 if (battleStatus->moveCategory == BTL_MENU_TYPE_JUMP || battleStatus->moveCategory == BTL_MENU_TYPE_SMASH) {
2641 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_ATK_BOOST) {
2642 battleStatus->merleeAttackBoost = 3;
2643 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
2644 battleStatus->battlePhase = PHASE_MERLEE_ATTACK_BONUS;
2646 player->takeTurnScript = script;
2647 player->takeTurnScriptID = script->id;
2648 script->owner1.actorID = ACTOR_PLAYER;
2652 } else {
2654 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2655 }
2656 } else {
2658 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2659 }
2660 }
2661
2662 switch (gBattleSubState) {
2664 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
2665 break;
2666 }
2667 player->takeTurnScript = NULL;
2669 if (battleStatus->selectedMoveID != MOVE_NONE) {
2670 tipIndex = gMoveTable[battleStatus->selectedMoveID].actionTip;
2671 if (tipIndex >= 0) {
2673 }
2674 }
2675 }
2678 break;
2680 if (BattleSubStateDelay != 0) {
2682 } else {
2684 }
2685 break;
2686 }
2687
2688 switch (gBattleSubState) {
2690 gBattleStatus.flags1 &= ~BS_FLAGS1_4000;
2691 gBattleStatus.flags1 &= ~BS_FLAGS1_10000;
2694 reset_all_actor_sounds(player);
2695 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
2698 } else {
2700 }
2701 player->takeTurnScript = script;
2703 player->takeTurnScriptID = script->id;
2704 script->owner1.actorID = ACTOR_PLAYER;
2705 break;
2707 // wait for player battle phase script to finish
2709 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
2710 break;
2711 }
2712 player->takeTurnScript = NULL;
2713 }
2714
2715 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
2716
2717 // wait for player battle event script to finish
2718 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
2719 break;
2720 }
2721 player->handleEventScript = NULL;
2722
2723 // wait for partner battle event script to finish
2724 if (partner != NULL) {
2725 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
2726 break;
2727 }
2728 partner->handleEventScript = NULL;
2729 }
2730
2731 // wait for all enemy battle phase scripts to finish
2732 enemyNotDone = FALSE;
2733 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2734 actor = battleStatus->enemyActors[i];
2735 if (actor != NULL && actor->takeTurnScript != NULL) {
2736 if (does_script_exist(actor->takeTurnScriptID)) {
2737 enemyNotDone = TRUE;
2738 } else {
2739 actor->takeTurnScript = NULL;
2740 }
2741 }
2742 }
2743 if (enemyNotDone) {
2744 break;
2745 }
2746
2747 // wait for all enemy battle event scripts to finish
2748 enemyNotDone = FALSE;
2749 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2750 actor = battleStatus->enemyActors[i];
2751 if (actor != NULL && actor->handleEventScript != NULL) {
2753 enemyNotDone = TRUE;
2754 } else {
2755 actor->handleEventScript = NULL;
2756 }
2757 }
2758 }
2759 if (enemyNotDone) {
2760 break;
2761 }
2762
2763 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2764 actor = battleStatus->enemyActors[i];
2765 if (actor != NULL) {
2766 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2767 }
2768 }
2769
2770 if (battleStatus->stateFreezeCount != 0) {
2771 break;
2772 }
2773
2776 break;
2777 }
2778
2781 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
2783 return;
2784 }
2785
2786 if ((battleStatus->moveCategory == BTL_MENU_TYPE_SMASH)
2787 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE0)
2788 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE)
2789 && (battleStatus->selectedMoveID != MOVE_SUPER_SMASH_CHARGE)
2790 ) {
2791 gBattleStatus.flags1 &= ~BS_FLAGS1_HAMMER_CHARGED;
2792 }
2793
2794 if ((battleStatus->moveCategory == BTL_MENU_TYPE_JUMP)
2795 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE0)
2796 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE)
2797 && (battleStatus->selectedMoveID != MOVE_SUPER_JUMP_CHARGE)
2798 ) {
2799 gBattleStatus.flags1 &= ~BS_FLAGS1_JUMP_CHARGED;
2800 }
2801
2803 battleStatus->jumpCharge = 0;
2804 }
2806 battleStatus->hammerCharge = 0;
2807 }
2808
2809 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2810 actor = battleStatus->enemyActors[i];
2811 if (actor != NULL && !(actor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
2813 }
2814 }
2815
2817
2818 enemyNotDone = FALSE;
2819 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2820 actor = battleStatus->enemyActors[i];
2821 if (actor != NULL) {
2822 if (actor->statusAfflicted != 0) {
2823 enemyNotDone = TRUE;
2824 break;
2825 }
2826 }
2827 }
2828
2829 if (!enemyNotDone) {
2831 } else {
2833 switch (actor->statusAfflicted) {
2834 case 4:
2835 messageIndex = BTL_MSG_ENEMY_DAZED;
2836 break;
2837 case 6:
2838 messageIndex = BTL_MSG_ENEMY_ASLEEP;
2839 break;
2840 case 7:
2841 messageIndex = BTL_MSG_ENEMY_FROZEN;
2842 break;
2843 case 9:
2844 messageIndex = BTL_MSG_ENEMY_POISONED;
2845 break;
2846 case 10:
2847 messageIndex = BTL_MSG_ENEMY_SHRUNK;
2848 break;
2849 case 5:
2850 messageIndex = BTL_MSG_ENEMY_PARALYZED;
2851 break;
2852 case 11:
2853 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
2854 break;
2855 case 8:
2856 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
2857 break;
2858 default:
2859 messageIndex = 0;
2861 break;
2862 }
2864 btl_show_battle_message(messageIndex, 60);
2865 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2866 actor = battleStatus->enemyActors[i];
2867 if (actor != NULL) {
2868 actor->statusAfflicted = 0;
2869 }
2870 }
2872 }
2873 break;
2875 if (!btl_is_popup_displayed()) {
2877 btl_cam_move(15);
2880 }
2881 break;
2883 if (BattleSubStateDelay != 0) {
2885 } else {
2887 }
2888 break;
2889 }
2890
2891 switch (gBattleSubState) {
2893 if (player->statusAfflicted != 0) {
2895 switch (player->statusAfflicted) {
2896 case 4:
2897 messageIndex = BTL_MSG_PLAYER_DAZED;
2898 break;
2899 case 6:
2900 messageIndex = BTL_MSG_PLAYER_ASLEEP;
2901 break;
2902 case 7:
2903 messageIndex = BTL_MSG_PLAYER_FROZEN;
2904 break;
2905 case 9:
2906 messageIndex = BTL_MSG_PLAYER_POISONED;
2907 break;
2908 case 10:
2909 messageIndex = BTL_MSG_PLAYER_SHRUNK;
2910 break;
2911 case 5:
2912 messageIndex = BTL_MSG_PLAYER_PARALYZED;
2913 break;
2914 case 11:
2915 messageIndex = BTL_MSG_PLAYER_CHARGED;
2916 break;
2917 default:
2918 messageIndex = 0;
2920 break;
2921 }
2922 btl_show_battle_message(messageIndex, 60);
2923 player->statusAfflicted = 0;
2924 player->disableDismissTimer = 0;
2927
2928 } else {
2930 }
2931 break;
2933 if (!btl_is_popup_displayed()) {
2935 btl_cam_move(15);
2938 }
2939 break;
2941 if (BattleSubStateDelay != 0) {
2943 } else {
2945 }
2946 break;
2947 }
2948
2950 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
2951 player->takeTurnScript = NULL;
2953 }
2954 }
2955}
2956
2959
2961 BattleStatus* battleStatus = &gBattleStatus;
2962 Actor* player = battleStatus->playerActor;
2963 Actor* partner = battleStatus->partnerActor;
2964 Evt* script;
2965
2967 if (battleStatus->moveCategory == BTL_MENU_TYPE_ITEMS && battleStatus->itemUsesLeft >= 2) {
2969 } else if (
2974 ) {
2976 } else if (player->stoneStatus == STATUS_KEY_STONE || battleStatus->outtaSightActive) {
2978 } else {
2979 s32 prevHPDrainCount = 0;
2980 s32 hpRecovery = 0;
2981 s32 fpRecovery = 0;
2982
2984 prevHPDrainCount = battleStatus->hpDrainCount;
2985 battleStatus->hpDrainCount = 0;
2986 }
2987
2988 if (rand_int(100) < 50) {
2989 hpRecovery = is_ability_active(ABILITY_CRAZY_HEART) * 3;
2990 }
2991 if (rand_int(100) < 50) {
2993 }
2994 if (rand_int(100) < 50) {
2996 }
2997
2998 if (prevHPDrainCount + hpRecovery + fpRecovery == 0) {
3000 } else {
3001 battleStatus->battlePhase = PHASE_PLAYER_HAPPY;
3003 player->takeTurnScript = script;
3004 player->takeTurnScriptID = script->id;
3005 script->owner1.actorID = ACTOR_PLAYER;
3007 script->varTable[10] += battleStatus->hpDrainCount;
3008 battleStatus->hpDrainCount = 0;
3009 }
3010 script->varTable[10] = prevHPDrainCount;
3011 script->varTable[11] = hpRecovery;
3012 script->varTable[12] = fpRecovery;
3013
3014 if (script->varTable[10] > 99) {
3015 script->varTable[10] = 99;
3016 }
3017 if (script->varTable[11] > 99) {
3018 script->varTable[11] = 99;
3019 }
3020 if (script->varTable[12] > 99) {
3021 script->varTable[12] = 99;
3022 }
3023
3024 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_DRAINED_HP;
3026 }
3027 }
3028 }
3029
3030 switch (gBattleSubState) {
3032 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
3033 break;
3034 }
3035 player->takeTurnScript = NULL;
3036
3039 } else {
3040 player->state.curPos.x = player->homePos.x;
3041 player->state.curPos.z = player->homePos.z;
3042 player->state.goalPos.x = partner->homePos.x;
3043 player->state.goalPos.z = partner->homePos.z;
3044 player->state.moveTime = 4;
3045 player->state.angle = 0.0f;
3047 }
3048 break;
3049 }
3050
3052 if (player->state.moveTime != 0) {
3053 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
3054 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
3055 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
3056 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
3057 }
3058 player->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
3059 player->yaw = clamp_angle(-player->state.angle);
3060 partner->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
3061 partner->yaw = clamp_angle(-player->state.angle);
3062 player->state.angle += 90.0f;
3063
3064 if (player->state.moveTime != 0) {
3065 player->state.moveTime--;
3066 } else {
3067 player->curPos.x = player->state.goalPos.x;
3068 player->curPos.z = player->state.goalPos.z;
3069 partner->curPos.x = player->state.curPos.x;
3070 partner->curPos.z = player->state.curPos.z;
3071 player->homePos.x = player->curPos.x;
3072 player->homePos.z = player->curPos.z;
3073 partner->homePos.x = partner->curPos.x;
3074 partner->homePos.z = partner->curPos.z;
3077 }
3078 }
3079
3082 if (battleStatus->moveCategory == BTL_MENU_TYPE_ITEMS && battleStatus->itemUsesLeft >= 2) {
3084 btl_cam_move(10);
3085 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3086 } else {
3088 }
3089
3090 if (battleStatus->unk_94 < 0) {
3091 battleStatus->unk_94 = 0;
3092 battleStatus->itemUsesLeft = 0;
3094 return;
3095 }
3096
3097 if (battleStatus->itemUsesLeft != 0) {
3098 battleStatus->itemUsesLeft--;
3099 if (battleStatus->itemUsesLeft != 0) {
3100 // double or triple dip has not run out yet, let the player choose another item
3103 return;
3104 }
3105
3107 if (battleStatus->hustleTurns != 0) {
3108 battleStatus->hustleTurns--;
3109 }
3110 }
3111
3112 if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) {
3113 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3115 return;
3116 } else {
3117 gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLED;
3119 return;
3120 }
3121 }
3122
3124 if (battleStatus->hustleTurns != 0) {
3125 battleStatus->hustleTurns--;
3126 }
3127 }
3128
3129 if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) {
3130 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3132 } else {
3133 gBattleStatus.flags1 &= ~BS_FLAGS2_HAS_DRAINED_HP;
3136 } else {
3138 }
3139 }
3140 }
3141 }
3142}
3143
3146
3148 BattleStatus* battleStatus = &gBattleStatus;
3149 PlayerData* playerData = &gPlayerData;
3150 Actor* player = battleStatus->playerActor;
3151 Actor* partner = battleStatus->partnerActor;
3152 Actor* enemyActor;
3153 Evt* script;
3154 s8 switchCondition;
3155 s32 enemyFound;
3156 s32 messageIndex;
3157 s32 i;
3158
3159 switch (gBattleSubState) {
3161 if (partner == NULL) {
3163 break;
3164 }
3165 battleStatus->stateFreezeCount = 0;
3166 battleStatus->actionResult = ACTION_RESULT_NONE;
3167 battleStatus->blockResult = BLOCK_RESULT_NONE;
3168 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
3169 gBattleStatus.flags1 &= ~BS_FLAGS1_AUTO_SUCCEED_ACTION;
3170 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3172 partner->statusAfflicted = 0;
3173 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3174 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3178 gBattleStatus.flags1 &= ~BS_FLAGS1_YIELD_TURN;
3179
3180 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3181 enemyActor = battleStatus->enemyActors[i];
3182 if (enemyActor != NULL) {
3183 enemyActor->statusAfflicted = 0;
3184 }
3185 }
3188 break;
3190 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3191 enemyActor = battleStatus->enemyActors[i];
3192 if (enemyActor != NULL) {
3193 enemyActor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3194 enemyActor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3195 }
3196 }
3197
3201 reset_all_actor_sounds(partner);
3202 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
3203 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
3204 partner->takeTurnScript = script;
3205 partner->takeTurnScriptID = script->id;
3206 script->owner1.actorID = ACTOR_PARTNER;
3208 break;
3211 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
3212 break;
3213 }
3214 partner->takeTurnScript = NULL;
3215 }
3216 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
3217
3218 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
3219 break;
3220 }
3221 partner->handleEventScript = NULL;
3222
3223 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
3224 break;
3225 }
3226 player->handleEventScript = NULL;
3227
3228 enemyFound = FALSE;
3229 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3230 enemyActor = battleStatus->enemyActors[i];
3231 if (enemyActor != NULL && enemyActor->takeTurnScript != NULL) {
3232 if (does_script_exist(enemyActor->takeTurnScriptID)) {
3233 enemyFound = TRUE;
3234 } else {
3235 enemyActor->takeTurnScript = NULL;
3236 }
3237 }
3238 }
3239 if (enemyFound) {
3240 break;
3241 }
3242
3243 enemyFound = FALSE;
3244 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3245 enemyActor = battleStatus->enemyActors[i];
3246 if (enemyActor != NULL && enemyActor->handleEventScript != NULL) {
3247 if (does_script_exist(enemyActor->handleEventScriptID)) {
3248 enemyFound = TRUE;
3249 } else {
3250 enemyActor->handleEventScript = NULL;
3251 }
3252 }
3253 }
3254 if (enemyFound) {
3255 break;
3256 }
3257
3258 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3259 enemyActor = battleStatus->enemyActors[i];
3260 if (enemyActor != NULL) {
3261 enemyActor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3262 }
3263 }
3264
3265 if (battleStatus->stateFreezeCount != 0) {
3266 break;
3267 }
3268
3271 break;
3272 }
3274 if (playerData->curPartner == PARTNER_GOOMBARIO
3275 && battleStatus->moveCategory == BTL_MENU_TYPE_CHANGE_PARTNER
3276 && battleStatus->selectedMoveID != MOVE_CHARGE) {
3277 partner->isGlowing = FALSE;
3278 gBattleStatus.flags1 &= ~BS_FLAGS1_GOOMBARIO_CHARGED;
3279 }
3281 return;
3282 }
3283
3284 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3285 enemyActor = battleStatus->enemyActors[i];
3286 if (enemyActor != NULL) {
3287 if (!(enemyActor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
3289 }
3290 }
3291 }
3292
3294
3298 partner->statusAfflicted = 0;
3299 partner->disableDismissTimer = 0;
3302 } else {
3304 }
3305 break;
3307 if (btl_is_popup_displayed()) {
3308 break;
3309 }
3311 btl_cam_move(15);
3314 break;
3316 if (BattleSubStateDelay != 0) {
3318 } else {
3320 }
3321 break;
3322 }
3323
3324 switch (gBattleSubState) {
3326 enemyFound = FALSE;
3327 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3328 enemyActor = battleStatus->enemyActors[i];
3329 if (enemyActor != NULL) {
3330 if (enemyActor->statusAfflicted != 0) {
3331 enemyFound = TRUE;
3332 break;
3333 }
3334 }
3335 }
3336
3337 if (!enemyFound) {
3339 } else {
3341 switchCondition = enemyActor->statusAfflicted - 4;
3342 switch (switchCondition) {
3343 case 0:
3344 messageIndex = BTL_MSG_ENEMY_DAZED;
3345 break;
3346 case 2:
3347 messageIndex = BTL_MSG_ENEMY_ASLEEP;
3348 break;
3349 case 3:
3350 messageIndex = BTL_MSG_ENEMY_FROZEN;
3351 break;
3352 case 5:
3353 messageIndex = BTL_MSG_ENEMY_POISONED;
3354 break;
3355 case 6:
3356 messageIndex = BTL_MSG_ENEMY_SHRUNK;
3357 break;
3358 case 1:
3359 messageIndex = BTL_MSG_ENEMY_PARALYZED;
3360 break;
3361 case 7:
3362 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
3363 break;
3364 case 4:
3365 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
3366 break;
3367 default:
3368 messageIndex = 0;
3370 break;
3371 }
3372
3374 btl_show_battle_message(messageIndex, 60);
3375
3376 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3377 enemyActor = battleStatus->enemyActors[i];
3378 if (enemyActor != NULL) {
3379 enemyActor->statusAfflicted = 0;
3380 }
3381 }
3383 }
3384 break;
3386 if (btl_is_popup_displayed() == FALSE) {
3388 btl_cam_move(15);
3391 }
3392 break;
3394 if (BattleSubStateDelay != 0) {
3396 } else {
3398 }
3399 break;
3400 }
3401
3403 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
3404 return;
3405 }
3406 partner->takeTurnScript = NULL;
3408 }
3409}
3410
3413
3415 BattleStatus* battleStatus = &gBattleStatus;
3416
3418 battleStatus->flags2 |= BS_FLAGS2_PARTNER_TURN_USED;
3420 return;
3421 }
3422 battleStatus->flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
3423 battleStatus->flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
3424
3425 if (battleStatus->unk_94 < 0) {
3426 battleStatus->unk_94 = 0;
3428 } else {
3430 }
3431 }
3432}
3433
3436
3438 BattleStatus* battleStatus = &gBattleStatus;
3440 Actor* partner = gBattleStatus.partnerActor;
3441 Actor* enemy;
3442 s32 skipEnemy;
3443 s32 i;
3444
3445 switch (gBattleSubState) {
3448 i = battleStatus->nextEnemyIndex;
3449 if (i >= battleStatus->numEnemyActors) {
3450 // all enemies have been exhausted
3451 battleStatus->nextEnemyIndex = 0;
3453 return;
3454 }
3455
3456 // find the next eligible enemy
3457 while (TRUE) {
3458 if (battleStatus->enemyIDs[i] >= 0) {
3459 u16 enemyID = battleStatus->enemyIDs[i];
3460
3461 enemy = battleStatus->enemyActors[enemyID & 0xFF];
3462 if (enemy != NULL) {
3464 break;
3465 }
3466 }
3467 }
3468 i++;
3469 if (i >= battleStatus->numEnemyActors) {
3470 i = 0;
3471 }
3472 if (i == 0) {
3473 battleStatus->nextEnemyIndex = 0;
3475 return;
3476 }
3477 }
3478
3479 battleStatus->activeEnemyActorID = battleStatus->enemyIDs[i++];
3480 battleStatus->curTurnEnemy = enemy;
3481 battleStatus->nextEnemyIndex = i;
3482
3483 skipEnemy = FALSE;
3484
3485 if (enemy->debuff == STATUS_KEY_SLEEP) {
3486 skipEnemy = TRUE;
3487 }
3488 if (enemy->debuff == STATUS_KEY_FEAR) {
3489 skipEnemy = TRUE;
3490 }
3491 if (enemy->debuff == STATUS_KEY_DIZZY) {
3492 skipEnemy = TRUE;
3493 }
3494 if (enemy->debuff == STATUS_KEY_PARALYZE) {
3495 skipEnemy = TRUE;
3496 }
3497 if (enemy->debuff == STATUS_KEY_FROZEN) {
3498 skipEnemy = TRUE;
3499 }
3500 if (enemy->debuff == STATUS_KEY_STOP) {
3501 skipEnemy = TRUE;
3502 }
3503 if (enemy->stoneStatus == STATUS_KEY_STONE) {
3504 skipEnemy = TRUE;
3505 }
3506 if (enemy->flags & ACTOR_FLAG_SKIP_TURN) {
3507 skipEnemy = TRUE;
3508 }
3509
3510 if (skipEnemy) {
3511 // reset state to fetch next enemy
3513 return;
3514 }
3515
3516 battleStatus->stateFreezeCount = 0;
3517 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3518 gBattleStatus.flags1 &= ~BS_FLAGS1_BATTLE_FLED;
3519 gBattleStatus.flags1 &= ~BS_FLAGS1_AUTO_SUCCEED_ACTION;
3520 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
3521
3522 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3524
3525 if (partner != NULL) {
3526 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3528 }
3529
3530 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3531 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
3533
3534 D_8029F244 = enemy->unk_134;
3535 if (enemy->handlePhaseSource != NULL) {
3536 Evt* onTurnChanceScript;
3537
3538 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
3539 onTurnChanceScript = start_script(enemy->handlePhaseSource, EVT_PRIORITY_A, 0);
3540 enemy->handlePhaseScript = onTurnChanceScript;
3541 enemy->handleBatttlePhaseScriptID = onTurnChanceScript->id;
3542 onTurnChanceScript->owner1.actorID = battleStatus->activeEnemyActorID;
3543 }
3545 break;
3547 if (battleStatus->stateFreezeCount == 0) {
3548 enemy = get_actor(battleStatus->activeEnemyActorID);
3549
3550 if (enemy == NULL || enemy->unk_134 != D_8029F244) {
3552 } else {
3553 if (enemy->handlePhaseSource == NULL || !does_script_exist(enemy->handleBatttlePhaseScriptID)) {
3554 if (battleStatus->unk_94 < 0) {
3555 battleStatus->unk_94 = 0;
3557 } else {
3559 }
3560 }
3561 }
3562 }
3563 break;
3564 }
3565}
3566
3568}
3569
3571 BattleStatus* battleStatus = &gBattleStatus;
3573 Actor* partner = gBattleStatus.partnerActor;
3574 Actor* enemy;
3575 s32 i;
3576
3577 Evt* script;
3578 s32 messageIndex;
3579 s32 waitingForEnemyScript;
3580
3581 switch (gBattleSubState) {
3584 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3585 gBattleStatus.flags1 &= ~BS_FLAGS1_YIELD_TURN;
3586 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3587 if (partner != NULL) {
3588 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3589 }
3590 battleStatus->stateFreezeCount = 0;
3591 battleStatus->lastAttackDamage = 0;
3592 battleStatus->actionSuccess = 0;
3593 battleStatus->actionResult = ACTION_RESULT_NONE;
3594 battleStatus->blockResult = BLOCK_RESULT_NONE;
3595 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
3598 player->statusAfflicted = 0;
3599 if (partner != NULL) {
3600 partner->statusAfflicted = 0;
3601 }
3602
3604 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3605 enemy = battleStatus->enemyActors[i];
3606 if (enemy != NULL) {
3607 enemy->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3608 }
3609 }
3610
3611 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3612 enemy = battleStatus->enemyActors[i];
3613 if (enemy != NULL) {
3614 if (!(enemy->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
3615 enemy->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3616 }
3617 }
3618 }
3619
3620 enemy = battleStatus->curTurnEnemy;
3621 if (!(enemy->flags & ACTOR_FLAG_NO_ATTACK)) {
3623 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
3624 script = start_script(enemy->takeTurnSource, EVT_PRIORITY_A, 0);
3625 enemy->takeTurnScript = script;
3626 enemy->takeTurnScriptID = script->id;
3627 script->owner1.actorID = battleStatus->activeEnemyActorID;
3628 }
3630 break;
3632 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
3633 break;
3634 }
3635 player->takeTurnScript = NULL;
3636
3637 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
3638 break;
3639 }
3640 player->handleEventScript = NULL;
3641
3642 if (partner != NULL) {
3643 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
3644 break;
3645 }
3646 partner->handleEventScript = NULL;
3647 }
3648
3649 waitingForEnemyScript = FALSE;
3650 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3651 enemy = battleStatus->enemyActors[i];
3652 if (enemy != NULL && enemy->handleEventScript != NULL) {
3654 waitingForEnemyScript = TRUE;
3655 } else {
3656 enemy->handleEventScript = NULL;
3657 }
3658 }
3659 }
3660
3661 if (waitingForEnemyScript) {
3662 break;
3663 }
3664
3666 return;
3667 }
3668
3669 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3670 enemy = battleStatus->enemyActors[i];
3671 if (enemy != NULL && enemy->takeTurnScript != NULL) {
3672 if (does_script_exist(enemy->takeTurnScriptID)) {
3673 waitingForEnemyScript = TRUE;
3674 } else {
3675 enemy->takeTurnScript = NULL;
3676 }
3677 }
3678 }
3679
3680 if (waitingForEnemyScript && !(gBattleStatus.flags1 & BS_FLAGS1_YIELD_TURN)) {
3681 break;
3682 }
3683
3684 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
3685 gBattleStatus.flags2 &= ~BS_FLAGS2_IGNORE_DARKNESS;
3687 return;
3688 }
3689
3690 if (battleStatus->stateFreezeCount != 0) {
3691 break;
3692 }
3693
3696 } else {
3698 if (player->statusAfflicted != 0) {
3700 if (partner != NULL) {
3702 }
3704
3705 switch (player->statusAfflicted) {
3706 case STATUS_KEY_DIZZY:
3707 messageIndex = BTL_MSG_PLAYER_DAZED;
3708 break;
3709 case STATUS_KEY_SLEEP:
3710 messageIndex = BTL_MSG_PLAYER_ASLEEP;
3711 break;
3712 case STATUS_KEY_FROZEN:
3713 messageIndex = BTL_MSG_PLAYER_FROZEN;
3714 break;
3715 case STATUS_KEY_POISON:
3716 messageIndex = BTL_MSG_PLAYER_POISONED;
3717 break;
3718 case STATUS_KEY_SHRINK:
3719 messageIndex = BTL_MSG_PLAYER_SHRUNK;
3720 break;
3722 messageIndex = BTL_MSG_PLAYER_PARALYZED;
3723 break;
3724 default:
3725 messageIndex = 0;
3727 break;
3728 }
3729 btl_show_battle_message(messageIndex, 60);
3730 player->statusAfflicted = 0;
3732 break;
3733 } else {
3735 break;
3736 }
3737 }
3738 break;
3740 if (!btl_is_popup_displayed()) {
3742 btl_cam_move(15);
3745 }
3746 break;
3748 if (BattleSubStateDelay != 0) {
3750 } else {
3752 break;
3753 }
3754 break;
3755 }
3756
3757 switch (gBattleSubState) {
3759 if (partner != NULL) {
3760 if (partner->statusAfflicted == STATUS_KEY_DAZE) {
3765 partner->statusAfflicted = 0;
3767 } else {
3769 }
3770 } else {
3772 }
3773 break;
3775 if (!btl_is_popup_displayed()) {
3777 btl_cam_move(15);
3780 }
3781 break;
3783 if (BattleSubStateDelay != 0) {
3785 } else {
3787 }
3788 break;
3789 }
3790
3793 }
3794}
3795
3797}
3798
3800 PlayerData* playerData = &gPlayerData;
3801 BattleStatus* battleStatus = &gBattleStatus;
3802 EncounterStatus* encounterStatus = &gCurrentEncounter;
3804 Actor* partner = gBattleStatus.partnerActor;
3805 Evt* script;
3806 Actor* enemy;
3807 s32 enemyNotDone;
3808 s32 i;
3809
3810 switch (gBattleSubState) {
3812 D_8029F254 = FALSE;
3814 if (playerData->playerFirstStrikes < 9999) {
3815 playerData->playerFirstStrikes++;
3816 }
3817
3818 // clear rush flags to initialize
3819 battleStatus->rushFlags = RUSH_FLAG_NONE;
3820 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH;
3821
3822 // set rush flags based on danger/peril status
3826 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
3827 }
3829 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
3831 battleStatus->rushFlags |= RUSH_FLAG_POWER;
3832 }
3833 }
3834 }
3835
3836 // setup dummy 'menu selection' for player move
3837 switch (encounterStatus->hitType) {
3839 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
3840 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_JUMP;
3841 battleStatus->moveArgument = encounterStatus->hitTier;
3842 battleStatus->curTargetListFlags = gMoveTable[MOVE_FIRST_STRIKE_JUMP].flags;
3843 break;
3845 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
3846 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_HAMMER;
3847 battleStatus->moveArgument = encounterStatus->hitTier;
3848 battleStatus->curTargetListFlags = gMoveTable[MOVE_FIRST_STRIKE_HAMMER].flags;
3849 break;
3852 return;
3853 }
3854 // let the enemy know a first strike is coming
3855 enemy = get_actor(ACTOR_ENEMY0);
3856 if (enemy->handleEventSource != NULL) {
3859 enemy->handleEventScript = script;
3860 enemy->handleEventScriptID = script->id;
3861 script->owner1.actorID = enemy->actorID;
3862 }
3864 break;
3866 enemy = get_actor(ACTOR_ENEMY0);
3867 if (enemy->handleEventSource != NULL) {
3869 break;
3870 } else {
3871 enemy->handleEventScript = NULL;
3872 }
3873 }
3874
3875 func_80263230(player, enemy);
3876 battleStatus->stateFreezeCount = 0;
3877 battleStatus->lastAttackDamage = 0;
3878 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
3879 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3881 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
3886 // begin the partner turn script
3887 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
3889 player->takeTurnScript = script;
3890 player->takeTurnScriptID = script->id;
3891 script->owner1.actorID = ACTOR_PLAYER;
3894 break;
3896 if (BattleSubStateDelay != 0) {
3898 } else {
3899 D_8029F254 = TRUE;
3900 }
3901
3902 // wait for player move script
3904 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
3905 break;
3906 }
3907 player->takeTurnScript = NULL;
3908 }
3909
3910 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
3911
3912 // wait for player handle event script
3913 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
3914 break;
3915 }
3916 player->handleEventScript = NULL;
3917
3918 // wait for partner handle event script
3919 if (partner != NULL) {
3920 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
3921 break;
3922 }
3923 partner->handleEventScript = NULL;
3924 }
3925
3926 // wait for all enemy turn scripts
3927 enemyNotDone = FALSE;
3928 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3929 enemy = battleStatus->enemyActors[i];
3930 if (enemy != NULL && enemy->takeTurnScript != NULL) {
3931 if (does_script_exist(enemy->takeTurnScriptID)) {
3932 enemyNotDone = TRUE;
3933 } else {
3934 enemy->takeTurnScript = NULL;
3935 }
3936 }
3937 }
3938 if (enemyNotDone) {
3939 break;
3940 }
3941
3942 // wait for all enemy handle event scripts
3943 enemyNotDone = FALSE;
3944 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3945 enemy = battleStatus->enemyActors[i];
3946 if (enemy != NULL && enemy->handleEventScript != NULL) {
3948 enemyNotDone = TRUE;
3949 } else {
3950 enemy->handleEventScript = NULL;
3951 }
3952 }
3953 }
3954 if (enemyNotDone) {
3955 break;
3956 }
3957
3958 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3959 enemy = battleStatus->enemyActors[i];
3960 if (enemy != NULL) {
3961 enemy->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3962 }
3963 }
3964
3965 if (battleStatus->stateFreezeCount == 0) {
3968 Actor* target;
3969
3971 return;
3972 }
3973
3974 target = get_actor(player->targetActorID);
3975 if (target != NULL) {
3976 if (target->handleEventSource != NULL) {
3979 target->handleEventScript = script;
3980 target->handleEventScriptID = script->id;
3981 script->owner1.actorID = target->actorID;
3982 }
3983 }
3985 } else {
3987 }
3988 }
3989 break;
3991 enemyNotDone = FALSE;
3992 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3993 enemy = battleStatus->enemyActors[i];
3994 if (enemy != NULL && enemy->handleEventScript != NULL) {
3996 enemyNotDone = TRUE;
3997 } else {
3998 enemy->handleEventScript = NULL;
3999 }
4000 }
4001 }
4002 if (enemyNotDone) {
4003 break;
4004 }
4005 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
4006 player->takeTurnScript = NULL;
4008 }
4009 break;
4010 }
4011}
4012
4014 if (D_802809F6 == -1 && D_8029F254) {
4015 if (BattleScreenFadeAmt == 0) {
4017 } else {
4019 BattleScreenFadeAmt -= 20;
4020 } else {
4021 BattleScreenFadeAmt -= 50;
4022 }
4023
4024 if (BattleScreenFadeAmt < 0) {
4026 }
4028 }
4029 }
4030}
4031
4033 PlayerData* playerData = &gPlayerData;
4034 BattleStatus* battleStatus = &gBattleStatus;
4035 Actor* player = battleStatus->playerActor;
4036 Actor* partner = battleStatus->partnerActor;
4037 Actor* actor;
4038 s32 enemyNotDone;
4039 SelectableTarget* target;
4040 Evt* script;
4041 s32 level;
4042 s32 i;
4043
4044 switch (gBattleSubState) {
4046 D_8029F254 = FALSE;
4047 // setup dummy 'menu selection' for partner move
4048 level = partner->actorBlueprint->level;
4049 switch (playerData->curPartner) {
4050 case PARTNER_KOOPER:
4052 battleStatus->moveArgument = 0;
4053 battleStatus->selectedMoveID = level + MOVE_SHELL_TOSS1;
4054 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
4055 break;
4056 case PARTNER_BOMBETTE:
4058 battleStatus->moveArgument = 0;
4059 battleStatus->selectedMoveID = level + MOVE_BODY_SLAM1;
4060 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
4061 break;
4062 }
4063 // let the enemy know a first strike is coming
4064 actor = get_actor(ACTOR_ENEMY0);
4065 if (actor->handleEventSource != NULL) {
4068 actor->handleEventScript = script;
4069 actor->handleEventScriptID = script->id;
4070 script->owner1.actorID = actor->actorID;
4071 }
4073 break;
4076 target = &partner->targetData[partner->targetIndexList[0]];
4077 partner->targetActorID = target->actorID;
4078 partner->targetPartID = target->partID;
4079 battleStatus->stateFreezeCount = 0;
4080 battleStatus->lastAttackDamage = 0;
4081 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
4082 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
4089 // begin the partner turn script
4090 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
4091 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
4092 partner->takeTurnScript = script;
4093 partner->takeTurnScriptID = script->id;
4094 script->owner1.actorID = ACTOR_PARTNER;
4097 break;
4099 if (BattleSubStateDelay != 0) {
4101 } else {
4102 D_8029F254 = TRUE;
4103 }
4104 // wait for partner move script
4105 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
4106 break;
4107 }
4108 partner->takeTurnScript = NULL;
4109 // wait for partner handle event script
4110 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
4111 break;
4112 }
4113 partner->handleEventScript = NULL;
4114 // wait for player handle event script
4115 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
4116 break;
4117 }
4118 player->handleEventScript = NULL;
4119
4120 // wait for all enemy turn scripts
4121 enemyNotDone = FALSE;
4122 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4123 actor = battleStatus->enemyActors[i];
4124 if (actor != NULL && actor->takeTurnScript != NULL) {
4125 if (does_script_exist(actor->takeTurnScriptID)) {
4126 enemyNotDone = TRUE;
4127 } else {
4128 actor->takeTurnScript = NULL;
4129 }
4130 }
4131 }
4132 if (enemyNotDone) {
4133 break;
4134 }
4135
4136 // wait for all enemy handle event scripts
4137 enemyNotDone = FALSE;
4138 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4139 actor = battleStatus->enemyActors[i];
4140 if (actor != NULL && actor->handleEventScript != NULL) {
4142 enemyNotDone = TRUE;
4143 } else {
4144 actor->handleEventScript = NULL;
4145 }
4146 }
4147 }
4148 if (enemyNotDone) {
4149 break;
4150 }
4151
4152 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4153 actor = battleStatus->enemyActors[i];
4154 if (actor != NULL) {
4155 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
4156 }
4157 }
4158
4159 if (battleStatus->stateFreezeCount == 0) {
4162 return;
4163 }
4164
4165 actor = get_actor(partner->targetActorID);
4166 if (actor != NULL) {
4167 if (actor->handleEventSource != NULL) {
4170 actor->handleEventScript = script;
4171 actor->handleEventScriptID = script->id;
4172 script->owner1.actorID = actor->actorID;
4173 }
4174 }
4176 }
4177 break;
4179 enemyNotDone = FALSE;
4180 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4181 actor = battleStatus->enemyActors[i];
4182 if (actor != NULL && actor->handleEventScript != NULL) {
4184 enemyNotDone = TRUE;
4185 } else {
4186 actor->handleEventScript = NULL;
4187 }
4188 }
4189 }
4190 if (!enemyNotDone) {
4192 }
4193 break;
4194 }
4195}
4196
4211
4213 PlayerData* playerData = &gPlayerData;
4214 BattleStatus* battleStatus = &gBattleStatus;
4215 Actor* player = battleStatus->playerActor;
4216 Actor* partner = battleStatus->partnerActor;
4217 Evt* script;
4218 Actor* actor;
4219 u16* enemyIDs;
4220 s16 activeEnemyActorID;
4221 s32 nextEnemyIdx;
4222 s32 count;
4223 s32 flags;
4224 s32 waitingForScript;
4225 s32 i;
4226 s32 j;
4227
4228 switch (gBattleSubState) {
4230 battleStatus->stateFreezeCount = 0;
4231 battleStatus->lastAttackDamage = 0;
4232 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
4233 playerData->enemyFirstStrikes++;
4234 battleStatus->flags1 &= ~BS_FLAGS1_MENU_OPEN;
4235 D_8029F254 = FALSE;
4236 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
4237 if (partner != NULL) {
4238 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
4239 }
4240 battleStatus->flags2 |= BS_FLAGS2_IS_FIRST_STRIKE;
4241 battleStatus->flags2 |= BS_FLAGS2_IGNORE_DARKNESS;
4242 count = 0;
4243
4244 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4245 actor = battleStatus->enemyActors[i];
4246 if (actor != NULL) {
4247 battleStatus->enemyIDs[count] = i | ACTOR_ENEMY0;
4248 count++;
4249 }
4250 }
4251
4252 battleStatus->numEnemyActors = count;
4253
4254 enemyIDs = battleStatus->enemyIDs;
4255 for (i = 0; i < count - 1; i++) {
4256 for (j = i + 1; j < count; j++) {
4257 s32 iVal = enemyIDs[i];
4258 s32 jVal = enemyIDs[j];
4259
4260 if (battleStatus->enemyActors[iVal & 0xFF]->turnPriority <
4261 battleStatus->enemyActors[jVal & 0xFF]->turnPriority)
4262 {
4263 enemyIDs[i] = jVal;
4264 enemyIDs[j] = iVal;
4265 }
4266 }
4267 }
4268
4269 battleStatus->nextEnemyIndex = 0;
4270 nextEnemyIdx = 0;
4272
4273 while (TRUE) {
4274 actor = battleStatus->enemyActors[battleStatus->enemyIDs[nextEnemyIdx] & 0xFF];
4275 if (actor == NULL || (actor->flags & flags)) {
4276 nextEnemyIdx++;
4277 if (nextEnemyIdx >= battleStatus->numEnemyActors) {
4278 nextEnemyIdx = 0;
4279 }
4280 } else {
4281 break;
4282 }
4283 }
4284
4285 activeEnemyActorID = battleStatus->enemyIDs[nextEnemyIdx];
4286 nextEnemyIdx++;
4287 battleStatus->curTurnEnemy = actor;
4288 battleStatus->activeEnemyActorID = activeEnemyActorID;
4289 if (nextEnemyIdx >= battleStatus->numEnemyActors) {
4290 nextEnemyIdx = 0;
4291 }
4292 battleStatus->nextEnemyIndex = nextEnemyIdx;
4294 actor = battleStatus->curTurnEnemy;
4296 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
4297 script = start_script(actor->takeTurnSource, EVT_PRIORITY_A, 0);
4298 actor->takeTurnScript = script;
4300 actor->takeTurnScriptID = script->id;
4302 script->owner1.actorID = battleStatus->activeEnemyActorID;
4303 break;
4305 if (BattleSubStateDelay != 0) {
4307 } else {
4308 D_8029F254 = TRUE;
4309 }
4310
4311 // wait for current enemy TakeTurn script to finish
4312 actor = battleStatus->curTurnEnemy;
4313 if (actor->takeTurnScript != NULL && does_script_exist(actor->takeTurnScriptID)) {
4314 break;
4315 }
4316 actor->takeTurnScript = NULL;
4317
4318 // wait for player HandleEvent script to finish (may have been triggered by enemy Take Turn)
4319 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
4320 break;
4321 }
4322 player->handleEventScript = NULL;
4323
4324 // wait for partner HandleEvent script to finish (may have been triggered by enemy Take Turn)
4325 if (partner != NULL) {
4326 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
4327 break;
4328 }
4329 partner->handleEventScript = NULL;
4330 }
4331
4332 // wait for all enemy TakeTurn scripts to finish
4333 waitingForScript = FALSE;
4334
4335 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4336 actor = battleStatus->enemyActors[i];
4337 if (actor != NULL && actor->takeTurnScript != NULL) {
4338 if (does_script_exist(actor->takeTurnScriptID)) {
4339 waitingForScript = TRUE;
4340 } else {
4341 actor->takeTurnScript = NULL;
4342 }
4343 }
4344 }
4345
4346 if (waitingForScript) {
4347 break;
4348 }
4349
4350 // wait for all enemy HandleEvent scripts to finish
4351 waitingForScript = FALSE;
4352
4353 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4354 actor = battleStatus->enemyActors[i];
4355 if (actor != NULL && actor->handleEventScript != NULL) {
4357 waitingForScript = TRUE;
4358 } else {
4359 actor->handleEventScript = NULL;
4360 }
4361 }
4362 }
4363
4364 if (waitingForScript) {
4365 break;
4366 }
4367
4368 // reset state
4369 gBattleStatus.flags2 &= ~BS_FLAGS2_IGNORE_DARKNESS;
4370 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4371 actor = battleStatus->enemyActors[i];
4372 if (actor != NULL) {
4373 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
4374 }
4375 }
4376
4377 if (battleStatus->stateFreezeCount == 0) {
4379 return;
4380 }
4382 }
4383 break;
4384 }
4385}
4386
4401
4403 BattleStatus* battleStatus = &gBattleStatus;
4404 Battle* battle = gCurrentBattlePtr;
4405 Stage* stage;
4406 s32 i;
4407
4408 switch (gBattleSubState) {
4411 if (D_802809F6 == -1) {
4412 if (DemoBattleBeginDelay != 0) {
4414 break;
4415 }
4416 }
4418 break;
4420 switch (D_802809F6) {
4421 case 255:
4423 return;
4424 case -1:
4425 if (BattleScreenFadeAmt == 255) {
4427 return;
4428 }
4429 BattleScreenFadeAmt += 50;
4430 if (BattleScreenFadeAmt > 255) {
4431 BattleScreenFadeAmt = 255;
4432 }
4433 return;
4434 }
4435 break;
4437 BattleScreenFadeAmt = 255;
4438 gBattleStatus.flags1 &= ~BS_FLAGS1_ACTORS_VISIBLE;
4439 if (gCurrentStagePtr == NULL) {
4440 stage = battle->stage;
4441 } else {
4442 stage = gCurrentStagePtr->stage;
4443 }
4444
4445 if (stage->postBattle == NULL) {
4447 } else {
4448 battleStatus->controlScript = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
4449 battleStatus->controlScriptID = battleStatus->controlScript->id;
4451 }
4452 break;
4454 if (does_script_exist(battleStatus->controlScriptID)) {
4455 break;
4456 }
4458 //fallthrough
4461
4462 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4463 Actor* enemy = battleStatus->enemyActors[i];
4464
4465 if (enemy != NULL) {
4466 btl_delete_actor(enemy);
4467 }
4468 }
4469
4470 if (battleStatus->partnerActor != NULL) {
4471 btl_delete_actor(battleStatus->partnerActor);
4472 }
4473
4474 btl_delete_player_actor(battleStatus->playerActor);
4477
4480 }
4481
4482 if (D_802809F6 != -1) {
4484 }
4485
4489 break;
4490 }
4491}
4492
Actor * create_actor(Formation formation)
Definition 190B20.c:1676
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
@ ACTION_COMMAND_MODE_LEARNED
Definition action_cmd.h:39
BSS Battle * gCurrentBattlePtr
Definition battle.c:19
void btl_state_draw_switch_to_partner(void)
void btl_state_update_end_battle(void)
s32 BattleScreenFadeAmt
Definition 16C8E0.c:49
void btl_state_update_end_turn(void)
void btl_state_draw_9(void)
void btl_state_update_end_training_battle(void)
BSS s32 BattleEnemiesCreated
void btl_state_update_prepare_menu(void)
b32 dispatch_damage_tick_event_player(s32 damageAmount, s32 event)
void btl_state_update_end_player_turn(void)
void btl_state_update_enemy_move(void)
BSS s32 RunAwayRewardStep
void btl_state_update_first_strike(void)
BSS s32 RunAwayRewardIncrement
void btl_state_draw_partner_striking_first(void)
void btl_state_update_enemy_striking_first(void)
void btl_state_draw_prepare_menu(void)
void btl_state_draw_1C(void)
void btl_state_update_normal_start(void)
void btl_state_draw_begin_player_turn(void)
void btl_state_update_begin_player_turn(void)
void btl_state_draw_defend(void)
void btl_state_update_defeat(void)
void btl_state_update_next_enemy(void)
void btl_state_update_1C(void)
void btl_state_draw_end_player_turn(void)
void btl_state_draw_victory(void)
void btl_state_update_victory(void)
s16 DemoBattleBeginDelay
Definition 16C8E0.c:13
BSS s32 D_8029F258
void btl_state_draw_end_demo_battle(void)
void btl_state_update_9(void)
void btl_state_update_partner_striking_first(void)
void btl_state_draw_end_turn(void)
void btl_state_draw_partner_move(void)
ShapeFile gMapShapeData
Definition heaps.c:16
void btl_state_update_change_partner(void)
void btl_state_update_partner_move(void)
void btl_state_update_begin_partner_turn(void)
void btl_merlee_on_first_strike(void)
EvtScript EVS_Peach_OnActorCreate
void btl_state_update_switch_to_player(void)
StageListRow * gCurrentStagePtr
Definition battle.c:9
BSS s32 BattleSubStateDelay
BSS s32 RunAwayRewardTotal
void btl_state_update_begin_turn(void)
BSS u8 D_8029F244
void btl_state_draw_begin_partner_turn(void)
void btl_state_draw_player_move(void)
BSS s32 D_8029F264
BSS s32 D_8029F24C
void btl_state_draw_end_partner_turn(void)
void btl_state_draw_begin_turn(void)
void btl_state_update_defend(void)
s16 D_802809F6
Definition 16C8E0.c:12
void btl_state_draw_enemy_move(void)
s32 bActorsIgnoreDuringCount[]
void btl_state_draw_switch_to_player(void)
EvtScript EVS_OnBattleInit
Definition camera.c:1171
void btl_state_draw_next_enemy(void)
void btl_set_state(s32 battleState)
void btl_state_draw_normal_start(void)
EvtScript EVS_Mario_OnActorCreate
void btl_state_draw_run_away(void)
void btl_state_update_end_partner_turn(void)
void btl_merlee_on_start_turn(void)
void btl_state_draw_end_training_battle(void)
void btl_state_draw_defeat(void)
void btl_state_draw_end_battle(void)
void btl_state_update_end_demo_battle(void)
void btl_state_update_player_move(void)
void btl_state_draw_change_partner(void)
void btl_state_draw_enemy_striking_first(void)
void btl_state_draw_first_stike(void)
void btl_state_update_run_away(void)
BSS b32 D_8029F254
void btl_state_update_switch_to_partner(void)
struct EffectInstance * disableEffect
struct Evt * handlePhaseScript
struct Evt * takeTurnScript
s8 transparentStatus
EvtScript * handleEventSource
s8 disableDismissTimer
struct ActorBlueprint * actorBlueprint
ActorState state
struct Evt * handleEventScript
struct ActorPart * partsTable
s32 takeTurnScriptID
struct SelectableTarget targetData[24]
EvtScript * handlePhaseSource
s16 targetActorID
struct EffectInstance * icePillarEffect
s8 chillOutAmount
s32 b32
Vec3f homePos
s32 handleEventScriptID
union Evt::@8 owner1
Initially -1.
s16 hudElementDataIndex
EvtScript * takeTurnSource
Vec3f curPos
s8 targetIndexList[24]
s8 instigatorValue
Bytecode EvtScript[]
s8 statusAfflicted
s8 staticDuration
s8 debuffDuration
s8 transparentDuration
s32 handleBatttlePhaseScriptID
Vec3f scale
s8 flags
Definition demo_api.c:15
#define remove_effect
#define rand_int
#define clamp_angle
struct DisableXFXData * disableX
Definition effects.h:2529
s16 turnsLeft
Definition effects.h:2326
struct PartnerBuffFXData * partnerBuff
Definition effects.h:2591
@ FX_WATER_BLOCK_DESTROY
Definition effects.h:1540
BuffData unk_0C[3]
Definition effects.h:2336
@ FX_BUFF_DATA_TURBO_CHARGE
Definition effects.h:2320
@ FX_BUFF_DATA_CLOUD_NINE
Definition effects.h:2319
@ FX_BUFF_DATA_WATER_BLOCK
Definition effects.h:2318
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ gv_01_ENTRY_0
Definition entrances.h:1286
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ MERLEE_SPELL_COIN_BOOST
Definition enums.h:1914
@ MERLEE_SPELL_EXP_BOOST
Definition enums.h:1913
@ MERLEE_SPELL_ATK_BOOST
Definition enums.h:1911
@ MERLEE_SPELL_DEF_BOOST
Definition enums.h:1912
@ MERLEE_SPELL_NONE
Definition enums.h:1910
@ OVERLAY_NONE
Definition enums.h:2387
@ OVERLAY_SCREEN_MARIO
Definition enums.h:2395
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2388
@ ACTOR_CLASS_ENEMY
Definition enums.h:2079
@ BUTTON_START
Definition enums.h:2787
@ BS_FLAGS1_10000
Definition enums.h:3585
@ BS_FLAGS1_PLAYER_IN_BACK
Definition enums.h:3589
@ BS_FLAGS1_DISABLE_CELEBRATION
Definition enums.h:3586
@ BS_FLAGS1_BATTLE_FLED
Definition enums.h:3587
@ BS_FLAGS1_HUSTLED
Definition enums.h:3595
@ BS_FLAGS1_STAR_POINTS_DROPPED
Definition enums.h:3593
@ BS_FLAGS1_SORT_ENEMIES_BY_POSX
Definition enums.h:3596
@ BS_FLAGS1_NO_GAME_OVER
Definition enums.h:3592
@ BS_FLAGS1_PARTNER_ACTING
Definition enums.h:3588
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3590
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_JUMP_CHARGED
Definition enums.h:3598
@ BS_FLAGS1_HAMMER_CHARGED
Definition enums.h:3597
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3568
@ BS_FLAGS1_ACTORS_VISIBLE
Definition enums.h:3565
@ BS_FLAGS1_EXECUTING_MOVE
Definition enums.h:3578
@ BTL_MSG_PLAYER_FROZEN
Definition enums.h:4070
@ BTL_MSG_PLAYER_POISONED
Definition enums.h:4071
@ BTL_MSG_TURBO_CHARGE_END
Definition enums.h:4101
@ BTL_MSG_PLAYER_PARALYZED
Definition enums.h:4073
@ BTL_MSG_ENEMY_ASLEEP
Definition enums.h:4077
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:4074
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:4069
@ BTL_MSG_ENEMY_POISONED
Definition enums.h:4079
@ BTL_MSG_PLAYER_SHRUNK
Definition enums.h:4072
@ BTL_MSG_ENEMY_CANT_MOVE
Definition enums.h:4083
@ BTL_MSG_ENEMY_PARALYZED
Definition enums.h:4081
@ BTL_MSG_CLOUD_NINE_END
Definition enums.h:4099
@ BTL_MSG_ENEMY_FROZEN
Definition enums.h:4078
@ BTL_MSG_ENEMY_DAZED
Definition enums.h:4076
@ BTL_MSG_WATER_BLOCK_END
Definition enums.h:4097
@ BTL_MSG_FIRST_ACTION_TIP
Definition enums.h:4104
@ BTL_MSG_PARTNER_INJURED
Definition enums.h:4093
@ BTL_MSG_ENEMY_ELECTRIFIED
Definition enums.h:4082
@ BTL_MSG_ENEMY_SHRUNK
Definition enums.h:4080
@ BTL_MSG_PLAYER_DAZED
Definition enums.h:4068
@ DEBUG_CONTACT_DIE_IN_BATTLE
Definition enums.h:4270
@ DEBUG_CONTACT_DIE_ON_TOUCH
Definition enums.h:4269
@ DEBUG_CONTACT_AUTO_FLEE
Definition enums.h:4271
@ SCREEN_LAYER_FRONT
Definition enums.h:2382
@ SCREEN_LAYER_BACK
Definition enums.h:2383
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3543
@ CAMERA_FLAG_DISABLED
Definition enums.h:4721
@ RUSH_FLAG_NONE
Definition enums.h:5330
@ RUSH_FLAG_MEGA
Definition enums.h:5331
@ RUSH_FLAG_POWER
Definition enums.h:5332
@ PHASE_PLAYER_HAPPY
Definition enums.h:2073
@ PHASE_MERLEE_ATTACK_BONUS
Definition enums.h:2070
@ PHASE_USE_DEFEND
Definition enums.h:2063
@ PHASE_RUN_AWAY_START
Definition enums.h:2060
@ PHASE_EXECUTE_ACTION
Definition enums.h:2058
@ PHASE_MERLEE_EXP_BONUS
Definition enums.h:2072
@ PHASE_ENEMY_BEGIN
Definition enums.h:2068
@ PHASE_USE_LIFE_SHROOM
Definition enums.h:2065
@ PHASE_PLAYER_BEGIN
Definition enums.h:2066
@ PHASE_MERLEE_DEFENSE_BONUS
Definition enums.h:2071
@ PHASE_ENEMY_END
Definition enums.h:2067
@ PHASE_PLAYER_END
Definition enums.h:2069
@ PHASE_DEATH
Definition enums.h:2061
@ PHASE_RUN_AWAY_FAIL
Definition enums.h:2064
@ PHASE_FIRST_STRIKE
Definition enums.h:2059
@ BTL_MENU_TYPE_SMASH
Definition enums.h:4228
@ BTL_MENU_TYPE_JUMP
Definition enums.h:4227
@ BTL_MENU_TYPE_CHANGE_PARTNER
Definition enums.h:4232
@ BTL_MENU_TYPE_ITEMS
Definition enums.h:4229
@ BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER
Definition enums.h:3608
@ BS_FLAGS2_STORED_TURBO_CHARGE_TURN
Definition enums.h:3611
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3618
@ BS_FLAGS2_PLAYER_TURN_USED
Definition enums.h:3605
@ BS_FLAGS2_HAS_DRAINED_HP
Definition enums.h:3620
@ BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER
Definition enums.h:3607
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3621
@ BS_FLAGS2_CAN_FLEE
Definition enums.h:3609
@ BS_FLAGS2_PARTNER_TURN_USED
Definition enums.h:3606
@ BS_FLAGS2_DONT_STOP_MUSIC
Definition enums.h:3619
@ BS_FLAGS2_IGNORE_DARKNESS
Definition enums.h:3615
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3610
@ BS_FLAGS2_HIDE_BUFF_COUNTERS
Definition enums.h:3616
@ BS_FLAGS2_DROP_WHACKA_BUMP
Definition enums.h:3622
@ ENCOUNTER_TRIGGER_JUMP
Definition enums.h:269
@ ENCOUNTER_TRIGGER_HAMMER
Definition enums.h:271
@ ENCOUNTER_TRIGGER_PARTNER
Definition enums.h:273
@ ENCOUNTER_TRIGGER_SPIN
Definition enums.h:270
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2232
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STONE
Definition enums.h:2208
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_KEY_DAZE
Definition enums.h:2209
@ BTL_CAM_MIDPOINT_CLOSE
Definition enums.h:4832
@ BTL_CAM_PARTNER_INJURED
Definition enums.h:4876
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_INTERRUPT
Definition enums.h:4823
@ BTL_CAM_PLAYER_FLEE
Definition enums.h:4847
@ BTL_CAM_REPOSITION
Definition enums.h:4841
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ BTL_CAM_PLAYER_STATUS_AFFLICTED
Definition enums.h:4855
@ BTL_SUBSTATE_FIRST_STRIKE_AWAIT_ENEMY_READY
Definition enums.h:3682
@ BTL_SUBSTATE_PARTNER_MOVE_EXECUTE_MOVE
Definition enums.h:3801
@ BTL_SUBSTATE_END_TRAINING_DONE
Definition enums.h:3880
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_AWAIT_ENEMY_DONE
Definition enums.h:3690
@ BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE
Definition enums.h:3790
@ BTL_SUBSTATE_FIRST_STRIKE_AWAIT_SCRIPTS
Definition enums.h:3683
@ BTL_SUBSTATE_CHANGE_PARTNER_EXEC_PUT_AWAY
Definition enums.h:3867
@ BTL_SUBSTATE_END_TURN_PERFORM_SWAP
Definition enums.h:3707
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE
Definition enums.h:3715
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_TURN_SCRIPT
Definition enums.h:3729
@ BTL_SUBSTATE_DEFEAT_INIT
Definition enums.h:3858
@ BTL_SUBSTATE_DEFEAT_CHECK_LIFE_SHROOM
Definition enums.h:3859
@ BTL_SUBSTATE_INIT
Definition enums.h:3671
@ BTL_SUBSTATE_END_DEMO_BATTLE_EXEC_STAGE_SCRIPT
Definition enums.h:3915
@ BTL_SUBSTATE_END_BATTLE_CLEANUP
Definition enums.h:3889
@ BTL_SUBSTATE_NORMAL_START_FADE_IN
Definition enums.h:3677
@ BTL_SUBSTATE_VICTORY_DONE
Definition enums.h:3851
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_EXEC_TURN_SCRIPT
Definition enums.h:3728
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_RESET_STATE
Definition enums.h:3723
@ BTL_SUBSTATE_9_3
Definition enums.h:3737
@ BTL_SUBSTATE_NEXT_ENEMY_DONE
Definition enums.h:3813
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_AWAIT_ENEMY_READY
Definition enums.h:3688
@ BTL_SUBSTATE_NORMAL_START_CREATE_ENEMIES
Definition enums.h:3675
@ BTL_SUBSTATE_END_BATTLE_INIT
Definition enums.h:3885
@ BTL_SUBSTATE_9_1
Definition enums.h:3735
@ BTL_SUBSTATE_9_4
Definition enums.h:3738
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_INIT
Definition enums.h:3726
@ BTL_SUBSTATE_PARTNER_MOVE_AWAIT_ENEMY_STATUS_POPUP
Definition enums.h:3806
@ BTL_SUBSTATE_RUN_AWAY_EXEC_SCRIPT
Definition enums.h:3835
@ BTL_SUBSTATE_ENEMY_FIRST_STRIKE_INIT
Definition enums.h:3693
@ BTL_SUBSTATE_CHANGE_PARTNER_EXEC_PHASE
Definition enums.h:3870
@ BTL_SUBSTATE_PLAYER_MOVE_POST_PLAYER_STATUS_POPUP
Definition enums.h:3796
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_WATER_BLOCK
Definition enums.h:3713
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_END_DELAY
Definition enums.h:3730
@ BTL_SUBSTATE_END_TURN_CHECK_FOR_SWAP
Definition enums.h:3703
@ BTL_SUBSTATE_PARTNER_MOVE_AWAIT_PARTNER_STATUS_POPUP
Definition enums.h:3803
@ BTL_SUBSTATE_RUN_AWAY_GIVE_STAR_POINTS
Definition enums.h:3839
@ BTL_SUBSTATE_NEXT_ENEMY_UNUSED_1
Definition enums.h:3812
@ BTL_SUBSTATE_FIRST_STRIKE_AWAIT_ENEMY_DONE
Definition enums.h:3684
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_AWAIT_SCRIPTS
Definition enums.h:3689
@ BTL_SUBSTATE_RUN_AWAY_AWAIT_SCRIPT
Definition enums.h:3836
@ BTL_SUBSTATE_END_TRAINING_CHECK_OUTTA_SIGHT
Definition enums.h:3877
@ BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PLAYER_POPUP_DONE
Definition enums.h:3819
@ BTL_SUBSTATE_VICTORY_AWAIT_SWAP
Definition enums.h:3855
@ BTL_SUBSTATE_ENEMY_MOVE_EXECUTE
Definition enums.h:3816
@ BTL_SUBSTATE_9_INIT
Definition enums.h:3734
@ BTL_SUBSTATE_END_DEMO_BATTLE_CLEANUP
Definition enums.h:3917
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_INIT
Definition enums.h:3687
@ BTL_SUBSTATE_ENEMY_MOVE_POST_PARTNER_POPUP_DELAY
Definition enums.h:3823
@ BTL_SUBSTATE_ENEMY_MOVE_UNUSED_1
Definition enums.h:3817
@ BTL_SUBSTATE_PARTNER_MOVE_DONE
Definition enums.h:3808
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_RECOVER_DONE
Definition enums.h:3727
@ BTL_SUBSTATE_9_2
Definition enums.h:3736
@ BTL_SUBSTATE_CHANGE_PARTNER_INIT
Definition enums.h:3866
@ BTL_SUBSTATE_END_TRAINING_AWAIT_OUTTA_SIGHT
Definition enums.h:3878
@ BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT
Definition enums.h:3887
@ BTL_SUBSTATE_END_PLAYER_TURN_AWAIT_HAPPY
Definition enums.h:3828
@ BTL_SUBSTATE_VICTORY_AWAIT_RECOVER_KO
Definition enums.h:3853
@ BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PARTNER_POPUP_DONE
Definition enums.h:3822
@ BTL_SUBSTATE_END_TRAINING_INIT
Definition enums.h:3875
@ BTL_SUBSTATE_PARTNER_MOVE_POST_ENEMY_STATUS_POPUP
Definition enums.h:3807
@ BTL_SUBSTATE_BEGIN_TURN_INIT
Definition enums.h:3697
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_RECOVER
Definition enums.h:3721
@ BTL_SUBSTATE_END_TURN_AWAIT_SCRIPTS
Definition enums.h:3704
@ BTL_SUBSTATE_END_TURN_INIT
Definition enums.h:3702
@ BTL_SUBSTATE_END_DEMO_BATTLE_FADE_OUT
Definition enums.h:3914
@ BTL_SUBSTATE_END_BATTLE_FADE_OUT
Definition enums.h:3886
@ BTL_SUBSTATE_PLAYER_MOVE_SHOW_TIP_DELAY
Definition enums.h:3789
@ BTL_SUBSTATE_9_7
Definition enums.h:3741
@ BTL_SUBSTATE_END_PLAYER_TURN_AWAIT_SWAP
Definition enums.h:3829
@ BTL_SUBSTATE_DEFEND_AWAIT_SCRIPT
Definition enums.h:3844
@ BTL_SUBSTATE_PARTNER_MOVE_POST_PARTNER_STATUS_POPUP
Definition enums.h:3804
@ BATTLE_SUBSTATE_PREPARE_MENU_DIPPING
Definition enums.h:3747
@ BTL_SUBSTATE_VICTORY_CHECK_SWAP
Definition enums.h:3854
@ BTL_SUBSTATE_PLAYER_MOVE_AWAIT_PLAYER_STATUS_POPUP
Definition enums.h:3795
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_COMMAND_RECOVER
Definition enums.h:3712
@ BTL_SUBSTATE_CHANGE_PARTNER_DONE
Definition enums.h:3872
@ BTL_SUBSTATE_RUN_AWAY_DONE
Definition enums.h:3840
@ BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE
Definition enums.h:3797
@ BTL_SUBSTATE_END_TRAINING_RESET_CAM
Definition enums.h:3879
@ BTL_SUBSTATE_NORMAL_START_CHECK_FIRST_STRIKE
Definition enums.h:3676
@ BTL_SUBSTATE_END_TURN_UNUSED_4
Definition enums.h:3706
@ BTL_SUBSTATE_FIRST_STRIKE_INIT
Definition enums.h:3681
@ BTL_SUBSTATE_END_TURN_START_SCRIPTS
Definition enums.h:3708
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_END_DELAY
Definition enums.h:3722
@ BTL_SUBSTATE_RUN_AWAY_AWAIT_POST_FAILURE
Definition enums.h:3838
@ BTL_SUBSTATE_VICTORY_CHECK_OUTTA_SIGHT
Definition enums.h:3847
@ BTL_SUBSTATE_PARTNER_MOVE_HANDLE_RESULTS
Definition enums.h:3802
@ BTL_SUBSTATE_END_TRAINING_AWAIT_RECOVERING
Definition enums.h:3876
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_INIT
Definition enums.h:3711
@ BTL_SUBSTATE_END_BATTLE_AWAIT_STAGE_SCRIPT
Definition enums.h:3888
@ BTL_SUBSTATE_9_6
Definition enums.h:3740
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE
Definition enums.h:3720
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE
Definition enums.h:3717
@ BTL_SUBSTATE_NORMAL_START_INIT
Definition enums.h:3674
@ BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS
Definition enums.h:3794
@ BTL_SUBSTATE_VICTORY_CHECK_MERLEE
Definition enums.h:3849
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_WATER_BLOCK
Definition enums.h:3714
@ BTL_SUBSTATE_CHANGE_PARTNER_LOAD_NEW_PARTNER
Definition enums.h:3868
@ BTL_SUBSTATE_9_5
Definition enums.h:3739
@ BTL_SUBSTATE_PARTNER_MOVE_CHECK_ENEMY_STATUS
Definition enums.h:3805
@ BTL_SUBSTATE_NEXT_ENEMY_INIT
Definition enums.h:3811
@ BTL_SUBSTATE_END_DEMO_BATTLE_AWAIT_STAGE_SCRIPT
Definition enums.h:3916
@ BTL_SUBSTATE_PARTNER_MOVE_INIT
Definition enums.h:3800
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_TURBO_CHARGE
Definition enums.h:3718
@ BTL_SUBSTATE_VICTORY_AWAIT_OUTTA_SIGHT
Definition enums.h:3848
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_OUTTA_SIGHT
Definition enums.h:3719
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_RESET_STATE
Definition enums.h:3731
@ BTL_SUBSTATE_CHANGE_PARTNER_EXEC_BRING_OUT
Definition enums.h:3869
@ BTL_SUBSTATE_END_PLAYER_TURN_DONE
Definition enums.h:3830
@ BTL_SUBSTATE_END_TURN_BEGIN_NEXT
Definition enums.h:3705
@ BTL_SUBSTATE_VICTORY_RECOVER_STATUS
Definition enums.h:3852
@ BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_DEATH
Definition enums.h:3699
@ BTL_SUBSTATE_ENEMY_MOVE_POST_PLAYER_POPUP_DELAY
Definition enums.h:3820
@ BTL_SUBSTATE_PLAYER_MOVE_POST_ENEMY_STATUS_POPUP
Definition enums.h:3793
@ BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_SCRIPTS
Definition enums.h:3698
@ BTL_SUBSTATE_ENEMY_MOVE_AWAIT_SCRIPTS
Definition enums.h:3818
@ BTL_SUBSTATE_PLAYER_MOVE_INIT
Definition enums.h:3787
@ BTL_SUBSTATE_DEFEAT_DONE
Definition enums.h:3861
@ BTL_SUBSTATE_ENEMY_MOVE_DONE
Definition enums.h:3824
@ BTL_SUBSTATE_RUN_AWAY_EXEC_POST_FAILURE
Definition enums.h:3837
@ BTL_SUBSTATE_END_PLAYER_TURN_CHECK_HAPPY
Definition enums.h:3827
@ BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER
Definition enums.h:3821
@ BTL_SUBSTATE_NORMAL_START_DONE
Definition enums.h:3678
@ BTL_SUBSTATE_DEFEND_INIT
Definition enums.h:3843
@ BTL_SUBSTATE_ENEMY_FIRST_STRIKE_AWAIT_SCRIPTS
Definition enums.h:3694
@ BTL_SUBSTATE_VICTORY_AWAIT_MERLEE
Definition enums.h:3850
@ BTL_SUBSTATE_END_DEMO_BATTLE_INIT
Definition enums.h:3913
@ BTL_SUBSTATE_PLAYER_MOVE_BEGIN_SHOW_TIP
Definition enums.h:3788
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_CLOUD_NINE
Definition enums.h:3716
@ BTL_SUBSTATE_DEFEAT_AWAIT_LIFE_SHROOM
Definition enums.h:3860
@ BTL_SUBSTATE_PLAYER_MOVE_AWAIT_ENEMY_STATUS_POPUP
Definition enums.h:3792
@ BTL_SUBSTATE_CHANGE_PARTNER_AWAIT_PHASE
Definition enums.h:3871
@ BTL_SUBSTATE_PLAYER_MOVE_HANDLE_RESULTS
Definition enums.h:3791
@ BATTLE_STATE_BEGIN_PARTNER_TURN
Definition enums.h:3639
@ BATTLE_STATE_ENEMY_MOVE
Definition enums.h:3652
@ BATTLE_STATE_NEXT_ENEMY
Definition enums.h:3651
@ BATTLE_STATE_0
Definition enums.h:3631
@ BATTLE_STATE_ENEMY_FIRST_STRIKE
Definition enums.h:3635
@ BATTLE_STATE_RUN_AWAY
Definition enums.h:3655
@ BATTLE_STATE_FIRST_STRIKE
Definition enums.h:3633
@ BATTLE_STATE_PREPARE_MENU
Definition enums.h:3643
@ BATTLE_STATE_SWITCH_TO_PARTNER
Definition enums.h:3642
@ BATTLE_STATE_PLAYER_MENU
Definition enums.h:3644
@ BATTLE_STATE_END_DEMO_BATTLE
Definition enums.h:3666
@ BATTLE_STATE_CELEBRATION
Definition enums.h:3664
@ BATTLE_STATE_SWITCH_TO_PLAYER
Definition enums.h:3641
@ BATTLE_STATE_BEGIN_TURN
Definition enums.h:3636
@ BATTLE_STATE_PARTNER_FIRST_STRIKE
Definition enums.h:3634
@ BATTLE_STATE_END_PARTNER_TURN
Definition enums.h:3654
@ BATTLE_STATE_END_PLAYER_TURN
Definition enums.h:3653
@ BATTLE_STATE_PEACH_MENU
Definition enums.h:3646
@ BATTLE_STATE_PARTNER_MENU
Definition enums.h:3645
@ BATTLE_STATE_BEGIN_PLAYER_TURN
Definition enums.h:3638
@ BATTLE_STATE_9
Definition enums.h:3640
@ BATTLE_STATE_TWINK_MENU
Definition enums.h:3647
@ BATTLE_STATE_END_BATTLE
Definition enums.h:3663
@ BATTLE_STATE_END_TURN
Definition enums.h:3637
@ WINDOW_GROUP_ALL
Definition enums.h:5323
@ DMG_SRC_DEFAULT
Definition enums.h:1988
@ ABILITY_BERSERKER
Definition enums.h:457
@ ABILITY_QUICK_CHANGE
Definition enums.h:462
@ ABILITY_FEELING_FINE
Definition enums.h:450
@ ABILITY_POWER_RUSH
Definition enums.h:466
@ ABILITY_CHILL_OUT
Definition enums.h:453
@ ABILITY_MEGA_RUSH
Definition enums.h:456
@ ABILITY_DIZZY_ATTACK
Definition enums.h:481
@ ABILITY_ZAP_TAP
Definition enums.h:455
@ ABILITY_HAPPY_HEART
Definition enums.h:454
@ ABILITY_CRAZY_HEART
Definition enums.h:467
@ ABILITY_HAPPY_FLOWER
Definition enums.h:488
@ ABILITY_RUNAWAY_PAY
Definition enums.h:459
@ SOUND_INFLICT_KO
Definition enums.h:1545
@ SOUND_FROZEN_SHATTER
Definition enums.h:722
@ SOUND_DESTROY_WATER_BLOCK
Definition enums.h:1015
@ SOUND_COIN_PICKUP
Definition enums.h:922
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_PARTNER
Definition enums.h:2086
@ ACTOR_ENEMY0
Definition enums.h:2087
@ ACTOR_FLAG_SKIP_TURN
Definition enums.h:3336
@ ACTOR_FLAG_HEALTH_BAR_HIDDEN
Definition enums.h:3338
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3343
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3334
@ ACTOR_FLAG_NO_HEALTH_BAR
Definition enums.h:3337
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3339
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3342
@ OUTCOME_ENEMY_FLED
Definition enums.h:1905
@ OUTCOME_PLAYER_WON
Definition enums.h:1902
@ OUTCOME_PLAYER_LOST
Definition enums.h:1903
@ OUTCOME_PLAYER_FLED
Definition enums.h:1904
@ PARTNER_BOMBETTE
Definition enums.h:2888
@ PARTNER_KOOPER
Definition enums.h:2887
@ PARTNER_GOOMBARIO
Definition enums.h:2886
@ BLOCK_RESULT_NONE
Definition enums.h:1972
@ FIRST_STRIKE_NONE
Definition enums.h:3458
@ FIRST_STRIKE_ENEMY
Definition enums.h:3460
@ FIRST_STRIKE_PLAYER
Definition enums.h:3459
@ ACTION_RESULT_NONE
Definition enums.h:1963
@ BTL_MENU_IDX_PARTNER
Definition enums.h:4217
@ BTL_MENU_IDX_STRATEGY
Definition enums.h:4219
@ BTL_MENU_IDX_SMASH
Definition enums.h:4214
@ BTL_MENU_IDX_STAR_POWER
Definition enums.h:4218
@ BTL_MENU_IDX_MAIN
Definition enums.h:4212
@ BTL_MENU_IDX_JUMP
Definition enums.h:4213
@ BTL_MENU_IDX_DIP
Definition enums.h:4216
@ BTL_MENU_IDX_ABILITY
Definition enums.h:4221
@ BTL_MENU_IDX_ITEMS
Definition enums.h:4215
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_BEGIN_FIRST_STRIKE
Definition enums.h:2173
@ EVENT_END_FIRST_STRIKE
Definition enums.h:2171
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_RECOVER_FROM_KO
Definition enums.h:2170
@ EVENT_32
Definition enums.h:2168
@ EVENT_RECOVER_STATUS
Definition enums.h:2167
@ ACTOR_PART_FLAG_TRANSPARENT
Definition enums.h:3357
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_1
Definition enums.h:3969
@ BTL_DARKNESS_STATE_NONE
Definition enums.h:6365
@ CAM_TATTLE
Definition enums.h:1802
@ CAM_DEFAULT
Definition enums.h:1800
@ CAM_BATTLE
Definition enums.h:1801
@ EVT_PRIORITY_A
Definition evt.h:153
#define ApiStatus_DONE2
Definition evt.h:118
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:161
void load_partner_actor(void)
Definition 190B20.c:1422
void disable_partner_blur(void)
void set_screen_overlay_params_back(u8, f32)
s32 btl_are_all_enemies_defeated(void)
Definition 190B20.c:636
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
void kill_all_scripts(void)
void get_map_IDs_by_name_checked(const char *mapName, s16 *areaID, s16 *mapID)
Same as get_map_IDs_by_name, but will panic if the map doesn't exist.
Definition world.c:247
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
void setup_status_bar_for_battle(void)
Definition inventory.c:1461
void * load_asset_by_name(const char *assetName, u32 *decompressedSize)
Definition world.c:251
void remove_status_debuff(s32)
void reset_all_actor_sounds(Actor *)
Definition 190B20.c:2938
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void set_background(BackgroundHeader *)
Definition background.c:40
void decrement_status_bar_disabled(void)
Definition inventory.c:1646
void btl_cam_set_zoom(s16)
Definition camera.c:1984
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:103
void load_battle_hit_asset(const char *hitName)
Definition collision.c:166
void load_data_for_models(struct ModelNode *model, s32 romOffset, s32 size)
Definition model.c:3319
void btl_update_ko_status(void)
Definition 190B20.c:2869
void remove_status_static(s32)
void func_8023E104(void)
Definition 16C8E0.c:150
void enable_partner_blur(void)
void reset_actor_turn_info(void)
Definition 190B20.c:978
void btl_cam_set_target_pos(f32, f32, f32)
Definition camera.c:1962
void set_screen_overlay_params_front(u8, f32)
void close_action_command_instruction_popup(void)
void load_map_bg(char *optAssetName)
Definition background.c:14
s32 get_asset_offset(char *, s32 *)
Definition world.c:273
void remove_all_effects(void)
Definition effects.c:274
void remove_status_transparent(s32)
void dispatch_event_player(s32)
Definition dmg_player.c:131
void btl_set_player_idle_anims(void)
void status_bar_stop_blinking_starpoints(void)
Definition inventory.c:1637
void btl_cam_use_preset(s32)
Definition camera.c:1919
void btl_cam_target_actor(s32)
Definition camera.c:1926
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 find_item(s32)
Search player inventory for itemID and return first matching array index.
Definition inventory.c:258
void btl_cam_set_zoffset(s16)
Definition camera.c:1996
s32 func_80263230(Actor *, Actor *)
Definition 190B20.c:558
void status_bar_start_blinking_starpoints(void)
Definition inventory.c:1628
void set_screen_overlay_center(s32, s32, s32, s32)
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void set_screen_overlay_color(s32, u8, u8, u8)
void btl_show_battle_message(s32 messageIndex, s32 duration)
void func_8023E11C(void)
Definition 16C8E0.c:155
void btl_cam_move(s16)
Definition camera.c:1953
s32 general_heap_free(void *data)
Definition heap.c:18
void deduct_current_move_fp(void)
Definition 190B20.c:961
void btl_delete_player_actor(Actor *player)
Definition 16C8E0.c:1176
s32 btl_cam_is_moving_done(void)
Definition camera.c:1980
void decode_yay0(void *src, void *dst)
void set_windows_visible(s32 groupIdx)
Definition windows.c:445
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:889
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2581
s32 does_script_exist(s32 id)
void load_player_actor(void)
Definition 190B20.c:1208
void btl_delete_actor(Actor *actor)
Definition 16C8E0.c:1111
f32 sin_rad(f32 x)
Definition 43F0.c:713
s32 btl_is_popup_displayed(void)
void create_current_pos_target_list(Actor *actor)
Definition 190B20.c:472
void btl_cam_unfreeze(void)
Definition camera.c:2002
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653
void set_curtain_scale_goal(f32 scale)
Definition curtains.c:285
void remove_status_chill_out(s32)
void increment_status_bar_disabled(void)
Definition inventory.c:1654
void dispatch_event_partner(s32)
Definition dmg_partner.c:7
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_END_BATTLE
Definition game_modes.h:16
@ GAME_MODE_GAME_OVER
Definition game_modes.h:14
EvtScript BtlPutPartnerAway
Definition 16C8E0.c:51
EvtScript EVS_PeachEnterStage
EvtScript EVS_ApplyDizzyAttack
EvtScript EVS_PlayerRegainAbility
EvtScript EVS_Peach_HandlePhase
EvtScript BtlBringPartnerOut
Definition 16C8E0.c:77
EvtScript EVS_Mario_HandlePhase
EvtScript EVS_MarioEnterStage
ModelNode * root
Definition model.h:174
ShapeFileHeader header
Definition model.h:183
s32 flags
Definition npc.h:295
u8 damageTaken
Definition npc.h:375
Enemy * curEnemy
Definition npc.h:394
void func_8003E514(s8 arg0)
Definition npc.c:2266
b8 hasMerleeCoinBonus
Definition npc.h:374
FieldStatus dizzyAttack
Definition npc.h:399
s8 forbidFleeing
Definition npc.h:379
s16 duration
Definition npc.h:362
s8 status
Definition npc.h:360
EncounterStatus gCurrentEncounter
Definition encounter.c:176
s8 instigatorValue
Definition npc.h:378
s8 battleOutcome
Definition npc.h:372
s8 dropWhackaBump
Definition npc.h:381
s8 encountered
Definition npc.h:297
s8 firstStrikeType
Definition npc.h:367
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:525
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define SP_PER_SEG
Definition macros.h:103
#define SP_PER_BAR
Definition macros.h:102
#define LAST_DEMO_SCENE_IDX
Definition macros.h:108
EvtScript * preBattle
Definition battle.h:185
char * texture
Definition battle.h:182
const char * shape
Definition battle.h:183
#define PERIL_THRESHOLD
Definition battle.h:267
Stage * stage
Definition battle.h:199
Formation * stageFormation
Definition battle.h:190
Formation * formation
Definition battle.h:198
s32 formationSize
Definition battle.h:197
s32 stageEnemyChance
Definition battle.h:191
Stage * stage
Definition battle.h:208
EvtScript * postBattle
Definition battle.h:186
EvtScript * onBattleStart
Definition battle.h:200
s32 stageEnemyCount
Definition battle.h:189
const char * hit
Definition battle.h:184
char * bg
Definition battle.h:187
#define DANGER_THRESHOLD
Definition battle.h:266
Zero-terminated.
Definition battle.h:195
Zero-terminated.
Definition battle.h:206
void(* initBattleCallback)(void)
struct Stage * curStage
struct Evt * camMovementScript
s8 moveCategory
0 = jump, 1 = hammer, 5 = partner, ...
s8 lastPlayerMenuSelection[16]
struct EffectInstance * waterBlockEffect
void(* preUpdateCallback)(void)
struct EffectInstance * cloudNineEffect
struct Actor * curTurnEnemy
struct Actor * partnerActor
struct Evt * controlScript
struct Actor * playerActor
s8 lastPartnerMenuSelection[16]
struct Actor * enemyActors[24]
struct EffectInstance * buffEffect
union Camera::@17 params
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
s32 gBattleState
Definition battle.c:10
s32 gCurrentBattleID
Definition battle.c:16
BackgroundHeader gBackgroundImage
GameStatus * gGameStatusPtr
Definition main_loop.c:32
struct Battle * gOverrideBattlePtr
Definition battle.c:18
Camera gCameras[4]
Definition cam_main.c:17
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11
s32 gCurrentCameraID
Definition cam_math.c:4
s32 gCurrentStageID
Definition battle.c:17
s32 gBattleSubState
Definition battle.c:14
MoveData gMoveTable[]
StatusBar gStatusBar
Definition inventory.c:17
s32 gLastDrawBattleState
Definition battle.c:12