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)
HudElemID hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
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 targetListLength;
251 s32 actorID;
255 s32 id;
256 s32 i;
258 s32 xOffset, yOffset;
259 f32 targetX, targetY, targetZ;
261 s32 selectedTargetIndex;
262 s8* targetIndexList;
263
265 choosingActor = battleStatus->playerActor;
266 } else {
267 choosingActor = battleStatus->partnerActor;
268 }
269
270 targetListLength = choosingActor->targetListLength;
271 target = choosingActor->targetData;
272 selectedTargetIndex = choosingActor->selectedTargetIndex;
273 targetIndexList = choosingActor->targetIndexList;
274
275 if (targetListLength == 0) {
276 return;
277 }
278
279 // draw target pointers
280 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
281 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
282 enemyActor = get_actor(target->actorID);
284 targetX = target->truePos.x;
285 targetY = target->truePos.y;
286 targetZ = target->truePos.z;
287
288 // select target pointer style based on target actor orientation
289 if (enemyActor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
290 xOffset = 16;
291 yOffset = 2;
294 }
295 } else {
296 xOffset = 5;
297 yOffset = -11;
300 }
301 }
302
303 get_screen_coords(CAM_BATTLE, targetX, targetY, targetZ, &screenX, &screenY, &screenZ);
304 hud_element_set_render_pos(id, screenX + xOffset, screenY + yOffset);
306 } else {
307 for (i = 0; i < targetListLength; i++) {
308 target = &choosingActor->targetData[targetIndexList[i]];
309 enemyActor = get_actor(target->actorID);
311 targetX = target->truePos.x;
312 targetY = target->truePos.y;
313 targetZ = target->truePos.z;
314
315 // select target pointer style based on target actor orientation
316 if (enemyActor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
317 xOffset = 16;
318 yOffset = 2;
321 }
322 } else {
323 xOffset = 5;
324 yOffset = -11;
327 }
328 }
329
330 get_screen_coords(CAM_BATTLE, targetX, targetY, targetZ, &screenX, &screenY, &screenZ);
331 hud_element_set_render_pos(id, screenX + xOffset, screenY + yOffset);
333 }
334 }
335
337 screenX = 52;
338 screenY = 64;
341 }
342
343 // get target name width
344 if ((battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) || targetListLength == 1) {
345 actorID = target->actorID;
346 if (actorID == ACTOR_PLAYER) {
348 } else if (actorID == ACTOR_PARTNER) {
350 } else {
351 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
352 enemyActor = get_actor(target->actorID);
354 if (msgID == MSG_NONE) {
355 msgID = bActorNames[enemyActor->actorType];
356 }
357 nameWidth = get_msg_width(msgID, 0) + 10;
358 }
359 } else {
360 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
361 actorID = target->actorID;
362 if (actorID == ACTOR_PLAYER) {
364 } else if (actorID == ACTOR_PARTNER) {
366 } else {
368 }
369 }
370
371 // draw target name box
373 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, nullptr, nullptr, nullptr, SCREEN_WIDTH, SCREEN_HEIGHT, nullptr);
374
375 // draw target name text
376 screenX += 4;
377 screenY += 2;
378 if ((battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) || targetListLength == 1) {
379 actorID = target->actorID;
380 if (actorID == ACTOR_PLAYER) {
382 } else if (actorID == ACTOR_PARTNER) {
384 } else {
385 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
386 enemyActor = get_actor(target->actorID);
388 if (msgID == MSG_NONE) {
389 msgID = bActorNames[enemyActor->actorType];
390 }
392 }
393 } else {
394 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
395 actorID = target->actorID;
396 if (actorID == ACTOR_PLAYER) {
398 } else if (actorID == ACTOR_PARTNER) {
400 } else {
402 }
403 }
404}
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:108
#define SCREEN_HEIGHT
Definition macros.h:109
EXTERN_C s32 bActorNames[]
Definition battle.h:105
PlayerData gPlayerData
Definition 77480.c:39

Referenced by btl_draw_ui().