Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
states.h File Reference

Go to the source code of this file.

Enumerations

enum  BattleSubStates { BTL_SUBSTATE_INIT = 0 , BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT = 2 , BTL_SUBSTATE_PLAYER_CONTINUE_DIP = 70 }
 

Functions

void btl_state_update_normal_start (void)
 
void btl_state_draw_normal_start (void)
 
void btl_state_update_begin_turn (void)
 
void btl_state_draw_begin_turn (void)
 
void btl_state_update_begin_player_turn (void)
 
void btl_state_draw_begin_player_turn (void)
 
void btl_state_update_switch_to_player (void)
 
void btl_state_draw_switch_to_player (void)
 
void btl_state_update_begin_partner_turn (void)
 
void btl_state_draw_begin_partner_turn (void)
 
void btl_state_update_switch_to_partner (void)
 
void btl_state_draw_switch_to_partner (void)
 
void btl_state_update_transfer_turn (void)
 
void btl_state_draw_transfer_turn (void)
 
void btl_state_update_prepare_menu (void)
 
void btl_state_draw_prepare_menu (void)
 
void btl_state_update_end_turn (void)
 
void btl_state_draw_end_turn (void)
 
void btl_state_update_victory (void)
 
void btl_state_draw_victory (void)
 
void btl_state_update_end_training_battle (void)
 
void btl_state_draw_end_training_battle (void)
 
void btl_state_update_end_battle (void)
 
void btl_state_draw_end_battle (void)
 
void btl_state_update_defend (void)
 
void btl_state_draw_defend (void)
 
void btl_state_update_run_away (void)
 
void btl_state_draw_run_away (void)
 
void btl_state_update_defeat (void)
 
void btl_state_draw_defeat (void)
 
void btl_state_update_change_partner (void)
 
void btl_state_draw_change_partner (void)
 
void btl_state_update_player_move (void)
 
void btl_state_draw_player_move (void)
 
void btl_state_update_end_player_turn (void)
 
void btl_state_update_partner_move (void)
 
void btl_state_draw_end_player_turn (void)
 
void btl_state_draw_partner_move (void)
 
void btl_state_update_end_partner_turn (void)
 
void btl_state_draw_end_partner_turn (void)
 
void btl_state_update_next_enemy (void)
 
void btl_state_draw_next_enemy (void)
 
void btl_state_update_enemy_move (void)
 
void btl_state_draw_enemy_move (void)
 
void btl_state_update_first_strike (void)
 
void btl_state_draw_first_stike (void)
 
void btl_state_update_partner_striking_first (void)
 
void btl_state_draw_partner_striking_first (void)
 
void btl_state_update_enemy_striking_first (void)
 
void btl_state_draw_enemy_striking_first (void)
 
void btl_state_update_end_demo_battle (void)
 
void btl_state_draw_end_demo_battle (void)
 
void btl_state_update_player_menu (void)
 
void btl_state_draw_player_menu (void)
 
void btl_state_update_partner_menu (void)
 
void btl_state_draw_partner_menu (void)
 
void btl_state_update_peach_menu (void)
 
void btl_state_draw_peach_menu (void)
 
void btl_state_update_twink_menu (void)
 
void btl_state_draw_twink_menu (void)
 
void btl_state_update_select_target (void)
 
void btl_state_draw_select_target (void)
 
void btl_state_update_celebration (void)
 
void btl_state_draw_celebration (void)
 

Variables

s16 EndDemoWhiteOut
 
b32 BattleSkipActorTurn
 
b32 BattleCanShowFirstStrike
 
s32 BattleStatusUpdateDelay
 
s32 BattleSubstateDelay
 
s32 BattleScreenFadeAmt
 

Enumeration Type Documentation

◆ BattleSubStates

Enumerator
BTL_SUBSTATE_INIT 
BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT 
BTL_SUBSTATE_PLAYER_CONTINUE_DIP 

Definition at line 6 of file states.h.

6 {
7 // shared
9
10 // accessed across states
13};
@ BTL_SUBSTATE_INIT
Definition states.h:8
@ BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT
Definition states.h:11
@ BTL_SUBSTATE_PLAYER_CONTINUE_DIP
Definition states.h:12

Function Documentation

◆ btl_state_update_normal_start()

void btl_state_update_normal_start ( void )

Definition at line 50 of file start_battle.c.

50 {
54 Stage* stage;
55 Actor* actor;
56 Evt* script;
58 s32 type;
59 s32 i;
60 s32 j;
61
62 s32* types;
63
65 if (gOverrideBattlePtr != NULL) {
67 }
68
69 if (gCurrentStagePtr == NULL) {
70 stage = battle->stage;
71 } else {
72 stage = gCurrentStagePtr->stage;
73 }
74
75 battleStatus->curStage = stage;
76 switch (gBattleSubState) {
78 #if DX_DEBUG_MENU
80 #endif
81
82 BattleEnemiesCreated = battle->formationSize;
84
85 load_stage_assets(stage);
86
89 }
90
91 battleStatus->controlScript = NULL;
92 battleStatus->camMovementScript = NULL;
93 battleStatus->unk_90 = 0;
94 battleStatus->preUpdateCallback = NULL;
95 battleStatus->initBattleCallback = NULL;
96 battleStatus->curSubmenu = 0;
97 battleStatus->lastSelectedAbility = 0;
98 battleStatus->curPartnerSubmenu = 0;
99 battleStatus->lastPartnerPowerSelection = 0;
100 battleStatus->totalStarPoints = 0;
101 battleStatus->pendingStarPoints = 0;
102 battleStatus->incrementStarPointDelay = 0;
103 battleStatus->damageTaken = 0;
104 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
105 battleStatus->actionCommandMode = AC_MODE_NOT_LEARNED;
110 battleStatus->actionCommandMode = AC_MODE_LEARNED;
111 }
112 battleStatus->actionQuality = 0;
113 battleStatus->maxActionQuality = 0;
114 battleStatus->enabledMenusFlags = -1;
115 battleStatus->enabledStarPowersFlags = -1;
116 battleStatus->itemUsesLeft = 0;
117 battleStatus->hammerCharge = 0;
118 battleStatus->jumpCharge = 0;
119 battleStatus->unk_98 = 0;
120 battleStatus->hpDrainCount = 0;
122 if (currentEncounter->forbidFleeing) {
124 }
125 battleStatus->endBattleFadeOutRate = 10;
126 battleStatus->waitForState = BATTLE_STATE_NONE;
127 battleStatus->hammerLossTurns = -1;
128 battleStatus->jumpLossTurns = -1;
129 battleStatus->itemLossTurns = -1;
130 battleStatus->outtaSightActive = 0;
131 battleStatus->waterBlockTurnsLeft = 0;
132 battleStatus->waterBlockAmount = 0;
133 battleStatus->waterBlockEffect = NULL;
134 battleStatus->cloudNineTurnsLeft = 0;
135 battleStatus->cloudNineDodgeChance = 0;
136 battleStatus->cloudNineEffect = NULL;
137 battleStatus->reflectFlags = 0;
138 battleStatus->turboChargeTurnsLeft = 0;
139 battleStatus->turboChargeAmount = 0;
140 battleStatus->stateFreezeCount = 0;
141 battleStatus->merleeAttackBoost = 0;
142 battleStatus->merleeDefenseBoost = 0;
144 battleStatus->unk_433 = -1;
145 battleStatus->hustleTurns = 0;
146 battleStatus->nextActorOrdinal = 0;
147 battleStatus->cancelTurnMode = 0;
154
155 for (i = 0; i < ARRAY_COUNT(battleStatus->varTable); i++) {
156 battleStatus->varTable[i] = 0;
157 }
158
160 battleStatus->inputBitmask = 0xFFFFF & ~(BUTTON_START | 0xC0);
161 battleStatus->buffEffect = fx_partner_buff(0, 0.0f, 0.0f, 0.0f, 0.0f, 0);
165 battleStatus->camMovementScript = script;
166 battleStatus->camMovementScriptID = script->id;
168 break;
170 // wait for camera initialization to finish
171 if (does_script_exist(battleStatus->camMovementScriptID)) {
172 break;
173 }
174
175 if (stage->preBattle != NULL) {
177 battleStatus->controlScript = script;
178 battleStatus->controlScriptID = script->id;
179 }
180
183
184 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
185 battleStatus->enemyActors[i] = NULL;
186 }
187 battleStatus->initialEnemyCount = 0;
188
189 for (i = 0; i < BattleEnemiesCreated; i++) {
190 create_actor(&(*battle->formation)[i]);
192 actor = battleStatus->enemyActors[i];
193
194 while (TRUE) {
195 type = *types;
196 if (type == -1) {
197 battleStatus->initialEnemyCount++;
198 break;
199 } else if (actor->actorType == type) {
200 break;
201 }
202 types++;
203 }
204
205 actor->instigatorValue = 0;
206 if (i == 0) {
207 actor->instigatorValue = currentEncounter->instigatorValue;
208 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
210 }
211 }
212 }
213
214 if (stage->stageEnemyCount != 0) {
215 if (stage->stageEnemyChance == 0 || (stage->stageEnemyChance > 0 && (rand_int(stage->stageEnemyChance) == 0))) {
217 for (j = 0; i < BattleEnemiesCreated; i++, j++) {
218 create_actor(&(*stage->stageFormation)[j]);
219 actor = battleStatus->enemyActors[i];
220 actor->instigatorValue = 0;
221 if (i == 0) {
222 actor->instigatorValue = 0;
223 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
225 }
226 }
227
228 }
229 }
230 }
231
233 actor = battleStatus->playerActor;
236 } else {
238 }
239 actor->takeTurnScript = script;
240 actor->takeTurnScriptID = script->id;
241 script->owner1.actorID = ACTOR_PLAYER;
244 break;
247 for (i = 0; i < BattleEnemiesCreated; i++) {
248 actor = battleStatus->enemyActors[i];
251 break;
252 } else {
253 actor->takeTurnScript = NULL;
254 }
255 }
256 if (enemyNotDone) {
257 break;
258 }
259
260 actor = battleStatus->playerActor;
262 break;
263 }
264 actor->takeTurnScript = NULL;
265
266 actor = battleStatus->partnerActor;
267 if (actor != NULL) {
269 break;
270 }
271 actor->takeTurnScript = NULL;
272 }
273
274 if (battle->onBattleStart != NULL) {
275 script = start_script(battle->onBattleStart, EVT_PRIORITY_A, 0);
276 battleStatus->controlScript = script;
277 battleStatus->controlScriptID = script->id;
278 }
279 if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) {
282 }
284 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
285 }
286
287 switch (currentEncounter->firstStrikeType) {
290 break;
293 break;
294 default:
296 actor = battleStatus->playerActor;
299 } else {
301 }
302 actor->takeTurnScript = script;
303 actor->takeTurnScriptID = script->id;
304 script->owner1.actorID = ACTOR_PLAYER;
305 }
306
307 if (currentEncounter->curEnemy != NULL
308 && currentEncounter->curEnemy->encountered == ENCOUNTER_TRIGGER_SPIN
310 ) {
311 actor = battleStatus->enemyActors[0];
313 actor->takeTurnScript = script;
314 actor->takeTurnScriptID = script->id;
315 script->owner1.enemyID = ACTOR_ENEMY0;
316 }
317
321 break;
322 }
323 break;
325 if (BattleScreenFadeAmt == 0) {
327 break;
328 }
329
331 if (BattleSubstateDelay == 15) {
333 }
334
337 } else {
339 }
340
341 if (BattleScreenFadeAmt < 0) {
343 }
344 break;
346 if (battleStatus->stateFreezeCount == 0) {
349 }
350 break;
351 }
352}
s32 BattleScreenFadeAmt
Definition 16C8E0.c:50
Actor * create_actor(Formation formation)
Definition 190B20.c:1408
BSS s32 PopupMenu_SelectedIndex
@ AC_MODE_NOT_LEARNED
Definition action_cmd.h:60
@ AC_MODE_LEARNED
Definition action_cmd.h:61
BSS Battle * gCurrentBattlePtr
Definition battle.cpp:22
BSS s32 BattleSubstateDelay
struct Evt * takeTurnScript
s32 takeTurnScriptID
s8 instigatorValue
#define rand_int
@ MERLEE_SPELL_NONE
Definition enums.h:1936
@ OVERLAY_NONE
Definition enums.h:2373
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2374
@ BUTTON_START
Definition enums.h:2773
@ BS_FLAGS1_ACTORS_VISIBLE
Definition enums.h:3598
@ SCREEN_LAYER_BACK
Definition enums.h:2369
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3576
@ CAMERA_FLAG_DISABLED
Definition enums.h:4306
@ BS_FLAGS2_CAN_FLEE
Definition enums.h:3642
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ ENCOUNTER_TRIGGER_SPIN
Definition enums.h:270
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2837
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BATTLE_STATE_ENEMY_FIRST_STRIKE
Definition enums.h:3668
@ BATTLE_STATE_FIRST_STRIKE
Definition enums.h:3666
@ BATTLE_STATE_BEGIN_TURN
Definition enums.h:3669
@ BATTLE_STATE_NONE
Definition enums.h:3664
@ ABILITY_CHILL_OUT
Definition enums.h:453
@ ABILITY_DIZZY_ATTACK
Definition enums.h:481
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_ENEMY0
Definition enums.h:2120
@ FIRST_STRIKE_NONE
Definition enums.h:3492
@ FIRST_STRIKE_ENEMY
Definition enums.h:3494
@ FIRST_STRIKE_PLAYER
Definition enums.h:3493
@ BTL_DARKNESS_STATE_NONE
Definition enums.h:5950
@ CAM_TATTLE
Definition enums.h:1828
@ CAM_DEFAULT
Definition enums.h:1826
@ CAM_BATTLE
Definition enums.h:1827
@ EVT_PRIORITY_A
Definition evt.h:154
void load_partner_actor(void)
Definition 190B20.c:1154
void set_screen_overlay_params_back(u8, f32)
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
void setup_status_bar_for_battle(void)
Definition inventory.c:1471
void set_screen_overlay_params_front(u8, f32)
void btl_cam_use_preset(s32)
Definition camera.c:1919
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void set_screen_overlay_color(s32, u8, u8, u8)
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2313
s32 does_script_exist(s32 id)
void load_player_actor(void)
Definition 190B20.c:940
void btl_set_state(s32 battleState)
void set_curtain_scale_goal(f32 scale)
Definition curtains.c:285
EvtScript EVS_ApplyDizzyAttack
EncounterStatus gCurrentEncounter
Definition encounter.c:175
#define ARRAY_COUNT(arr)
Definition macros.h:40
EvtScript * preBattle
Definition battle.h:185
const char * shape
Definition battle.h:183
Formation * stageFormation
Definition battle.h:190
s32 stageEnemyChance
Definition battle.h:191
Stage * stage
Definition battle.h:208
s32 stageEnemyCount
Definition battle.h:189
Zero-terminated.
Definition battle.h:195
BSS s32 BattleEnemiesCreated
@ BTL_SUBSTATE_CHECK_FIRST_STRIKE
@ BTL_SUBSTATE_CREATE_ENEMIES
@ BTL_SUBSTATE_DONE
@ BTL_SUBSTATE_FADE_IN
EvtScript EVS_PeachEnterStage
EvtScript EVS_Peach_OnActorCreate
StageListRow * gCurrentStagePtr
Definition battle.cpp:12
void load_stage_assets(Stage *stage)
EvtScript EVS_MarioEnterStage
s32 bActorsIgnoreDuringCount[]
EvtScript EVS_OnBattleInit
Definition camera.c:1171
EvtScript EVS_Mario_OnActorCreate
s32 gCurrentBattleID
Definition battle.cpp:19
GameStatus * gGameStatusPtr
Definition main_loop.c:31
struct Battle * gOverrideBattlePtr
Definition battle.cpp:21
Camera gCameras[4]
Definition cam_main.c:16
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gCurrentCameraID
Definition cam_math.c:5
s32 gCurrentStageID
Definition battle.cpp:20
s32 gBattleSubState
Definition battle.cpp:17
StatusBar gStatusBar
Definition inventory.c:22

Referenced by btl_update().

◆ btl_state_draw_normal_start()

void btl_state_draw_normal_start ( void )

Definition at line 354 of file start_battle.c.

Referenced by btl_draw_ui().

◆ btl_state_update_begin_turn()

void btl_state_update_begin_turn ( void )

Definition at line 12 of file turn_begin.c.

12 {
14 Actor* partner = battleStatus->partnerActor;
15 Actor* player = battleStatus->playerActor;
16 Actor* enemy;
19 Evt* script;
21 u16 id1;
22 u16 id2;
23 s32 numEnemyActors;
24 s32 i;
25 s32 j;
26 s16* enemyIDs;
27
33 battleStatus->merleeAttackBoost = 0;
34 battleStatus->merleeDefenseBoost = 0;
36
38 player->disableDismissTimer = 0;
39 if (partner != NULL) {
41 partner->disableDismissTimer = 0;
42 }
43
44 if (battleStatus->hustleTurns != 0) {
46 }
47
48 numEnemyActors = 0;
49 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
50 enemy = battleStatus->enemyActors[i];
51 if (enemy != NULL) {
52 battleStatus->enemyIDs[numEnemyActors] = i | ACTOR_ENEMY0;
53 numEnemyActors++;
54 }
55 }
56 battleStatus->numEnemyActors = numEnemyActors;
57
58 // sort enemies by x-position or turn priority
59 enemyIDs = battleStatus->enemyIDs;
60 for (i = 0; i < numEnemyActors - 1; i++) {
61 for (j = i + 1; j < numEnemyActors; j++) {
62 id1 = enemyIDs[i];
63 id2 = enemyIDs[j];
64 enemy1 = battleStatus->enemyActors[id1 & 0xFF];
65 enemy2 = battleStatus->enemyActors[id2 & 0xFF];
67 if (enemy1->homePos.x > enemy2->homePos.x) {
68 enemyIDs[i] = id2;
69 enemyIDs[j] = id1;
70 }
71 } else if (enemy1->turnPriority < enemy2->turnPriority) {
72 enemyIDs[i] = id2;
73 enemyIDs[j] = id1;
74 }
75 }
76 }
77 battleStatus->nextEnemyIndex = 0;
78
80
81 // clear rush flags to initialize
82 battleStatus->rushFlags = RUSH_FLAG_NONE;
84
85 // set rush flags based on danger/peril status
89 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
90 }
92 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
94 battleStatus->rushFlags |= RUSH_FLAG_POWER;
95 }
96 }
97 }
98
100 battleStatus->jumpCharge = 0;
101 }
102
104 battleStatus->hammerCharge = 0;
105 }
106
109 return;
110 }
111
113 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
114 enemy = battleStatus->enemyActors[i];
115 if (enemy != NULL && enemy->handleEventSource != NULL) {
117
118 enemy->handleEventScript = script;
119 script->owner1.actorID = i | ACTOR_ENEMY0;
120 enemy->handleEventScriptID = script->id;
121 enemy->lastEventType = EVENT_DEATH;
122 }
123 }
125 } else {
126 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
127 enemy = battleStatus->enemyActors[i];
128 if (enemy != NULL && enemy->handlePhaseSource != NULL) {
129 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
131 enemy->handlePhaseScript = script;
132 enemy->handlePhaseScriptID = script->id;
133 script->owner1.actorID = i | ACTOR_ENEMY0;
134 }
135 }
136
137 partner = battleStatus->partnerActor;
138 if (partner != NULL && partner->handlePhaseSource != NULL) {
139 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
140 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
141 partner->handlePhaseScript = script;
142 partner->handlePhaseScriptID = script->id;
143 script->owner1.actorID = ACTOR_PARTNER;
144 }
146 }
147 }
148
150 awaiting = FALSE;
151 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
152 enemy = battleStatus->enemyActors[i];
153 if (enemy != NULL && enemy->handlePhaseSource != NULL && does_script_exist(enemy->handlePhaseScriptID)) {
154 awaiting = TRUE;
155 }
156 }
157 if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handlePhaseScriptID)) {
158 awaiting = TRUE;
159 }
160
161 if (!awaiting) {
164 }
165 return;
166 }
167 }
168
170 awaiting = FALSE;
171 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
172 enemy = battleStatus->enemyActors[i];
173 if (enemy != NULL && enemy->handleEventSource != NULL && does_script_exist(enemy->handleEventScriptID)) {
174 awaiting = TRUE;
175 }
176 }
177
178 if (!awaiting) {
181 }
182 }
183 }
184}
struct Evt * handlePhaseScript
EvtScript * handleEventSource
s8 disableDismissTimer
struct Evt * handleEventScript
EvtScript * handlePhaseSource
s32 b32
s32 handleEventScriptID
s32 handlePhaseScriptID
union Evt::@10 owner1
Initially -1.
@ BS_FLAGS1_HUSTLED
Definition enums.h:3628
@ BS_FLAGS1_SORT_ENEMIES_BY_POSX
Definition enums.h:3629
@ BS_FLAGS1_JUMP_CHARGED
Definition enums.h:3631
@ BS_FLAGS1_HAMMER_CHARGED
Definition enums.h:3630
@ DEBUG_CONTACT_DIE_IN_BATTLE
Definition enums.h:3869
@ DEBUG_CONTACT_AUTO_FLEE
Definition enums.h:3870
@ RUSH_FLAG_NONE
Definition enums.h:4915
@ RUSH_FLAG_MEGA
Definition enums.h:4916
@ RUSH_FLAG_POWER
Definition enums.h:4917
@ PHASE_PLAYER_BEGIN
Definition enums.h:2099
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3654
@ BATTLE_STATE_RUN_AWAY
Definition enums.h:3688
@ BATTLE_STATE_BEGIN_PLAYER_TURN
Definition enums.h:3671
@ ABILITY_POWER_RUSH
Definition enums.h:466
@ ABILITY_MEGA_RUSH
Definition enums.h:456
@ ACTOR_PARTNER
Definition enums.h:2119
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3377
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3376
@ EVENT_DEATH
Definition enums.h:2186
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653
#define PERIL_THRESHOLD
Definition battle.h:277
#define DANGER_THRESHOLD
Definition battle.h:276
void btl_merlee_on_start_turn(void)
@ BTL_SUBSTATE_AWAIT_ENEMY_SCRIPTS
Definition turn_begin.c:8
@ BTL_SUBSTATE_AWAIT_ENEMY_DEATH
Definition turn_begin.c:9

Referenced by btl_update().

◆ btl_state_draw_begin_turn()

void btl_state_draw_begin_turn ( void )

Definition at line 186 of file turn_begin.c.

186 {
187}

Referenced by btl_draw_ui().

◆ btl_state_update_begin_player_turn()

void btl_state_update_begin_player_turn ( void )

Definition at line 346 of file player_turn_begin.c.

346 {
348 Actor* player = battleStatus->playerActor;
349 Actor* partner = battleStatus->partnerActor;
350 Evt* script;
351
354 btl_cam_move(5);
356 }
357
358 switch (gBattleSubState) {
363 battleStatus->actionResult = ACTION_RESULT_NONE;
364 battleStatus->blockResult = BLOCK_RESULT_NONE;
365 battleStatus->selectedMoveID = 0;
368 player->disableDismissTimer = 0;
370
371 if (partner != NULL) {
373 partner->disableDismissTimer = 0;
374 }
375
376 battleStatus->stateFreezeCount = 0;
379
380 if (battleStatus->outtaSightActive != 0) {
381 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
382 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
383 partner->handlePhaseScript = script;
385 partner->handlePhaseScriptID = script->id;
386 script->owner1.actorID = ACTOR_PARTNER;
387 } else {
389 }
390 }
391 break;
393 if (!does_script_exist(partner->handlePhaseScriptID)) {
394 battleStatus->outtaSightActive = 0;
397 }
398 break;
399 }
400
404
407
409 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
410 player->handleEventScript = NULL;
411
413 return;
414 }
415
416 if (BattleStatusUpdateDelay != 0) {
418 return;
419 }
420
424 } else{
426 }
427 }
428 }
429}
BSS s32 BattleStatusUpdateDelay
BSS b32 BattleSkipActorTurn
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3601
@ PHASE_ENEMY_BEGIN
Definition enums.h:2101
@ BS_FLAGS2_PLAYER_TURN_USED
Definition enums.h:3638
@ BS_FLAGS2_PARTNER_TURN_USED
Definition enums.h:3639
@ BATTLE_STATE_BEGIN_PARTNER_TURN
Definition enums.h:3672
@ BATTLE_STATE_SWITCH_TO_PLAYER
Definition enums.h:3674
@ BLOCK_RESULT_NONE
Definition enums.h:1998
@ ACTION_RESULT_NONE
Definition enums.h:1989
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void reset_actor_turn_info(void)
Definition 190B20.c:710
void btl_cam_move(s16)
Definition camera.c:1953
s32 btl_cam_is_moving_done(void)
Definition camera.c:1980
void update_turbo_charge(void)
void update_cloud_nine(void)
void update_water_block(void)
void update_status_damage(void)
void update_command_loss(void)
@ BTL_SUBSTATE_RESET_STATE
@ BTL_SUBSTATE_CHECK_WATER_BLOCK
@ BTL_SUBSTATE_AWAIT_OUTTA_SIGHT
@ BTL_SUBSTATE_END_DELAY

Referenced by btl_update().

◆ btl_state_draw_begin_player_turn()

void btl_state_draw_begin_player_turn ( void )

Definition at line 431 of file player_turn_begin.c.

431 {
432}

Referenced by btl_draw_ui().

◆ btl_state_update_switch_to_player()

void btl_state_update_switch_to_player ( void )

Definition at line 3 of file switch_to_player.c.

3 {
6 s32 i;
7
16 if (partner != NULL) {
18 }
19
20 for (i = 0; i < ARRAY_COUNT(gBattleStatus.enemyActors); i++) {
22
23 if (enemy != NULL) {
26 }
27 }
28
30 }
31}
@ BATTLE_STATE_PREPARE_MENU
Definition enums.h:3676
@ ACTOR_FLAG_HEALTH_BAR_HIDDEN
Definition enums.h:3372
struct Actor * partnerActor
struct Actor * playerActor
struct Actor * enemyActors[24]

Referenced by btl_update().

◆ btl_state_draw_switch_to_player()

void btl_state_draw_switch_to_player ( void )

Definition at line 33 of file switch_to_player.c.

33 {
34}

Referenced by btl_draw_ui().

◆ btl_state_update_begin_partner_turn()

void btl_state_update_begin_partner_turn ( void )

Definition at line 13 of file partner_turn_begin.c.

13 {
15 Actor* partner = battleStatus->partnerActor;
16 Actor* enemy;
17 Evt* script;
18 s32 i;
19
21 if (partner == NULL) {
26 return;
27 } else if (partner->flags & ACTOR_FLAG_NO_ATTACK) {
29 return;
30 } else {
32 btl_cam_move(5);
34 }
35 }
36
41 partner = battleStatus->partnerActor;
42 battleStatus->actionResult = ACTION_RESULT_NONE;
43 battleStatus->blockResult = BLOCK_RESULT_NONE;
48
49 if (partner->koStatus != 0) {
50 partner->koDuration--;
53 if (partner->koDuration > 0) {
54 partner->disableEffect->data.disableX->koDuration = partner->koDuration;
55 } else {
56 partner->koStatus = 0;
58 partner->disableEffect->data.disableX->koDuration = 0;
60 }
61 }
62
63 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
64 enemy = battleStatus->enemyActors[i];
65 if (enemy != NULL) {
67 }
68 }
70 }
71 }
72
73 switch (gBattleSubState) {
75 if (partner != NULL) {
76 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
77 break;
78 }
79 partner->handleEventScript = NULL;
80 }
81
84 return;
85 }
87 break;
88 }
89
91 if (partner->handlePhaseSource != NULL) {
92 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
93 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
94 partner->handlePhaseScript = script;
95 partner->handlePhaseScriptID = script->id;
96 script->owner1.actorID = ACTOR_PARTNER;
97 }
99 }
100
102 if (partner->handlePhaseSource == NULL || !does_script_exist(partner->handlePhaseScriptID)) {
104 }
105 }
106
108 if (BattleStatusUpdateDelay != 0) {
110 return;
111 }
116 } else {
118 }
119 }
120}
@ BS_FLAGS1_PLAYER_IN_BACK
Definition enums.h:3622
@ BS_FLAGS1_PARTNER_ACTING
Definition enums.h:3621
@ BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER
Definition enums.h:3640
@ BATTLE_STATE_SWITCH_TO_PARTNER
Definition enums.h:3675
@ BATTLE_STATE_TRANSFER_TURN
Definition enums.h:3673
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3373
@ EVENT_RECOVER_FROM_KO
Definition enums.h:2203
void dispatch_event_partner(s32)
Definition dmg_partner.c:7
@ BTL_SUBSTATE_AWAIT_RECOVER_DONE
@ BTL_SUBSTATE_RESET_STATE
@ BTL_SUBSTATE_AWAIT_TURN_SCRIPT
@ BTL_SUBSTATE_EXEC_TURN_SCRIPT
@ BTL_SUBSTATE_END_DELAY

Referenced by btl_update().

◆ btl_state_draw_begin_partner_turn()

void btl_state_draw_begin_partner_turn ( void )

Definition at line 122 of file partner_turn_begin.c.

122 {
123}

Referenced by btl_draw_ui().

◆ btl_state_update_switch_to_partner()

◆ btl_state_draw_switch_to_partner()

void btl_state_draw_switch_to_partner ( void )

Definition at line 30 of file switch_to_partner.c.

30 {
31}

Referenced by btl_draw_ui().

◆ btl_state_update_transfer_turn()

void btl_state_update_transfer_turn ( void )

Definition at line 16 of file turn_transfer.c.

16 {
18 Actor* player = battleStatus->playerActor;
19 Actor* partner = battleStatus->partnerActor;
20 Actor* actor;
21 ActorState* state;
22 Evt* script;
24 s32 i;
25
27
31 return;
32 }
33
34 if (partner != NULL) {
37 return;
38 }
39 }
40
43 if (partner != NULL) {
46 }
47
54 }
55
57 // await all enemy event scripts
59 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
60 actor = battleStatus->enemyActors[i];
61 if (actor != NULL && actor->handleEventScript != NULL) {
64 } else {
65 actor->handleEventScript = NULL;
66 }
67 }
68 }
69 if (waitingForScript) {
70 return;
71 }
72
74
75 // prepare each enemy actor for the coming turn
76 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
77 actor = battleStatus->enemyActors[i];
78
79 if (actor == NULL) {
80 continue;
81 }
82
85
86 if (actor->debuff != 0) {
87 if (actor->debuff == STATUS_KEY_UNUSED
88 || actor->debuff == STATUS_KEY_DIZZY
89 || actor->debuff == STATUS_KEY_PARALYZE
90 || actor->debuff == STATUS_KEY_SLEEP
91 || actor->debuff == STATUS_KEY_FROZEN
92 || actor->debuff == STATUS_KEY_STOP
93 ) {
95 }
96 actor->debuffDuration--;
97 if (actor->debuffDuration <= 0) {
98 actor->debuff = 0;
102 }
103 }
104
105 if (actor->staticStatus != 0) {
106 actor->staticDuration--;
107 if (actor->staticDuration <= 0) {
108 actor->staticStatus = 0;
111 }
112 }
113
114 if (actor->transparentStatus != 0) {
115 actor->transparentDuration--;
116 if (actor->transparentDuration <= 0) {
117 actor->transparentStatus = 0;
120 }
121 }
122
123 if (actor->stoneStatus != 0) {
124 actor->stoneDuration--;
125 if (actor->stoneDuration <= 0) {
126 actor->stoneStatus = 0;
128 }
129 }
130
131 oldKoDuration = actor->koDuration;
132 actor->koDuration = actor->debuffDuration;
133 if (actor->koDuration > 0) {
134 actor->koStatus = STATUS_KEY_KO;
136 } else if (oldKoDuration != actor->koDuration) {
137 actor->koStatus = 0;
139 }
140 if (actor->debuff == STATUS_KEY_POISON) {
144 }
145 }
147 }
148
150 // wait for player HandleEvent script to finish
151 if(player->handleEventScript != NULL) {
153 return;
154 } else {
155 player->handleEventScript = NULL;
156 }
157 }
158
159 // wait for partner HandleEvent script to finish
160 if (partner != NULL) {
161 if (partner->handleEventScript != NULL) {
162 if (does_script_exist(partner->handleEventScriptID)) {
163 return;
164 } else {
165 partner->handleEventScript = NULL;
166 }
167 }
168 }
169
170 // wait for all enemy HandleEvent scripts to finish
172 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
173 actor = battleStatus->enemyActors[i];
174 if (actor != NULL && actor->handleEventScript != NULL) {
177 } else {
178 actor->handleEventScript = NULL;
179 }
180 }
181 }
182 if (waitingForScript) {
183 return;
184 }
185
187 return;
188 }
189
191
196 } else {
201 state = &partner->state;
202 if (!battleStatus->outtaSightActive) {
203 partner->state.curPos.x = partner->homePos.x;
204 partner->state.curPos.z = partner->homePos.z;
205 partner->state.goalPos.x = player->homePos.x;
206 partner->state.goalPos.z = player->homePos.z;
207 } else {
208 partner->state.curPos.x = partner->homePos.x;
209 partner->state.curPos.z = partner->homePos.z;
210 partner->state.goalPos.x = partner->homePos.x;
211 partner->state.goalPos.z = partner->homePos.z + 5.0f;
212 partner->homePos.x = player->homePos.x;
213 partner->homePos.z = player->homePos.z;
214 }
215 state->moveTime = 4;
216 state->angle = 0.0f;
218 }
219 }
220
222 if (partner->state.moveTime != 0) {
223 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
224 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
225 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
226 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
227 }
228 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
229 partner->yaw = clamp_angle(partner->state.angle);
230 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
231 player->yaw = clamp_angle(partner->state.angle);
232 partner->state.angle += 90.0f;
233
234 if (partner->state.moveTime != 0) {
235 partner->state.moveTime--;
236 } else {
237 partner->curPos.x = partner->state.goalPos.x;
238 partner->curPos.z = partner->state.goalPos.z;
239 player->curPos.x = partner->state.curPos.x;
240 player->curPos.z = partner->state.curPos.z;
241 if (!battleStatus->outtaSightActive) {
242 partner->homePos.x = partner->curPos.x;
243 partner->homePos.z = partner->curPos.z;
244 player->homePos.x = player->curPos.x;
245 player->homePos.z = player->curPos.z;
246 } else {
247 player->homePos.x = player->curPos.x;
248 player->homePos.z = player->curPos.z;
249 }
252 }
253 }
254
256 if (BattleStatusUpdateDelay != 0) {
258 return;
259 }
260
261 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_DEF_BOOST) {
262 battleStatus->merleeDefenseBoost = 3;
263 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
266 player->takeTurnScript = script;
267 player->takeTurnScriptID = script->id;
268 script->owner1.actorID = ACTOR_PLAYER;
269 }
273 if (partner != NULL) {
276 }
282 }
283
285 // potentially wait for the merlee script to end
286 if (player->takeTurnScript != NULL) {
287 if (does_script_exist(player->takeTurnScriptID)) {
288 return;
289 } else {
290 player->takeTurnScript = NULL;
291 }
292 }
293
294 // initiate all enemy PHASE_PLAYER_END scripts
295 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
296 actor = battleStatus->enemyActors[i];
297 if (actor != NULL && actor->handlePhaseSource != NULL) {
298 battleStatus->battlePhase = PHASE_PLAYER_END;
300 actor->handlePhaseScript = script;
301 actor->handlePhaseScriptID = script->id;
302 script->owner1.enemyID = i | ACTOR_CLASS_ENEMY;
303 }
304 }
305
307 }
308
310 // await all the enemy PHASE_PLAYER_END scripts
312 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
313 actor = battleStatus->enemyActors[i];
314 // interesting: this condition checks for handlePhaseSource instead of handlePhaseScript,
315 // which is the expected pattern. result: handlePhaseScript is never NULL'd. minor bug?
316 if (actor != NULL && actor->handlePhaseSource != NULL) {
319 }
320 }
321 }
322 if (waitingForScript) {
323 return;
324 }
325
327 }
328
331 }
332}
struct EffectInstance * disableEffect
s8 transparentStatus
Vec3f homePos
s16 hudElementDataIndex
Vec3f curPos
s8 staticDuration
s8 debuffDuration
s8 transparentDuration
#define clamp_angle
struct DisableXFXData * disableX
Definition effects.h:2529
EffectInstanceDataPtr data
Definition effects.h:2605
@ MERLEE_SPELL_DEF_BOOST
Definition enums.h:1938
@ ACTOR_CLASS_ENEMY
Definition enums.h:2112
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3608
@ PHASE_MERLEE_DEFENSE_BONUS
Definition enums.h:2104
@ PHASE_PLAYER_END
Definition enums.h:2102
@ STATUS_KEY_PARALYZE
Definition enums.h:2806
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_KEY_KO
Definition enums.h:2814
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ STATUS_KEY_UNUSED
Definition enums.h:2804
@ STATUS_KEY_STOP
Definition enums.h:2809
@ STATUS_KEY_POISON
Definition enums.h:2810
@ BATTLE_STATE_NEXT_ENEMY
Definition enums.h:3684
@ ACTOR_FLAG_SKIP_TURN
Definition enums.h:3370
@ EVENT_HIT
Definition enums.h:2165
@ EVENT_RECOVER_STATUS
Definition enums.h:2200
void remove_status_debuff(s32)
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:102
void remove_status_static(s32)
void remove_status_transparent(s32)
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:875
f32 sin_rad(f32 x)
Definition 43F0.c:711
EvtScript EVS_Mario_HandlePhase
#define DEG_TO_RAD(deg)
Definition macros.h:146
@ BTL_SUBSTATE_TRY_MERLEE_DEF
@ BTL_SUBSTATE_RESET_ENEMIES
@ BTL_SUBSTATE_NOTIFY_ENEMY_PHASE
@ BTL_SUBSTATE_RESET_POSITIONS
@ BTL_SUBSTATE_AWAIT_ALL
@ BTL_SUBSTATE_AWAIT_ENEMY_PHASE
@ BTL_SUBSTATE_DONE

Referenced by btl_update().

◆ btl_state_draw_transfer_turn()

void btl_state_draw_transfer_turn ( void )

Definition at line 334 of file turn_transfer.c.

334 {
335}

Referenced by btl_draw_ui().

◆ btl_state_update_prepare_menu()

void btl_state_update_prepare_menu ( void )

Definition at line 4 of file prepare_menu.c.

4 {
6
8 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH] = -1;
9 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS] = -1;
10 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = -1;
11 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_PARTNER] = -1;
12 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER] = -1;
13 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY] = -1;
14 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY] = -1;
15 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER] = -1;
16 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] = -1;
17
19
25 } else {
27 }
28}
@ BATTLE_STATE_PLAYER_MENU
Definition enums.h:3677
@ BATTLE_STATE_PARTNER_MENU
Definition enums.h:3678
@ BTL_MENU_IDX_PARTNER
Definition enums.h:3816
@ BTL_MENU_IDX_STRATEGY
Definition enums.h:3818
@ BTL_MENU_IDX_SMASH
Definition enums.h:3813
@ BTL_MENU_IDX_STAR_POWER
Definition enums.h:3817
@ BTL_MENU_IDX_JUMP
Definition enums.h:3812
@ BTL_MENU_IDX_DIP
Definition enums.h:3815
@ BTL_MENU_IDX_ABILITY
Definition enums.h:3820
@ BTL_MENU_IDX_ITEMS
Definition enums.h:3814
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:538
s8 lastPlayerMenuSelection[16]

Referenced by btl_update().

◆ btl_state_draw_prepare_menu()

void btl_state_draw_prepare_menu ( void )

Definition at line 30 of file prepare_menu.c.

30 {
31}

Referenced by btl_draw_ui().

◆ btl_state_update_end_turn()

void btl_state_update_end_turn ( void )

Definition at line 13 of file turn_end.c.

13 {
16 Actor* player = battleStatus->playerActor;
17 Actor* partner = battleStatus->partnerActor;
18 Actor* actor;
19 Evt* script;
20 s32 i;
21
23 s32 cond = FALSE;
24
25 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
26 actor = battleStatus->enemyActors[i];
27 if (actor != NULL && actor->handleEventScript != NULL) {
29 cond = TRUE;
30 } else {
31 actor->handleEventScript = NULL;
32 }
33 }
34 }
35
36 if (!cond) {
37 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
38 actor = battleStatus->enemyActors[i];
39 if (actor != NULL && actor->takeTurnScript != NULL) {
41 cond = TRUE;
42 } else {
43 actor->takeTurnScript = NULL;
44 }
45 }
46 }
47
48 if (!cond) {
51 }
52 }
53 }
54
60 } else {
65 partner->state.curPos.x = partner->homePos.x;
66 partner->state.curPos.z = partner->homePos.z;
67 partner->state.goalPos.x = player->homePos.x;
68 partner->state.goalPos.z = player->homePos.z;
69 partner->state.moveTime = 4;
70 partner->state.angle = 0.0f;
72 }
73 }
74
76 if (partner->state.moveTime != 0) {
77 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
78 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
79 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
80 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
81 }
82 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
83 partner->yaw = clamp_angle(partner->state.angle);
84 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
85 player->yaw = clamp_angle(partner->state.angle);
86 partner->state.angle += 90.0f;
87 if (partner->state.moveTime != 0) {
88 partner->state.moveTime--;
89 } else {
90 partner->curPos.x = partner->state.goalPos.x;
91 partner->curPos.z = partner->state.goalPos.z;
92 player->curPos.x = partner->state.curPos.x;
93 player->curPos.z = partner->state.curPos.z;
94 partner->homePos.x = partner->curPos.x;
95 partner->homePos.z = partner->curPos.z;
96 player->homePos.x = player->curPos.x;
97 player->homePos.z = player->curPos.z;
102 } else {
104 }
106 }
107 }
108
111 player->disableDismissTimer = 0;
113 if (partner != NULL) {
115 partner->disableDismissTimer = 0;
116 }
117
120 playerData->starPower += SP_PER_SEG;
121 if (playerData->starPower > playerData->maxStarPower * SP_PER_BAR) {
122 playerData->starPower = playerData->maxStarPower * SP_PER_BAR;
123 }
124
125 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
126 actor = battleStatus->enemyActors[i];
127 if (actor != NULL && actor->handlePhaseSource != NULL) {
128 battleStatus->battlePhase = PHASE_ENEMY_END;
130 actor->handlePhaseScript = script;
131 actor->handlePhaseScriptID = script->id;
132 script->owner1.enemyID = i | ACTOR_ENEMY0;
133 }
134 }
135
136 if (partner != NULL && partner->handlePhaseSource != NULL) {
137 battleStatus->battlePhase = PHASE_ENEMY_END;
138 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
139 partner->handlePhaseScript = script;
140 partner->handlePhaseScriptID = script->id;
141 script->owner1.actorID = ACTOR_PARTNER;
142 }
144 }
145
146 // wait for all end turn scripts to finish executing
149
150 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
151 actor = battleStatus->enemyActors[i];
152 if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handlePhaseScriptID)) {
154 }
155 }
156
157 if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handlePhaseScriptID)) {
159 }
160
161 if (!waitingForScript) {
164 }
165 }
166
167 // proceed to next turn
168 switch (gBattleSubState) {
172 break;
173 }
174}
@ PHASE_ENEMY_END
Definition enums.h:2100
void btl_set_player_idle_anims(void)
#define SP_PER_SEG
Definition macros.h:103
#define SP_PER_BAR
Definition macros.h:102
@ BTL_SUBSTATE_CHECK_FOR_SWAP
Definition turn_end.c:5
@ BTL_SUBSTATE_BEGIN_NEXT
Definition turn_end.c:7
@ BTL_SUBSTATE_PERFORM_SWAP
Definition turn_end.c:9
@ BTL_SUBSTATE_AWAIT_SCRIPTS
Definition turn_end.c:6
@ BTL_SUBSTATE_START_SCRIPTS
Definition turn_end.c:10
@ BTL_SUBSTATE_UNUSED_4
Definition turn_end.c:8

Referenced by btl_update().

◆ btl_state_draw_end_turn()

void btl_state_draw_end_turn ( void )

Definition at line 176 of file turn_end.c.

176 {
177}

Referenced by btl_draw_ui().

◆ btl_state_update_victory()

void btl_state_update_victory ( void )

Definition at line 16 of file victory.c.

16 {
18 Actor* player = battleStatus->playerActor;
19 Actor* partner = battleStatus->partnerActor;
20 Evt* script;
21
22 switch (gBattleSubState) {
25 if (partner != NULL) {
27 }
28
29 battleStatus->stateFreezeCount = 0;
30 if (battleStatus->outtaSightActive == 0) {
32 } else {
33 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
34 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
35 partner->handlePhaseScript = script;
36 partner->handlePhaseScriptID = script->id;
37 script->owner1.actorID = ACTOR_PARTNER;
39 }
40
41 break;
43 if (!does_script_exist(partner->handlePhaseScriptID)) {
44 battleStatus->outtaSightActive = 0;
46 }
47 break;
48 }
49
50 switch (gBattleSubState) {
53 if (partner != NULL) {
55 }
61
63 if (player->koStatus == STATUS_KEY_KO) {
66 }
67 player->debuff = 0;
68 player->staticStatus = 0;
69 player->stoneStatus = 0;
70 player->transparentStatus = 0;
71 player->koStatus = 0;
72 player->koDuration = 0;
74
75 if (partner != NULL) {
76 if (partner->koStatus == STATUS_KEY_KO) {
79 }
80 partner->debuff = 0;
81 partner->staticStatus = 0;
82 partner->stoneStatus = 0;
83 partner->transparentStatus = 0;
84 partner->koStatus = 0;
85 partner->koDuration = 0;
86 partner->disableEffect->data.disableX->koDuration = 0;
87 }
88 break;
91 break;
92 }
93 player->handleEventScript = NULL;
94
95 if (partner != NULL) {
96 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
97 break;
98 }
99 partner->handleEventScript = NULL;
100 }
102 break;
103 }
104
108 } else {
109 partner->state.curPos.x = partner->curPos.x;
110 partner->state.curPos.z = partner->curPos.z;
111 partner->state.goalPos.x = player->curPos.x;
112 partner->state.goalPos.z = player->curPos.z;
113 partner->state.moveTime = 4;
114 partner->state.angle = 0.0f;
116 }
117 }
118
120 if (partner->state.moveTime != 0) {
121 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
122 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
123 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
124 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
125 }
126 partner->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
127 partner->yaw = clamp_angle(-partner->state.angle);
128 player->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
129 player->yaw = clamp_angle(-partner->state.angle);
130 partner->state.angle += 90.0f;
131
132 if (partner->state.moveTime != 0) {
133 partner->state.moveTime--;
134 } else {
135 partner->curPos.x = partner->state.goalPos.x;
136 partner->curPos.z = partner->state.goalPos.z;
137 player->curPos.x = partner->state.curPos.x;
138 player->curPos.z = partner->state.curPos.z;
139 partner->homePos.x = partner->curPos.x;
140 partner->homePos.z = partner->curPos.z;
141 player->homePos.x = player->curPos.x;
142 player->homePos.z = player->curPos.z;
145 }
146 }
147
150 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_EXP_BOOST) {
151 if (battleStatus->totalStarPoints == 0) {
152 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
155 } else {
158 player->takeTurnScript = script;
159 player->takeTurnScriptID = script->id;
160 script->owner1.actorID = ACTOR_PLAYER;
161 }
162 }
166 }
167
169 if (BattleSubstateDelay != 0) {
171 } else {
172 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
173 player->takeTurnScript = NULL;
174 if (battleStatus->nextMerleeSpellType != MERLEE_SPELL_EXP_BOOST) {
176 } else {
177 battleStatus->incrementStarPointDelay = 20;
178 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
180 battleStatus->pendingStarPoints = battleStatus->totalStarPoints
181 + battleStatus->pendingStarPoints + battleStatus->pendingStarPoints;
182 }
183 }
184 }
185 }
186
188 if (battleStatus->pendingStarPoints <= 0) {
191 }
192 if (gPlayerData.battlesWon < 9999) {
194 }
197 } else {
199 }
202 bgm_set_song(0, -1, 0, 1500, 8);
203 }
205 } else {
207 }
208 }
209 }
210}
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
@ MERLEE_SPELL_EXP_BOOST
Definition enums.h:1939
@ BS_FLAGS1_DISABLE_CELEBRATION
Definition enums.h:3619
@ BS_FLAGS1_BATTLE_FLED
Definition enums.h:3620
@ BS_FLAGS1_STAR_POINTS_DROPPED
Definition enums.h:3626
@ PHASE_MERLEE_EXP_BONUS
Definition enums.h:2105
@ BS_FLAGS2_DONT_STOP_MUSIC
Definition enums.h:3652
@ BATTLE_STATE_CELEBRATION
Definition enums.h:3695
@ BATTLE_STATE_END_BATTLE
Definition enums.h:3694
@ OUTCOME_ENEMY_FLED
Definition enums.h:1931
@ OUTCOME_PLAYER_WON
Definition enums.h:1928
void dispatch_event_player(s32)
Definition dmg_player.c:131
s8 battleOutcome
Definition npc.h:372
@ BTL_SUBSTATE_AWAIT_SWAP
Definition victory.c:13
@ BTL_SUBSTATE_AWAIT_OUTTA_SIGHT
Definition victory.c:6
@ BTL_SUBSTATE_CHECK_MERLEE
Definition victory.c:7
@ BTL_SUBSTATE_CHECK_OUTTA_SIGHT
Definition victory.c:5
@ BTL_SUBSTATE_AWAIT_MERLEE
Definition victory.c:8
@ BTL_SUBSTATE_AWAIT_RECOVER_KO
Definition victory.c:11
@ BTL_SUBSTATE_RECOVER_STATUS
Definition victory.c:10
@ BTL_SUBSTATE_DONE
Definition victory.c:9
@ BTL_SUBSTATE_CHECK_SWAP
Definition victory.c:12

Referenced by btl_update().

◆ btl_state_draw_victory()

void btl_state_draw_victory ( void )

Definition at line 212 of file victory.c.

212 {
213}

Referenced by btl_draw_ui().

◆ btl_state_update_end_training_battle()

void btl_state_update_end_training_battle ( void )

Definition at line 13 of file end_training.c.

13 {
19 Evt* script;
20
21 switch (gBattleSubState) {
24 if (partner != NULL) {
26 }
32
33 if (player->koStatus == STATUS_KEY_KO) {
36 }
37 player->debuff = 0;
38 player->staticStatus = 0;
39 player->stoneStatus = 0;
40 player->transparentStatus = 0;
41 player->koStatus = 0;
42 player->koDuration = 0;
44 if (partner != NULL) {
45 if (partner->koStatus == STATUS_KEY_KO) {
48 }
49 partner->debuff = 0;
50 partner->staticStatus = 0;
51 partner->stoneStatus = 0;
52 partner->transparentStatus = 0;
53 partner->koStatus = 0;
54 partner->koDuration = 0;
55 partner->disableEffect->data.disableX->koDuration = 0;
56 }
57 break;
60 break;
61 }
62 player->handleEventScript = NULL;
63
64 if (partner != NULL) {
65 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
66 break;
67 }
68 partner->handleEventScript = NULL;
69 }
70
72 break;
73 }
74
75 switch (gBattleSubState) {
77 battleStatus->stateFreezeCount = 0;
82
83 if (!battleStatus->outtaSightActive) {
85 } else {
86 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
87 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
88 partner->handlePhaseScript = script;
89 partner->handlePhaseScriptID = script->id;
90 script->owner1.actorID = ACTOR_PARTNER;
92 }
93 break;
95 if (!does_script_exist(partner->handlePhaseScriptID)) {
96 battleStatus->outtaSightActive = FALSE;
98 }
99 break;
100 }
101
102 switch (gBattleSubState) {
107 break;
109 if (BattleSubstateDelay != 0) {
111 return;
112 }
113 if (playerData->trainingsDone < 9999) {
114 playerData->trainingsDone++;
115 }
116 encounterStatus->battleOutcome = OUTCOME_ENEMY_FLED;
118 bgm_set_song(0, -1, 0, 1500, 8);
119 }
121 break;
122 }
123}
@ BTL_SUBSTATE_AWAIT_OUTTA_SIGHT
Definition end_training.c:8
@ BTL_SUBSTATE_AWAIT_RECOVERING
Definition end_training.c:6
@ BTL_SUBSTATE_RESET_CAM
Definition end_training.c:9
@ BTL_SUBSTATE_CHECK_OUTTA_SIGHT
Definition end_training.c:7
@ BTL_SUBSTATE_DONE

Referenced by btl_update().

◆ btl_state_draw_end_training_battle()

void btl_state_draw_end_training_battle ( void )

Definition at line 125 of file end_training.c.

125 {
126}

Referenced by btl_draw_ui().

◆ btl_state_update_end_battle()

void btl_state_update_end_battle ( void )

Definition at line 15 of file end_battle.c.

15 {
19 Stage* stage;
20 Evt* script;
21 s32 i;
22
23 switch (gBattleSubState) {
28 }
34 }
36 break;
38 if (BattleScreenFadeAmt == 255) {
40 break;
41 }
42 BattleScreenFadeAmt += battleStatus->endBattleFadeOutRate;
43 if (BattleScreenFadeAmt > 255) {
45 }
46 break;
50 if (gCurrentStagePtr == NULL) {
51 stage = battle->stage;
52 } else {
53 stage = gCurrentStagePtr->stage;
54 }
55 if (stage->postBattle == NULL) {
57 return;
58 }
60 battleStatus->controlScript = script;
61 battleStatus->controlScriptID = script->id;
63 break;
65 if (does_script_exist(battleStatus->controlScriptID)) {
66 break;
67 }
69 // fallthrough
72 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
73 if (battleStatus->enemyActors[i] != NULL) {
74 btl_delete_actor(battleStatus->enemyActors[i]);
75 }
76 }
77 if (battleStatus->partnerActor != NULL) {
78 btl_delete_actor(battleStatus->partnerActor);
79 }
80
82
83 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_COIN_BOOST) {
84 encounterStatus->hasMerleeCoinBonus = TRUE;
85 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
86 }
87
88 encounterStatus->damageTaken = battleStatus->damageTaken;
89
91 encounterStatus->dropWhackaBump = TRUE;
92 }
93
96
99 }
100
101 if (encounterStatus->battleOutcome == OUTCOME_PLAYER_LOST &&
103 {
104 s16 areaID;
105 s16 mapID;
106
109 get_map_IDs_by_name_checked("gv_01", &areaID, &mapID);
110 gGameStatusPtr->areaID = areaID;
111 gGameStatusPtr->mapID = mapID;
114 } else {
117 func_8003E514(1);
119 }
120 break;
121 }
122}
@ BTL_SUBSTATE_FADE_OUT
Definition end_battle.c:9
@ BTL_SUBSTATE_EXEC_STAGE_SCRIPT
Definition end_battle.c:10
@ BTL_SUBSTATE_CLEANUP
Definition end_battle.c:12
@ BTL_SUBSTATE_AWAIT_STAGE_SCRIPT
Definition end_battle.c:11
StageListRow * gCurrentStagePtr
Definition battle.cpp:12
@ gv_01_ENTRY_0
Definition entrances.h:1286
@ MERLEE_SPELL_COIN_BOOST
Definition enums.h:1940
@ BS_FLAGS1_NO_GAME_OVER
Definition enums.h:3625
@ DEBUG_CONTACT_DIE_ON_TOUCH
Definition enums.h:3868
@ BS_FLAGS2_DROP_WHACKA_BUMP
Definition enums.h:3655
@ BTL_CAM_INTERRUPT
Definition enums.h:4408
@ OUTCOME_PLAYER_LOST
Definition enums.h:1929
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
void decrement_status_bar_disabled(void)
Definition inventory.c:1656
void remove_all_effects(void)
Definition effects.c:278
void set_screen_overlay_center(s32, s32, s32, s32)
void btl_delete_player_actor(Actor *player)
Definition 16C8E0.c:1107
void set_windows_visible(s32 groupIdx)
Definition windows.c:445
void btl_delete_actor(Actor *actor)
Definition 16C8E0.c:1041
void btl_cam_unfreeze(void)
Definition camera.c:2002
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
void func_8003E514(s8 arg0)
Definition npc.c:2264
EvtScript * postBattle
Definition battle.h:186
s32 gBattleState
Definition battle.cpp:13
s32 gLastDrawBattleState
Definition battle.cpp:15

Referenced by btl_update().

◆ btl_state_draw_end_battle()

void btl_state_draw_end_battle ( void )

◆ btl_state_update_defend()

void btl_state_update_defend ( void )

Definition at line 9 of file defend.c.

9 {
11 Evt* script;
12
13 switch (gBattleSubState) {
16
17 // prompt player to handle PHASE_USE_DEFEND
20 player->takeTurnScriptID = script->id;
21 script->owner1.actorID = ACTOR_PLAYER;
23 break;
25 // wait for PHASE_USE_DEFEND event to complete
27 break;
28 }
29
30 // done waiting for the script
32 break;
33 }
34}
@ BTL_SUBSTATE_AWAIT
Definition defend.c:6
@ PHASE_USE_DEFEND
Definition enums.h:2096
@ BATTLE_STATE_END_PLAYER_TURN
Definition enums.h:3686

Referenced by btl_update().

◆ btl_state_draw_defend()

void btl_state_draw_defend ( void )

Definition at line 36 of file defend.c.

36 {
37}

Referenced by btl_draw_ui().

◆ btl_state_update_run_away()

void btl_state_update_run_away ( void )

Definition at line 17 of file run_away.c.

17 {
21 Actor* player = battleStatus->playerActor;
22 Actor* partner = battleStatus->partnerActor;
23 Actor* enemy;
26 Evt* script;
27 s32 i;
28
29 switch (gBattleSubState) {
31 battleStatus->stateFreezeCount = 0;
37
38 playerData->fleeAttempts++;
41
42 // calculate average escape chance
43 enemyCount = 0;
44 totalEscapeChance = 0.0f;
45
46 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
47 enemy = battleStatus->enemyActors[i];
48 if (enemy != NULL) {
49 if (!(enemy->flags & ACTOR_FLAG_TARGET_ONLY)) {
50 if (!(enemy->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
51 f32 escapeChance = enemy->actorBlueprint->escapeChance;
52
53 if (enemy->debuff == STATUS_KEY_UNUSED ||
54 enemy->debuff == STATUS_KEY_DIZZY ||
55 enemy->debuff == STATUS_KEY_PARALYZE ||
56 enemy->debuff == STATUS_KEY_SLEEP ||
57 enemy->debuff == STATUS_KEY_FROZEN ||
58 enemy->debuff == STATUS_KEY_STOP)
59 {
60 escapeChance = 100.0f;
61 }
62 totalEscapeChance += escapeChance;
63 enemyCount++;
64 }
65 }
66 }
67 }
68 player->state.varTable[0] = totalEscapeChance / enemyCount;
69
71 player->state.varTable[0] = 100;
72 }
73
76 player->takeTurnScript = script;
77 player->takeTurnScriptID = script->id;
78 script->owner1.actorID = ACTOR_PLAYER;
79 if (partner != NULL && partner->koStatus == 0) {
80 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
81 partner->takeTurnScript = script;
82 partner->takeTurnScriptID = script->id;
83 script->owner1.actorID = ACTOR_PARTNER;
84 }
86 break;
88 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
89 break;
90 }
93 } else {
97 } else {
101 // divide reward into 20 increments
102 RunAwayRewardTotal = battleStatus->totalStarPoints * 100;
106 }
107 }
108 break;
109 }
110
112 if (battleStatus->totalStarPoints != 0) {
113 s32 deltaSP;
114 s32 prevSP;
115
117 prevSP = battleStatus->totalStarPoints;
118 battleStatus->totalStarPoints = RunAwayRewardTotal / 100;
119 deltaSP = prevSP - battleStatus->totalStarPoints;
120
121 if (deltaSP > 0) {
123 }
124 playerData->starPoints += deltaSP;
126 if (RunAwayRewardStep == 0 && battleStatus->totalStarPoints != 0) {
127 playerData->starPoints++;
128 }
129 }
130 if (playerData->starPoints >= 99) {
131 playerData->starPoints = 99;
132 }
133 if (battleStatus->totalStarPoints == 0) {
134 if (RunAwayRewardStep != 0) {
136 } else {
140 }
141 }
142 }
143
145 playerData->battlesFled++;
147 bgm_set_song(0, -1, 0, 1500, 8);
148 }
150 }
151
152 switch (gBattleSubState) {
154 battleStatus->battlePhase = PHASE_RUN_AWAY_FAIL;
156 player->takeTurnScript = script;
157 player->takeTurnScriptID = script->id;
158 script->owner1.actorID = ACTOR_PLAYER;
159 if (partner != NULL && partner->koStatus == 0) {
160 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
161 partner->takeTurnScript = script;
162 partner->takeTurnScriptID = script->id;
163 script->owner1.actorID = ACTOR_PARTNER;
164 }
166 break;
168 if (BattleSubstateDelay != 0) {
170 return;
171 }
173 && (partner == NULL || !does_script_exist(partner->takeTurnScriptID))
174 && battleStatus->stateFreezeCount == 0
175 ) {
177 }
178 break;
179 }
180}
struct ActorBlueprint * actorBlueprint
ActorState state
@ PHASE_RUN_AWAY_START
Definition enums.h:2093
@ PHASE_RUN_AWAY_FAIL
Definition enums.h:2097
@ BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER
Definition enums.h:3641
@ BTL_CAM_PLAYER_FLEE
Definition enums.h:4432
@ ABILITY_RUNAWAY_PAY
Definition enums.h:459
@ SOUND_COIN_PICKUP
Definition enums.h:925
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3368
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3374
@ OUTCOME_PLAYER_FLED
Definition enums.h:1930
void btl_start_blinking_starpoints(void)
Definition 16C8E0.c:97
void btl_stop_blinking_starpoints(void)
Definition 16C8E0.c:102
void status_bar_stop_blinking_starpoints(void)
Definition inventory.c:1647
void btl_cam_target_actor(s32)
Definition camera.c:1926
void status_bar_start_blinking_starpoints(void)
Definition inventory.c:1638
void sfx_play_sound(s32 soundID)
BSS s32 RunAwayRewardStep
Definition run_away.c:13
BSS s32 RunAwayRewardIncrement
Definition run_away.c:15
@ BTL_SUBSTATE_EXEC_POST_FAILURE
Definition run_away.c:7
@ BTL_SUBSTATE_GIVE_STAR_POINTS
Definition run_away.c:9
@ BTL_SUBSTATE_AWAIT_SCRIPT
Definition run_away.c:6
@ BTL_SUBSTATE_AWAIT_POST_FAILURE
Definition run_away.c:8
@ BTL_SUBSTATE_EXEC_SCRIPT
Definition run_away.c:5
@ BTL_SUBSTATE_DONE
Definition run_away.c:10
BSS s32 RunAwayRewardTotal
Definition run_away.c:14

Referenced by btl_update().

◆ btl_state_draw_run_away()

void btl_state_draw_run_away ( void )

Definition at line 182 of file run_away.c.

182 {
183}

Referenced by btl_draw_ui().

◆ btl_state_update_defeat()

void btl_state_update_defeat ( void )

Definition at line 11 of file defeat.c.

11 {
13 Actor* player = battleStatus->playerActor;
14 Actor* partner = battleStatus->partnerActor;
15 Evt* script;
16
17 switch (gBattleSubState) {
24 battleStatus->stateFreezeCount = 0;
25
26 // clear player debuffs
27 if (player->debuff != 0) {
28 if (player->debuff == STATUS_KEY_FROZEN) {
31 player->icePillarEffect = NULL;
32 }
33 player->debuff = 0;
34 player->debuffDuration = 0;
36 player->koStatus = 0;
37 player->koDuration = 0;
39 }
40
43
44 // prompt player to handle PHASE_DEATH
45 battleStatus->battlePhase = PHASE_DEATH;
47 player->takeTurnScript = script;
48 player->takeTurnScriptID = script->id;
49 script->owner1.actorID = ACTOR_PLAYER;
50
51 // prompt partner to handle PHASE_DEATH
52 if (partner != NULL) {
53 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
54 partner->takeTurnScript = script;
55 partner->takeTurnScriptID = script->id;
56 script->owner1.actorID = ACTOR_PARTNER;
57 }
59 break;
61 // wait for player PHASE_DEATH event to complete (ignore partner script)
62 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
63 break;
64 }
65 if (find_item(ITEM_LIFE_SHROOM) >= 0) {
66 // prompt player to handle PHASE_USE_LIFE_SHROOM
69 player->takeTurnScript = script;
70 player->takeTurnScriptID = script->id;
71 script->owner1.actorID = ACTOR_PLAYER;
73 } else {
75 }
76 break;
78 // wait for player PHASE_USE_LIFE_SHROOM event to complete
79 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
80 break;
81 }
82 // never reached if life shroom is successful. its item script calls RestorePreDefeatState,
83 // resetting the state to BATTLE_STATE_ENEMY_MOVE (based on the value of gDefeatedBattleState)
85 break;
86 }
87
91 bgm_set_song(0, -1, 0, 1500, 8);
92 }
94 }
95}
struct EffectInstance * icePillarEffect
@ BTL_SUBSTATE_CHECK_LIFE_SHROOM
Definition defeat.c:6
@ BTL_SUBSTATE_AWAIT_LIFE_SHROOM
Definition defeat.c:7
@ BTL_SUBSTATE_DONE
Definition defeat.c:8
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3551
@ PHASE_USE_LIFE_SHROOM
Definition enums.h:2098
@ PHASE_DEATH
Definition enums.h:2094
@ SOUND_FROZEN_SHATTER
Definition enums.h:725
s32 find_item(s32)
Search player inventory for itemID and return first matching array index.
Definition inventory.c:263

Referenced by btl_update().

◆ btl_state_draw_defeat()

void btl_state_draw_defeat ( void )

Definition at line 97 of file defeat.c.

97 {
98}

Referenced by btl_draw_ui().

◆ btl_state_update_change_partner()

void btl_state_update_change_partner ( void )

Definition at line 66 of file change_partner.c.

66 {
68 Actor* player = battleStatus->playerActor;
69 Actor* partner = battleStatus->partnerActor;
71 Evt* script;
72 s32 i;
73
74 switch (gBattleSubState) {
78 battleStatus->stateFreezeCount = 0;
81 btl_cam_set_target_pos(-89.0, 40.0, -99.0);
85
86 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
87 enemyActor = battleStatus->enemyActors[i];
88 if (enemyActor != NULL) {
91 }
92 }
93
94 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] = -1;
97
98 // fallthrough
100 if (BattleSubstateDelay != 0) {
102 break;
103 }
106 battleStatus->controlScript = script;
107 battleStatus->controlScriptID = script->id;
108 script->owner1.actorID = ACTOR_PARTNER;
109 player->state.unk_18.x = partner->curPos.x;
110 player->state.unk_18.y = 0.0f;
111 player->state.unk_18.z = partner->curPos.z;
113 break;
115 if (does_script_exist(battleStatus->controlScriptID)) {
116 break;
117 }
119 gPlayerData.curPartner = battleStatus->lastSelectedPartner;
121 partner = battleStatus->partnerActor;
122 partner->scale.x = 0.1f;
123 partner->scale.y = 0.1f;
124 partner->scale.z = 0.1f;
125 partner->state.goalPos.x = player->state.unk_18.x;
126 partner->state.goalPos.y = partner->curPos.y;
127 partner->state.goalPos.z = player->state.unk_18.z;
128 partner->curPos.x = player->curPos.x;
129 partner->curPos.y = player->curPos.y + 25.0f;
130 partner->curPos.z = player->curPos.z;
132 break;
134 partner = battleStatus->partnerActor;
135 if (partner != NULL) {
136 if (does_script_exist(partner->takeTurnScriptID)) {
137 break;
138 }
139 partner->takeTurnScript = NULL;
140 }
141
143 battleStatus->controlScript = script;
144 battleStatus->controlScriptID = script->id;
145 script->owner1.actorID = ACTOR_PARTNER;
147 break;
149 if (does_script_exist(battleStatus->controlScriptID)) {
150 break;
151 }
152 partner = battleStatus->partnerActor;
153 if (partner != NULL) {
154 if (partner->handlePhaseSource != NULL) {
155 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
156 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
157 partner->handlePhaseScript = script;
158 partner->handlePhaseScriptID = script->id;
159 script->owner1.actorID = ACTOR_PARTNER;
160 }
161 }
163 break;
165 partner = battleStatus->partnerActor;
166 if (partner != NULL) {
167 if (partner->handlePhaseSource != NULL && does_script_exist(partner->handlePhaseScriptID)) {
168 break;
169 }
170 }
173 break;
175 if (battleStatus->stateFreezeCount != 0) {
176 break;
177 }
182 } else {
184 }
185 } else {
188 } else {
190 }
191 }
192 break;
193 }
194}
EvtScript EVS_BtlPutPartnerAway
@ BTL_SUBSTATE_LOAD_NEW_PARTNER
@ BTL_SUBSTATE_EXEC_PUT_AWAY
@ BTL_SUBSTATE_AWAIT_PHASE
@ BTL_SUBSTATE_DONE
@ BTL_SUBSTATE_EXEC_PHASE
@ BTL_SUBSTATE_EXEC_BRING_OUT
EvtScript EVS_BtlBringPartnerOut
@ BTL_CAM_REPOSITION
Definition enums.h:4426
@ BATTLE_STATE_END_PARTNER_TURN
Definition enums.h:3687
@ ABILITY_QUICK_CHANGE
Definition enums.h:462
@ BTL_MENU_IDX_MAIN
Definition enums.h:3811
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2497
void btl_cam_set_zoom(s16)
Definition camera.c:1984
void btl_cam_set_target_pos(f32, f32, f32)
Definition camera.c:1962
void btl_cam_set_zoffset(s16)
Definition camera.c:1996
void deduct_current_move_fp(void)
Definition 190B20.c:693

Referenced by btl_update().

◆ btl_state_draw_change_partner()

void btl_state_draw_change_partner ( void )

Definition at line 196 of file change_partner.c.

196 {
197}

Referenced by btl_draw_ui().

◆ btl_state_update_player_move()

void btl_state_update_player_move ( void )

Definition at line 19 of file player_move.c.

19 {
21 Actor* player = battleStatus->playerActor;
22 Actor* partner = battleStatus->partnerActor;
23 s32 messageIndex;
24 Actor* actor;
25 Evt* script;
28 s32 i;
29
31 battleStatus->stateFreezeCount = 0;
32 battleStatus->actionResult = ACTION_RESULT_NONE;
33 battleStatus->blockResult = BLOCK_RESULT_NONE;
34 battleStatus->lastAttackDamage = 0;
35 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
40 if (partner != NULL) {
42 }
45 player->statusAfflicted = 0;
48
49 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
50 actor = battleStatus->enemyActors[i];
51 if (actor != NULL) {
52 actor->statusAfflicted = 0;
53 }
54 }
55
56 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
57 actor = battleStatus->enemyActors[i];
58 if (actor != NULL) {
61 }
62 }
63
64 if (battleStatus->moveCategory == BTL_MENU_TYPE_JUMP || battleStatus->moveCategory == BTL_MENU_TYPE_SMASH) {
65 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_ATK_BOOST) {
66 battleStatus->merleeAttackBoost = 3;
67 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
70 player->takeTurnScript = script;
71 player->takeTurnScriptID = script->id;
72 script->owner1.actorID = ACTOR_PLAYER;
76 } else {
79 }
80 } else {
83 }
84 }
85
86 switch (gBattleSubState) {
88 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
89 break;
90 }
91 player->takeTurnScript = NULL;
93 if (battleStatus->selectedMoveID != MOVE_NONE) {
94 tipIndex = gMoveTable[battleStatus->selectedMoveID].actionTip;
95 if (tipIndex >= 0) {
97 }
98 }
99 }
102 break;
104 if (BattleSubstateDelay != 0) {
106 } else {
108 }
109 break;
110 }
111
112 switch (gBattleSubState) {
119 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
122 } else {
124 }
125 player->takeTurnScript = script;
127 player->takeTurnScriptID = script->id;
128 script->owner1.actorID = ACTOR_PLAYER;
129 break;
131 // wait for player battle phase script to finish
133 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
134 break;
135 }
136 player->takeTurnScript = NULL;
137 }
138
140
141 // wait for player battle event script to finish
142 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
143 break;
144 }
145 player->handleEventScript = NULL;
146
147 // wait for partner battle event script to finish
148 if (partner != NULL) {
149 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
150 break;
151 }
152 partner->handleEventScript = NULL;
153 }
154
155 // wait for all enemy battle phase scripts to finish
157 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
158 actor = battleStatus->enemyActors[i];
159 if (actor != NULL && actor->takeTurnScript != NULL) {
162 } else {
163 actor->takeTurnScript = NULL;
164 }
165 }
166 }
167 if (enemyNotDone) {
168 break;
169 }
170
171 // wait for all enemy battle event scripts to finish
173 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
174 actor = battleStatus->enemyActors[i];
175 if (actor != NULL && actor->handleEventScript != NULL) {
178 } else {
179 actor->handleEventScript = NULL;
180 }
181 }
182 }
183 if (enemyNotDone) {
184 break;
185 }
186
187 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
188 actor = battleStatus->enemyActors[i];
189 if (actor != NULL) {
191 }
192 }
193
194 if (battleStatus->stateFreezeCount != 0) {
195 break;
196 }
197
200 break;
201 }
202
207 return;
208 }
209
210 if ((battleStatus->moveCategory == BTL_MENU_TYPE_SMASH)
211 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE0)
212 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE)
213 && (battleStatus->selectedMoveID != MOVE_SUPER_SMASH_CHARGE)
214 ) {
216 }
217
218 if ((battleStatus->moveCategory == BTL_MENU_TYPE_JUMP)
219 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE0)
220 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE)
221 && (battleStatus->selectedMoveID != MOVE_SUPER_JUMP_CHARGE)
222 ) {
224 }
225
227 battleStatus->jumpCharge = 0;
228 }
230 battleStatus->hammerCharge = 0;
231 }
232
233 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
234 actor = battleStatus->enemyActors[i];
235 if (actor != NULL && !(actor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
237 }
238 }
239
241
243 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
244 actor = battleStatus->enemyActors[i];
245 if (actor != NULL) {
246 if (actor->statusAfflicted != 0) {
248 break;
249 }
250 }
251 }
252
253 if (!enemyNotDone) {
255 } else {
257 switch (actor->statusAfflicted) {
258 case STATUS_KEY_DIZZY:
259 messageIndex = BTL_MSG_ENEMY_DAZED;
260 break;
261 case STATUS_KEY_SLEEP:
262 messageIndex = BTL_MSG_ENEMY_ASLEEP;
263 break;
265 messageIndex = BTL_MSG_ENEMY_FROZEN;
266 break;
268 messageIndex = BTL_MSG_ENEMY_POISONED;
269 break;
271 messageIndex = BTL_MSG_ENEMY_SHRUNK;
272 break;
274 messageIndex = BTL_MSG_ENEMY_PARALYZED;
275 break;
277 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
278 break;
279 case STATUS_KEY_STOP:
280 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
281 break;
282 default:
283 messageIndex = 0;
285 break;
286 }
288 btl_show_battle_message(messageIndex, 60);
289 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
290 actor = battleStatus->enemyActors[i];
291 if (actor != NULL) {
292 actor->statusAfflicted = 0;
293 }
294 }
296 }
297 break;
299 if (!btl_is_popup_displayed()) {
301 btl_cam_move(15);
304 }
305 break;
307 if (BattleSubstateDelay != 0) {
309 } else {
311 }
312 break;
313 }
314
315 switch (gBattleSubState) {
317 if (player->statusAfflicted != 0) {
319 switch (player->statusAfflicted) {
320 case STATUS_KEY_DIZZY:
321 messageIndex = BTL_MSG_PLAYER_DAZED;
322 break;
323 case STATUS_KEY_SLEEP:
324 messageIndex = BTL_MSG_PLAYER_ASLEEP;
325 break;
327 messageIndex = BTL_MSG_PLAYER_FROZEN;
328 break;
330 messageIndex = BTL_MSG_PLAYER_POISONED;
331 break;
333 messageIndex = BTL_MSG_PLAYER_SHRUNK;
334 break;
336 messageIndex = BTL_MSG_PLAYER_PARALYZED;
337 break;
339 messageIndex = BTL_MSG_PLAYER_CHARGED;
340 break;
341 default:
342 messageIndex = 0;
344 break;
345 }
346 btl_show_battle_message(messageIndex, 60);
347 player->statusAfflicted = 0;
348 player->disableDismissTimer = 0;
351
352 } else {
354 }
355 break;
357 if (!btl_is_popup_displayed()) {
359 btl_cam_move(15);
362 }
363 break;
365 if (BattleSubstateDelay != 0) {
367 } else {
369 }
370 break;
371 }
372
374 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
375 player->takeTurnScript = NULL;
377 }
378 }
379}
s8 statusAfflicted
@ MERLEE_SPELL_ATK_BOOST
Definition enums.h:1937
@ BS_FLAGS1_10000
Definition enums.h:3618
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3623
@ BS_FLAGS1_EXECUTING_MOVE
Definition enums.h:3611
@ BTL_MSG_PLAYER_FROZEN
Definition enums.h:3712
@ BTL_MSG_PLAYER_POISONED
Definition enums.h:3713
@ BTL_MSG_PLAYER_PARALYZED
Definition enums.h:3715
@ BTL_MSG_ENEMY_ASLEEP
Definition enums.h:3719
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:3716
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:3711
@ BTL_MSG_ENEMY_POISONED
Definition enums.h:3721
@ BTL_MSG_PLAYER_SHRUNK
Definition enums.h:3714
@ BTL_MSG_ENEMY_CANT_MOVE
Definition enums.h:3725
@ BTL_MSG_ENEMY_PARALYZED
Definition enums.h:3723
@ BTL_MSG_ENEMY_FROZEN
Definition enums.h:3720
@ BTL_MSG_ENEMY_DAZED
Definition enums.h:3718
@ BTL_MSG_FIRST_ACTION_TIP
Definition enums.h:3746
@ BTL_MSG_ENEMY_ELECTRIFIED
Definition enums.h:3724
@ BTL_MSG_ENEMY_SHRUNK
Definition enums.h:3722
@ BTL_MSG_PLAYER_DAZED
Definition enums.h:3710
@ PHASE_MERLEE_ATTACK_BONUS
Definition enums.h:2103
@ PHASE_EXECUTE_ACTION
Definition enums.h:2091
@ BTL_MENU_TYPE_SMASH
Definition enums.h:3827
@ BTL_MENU_TYPE_JUMP
Definition enums.h:3826
@ STATUS_KEY_STATIC
Definition enums.h:2812
@ STATUS_KEY_SHRINK
Definition enums.h:2811
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4410
@ BTL_CAM_PLAYER_STATUS_AFFLICTED
Definition enums.h:4440
@ BATTLE_STATE_END_DEMO_BATTLE
Definition enums.h:3696
@ DMG_SRC_DEFAULT
Definition enums.h:2014
@ ABILITY_BERSERKER
Definition enums.h:457
@ SOUND_INFLICT_KO
Definition enums.h:1548
void reset_all_actor_sounds(Actor *)
Definition 190B20.c:2670
void btl_update_ko_status(void)
Definition 190B20.c:2601
void close_action_command_instruction_popup(void)
void btl_show_battle_message(s32 messageIndex, s32 duration)
s32 btl_is_popup_displayed(void)
void increment_status_bar_disabled(void)
Definition inventory.c:1664
EvtScript EVS_Peach_HandlePhase
@ BTL_SUBSTATE_SHOW_TIP_DELAY
Definition player_move.c:8
@ BTL_SUBSTATE_BEGIN_SHOW_TIP
Definition player_move.c:7
@ BTL_SUBSTATE_POST_ENEMY_STATUS_POPUP
Definition player_move.c:12
@ BTL_SUBSTATE_AWAIT_PLAYER_STATUS_POPUP
Definition player_move.c:14
@ BTL_SUBSTATE_AWAIT_ENEMY_STATUS_POPUP
Definition player_move.c:11
@ BTL_SUBSTATE_POST_PLAYER_STATUS_POPUP
Definition player_move.c:15
@ BTL_SUBSTATE_EXECUTE_MOVE
Definition player_move.c:9
@ BTL_SUBSTATE_CHECK_PLAYER_STATUS
Definition player_move.c:13
@ BTL_SUBSTATE_AWAIT_DONE
Definition player_move.c:16
@ BTL_SUBSTATE_HANDLE_RESULTS
Definition player_move.c:10
MoveData gMoveTable[]

Referenced by btl_update().

◆ btl_state_draw_player_move()

void btl_state_draw_player_move ( void )

Definition at line 381 of file player_move.c.

381 {
382}

Referenced by btl_draw_ui().

◆ btl_state_update_end_player_turn()

void btl_state_update_end_player_turn ( void )

Definition at line 68 of file player_turn_end.c.

68 {
70 Actor* player = battleStatus->playerActor;
71 Actor* partner = battleStatus->partnerActor;
72 Evt* script;
73
77 }
78
80 // if a script is running from 'Happy!', wait for it to complete
81 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
82 return;
83 }
84 player->takeTurnScript = NULL;
85
86 // force peach to back position after turn end
88 player->state.curPos.x = player->homePos.x;
89 player->state.curPos.z = player->homePos.z;
90 player->state.goalPos.x = partner->homePos.x;
91 player->state.goalPos.z = partner->homePos.z;
92 player->state.moveTime = 4;
93 player->state.angle = 0.0f;
95 } else {
97 }
98 }
99
101 if (player->state.moveTime != 0) {
102 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
103 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
104 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
105 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
106 }
107 player->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
108 player->yaw = clamp_angle(-player->state.angle);
109 partner->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
110 partner->yaw = clamp_angle(-player->state.angle);
111 player->state.angle += 90.0f;
112
113 if (player->state.moveTime != 0) {
114 player->state.moveTime--;
115 } else {
116 player->curPos.x = player->state.goalPos.x;
117 player->curPos.z = player->state.goalPos.z;
118 partner->curPos.x = player->state.curPos.x;
119 partner->curPos.z = player->state.curPos.z;
120 player->homePos.x = player->curPos.x;
121 player->homePos.z = player->curPos.z;
122 partner->homePos.x = partner->curPos.x;
123 partner->homePos.z = partner->curPos.z;
126 }
127 }
128
130 // dont bother with command loss if all enemies are defeated
132 return;
133 }
134
135 if (battleStatus->moveCategory == BTL_MENU_TYPE_ITEMS && battleStatus->itemUsesLeft >= 2) {
137 btl_cam_move(10);
139 } else {
141 }
142
143 // if the rest of the turn was canceled, proceed immediately to END_TURN
144 if (battleStatus->cancelTurnMode < 0) {
145 battleStatus->cancelTurnMode = 0;
146 battleStatus->itemUsesLeft = 0;
148 return;
149 }
150
151 if (battleStatus->itemUsesLeft != 0) {
152 battleStatus->itemUsesLeft--;
153 if (battleStatus->itemUsesLeft != 0) {
154 // double or triple dip has not run out yet, let the player choose another item
157 return;
158 }
159
161 if (battleStatus->hustleTurns != 0) {
162 battleStatus->hustleTurns--;
163 }
164 }
165
166 if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) {
169 return;
170 } else {
173 return;
174 }
175 }
176
178 if (battleStatus->hustleTurns != 0) {
179 battleStatus->hustleTurns--;
180 }
181 }
182
183 if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) {
186 } else {
190 } else {
192 }
193 }
194 }
195}
@ BTL_MENU_TYPE_ITEMS
Definition enums.h:3828
@ BATTLE_STATE_END_TURN
Definition enums.h:3670
@ BTL_SUBSTATE_AWAIT_RECOVER
@ BTL_SUBSTATE_AWAIT_SWAP
@ BTL_SUBSTATE_DONE
void btl_substate_try_hpfp_recovery(void)

Referenced by btl_update().

◆ btl_state_update_partner_move()

void btl_state_update_partner_move ( void )

Definition at line 15 of file partner_move.c.

15 {
18 Actor* player = battleStatus->playerActor;
19 Actor* partner = battleStatus->partnerActor;
21 Evt* script;
23 s32 messageIndex;
24 s32 i;
25
26 switch (gBattleSubState) {
28 if (partner == NULL) {
30 break;
31 }
32 battleStatus->stateFreezeCount = 0;
33 battleStatus->actionResult = ACTION_RESULT_NONE;
34 battleStatus->blockResult = BLOCK_RESULT_NONE;
35 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
39 partner->statusAfflicted = 0;
46
47 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
48 enemyActor = battleStatus->enemyActors[i];
49 if (enemyActor != NULL) {
50 enemyActor->statusAfflicted = 0;
51 }
52 }
55 break;
57 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
58 enemyActor = battleStatus->enemyActors[i];
59 if (enemyActor != NULL) {
62 }
63 }
64
70 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
71 partner->takeTurnScript = script;
72 partner->takeTurnScriptID = script->id;
73 script->owner1.actorID = ACTOR_PARTNER;
75 break;
78 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
79 break;
80 }
81 partner->takeTurnScript = NULL;
82 }
84
85 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
86 break;
87 }
88 partner->handleEventScript = NULL;
89
91 break;
92 }
93 player->handleEventScript = NULL;
94
96 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
97 enemyActor = battleStatus->enemyActors[i];
98 if (enemyActor != NULL && enemyActor->takeTurnScript != NULL) {
99 if (does_script_exist(enemyActor->takeTurnScriptID)) {
101 } else {
102 enemyActor->takeTurnScript = NULL;
103 }
104 }
105 }
106 if (enemyFound) {
107 break;
108 }
109
111 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
112 enemyActor = battleStatus->enemyActors[i];
113 if (enemyActor != NULL && enemyActor->handleEventScript != NULL) {
114 if (does_script_exist(enemyActor->handleEventScriptID)) {
116 } else {
117 enemyActor->handleEventScript = NULL;
118 }
119 }
120 }
121 if (enemyFound) {
122 break;
123 }
124
125 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
126 enemyActor = battleStatus->enemyActors[i];
127 if (enemyActor != NULL) {
129 }
130 }
131
132 if (battleStatus->stateFreezeCount != 0) {
133 break;
134 }
135
138 break;
139 }
141 if (playerData->curPartner == PARTNER_GOOMBARIO
143 && battleStatus->selectedMoveID != MOVE_CHARGE) {
144 partner->isGlowing = FALSE;
146 }
148 return;
149 }
150
151 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
152 enemyActor = battleStatus->enemyActors[i];
153 if (enemyActor != NULL) {
154 if (!(enemyActor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
156 }
157 }
158 }
159
161
162 if (partner->statusAfflicted == STATUS_KEY_KO && !btl_are_all_enemies_defeated()) {
165 partner->statusAfflicted = 0;
166 partner->disableDismissTimer = 0;
169 } else {
171 }
172 break;
175 break;
176 }
178 btl_cam_move(15);
181 break;
183 if (BattleSubstateDelay != 0) {
185 } else {
187 }
188 break;
189 }
190
191 switch (gBattleSubState) {
194 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
195 enemyActor = battleStatus->enemyActors[i];
196 if (enemyActor != NULL) {
197 if (enemyActor->statusAfflicted != 0) {
199 break;
200 }
201 }
202 }
203 if (!enemyFound) {
205 break;
206 }
207
209 switch (enemyActor->statusAfflicted) {
210 case STATUS_KEY_DIZZY:
211 messageIndex = BTL_MSG_ENEMY_DAZED;
212 break;
213 case STATUS_KEY_SLEEP:
214 messageIndex = BTL_MSG_ENEMY_ASLEEP;
215 break;
217 messageIndex = BTL_MSG_ENEMY_FROZEN;
218 break;
220 messageIndex = BTL_MSG_ENEMY_POISONED;
221 break;
223 messageIndex = BTL_MSG_ENEMY_SHRUNK;
224 break;
226 messageIndex = BTL_MSG_ENEMY_PARALYZED;
227 break;
229 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
230 break;
231 case STATUS_KEY_STOP:
232 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
233 break;
234 default:
235 messageIndex = 0;
237 break;
238 }
239
241 btl_show_battle_message(messageIndex, 60);
242
243 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
244 enemyActor = battleStatus->enemyActors[i];
245 if (enemyActor != NULL) {
246 enemyActor->statusAfflicted = 0;
247 }
248 }
250 break;
252 if (btl_is_popup_displayed() == FALSE) {
254 btl_cam_move(15);
257 }
258 break;
260 if (BattleSubstateDelay != 0) {
262 } else {
264 }
265 break;
266 }
267
269 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
270 return;
271 }
272 partner->takeTurnScript = NULL;
274 }
275}
@ BTL_MSG_PARTNER_INJURED
Definition enums.h:3735
@ BTL_MENU_TYPE_CHANGE_PARTNER
Definition enums.h:3831
@ BTL_CAM_PARTNER_INJURED
Definition enums.h:4461
@ PARTNER_GOOMBARIO
Definition enums.h:2920
s32 btl_are_all_enemies_defeated(void)
Definition 190B20.c:636
@ BTL_SUBSTATE_POST_ENEMY_STATUS_POPUP
@ BTL_SUBSTATE_AWAIT_ENEMY_STATUS_POPUP
@ BTL_SUBSTATE_AWAIT_PARTNER_STATUS_POPUP
Definition partner_move.c:7
@ BTL_SUBSTATE_EXECUTE_MOVE
Definition partner_move.c:5
@ BTL_SUBSTATE_CHECK_ENEMY_STATUS
Definition partner_move.c:9
@ BTL_SUBSTATE_POST_PARTNER_STATUS_POPUP
Definition partner_move.c:8
@ BTL_SUBSTATE_HANDLE_RESULTS
Definition partner_move.c:6
@ BTL_SUBSTATE_DONE

Referenced by btl_update().

◆ btl_state_draw_end_player_turn()

void btl_state_draw_end_player_turn ( void )

Definition at line 197 of file player_turn_end.c.

197 {
198}

Referenced by btl_draw_ui().

◆ btl_state_draw_partner_move()

void btl_state_draw_partner_move ( void )

Definition at line 277 of file partner_move.c.

277 {
278}

Referenced by btl_draw_ui().

◆ btl_state_update_end_partner_turn()

void btl_state_update_end_partner_turn ( void )

Definition at line 3 of file partner_turn_end.c.

Referenced by btl_update().

◆ btl_state_draw_end_partner_turn()

void btl_state_draw_end_partner_turn ( void )

Definition at line 23 of file partner_turn_end.c.

23 {
24}

Referenced by btl_draw_ui().

◆ btl_state_update_next_enemy()

void btl_state_update_next_enemy ( void )

Definition at line 11 of file enemy_next.c.

11 {
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}
@ 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
@ BS_FLAGS2_HIDE_BUFF_COUNTERS
Definition enums.h:3649
@ STATUS_KEY_STONE
Definition enums.h:2813
@ BATTLE_STATE_ENEMY_MOVE
Definition enums.h:3685
Actor * get_actor(s32 actorID)
Definition actor_api.c:155

Referenced by btl_update().

◆ btl_state_draw_next_enemy()

void btl_state_draw_next_enemy ( void )

Definition at line 141 of file enemy_next.c.

141 {
142}

Referenced by btl_draw_ui().

◆ btl_state_update_enemy_move()

void btl_state_update_enemy_move ( void )

Definition at line 15 of file enemy_move.c.

15 {
19 Actor* enemy;
20 s32 i;
21
22 Evt* script;
23 s32 messageIndex;
25
26 switch (gBattleSubState) {
32 if (partner != NULL) {
34 }
35 battleStatus->stateFreezeCount = 0;
36 battleStatus->lastAttackDamage = 0;
37 battleStatus->actionQuality = 0;
38 battleStatus->actionResult = ACTION_RESULT_NONE;
39 battleStatus->blockResult = BLOCK_RESULT_NONE;
40 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
43 player->statusAfflicted = 0;
44 if (partner != NULL) {
45 partner->statusAfflicted = 0;
46 }
47
49 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
50 enemy = battleStatus->enemyActors[i];
51 if (enemy != NULL) {
53 }
54 }
55
56 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
57 enemy = battleStatus->enemyActors[i];
58 if (enemy != NULL) {
59 if (!(enemy->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
61 }
62 }
63 }
64
65 enemy = battleStatus->curTurnEnemy;
66 if (!(enemy->flags & ACTOR_FLAG_NO_ATTACK)) {
70 enemy->takeTurnScript = script;
71 enemy->takeTurnScriptID = script->id;
72 script->owner1.actorID = battleStatus->activeEnemyActorID;
73 }
75 break;
77 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
78 break;
79 }
80 player->takeTurnScript = NULL;
81
83 break;
84 }
85 player->handleEventScript = NULL;
86
87 if (partner != NULL) {
88 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
89 break;
90 }
91 partner->handleEventScript = NULL;
92 }
93
95 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
96 enemy = battleStatus->enemyActors[i];
97 if (enemy != NULL && enemy->handleEventScript != NULL) {
100 } else {
101 enemy->handleEventScript = NULL;
102 }
103 }
104 }
105
107 break;
108 }
109
111 return;
112 }
113
114 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
115 enemy = battleStatus->enemyActors[i];
116 if (enemy != NULL && enemy->takeTurnScript != NULL) {
119 } else {
120 enemy->takeTurnScript = NULL;
121 }
122 }
123 }
124
126 break;
127 }
128
132 return;
133 }
134
135 if (battleStatus->stateFreezeCount != 0) {
136 break;
137 }
138
141 } else {
143 if (player->statusAfflicted != 0) {
145 if (partner != NULL) {
147 }
149
150 switch (player->statusAfflicted) {
151 case STATUS_KEY_DIZZY:
152 messageIndex = BTL_MSG_PLAYER_DAZED;
153 break;
154 case STATUS_KEY_SLEEP:
155 messageIndex = BTL_MSG_PLAYER_ASLEEP;
156 break;
158 messageIndex = BTL_MSG_PLAYER_FROZEN;
159 break;
161 messageIndex = BTL_MSG_PLAYER_POISONED;
162 break;
164 messageIndex = BTL_MSG_PLAYER_SHRUNK;
165 break;
167 messageIndex = BTL_MSG_PLAYER_PARALYZED;
168 break;
169 default:
170 messageIndex = 0;
172 break;
173 }
174 btl_show_battle_message(messageIndex, 60);
175 player->statusAfflicted = 0;
177 break;
178 } else {
180 break;
181 }
182 }
183 break;
185 if (!btl_is_popup_displayed()) {
187 btl_cam_move(15);
190 }
191 break;
193 if (BattleSubstateDelay != 0) {
195 } else {
197 break;
198 }
199 break;
200 }
201
202 switch (gBattleSubState) {
204 if (partner != NULL) {
205 if (partner->statusAfflicted == STATUS_KEY_KO) {
210 partner->statusAfflicted = 0;
212 } else {
214 }
215 } else {
217 }
218 break;
220 if (!btl_is_popup_displayed()) {
222 btl_cam_move(15);
225 }
226 break;
228 if (BattleSubstateDelay != 0) {
230 } else {
232 }
233 break;
234 }
235
238 }
239}
EvtScript * takeTurnSource
@ BTL_SUBSTATE_POST_PARTNER_POPUP_DELAY
Definition enemy_move.c:11
@ BTL_SUBSTATE_POST_PLAYER_POPUP_DELAY
Definition enemy_move.c:8
@ BTL_SUBSTATE_UNUSED_1
Definition enemy_move.c:5
@ BTL_SUBSTATE_EXECUTE
Definition enemy_move.c:4
@ BTL_SUBSTATE_AWAIT_PARTNER_POPUP_DONE
Definition enemy_move.c:10
@ BTL_SUBSTATE_CHECK_PARTNER
Definition enemy_move.c:9
@ BTL_SUBSTATE_AWAIT_SCRIPTS
Definition enemy_move.c:6
@ BTL_SUBSTATE_DONE
Definition enemy_move.c:12
@ BTL_SUBSTATE_AWAIT_PLAYER_POPUP_DONE
Definition enemy_move.c:7
@ BS_FLAGS2_IGNORE_DARKNESS
Definition enums.h:3648

Referenced by btl_update().

◆ btl_state_draw_enemy_move()

void btl_state_draw_enemy_move ( void )

Definition at line 241 of file enemy_move.c.

241 {
242}

Referenced by btl_draw_ui().

◆ btl_state_update_first_strike()

void btl_state_update_first_strike ( void )

Definition at line 13 of file player_first_strike.c.

13 {
19 Evt* script;
20 Actor* enemy;
22 s32 i;
23
24 switch (gBattleSubState) {
28 if (playerData->playerFirstStrikes < 9999) {
29 playerData->playerFirstStrikes++;
30 }
31
32 // clear rush flags to initialize
33 battleStatus->rushFlags = RUSH_FLAG_NONE;
35
36 // set rush flags based on danger/peril status
40 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
41 }
43 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
45 battleStatus->rushFlags |= RUSH_FLAG_POWER;
46 }
47 }
48 }
49
50 // setup dummy 'menu selection' for player move
51 switch (encounterStatus->hitType) {
53 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
54 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_JUMP;
55 battleStatus->moveArgument = encounterStatus->hitTier;
57 break;
59 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
60 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_HAMMER;
61 battleStatus->moveArgument = encounterStatus->hitTier;
63 break;
66 return;
67 }
68 // let the enemy know a first strike is coming
69 enemy = get_actor(ACTOR_ENEMY0);
70 if (enemy->handleEventSource != NULL) {
74 enemy->handleEventScriptID = script->id;
75 script->owner1.actorID = enemy->actorID;
76 }
78 break;
80 enemy = get_actor(ACTOR_ENEMY0);
81 if (enemy->handleEventSource != NULL) {
83 break;
84 } else {
85 enemy->handleEventScript = NULL;
86 }
87 }
88
89 func_80263230(player, enemy);
90 battleStatus->stateFreezeCount = 0;
91 battleStatus->lastAttackDamage = 0;
92 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
100 // begin the player turn script
101 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
103 player->takeTurnScript = script;
104 player->takeTurnScriptID = script->id;
105 script->owner1.actorID = ACTOR_PLAYER;
108 break;
110 if (BattleSubstateDelay != 0) {
112 } else {
114 }
115
116 // wait for player move script
118 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
119 break;
120 }
121 player->takeTurnScript = NULL;
122 }
123
125
126 // wait for player handle event script
127 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
128 break;
129 }
130 player->handleEventScript = NULL;
131
132 // wait for partner handle event script
133 if (partner != NULL) {
134 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
135 break;
136 }
137 partner->handleEventScript = NULL;
138 }
139
140 // wait for all enemy turn scripts
142 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
143 enemy = battleStatus->enemyActors[i];
144 if (enemy != NULL && enemy->takeTurnScript != NULL) {
147 } else {
148 enemy->takeTurnScript = NULL;
149 }
150 }
151 }
152 if (enemyNotDone) {
153 break;
154 }
155
156 // wait for all enemy handle event scripts
158 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
159 enemy = battleStatus->enemyActors[i];
160 if (enemy != NULL && enemy->handleEventScript != NULL) {
163 } else {
164 enemy->handleEventScript = NULL;
165 }
166 }
167 }
168 if (enemyNotDone) {
169 break;
170 }
171
172 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
173 enemy = battleStatus->enemyActors[i];
174 if (enemy != NULL) {
176 }
177 }
178
179 if (battleStatus->stateFreezeCount == 0) {
182 Actor* target;
183
185 return;
186 }
187
188 target = get_actor(player->targetActorID);
189 if (target != NULL) {
190 if (target->handleEventSource != NULL) {
191 target->lastEventType = EVENT_END_FIRST_STRIKE;
193 target->handleEventScript = script;
194 target->handleEventScriptID = script->id;
195 script->owner1.actorID = target->actorID;
196 }
197 }
199 } else {
201 }
202 }
203 break;
206 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
207 enemy = battleStatus->enemyActors[i];
208 if (enemy != NULL && enemy->handleEventScript != NULL) {
211 } else {
212 enemy->handleEventScript = NULL;
213 }
214 }
215 }
216 if (enemyNotDone) {
217 break;
218 }
219 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
220 player->takeTurnScript = NULL;
222 }
223 break;
224 }
225}
BSS b32 BattleCanShowFirstStrike
s16 targetActorID
@ PHASE_FIRST_STRIKE
Definition enums.h:2092
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3651
@ ENCOUNTER_TRIGGER_JUMP
Definition enums.h:269
@ ENCOUNTER_TRIGGER_HAMMER
Definition enums.h:271
@ ENCOUNTER_TRIGGER_PARTNER
Definition enums.h:273
@ BTL_CAM_MIDPOINT_CLOSE
Definition enums.h:4417
@ BATTLE_STATE_PARTNER_FIRST_STRIKE
Definition enums.h:3667
@ EVENT_BEGIN_FIRST_STRIKE
Definition enums.h:2206
@ EVENT_END_FIRST_STRIKE
Definition enums.h:2204
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:162
s32 func_80263230(Actor *, Actor *)
Definition 190B20.c:558
@ BTL_SUBSTATE_AWAIT_SCRIPTS
@ BTL_SUBSTATE_AWAIT_ENEMY_DONE
@ BTL_SUBSTATE_AWAIT_ENEMY_READY
void btl_merlee_on_first_strike(void)

Referenced by btl_update().

◆ btl_state_draw_first_stike()

void btl_state_draw_first_stike ( void )

Definition at line 227 of file player_first_strike.c.

227 {
229 if (BattleScreenFadeAmt == 0) {
231 } else {
234 } else {
236 }
237
238 if (BattleScreenFadeAmt < 0) {
240 }
242 }
243 }
244}
s16 EndDemoWhiteOut
Definition 16C8E0.c:13

Referenced by btl_draw_ui().

◆ btl_state_update_partner_striking_first()

void btl_state_update_partner_striking_first ( void )

Definition at line 11 of file partner_first_strike.c.

11 {
13 Actor* player = battleStatus->playerActor;
14 Actor* partner = battleStatus->partnerActor;
15 Actor* actor;
18 Evt* script;
19 s32 level;
20 s32 i;
21
22 switch (gBattleSubState) {
25 // setup dummy 'menu selection' for partner move
26 level = partner->actorBlueprint->level;
27 switch (gPlayerData.curPartner) {
28 case PARTNER_KOOPER:
30 battleStatus->moveArgument = 0;
31 battleStatus->selectedMoveID = level + MOVE_SHELL_TOSS1;
32 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
33 break;
36 battleStatus->moveArgument = 0;
37 battleStatus->selectedMoveID = level + MOVE_BODY_SLAM1;
38 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
39 break;
40 }
41 // let the enemy know a first strike is coming
42 actor = get_actor(ACTOR_ENEMY0);
43 if (actor->handleEventSource != NULL) {
47 actor->handleEventScriptID = script->id;
48 script->owner1.actorID = actor->actorID;
49 }
51 break;
54 target = &partner->targetData[partner->targetIndexList[0]];
55 partner->targetActorID = target->actorID;
56 partner->targetPartID = target->partID;
57 battleStatus->stateFreezeCount = 0;
58 battleStatus->lastAttackDamage = 0;
59 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
67 // begin the partner turn script
68 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
69 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
70 partner->takeTurnScript = script;
71 partner->takeTurnScriptID = script->id;
72 script->owner1.actorID = ACTOR_PARTNER;
75 break;
77 if (BattleSubstateDelay != 0) {
79 } else {
81 }
82 // wait for partner move script
83 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
84 break;
85 }
86 partner->takeTurnScript = NULL;
87 // wait for partner handle event script
88 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
89 break;
90 }
91 partner->handleEventScript = NULL;
92 // wait for player handle event script
94 break;
95 }
96 player->handleEventScript = NULL;
97
98 // wait for all enemy turn scripts
100 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
101 actor = battleStatus->enemyActors[i];
102 if (actor != NULL && actor->takeTurnScript != NULL) {
105 } else {
106 actor->takeTurnScript = NULL;
107 }
108 }
109 }
110 if (enemyNotDone) {
111 break;
112 }
113
114 // wait for all enemy handle event scripts
116 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
117 actor = battleStatus->enemyActors[i];
118 if (actor != NULL && actor->handleEventScript != NULL) {
121 } else {
122 actor->handleEventScript = NULL;
123 }
124 }
125 }
126 if (enemyNotDone) {
127 break;
128 }
129
130 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
131 actor = battleStatus->enemyActors[i];
132 if (actor != NULL) {
134 }
135 }
136
137 if (battleStatus->stateFreezeCount == 0) {
140 return;
141 }
142
143 actor = get_actor(partner->targetActorID);
144 if (actor != NULL) {
145 if (actor->handleEventSource != NULL) {
148 actor->handleEventScript = script;
149 actor->handleEventScriptID = script->id;
150 script->owner1.actorID = actor->actorID;
151 }
152 }
154 }
155 break;
158 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
159 actor = battleStatus->enemyActors[i];
160 if (actor != NULL && actor->handleEventScript != NULL) {
163 } else {
164 actor->handleEventScript = NULL;
165 }
166 }
167 }
168 if (!enemyNotDone) {
170 }
171 break;
172 }
173}
@ PARTNER_BOMBETTE
Definition enums.h:2922
@ PARTNER_KOOPER
Definition enums.h:2921
void create_current_pos_target_list(Actor *actor)
Definition 190B20.c:472
@ BTL_SUBSTATE_AWAIT_SCRIPTS
@ BTL_SUBSTATE_AWAIT_ENEMY_DONE
@ BTL_SUBSTATE_AWAIT_ENEMY_READY

Referenced by btl_update().

◆ btl_state_draw_partner_striking_first()

void btl_state_draw_partner_striking_first ( void )

Definition at line 175 of file partner_first_strike.c.

Referenced by btl_draw_ui().

◆ btl_state_update_enemy_striking_first()

void btl_state_update_enemy_striking_first ( void )

Definition at line 8 of file enemy_first_strike.c.

8 {
10 Actor* player = battleStatus->playerActor;
11 Actor* partner = battleStatus->partnerActor;
12 Evt* script;
13 Actor* actor;
14 u16* enemyIDs;
15 s16 activeEnemyActorID;
17 s32 count;
18 s32 flags;
20 s32 i;
21 s32 j;
22
23 switch (gBattleSubState) {
26 battleStatus->stateFreezeCount = 0;
27 battleStatus->lastAttackDamage = 0;
28 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
32 if (partner != NULL) {
34 }
37 count = 0;
38
39 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
40 actor = battleStatus->enemyActors[i];
41 if (actor != NULL) {
42 battleStatus->enemyIDs[count] = i | ACTOR_ENEMY0;
43 count++;
44 }
45 }
46
47 battleStatus->numEnemyActors = count;
48
49 enemyIDs = battleStatus->enemyIDs;
50 for (i = 0; i < count - 1; i++) {
51 for (j = i + 1; j < count; j++) {
52 s32 iVal = enemyIDs[i];
53 s32 jVal = enemyIDs[j];
54
55 if (battleStatus->enemyActors[iVal & 0xFF]->turnPriority <
56 battleStatus->enemyActors[jVal & 0xFF]->turnPriority)
57 {
58 enemyIDs[i] = jVal;
59 enemyIDs[j] = iVal;
60 }
61 }
62 }
63
64 battleStatus->nextEnemyIndex = 0;
65 nextEnemyIdx = 0;
67
68 while (TRUE) {
69 actor = battleStatus->enemyActors[battleStatus->enemyIDs[nextEnemyIdx] & 0xFF];
70 if (actor == NULL || (actor->flags & flags)) {
72 if (nextEnemyIdx >= battleStatus->numEnemyActors) {
73 nextEnemyIdx = 0;
74 }
75 } else {
76 break;
77 }
78 }
79
80 activeEnemyActorID = battleStatus->enemyIDs[nextEnemyIdx];
82 battleStatus->curTurnEnemy = actor;
83 battleStatus->activeEnemyActorID = activeEnemyActorID;
84 if (nextEnemyIdx >= battleStatus->numEnemyActors) {
85 nextEnemyIdx = 0;
86 }
87 battleStatus->nextEnemyIndex = nextEnemyIdx;
88 btl_cam_target_actor(battleStatus->activeEnemyActorID);
89 actor = battleStatus->curTurnEnemy;
91 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
93 script->owner1.actorID = battleStatus->activeEnemyActorID;
94 actor->takeTurnScript = script;
95 actor->takeTurnScriptID = script->id;
98 break;
100 if (BattleSubstateDelay != 0) {
102 } else {
104 }
105
106 // wait for current enemy TakeTurn script to finish
107 actor = battleStatus->curTurnEnemy;
108 if (actor->takeTurnScript != NULL && does_script_exist(actor->takeTurnScriptID)) {
109 break;
110 }
111 actor->takeTurnScript = NULL;
112
113 // wait for player HandleEvent script to finish (may have been triggered by enemy Take Turn)
114 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
115 break;
116 }
117 player->handleEventScript = NULL;
118
119 // wait for partner HandleEvent script to finish (may have been triggered by enemy Take Turn)
120 if (partner != NULL) {
121 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
122 break;
123 }
124 partner->handleEventScript = NULL;
125 }
126
127 // wait for all enemy TakeTurn scripts to finish
129
130 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
131 actor = battleStatus->enemyActors[i];
132 if (actor != NULL && actor->takeTurnScript != NULL) {
135 } else {
136 actor->takeTurnScript = NULL;
137 }
138 }
139 }
140
141 if (waitingForScript) {
142 break;
143 }
144
145 // wait for all enemy HandleEvent scripts to finish
147
148 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
149 actor = battleStatus->enemyActors[i];
150 if (actor != NULL && actor->handleEventScript != NULL) {
153 } else {
154 actor->handleEventScript = NULL;
155 }
156 }
157 }
158
159 if (waitingForScript) {
160 break;
161 }
162
163 // reset state
165 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
166 actor = battleStatus->enemyActors[i];
167 if (actor != NULL) {
169 }
170 }
171
172 if (battleStatus->stateFreezeCount == 0) {
174 return;
175 }
177 }
178 break;
179 }
180}
s8 flags
Definition demo_api.c:15
@ BTL_SUBSTATE_AWAIT

Referenced by btl_update().

◆ btl_state_draw_enemy_striking_first()

void btl_state_draw_enemy_striking_first ( void )

Definition at line 182 of file enemy_first_strike.c.

Referenced by btl_draw_ui().

◆ btl_state_update_end_demo_battle()

void btl_state_update_end_demo_battle ( void )

Definition at line 16 of file end_demo.c.

16 {
19 Stage* stage;
20 s32 i;
21
22 switch (gBattleSubState) {
25 if (EndDemoWhiteOut == -1) {
26 if (DemoBattleBeginDelay != 0) {
28 break;
29 }
30 }
32 break;
34 switch (EndDemoWhiteOut) {
35 case 255:
37 return;
38 case -1:
39 if (BattleScreenFadeAmt == 255) {
41 return;
42 }
44 if (BattleScreenFadeAmt > 255) {
46 }
47 return;
48 }
49 break;
53 if (gCurrentStagePtr == NULL) {
54 stage = battle->stage;
55 } else {
56 stage = gCurrentStagePtr->stage;
57 }
58
59 if (stage->postBattle == NULL) {
61 } else {
62 battleStatus->controlScript = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
63 battleStatus->controlScriptID = battleStatus->controlScript->id;
65 }
66 break;
68 if (does_script_exist(battleStatus->controlScriptID)) {
69 break;
70 }
72 //fallthrough
75
76 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
77 Actor* enemy = battleStatus->enemyActors[i];
78
79 if (enemy != NULL) {
80 btl_delete_actor(enemy);
81 }
82 }
83
84 if (battleStatus->partnerActor != NULL) {
85 btl_delete_actor(battleStatus->partnerActor);
86 }
87
91
94 }
95
96 if (EndDemoWhiteOut != -1) {
98 }
99
103 break;
104 }
105}
s16 DemoBattleBeginDelay
Definition 16C8E0.c:14
StageListRow * gCurrentStagePtr
Definition battle.cpp:12
@ BTL_SUBSTATE_FADE_OUT
Definition end_demo.c:10
@ BTL_SUBSTATE_EXEC_STAGE_SCRIPT
Definition end_demo.c:11
@ BTL_SUBSTATE_CLEANUP
Definition end_demo.c:13
@ BTL_SUBSTATE_AWAIT_STAGE_SCRIPT
Definition end_demo.c:12
@ WINDOW_GROUP_ALL
Definition enums.h:4908
#define LAST_DEMO_SCENE_IDX
Definition macros.h:120

Referenced by btl_update().

◆ btl_state_draw_end_demo_battle()

void btl_state_draw_end_demo_battle ( void )

Definition at line 107 of file end_demo.c.

Referenced by btl_draw_ui().

◆ btl_state_update_player_menu()

void btl_state_update_player_menu ( void )

Definition at line 298 of file menu_player.c.

298 {
301 Actor* playerActor = battleStatus->playerActor;
302 Actor* partnerActor = battleStatus->partnerActor;
305 s32 entryIdx, initialPos;
306 s32 i;
310 s32 starBeamLevel;
315
316 switch (gBattleSubState) {
318 battleStatus->moveCategory = BTL_MENU_TYPE_INVALID;
319 battleStatus->selectedMoveID = 0;
320 battleStatus->curAttackElement = 0;
321 if (!btl_player_can_act()) {
323 return;
324 }
326 btl_cam_move(10);
327 if (!(battleStatus->flags1 & BS_FLAGS1_PLAYER_IN_BACK)) {
329 } else {
331 partnerActor->state.curPos.x = partnerActor->homePos.x;
332 partnerActor->state.curPos.z = partnerActor->homePos.z;
333 partnerActor->state.goalPos.x = playerActor->homePos.x;
334 partnerActor->state.goalPos.z = playerActor->homePos.z;
335 partnerActor->state.moveTime = 4;
336 partnerActor->state.angle = 0.0f;
337 }
338 break;
340 if (partnerActor->state.moveTime != 0) {
341 partnerActor->curPos.x += (partnerActor->state.goalPos.x - partnerActor->curPos.x) / partnerActor->state.moveTime;
342 partnerActor->curPos.z += (partnerActor->state.goalPos.z - partnerActor->curPos.z) / partnerActor->state.moveTime;
343 playerActor->curPos.x += (partnerActor->state.curPos.x - playerActor->curPos.x) / partnerActor->state.moveTime;
344 playerActor->curPos.z += (partnerActor->state.curPos.z - playerActor->curPos.z) / partnerActor->state.moveTime;
345 }
346 partnerActor->curPos.z -= sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
347 partnerActor->yaw = clamp_angle(-partnerActor->state.angle);
348 playerActor->curPos.z += sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
349 playerActor->yaw = clamp_angle(-partnerActor->state.angle);
350 partnerActor->state.angle += 90.0f;
351 if (partnerActor->state.moveTime != 0) {
352 partnerActor->state.moveTime--;
353 } else {
354 partnerActor->curPos.x = partnerActor->state.goalPos.x;
355 partnerActor->curPos.z = partnerActor->state.goalPos.z;
356 playerActor->curPos.x = partnerActor->state.curPos.x;
357 playerActor->curPos.z = partnerActor->state.curPos.z;
358 partnerActor->homePos.x = partnerActor->curPos.x;
359 partnerActor->homePos.z = partnerActor->curPos.z;
360 playerActor->homePos.x = playerActor->curPos.x;
361 playerActor->homePos.z = playerActor->curPos.z;
364 }
365 break;
366 }
367
368 switch (gBattleSubState) {
371 playerActor->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
372 playerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
373 if (partnerActor != NULL) {
374 partnerActor->flags |= ACTOR_FLAG_USING_IDLE_ANIM;
375 partnerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
376 }
383 break;
384 }
385
386 entryIdx = 0;
387 initialPos = 2;
388 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] < 0) {
389 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] = 0;
390 }
391
392 // strategies menu category
399 }
401 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STRATEGIES)) {
405 }
406 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_STRATEGIES) {
407 initialPos = entryIdx;
408 }
409 entryIdx++;
410
411 // items menu category
412 if (battleStatus->menuStatus[0] >= 0) {
417
418 if(battleStatus->menuStatus[0] == 0) {
422 }
423
424 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_ITEMS)) {
428 }
429
430 if (battleStatus->itemLossTurns >= 0) {
434 }
435
436 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_ITEMS) {
437 initialPos = entryIdx;
438 }
439
440 entryIdx++;
441 }
442
443 // jump menu category
448
449 if (battleStatus->menuStatus[1] <= 0) {
453 }
454 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_JUMP)) {
458 }
459 if (battleStatus->jumpLossTurns >= 0) {
463 }
464 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_JUMP) {
465 initialPos = entryIdx;
466 }
467 entryIdx++;
468
469 // hammer menu category
470 if (playerData->hammerLevel >= 0) {
475 if (battleStatus->menuStatus[2] <= 0) {
479 }
480 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_SMASH)) {
484 }
485 if (battleStatus->hammerLossTurns >= 0) {
489 }
490 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_SMASH) {
491 initialPos = entryIdx;
492 }
493 entryIdx++;
494 }
495
496 // star powers menu category
497 if (playerData->maxStarPower != 0) {
503 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STAR_POWERS)) {
507 }
508 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_STAR_POWERS) {
509 initialPos = entryIdx;
510 }
511 entryIdx++;
512 }
513
515 BattleMenu_PrevSelected = initialPos;
516 BattleMenu_WheelBase = 2 - initialPos;
517 if (btl_partner_can_act()) {
519 } else {
521 }
526 break;
528 if (battleStatus->hustleTurns != 0) {
530 } else {
532 }
534 if (BattleMenu_SwapDelay != 0) {
537 if (btl_partner_can_act() && battleStatus->hustleTurns != 1) {
542 } else if (partnerActor != NULL && !(partnerActor->flags & BS_FLAGS1_YIELD_TURN) && battleStatus->hustleTurns != 1) {
545 }
546 break;
547 }
548
549 if (BattleMenu_ChooseDelay != 0) {
551 break;
552 }
553
554 if (submenuResult == 0) {
555 break;
556 }
557
559 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] = battleStatus->curSubmenu = WheelOptionSubmenu[submenuResult - 1];
560 for (i = 0; i < ARRAY_COUNT(battleStatus->submenuMoves); i++) {
561 battleStatus->submenuMoves[i] = MOVE_NONE;
562 battleStatus->submenuIcons[i] = ITEM_NONE;
563 battleStatus->submenuStatus[i] = 0;
564 }
565
566 switch (battleStatus->curSubmenu) {
568 battleStatus->submenuMoves[0] = MOVE_ITEMS;
569 battleStatus->submenuIcons[0] = ITEM_PARTNER_ATTACK;
570 battleStatus->submenuStatus[0] = 1;
571 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
572 if (playerData->invItems[i] == ITEM_NONE) {
573 continue;
574 }
575 itemData = &gItemTable[playerData->invItems[i]];
576
577 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
578 battleStatus->moveArgument = playerData->invItems[i];
579 battleStatus->curTargetListFlags = itemData->targetFlags;
581 }
582 entryIdx = 1;
583 for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) {
584 if (playerData->equippedBadges[i] != 0) {
585 s32 moveID = gItemTable[playerData->equippedBadges[i]].moveID;
586 moveData = &gMoveTable[moveID];
587 if (moveData->category == BattleMenu_CategoryForSubmenu[battleStatus->curSubmenu]) {
589 battleStatus->submenuMoves[entryIdx] = moveID;
590 battleStatus->submenuIcons[entryIdx] = playerData->equippedBadges[i];
591 battleStatus->submenuStatus[entryIdx] = 1;
592
595
596 if (playerData->curFP < cost) {
597 battleStatus->submenuStatus[entryIdx] = 0;
598 }
599 entryIdx++;
600 }
601 }
602 }
603 battleStatus->submenuMoveCount = entryIdx;
604 if (entryIdx == 1) {
605 battleStatus->submenuMoveCount = 0;
606 }
607 break;
610 if (battleStatus->submenuMoveCount == 1) {
611 battleStatus->submenuMoveCount = 0;
612 }
613 if (battleStatus->actionCommandMode == AC_MODE_TUTORIAL) {
614 battleStatus->submenuMoveCount = 0;
615 }
616 break;
619 if (battleStatus->submenuMoveCount == 1) {
620 battleStatus->submenuMoveCount = 0;
621 }
622 if (battleStatus->actionCommandMode == AC_MODE_TUTORIAL) {
623 battleStatus->submenuMoveCount = 0;
624 }
625 break;
627 battleStatus->submenuMoves[0] = MOVE_FOCUS;
628 battleStatus->submenuIcons[0] = ITEM_PARTNER_ATTACK;
629 battleStatus->submenuStatus[0] = 1;
630 entryIdx = 1;
631 initialPos = 8;
632 for (i = 0; i < playerData->maxStarPower; i++) {
634 battleStatus->submenuMoves[entryIdx] = MOVE_REFRESH + i;
635 battleStatus->submenuIcons[entryIdx] = ITEM_NONE;
637 battleStatus->moveArgument = MOVE_REFRESH + i;
638 battleStatus->curTargetListFlags = moveData->flags;
640 battleStatus->submenuStatus[entryIdx] = 1;
641 if (playerActor->targetListLength == 0) {
642 battleStatus->submenuStatus[entryIdx] = -2;
643 }
644 if (playerData->starPower / SP_PER_BAR < moveData->costFP) {
645 battleStatus->submenuStatus[entryIdx] = 0;
646 }
648 battleStatus->submenuStatus[entryIdx] = -1;
649 }
650 entryIdx++;
651 }
652 starBeamLevel = playerData->starBeamLevel;
653 if (starBeamLevel == 1) {
655 battleStatus->submenuMoves[entryIdx] = MOVE_STAR_BEAM;
656 battleStatus->submenuIcons[entryIdx] = 0;
658 battleStatus->moveArgument = MOVE_REFRESH + i;
659 battleStatus->curTargetListFlags = moveData->flags;
661 battleStatus->submenuStatus[entryIdx] = starBeamLevel;
662 if (playerActor->targetListLength == 0) {
663 battleStatus->submenuStatus[entryIdx] = -2;
664 }
665 if (playerData->starPower / SP_PER_BAR < moveData->costFP) {
666 battleStatus->submenuStatus[entryIdx] = 0;
667 }
669 battleStatus->submenuStatus[entryIdx] = -1;
670 }
671 entryIdx++;
672 }
673 if (playerData->starBeamLevel == 2) {
675 battleStatus->submenuMoves[entryIdx] = MOVE_PEACH_BEAM;
676 battleStatus->submenuIcons[entryIdx] = ITEM_NONE;
678 battleStatus->moveArgument = MOVE_REFRESH + i;
679 battleStatus->curTargetListFlags = moveData->flags;
681 battleStatus->submenuStatus[entryIdx] = 1;
682 if (playerActor->targetListLength == 0) {
683 battleStatus->submenuStatus[entryIdx] = -2;
684 }
685 if (playerData->starPower / SP_PER_BAR < moveData->costFP) {
686 battleStatus->submenuStatus[entryIdx] = 0;
687 }
689 battleStatus->submenuStatus[entryIdx] = -1;
690 }
691 entryIdx++;
692 }
693 battleStatus->submenuMoveCount = entryIdx;
694 break;
695 }
696
697 currentSubmenu = battleStatus->curSubmenu;
698
703 break;
704 }
705
711 } else {
713 battleStatus->moveCategory = currentSubmenu;
714 battleStatus->moveArgument = 0;
715 battleStatus->selectedMoveID = 0;
717 }
718 break;
719 }
720
721 // handle menus without multiple options (skipping submenu)
722 if (battleStatus->submenuMoveCount == 0) {
725 } else {
729 }
730 break;
731 }
732
733 initialPos = 0;
735 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP] < 0) {
736 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP] = 0;
737 }
738 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP];
739 }
740 if (battleStatus->curSubmenu == BTL_MENU_TYPE_SMASH) {
741 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH] < 0) {
742 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH] = 0;
743 }
744 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH];
745 }
746 if (battleStatus->curSubmenu == BTL_MENU_TYPE_ITEMS) {
747 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS] < 0) {
748 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS] = 0;
749 }
750 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS];
751 }
752
753 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
754 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
755 itemData = &gItemTable[battleStatus->submenuIcons[i]];
757
758 MovesOptionError[i] = 0;
759 if (battleStatus->submenuStatus[i] == 0) {
760 MovesOptionError[i] = 0;
761 }
762 if (battleStatus->submenuStatus[i] == -1) {
763 battleStatus->submenuStatus[i] = 0;
765 }
766 if (battleStatus->submenuStatus[i] == -2) {
767 battleStatus->submenuStatus[i] = 0;
769 }
770 if (battleStatus->submenuStatus[i] == -3) {
771 battleStatus->submenuStatus[i] = 0;
773 }
775 if (battleStatus->submenuStatus[i] == 0) {
777 }
778
780 MovesOptionBPCosts[i] = moveData->costBP;
784
788 }
792 }
793
794 MovesOptionIndices[i] = i;
795 MovesOptionEnabled[i] = battleStatus->submenuStatus[i];
796 MovesOptionNames[i] = moveData->nameMsg;
797 MovesOptionDesc[i] = moveData->shortDescMsg;
798
799 }
801 MovesOptionCount = battleStatus->submenuMoveCount;
802 MovesPrevSelected = initialPos;
805 break;
808 switch (submenuResult) {
810 // do nothing while player is choosing from menu
811 break;
814 break;
822 break;
823 default: // something has been selected
824 battleStatus->lastSelectedAbility = MovesOptionIndices[submenuResult - 1];
825 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->lastSelectedAbility];
826 if (battleStatus->curSubmenu == BTL_MENU_TYPE_JUMP) {
827 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP] = SelectedMovesIndex;
828 }
829 if (battleStatus->curSubmenu == BTL_MENU_TYPE_SMASH) {
830 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH] = SelectedMovesIndex;
831 }
832 currentSubmenu2 = battleStatus->curSubmenu;
833 if (battleStatus->curSubmenu == BTL_MENU_TYPE_ITEMS) {
834 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS] = SelectedMovesIndex;
835 if (battleStatus->curSubmenu == currentSubmenu2) {
839 break;
840 }
841 }
845 break;
846 }
847 break;
850 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
854 break;
855 }
856 if (btl_main_menu_update() == 0) {
857 break;
858 }
859 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_ABILITIES_TARGET_CANCEL;
860 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_ABILITIES_TARGET_CHOSEN;
861 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->lastSelectedAbility];
862 battleStatus->curTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->lastSelectedAbility]].flags;
863 currentSubmenu = battleStatus->curSubmenu;
864 switch (currentSubmenu) {
866 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
867 battleStatus->moveArgument = playerData->bootsLevel;
869 break;
871 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
872 battleStatus->moveArgument = playerData->hammerLevel;
874 break;
876 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
878 battleStatus->moveCategory = BTL_MENU_TYPE_DEFEND;
880 break;
881 }
882 break;
885 if (btl_main_menu_update() == 0) {
886 break;
887 }
889 break;
894 break;
898 break;
900 if (btl_submenu_moves_update() != -1) {
902 }
903 break;
907 } else {
909 }
912 break;
915 break;
916 }
921 break;
925 break;
928
929 if (submenuResult == 0) {
930 if (battleStatus->curButtonsPressed & BUTTON_B) {
933 }
934 break;
935 }
936
937 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_NOSUBMENU_TARGET_CANCEL;
938 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_NOSUBMENU_TARGET_CHOSEN;
939 switch (battleStatus->curSubmenu) {
941 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
942 battleStatus->moveArgument = playerData->bootsLevel;
943 battleStatus->selectedMoveID = playerData->bootsLevel + MOVE_JUMP1;
944 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
946 break;
948 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
949 battleStatus->moveArgument = playerData->hammerLevel;
950 battleStatus->selectedMoveID = playerData->hammerLevel + MOVE_HAMMER1;
951 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
953 break;
954 default:
955 ; // fallthrough
956 }
958 if (btl_main_menu_update() == 0) {
959 break;
960 }
964 break;
968 break;
971 break;
973 if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) {
974 battleStatus->itemUsesLeft = 2;
975 }
976 if (battleStatus->selectedMoveID == MOVE_TRIPLE_DIP) {
977 battleStatus->itemUsesLeft = 3;
978 }
979 entryIdx = 0;
980 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
981 if (playerData->invItems[i] == ITEM_NONE) {
982 continue;
983 }
984 itemData = &gItemTable[playerData->invItems[i]];
986 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
987 continue;
988 }
989 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
990 battleStatus->moveArgument = playerData->invItems[i];
991 battleStatus->curTargetListFlags = itemData->targetFlags;
993 popup->ptrIcon[entryIdx] = hudScriptPair->enabled;
994 popup->userIndex[entryIdx] = playerData->invItems[i];
995 popup->enabled[entryIdx] = TRUE;
996 popup->nameMsg[entryIdx] = itemData->nameMsg;
997 popup->descMsg[entryIdx] = itemData->shortDescMsg;
998 if (playerActor->targetListLength == 0) {
999 popup->ptrIcon[entryIdx] = hudScriptPair->disabled;
1000 popup->enabled[entryIdx] = 0;
1001 }
1002 entryIdx++;
1003 }
1004 popup->dipMode = 0;
1005 popup->titleNumber = 0;
1006 if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) {
1007 popup->dipMode = 1;
1008 popup->titleNumber = battleStatus->itemUsesLeft;
1009 }
1010 if (battleStatus->selectedMoveID == MOVE_TRIPLE_DIP) {
1011 popup->dipMode = 2;
1012 popup->titleNumber = battleStatus->itemUsesLeft;
1013 }
1014 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] < 0) {
1015 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = 0;
1016 }
1017 popup->popupType = POPUP_MENU_USE_ITEM;
1018 popup->numEntries = entryIdx;
1019 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP];
1020 popup->initialPos = initialPos;
1024 break;
1026 switch (popup->result) {
1028 // do nothing while player is choosing from popup menu
1029 break;
1032 battleStatus->selectedMoveID = 0;
1033 battleStatus->itemUsesLeft = 0;
1037 break;
1038 default:
1039 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_DIPPING_TARGET_CANCEL;
1040 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_DIPPING_TARGET_CHOSEN;
1041 battleStatus->lastSelectedItem = popup->userIndex[popup->result - 1];
1042 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
1043 battleStatus->moveArgument = battleStatus->lastSelectedItem;
1044 battleStatus->curTargetListFlags = gItemTable[battleStatus->moveArgument].targetFlags | TARGET_FLAG_PRIMARY_ONLY;
1045 battleStatus->curAttackElement = 0;
1046 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = popup->result - 1;
1051 break;
1052 }
1053 break;
1055 if ((battleStatus->curButtonsPressed & BUTTON_B) && popup->result == POPUP_RESULT_CHOOSING) {
1059 battleStatus->selectedMoveID = 0;
1061 } else {
1063 if (btl_main_menu_update()) {
1065 }
1066 }
1067 break;
1070 if (btl_main_menu_update() != 0) {
1072 }
1073 break;
1080 break;
1085 break;
1087 entryIdx = 0;
1088 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
1089 if (playerData->invItems[i] == ITEM_NONE) {
1090 continue;
1091 }
1092 itemData = &gItemTable[playerData->invItems[i]];
1093 hudScriptPair = &gItemHudScripts[itemData->hudElemID];
1094 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
1095 continue;
1096 }
1097 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
1098 battleStatus->moveArgument = playerData->invItems[i];
1099 battleStatus->curTargetListFlags = itemData->targetFlags;
1100 create_current_pos_target_list(playerActor);
1101 popup->ptrIcon[entryIdx] = hudScriptPair->enabled;
1102
1103 popup->userIndex[entryIdx] = playerData->invItems[i];
1104 popup->enabled[entryIdx] = TRUE;
1105 popup->nameMsg[entryIdx] = itemData->nameMsg;
1106 popup->descMsg[entryIdx] = itemData->shortDescMsg;
1107 if (playerActor->targetListLength == 0) {
1108 popup->ptrIcon[entryIdx] = hudScriptPair->disabled;
1109 popup->enabled[entryIdx] = 0;
1110 }
1111 entryIdx++;
1112 }
1113 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] < 0) {
1114 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = 0;
1115 }
1116 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP];
1117 popup->popupType = POPUP_MENU_USE_ITEM;
1118 popup->numEntries = entryIdx;
1119 popup->dipMode = 0;
1120 popup->titleNumber = 0;
1121 popup->initialPos = initialPos;
1125 break;
1127 switch(popup->result) {
1129 // do nothing while player is choosing from popup menu
1130 break;
1138 break;
1139 default:
1140 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_ITEMS_TARGET_CANCEL;
1141 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_ITEMS_TARGET_CHOSEN;
1142 battleStatus->lastSelectedItem = popup->userIndex[popup->result - 1];
1143 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
1144 battleStatus->moveArgument = battleStatus->lastSelectedItem;
1145 battleStatus->selectedMoveID = MOVE_ITEMS;
1146 battleStatus->curTargetListFlags = gItemTable[battleStatus->moveArgument].targetFlags | TARGET_FLAG_PRIMARY_ONLY;
1147 battleStatus->curAttackElement = 0;
1148 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = popup->result - 1;
1152 break;
1153 }
1154 break;
1156 if ((battleStatus->curButtonsPressed & BUTTON_B) && popup->result == POPUP_RESULT_CHOOSING) {
1160 } else {
1161 if (btl_main_menu_update() != 0) {
1163 }
1164 }
1165 break;
1167 if (btl_main_menu_update() != 0) {
1169 }
1170 break;
1175 break;
1179 break;
1181 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
1182 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
1183 MovesOptionError[i] = 0;
1184
1185 if (battleStatus->submenuStatus[i] == 0) {
1186 MovesOptionError[i] = 0;
1187 }
1188
1189 if (battleStatus->submenuStatus[i] == -1) {
1190 battleStatus->submenuStatus[i] = 0;
1192 }
1193 if (battleStatus->submenuStatus[i] == -2) {
1194 battleStatus->submenuStatus[i] = 0;
1196 }
1197 if (!(battleStatus->enabledStarPowersFlags & (1 << i))) {
1198 battleStatus->submenuStatus[i] = 0;
1200 }
1201
1203 if (battleStatus->submenuStatus[i] == 0) {
1205 }
1206 MovesOptionDisplayCosts[i] = moveData->costFP;
1207 MovesOptionBPCosts[i] = moveData->costBP;
1209 MovesOptionIndices[i] = i;
1210 MovesOptionEnabled[i] = battleStatus->submenuStatus[i];
1211 MovesOptionNames[i] = moveData->nameMsg;
1212 MovesOptionDesc[i] = moveData->shortDescMsg;
1213 MovesOptionDiscounts[i] = 0;
1215 }
1216 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER] < 0) {
1217 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER] = 0;
1218 }
1220 MovesOptionCount = battleStatus->submenuMoveCount;
1221 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER];
1222 MovesPrevSelected = initialPos;
1225 break;
1228 switch(submenuResult) {
1230 // do nothing while player is choosing from menu
1231 break;
1234 break;
1242 break;
1243 default:
1244 battleStatus->lastSelectedAbility = MovesOptionIndices[submenuResult - 1];
1245 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER] = SelectedMovesIndex;
1249 break;
1250 }
1251 break;
1254 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
1258 } else if (btl_main_menu_update() != 0) {
1259 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_STAR_SPIRITS_TARGET_CANCEL;
1260 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_STAR_SPIRITS_TARGET_CHOSEN;
1262 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->lastSelectedAbility];
1263 battleStatus->curTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->lastSelectedAbility]].flags;
1264 battleStatus->moveArgument = battleStatus->lastSelectedAbility;
1265 if (playerData->starBeamLevel == 2 && battleStatus->moveArgument == 8) {
1266 battleStatus->moveArgument++;
1267 }
1269 }
1270 break;
1273 if (btl_main_menu_update() != 0) {
1275 }
1276 break;
1281 break;
1285 break;
1289 }
1290 break;
1292 if (!btl_player_can_act()) {
1293 battleStatus->itemUsesLeft = 1;
1295 } else {
1296 entryIdx = 0;
1297 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
1298 if (playerData->invItems[i] == ITEM_NONE) {
1299 continue;
1300 }
1301 itemData = &gItemTable[playerData->invItems[i]];
1302 hudScriptPair = &gItemHudScripts[itemData->hudElemID];
1303 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
1304 continue;
1305 }
1306
1307 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
1308 battleStatus->moveArgument = playerData->invItems[i];
1309 battleStatus->curTargetListFlags = itemData->targetFlags;
1310 create_current_pos_target_list(playerActor);
1311 popup->ptrIcon[entryIdx] = hudScriptPair->enabled;
1312 popup->userIndex[entryIdx] = playerData->invItems[i];
1313 popup->enabled[entryIdx] = TRUE;
1314 popup->nameMsg[entryIdx] = itemData->nameMsg;
1315 popup->descMsg[entryIdx] = itemData->shortDescMsg;
1316 if (playerActor->targetListLength == 0) {
1317 popup->ptrIcon[entryIdx] = hudScriptPair->disabled;
1318 popup->enabled[entryIdx] = FALSE;
1319 }
1320 entryIdx++;
1321 }
1322 if (entryIdx == 0) {
1323 battleStatus->itemUsesLeft = 1;
1325 } else {
1326 popup->popupType = POPUP_MENU_USE_ITEM;
1327 if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) {
1328 popup->popupType += POPUP_MENU_DOUBLE_DIP;
1329 popup->dipMode = 1;
1330 popup->titleNumber = battleStatus->itemUsesLeft;
1331 }
1332 if (battleStatus->selectedMoveID == MOVE_TRIPLE_DIP) {
1333 popup->popupType += POPUP_MENU_TRIPLE_DIP;
1334 popup->dipMode = 2;
1335 popup->titleNumber = battleStatus->itemUsesLeft;
1336 }
1337 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] < 0) {
1338 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = 0;
1339 }
1340 popup->numEntries = entryIdx;
1341 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP];
1342 popup->initialPos = initialPos;
1346 }
1347 }
1348 break;
1350 switch(popup->result) {
1352 // do nothing while player is choosing from menu
1353 break;
1355 battleStatus->itemUsesLeft = 1;
1357 break;
1358 default:
1359 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_NEXT_DIP_TARGET_CANCEL;
1360 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_NEXT_DIP_TARGET_CHOSEN;
1361 battleStatus->lastSelectedItem = popup->userIndex[popup->result - 1];
1362 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
1363 battleStatus->moveArgument = battleStatus->lastSelectedItem;
1364 battleStatus->curTargetListFlags = gItemTable[battleStatus->moveArgument].targetFlags | TARGET_FLAG_PRIMARY_ONLY;
1365 battleStatus->curAttackElement = 0;
1366 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = popup->result - 1;
1370 break;
1371 }
1372 break;
1374 if (BattleMenu_ChooseDelay != 0) {
1376 } else {
1378 }
1379 break;
1381 if (BattleMenu_ChooseDelay != 0) {
1383 } else {
1385 }
1386 break;
1391 break;
1394 break;
1396 if (playerData->bootsLevel > GEAR_RANK_NONE) {
1397 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_JUMP].flags;
1398 create_current_pos_target_list(playerActor);
1399 jumpTargetCount = playerActor->targetListLength;
1400 } else {
1401 jumpTargetCount = 0;
1402 }
1403
1404 if (playerData->hammerLevel > GEAR_RANK_NONE) {
1405 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_HAMMER].flags;
1406 create_current_pos_target_list(playerActor);
1407 hammerTargetCount = playerActor->targetListLength;
1408 } else {
1410 }
1411
1412 if (jumpTargetCount <= 0 && hammerTargetCount <= 0) {
1413 battleStatus->moveCategory = BTL_MENU_TYPE_DO_NOTHING;
1414 battleStatus->waitForState = BATTLE_STATE_NONE;
1416 } else {
1417 jumpChance = 50;
1418 if (jumpTargetCount <= 0) {
1419 jumpChance = 0;
1420 }
1421 if (hammerTargetCount <= 0) {
1422 jumpChance = 101;
1423 }
1424 if (rand_int(100) < jumpChance) {
1425 battleStatus->selectedMoveID = MOVE_BERSERKER_JUMP;
1426 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
1427 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_JUMP].flags;
1428 battleStatus->moveArgument = playerData->bootsLevel;
1429 create_current_pos_target_list(playerActor);
1430 } else {
1431 battleStatus->selectedMoveID = MOVE_BERSERKER_HAMMER;
1432 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
1433 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_HAMMER].flags;
1434 battleStatus->moveArgument = playerData->hammerLevel;
1435 create_current_pos_target_list(playerActor);
1436 }
1438 }
1439 break;
1441 entryIdx = 0;
1443
1444 // add 'Change Member' command
1445 if (battleStatus->changePartnerAllowed >= 0) {
1451 if (battleStatus->changePartnerAllowed <= 0) {
1455 }
1456 entryIdx++;
1457 }
1458
1459 // add 'Do Nothing' command
1465 entryIdx++;
1466
1467 // add 'Run Away' command
1477 }
1478 entryIdx++;
1479
1480 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY] < 0) {
1481 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY] = 0;
1482 }
1483 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY];
1485 StratsPrevSelected = initialPos;
1488 break;
1491 switch(submenuResult) {
1493 // do nothing while player is choosing from menu
1494 break;
1497 break;
1505 break;
1506 default:
1508 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY] = submenuResult - 1;
1509 if (battleStatus->curSubmenu == BTL_MENU_TYPE_CHANGE_PARTNER) {
1513 } else {
1517 }
1518 break;
1519 }
1520 break;
1523 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
1527 } else if (btl_main_menu_update() != 0) {
1528 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_STRATEGIES_TARGET_CANCEL;
1529 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_STRATEGIES_TARGET_CHOSEN;
1530 switch (battleStatus->curSubmenu) {
1534 battleStatus->moveCategory = BTL_MENU_TYPE_RUN_AWAY;
1535 battleStatus->selectedMoveID = MOVE_RUN_AWAY;
1537 break;
1539 battleStatus->hustleTurns = 0;
1541 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
1544 break;
1548 battleStatus->moveCategory = BTL_MENU_TYPE_DEFEND;
1549 battleStatus->selectedMoveID = MOVE_DEFEND;
1551 break;
1556 break;
1557 }
1558 }
1559 break;
1562 if (btl_main_menu_update() != 0) {
1566 }
1567 break;
1572 break;
1576 break;
1578 if (btl_submenu_strats_update() != -1) {
1580 }
1581 break;
1583 entryIdx = 0;
1584 for (i = 1; i < ARRAY_COUNT(playerData->partners); i++) {
1586 if (playerData->partners[partnerId].enabled) {
1589 popup->enabled[entryIdx] = TRUE;
1590 popup->userIndex[entryIdx] = partnerId;
1591 popup->nameMsg[entryIdx] = prop->nameMsg;
1592 popup->descMsg[entryIdx] = prop->battleDescMsg;
1593 popup->value[entryIdx] = playerData->partners[partnerId].level;
1594 if (playerData->curPartner == partnerId) {
1596 popup->enabled[entryIdx] = FALSE;
1597 }
1598 entryIdx++;
1599 }
1600 }
1601 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_PARTNER] < 0) {
1602 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_PARTNER] = 0;
1603 }
1604 popup->popupType = POPUP_MENU_SWITCH_PARTNER;
1605 popup->numEntries = entryIdx;
1606 popup->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
1607 popup->dipMode = 0;
1608 popup->titleNumber = 0;
1612 break;
1614 switch(popup->result) {
1616 // do nothing while player is choosing from menu
1617 break;
1620 break;
1626 break;
1627 default:
1628 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CANCEL;
1629 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CHOSEN;
1630 battleStatus->lastSelectedPartner = popup->userIndex[popup->result - 1];
1632 battleStatus->selectedMoveID = MOVE_CHANGE_PARTNER;
1633 battleStatus->curTargetListFlags = TARGET_FLAG_2;
1634 battleStatus->moveArgument = battleStatus->lastSelectedPartner;
1635 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_PARTNER] = popup->result - 1;
1640 break;
1641 }
1642 break;
1644 if ((battleStatus->curButtonsPressed & BUTTON_B) && popup->result == POPUP_RESULT_CHOOSING) {
1649 } else {
1651 if (btl_main_menu_update() != 0) {
1652 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
1655 }
1656 }
1657 break;
1660 if (btl_main_menu_update() != 0) {
1662 }
1663 break;
1669 break;
1674 break;
1678 if (popup->result != POPUP_RESULT_INVALID) {
1682 }
1683 break;
1684 }
1685}
void btl_init_menu_items(void)
Definition 190B20.c:601
void btl_check_can_change_partner(void)
Definition 190B20.c:566
s32 MenuIndexFromPartnerID[]
Definition 5B320.c:316
PartnerPopupProperties gPartnerPopupProperties[]
Definition 5B320.c:331
void create_battle_popup_menu(PopupMenu *popup)
void flush_popup_menu(void)
void show_popup_menu(void)
@ AC_MODE_TUTORIAL
Definition action_cmd.h:62
void btl_main_menu_resume_choose(void)
void btl_main_menu_destroy(void)
void btl_main_menu_restore_choose(void)
s8 BattleMenu_CurPos
s32 BattleMenu_ChooseDelay
#define MENU_DIPPING_DELAY
Definition battle_menu.h:8
IconHudScriptPair gItemHudScripts[]
s32 MovesOptionNames[24]
Definition menu_moves.c:55
void btl_submenu_moves_restore_locked(void)
Definition menu_moves.c:249
s8 ShowingErrorMessage
Definition menu_strats.c:54
s32 MovesOptionCount
Definition menu_moves.c:65
s32 MovesOptionIndices[24]
Definition menu_moves.c:61
void btl_submenu_moves_resume_choose(void)
Definition menu_moves.c:167
IconHudScriptPair StarPowersHudScripts
s32 btl_submenu_moves_update(void)
Definition menu_moves.c:254
s32 WheelOptionEnabled[]
s32 WheelOptionName[]
s32 MovesOptionEnabled[24]
Definition menu_moves.c:62
void btl_main_menu_init(void)
void btl_submenu_moves_destroy(void)
Definition menu_moves.c:138
s32 btl_main_menu_update(void)
s32 BattleMenu_SwapDelay
void btl_submenu_strats_restore_choose(void)
HudScript * MovesOptionHudScripts[24]
Definition menu_moves.c:52
s32 StratsOptionNames[]
Definition menu_strats.c:38
s32 MovesOptionBPCosts[24]
Definition menu_moves.c:60
s32 MovesOptionDiscounts[24]
Definition menu_moves.c:58
s32 UsingSpiritsSubmenu
Definition menu_moves.c:82
s32 WheelOptionError[]
s32 LeftJustMenuMessages[]
s32 WheelOptionSubmenu[]
s32 StratsOptionError[]
Definition menu_strats.c:42
IconHudScriptPair StrategiesHudScripts
s8 MovesOptionSortPriority[24]
Definition menu_moves.c:63
void btl_submenu_moves_restore_choose(void)
Definition menu_moves.c:207
s8 BattleMenu_HomePos
void btl_submenu_strats_restore_locked(void)
void btl_submenu_moves_hide(void)
Definition menu_moves.c:134
s32 StratsOptionMessage[]
Definition menu_strats.c:41
HudScript * StratsOptionHudScripts[]
Definition menu_strats.c:36
s32 MovesPrevSelected
Definition menu_moves.c:46
s32 MovesOptionDesc[24]
Definition menu_moves.c:56
IconHudScriptPair PartnerHudScripts[]
#define MENU_CHANGE_DELAY
Definition battle_menu.h:7
void btl_main_menu_restore_submenu(void)
s32 StratsPrevSelected
Definition menu_strats.c:34
void btl_main_menu_hide(void)
void btl_submenu_moves_init(void)
Definition menu_moves.c:94
HudScript * WheelOptionHudScript[]
b32 btl_partner_can_act(void)
IconHudScriptPair ItemsHudScripts
void btl_submenu_strats_hide(void)
void btl_submenu_strats_destroy(void)
s32 BattleMenu_WheelBase
s32 StratsOptionEnabled[]
Definition menu_strats.c:40
IconHudScriptPair DoNothingHudScripts
s32 BattleMenu_PrevSelected
IconHudScriptPair StarPowerMovesHudScripts[]
PopupMenu BattlePopupMenu
s32 WheelOptionCount
s8 MovesOptionError[24]
Definition menu_moves.c:64
s32 StratsOptionMenuTypes[]
Definition menu_strats.c:39
b32 btl_player_can_act(void)
void btl_menu_strats_init(void)
Definition menu_strats.c:66
IconHudScriptPair FleeHudScripts
b32 BattleMenu_ShowSwapIcons
s32 SelectedMovesIndex
Definition menu_moves.c:83
s32 btl_submenu_strats_update(void)
s32 StratsOptionCount
Definition menu_strats.c:43
s32 MovesOptionDisplayCosts[24]
Definition menu_moves.c:57
s32 MovesOptionDiscountColors[24]
Definition menu_moves.c:59
s32 CenteredBattleMessages[]
void btl_submenu_strats_resume_choose(void)
u32 pressedButtons[4]
s8 targetListLength
@ BUTTON_B
Definition enums.h:2775
@ BUTTON_Z
Definition enums.h:2774
@ BS_FLAGS1_TUTORIAL_BATTLE
Definition enums.h:3627
@ BS_FLAGS1_MENU_OPEN
Definition enums.h:3599
@ BTL_MSG_CANT_SWITCH
Definition enums.h:3782
@ BTL_MSG_CANT_MOVE
Definition enums.h:3783
@ BTL_MSG_NO_JUMP_TARGET
Definition enums.h:3769
@ BTL_MSG_NO_ITEM_TARGET
Definition enums.h:3771
@ BTL_MSG_CANT_SELECT_NOW
Definition enums.h:3774
@ BTL_MSG_CANT_SELECT_NOW_ALT
Definition enums.h:3786
@ BTL_MSG_NO_HAMMER_TARGET
Definition enums.h:3770
@ POPUP_MENU_DOUBLE_DIP
Definition enums.h:3179
@ POPUP_MENU_USE_ITEM
Definition enums.h:3165
@ POPUP_MENU_TRIPLE_DIP
Definition enums.h:3180
@ POPUP_MENU_SWITCH_PARTNER
Definition enums.h:3166
@ WINDOW_UPDATE_9
Definition enums.h:4904
@ WINDOW_UPDATE_HIDE
Definition enums.h:4897
@ BTL_MENU_TYPE_INVALID
Definition enums.h:3825
@ BTL_MENU_TYPE_RUN_AWAY
Definition enums.h:3829
@ BTL_MENU_TYPE_STAR_POWERS
Definition enums.h:3834
@ BTL_MENU_TYPE_ACT_LATER
Definition enums.h:3836
@ BTL_MENU_TYPE_DEFEND
Definition enums.h:3830
@ BTL_MENU_TYPE_STRATEGIES
Definition enums.h:3833
@ BTL_MENU_TYPE_DO_NOTHING
Definition enums.h:3835
@ BS_FLAGS2_NO_TARGET_AVAILABLE
Definition enums.h:3647
@ STATUS_KEY_THINKING
Definition enums.h:2829
@ ITEM_TYPE_FLAG_BATTLE_USABLE
Definition enums.h:1861
@ TARGET_FLAG_PRIMARY_ONLY
Definition enums.h:1889
@ TARGET_FLAG_2
Definition enums.h:1876
@ POPUP_RESULT_CANCEL
Definition enums.h:3212
@ POPUP_RESULT_CHOOSING
Definition enums.h:3211
@ POPUP_RESULT_INVALID
Definition enums.h:3209
@ BATTLE_STATE_DEFEND
Definition enums.h:3689
@ BATTLE_STATE_PLAYER_MOVE
Definition enums.h:3682
@ BATTLE_STATE_SELECT_TARGET
Definition enums.h:3681
@ BATTLE_STATE_CHANGE_PARTNER
Definition enums.h:3692
@ ABILITY_FLOWER_SAVER
Definition enums.h:460
@ ABILITY_FLOWER_FANATIC
Definition enums.h:474
@ SOUND_PARTNER_SWAP_BATTLE_POS
Definition enums.h:563
@ SOUND_MENU_ERROR
Definition enums.h:936
@ GEAR_RANK_NONE
Definition enums.h:2044
@ BTL_MENU_ENABLED_SMASH
Definition enums.h:3842
@ BTL_MENU_ENABLED_ITEMS
Definition enums.h:3843
@ BTL_MENU_ENABLED_STAR_POWERS
Definition enums.h:3846
@ BTL_MENU_ENABLED_JUMP
Definition enums.h:3841
@ BTL_MENU_ENABLED_STRATEGIES
Definition enums.h:3845
@ WIN_BTL_STRATS_MENU
Definition enums.h:4832
@ WIN_BTL_STRATS_TITLE
Definition enums.h:4833
void btl_show_variable_battle_message(s32, s32, s32)
void hide_popup_menu(void)
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void destroy_popup_menu(void)
void set_actor_anim(s32 actorID, s32 partID, AnimID animID)
Definition 190B20.c:737
HudScript * disabled
HudScript * enabled
IconHudScriptPair HammerHudScripts[]
void btl_init_menu_hammer(void)
@ BTL_SUBSTATE_DIPPING_HANDOVER
Definition menu_player.c:34
@ BTL_SUBSTATE_STAR_SPIRITS_BUILD_MENU
Definition menu_player.c:54
@ BTL_SUBSTATE_NEXT_DIP_HANDOVER
Definition menu_player.c:64
@ BTL_SUBSTATE_NEXT_DIP_REOPEN_MENU
Definition menu_player.c:65
@ BTL_SUBSTATE_CREATE_MAIN_MENU
Definition menu_player.c:80
@ BTL_SUBSTATE_STAR_SPIRITS_SHOW_ERROR
Definition menu_player.c:60
@ BTL_SUBSTATE_MAIN_AWAIT_CANT_SWAP
Definition menu_player.c:23
@ BTL_SUBSTATE_STRATEGIES_SHOW_ERROR
Definition menu_player.c:77
@ BTL_SUBSTATE_STAR_SPIRITS_TARGET_CHOSEN
Definition menu_player.c:59
@ BTL_SUBSTATE_STAR_SPIRITS_CHOOSING
Definition menu_player.c:55
@ BTL_SUBSTATE_NEXT_DIP_BUILD_MENU
Definition menu_player.c:62
@ BTL_SUBSTATE_ABILITIES_SHOW_ERROR
Definition menu_player.c:21
@ BTL_SUBSTATE_STAR_SPIRITS_HANDOVER
Definition menu_player.c:56
@ BTL_SUBSTATE_CHANGE_PARTNER_HANDOVER
Definition menu_player.c:41
@ BTL_SUBSTATE_NOSUBMENU_TARGET_CANCEL
Definition menu_player.c:29
@ BTL_SUBSTATE_CHANGE_PARTNER_CHOOSING
Definition menu_player.c:40
@ BTL_SUBSTATE_NEXT_DIP_TARGET_CHOSEN
Definition menu_player.c:67
@ BTL_SUBSTATE_CHANGE_PARTNER_REOPEN_MENU
Definition menu_player.c:42
@ BTL_SUBSTATE_ABILITIES_HANDOVER
Definition menu_player.c:17
@ BTL_SUBSTATE_DIPPING_TARGET_CANCEL
Definition menu_player.c:36
@ BTL_SUBSTATE_DIPPING_CHOOSING
Definition menu_player.c:33
@ BTL_SUBSTATE_MAIN_CHOOSING
Definition menu_player.c:14
@ BTL_SUBSTATE_ITEMS_BUILD_MENU
Definition menu_player.c:47
@ BTL_SUBSTATE_STRATEGIES_HANDOVER
Definition menu_player.c:73
@ BTL_SUBSTATE_NEXT_DIP_CHOOSING
Definition menu_player.c:63
@ BTL_SUBSTATE_DIPPING_REOPEN_MENU
Definition menu_player.c:35
@ BTL_SUBSTATE_NOSUBMENU_SHOW
Definition menu_player.c:26
@ BTL_SUBSTATE_ABILITIES_CHOOSING
Definition menu_player.c:16
@ BTL_SUBSTATE_ITEMS_REOPEN_MENU
Definition menu_player.c:50
@ BTL_SUBSTATE_STAR_SPIRITS_TARGET_CANCEL
Definition menu_player.c:58
@ BTL_SUBSTATE_CHANGE_PARTNER_BUILD_MENU
Definition menu_player.c:39
@ BTL_SUBSTATE_STRATEGIES_TARGET_CHOSEN
Definition menu_player.c:76
@ BTL_SUBSTATE_NEXT_DIP_TARGET_CANCEL
Definition menu_player.c:66
@ BTL_SUBSTATE_STRATEGIES_REOPEN_MENU
Definition menu_player.c:74
@ BTL_SUBSTATE_ITEMS_TARGET_CANCEL
Definition menu_player.c:51
@ BTL_SUBSTATE_PERFORM_SWAP
Definition menu_player.c:79
@ BTL_SUBSTATE_CHANGE_PARTNER_ERROR
Definition menu_player.c:45
@ BTL_SUBSTATE_DIPPING_BUILD_MENU
Definition menu_player.c:32
@ BTL_SUBSTATE_NOSUBMENU_TARGET_CHOSEN
Definition menu_player.c:30
@ BTL_SUBSTATE_ITEMS_HANDOVER
Definition menu_player.c:49
@ BTL_SUBSTATE_ABILITIES_REOPEN_MENU
Definition menu_player.c:18
@ BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CANCEL
Definition menu_player.c:43
@ BTL_SUBSTATE_NOSUBMENU_HANDOVER
Definition menu_player.c:27
@ BTL_SUBSTATE_NOSUBMENU_RETURN_MAIN
Definition menu_player.c:28
@ BTL_SUBSTATE_STAR_SPIRITS_REOPEN_MENU
Definition menu_player.c:57
@ BTL_SUBSTATE_MAIN_SHOW_CANT_SWAP
Definition menu_player.c:22
@ BTL_SUBSTATE_DIPPING_TARGET_CHOSEN
Definition menu_player.c:37
@ BTL_SUBSTATE_ITEMS_CHOOSING
Definition menu_player.c:48
@ BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CHOSEN
Definition menu_player.c:44
@ BTL_SUBSTATE_STRATEGIES_BUILD_MENU
Definition menu_player.c:71
@ BTL_SUBSTATE_ABILITIES_TARGET_CHOSEN
Definition menu_player.c:20
@ BTL_SUBSTATE_BERSERKER_CHOOSE
Definition menu_player.c:69
@ BTL_SUBSTATE_STRATEGIES_CHOOSING
Definition menu_player.c:72
@ BTL_SUBSTATE_STRATEGIES_TARGET_CANCEL
Definition menu_player.c:75
@ BTL_SUBSTATE_ITEMS_TARGET_CHOSEN
Definition menu_player.c:52
@ BTL_SUBSTATE_ABILITIES_TARGET_CANCEL
Definition menu_player.c:19
s32 BattleMenu_CategoryForSubmenu[]
Definition menu_player.c:83
void btl_state_update_player_menu(void)
IconHudScriptPair BootsHudScripts[]
Definition menu_player.c:98
s32 get_player_anim_for_status(s32 animID)
Definition 190B20.c:1697
void btl_init_menu_boots(void)
ItemData gItemTable[]
s32 PartnerIDFromMenuIndex[12]
Definition 5B320.c:300

Referenced by btl_state_update_player_menu(), btl_state_update_select_target(), and btl_update().

◆ btl_state_draw_player_menu()

void btl_state_draw_player_menu ( void )

Definition at line 1687 of file menu_player.c.

1687 {
1688 switch (gBattleSubState) {
1691 break;
1719 break;
1725 break;
1728 break;
1731 break;
1734 break;
1737 break;
1738 }
1739}
void btl_main_menu_draw(void)

Referenced by btl_draw_ui().

◆ btl_state_update_partner_menu()

void btl_state_update_partner_menu ( void )

Definition at line 281 of file menu_partner.c.

281 {
284 Actor* playerActor = battleStatus->playerActor;
285 Actor* partnerActor = battleStatus->partnerActor;
288 s32 i;
290 s32 initialPos;
293
295 battleStatus->moveCategory = BTL_MENU_TYPE_INVALID;
296 battleStatus->selectedMoveID = MOVE_NONE;
297 battleStatus->curAttackElement = 0;
298 if (!btl_partner_can_act()) {
300 } else {
307 } else {
309 partnerActor->state.curPos.x = partnerActor->homePos.x;
310 partnerActor->state.curPos.z = partnerActor->homePos.z;
311 partnerActor->state.goalPos.x = playerActor->homePos.x;
312 partnerActor->state.goalPos.z = playerActor->homePos.z;
313 partnerActor->state.moveTime = 4;
314 partnerActor->state.angle = 0.0f;
315 }
316 }
317 }
318
320 if (partnerActor->state.moveTime != 0) {
321 partnerActor->curPos.x += (partnerActor->state.goalPos.x - partnerActor->curPos.x) / partnerActor->state.moveTime;
322 partnerActor->curPos.z += (partnerActor->state.goalPos.z - partnerActor->curPos.z) / partnerActor->state.moveTime;
323 playerActor->curPos.x += (partnerActor->state.curPos.x - playerActor->curPos.x) / partnerActor->state.moveTime;
324 playerActor->curPos.z += (partnerActor->state.curPos.z - playerActor->curPos.z) / partnerActor->state.moveTime;
325 }
326 partnerActor->curPos.z += sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
327 partnerActor->yaw = clamp_angle(-partnerActor->state.angle);
328 playerActor->curPos.z -= sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
329 playerActor->yaw = clamp_angle(-partnerActor->state.angle);
330 partnerActor->state.angle += 90.0f;
331 if (partnerActor->state.moveTime != 0) {
332 partnerActor->state.moveTime--;
333 } else {
335 partnerActor->curPos.x = partnerActor->state.goalPos.x;
336 partnerActor->curPos.z = partnerActor->state.goalPos.z;
337 playerActor->curPos.x = partnerActor->state.curPos.x;
338 playerActor->curPos.z = partnerActor->state.curPos.z;
339 partnerActor->homePos.x = partnerActor->curPos.x;
340 partnerActor->homePos.z = partnerActor->curPos.z;
341 playerActor->homePos.x = playerActor->curPos.x;
342 playerActor->homePos.z = playerActor->curPos.z;
344 }
345 }
346
347 switch (gBattleSubState) {
349 partnerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
350 partnerActor->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
351 playerActor->flags |= ACTOR_FLAG_USING_IDLE_ANIM;
352 playerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
355
356 // default menu position is section option: abilities
357 // will be overridden by most recently selected option, if one exists
358 initialPos = 1;
359 entryIdx = 0;
360
361 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] < 0) {
362 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] = BTL_MENU_TYPE_ABILITY;
363 }
366
367 // strategies menu category
373 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STRATEGIES)) {
377 }
378 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_STRATEGIES) {
379 initialPos = entryIdx;
380 }
381 entryIdx++;
382
383 // abilities menu category
388 if (battleStatus->menuStatus[3] <= 0) {
392 }
393 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_ABILITIES)) {
397 }
398 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_ABILITY) {
399 initialPos = entryIdx;
400 }
401 entryIdx++;
402
403 // focus menu category
404 if (playerData->maxStarPower != 0 && is_ability_active(ABILITY_GROUP_FOCUS)) {
410 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_PARTNER_FOCUS)) {
414 }
415 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] == BTL_MENU_TYPE_PARTNER_FOCUS) {
416 initialPos = entryIdx;
417 }
418 entryIdx++;
419 }
420
422 BattleMenu_PrevSelected = initialPos;
423 BattleMenu_WheelBase = 2 - initialPos;
424 if (btl_player_can_act()) {
426 } else {
428 }
433 return;
437 // fall through
440
441 if (BattleMenu_SwapDelay != 0) {
444 if (btl_player_can_act()) {
449 } else {
452 }
453 break;
454 }
455
456 if (BattleMenu_ChooseDelay != 0) {
458 break;
459 }
460
461 if (entryIdx != 0) {
463 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] = battleStatus->curPartnerSubmenu = WheelOptionSubmenu[entryIdx - 1];
464 switch (battleStatus->curPartnerSubmenu) {
469 break;
474 break;
479 break;
484 break;
489 break;
490 default:
491 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_MAIN_TARGET_CANCEL;
492 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_MAIN_TARGET_CHOSEN;
495 break;
496 }
497 }
498 break;
501 if ((battleStatus->curButtonsPressed & BUTTON_B) && entryIdx == 0) {
504 return;
505 }
506 if (entryIdx != 0) {
508 battleStatus->selectedMoveID = MOVE_FOCUS;
509 battleStatus->moveArgument = 0;
510 battleStatus->curTargetListFlags = gMoveTable[MOVE_FOCUS].flags;
512 return;
513 }
514 break;
516 if (btl_main_menu_update() != 0) {
520 }
521 break;
525 break;
528 break;
530 if (!btl_player_can_act()) {
532 } else {
534 }
537 break;
540 break;
541 }
546 break;
548 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
549 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
550
551 MovesOptionError[i] = 0;
552 if (battleStatus->submenuStatus[i] == 0) {
553 MovesOptionError[i] = 0;
554 }
555 if (battleStatus->submenuStatus[i] == -1) {
556 battleStatus->submenuStatus[i] = 0;
558 }
559 if (battleStatus->submenuStatus[i] == -2) {
560 battleStatus->submenuStatus[i] = 0;
562 }
564 if (battleStatus->submenuStatus[i] == 0) {
566 }
567 MovesOptionIndices[i] = battleStatus->submenuMoves[i];
568 MovesOptionEnabled[i] = battleStatus->submenuStatus[i];
569 MovesOptionNames[i] = moveData->nameMsg;
570 MovesOptionDesc[i] = moveData->shortDescMsg;
572 MovesOptionBPCosts[i] = moveData->costBP;
574
580 }
584 }
585 }
586 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY] < 0) {
587 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY] = 0;
588 }
590 MovesOptionCount = battleStatus->submenuMoveCount;
591 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY];
592 MovesPrevSelected = initialPos;
595 break;
598 switch (entryIdx) {
600 // do nothing while player is choosing from popup menu
601 break;
604 break;
612 break;
613 default:
614 battleStatus->lastPartnerPowerSelection = entryIdx - 1;
618 break;
619 }
620 break;
623 if ((battleStatus->curButtonsPressed & BUTTON_B) && entryIdx == 0) {
627 } else if (btl_main_menu_update() != 0) {
628 battleStatus->moveCategory = BTL_MENU_TYPE_ABILITY;
629 battleStatus->selectedMoveID = MovesOptionIndices[battleStatus->lastPartnerPowerSelection];
630 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
631 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY] = SelectedMovesIndex;
632 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_ABILITIES_TARGET_CANCEL;
633 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_ABILITIES_TARGET_CHOSEN;
635 }
636 break;
639 if (btl_main_menu_update() != 0) {
641 }
642 break;
647 break;
651 break;
653 if (btl_submenu_moves_update() != -1) {
655 }
656 break;
658 popupIndex = 0;
659 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
660 ItemData* item;
662 if (playerData->invItems[i] == ITEM_NONE) {
663 continue;
664 }
665 item = &gItemTable[playerData->invItems[i]];
667
669 continue;
670 }
671 popupMenu->ptrIcon[popupIndex] = hudScript[0];
672 popupMenu->userIndex[popupIndex] = playerData->invItems[i];
673 popupMenu->enabled[popupIndex] = TRUE;
674 popupMenu->nameMsg[popupIndex] = item->nameMsg;
675 popupMenu->descMsg[popupIndex] = item->shortDescMsg;
676 popupIndex++;
677 }
678 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM] < 0) {
679 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM] = 0;
680 }
681 popupMenu->popupType = POPUP_MENU_USE_ITEM;
682 popupMenu->numEntries = popupIndex;
683 popupMenu->dipMode = 0;
684 popupMenu->titleNumber = 0;
685 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM];
686 popupMenu->initialPos = initialPos;
690 break;
692 switch (popupMenu->result) {
694 // do nothing while player is choosing from menu
695 break;
703 break;
704 default: // something has been selected
705 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_ITEMS_TARGET_CANCEL;
706 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_ITEMS_TARGET_CHOSEN;
707 battleStatus->lastSelectedItem = popupMenu->userIndex[popupMenu->result - 1];
708 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
709 battleStatus->moveArgument = battleStatus->lastSelectedItem;
710 battleStatus->curTargetListFlags = gItemTable[battleStatus->moveArgument].targetFlags | TARGET_FLAG_PRIMARY_ONLY;
711 battleStatus->curAttackElement = 0;
712 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM] = popupMenu->result - 1;
716 break;
717 }
718 break;
720 if (btl_main_menu_update() != 0) {
722 }
723 break;
725 if ((battleStatus->curButtonsPressed & BUTTON_B) && popupMenu->result == POPUP_RESULT_CHOOSING) {
729 } else if (btl_main_menu_update() != 0) {
731 }
732 break;
737 break;
741 break;
743 popupIndex = 0;
744 for (i = 1; i < ARRAY_COUNT(PartnerIDFromMenuIndex); i++) {
746 if (playerData->partners[partnerId].enabled) {
749 popupMenu->enabled[popupIndex] = TRUE;
750 popupMenu->userIndex[popupIndex] = partnerId;
751 popupMenu->nameMsg[popupIndex] = popupProps->nameMsg;
752 popupMenu->descMsg[popupIndex] = popupProps->battleDescMsg;
753 popupMenu->value[popupIndex] = playerData->partners[partnerId].level;
754 if (playerData->curPartner == partnerId) {
756 popupMenu->enabled[popupIndex] = FALSE;
757 }
758 popupIndex++;
759 }
760 }
761 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] < 0) {
762 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] = 0;
763 }
765 popupMenu->numEntries = popupIndex;
766 popupMenu->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
767 popupMenu->dipMode = 0;
768 popupMenu->titleNumber = 0;
772 break;
774 switch (popupMenu->result) {
776 // do nothing while player is choosing from popup menu
777 break;
780 break;
788 break;
789 default:
792 battleStatus->lastSelectedPartner = popupMenu->userIndex[popupMenu->result - 1];
794 battleStatus->selectedMoveID = MOVE_CHANGE_PARTNER;
795 battleStatus->curTargetListFlags = TARGET_FLAG_2;
796 battleStatus->moveArgument = battleStatus->lastSelectedPartner;
797 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] = popupMenu->result - 1;
801 break;
802 }
803 break;
805 if ((battleStatus->curButtonsPressed & BUTTON_B) && (popupMenu->result == POPUP_RESULT_CHOOSING)) {
809 } else if (btl_main_menu_update() != 0) {
810 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
813 }
814 break;
816 if (btl_main_menu_update() != 0) {
818 }
819 break;
824 break;
828 break;
830 if (popupMenu->result != POPUP_RESULT_INVALID) {
832 }
833 break;
835 entryIdx = 1;
836 battleStatus->submenuMoveCount = entryIdx;
837 battleStatus->submenuMoves[0] = MOVE_FOCUS;
838 battleStatus->submenuIcons[0] = ITEM_PARTNER_ATTACK;
839 battleStatus->submenuStatus[0] = 1;
840 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
841 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
843 if (battleStatus->submenuStatus[i] == 0) {
845 }
847 MovesOptionBPCosts[i] = moveData->costBP;
848 MovesOptionIndices[i] = i;
850 MovesOptionEnabled[i] = battleStatus->submenuStatus[i];
851 MovesOptionNames[i] = moveData->nameMsg;
852 MovesOptionDesc[i] = moveData->shortDescMsg;
855 }
856 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER] < 0) {
857 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER] = 0;
858 }
860 MovesOptionCount = battleStatus->submenuMoveCount;
861 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER];
862 MovesPrevSelected = initialPos;
865 break;
868 switch (entryIdx) {
870 // do nothing while player is choosing from popup menu
871 break;
879 break;
880 default:
881 battleStatus->lastPartnerPowerSelection = MovesOptionIndices[entryIdx - 1];
885 break;
886 }
887 break;
890 if ((battleStatus->curButtonsPressed & BUTTON_B) && (entryIdx == 0)) {
894 } else if (btl_main_menu_update() != 0) {
895 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_FOCUS_CANCELED;
896 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_FOCUS_SELECTED;
898 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->lastPartnerPowerSelection];
899 battleStatus->curTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->lastPartnerPowerSelection]].flags;
900 battleStatus->moveArgument = battleStatus->lastPartnerPowerSelection;
901 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER] = SelectedMovesIndex;
903 }
904 break;
907 if (btl_main_menu_update() != 0) {
909 }
910 break;
915 break;
919 break;
921 popupIndex = 0;
923
924 // add 'Change Member' command
925 if (battleStatus->changePartnerAllowed >= 0) {
931 if (battleStatus->changePartnerAllowed <= 0) {
935 }
936 popupIndex++;
937 }
938
939 // add 'Do Nothing' command
945 popupIndex++;
946
947 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] < 0) {
948 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] = 0;
949 }
951 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY];
952 StratsPrevSelected = initialPos;
955 break;
958 switch (entryIdx) {
960 // do nothing while player is selecting an entry
961 break;
969 break;
970 default:
971 battleStatus->curPartnerSubmenu = StratsOptionMenuTypes[entryIdx - 1];
972 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] = entryIdx - 1;
973 if (battleStatus->curPartnerSubmenu == BTL_MENU_TYPE_CHANGE_PARTNER) {
977 } else {
981 }
982 break;
983 }
984 break;
987 if ((battleStatus->curButtonsPressed & BUTTON_B) && entryIdx == POPUP_RESULT_CHOOSING) {
991 } else if (btl_main_menu_update() != 0) {
992 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_STRATEGIES_TARGET_CANCEL;
993 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_STRATEGIES_TARGET_CHOSEN;
994 switch (battleStatus->curPartnerSubmenu) {
999 break;
1003 battleStatus->moveCategory = BTL_MENU_TYPE_RUN_AWAY;
1004 battleStatus->selectedMoveID = MOVE_RUN_AWAY;
1006 break;
1011 break;
1012 }
1013 }
1014 break;
1017 if (btl_main_menu_update() != 0) {
1021 }
1022 break;
1027 break;
1031 break;
1033 popupIndex = 0;
1034 for (i = 1; i < ARRAY_COUNT(PartnerIDFromMenuIndex); i++) {
1036 if (playerData->partners[partnerId].enabled) {
1039 popupMenu->enabled[popupIndex] = TRUE;
1040 popupMenu->userIndex[popupIndex] = partnerId;
1041 popupMenu->nameMsg[popupIndex] = popupProps->nameMsg;
1042 popupMenu->descMsg[popupIndex] = popupProps->battleDescMsg;
1043 popupMenu->value[popupIndex] = playerData->partners[partnerId].level;
1044 if (playerData->curPartner == partnerId) {
1046 popupMenu->enabled[popupIndex] = FALSE;
1047 }
1048 popupIndex++;
1049 }
1050 }
1051 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] < 0) {
1052 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] = 0;
1053 }
1055 popupMenu->numEntries = popupIndex;
1056 popupMenu->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
1057 popupMenu->dipMode = 0;
1058 popupMenu->titleNumber = 0;
1062 break;
1064 switch (popupMenu->result) {
1066 // do nothing while player is choosing from popup menu
1067 break;
1070 break;
1076 break;
1077 default:
1078 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CANCEL;
1079 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CHOSEN;
1080 battleStatus->lastSelectedPartner = popupMenu->userIndex[popupMenu->result - 1];
1082 battleStatus->selectedMoveID = MOVE_CHANGE_PARTNER;
1083 battleStatus->curTargetListFlags = TARGET_FLAG_2;
1084 battleStatus->moveArgument = battleStatus->lastSelectedPartner;
1085 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] = popupMenu->result - 1;
1090 break;
1091 }
1092 break;
1094 if ((battleStatus->curButtonsPressed & BUTTON_B) && popupMenu->result == POPUP_RESULT_CHOOSING) {
1099 } else {
1101 if (btl_main_menu_update() != 0) {
1102 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
1105 }
1106 }
1107 break;
1110 if (btl_main_menu_update() != 0) {
1112 }
1113 break;
1119 break;
1124 break;
1128 if (popupMenu->result != POPUP_RESULT_INVALID) {
1132 }
1133 break;
1134 }
1135}
@ BTL_MENU_TYPE_ABILITY
Definition enums.h:3832
@ BTL_MENU_TYPE_PARTNER_FOCUS
Definition enums.h:3837
@ ABILITY_GROUP_FOCUS
Definition enums.h:489
@ BTL_MENU_ENABLED_PARTNER_FOCUS
Definition enums.h:3847
@ BTL_MENU_ENABLED_ABILITIES
Definition enums.h:3844
@ BTL_MENU_IDX_PARTNER_ITEM
Definition enums.h:3821
s32 HudScript[]
Definition hud_element.h:9
void btl_state_update_partner_menu(void)
AnimID PartnerThinkAnims[]
void btl_init_menu_partner(void)
IconHudScriptPair PartnerMoveHudScripts[][5]
AnimID PartnerIdleAnims[]
@ BTL_SUBSTATE_UNUSED_CHANGE_PARTNER_TARGET_CANCEL
@ BTL_SUBSTATE_FOCUS_SELECTED
@ BTL_SUBSTATE_UNUSED_CHANGE_PARTNER_HANDOVER
@ BTL_SUBSTATE_ABILITIES_BUILD_MENU
@ BTL_SUBSTATE_CREATE_MAIN_MENU
@ BTL_SUBSTATE_MAIN_AWAIT_CANT_SWAP
@ BTL_SUBSTATE_ABILITIES_SHOW_ERROR
@ BTL_SUBSTATE_UNUSED_CHANGE_PARTNER_REOPEN_MENU
@ BTL_SUBSTATE_FOCUS_CANCELED
@ BTL_SUBSTATE_FOCUS_CHOOSING
@ BTL_SUBSTATE_CHANGE_PARTNER_HANDOVER
@ BTL_SUBSTATE_CHANGE_PARTNER_CHOOSING
@ BTL_SUBSTATE_CHANGE_PARTNER_REOPEN_MENU
@ BTL_SUBSTATE_UNUSED_CHANGE_BUILD_MENU
@ BTL_SUBSTATE_ABILITIES_HANDOVER
@ BTL_SUBSTATE_MAIN_CHOOSING
@ BTL_SUBSTATE_ITEMS_BUILD_MENU
@ BTL_SUBSTATE_STRATEGIES_HANDOVER
@ BTL_SUBSTATE_ABILITIES_CHOOSING
@ BTL_SUBSTATE_ITEMS_REOPEN_MENU
@ BTL_SUBSTATE_CHANGE_PARTNER_BUILD_MENU
@ BTL_SUBSTATE_STRATEGIES_TARGET_CHOSEN
@ BTL_SUBSTATE_STRATEGIES_REOPEN_MENU
@ BTL_SUBSTATE_ITEMS_TARGET_CANCEL
@ BTL_SUBSTATE_MAIN_BEGIN
@ BTL_SUBSTATE_FOCUS_BUILD_MENU
@ BTL_SUBSTATE_PERFORM_SWAP
@ BTL_SUBSTATE_CHANGE_PARTNER_ERROR
@ BTL_SUBSTATE_MAIN_TARGET_CANCEL
@ BTL_SUBSTATE_ITEMS_HANDOVER
@ BTL_SUBSTATE_ABILITIES_REOPEN_MENU
@ BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CANCEL
@ BTL_SUBSTATE_MAIN_SHOW_CANT_SWAP
@ BTL_SUBSTATE_ITEMS_CHOOSING
@ BTL_SUBSTATE_FOCUS_REOPEN_MENU
@ BTL_SUBSTATE_CHANGE_PARTNER_TARGET_CHOSEN
@ BTL_SUBSTATE_UNUSED_CHANGE_PARTNER_TARGET_CHOSEN
@ BTL_SUBSTATE_MAIN_TARGET_CHOSEN
@ BTL_SUBSTATE_MAIN_HANDOVER
@ BTL_SUBSTATE_FOCUS_HANDOVER
@ BTL_SUBSTATE_STRATEGIES_BUILD_MENU
@ BTL_SUBSTATE_UNUSED_CHANGE_PARTNER_SHOW_ERROR
@ BTL_SUBSTATE_ABILITIES_TARGET_CHOSEN
@ BTL_SUBSTATE_MAIN_REOPEN_MENU
@ BTL_SUBSTATE_UNUSED_CHANGE_PARTNER_CHOOSING
@ BTL_SUBSTATE_STRATEGIES_CHOOSING
@ BTL_SUBSTATE_STRATEGIES_TARGET_CANCEL
@ BTL_SUBSTATE_ITEMS_TARGET_CHOSEN
@ BTL_SUBSTATE_ABILITIES_TARGET_CANCEL

Referenced by btl_state_update_partner_menu(), btl_state_update_select_target(), and btl_update().

◆ btl_state_draw_partner_menu()

void btl_state_draw_partner_menu ( void )

Definition at line 1137 of file menu_partner.c.

1137 {
1138 switch (gBattleSubState) {
1180 break;
1181 }
1182}
@ BTL_SUBSTATE_UNKNOWN_2
@ BTL_SUBSTATE_UNKNOWN_4
@ BTL_SUBSTATE_UNKNOWN_5
@ BTL_SUBSTATE_UNKNOWN_1
@ BTL_SUBSTATE_UNKNOWN_3

Referenced by btl_draw_ui().

◆ btl_state_update_peach_menu()

void btl_state_update_peach_menu ( void )

Definition at line 24 of file menu_peach.c.

24 {
26 Actor* player = battleStatus->playerActor;
27 Actor* partner = battleStatus->partnerActor;
28 s32 selectedOption;
29 s32 initialPos;
31
32 switch (gBattleSubState) {
35 btl_cam_move(10);
37 // if the player (Peach) is in back, we need to swap her to the front before opening the menu
38 player->state.curPos.x = player->homePos.x;
39 player->state.curPos.z = player->homePos.z;
40 player->state.goalPos.x = partner->homePos.x;
41 player->state.goalPos.z = partner->homePos.z;
42 player->state.moveTime = 4;
43 player->state.angle = 0.0f;
45 } else {
47 }
48 break;
50 if (player->state.moveTime != 0) {
51 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
52 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
53 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
54 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
55 }
56
57 player->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
58 player->yaw = clamp_angle(-player->state.angle);
59 partner->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
60 partner->yaw = clamp_angle(-player->state.angle);
61 player->state.angle += 90.0f;
62
63 if (player->state.moveTime != 0) {
64 player->state.moveTime--;
65 break;
66 }
67
68 player->curPos.x = player->state.goalPos.x;
69 player->curPos.z = player->state.goalPos.z;
70 partner->curPos.x = player->state.curPos.x;
71 partner->curPos.z = player->state.curPos.z;
72 player->homePos.x = player->curPos.x;
73 player->homePos.z = player->curPos.z;
74 partner->homePos.x = partner->curPos.x;
75 partner->homePos.z = partner->curPos.z;
77 // fallthrough
82 if (partner != NULL) {
85 }
86
87 // add main menu entry for star powers
88 entryIdx = 0;
89 battleStatus->selectedMoveID = MOVE_NONE;
95 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STAR_POWERS)) {
99 }
100 entryIdx++;
101
102 initialPos = 0;
104 BattleMenu_PrevSelected = initialPos;
105 BattleMenu_WheelBase = 2 - initialPos;
106
109 } else {
111 }
112
116 break;
119 selectedOption = btl_main_menu_update();
120 if (BattleMenu_ChooseDelay != 0) {
122 break;
123 }
124 if (selectedOption != 0) {
126 battleStatus->curSubmenu = WheelOptionSubmenu[selectedOption - 1];
131 }
132 break;
134 if (btl_main_menu_update() != 0) {
135 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_TARGET_CANCEL;
136 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_TARGET_CHOSEN;
137 battleStatus->curTargetListFlags = gMoveTable[MOVE_PEACH_FOCUS].flags;
139 battleStatus->selectedMoveID = MOVE_PEACH_FOCUS;
142 }
143 break;
149 break;
152 break;
157 break;
160 break;
161 }
165 break;
166 }
167}
void btl_state_update_peach_menu(void)
Definition menu_peach.c:24
IconHudScriptPair PeachStarPowerHudScripts
Definition menu_peach.c:18
@ BTL_SUBSTATE_CREATE_MAIN_MENU
Definition menu_peach.c:15
@ BTL_SUBSTATE_TARGET_CANCEL
Definition menu_peach.c:10
@ BTL_SUBSTATE_SWAP_PEACH_FRONT
Definition menu_peach.c:14
@ BTL_SUBSTATE_AWAIT_CANT_SWITCH_POPUP
Definition menu_peach.c:13
@ BTL_SUBSTATE_TARGET_CHOSEN
Definition menu_peach.c:11
@ BTL_SUBSTATE_CHOOSE_TARGET
Definition menu_peach.c:9
@ BTL_SUBSTATE_CHOOSE_CATEGORY
Definition menu_peach.c:8
@ BTL_SUBSTATE_SHOW_CANT_SWITCH
Definition menu_peach.c:12
s32 PeachMenuMessages[]
Definition menu_peach.c:20

Referenced by btl_state_update_peach_menu(), btl_state_update_select_target(), and btl_update().

◆ btl_state_draw_peach_menu()

void btl_state_draw_peach_menu ( void )

Definition at line 169 of file menu_peach.c.

169 {
170 switch (gBattleSubState) {
173 break;
176 break;
179 break;
182 break;
185 break;
186 }
187}

Referenced by btl_draw_ui().

◆ btl_state_update_twink_menu()

void btl_state_update_twink_menu ( void )

Definition at line 27 of file menu_twink.c.

27 {
29 Actor* player = battleStatus->playerActor;
30 Actor* partner = battleStatus->partnerActor;
33 s32 initialPos;
35
36 switch (gBattleSubState) {
39
40 switch (player->debuff) {
46 case STATUS_KEY_STOP:
48 break;
49 default:
50 break;
51 }
52
53 if (player->stoneStatus == STATUS_KEY_STONE) {
55 }
56
57 if (player->koStatus == STATUS_KEY_KO) {
59 }
60
61 if (shouldSkipTurn) {
63 break;
64 }
65
67 btl_cam_move(10);
69 // if the player (Peach) is in front, we need to swap her to the back before opening the menu
70 player->state.curPos.x = player->homePos.x;
71 player->state.curPos.z = player->homePos.z;
72 player->state.goalPos.x = partner->homePos.x;
73 player->state.goalPos.z = partner->homePos.z;
74 player->state.moveTime = 4;
75 player->state.angle = 0.0f;
77 } else {
79 }
80 break;
82 if (player->state.moveTime != 0) {
83 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
84 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
85 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
86 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
87 }
88 player->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
89 player->yaw = clamp_angle(-player->state.angle);
90 partner->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
91 partner->yaw = clamp_angle(-player->state.angle);
92 player->state.angle += 90.0f;
93 if (player->state.moveTime != 0) {
94 player->state.moveTime--;
95 break;
96 }
97 player->curPos.x = player->state.goalPos.x;
98 player->curPos.z = player->state.goalPos.z;
99 partner->curPos.x = player->state.curPos.x;
100 partner->curPos.z = player->state.curPos.z;
101 player->homePos.x = player->curPos.x;
102 player->homePos.z = player->curPos.z;
103 partner->homePos.x = partner->curPos.x;
104 partner->homePos.z = partner->curPos.z;
106 // fallthrough
111 if (partner != NULL) {
114 }
115
116 // add main menu entry for star powers
117 entryIdx = 0;
118 battleStatus->selectedMoveID = MOVE_NONE;
124 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STAR_POWERS)) {
128 }
129 entryIdx++;
130
131 initialPos = 0;
133 BattleMenu_PrevSelected = initialPos;
134 BattleMenu_WheelBase = 2 - initialPos;
135
138 } else {
140 }
141
145 break;
149 if (BattleMenu_ChooseDelay != 0) {
151 break;
152 }
153 if (selection != 0) {
155 battleStatus->curSubmenu = WheelOptionSubmenu[selection - 1];
160 }
161 break;
163 if (btl_main_menu_update() != 0) {
164 battleStatus->cancelTargetMenuSubstate = BTL_SUBSTATE_TARGET_CANCEL;
165 battleStatus->acceptTargetMenuSubstate = BTL_SUBSTATE_TARGET_CHOSEN;
167 battleStatus->selectedMoveID = MOVE_TWINK_DASH;
168 battleStatus->moveArgument = 0;
169 battleStatus->curTargetListFlags = gMoveTable[MOVE_TWINK_DASH].flags;
171 }
172 break;
178 break;
181 break;
186 break;
189 break;
190 }
194 break;
195 }
196}
s32 TwinkMenuMessages[]
Definition menu_twink.c:23
IconHudScriptPair TwinkStarPowerHudScripts
Definition menu_twink.c:21
@ BTL_SUBSTATE_CREATE_MAIN_MENU
Definition menu_twink.c:18
@ BTL_SUBSTATE_TARGET_CANCEL
Definition menu_twink.c:11
@ BTL_SUBSTATE_AWAIT_CANT_SWITCH_POPUP
Definition menu_twink.c:16
@ BTL_SUBSTATE_TARGET_CHOSEN
Definition menu_twink.c:12
@ BTL_SUBSTATE_SWAP_PEACH_BACK
Definition menu_twink.c:17
@ BTL_SUBSTATE_CHOOSE_TARGET
Definition menu_twink.c:9
@ BTL_SUBSTATE_CHOOSE_CATEGORY
Definition menu_twink.c:8
@ BTL_SUBSTATE_SHOW_CANT_SWITCH
Definition menu_twink.c:15
void btl_state_update_twink_menu(void)
Definition menu_twink.c:27

Referenced by btl_state_update_select_target(), btl_state_update_twink_menu(), and btl_update().

◆ btl_state_draw_twink_menu()

void btl_state_draw_twink_menu ( void )

Definition at line 198 of file menu_twink.c.

198 {
199 switch (gBattleSubState) {
202 break;
205 break;
208 break;
211 break;
214 break;
219 break;
220 }
221}
@ BTL_SUBSTATE_UNUSED_7
Definition menu_twink.c:14
@ BTL_SUBSTATE_UNUSED_6
Definition menu_twink.c:13
@ BTL_SUBSTATE_UNUSED_3
Definition menu_twink.c:10

Referenced by btl_draw_ui().

◆ btl_state_update_select_target()

void btl_state_update_select_target ( void )

Definition at line 13 of file select_target.c.

13 {
15 Actor* actor;
16 s32 targetListLength;
17 s32 selectedTargetIndex;
19 s8* targetIndexList;
21 s32 i;
22
24 actor = battleStatus->playerActor;
25 } else {
26 actor = battleStatus->partnerActor;
27 }
28 targetListLength = actor->targetListLength;
29 selectedTargetIndex = actor->selectedTargetIndex;
30
32 targetIndexList = actor->targetIndexList;
33 switch (gBattleSubState) {
38
39 // prepare the action command tip for the selected move
41 if (battleStatus->selectedMoveID != MOVE_NONE) {
42 s8 actionTip = gMoveTable[battleStatus->selectedMoveID].actionTip;
43
44 if (actionTip >= 0) {
46 }
47 }
48 }
49
50 // create the target list
52 targetListLength = actor->targetListLength;
53 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
54 targetIndexList = actor->targetIndexList;
55 for (i = 0; i < targetListLength; i++) {
56 target = &actor->targetData[targetIndexList[i]];
58 actor->selectedTargetIndex = i;
59 break;
60 }
61 }
62 }
63
64 // when TARGET_FLAG_OVERRIDE is set, skip selecting a target and begin executing the move
65 if (battleStatus->curTargetListFlags & TARGET_FLAG_OVERRIDE) {
67 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
70 } else {
72 }
74 } else {
75 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
78 } else {
80 }
82 }
83 break;
84 }
85
86 // if the target list is empty, skip selecting a target and begin executing the move
87 if (targetListLength == 0) {
89 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
92 } else {
94 }
96 } else {
97 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
100 } else {
102 }
104 }
105 break;
106 }
107
108 // create the HUD elements for the target pointers
109 for (i = 0; i < targetListLength; i++) {
114 }
116 break;
118 // animate the target name sliding into view
123 }
124 }
125
126 if (battleStatus->curButtonsPressed & BUTTON_B) {
129 break;
130 }
131
132 if (battleStatus->curButtonsPressed & BUTTON_A) {
137 break;
138 }
139
141 if (battleStatus->curButtonsDown & (BUTTON_Z | BUTTON_R)) {
143 break;
144 }
145
146 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
147 s32 oldSelectedTargetIndex = selectedTargetIndex;
148
149 if (battleStatus->curButtonsHeld & BUTTON_STICK_LEFT) {
150 selectedTargetIndex--;
151 }
152 if (battleStatus->curButtonsHeld & BUTTON_STICK_RIGHT) {
153 selectedTargetIndex++;
154 }
155 if (selectedTargetIndex < 0) {
156 selectedTargetIndex = targetListLength - 1;
157 }
158 if (selectedTargetIndex >= targetListLength) {
159 selectedTargetIndex = 0;
160 }
161 if (selectedTargetIndex != oldSelectedTargetIndex) {
163
164 target = &actor->targetData[targetIndexList[selectedTargetIndex]];
165 actorFlags = get_actor(target->actorID)->flags;
167
170 } else {
172 }
174 }
175 actor->selectedTargetIndex = selectedTargetIndex;
176 }
177 break;
180 target = &actor->targetData[targetIndexList[actor->selectedTargetIndex]];
181 actor->targetActorID = target->actorID;
182 actor->targetPartID = target->partID;
183
184 // free the HUD elements for the target pointers
185 for (i = 0; i < targetListLength; i++) {
187 }
188
189 // begin executing the move
191 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
194 } else {
196 }
198 } else {
199 gBattleSubState = battleStatus->acceptTargetMenuSubstate;
202 } else {
204 }
206 }
207 break;
209 // free the HUD elements for the target pointers
210 for (i = 0; i < targetListLength; i++) {
212 }
213
216
217 if (battleStatus->itemUsesLeft != 0) {
219 gBattleSubState = battleStatus->cancelTargetMenuSubstate;
222 } else {
224 }
227 gBattleSubState = battleStatus->cancelTargetMenuSubstate;
230 } else {
232 }
233 } else {
235 gBattleSubState = battleStatus->cancelTargetMenuSubstate;
238 } else {
240 }
241 }
242 break;
243 }
244}
HudScript HES_HandPointDownLoop
Definition 5B320.c:173
HudScript HES_HandPointLeftLoop
Definition 5B320.c:234
s32 BattleMenu_TargetPointerAlpha
s32 BattleMenu_TargetHudElems[]
s32 BattleMenu_TargetNameOffsetX
s8 selectedTargetIndex
struct SelectableTarget targetData[24]
s32 HudElemID
s8 targetIndexList[24]
@ BUTTON_A
Definition enums.h:2776
@ BUTTON_R
Definition enums.h:2767
@ BUTTON_STICK_LEFT
Definition enums.h:2779
@ BUTTON_STICK_RIGHT
Definition enums.h:2780
@ BTL_MSG_ACTION_TIP_PRESS_BEFORE_LANDING
Definition enums.h:3747
@ TARGET_FLAG_OVERRIDE
Definition enums.h:1897
@ TARGET_FLAG_SELECT_ONE
Definition enums.h:1875
@ BATTLE_STATE_PARTNER_MOVE
Definition enums.h:3683
@ SOUND_MENU_BACK
Definition enums.h:704
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:701
@ SOUND_MENU_NEXT
Definition enums.h:703
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
Definition enums.h:3365
@ ACTOR_PART_FLAG_DEFAULT_TARGET
Definition enums.h:3387
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:923
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_depth(s32 id, s32 z)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_free(s32 id)
@ BTL_SUBSTATE_CHOOSE
@ BTL_SUBSTATE_DONE
@ BTL_SUBSTATE_CANCEL

Referenced by btl_update().

◆ btl_state_draw_select_target()

void btl_state_draw_select_target ( void )

Definition at line 246 of file select_target.c.

246 {
248 s32 msgID;
249 s32 msgX;
250 s32 msgY;
251 s32 targetListLength;
253 s32 actorID;
257 s32 id;
258 s32 i;
260 s32 xOffset, yOffset;
261 f32 targetX, targetY, targetZ;
263 s32 selectedTargetIndex;
264 s8* targetIndexList;
265
267 choosingActor = battleStatus->playerActor;
268 } else {
269 choosingActor = battleStatus->partnerActor;
270 }
271
272 targetListLength = choosingActor->targetListLength;
273 target = choosingActor->targetData;
274 selectedTargetIndex = choosingActor->selectedTargetIndex;
275 targetIndexList = choosingActor->targetIndexList;
276
277 if (targetListLength == 0) {
278 return;
279 }
280
281 // draw target pointers
282 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
283 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
284 enemyActor = get_actor(target->actorID);
286 targetX = target->truePos.x;
287 targetY = target->truePos.y;
288 targetZ = target->truePos.z;
289
290 // select target pointer style based on target actor orientation
291 if (enemyActor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
292 xOffset = 16;
293 yOffset = 2;
296 }
297 } else {
298 xOffset = 5;
299 yOffset = -11;
302 }
303 }
304
305 get_screen_coords(CAM_BATTLE, targetX, targetY, targetZ, &screenX, &screenY, &screenZ);
306 hud_element_set_render_pos(id, screenX + xOffset, screenY + yOffset);
308 } else {
309 for (i = 0; i < targetListLength; i++) {
310 target = &choosingActor->targetData[targetIndexList[i]];
311 enemyActor = get_actor(target->actorID);
313 targetX = target->truePos.x;
314 targetY = target->truePos.y;
315 targetZ = target->truePos.z;
316
317 // select target pointer style based on target actor orientation
318 if (enemyActor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
319 xOffset = 16;
320 yOffset = 2;
323 }
324 } else {
325 xOffset = 5;
326 yOffset = -11;
329 }
330 }
331
332 get_screen_coords(CAM_BATTLE, targetX, targetY, targetZ, &screenX, &screenY, &screenZ);
333 hud_element_set_render_pos(id, screenX + xOffset, screenY + yOffset);
335 }
336 }
337
339 screenX = 52;
340 screenY = 64;
343 }
344
345 // get target name width
346 if ((battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) || targetListLength == 1) {
347 actorID = target->actorID;
348 if (actorID == ACTOR_PLAYER) {
350 } else if (actorID == ACTOR_PARTNER) {
352 } else {
353 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
354 enemyActor = get_actor(target->actorID);
356 if (msgID == MSG_NONE) {
357 msgID = bActorNames[enemyActor->actorType];
358 }
359 nameWidth = get_msg_width(msgID, 0) + 10;
360 }
361 } else {
362 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
363 actorID = target->actorID;
364 if (actorID == ACTOR_PLAYER) {
366 } else if (actorID == ACTOR_PARTNER) {
368 } else {
370 }
371 }
372
373 // draw target name box
375 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
376
377 // draw target name text
378 screenX += 4;
379 screenY += 2;
380 if ((battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) || targetListLength == 1) {
381 actorID = target->actorID;
382 if (actorID == ACTOR_PLAYER) {
384 } else if (actorID == ACTOR_PARTNER) {
386 } else {
387 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
388 enemyActor = get_actor(target->actorID);
390 if (msgID == MSG_NONE) {
391 msgID = bActorNames[enemyActor->actorType];
392 }
394 }
395 } else {
396 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
397 actorID = target->actorID;
398 if (actorID == ACTOR_PLAYER) {
400 } else if (actorID == ACTOR_PARTNER) {
402 } else {
404 }
405 }
406}
s32 PartnerNameMessages[]
ActorPartBlueprint * staticData
#define get_msg_width
#define draw_msg
#define draw_box
@ WINDOW_STYLE_4
Definition enums.h:5959
@ MSG_PAL_36
Definition enums.h:5044
@ PARTNER_TWINK
Definition enums.h:2930
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:409
void hud_element_set_alpha(s32 id, s32 opacity)
HudScript * hud_element_get_script(s32 id)
#define SCREEN_WIDTH
Definition macros.h:109
#define SCREEN_HEIGHT
Definition macros.h:110
EXTERN_C s32 bActorNames[]
Definition battle.h:105

Referenced by btl_draw_ui().

◆ btl_state_update_celebration()

void btl_state_update_celebration ( void )

Definition at line 508 of file level_up.c.

508 {
511 Actor* player = battleStatus->playerActor;
512 Actor* partner = battleStatus->partnerActor;
516 s32 x, y, z;
517 s32 width;
519
520 Evt* takeTurnScript;
521 Evt* script;
522
525
526 s32 deltaSP;
527 s32 prevSP;
528
529 s32 i;
530 s32 j;
531
533
534 switch (gBattleSubState) {
536 if (battleStatus->pendingStarPoints <= 0) {
538 EndBattleRewardTotal = battleStatus->totalStarPoints * 100;
539 pendingLevelUps = 0;
540 D_8029FB50 = 0;
541 bFadeToBlackAmt = 0;
545
546 prevSP = playerData->starPoints + battleStatus->totalStarPoints;
547 if (prevSP > 99) {
548 bgm_set_song(0, SONG_LEVEL_UP, 0, 250, 8);
549 } else {
550 bgm_set_song(0, SONG_BATTLE_END, 0, 250, 8);
551 }
552
559 }
560 break;
562 if (CelebrateSubstateTime != 0) {
564 } else if (btl_cam_is_moving_done()) {
568 // divide reward into 20 increments
571 player->takeTurnScript = script;
573 player->takeTurnScriptID = script->id;
574 script->owner1.actorID = ACTOR_PLAYER;
576 }
577 break;
579 if (CelebrateSubstateTime == 0) {
580 if (battleStatus->totalStarPoints != 0) {
581 // determine the remaining star point reward after this step and give the difference to the player
583 prevSP = battleStatus->totalStarPoints;
584 battleStatus->totalStarPoints = EndBattleRewardTotal / 100;
585 deltaSP = prevSP - battleStatus->totalStarPoints;
586 if (deltaSP > 0) {
588 }
589
590 playerData->starPoints += deltaSP;
591 bFadeToBlackAmt++; // ??
592 if (EndBattleRewardStep == 0 && battleStatus->totalStarPoints != 0) {
593 playerData->starPoints++;
594 }
595 }
596 if (playerData->level >= 27) {
597 playerData->starPoints = 0;
598 }
599 if (playerData->starPoints >= 100) {
600 pendingLevelUps = 1;
601 playerData->starPoints -= 100;
602 }
603 if (playerData->level + pendingLevelUps == 27) {
604 playerData->starPoints = 0;
605 }
606 if (battleStatus->totalStarPoints == 0) {
607 if (EndBattleRewardStep == 0) {
610 if (partner != NULL) {
612 }
613 battleStatus->battlePhase = PHASE_CELEBRATE;
615 player->takeTurnScript = script;
616 player->takeTurnScriptID = script->id;
617 script->owner1.actorID = ACTOR_PLAYER;
618 if (partner != NULL) {
619 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
620 partner->takeTurnScript = script;
621 partner->takeTurnScriptID = script->id;
622 script->owner1.actorID = ACTOR_PARTNER;
623 }
626 } else {
628 }
629 }
630 } else {
632 }
633 break;
635 if (CelebrateSubstateTime == 0) {
636 if (pendingLevelUps == 0) {
638 } else {
640 }
641 break;
642 }
644 break;
646 if (CelebrateStateTime >= 99) {
647 playerData->level++;
649 btl_cam_move(5);
654 }
655 break;
663 mdl_set_shroud_tint_params(0, 0, 0, 0);
664 break;
666 if (CelebrateSubstateTime == 18) {
667 playerData->curHP = playerData->curMaxHP;
668 playerData->curFP = playerData->curMaxFP;
669 x = player->curPos.x + 0.0f;
670 y = player->curPos.y + 35.0f;
671 z = player->curPos.z;
672 fx_recover(0, x, y, z, playerData->curHP);
673 x = player->curPos.x + 20.0f;
674 y = player->curPos.y + 25.0f;
675 z = player->curPos.z;
676 fx_recover(1, x, y, z, playerData->curFP);
677 playerData->starPower = playerData->maxStarPower * SP_PER_BAR;
678 }
679
680 if (CelebrateSubstateTime != 0) {
682 if (CelebrateSubstateTime < 10) {
683 mdl_set_shroud_tint_params(0, 0, 0, ((10 - CelebrateSubstateTime) * 16) & 0xF0);
684 }
685 } else {
690
695
700
705
710
711 for (i = 1; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
716 }
717
722
723 for (i = 1; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
728 }
729
734
735 for (i = 1; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
740 }
741
745
746 if (playerData->hardMaxFP != 50) {
747 // current FP
748 tensDigit = playerData->curMaxFP / 10;
749 onesDigit = playerData->curMaxFP % 10;
752 if (tensDigit != 0) {
754 }
756 hud_element_set_render_pos(hid, x - 14, y + 46);
757
762 hud_element_set_render_pos(hid, x - 8, y + 46);
763
768 hud_element_set_render_pos(hid, x - 3, y + 46);
769
770 // upgraded FP
771 tensDigit = (playerData->curMaxFP + 5) / 10;
772 onesDigit = (playerData->curMaxFP + 5) % 10;
775 if (tensDigit != 0) {
777 }
779 hud_element_set_render_pos(hid, x + 3, y + 46);
780
785 hud_element_set_render_pos(hid, x + 10, y + 46);
786 } else {
787 // upgraded FP only
789 tensDigit = playerData->curMaxFP / 10;
790 onesDigit = playerData->curMaxFP % 10;
792 if (tensDigit != 0) {
794 }
796 hud_element_set_render_pos(hid, x - 6, y + 46);
797
802 hud_element_set_render_pos(hid, x + 2, y + 46);
804 }
805
813 hud_element_set_render_pos(hid, x + 17, y + 46);
814 }
815
816 if (playerData->hardMaxHP != 50) {
817 // current HP
818 tensDigit = playerData->curMaxHP / 10;
819 onesDigit = playerData->curMaxHP % 10;
820
823 if (tensDigit != 0) {
825 }
827 hud_element_set_render_pos(hid, x - 14, y + 46);
828
833 hud_element_set_render_pos(hid, x - 8, y + 46);
834
839 hud_element_set_render_pos(hid, x - 3, y + 46);
840
841 tensDigit = (playerData->curMaxHP + 5) / 10;
842 onesDigit = (playerData->curMaxHP + 5) % 10;
843
846 if (tensDigit != 0) {
848 }
850 hud_element_set_render_pos(hid, x + 3, y + 46);
851
856 hud_element_set_render_pos(hid, x + 10, y + 46);
857 } else {
858 tensDigit = playerData->curMaxHP / 10;
859 onesDigit = playerData->curMaxHP % 10;
860
863 if (tensDigit != 0) {
865 }
867 hud_element_set_render_pos(hid, x - 6, y + 46);
868
873 hud_element_set_render_pos(hid, x + 2, y + 46);
875 }
876
884 hud_element_set_render_pos(hid, x + 17, y + 46);
885 }
886
887 if (playerData->maxBP != 30) {
888 tensDigit = playerData->maxBP / 10;
889 onesDigit = playerData->maxBP % 10;
890
893 if (tensDigit != 0) {
895 }
897 hud_element_set_render_pos(hid, x - 14, y + 46);
898
903 hud_element_set_render_pos(hid, x - 8, y + 46);
904
909 hud_element_set_render_pos(hid, x - 3, y + 46);
910
911 tensDigit = (playerData->maxBP + 3) / 10;
912 onesDigit = (playerData->maxBP + 3) % 10;
913
916 if (tensDigit != 0) {
918 }
920 hud_element_set_render_pos(hid, x + 3, y + 46);
921
926 hud_element_set_render_pos(hid, x + 10, y + 46);
927 } else {
932 hud_element_set_render_pos(hid, x - 6, y + 46);
933
938 hud_element_set_render_pos(hid, x + 2, y + 46);
940 }
941
945 hud_element_set_tint(hid, 255, 255, 255);
947 hud_element_set_transform_rotation(hid, 0.0f, 0.0f, 180.0f);
948 hud_element_set_transform_scale(hid, 1.0f, 1.5f, 1.0f);
951
955 battleStatus->curSubmenu = MENU_FP;
956
959 }
960 break;
964 x -= 20;
966
967 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
970 x -= 20;
972 }
973
976 y -= 20;
978
981 y -= 20;
983
984 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
987 y -= 20;
989 }
990
993 x += 20;
995
996 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
999 x += 20;
1001 }
1002
1004 if (CelebrateSubstateTime == 0) {
1005 hud_element_set_tint(hid, 128, 128, 128);
1006#if VERSION_JP
1007 x = 32;
1008 y = 186;
1010#else
1011 x = 20;
1012 y = 186;
1014#endif
1017 }
1018 break;
1020 if (battleStatus->curButtonsPressed & BUTTON_A) {
1021 if (!CantLevelUpStat[battleStatus->curSubmenu]) {
1025 } else {
1028 }
1029 break;
1030 }
1031
1032 newSubmenu = currentSubmenu = battleStatus->curSubmenu;
1033 if (battleStatus->curButtonsHeld & BUTTON_STICK_LEFT) {
1034 newSubmenu--;
1035 }
1036 if (battleStatus->curButtonsHeld & BUTTON_STICK_RIGHT) {
1037 newSubmenu++;
1038 }
1039 if (newSubmenu < 0) {
1040 newSubmenu = 0;
1041 }
1042 if (newSubmenu > 2) {
1043 newSubmenu = 2;
1044 }
1045 if (newSubmenu != currentSubmenu) {
1047 battleStatus->curSubmenu = newSubmenu;
1048 }
1049
1051 if (CelebrateStateTime > 100) {
1052 fx_confetti(3, 0.0f, 100.0f, 0.0f, 1.0f, 120);
1054 }
1055 break;
1059
1060 switch (battleStatus->curSubmenu) {
1061 case 0:
1062 playerData->hardMaxHP += 5;
1063 playerData->curMaxHP += 5;
1064 playerData->curHP += 5;
1065 if (playerData->curMaxHP > 75) {
1066 playerData->curMaxHP = 75;
1067 }
1068 if (playerData->curHP > playerData->curMaxHP) {
1069 playerData->curHP = playerData->curMaxHP;
1070 }
1071 player->maxHP = playerData->curMaxHP;
1072 player->curHP = playerData->curHP;
1073 break;
1074 case 1:
1075 playerData->hardMaxFP += 5;
1076 playerData->curMaxFP += 5;
1077 playerData->curFP += 5;
1078 if (playerData->curMaxFP > 75) {
1079 playerData->curMaxFP = 75;
1080 }
1081 if (playerData->curFP > playerData->curMaxFP) {
1082 playerData->curFP = playerData->curMaxFP;
1083 }
1084 break;
1085 case 2:
1086 playerData->maxBP += 3;
1087 if (playerData->maxBP > 30) {
1088 playerData->maxBP = 30;
1089 }
1090 break;
1091 }
1092
1094
1095 if (partner != NULL) {
1096 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
1097 partner->takeTurnScript = script;
1098 partner->takeTurnScriptID = script->id;
1099 script->owner1.actorID = ACTOR_PARTNER;
1100 }
1102 bgm_set_song(0, -1, 0, 2000, 8);
1103 }
1104 bFadeToBlackAmt = 0;
1106 break;
1108 if ((gGameStatusPtr->frameCounter % 2) != 0) {
1109 switch (battleStatus->curSubmenu) {
1110 case MENU_HP:
1112 break;
1113 case MENU_FP:
1116 break;
1117 case MENU_BP:
1119 break;
1120 }
1121 } else {
1122 switch (battleStatus->curSubmenu) {
1123 case MENU_HP:
1125 break;
1126 case MENU_FP:
1129 break;
1130 case MENU_BP:
1132 break;
1133 }
1134 }
1135 if (bFadeToBlackAmt == 255) {
1137 break;
1138 }
1139 bFadeToBlackAmt += 10;
1140 if (bFadeToBlackAmt > 255) {
1141 bFadeToBlackAmt = 255;
1142 }
1143 break;
1149
1150 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs); i++) {
1151 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); j++) {
1153 }
1154 }
1155
1157 mdl_set_shroud_tint_params(0, 0, 0, 0);
1160 break;
1162 width = get_msg_width(MSG_Menus_CantIncrease, 0) + 31;
1163 x = 160 - (width / 2);
1164 y = 80;
1169 break;
1173 }
1174 if (CelebrateSubstateTime != 0) {
1176 break;
1177 }
1180 break;
1182 if (battleStatus->curButtonsPressed & (BUTTON_A | BUTTON_B)) {
1183 CelebrateStateTime = 99;
1184#if VERSION_JP
1186#endif
1187 }
1188 if (CelebrateStateTime >= 99) {
1190 bgm_set_song(0, -1, 0, 1500, 8);
1191 }
1192 bFadeToBlackAmt = 0;
1193 btl_cam_set_params(TRUE, 270, 100, 8, 0, 0x2400, 100);
1195 if (partner != NULL) {
1197 }
1200 break;
1201 }
1202 break;
1204 if (CelebrateSubstateTime != 0) {
1206 if (CelebrateSubstateTime == 0) {
1208 }
1209 } else {
1210 player->yaw = 0.0f;
1211 if (partner != NULL) {
1212 partner->yaw = 0.0f;
1213 }
1214
1215 player->curPos.x += 4.0f;
1216 if (partner != NULL) {
1217 partner->curPos.x += 4.0f;
1218 }
1219 }
1220 if (bFadeToBlackAmt == 255) {
1222 break;
1223 }
1224 bFadeToBlackAmt += 20;
1225 if (bFadeToBlackAmt > 255) {
1226 bFadeToBlackAmt = 255;
1227 }
1228 break;
1229 case BTL_SUBSTATE_DONE:
1230 if (does_script_exist(player->takeTurnScriptID)) {
1232 }
1233 if (partner != NULL && does_script_exist(partner->takeTurnScriptID)) {
1234 kill_script_by_ID(partner->takeTurnScriptID);
1235 }
1238 break;
1239 }
1241}
s32 D_80284154[]
Definition level_up.c:183
@ LVL_UP_FP
Definition level_up.c:53
@ LVL_UP_HP
Definition level_up.c:54
@ LVL_UP_BP
Definition level_up.c:55
IconHudScriptPair gItemHudScripts[]
HudScript HES_level_up_small_blue_arrow
Definition level_up.c:485
BSS s32 EndBattleRewardTotal
Definition level_up.c:78
BSS HudElemID LevelUpSelectTextID
Definition level_up.c:72
BSS s32 EndBattleRewardIncrement
Definition level_up.c:79
@ BTL_SUBSTATE_TALLY_STAR_POINTS
Definition level_up.c:27
@ BTL_SUBSTATE_SKIPPABLE_END_DELAY
Definition level_up.c:39
@ BTL_SUBSTATE_LEVEL_UP_DESTROY_HUD
Definition level_up.c:36
@ BTL_SUBSTATE_WALK_AWAY
Definition level_up.c:40
@ BTL_SUBSTATE_LOAD_STAR_POINTS
Definition level_up.c:26
@ BTL_SUBSTATE_LEVEL_UP_SHOW_HUD
Definition level_up.c:32
@ BTL_SUBSTATE_LEVEL_UP_INVALID
Definition level_up.c:37
@ BTL_SUBSTATE_LEVEL_UP_UPGRADE
Definition level_up.c:34
@ BTL_SUBSTATE_LEVEL_UP_CREATE_HUD
Definition level_up.c:31
@ BTL_SUBSTATE_LEVEL_UP_BEGIN
Definition level_up.c:30
@ BTL_SUBSTATE_POST_STAR_POINTS
Definition level_up.c:28
@ BTL_SUBSTATE_LEVEL_UP_INVALID_DELAY
Definition level_up.c:38
@ BTL_SUBSTATE_LEVEL_UP_CHOOSE
Definition level_up.c:33
@ BTL_SUBSTATE_LEVEL_UP_LOAD
Definition level_up.c:29
@ BTL_SUBSTATE_LEVEL_UP_FADE_OUT
Definition level_up.c:35
@ BTL_SUBSTATE_DONE
Definition level_up.c:41
BSS HudElemID LevelUpStatEmblemIDs[4]
Definition level_up.c:69
HudScript HES_ProjectorBeam
HudScript HES_level_up_select_one_to_upgrade
Definition level_up.c:487
@ MENU_HP
Definition level_up.c:46
@ MENU_FP
Definition level_up.c:47
@ MENU_BP
Definition level_up.c:48
HudScript HES_level_up_leaves
Definition level_up.c:415
HudScript HES_level_up_badge
Definition level_up.c:416
HudScript * level_up_small_digit_scripts[3][10]
Definition level_up.c:258
BSS Evt * LevelUpScriptPtr
Definition level_up.c:82
EvtScript EVS_ShowLevelUp
Definition level_up.c:479
HudScript HES_level_up_small_red_arrow
Definition level_up.c:462
s32 bFadeToBlackAmt
Definition level_up.c:181
BSS HudElemID LevelUpSpotlightID
Definition level_up.c:71
HudScript HES_level_up_heart
Definition level_up.c:412
BSS s32 CelebrateSubstateTime
Definition level_up.c:74
BSS HudElemID LevelUpStatTextIDs[3][7]
Definition level_up.c:70
void draw_content_cant_increase_popup(void *data, s32 posX, s32 posY)
Definition level_up.c:1535
HudScript HES_level_up_flower
Definition level_up.c:414
BSS s32 D_8029FB50
Definition level_up.c:75
EvtScript EVS_ShowStarpoints
Definition level_up.c:371
BSS s32 pendingLevelUps
Definition level_up.c:80
BSS s32 EndBattleRewardsDone
Definition level_up.c:81
BSS s32 LevelUpSelectTextVelX
Definition level_up.c:86
BSS s32 CantLevelUpStat[3]
Definition level_up.c:77
void draw_content_level_up_textbox(void *data, s32 posX, s32 posY)
Definition level_up.c:1495
HudScript HES_level_up_small_green_arrow
Definition level_up.c:439
BSS s32 EndBattleRewardStep
Definition level_up.c:76
BSS s32 CelebrateStateTime
Definition level_up.c:84
@ LVL_UP_BONUS
Definition level_up.c:66
@ LVL_UP_TITLE
Definition level_up.c:60
@ LVL_UP_NEXT_ONES
Definition level_up.c:65
@ LVL_UP_ARROW
Definition level_up.c:63
@ LVL_UP_CUR_TENS
Definition level_up.c:61
@ LVL_UP_CUR_ONES
Definition level_up.c:62
@ LVL_UP_NEXT_TENS
Definition level_up.c:64
BSS s32 LevelUpSelectTextOffsetX
Definition level_up.c:85
HudScript * HES_LevelUpDigits[3][10]
Definition level_up.c:219
BSS s32 LevelUpScriptID
Definition level_up.c:83
HudScript * levelup_stat_scripts[3]
Definition level_up.c:213
@ ENV_TINT_SHROUD
Definition enums.h:3972
@ WINDOW_PRIORITY_10
Definition enums.h:3218
@ WINDOW_PRIORITY_20
Definition enums.h:3220
@ PHASE_CELEBRATE
Definition enums.h:2095
@ SONG_LEVEL_UP
Definition enums.h:424
@ SONG_BATTLE_END
Definition enums.h:421
@ WINDOW_UPDATE_SHOW
Definition enums.h:4896
@ BS_FLAGS2_AWARDING_STAR_POINTS
Definition enums.h:3637
@ BTL_CAM_VICTORY
Definition enums.h:4430
@ SOUND_ID_TRIGGER_CHANGE_SOUND
Definition enums.h:532
@ ABILITY_FP_PLUS
Definition enums.h:448
@ ABILITY_HP_PLUS
Definition enums.h:440
@ SOUND_LRAW_CHEERING
Definition enums.h:1154
@ SOUND_JINGLE_WON_BATTLE
Definition enums.h:712
@ SOUND_STAR_POINT_PICKUP
Definition enums.h:929
@ SOUND_LOOP_CHEERING
Definition enums.h:1592
@ WIN_BTL_POPUP
Definition enums.h:4835
@ WIN_BTL_DESC_BOX
Definition enums.h:4834
void btl_cam_set_params(b16, s16, s16, s16, s32, s32, s32)
Definition camera.c:1939
void mdl_set_all_tint_type(s32)
Definition model.c:4519
void kill_script_by_ID(s32 id)
void set_window_properties(s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void *drawContents, void *drawContentsArg, s8 parent)
Definition windows.c:373
void hud_element_get_render_pos(s32 id, s32 *x, s32 *y)
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_create_transform_B(s32 id)
void hud_element_set_tint(s32 id, s32 r, s32 g, s32 b)
void hud_element_set_transform_rotation(s32 id, f32 x, f32 y, f32 z)
void hud_element_set_transform_rotation_pivot(s32 id, s32 dx, s32 dy)
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_set_transform_scale(s32 id, f32 x, f32 y, f32 z)
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:72
@ HUD_ELEMENT_FLAG_MANUAL_RENDER
Definition hud_element.h:78
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:86
void mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
Definition model.c:3905
u8 * gBackgroundTintModePtr
Definition model.c:105

Referenced by btl_update().

◆ btl_state_draw_celebration()

void btl_state_draw_celebration ( void )

Definition at line 1294 of file level_up.c.

1294 {
1296 s32 rotZ;
1297 s32 id;
1298 s32 i;
1299 s32 j;
1300
1301 switch (gBattleSubState) {
1304 id = LevelUpStatEmblemIDs[0];
1305 hud_element_set_tint(id, 128, 128, 128);
1307 id = LevelUpStatEmblemIDs[3];
1308 hud_element_set_tint(id, 128, 128, 128);
1310 id = LevelUpStatEmblemIDs[1];
1311 hud_element_set_tint(id, 128, 128, 128);
1313 id = LevelUpStatEmblemIDs[2];
1314 hud_element_set_tint(id, 128, 128, 128);
1316
1317 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs); j++) {
1318 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1319 id = LevelUpStatTextIDs[j][i];
1320
1321 hud_element_set_tint(id, 128, 128, 128);
1323 }
1324 }
1325 break;
1329 switch (battleStatus->curSubmenu) {
1330 case MENU_HP:
1331 rotZ = 152;
1332 hud_element_set_tint(LevelUpStatEmblemIDs[0], 255, 255, 255);
1333 hud_element_set_tint(LevelUpStatEmblemIDs[3], 128, 128, 128);
1334 hud_element_set_tint(LevelUpStatEmblemIDs[1], 128, 128, 128);
1335 hud_element_set_tint(LevelUpStatEmblemIDs[2], 128, 128, 128);
1336
1337 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1339
1340 hud_element_set_tint(id, 128, 128, 128);
1341 }
1342
1343 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
1345
1346 hud_element_set_tint(id, 255, 255, 255);
1347 }
1348
1349 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
1351
1352 hud_element_set_tint(id, 128, 128, 128);
1353 }
1354
1355 id = LevelUpStatEmblemIDs[0];
1358 }
1359 id = LevelUpStatEmblemIDs[3];
1362 }
1363 id = LevelUpStatEmblemIDs[1];
1366 }
1367 id = LevelUpStatEmblemIDs[2];
1370 }
1371 break;
1372 case MENU_FP:
1373 rotZ = 180;
1374 hud_element_set_tint(LevelUpStatEmblemIDs[0], 128, 128, 128);
1375 hud_element_set_tint(LevelUpStatEmblemIDs[3], 255, 255, 255);
1376 hud_element_set_tint(LevelUpStatEmblemIDs[1], 255, 255, 255);
1377 hud_element_set_tint(LevelUpStatEmblemIDs[2], 128, 128, 128);
1378
1379 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1381
1382 hud_element_set_tint(id, 255, 255, 255);
1383 }
1384
1385 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
1387
1388 hud_element_set_tint(id, 128, 128, 128);
1389 }
1390
1391 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
1393
1394 hud_element_set_tint(id, 128, 128, 128);
1395 }
1396 break;
1397 case MENU_BP:
1398 default:
1399 rotZ = 208;
1400 hud_element_set_tint(LevelUpStatEmblemIDs[0], 128, 128, 128);
1401 hud_element_set_tint(LevelUpStatEmblemIDs[3], 128, 128, 128);
1402 hud_element_set_tint(LevelUpStatEmblemIDs[1], 128, 128, 128);
1403 hud_element_set_tint(LevelUpStatEmblemIDs[2], 255, 255, 255);
1404
1405 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1407
1408 hud_element_set_tint(id, 128, 128, 128);
1409 }
1410
1411 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
1413
1414 hud_element_set_tint(id, 128, 128, 128);
1415 }
1416
1417 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
1419
1420 hud_element_set_tint(id, 255, 255, 255);
1421 }
1422 break;
1423 }
1424
1430
1431 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs); j++) {
1432 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1434 }
1435 }
1436
1438 id = LevelUpSpotlightID;
1439 hud_element_set_transform_rotation(id, 0.0f, 0.0f, rotZ);
1441 break;
1449
1450 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs); j++) {
1451 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1453 }
1454 }
1455
1457 break;
1460 break;
1462 if (bFadeToBlackAmt != 0) {
1464 }
1465 break;
1466 }
1467
1468 switch (gBattleSubState) {
1474 if (LevelUpSelectTextOffsetX > 200) {
1476 LevelUpSelectTextVelX = -LevelUpSelectTextVelX / 3; // rebounding
1477 }
1481 break;
1485 if (LevelUpSelectTextOffsetX > 500) {
1487 }
1491 break;
1492 }
1493}
void btl_draw_upgrade_windows(s32 phase)
Definition level_up.c:1243
HudScript HES_level_up_heart_copy
Definition level_up.c:413
void hud_element_draw_complex_hud_next(s32 hid)
void hud_element_draw_complex_hud_first(s32 hid)
void hud_element_draw_clipped(s32 id)

Referenced by btl_draw_ui().

Variable Documentation

◆ EndDemoWhiteOut

s16 EndDemoWhiteOut
extern

◆ BattleSkipActorTurn

b32 BattleSkipActorTurn
extern

◆ BattleCanShowFirstStrike

◆ BattleStatusUpdateDelay

◆ BattleSubstateDelay

◆ BattleScreenFadeAmt