Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
popup_messages.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3#include "entity.h"
4#include "battle/battle.h"
5#include "battle/action_cmd.h"
6
7typedef struct BonkData {
8 /* 0x00 */ b32 alive;
9 /* 0x04 */ s32 entityModelIndex;
10 /* 0x08 */ Vec3f accel;
11 /* 0x14 */ Vec3f vel;
12 /* 0x20 */ s32 moveTime;
13 /* 0x24 */ s32 startupTime;
14 /* 0x28 */ f32 rotZ;
15 /* 0x2C */ f32 rotVelZ;
16 /* 0x30 */ f32 rotY;
17 /* 0x34 */ f32 scale;
18 /* 0x38 */ Vec3f pos;
19 /* 0x44 */ s32 holdTime;
20 /* 0x48 */ f32 alpha; // unused
21} BonkData; // size = 0x4C
22
23#if VERSION_JP
24extern s32* D_8028358C[];
25
26s32* D_8028358C_2[] = {
27 (s32*)D_8028358C, (s32*)D_8028358C, (s32*)D_8028358C
28};
29
30s8 D_8028374C_1BA13C[][4] = {
31 { 236, 0, 0, 0 }, { 204, 0, 0, 0 }, { 238, 0, 0, 0 }, { 248, 0, 0, 0 }, { 252, 0, 0, 0 },
32 { 252, 0, 0, 0 }, { 252, 0, 0, 0 }, { 252, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
33 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
34 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
35 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
36 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
37 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
38 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
39 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
40 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
41 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
42 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
43 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
44 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
45 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
46 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
47 { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 }, { 248, 0, 0, 0 },
48};
49#else
50 // all keyed by number of lines in the message (1 or 2)
51s16 BattleMessage_BoxSizesY[] = { 28, 40 };
53s16 BattleMessage_BoxOffsetsY[] = { 0, -12 };
54#endif
55
57 { 0.0f, 4.5f, 0.0f },
58 { 1.0f, 4.0f, 0.0f },
59 { 2.0f, 3.0f, 0.0f },
60 { 3.0f, 2.0f, 0.0f },
61 { 3.5f, 1.0f, 0.0f },
62 { 4.0f, 0.0f, 0.0f },
63 { 4.5f, 0.0f, 0.0f },
64 { 5.0f, 0.0f, 0.0f },
65 { 4.5f, 0.0f, 0.0f },
66 { 4.0f, 0.0f, 0.0f },
67 { 3.5f, -1.0f, 0.0f },
68 { 3.0f, -2.0f, 0.0f },
69 { 2.0f, -3.0f, 0.0f },
70 { 1.0f, -4.0f, 0.0f },
71 { 0.0f, -4.5f, 0.0f },
72};
73
75 { 1.0f, 1.0f, 1.0f },
76 { 0.8f, 0.8f, 0.8f },
77 { 0.9f, 0.9f, 0.9f },
78 { 1.1f, 1.1f, 1.1f },
79 { 1.0f, 1.0f, 1.0f },
80 { 0.8f, 0.8f, 0.8f },
81 { 0.9f, 0.9f, 0.9f },
82 { 1.1f, 1.1f, 1.1f },
83 { 1.0f, 1.0f, 1.0f },
84 { 0.8f, 0.8f, 0.8f },
85 { 0.9f, 0.9f, 0.9f },
86 { 1.1f, 1.1f, 1.1f },
87 { 1.0f, 1.0f, 1.0f },
88 { 0.8f, 0.8f, 0.8f },
89 { 0.9f, 0.9f, 0.9f },
90};
91
93
99
101 [BTL_MSG_MERLEE_ATK_UP] MSG_Menus_Merlee_IncreaseAttack,
102 [BTL_MSG_MERLEE_DEF_UP] MSG_Menus_Merlee_DecreaseDamage,
103 [BTL_MSG_MERLEE_EXP_UP] MSG_Menus_Merlee_IncreaseStarPoints,
104 [BTL_MSG_MERLEE_DONE] MSG_Menus_Merlee_Exhausted,
105 [BTL_MSG_CHARGE_HAMMER] MSG_Menus_ChargeHammer,
106 [BTL_MSG_CHARGE_HAMMER_MORE] MSG_Menus_ChargeHammerMore,
107 [BTL_MSG_CHARGE_JUMP] MSG_Menus_ChargeJump,
108 [BTL_MSG_CHARGE_JUMP_MORE] MSG_Menus_ChargeJumpMore,
109 [BTL_MSG_CANT_CHARGE] MSG_Menus_ChargeMaxedOut,
110 [BTL_MSG_ENEMY_MISSED] MSG_Menus_EnemyMissed,
111
112 // player status effects
113 [BTL_MSG_PLAYER_DAZED] MSG_Menus_PlayerDazed,
114 [BTL_MSG_PLAYER_ASLEEP] MSG_Menus_PlayerAsleep,
115 [BTL_MSG_PLAYER_FROZEN] MSG_Menus_PlayerFrozen,
116 [BTL_MSG_PLAYER_POISONED] MSG_Menus_PlayerPoisoned,
117 [BTL_MSG_PLAYER_SHRUNK] MSG_Menus_PlayerShrunk,
118 [BTL_MSG_PLAYER_PARALYZED] MSG_Menus_PlayerParalyzed,
119 [BTL_MSG_PLAYER_CHARGED] MSG_Menus_PlayerElectricCharge,
120 [BTL_MSG_PLAYER_TRANSPARENT] MSG_Menus_PlayerTransparent,
121
122 // enemy status effects
123 [BTL_MSG_ENEMY_DAZED] MSG_Menus_EnemyDazed,
124 [BTL_MSG_ENEMY_ASLEEP] MSG_Menus_EnemyAsleep,
125 [BTL_MSG_ENEMY_FROZEN] MSG_Menus_EnemyFrozen,
126 [BTL_MSG_ENEMY_POISONED] MSG_Menus_EnemyPoisoned,
127 [BTL_MSG_ENEMY_SHRUNK] MSG_Menus_EnemyShrunk,
128 [BTL_MSG_ENEMY_PARALYZED] MSG_Menus_EnemyParalyzed,
129 [BTL_MSG_ENEMY_ELECTRIFIED] MSG_Menus_EnemyElectrified,
130 [BTL_MSG_ENEMY_CANT_MOVE] MSG_Menus_EnemyCantMove,
131
132 [BTL_MSG_STAR_POWER_RECHARGED] MSG_Menus_StarEnergyRecharged,
133 [BTL_MSG_STAR_POWER_MAXED] MSG_Menus_StarEnergyMaxedOut,
134 [BTL_MSG_STAR_POWER_FILLED] MSG_Menus_StarEnergyFilled,
135 [BTL_MSG_ATTACK_UP] MSG_Menus_AttackUp,
136 [BTL_MSG_DEFENCE_UP] MSG_Menus_DefenseUp,
137 [BTL_MSG_HEAL_ONE] MSG_Menus_HealOne,
138 [BTL_MSG_HEAL_ALL] MSG_Menus_HealAll,
139
140 [BTL_MSG_ENEMY_TRANSPARENT] MSG_Menus_EnemyTransparent,
141 [BTL_MSG_ENEMY_CHARGED] MSG_Menus_EnemyElectricCharge,
142 [BTL_MSG_PARTNER_INJURED] MSG_Menus_PartnerInjured,
143 [BTL_MSG_CHARGE_GOOMBARIO] MSG_Menus_ChargeGoombario,
144 [BTL_MSG_CHARGE_GOOMBARIO_MORE] MSG_Menus_ChargeGoombarioMore,
145 [BTL_MSG_WATER_BLOCK_BEGIN] MSG_Menus_WaterBlockBegin,
146 [BTL_MSG_WATER_BLOCK_END] MSG_Menus_WaterBlockEnd,
147 [BTL_MSG_CLOUD_NINE_BEGIN] MSG_Menus_CloudNineBegin,
148 [BTL_MSG_CLOUD_NINE_END] MSG_Menus_CloudNineEnd,
149 [BTL_MSG_TURBO_CHARGE_BEGIN] MSG_Menus_TurboChargeBegin,
150 [BTL_MSG_TURBO_CHARGE_END] MSG_Menus_TurboChargeEnd,
151 [BTL_MSG_CHILL_OUT_BEGIN] MSG_Menus_ChillOutBegin,
152 [BTL_MSG_UNUSED_CLOUD_NINE] MSG_Menus_CloudNineBegin,
153
154 // move action command tips
155 [BTL_MSG_ACTION_TIP_PRESS_BEFORE_LANDING] MSG_Menus_MoveTip_PressBeforeLanding,
156 [BTL_MSG_ACTION_TIP_HOLD_LEFT_TIMED] MSG_Menus_MoveTip_PushLeftWithTiming,
157 [BTL_MSG_ACTION_TIP_PRESS_BEFORE_STRIKE] MSG_Menus_MoveTip_PressBeforeStriking,
158 [BTL_MSG_ACTION_TIP_MASH_BUTTON] MSG_Menus_MoveTip_PressRepeatedly,
159 [BTL_MSG_ACTION_TIP_MASH_LEFT] MSG_Menus_MoveTip_PushLeftRepeatedly,
160 [BTL_MSG_ACTION_TIP_HOLD_LEFT_AIM] MSG_Menus_MoveTip_PushLeftToAim,
161 [BTL_MSG_ACTION_TIP_UNUSED_1] MSG_Menus_MoveTip_PressBeforeLanding,
162 [BTL_MSG_ACTION_TIP_UNUSED_2] MSG_Menus_MoveTip_PressBeforeLanding,
163 [BTL_MSG_ACTION_TIP_PRESS_BUTTONS_SHOWN] MSG_Menus_MoveTip_PressAsShown,
164 [BTL_MSG_ACTION_TIP_NOT_USED_1] MSG_Menus_MoveTip_NOT_USED_1,
165 [BTL_MSG_ACTION_TIP_PRESS_WITH_TIMING] MSG_Menus_MoveTip_PressAsLightsUp,
166 [BTL_MSG_ACTION_TIP_NOT_USED_2] MSG_Menus_MoveTip_NOT_USED_2,
167 [BTL_MSG_ACTION_TIP_MASH_BOTH] MSG_Menus_MoveTip_PressBothRepeatedly,
168 [BTL_MSG_ACTION_TIP_UNUSED_3] MSG_Menus_MoveTip_PressBeforeLanding,
169 [BTL_MSG_ACTION_TIP_HOLD_THEN_TAP] MSG_Menus_MoveTip_HoldThenTap,
170 [BTL_MSG_ACTION_TIP_HOLD_THEN_RELEASE] MSG_Menus_MoveTip_HoldThenRelease,
171 [BTL_MSG_ACTION_TIP_MOVE_TO_AIM] MSG_Menus_MoveTip_MoveToAim,
172 [BTL_MSG_ACTION_TIP_UNUSED_4] MSG_Menus_MoveTip_PressBeforeLanding,
173 [BTL_MSG_ACTION_TIP_BREAK_FREE] MSG_Menus_MoveTip_PressToRunAway,
174 [BTL_MSG_ACTION_TIP_REDUCE_DAMAGE] MSG_Menus_MoveTip_PressToReduceDamage,
175 [BTL_MSG_ACTION_TIP_NOT_USED_3] MSG_Menus_MoveTip_NOT_USED_3,
176
177 // no targets available
178 [BTL_MSG_NO_JUMP_TARGET] MSG_Menus_Battle_NoTarget_Jump,
179 [BTL_MSG_NO_HAMMER_TARGET] MSG_Menus_Battle_NoTarget_Hammer,
180 [BTL_MSG_NO_ITEM_TARGET] MSG_Menus_Battle_NoTarget_Item,
181#if VERSION_JP
182 [BTL_MSG_46] MSG_Menus_JP_00DB,
183 [BTL_MSG_47] MSG_Menus_JP_00DC,
184#else
185 [BTL_MSG_46] MSG_NONE,
186 [BTL_MSG_47] MSG_NONE,
187#endif
188
189 // errors and warnings
190 [BTL_MSG_CANT_SELECT_NOW] MSG_Menus_Battle_CantSelectNow,
191 [BTL_MSG_HAMMER_DISABLED_1] MSG_Menus_Battle_CantUseHammer,
192 [BTL_MSG_HAMMER_DISABLED_2] MSG_Menus_Battle_CantUseHammer,
193 [BTL_MSG_HAMMER_DISABLED_3] MSG_Menus_Battle_CantUseHammer,
194 [BTL_MSG_JUMP_DISABLED_1] MSG_Menus_Battle_CantUseJump,
195 [BTL_MSG_JUMP_DISABLED_2] MSG_Menus_Battle_CantUseJump,
196 [BTL_MSG_JUMP_DISABLED_3] MSG_Menus_Battle_CantUseJump,
197 [BTL_MSG_ITEMS_DISABLED] MSG_Menus_Battle_CantUseItems,
198 [BTL_MSG_CANT_SWITCH] MSG_Menus_Battle_CantSwitch,
199 [BTL_MSG_CANT_MOVE] MSG_Menus_Battle_CantMove,
200 [BTL_MSG_CANT_SWITCH_UNUSED] MSG_Menus_Battle_CantSwitch,
201 [BTL_MSG_CANT_MOVE_UNUSED] MSG_Menus_Battle_CantMove,
202 [BTL_MSG_CANT_SELECT_NOW_ALT] MSG_Menus_Battle_CantSelectNow,
203};
204
205#if VERSION_JP
206s32 D_80283B88_1BA578[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
207s32 D_80283BA8_1BA598[] = { 0, 0, 0, 0, 1, 0, 0, 0 };
208#endif
209
211 MSG_Menus_Party_Mario,
212 MSG_Menus_Party_Goombario,
213 MSG_Menus_Party_Kooper,
214 MSG_Menus_Party_Bombette,
215 MSG_Menus_Party_Parakarry,
216 MSG_Menus_Party_Goompa,
217 MSG_Menus_Party_Watt,
218 MSG_Menus_Party_Sushie,
219 MSG_Menus_Party_Lakilester,
220 MSG_Menus_Party_Bow,
221 MSG_Menus_Party_Goombaria,
222 MSG_Menus_Party_Twink,
223 MSG_Menus_Party_Peach
224};
225
227
237#if !VERSION_JP
239#endif
240
264
265void btl_bonk_update(void* data);
266void btl_bonk_render(void* data);
267void btl_bonk_setup_gfx(void* data);
268void btl_update_message_popup(void* popup);
269void btl_show_message_popup(void* popup);
270
272 s32 i;
273
274 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
275 PopupMessage* popup = &popupMessages[i];
276 popup->active = FALSE;
277 popup->data.bonk = NULL;
278 }
279}
280
282 s32 i;
283
284 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
285 PopupMessage* popup = &popupMessages[i];
286 if (popup->data.bonk != NULL) {
287 heap_free(popup->data.bonk);
288 popup->data.bonk = NULL;
289 }
290 popup->active = FALSE;
291 }
292}
293
295 s32 i;
296
297 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
298 PopupMessage* popup = &popupMessages[i];
299 if (popup->active && popup->updateFunc != NULL) {
300 popup->updateFunc(popup);
301 }
302 }
303}
304
306 s32 i;
307
308 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
309 PopupMessage* popup = &popupMessages[i];
310 if (popup->active && popup->renderWorldFunc != NULL) {
311 popup->renderWorldFunc(popup);
312 }
313 }
314}
315
317 s32 i;
318
319 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
320 PopupMessage* popup = &popupMessages[i];
321 if (popup->active && popup->renderUIFunc != NULL) {
322 popup->renderUIFunc(popup);
323 }
324 }
325}
326
328 s32 i;
329
330 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
331 PopupMessage* popup = &popupMessages[i];
332 if (!popup->active) {
333 popup->active = TRUE;
334 return popup;
335 }
336 }
337
338 return NULL;
339}
340
342 if (popup->data.bonk != NULL) {
343 heap_free(popup->data.bonk);
344 popup->data.bonk = NULL;
345 }
346 popup->active = FALSE;
347}
348
349void show_immune_bonk(f32 x, f32 y, f32 z, s32 numStars, s32 startupTime, s32 animDir) {
350 BattleStatus* battleStatus = &gBattleStatus;
351 PopupMessage* popup;
352 BonkData* bonkData;
353 f32 timescale;
354 f32 baseScale;
355 s32 bonkPosIdx;
356 b32 hasShortLifetime;
357 s32 sign;
358 s32 i;
359
360 popup = btl_create_popup();
361 if (popup == NULL) {
362 // unable to create popup
363 return;
364 }
365
366 if (numStars < 1) {
367 numStars = 1;
368 baseScale = 0.4f;
369 timescale = 0.7f;
370 hasShortLifetime = TRUE;
371 } else {
372 baseScale = 1.0f;
373 timescale = 1.0f;
374 hasShortLifetime = FALSE;
375 }
376
377 if (battleStatus->flags1 & (BS_FLAGS1_NICE_HIT | BS_FLAGS1_SUPER_HIT)) {
378 baseScale *= 2.0;
379 }
380
381 if (animDir < 0) {
382 sign = -1;
383 } else {
384 sign = 1;
385 }
386
387 animDir = abs(animDir) % 5;
388
389 battleStatus->unk_90 = 0;
392 popup->unk_00 = FALSE;
393 popup->renderUIFunc = NULL;
394 popup->messageIndex = 1;
395 popup->active |= 0x10;
396 bonkData = popup->data.bonk = heap_malloc(numStars * sizeof(*popup->data.bonk));
397 ASSERT (popup->data.bonk != NULL);
398
399 for (i = 0; i < numStars; i++) {
400 bonkData->alive = TRUE;
404 bonkData->pos.x = x;
405 bonkData->pos.y = y;
406 bonkData->pos.z = z;
407 bonkPosIdx = animDir % 8;
408 animDir++;
409
410 bonkData->accel.x = BonkAnimAccel[bonkPosIdx].x * timescale * sign ;
411 bonkData->accel.y = BonkAnimAccel[bonkPosIdx].y * timescale;
412 bonkData->accel.z = BonkAnimAccel[bonkPosIdx].z * timescale;
413 bonkData->vel.x = 2.0 * bonkData->accel.x;
414 bonkData->vel.y = 2.0 * bonkData->accel.y;
415 bonkData->vel.z = 2.0 * bonkData->accel.z;
416
417 bonkData->scale = BonkAnimScale[i % 8].x * baseScale;
418 bonkData->rotY = clamp_angle(180.0f - gCameras[CAM_BATTLE].curYaw);
419 bonkData->rotZ = 0;
420 bonkData->rotVelZ = sign * 107;
421
422 bonkData->startupTime = startupTime;
423 bonkData->moveTime = 14;
424 bonkData->holdTime = 240;
425 if (hasShortLifetime) {
426 bonkData->holdTime = 10;
427 }
428
429 bonkData->alpha = 255.0f;
430 bonkData++;
431 }
432}
433
434void btl_bonk_update(void* data) {
435 PopupMessage* popup = data;
436 BonkData* bonkData = popup->data.bonk;
437 s32 allDone = TRUE;
438 s32 i;
439
440 for (i = 0; i < popup->messageIndex; i++, bonkData++) {
441 if (bonkData->alive) {
442 s32 modelIdx = bonkData->entityModelIndex;
443
444 allDone = FALSE;
445 if (bonkData->startupTime != 0) {
446 bonkData->startupTime--;
447 if (bonkData->startupTime == 0) {
449 }
451 break;
452 }
453
455 if (bonkData->moveTime >= 0) {
456 bonkData->pos.x += bonkData->vel.x;
457 bonkData->pos.y += bonkData->vel.y;
458 bonkData->pos.z += bonkData->vel.z;
459 }
460 bonkData->rotY = clamp_angle(180.0f - gCameras[CAM_BATTLE].curYaw);
461 bonkData->rotZ += bonkData->rotVelZ;
462 bonkData->rotZ = clamp_angle(bonkData->rotZ);
463 bonkData->rotVelZ *= 0.8;
464 if (bonkData->moveTime < 10) {
465 bonkData->accel.x *= 0.5;
466 bonkData->accel.y *= 0.5;
467 bonkData->accel.z *= 0.5;
468 bonkData->vel.x = bonkData->accel.x;
469 bonkData->vel.y = bonkData->accel.y;
470 bonkData->vel.z = bonkData->accel.z;
471 }
472
473 bonkData->moveTime--;
474 if (bonkData->moveTime < 0) {
475 bonkData->holdTime--;
476 if (bonkData->holdTime < 0) {
478 bonkData->alive = FALSE;
479 }
480 }
481 }
482 }
483
484 if (allDone) {
485 heap_free(popup->data.bonk);
486 popup->data.bonk = NULL;
487 free_popup(popup);
488 }
489}
490
491void btl_bonk_render(void* data) {
492 PopupMessage* popup = data;
493 BonkData* bonkData = popup->data.bonk;
494 Matrix4f sp18;
495 Matrix4f mtxRotX;
496 Matrix4f mtxRotY;
497 Matrix4f mtxRotZ;
498 Matrix4f sp118;
499 Matrix4f sp158;
500 Matrix4f sp198;
501 Matrix4f mtxScale;
502 Mtx sp218;
503 s32 i;
504
505 for (i = 0; i < popup->messageIndex; i++, bonkData++) {
506 if (bonkData->alive) {
507 if (bonkData->startupTime != 0) {
508 break;
509 } else {
510 guTranslateF(sp18, bonkData->pos.x, bonkData->pos.y, bonkData->pos.z);
511 guRotateF(mtxRotX, 0.0f, 1.0f, 0.0f, 0.0f);
512 guRotateF(mtxRotY, bonkData->rotY, 0.0f, 1.0f, 0.0f);
513 guRotateF(mtxRotZ, bonkData->rotZ, 0.0f, 0.0f, 1.0f);
514 guScaleF(mtxScale, bonkData->scale, bonkData->scale, bonkData->scale);
515 guMtxCatF(mtxRotZ, mtxRotX, sp158);
516 guMtxCatF(sp158, mtxRotY, sp118);
517 guMtxCatF(mtxScale, sp118, sp158);
518 guMtxCatF(sp158, sp18, sp198);
519 guMtxF2L(sp198, &sp218);
520 draw_entity_model_A(bonkData->entityModelIndex, &sp218);
521 }
522 }
523 }
524}
525
526void btl_bonk_setup_gfx(void* data) {
527 BonkData* bonkData = data;
528 s32 alphaAmt = bonkData->holdTime;
529
530 if (alphaAmt > 10) {
531 alphaAmt = 10;
532 }
533 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, (alphaAmt * 255) / 10);
534}
535
537 s32 i;
538
539 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
540 PopupMessage* popup = &popupMessages[i];
541
542 if (popup->active != 0 && (popup->active & 0x10)) {
543 BonkData* bonkData = popup->data.bonk;
544 s32 j;
545
546 for (j = 0; j < popup->messageIndex; j++, bonkData++) {
547 if (bonkData->alive) {
548 bonkData->startupTime = 0;
549 bonkData->moveTime = 1;
550 bonkData->holdTime = 20;
551 }
552 }
553 }
554 }
555}
556
557API_CALLABLE(ShowImmuneBonk) {
558 Bytecode* args = script->ptrReadPos;
559 s32 x = evt_get_variable(script, *args++);
560 s32 y = evt_get_variable(script, *args++);
561 s32 z = evt_get_variable(script, *args++);
562 s32 numStars = evt_get_variable(script, *args++);
563 s32 startupTime = evt_get_variable(script, *args++);
564 s32 arg6 = evt_get_variable(script, *args++);
565
566 show_immune_bonk(x, y, z, numStars, startupTime, arg6);
567 return ApiStatus_DONE2;
568}
569
570API_CALLABLE(ForceImmuneBonkCleanup) {
572 return ApiStatus_DONE2;
573}
574
575// show a popup message bubble with a message selected from BattleMessages
576void btl_show_battle_message(s32 messageIndex, s32 duration) {
578
579 if (popup != NULL) {
582 popup->unk_00 = FALSE;
583 popup->renderWorldFunc = NULL;
584 popup->messageIndex = messageIndex;
585 popup->duration = duration;
587 popup->needsInit = TRUE;
588 popup->data.bonk = NULL;
590 bPopupMessage = popup;
594#if !VERSION_JP
596#endif
597 }
598}
599
600// show a popup message bubble with a message selected from BattleMessages
601void btl_show_variable_battle_message(s32 messageIndex, s32 duration, s32 varValue) {
603
604 if (popup != NULL) {
607 popup->unk_00 = FALSE;
608 popup->renderWorldFunc = NULL;
609 popup->messageIndex = messageIndex;
610 popup->duration = duration;
612 popup->needsInit = TRUE;
613 popup->data.bonk = NULL;
614 BattlePopupMessageVar = varValue;
615 bPopupMessage = popup;
619#if !VERSION_JP
621#endif
622 }
623}
624
626 return bPopupMessage != NULL;
627}
628
629void btl_set_popup_duration(s32 duration) {
631
632 if (ActionCommandTipVisible && popup != NULL) {
633 popup->duration = duration;
634 }
635}
636
640
644
647
648 if (popup != NULL
651 ) {
652 popup->duration = 0;
653 }
654}
655
656void btl_update_message_popup(void* data) {
657 PopupMessage* popup = data;
658 BattleStatus* battleStatus = &gBattleStatus;
659 s32 shouldDisposeWindow = FALSE;
660
661 s32 actionCommandMode;
662
663 switch (popup->messageIndex) {
695 case BTL_MSG_HEAL_ONE:
696 case BTL_MSG_HEAL_ALL:
715 switch (popup->showMsgState) {
716 default:
717 break;
720 break;
723 break;
725 if (battleStatus->curButtonsPressed & (BUTTON_A | BUTTON_B)) {
726 popup->duration = 0;
727 }
728
729 if (popup->duration != 0) {
730 popup->duration--;
731 } else {
733 }
734 break;
737 break;
739 shouldDisposeWindow = TRUE;
740 break;
741 }
742 break;
743 // move action command tips
765 actionCommandMode = battleStatus->actionCommandMode;
767 if (actionCommandMode == ACTION_COMMAND_MODE_NOT_LEARNED) {
769 shouldDisposeWindow = TRUE;
770 break;
771 }
772
773 switch (popup->showMsgState) {
776 gBattleStatus.flags1 &= ~BS_FLAGS1_10000;
777 switch (popup->messageIndex) {
782 break;
787
791 break;
796
801 break;
806
810
814
818 break;
823 break;
828
832
836 break;
841 break;
846
850 break;
858 break;
863
867 break;
872
876 break;
881
886
891 break;
897 // fallthrough
908 break;
909 }
911 break;
914 gBattleStatus.flags1 &= ~BS_FLAGS1_4000;
916 popup->duration = 0;
918 break;
919 }
920
922 && (actionCommandMode != ACTION_COMMAND_MODE_TUTORIAL)
923 ) {
925 switch (popup->messageIndex) {
928 break;
931 break;
935 break;
939 break;
945 break;
948 break;
953 break;
956 break;
960 break;
964 break;
968 break;
971 break;
975 break;
978 break;
981 break;
985 // fallthrough
991 break;
992 }
993 if (popup->duration != -1) {
994 popup->duration = 30;
995 }
997 break;
998 }
999 break;
1001 if ((actionCommandMode != ACTION_COMMAND_MODE_TUTORIAL)
1003 ) {
1004 if (BattleMessage_CurBoxPosY < 192) {
1007 if (BattleMessage_CurBoxPosY > 192) {
1009 }
1010 } else {
1011 break;
1012 }
1013 }
1014
1015#if VERSION_JP
1017#else
1019#endif
1020
1021 if (popup->duration == -1) {
1022 break;
1023 }
1024
1025 if (popup->duration != 0) {
1026 popup->duration--;
1027 break;
1028 }
1029
1030 switch (popup->messageIndex) {
1044 break;
1053 break;
1059 break;
1065 break;
1066 }
1068 shouldDisposeWindow = TRUE;
1069 }
1070 break;
1071 }
1072 break;
1076 case BTL_MSG_46:
1077 case BTL_MSG_47:
1079 switch (popup->showMsgState) {
1080 default:
1081 break;
1082 case BTL_MSG_STATE_INIT:
1084 break;
1087 break;
1089 if (battleStatus->curButtonsPressed & (BUTTON_A | BUTTON_B)) {
1090 popup->duration = 0;
1091 }
1092
1093 if (popup->duration != 0) {
1094 popup->duration--;
1095 } else {
1097 }
1098 break;
1101 break;
1103 shouldDisposeWindow = TRUE;
1104 break;
1105 }
1106 break;
1114 switch (popup->showMsgState) {
1115 case BTL_MSG_STATE_INIT:
1116 switch (popup->messageIndex) {
1121 break;
1126 break;
1131 break;
1136 break;
1141 break;
1146 break;
1151 break;
1152 }
1154 break;
1156 if (popup->duration != 0) {
1157 popup->duration--;
1158 break;
1159 }
1160 shouldDisposeWindow = TRUE;
1162 break;
1163 }
1164 break;
1165 }
1166 if (shouldDisposeWindow) {
1168 bPopupMessage = NULL;
1169 free_popup(popup);
1170 }
1171}
1172
1173#if VERSION_IQUE
1174#define TIP_X_PRL 83
1175#define TIP_X_HLT1 44
1176#define TIP_X_HLT2 67
1177#define TIP_X_PBST 124
1178#define TIP_X_MB 70
1179#define TIP_X_ML 69
1180#define TIP_X_HLA1 43
1181#define TIP_X_HLA2 177
1182#define TIP_X_PBS1 105
1183#define TIP_X_PBS2 83
1184#define TIP_X_PBS3 127
1185#define TIP_X_PWT1 40
1186#define TIP_X_PWT2 106
1187#define TIP_X_MB1 95
1188#define TIP_X_MB2 116
1189#define TIP_X_HTT 58
1190#define TIP_X_HTR1 39
1191#define TIP_X_HTR2 55
1192#define TIP_X_MTA1 53
1193#define TIP_X_MTA2 55
1194#define TIP_X_MTA3 108
1195#define TIP_X_BF_RD 66
1196#define TIP_Y_HLT2 31
1197#define TIP_Y_HLA2 17
1198#define TIP_Y_PBS1 14
1199#define TIP_Y_PBS2 14
1200#define TIP_Y_PBS3 14
1201#define TIP_Y_PWT1 14
1202#define TIP_Y_HTR1 31
1203#define TIP_Y_MTA1 14
1204#define TIP_Y_MTA2 32
1205#define TIP_Y_BF_RD 14
1206#define TIP_SCALE1 0.6f
1207#define TIP_SCALE2 0.7f
1208#elif VERSION_JP
1209#define TIP_X_PRL 115
1210#define TIP_X_HLT1 29
1211#define TIP_X_HLT2 129
1212#define TIP_X_PBST 126
1213#define TIP_X_MB 28
1214#define TIP_X_ML 28
1215#define TIP_X_HLA1 29
1216#define TIP_X_HLA2 128
1217#define TIP_X_PBS1 111
1218#define TIP_X_PBS2 88
1219#define TIP_X_PBS3 134
1220#define TIP_X_PWT1 28
1221#define TIP_X_PWT2 160
1222#define TIP_X_MB1 20
1223#define TIP_X_MB2 43
1224#define TIP_X_HTT 29
1225#define TIP_X_HTR1 126
1226#define TIP_X_HTR2 28
1227#define TIP_X_MTA1 29
1228#define TIP_X_MTA2 153
1229#define TIP_X_MTA3 68
1230#define TIP_X_BF_RD 29
1231#define TIP_Y_HLT2 13
1232#define TIP_Y_HLA2 15
1233#define TIP_Y_PBS1 13
1234#define TIP_Y_PBS2 13
1235#define TIP_Y_PBS3 13
1236#define TIP_Y_PWT1 13
1237#define TIP_Y_HTR1 13
1238#define TIP_Y_MTA1 13
1239#define TIP_Y_MTA2 15
1240#define TIP_Y_BF_RD 13
1241#define TIP_SCALE1 0.8f
1242#define TIP_SCALE2 0.8f
1243#else
1244#define TIP_X_PRL 65
1245#define TIP_X_HLT1 55
1246#define TIP_X_HLT2 73
1247#define TIP_X_PBST 64
1248#define TIP_X_MB 67
1249#define TIP_X_ML 56
1250#define TIP_X_HLA1 65
1251#define TIP_X_HLA2 146
1252#define TIP_X_PBS1 86
1253#define TIP_X_PBS2 64
1254#define TIP_X_PBS3 108
1255#define TIP_X_PWT1 105
1256#define TIP_X_PWT2 65
1257#define TIP_X_MB1 63
1258#define TIP_X_MB2 84
1259#define TIP_X_HTT 124
1260#define TIP_X_HTR1 56
1261#define TIP_X_HTR2 53
1262#define TIP_X_MTA1 107
1263#define TIP_X_MTA2 210
1264#define TIP_X_MTA3 56
1265#define TIP_X_BF_RD 64
1266#define TIP_Y_HLT2 31
1267#define TIP_Y_HLA2 32
1268#define TIP_Y_PBS1 13
1269#define TIP_Y_PBS2 13
1270#define TIP_Y_PBS3 13
1271#define TIP_Y_PWT1 13
1272#define TIP_Y_HTR1 31
1273#define TIP_Y_MTA1 13
1274#define TIP_Y_MTA2 15
1275#define TIP_Y_BF_RD 13
1276#define TIP_SCALE1 0.8f
1277#define TIP_SCALE2 0.8f
1278#endif
1279
1280void btl_message_popup_draw_content(void* data, s32 x, s32 y) {
1281 PopupMessage* popup = data;
1282 s32 messageID;
1283 s32 msgLinesIdx;
1284 s32 opacity;
1285
1286#if VERSION_JP
1287 x += 11 + D_8028374C_1BA13C[popup->messageIndex][2];
1288 y += 6 + D_8028374C_1BA13C[popup->messageIndex][3];
1289#else
1290 x += 15;
1291 y += 6;
1292#endif
1293
1294 switch (popup->messageIndex) {
1334 case BTL_MSG_46:
1335 case BTL_MSG_47:
1338#if VERSION_JP
1339 case BTL_MSG_CANT_MOVE:
1340#endif
1344 messageID = BattleMessages[popup->messageIndex];
1345#if !VERSION_JP
1346 msgLinesIdx = get_msg_lines(messageID) - 1;
1347 y += BattleMessage_TextOffsetsY[msgLinesIdx];
1348#endif
1349 draw_msg(messageID, x, y, 255, MSG_PAL_0F, 0);
1350 break;
1355 case BTL_MSG_ATTACK_UP:
1356 case BTL_MSG_DEFENCE_UP:
1357 case BTL_MSG_HEAL_ONE:
1358 case BTL_MSG_HEAL_ALL:
1361 messageID = BattleMessages[popup->messageIndex];
1362#if !VERSION_JP
1363 msgLinesIdx = get_msg_lines(messageID) - 1;
1364 y += BattleMessage_TextOffsetsY[msgLinesIdx];
1365#endif
1367 draw_msg(messageID, x, y, 255, MSG_PAL_0F, 0);
1368 break;
1369#if !VERSION_JP
1370 case BTL_MSG_CANT_MOVE:
1371 messageID = BattleMessages[popup->messageIndex];
1372 msgLinesIdx = get_msg_lines(messageID) - 1;
1373 y += BattleMessage_TextOffsetsY[msgLinesIdx];
1375 draw_msg(messageID, x, y, 255, MSG_PAL_0F, 0);
1376 break;
1377#endif
1385 messageID = BattleMessages[popup->messageIndex];
1386 draw_msg(messageID, x + 29, y + 6, 255, MSG_PAL_0F, 0);
1389 break;
1411 opacity = 255;
1413 opacity = 160;
1414 }
1416 opacity = 255;
1417 }
1418
1419 x -= 11;
1420 y -= 6;
1421 messageID = BattleMessages[popup->messageIndex];
1422#if !VERSION_JP
1423 msgLinesIdx = get_msg_lines(messageID) - 1;
1424 y += BattleMessage_TextOffsetsY[msgLinesIdx];
1425#endif
1426 draw_msg(messageID, x + 11, y + 6, opacity, MSG_PAL_0F, 0);
1427
1428 switch (popup->messageIndex) {
1434 break;
1440
1444 break;
1450 break;
1456 break;
1462 break;
1468
1473 break;
1474#if VERSION_JP
1480
1485
1490
1495 break;
1501 break;
1502#endif
1508
1513
1518 break;
1519#if VERSION_JP
1525 break;
1526#endif
1531
1536 break;
1537#if VERSION_JP
1543
1548 break;
1549#endif
1555
1560 break;
1561#if VERSION_JP
1567 break;
1568#endif
1574 break;
1579
1584 break;
1590
1595
1600 break;
1601#if VERSION_JP
1607 break;
1608#endif
1615 break;
1616#if VERSION_JP
1622 break;
1623#endif
1624 }
1625 break;
1626 }
1627}
1628
1629void btl_show_message_popup(void* data) {
1630 PopupMessage* popup = data;
1631 s32 numLines;
1632 s32 posX;
1633 s32 posY = 80;
1634 s32 width;
1635 s32 msgWidth;
1636 s32 height;
1637
1638#if VERSION_JP
1639 switch (popup->messageIndex) {
1660 case BTL_MSG_46:
1661 case BTL_MSG_47:
1666 if (popup->needsInit) {
1667 popup->needsInit = FALSE;
1668 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1669 posX = 160 - (msgWidth / 2);
1670 width = msgWidth;
1671 height = 28 + D_8028374C_1BA13C[popup->messageIndex][1];
1672 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1673 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1674 }
1675 break;
1680 if (popup->needsInit) {
1681 popup->needsInit = FALSE;
1682 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1683 posX = 160 - (msgWidth / 2);
1684 width = msgWidth;
1685 height = 45 + D_8028374C_1BA13C[popup->messageIndex][1];
1686 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1687 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1688 }
1689 break;
1711 if (popup->needsInit) {
1712 popup->needsInit = FALSE;
1713 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1714 posX = 160 - (msgWidth / 2);
1715 width = msgWidth;
1716 posY = 192;
1717 height = 28 + D_8028374C_1BA13C[popup->messageIndex][1];
1719 posY = 120;
1721 }
1723
1724 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1726 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1727 } else {
1728 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW_DARKENED);
1729 }
1730 }
1731 break;
1739 if (popup->needsInit) {
1740 popup->needsInit = FALSE;
1741 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + (55 + D_8028374C_1BA13C[popup->messageIndex][0]);
1742 posX = 160 - (msgWidth / 2);
1743 width = msgWidth;
1744 height = 40 + D_8028374C_1BA13C[popup->messageIndex][1];
1745 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1746 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1747 }
1748 break;
1757 if (popup->needsInit) {
1758 popup->needsInit = FALSE;
1759 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1760 posX = 160 - (msgWidth / 2);
1761 width = msgWidth;
1762 if (D_80283B88_1BA578[popup->messageIndex - 10] != 0) {
1763 height = 45 + D_8028374C_1BA13C[popup->messageIndex][1];
1764 } else {
1765 height = 28 + D_8028374C_1BA13C[popup->messageIndex][1];
1766 }
1767
1768 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1769 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1770 }
1771 break;
1780 if (popup->needsInit) {
1781 popup->needsInit = FALSE;
1782 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1783 posX = 160 - (msgWidth / 2);
1784 width = msgWidth;
1785 if (D_80283BA8_1BA598[popup->messageIndex - 18] != 0) {
1786 height = 45 + D_8028374C_1BA13C[popup->messageIndex][1];
1787 } else {
1788 height = 28 + D_8028374C_1BA13C[popup->messageIndex][1];
1789 }
1790
1791 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1792 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1793 }
1794 break;
1799 case BTL_MSG_ATTACK_UP:
1800 case BTL_MSG_DEFENCE_UP:
1801 case BTL_MSG_HEAL_ONE:
1802 case BTL_MSG_HEAL_ALL:
1805 if (popup->needsInit) {
1806 s32 messageID;
1807
1808 popup->needsInit = FALSE;
1809 messageID = BattleMessages[popup->messageIndex];
1811 msgWidth = get_msg_width(messageID, 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1812 posX = 160 - (msgWidth / 2);
1813 width = msgWidth;
1814 height = 28 + D_8028374C_1BA13C[popup->messageIndex][1];
1815 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1816 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1817 }
1818 break;
1819 case BTL_MSG_CANT_MOVE:
1820 if (popup->needsInit) {
1821 s32 messageID;
1822
1823 popup->needsInit = FALSE;
1824 messageID = BattleMessages[popup->messageIndex];
1826 msgWidth = get_msg_width(messageID, 0) + (31 + D_8028374C_1BA13C[popup->messageIndex][0]);
1827 posX = 160 - (msgWidth / 2);
1828 width = msgWidth;
1829 height = 28 + D_8028374C_1BA13C[popup->messageIndex][1];
1830 set_window_properties(WINDOW_ID_BATTLE_POPUP, posX, posY, width, height, WINDOW_PRIORITY_0, btl_message_popup_draw_content, popup, -1);
1831 set_window_update(WINDOW_ID_BATTLE_POPUP, WINDOW_UPDATE_SHOW);
1832 }
1833 break;
1834 }
1835#else
1836 switch (popup->messageIndex) {
1876 case BTL_MSG_46:
1877 case BTL_MSG_47:
1883 if (popup->needsInit) {
1884 s32 messageID;
1885
1886 popup->needsInit = FALSE;
1887 messageID = BattleMessages[popup->messageIndex];
1888 msgWidth = get_msg_width(messageID, 0) + 30;
1889 posX = 160 - (msgWidth / 2);
1890 width = msgWidth;
1891 numLines = get_msg_lines(messageID) - 1;
1892 height = BattleMessage_BoxSizesY[numLines];
1895 }
1896 break;
1904 if (popup->needsInit) {
1905 popup->needsInit = FALSE;
1906 msgWidth = get_msg_width(BattleMessages[popup->messageIndex], 0) + 55;
1907 posX = 160 - (msgWidth / 2);
1908 width = msgWidth;
1909 height = 40;
1912 }
1913 break;
1918 case BTL_MSG_ATTACK_UP:
1919 case BTL_MSG_DEFENCE_UP:
1920 case BTL_MSG_HEAL_ONE:
1921 case BTL_MSG_HEAL_ALL:
1924 if (popup->needsInit) {
1925 s32 messageID;
1926
1927 popup->needsInit = FALSE;
1928 messageID = BattleMessages[popup->messageIndex];
1930 msgWidth = get_msg_width(messageID, 0) + 31;
1931 posX = 160 - (msgWidth / 2);
1932 width = msgWidth;
1933 numLines = get_msg_lines(messageID) - 1;
1934 height = BattleMessage_BoxSizesY[numLines];
1937 }
1938 break;
1939 case BTL_MSG_CANT_MOVE:
1940 if (popup->needsInit) {
1941 s32 messageID;
1942
1943 popup->needsInit = FALSE;
1944 messageID = BattleMessages[popup->messageIndex];
1946 msgWidth = get_msg_width(messageID, 0) + 31;
1947 posX = 160 - (msgWidth / 2);
1948 width = msgWidth;
1949 numLines = get_msg_lines(messageID) - 1;
1950 height = BattleMessage_BoxSizesY[numLines];
1953 }
1954 break;
1976 if (popup->needsInit) {
1977 s32 messageID;
1978
1979 popup->needsInit = FALSE;
1980 messageID = BattleMessages[popup->messageIndex];
1981 msgWidth = get_msg_width(messageID, 0) + 31;
1982 posX = 160 - (msgWidth / 2);
1983 posY = 192;
1984 width = msgWidth;
1985 numLines = get_msg_lines(messageID) - 1;
1986 height = BattleMessage_BoxSizesY[numLines];
1988 posY = 120;
1990 }
1993
1998 } else {
2000 }
2001 }
2002 break;
2003 }
2004#endif
2005}
2006
2007API_CALLABLE(ShowMessageBox) {
2008 Bytecode* args = script->ptrReadPos;
2009 s32 messageIndex = evt_get_variable(script, *args++);
2010 s32 duration = evt_get_variable(script, *args++);
2011
2012 btl_show_battle_message(messageIndex, duration);
2013 return ApiStatus_DONE2;
2014}
2015
2016API_CALLABLE(ShowVariableMessageBox) {
2017 Bytecode* args = script->ptrReadPos;
2018 s32 messageIndex = evt_get_variable(script, *args++);
2019 s32 duration = evt_get_variable(script, *args++);
2020 s32 varValue = evt_get_variable(script, *args++);
2021
2022 btl_show_variable_battle_message(messageIndex, duration, varValue);
2023 return ApiStatus_DONE2;
2024}
2025
2026API_CALLABLE(IsMessageBoxDisplayed) {
2027 Bytecode* args = script->ptrReadPos;
2028 s32 outVar = *args++;
2029
2030 evt_set_variable(script, outVar, btl_is_popup_displayed());
2031 return ApiStatus_DONE2;
2032}
2033
2034API_CALLABLE(WaitForMessageBoxDone) {
2036}
2037
2038API_CALLABLE(ForceCloseMessageBox) {
2039 if (bPopupMessage != NULL) {
2041 }
2042 return ApiStatus_DONE2;
2043}
2044
2045API_CALLABLE(SetMessageBoxDuration) {
2046 btl_set_popup_duration(evt_get_variable(script, *script->ptrReadPos));
2047 return ApiStatus_DONE2;
2048}
2049
2050API_CALLABLE(LockMessageBoxPosition) {
2052 return ApiStatus_DONE2;
2053}
2054
2055API_CALLABLE(UnlockMessageBoxPosition) {
2057 return ApiStatus_DONE2;
2058}
2059
2061 ActorPart* part = actor->partsTable;
2062
2063 while (part != NULL) {
2064 if (!(part->flags & ACTOR_PART_FLAG_INVISIBLE)
2065 && part->idleAnimations != NULL
2067 ) {
2068 f32 x = part->curPos.x;
2069 f32 y = part->curPos.y + (actor->size.y / 10);
2070 f32 z = part->curPos.z;
2071 s32 f1 = (part->size.x + (part->size.x / 4)) * actor->scalingFactor;
2072 s32 f2 = (part->size.y - 2) * actor->scalingFactor;
2073
2074 if (actor->flags & ACTOR_FLAG_HALF_HEIGHT) {
2075 y -= actor->size.y / 2;
2076 }
2077
2078 fx_flashing_box_shockwave(0, x, y, z, f1, f2);
2079 }
2080 part = part->nextPart;
2081 }
2082}
HudScript HES_MashBButton1
HudScript HES_BButton
HudScript HES_AButton
HudScript HES_TimingReady
HudScript HES_StickNeutral
HudScript HES_MashAButton
HudScript HES_PressAButton
HudScript HES_StickMashLeft
HudScript HES_AButtonDown
HudScript HES_PressBButton
@ ACTION_COMMAND_MODE_TUTORIAL
Definition action_cmd.h:40
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
HudScript HES_PressCDownButton
s32 * D_8028358C[]
Definition actors.c:210
u32 * idleAnimations
PopupMessageCallback updateFunc
f32 scalingFactor
PopupMessageCallback renderUIFunc
struct ActorPart * partsTable
s32 b32
Vec2bu size
f32 Matrix4f[4][4]
s16 b16
PopupMessageCallback renderWorldFunc
struct ActorPart * nextPart
union PopupMessage::@39 data
#define guRotateF
#define get_msg_width
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define clamp_angle
#define draw_msg
#define guScaleF
#define ASSERT(condition)
s32 EntityModelScript[]
Definition entity.h:7
s32 load_entity_model(EntityModelScript *cmdList)
@ ENTITY_MODEL_FLAG_HIDDEN
Definition enums.h:5015
@ BTL_MSG_STATE_POPUP_DISPOSE
Definition enums.h:4155
@ BTL_MSG_STATE_POPUP_POST_DELAY
Definition enums.h:4154
@ BTL_MSG_STATE_ERROR_PRE_DELAY
Definition enums.h:4160
@ BTL_MSG_STATE_DISABLED_DELAY
Definition enums.h:4165
@ BTL_MSG_STATE_INIT
Definition enums.h:4150
@ BTL_MSG_STATE_ACTION_TIP_DELAY
Definition enums.h:4157
@ BTL_MSG_STATE_ERROR_POST_DELAY
Definition enums.h:4162
@ BTL_MSG_STATE_ERROR_DISPOSE
Definition enums.h:4163
@ BTL_MSG_STATE_POPUP_PRE_DELAY
Definition enums.h:4152
@ BTL_MSG_STATE_ERROR_DELAY
Definition enums.h:4161
@ BTL_MSG_STATE_POPUP_DELAY
Definition enums.h:4153
@ BTL_MSG_STATE_ACTION_TIP_DISPOSE
Definition enums.h:4158
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_B
Definition enums.h:2789
@ BS_FLAGS1_10000
Definition enums.h:3585
@ BS_FLAGS1_SUPER_HIT
Definition enums.h:3579
@ BS_FLAGS1_NICE_HIT
Definition enums.h:3576
@ BS_FLAGS1_4000
Definition enums.h:3583
BattleMessages
Definition enums.h:4057
@ BTL_MSG_JUMP_DISABLED_1
Definition enums.h:4136
@ BTL_MSG_ACTION_TIP_HOLD_THEN_TAP
Definition enums.h:4119
@ BTL_MSG_ENEMY_MISSED
Definition enums.h:4067
@ BTL_MSG_CANT_SWITCH
Definition enums.h:4140
@ BTL_MSG_MERLEE_ATK_UP
Definition enums.h:4058
@ BTL_MSG_ITEMS_DISABLED
Definition enums.h:4139
@ BTL_MSG_ACTION_TIP_UNUSED_2
Definition enums.h:4112
@ BTL_MSG_PLAYER_FROZEN
Definition enums.h:4070
@ BTL_MSG_ACTION_TIP_MOVE_TO_AIM
Definition enums.h:4121
@ BTL_MSG_STAR_POWER_MAXED
Definition enums.h:4085
@ BTL_MSG_ACTION_TIP_UNUSED_3
Definition enums.h:4118
@ BTL_MSG_CANT_MOVE
Definition enums.h:4141
@ BTL_MSG_CHARGE_HAMMER_MORE
Definition enums.h:4063
@ BTL_MSG_ACTION_TIP_PRESS_BUTTONS_SHOWN
Definition enums.h:4113
@ BTL_MSG_PLAYER_POISONED
Definition enums.h:4071
@ BTL_MSG_MERLEE_EXP_UP
Definition enums.h:4060
@ BTL_MSG_TURBO_CHARGE_BEGIN
Definition enums.h:4100
@ BTL_MSG_TURBO_CHARGE_END
Definition enums.h:4101
@ BTL_MSG_ACTION_TIP_MASH_BUTTON
Definition enums.h:4108
@ BTL_MSG_PLAYER_PARALYZED
Definition enums.h:4073
@ BTL_MSG_ACTION_TIP_NOT_USED_3
Definition enums.h:4125
@ BTL_MSG_HEAL_ONE
Definition enums.h:4089
@ BTL_MSG_ENEMY_ASLEEP
Definition enums.h:4077
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:4074
@ BTL_MSG_ACTION_TIP_HOLD_LEFT_TIMED
Definition enums.h:4106
@ BTL_MSG_HAMMER_DISABLED_3
Definition enums.h:4135
@ BTL_MSG_CANT_SWITCH_UNUSED
Definition enums.h:4142
@ BTL_MSG_ACTION_TIP_NOT_USED_1
Definition enums.h:4114
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:4069
@ BTL_MSG_ENEMY_POISONED
Definition enums.h:4079
@ BTL_MSG_PLAYER_SHRUNK
Definition enums.h:4072
@ BTL_MSG_ENEMY_CANT_MOVE
Definition enums.h:4083
@ BTL_MSG_WATER_BLOCK_BEGIN
Definition enums.h:4096
@ BTL_MSG_47
Definition enums.h:4131
@ BTL_MSG_CANT_MOVE_UNUSED
Definition enums.h:4143
@ BTL_MSG_ACTION_TIP_UNUSED_4
Definition enums.h:4122
@ BTL_MSG_ENEMY_PARALYZED
Definition enums.h:4081
@ BTL_MSG_ACTION_TIP_HOLD_THEN_RELEASE
Definition enums.h:4120
@ BTL_MSG_UNUSED_CLOUD_NINE
Definition enums.h:4103
@ BTL_MSG_NO_JUMP_TARGET
Definition enums.h:4127
@ BTL_MSG_MERLEE_DONE
Definition enums.h:4061
@ BTL_MSG_ACTION_TIP_NOT_USED_2
Definition enums.h:4116
@ BTL_MSG_ACTION_TIP_BREAK_FREE
Definition enums.h:4123
@ BTL_MSG_ACTION_TIP_UNUSED_1
Definition enums.h:4111
@ BTL_MSG_LAST_ACTION_TIP
Definition enums.h:4126
@ BTL_MSG_CLOUD_NINE_END
Definition enums.h:4099
@ BTL_MSG_ACTION_TIP_HOLD_LEFT_AIM
Definition enums.h:4110
@ BTL_MSG_JUMP_DISABLED_3
Definition enums.h:4138
@ BTL_MSG_ENEMY_FROZEN
Definition enums.h:4078
@ BTL_MSG_NO_ITEM_TARGET
Definition enums.h:4129
@ BTL_MSG_ENEMY_DAZED
Definition enums.h:4076
@ BTL_MSG_HEAL_ALL
Definition enums.h:4090
@ BTL_MSG_CHILL_OUT_BEGIN
Definition enums.h:4102
@ BTL_MSG_WATER_BLOCK_END
Definition enums.h:4097
@ BTL_MSG_ACTION_TIP_PRESS_BEFORE_STRIKE
Definition enums.h:4107
@ BTL_MSG_CANT_SELECT_NOW
Definition enums.h:4132
@ BTL_MSG_ACTION_TIP_MASH_BOTH
Definition enums.h:4117
@ BTL_MSG_FIRST_ACTION_TIP
Definition enums.h:4104
@ BTL_MSG_MERLEE_DEF_UP
Definition enums.h:4059
@ BTL_MSG_46
Definition enums.h:4130
@ BTL_MSG_CHARGE_JUMP_MORE
Definition enums.h:4065
@ BTL_MSG_JUMP_DISABLED_2
Definition enums.h:4137
@ BTL_MSG_PARTNER_INJURED
Definition enums.h:4093
@ BTL_MSG_CHARGE_GOOMBARIO_MORE
Definition enums.h:4095
@ BTL_MSG_CANT_SELECT_NOW_ALT
Definition enums.h:4144
@ BTL_MSG_STAR_POWER_RECHARGED
Definition enums.h:4084
@ BTL_MSG_NO_HAMMER_TARGET
Definition enums.h:4128
@ BTL_MSG_DEFENCE_UP
Definition enums.h:4088
@ BTL_MSG_ACTION_TIP_PRESS_BEFORE_LANDING
Definition enums.h:4105
@ BTL_MSG_ACTION_TIP_PRESS_WITH_TIMING
Definition enums.h:4115
@ BTL_MSG_CANT_CHARGE
Definition enums.h:4066
@ BTL_MSG_CHARGE_HAMMER
Definition enums.h:4062
@ BTL_MSG_CHARGE_GOOMBARIO
Definition enums.h:4094
@ BTL_MSG_CLOUD_NINE_BEGIN
Definition enums.h:4098
@ BTL_MSG_ENEMY_ELECTRIFIED
Definition enums.h:4082
@ BTL_MSG_ATTACK_UP
Definition enums.h:4087
@ BTL_MSG_ACTION_TIP_REDUCE_DAMAGE
Definition enums.h:4124
@ BTL_MSG_CHARGE_JUMP
Definition enums.h:4064
@ BTL_MSG_ENEMY_TRANSPARENT
Definition enums.h:4091
@ BTL_MSG_ACTION_TIP_MASH_LEFT
Definition enums.h:4109
@ BTL_MSG_HAMMER_DISABLED_1
Definition enums.h:4133
@ BTL_MSG_ENEMY_SHRUNK
Definition enums.h:4080
@ BTL_MSG_PLAYER_DAZED
Definition enums.h:4068
@ BTL_MSG_PLAYER_TRANSPARENT
Definition enums.h:4075
@ BTL_MSG_HAMMER_DISABLED_2
Definition enums.h:4134
@ BTL_MSG_STAR_POWER_FILLED
Definition enums.h:4086
@ BTL_MSG_ENEMY_CHARGED
Definition enums.h:4092
@ WINDOW_PRIORITY_0
Definition enums.h:3182
@ MSG_PAL_0F
Definition enums.h:5420
@ WINDOW_UPDATE_SHOW
Definition enums.h:5311
@ WINDOW_UPDATE_SHOW_DARKENED
Definition enums.h:5318
@ WINDOW_UPDATE_HIDE
Definition enums.h:5312
@ WINDOW_UPDATE_SHOW_TRANSPARENT
Definition enums.h:5317
@ ACTOR_FLAG_HALF_HEIGHT
Definition enums.h:3335
@ ACTOR_PART_FLAG_SKIP_SHOCK_EFFECT
Definition enums.h:3365
@ ACTOR_PART_FLAG_INVISIBLE
Definition enums.h:3350
@ CAM_BATTLE
Definition enums.h:1801
@ WIN_BTL_POPUP
Definition enums.h:5250
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 sign(s32 value)
Definition 43F0.c:376
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void draw_entity_model_A(s32, Mtx *)
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void clear_entity_model_flags(s32 idx, s32 newFlags)
void set_entity_model_flags(s32 idx, s32 newFlags)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
void exec_entity_model_commandlist(s32 idx)
s32 heap_free(void *ptr)
Definition heap.c:42
void set_message_int_var(s32 value, s32 index)
Definition msg.c:1550
void set_message_text_var(s32 msgID, s32 index)
Definition msg.c:1520
void bind_entity_model_setupGfx(s32 idx, void *setupGfxCallbackArg0, void(*fpSetupGfxCallback)(void *))
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 free_entity_model_by_index(s32 idx)
void * heap_malloc(s32 size)
Definition heap.c:34
s32 get_msg_lines(s32 messageID)
Definition msg.c:1979
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_create_transform_B(s32 id)
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_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_draw_clipped(s32 id)
void hud_element_free(s32 id)
void func_80144218(s32 id)
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:88
s32 HudScript[]
Definition hud_element.h:9
void btl_set_popup_duration(s32 duration)
BSS PopupMessage popupMessages[32]
#define TIP_Y_PWT1
s32 bActorMessages[]
#define TIP_X_BF_RD
#define TIP_X_PWT1
#define TIP_SCALE1
s16 BattleMessage_TextOffsetsY[]
s16 BattleMessage_BoxOffsetsY[]
#define TIP_X_PBS2
void btl_popup_messages_draw_ui(void)
Vec3f BonkAnimScale[]
#define TIP_Y_MTA2
HudScript HES_Item_MenuItems
#define TIP_X_HTT
#define TIP_Y_PBS2
#define TIP_X_MTA3
PopupMessage * bPopupMessage
#define TIP_X_MTA1
void btl_bonk_setup_gfx(void *data)
void btl_show_variable_battle_message(s32 messageIndex, s32 duration, s32 varValue)
void btl_popup_messages_draw_world_geometry(void)
#define TIP_X_HLT2
void show_immune_bonk(f32 x, f32 y, f32 z, s32 numStars, s32 startupTime, s32 animDir)
HudScript HES_TimingBlink
BSS s16 BattleMessage_CurBoxOffsetY
BSS s16 BattleMessage_CurBoxPosY
#define TIP_Y_HTR1
#define TIP_X_HLA2
PopupMessage * btl_create_popup(void)
void close_action_command_instruction_popup(void)
#define TIP_X_PWT2
void btl_bonk_cleanup(void)
HudScript HES_MashCDownButton1
HudScript HES_Item_MenuBoots3
HudScript HES_Item_MenuHammer2
#define TIP_Y_PBS3
#define TIP_SCALE2
HudScript HES_CDownButton
HudScript HES_Item_MenuBoots1
#define TIP_X_HLT1
#define TIP_X_PBST
HudScript HES_Item_MenuBoots2
void btl_message_popup_draw_content(void *data, s32 x, s32 y)
#define TIP_X_HLA1
#define TIP_X_PBS3
HudScript HES_MashCLeftButton
BSS s16 HID_BattleMessage4
#define TIP_Y_MTA1
HudScript HES_StickTapRight
#define TIP_X_PBS1
HudScript HES_MashCRightButton1
BSS b16 BattleMessage_BoxPosLocked
void btl_update_message_popup(void *popup)
void btl_message_unlock_box_pos(void)
EntityModelScript EMS_BonkIcon
#define TIP_Y_PBS1
#define TIP_X_MTA2
#define TIP_X_MB1
void btl_show_battle_message(s32 messageIndex, s32 duration)
#define TIP_X_PRL
HudScript HES_StickBackAndForth
HudScript HES_CRightButton
BSS s16 HID_BattleMessage1
BSS s16 BattlePopupMessageVar
void btl_bonk_update(void *data)
#define TIP_Y_HLA2
#define TIP_Y_HLT2
#define TIP_X_ML
void btl_message_lock_box_pos(void)
#define TIP_Y_BF_RD
void btl_popup_messages_update(void)
void btl_popup_messages_init(void)
BSS s16 HID_BattleMessage2
#define TIP_X_HTR1
#define TIP_X_HTR2
HudScript HES_Item_MenuHammer3
#define TIP_X_MB
BSS b16 ActionCommandTipVisible
s16 BattleMessage_BoxSizesY[]
s32 entityModelIndex
HudScript HES_StickTapLeft
s32 btl_is_popup_displayed(void)
HudScript HES_Item_MenuHammer1
void apply_shock_effect(Actor *actor)
HudScript HES_MashBButton2
void btl_show_message_popup(void *popup)
void free_popup(PopupMessage *popup)
HudScript HES_AimTarget
HudScript HES_CLeftButton
Vec3f BonkAnimAccel[]
HudScript HES_MashCUpButton
void btl_popup_messages_delete(void)
BSS s16 HID_BattleMessage3
EntityModelScript * BonkModelScripts[]
HudScript HES_CUpButton
void btl_bonk_render(void *data)
#define TIP_X_MB2
HudScript HES_RotateStickCW
HudScript HES_AimReticle
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
BattleStatus gBattleStatus
Definition battle.c:11
Window gWindows[64]
Definition windows.c:23