Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
enemy_next.c
Go to the documentation of this file.
1#include "states.h"
2
3enum {
4 // BTL_SUBSTATE_INIT = 0,
6 BTL_SUBSTATE_DONE = 2, // enemy has been found
7};
8
10
15 Actor* enemy;
17 s32 i;
18
19 switch (gBattleSubState) {
22 i = battleStatus->nextEnemyIndex;
23 if (i >= battleStatus->numEnemyActors) {
24 // all enemies have been exhausted
25 battleStatus->nextEnemyIndex = 0;
27 return;
28 }
29
30 // find the next eligible enemy
31 while (TRUE) {
32 if (battleStatus->enemyIDs[i] >= 0) {
33 u16 enemyID = battleStatus->enemyIDs[i];
34
35 enemy = battleStatus->enemyActors[enemyID & 0xFF];
36 if (enemy != NULL) {
38 break;
39 }
40 }
41 }
42 i++;
43 if (i >= battleStatus->numEnemyActors) {
44 i = 0;
45 }
46 if (i == 0) {
47 battleStatus->nextEnemyIndex = 0;
49 return;
50 }
51 }
52
53 battleStatus->activeEnemyActorID = battleStatus->enemyIDs[i++];
54 battleStatus->curTurnEnemy = enemy;
55 battleStatus->nextEnemyIndex = i;
56
58
59 if (enemy->debuff == STATUS_KEY_SLEEP) {
61 }
62 if (enemy->debuff == STATUS_KEY_UNUSED) {
64 }
65 if (enemy->debuff == STATUS_KEY_DIZZY) {
67 }
68 if (enemy->debuff == STATUS_KEY_PARALYZE) {
70 }
71 if (enemy->debuff == STATUS_KEY_FROZEN) {
73 }
74 if (enemy->debuff == STATUS_KEY_STOP) {
76 }
77 if (enemy->stoneStatus == STATUS_KEY_STONE) {
79 }
80 if (enemy->flags & ACTOR_FLAG_SKIP_TURN) {
82 }
83
84 if (skipEnemy) {
85 // reset state to fetch next enemy
87 return;
88 }
89
90 battleStatus->stateFreezeCount = 0;
95
98
99 if (partner != NULL) {
102 }
103
107
109 if (enemy->handlePhaseSource != NULL) {
111
112 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
116 onTurnChanceScript->owner1.actorID = battleStatus->activeEnemyActorID;
117 }
119 break;
121 if (battleStatus->stateFreezeCount == 0) {
122 enemy = get_actor(battleStatus->activeEnemyActorID);
123
124 if (enemy == NULL || enemy->ordinal != NextEnemyWaitingOrdinal) {
126 } else {
128 if (battleStatus->cancelTurnMode < 0) {
129 battleStatus->cancelTurnMode = 0;
131 } else {
133 }
134 }
135 }
136 }
137 break;
138 }
139}
140
BSS s32 PopupMenu_SelectedIndex
struct Evt * handlePhaseScript
EvtScript * handlePhaseSource
s32 handlePhaseScriptID
@ BTL_SUBSTATE_UNUSED_1
Definition enemy_next.c:5
@ BTL_SUBSTATE_DONE
Definition enemy_next.c:6
BSS u8 NextEnemyWaitingOrdinal
Definition enemy_next.c:9
void btl_state_update_next_enemy(void)
Definition enemy_next.c:11
void btl_state_draw_next_enemy(void)
Definition enemy_next.c:141
@ PHASE_ENEMY_BEGIN
Definition enums.h:2101
@ BS_FLAGS2_HIDE_BUFF_COUNTERS
Definition enums.h:3649
@ STATUS_KEY_PARALYZE
Definition enums.h:2806
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ STATUS_KEY_UNUSED
Definition enums.h:2804
@ STATUS_KEY_STONE
Definition enums.h:2813
@ STATUS_KEY_STOP
Definition enums.h:2809
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ BATTLE_STATE_ENEMY_MOVE
Definition enums.h:3685
@ BATTLE_STATE_NEXT_ENEMY
Definition enums.h:3684
@ BATTLE_STATE_END_TURN
Definition enums.h:3670
@ ACTOR_FLAG_SKIP_TURN
Definition enums.h:3370
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3368
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3373
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3376
@ EVT_PRIORITY_A
Definition evt.h:154
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
s32 does_script_exist(s32 id)
void btl_set_state(s32 battleState)
#define BSS
Definition macros.h:7
@ BTL_SUBSTATE_INIT
Definition states.h:8
struct Actor * partnerActor
struct Actor * playerActor
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17