Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
select_target.c File Reference

Go to the source code of this file.

Enumerations

enum  { BTL_SUBSTATE_CHOOSE = 1 , BTL_SUBSTATE_DONE = 2 , BTL_SUBSTATE_CANCEL = 10 }
 

Functions

void btl_state_update_select_target (void)
 
void btl_state_draw_select_target (void)
 

Enumeration Type Documentation

◆ anonymous enum

Enumerator
BTL_SUBSTATE_CHOOSE 
BTL_SUBSTATE_DONE 
BTL_SUBSTATE_CANCEL 

Definition at line 6 of file select_target.c.

6 {
7 // BTL_SUBSTATE_INIT = 0,
11};
@ BTL_SUBSTATE_CHOOSE
@ BTL_SUBSTATE_DONE
@ BTL_SUBSTATE_CANCEL

Function Documentation

◆ 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
BSS s32 PopupMenu_SelectedIndex
s32 BattleMenu_ChooseDelay
s32 BattleMenu_TargetPointerAlpha
s32 BattleMenu_SwapDelay
s32 BattleMenu_TargetHudElems[]
#define MENU_CHANGE_DELAY
Definition battle_menu.h:7
s32 BattleMenu_TargetNameOffsetX
s8 selectedTargetIndex
struct SelectableTarget targetData[24]
s16 targetActorID
s32 HudElemID
s8 targetIndexList[24]
s8 targetListLength
@ 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
@ BUTTON_B
Definition enums.h:2775
@ BUTTON_Z
Definition enums.h:2774
@ BS_FLAGS1_10000
Definition enums.h:3618
@ BS_FLAGS1_MENU_OPEN
Definition enums.h:3599
@ BS_FLAGS1_PARTNER_ACTING
Definition enums.h:3621
@ BTL_MSG_ACTION_TIP_PRESS_BEFORE_LANDING
Definition enums.h:3747
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ TARGET_FLAG_OVERRIDE
Definition enums.h:1897
@ TARGET_FLAG_SELECT_ONE
Definition enums.h:1875
@ BATTLE_STATE_PLAYER_MENU
Definition enums.h:3677
@ BATTLE_STATE_PLAYER_MOVE
Definition enums.h:3682
@ BATTLE_STATE_PARTNER_MOVE
Definition enums.h:3683
@ BATTLE_STATE_PARTNER_MENU
Definition enums.h:3678
@ ABILITY_BERSERKER
Definition enums.h:457
@ SOUND_MENU_BACK
Definition enums.h:704
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:701
@ SOUND_MENU_NEXT
Definition enums.h:703
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3377
@ 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
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:923
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void btl_show_battle_message(s32 messageIndex, s32 duration)
void btl_set_state(s32 battleState)
void create_current_pos_target_list(Actor *actor)
Definition 190B20.c:472
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)
void btl_state_update_partner_menu(void)
void btl_state_update_peach_menu(void)
Definition menu_peach.c:24
void btl_state_update_player_menu(void)
void btl_state_update_twink_menu(void)
Definition menu_twink.c:27
void sfx_play_sound(s32 soundID)
@ BTL_SUBSTATE_INIT
Definition states.h:8
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17
MoveData gMoveTable[]

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
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_PARTNER
Definition enums.h:2119
@ PARTNER_TWINK
Definition enums.h:2930
@ CAM_BATTLE
Definition enums.h:1827
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
PlayerData gPlayerData
Definition 77480.c:39

Referenced by btl_draw_ui().