Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
player_events.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3#include "model.h"
4#include "hud_element.h"
5#include "script_api/battle.h"
6#include "sprite/npc/Twink.h"
7#include "sprite/npc/BattleMerlee.h"
9#include "battle/battle.h"
10#include "sprite/player.h"
11
12extern HudScript HES_Happy;
14
19
21
31
32enum {
33 MERLEE_EFFECTS_HOLD = 0, // effects appear and track Merlee's position
34 MERLEE_EFFECTS_RELEASE = 1, // effects grow larger before vanishing
35 MERLEE_EFFECTS_DISMISS = 2, // effects vanish and are dismissed
36};
37
39
42 ActorPart* actorPart = &battleStatus->playerActor->partsTable[0];
43
47 } else if (!battleStatus->outtaSightActive) {
48 actorPart->idleAnimations = bMarioIdleAnims;
49 }
50}
51
52API_CALLABLE(IsPlayerImmobile) {
54 Actor* playerActor = battleStatus->playerActor;
55 s32 isImmobile = playerActor->debuff == STATUS_KEY_UNUSED
56 || playerActor->debuff == STATUS_KEY_DIZZY
57 || playerActor->debuff == STATUS_KEY_PARALYZE
58 || playerActor->debuff == STATUS_KEY_SLEEP
59 || playerActor->debuff == STATUS_KEY_FROZEN
60 || playerActor->debuff == STATUS_KEY_STOP;
61
62 if (playerActor->stoneStatus == STATUS_KEY_STONE) {
64 }
65
66 script->varTable[0] = isImmobile;
67 return ApiStatus_DONE2;
68}
69
70API_CALLABLE(ActivateDefend) {
72
75 actorPart->idleAnimations = bMarioDefendAnims;
77 return ApiStatus_DONE2;
78}
79
80// (out) LVar0: skip playing lucky animation
81API_CALLABLE(TryPlayerLucky) {
83
84 show_action_rating(ACTION_RATING_LUCKY, player, player->curPos.x, player->curPos.y + 20.0f, player->curPos.z);
86
87 script->varTable[0] = FALSE;
88 if (player->debuff == STATUS_KEY_UNUSED
89 || player->debuff == STATUS_KEY_DIZZY
90 || player->debuff == STATUS_KEY_PARALYZE
91 || player->debuff == STATUS_KEY_SLEEP
92 || player->debuff == STATUS_KEY_FROZEN
93 || player->debuff == STATUS_KEY_STOP
94 ) {
95 script->varTable[0] = TRUE;
96 }
97 return ApiStatus_DONE2;
98}
99
100API_CALLABLE(ChoosePlayerCelebrationAnim) {
103 s32 weight;
104 s32 i;
105
106 if (rand_int(celebrations->randomChance + celebrations->hpBasedChance) < celebrations->randomChance) {
107 optionSet = 0;
108 } else {
110
111 if (healthRatio <= 0.25) {
112 optionSet = 1;
113 } else if (healthRatio <= 0.5) {
114 optionSet = 2;
115 } else if (healthRatio <= 0.75) {
116 optionSet = 3;
117 } else {
118 optionSet = 4;
119 }
120 }
121
122 weight = 0;
123 for (i = 0; i < 8; i++) {
124 weight += celebrations->options[optionSet][i].weight;
125 }
126 weight = rand_int(weight);
127 for (i = 0; i < 8; i++) {
128 weight -= celebrations->options[optionSet][i].weight;
129 if (weight <= 0) {
130 break;
131 }
132 }
133
134 script->varTable[0] = celebrations->options[optionSet][i].anim;
135
136 return ApiStatus_DONE2;
137}
138
139API_CALLABLE(SetFledBattleFlag) {
141 return ApiStatus_DONE2;
142}
143
144API_CALLABLE(DetermineAutoRunAwaySuccess) {
146 s32 var;
147
149 return ApiStatus_DONE2;
150 }
151
152 var = player->state.varTable[0];
153 if (var >= rand_int(100)) {
154 script->varTable[0] = TRUE;
155 } else {
156 script->varTable[0] = FALSE;
157 }
158 return ApiStatus_DONE2;
159}
160
161API_CALLABLE(func_80260E38) {
163 return ApiStatus_DONE2;
164}
165
166API_CALLABLE(func_80260E5C) {
170 return ApiStatus_DONE2;
171}
172
173// out LVar0: time caller should wait for coin spawns
174API_CALLABLE(GiveRefund) {
176 Actor* player = battleStatus->playerActor;
177 s32 sellValue = gItemTable[battleStatus->moveArgument].sellValue;
178 f32 angle = 0.0f;
179 s32 delayTime = 0;
180 f32 posX, posY, posZ;
181 posY = player->curPos.y + player->size.y;
182
183 if (player_team_is_ability_active(player, ABILITY_REFUND) && sellValue > 0) {
184 s32 i;
186
187 // 75% of the item's sell value, rounded up
188 sellValue = (sellValue * 75 + 99) / 100;
189
190 for (i = 0; i < sellValue; i++) {
191 posX = player->curPos.x;
192 posZ = player->curPos.z;
193
194 make_item_entity(ITEM_COIN, posX, posY, posZ, ITEM_SPAWN_MODE_TOSS_FADE1, (i * 3) + 1, angle, 0);
195 add_coins(1);
196 angle += 30.0f;
197 }
198
199 delayTime = (i * 3) + 30;
200
201 posX = player->curPos.x;
202 posY = player->curPos.y;
203 posZ = player->curPos.z;
207 }
208
209 script->varTable[0] = delayTime;
210
211 return ApiStatus_DONE2;
212}
213
214API_CALLABLE(GiveRefundCleanup) {
216
219 }
220
221 return ApiStatus_DONE2;
222}
223
224API_CALLABLE(LifeShroomShroudWorld) {
225 if (isInitialCall) {
228 mdl_set_shroud_tint_params(0, 0, 0, 0);
229 script->functionTemp[0] = 20;
230 }
231
232 mdl_set_shroud_tint_params(0, 0, 0, ((20 - script->functionTemp[0]) * 12) & 0xFC);
233
234 script->functionTemp[0]--;
235
236 if (script->functionTemp[0] == 0) {
237 return ApiStatus_DONE2;
238 }
239
240 return ApiStatus_BLOCK;
241}
242
243API_CALLABLE(LifeShroomRevealWorld) {
244 if (isInitialCall) {
245 script->functionTemp[0] = 20;
247 }
248
249 mdl_set_shroud_tint_params(0, 0, 0, (script->functionTemp[0] * 12) & 0xFC);
250
251 script->functionTemp[0]--;
252 if (script->functionTemp[0] == 0) {
253 mdl_set_shroud_tint_params(0, 0, 0, 0);
254 return ApiStatus_DONE2;
255 }
256
257 return ApiStatus_BLOCK;
258}
259
260API_CALLABLE(ConsumeLifeShroom) {
263
264 playerData->curHP += item->potencyA;
265 if (playerData->curMaxHP < playerData->curHP) {
266 playerData->curHP = playerData->curMaxHP;
267 }
270 script->varTable[3] = item->potencyA;
271
272 return ApiStatus_DONE2;
273}
274
275API_CALLABLE(RestorePreDefeatState) {
278
282
283 // clear rush flags to initialize
284 battleStatus->rushFlags = RUSH_FLAG_NONE;
286
287 // set rush flags based on danger/peril status
288 if (!(battleStatus->flags2 & BS_FLAGS2_PEACH_BATTLE)) {
291 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
292 }
293
295 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
297 battleStatus->rushFlags |= RUSH_FLAG_POWER;
298 }
299 }
300 }
301 return ApiStatus_DONE2;
302}
303
304API_CALLABLE(func_80261388) {
306
307 script->varTable[0] = FALSE;
308 if (partnerActorExists) {
309 script->varTable[0] = TRUE;
310 }
311 return ApiStatus_DONE2;
312}
313
314API_CALLABLE(SetItemAsLifeShroom) {
316 return ApiStatus_DONE2;
317}
318
319API_CALLABLE(PlayBattleMerleeGatherFX) {
320 Bytecode* args = script->ptrReadPos;
321 s32 var1 = evt_get_variable(script, *args++);
322 s32 var2 = evt_get_variable(script, *args++);
323 s32 var3 = evt_get_variable(script, *args++);
324
325 fx_energy_in_out(6, var1, var2 + 15, var3, 1.2f, 30);
326 return ApiStatus_DONE2;
327}
328
329API_CALLABLE(PlayBattleMerleeOrbFX) {
330 Bytecode* args = script->ptrReadPos;
331 s32 var1 = evt_get_variable(script, *args++);
332 s32 var2 = evt_get_variable(script, *args++);
333 s32 var3 = evt_get_variable(script, *args++);
334
335 fx_energy_orb_wave(9, var1, var2 + 15, var3, 5.0f, 15);
336 return ApiStatus_DONE2;
337}
338
339API_CALLABLE(BattleMerleeFadeStageToBlack) {
340 if (isInitialCall) {
343 mdl_set_shroud_tint_params(0, 0, 0, 0);
344 script->functionTemp[0] = 25;
345 }
346
347 mdl_set_shroud_tint_params(0, 0, 0, ((25 - script->functionTemp[0]) * 10) & 254);
348 script->functionTemp[0]--;
349
350 if (script->functionTemp[0] == 0) {
351 return ApiStatus_DONE2;
352 } else {
353 return ApiStatus_BLOCK;
354 }
355}
356
357API_CALLABLE(BattleMerleeFadeStageFromBlack) {
358 if (isInitialCall) {
359 script->functionTemp[0] = 25;
360 }
361
362 mdl_set_shroud_tint_params(0, 0, 0, (script->functionTemp[0] * 10) & 0xFF);
363
364 script->functionTemp[0] -= 5;
365 if (script->functionTemp[0] == 0) {
366 mdl_set_shroud_tint_params(0, 0, 0, 0);
367 return ApiStatus_DONE2;
368 }
369
370 return ApiStatus_BLOCK;
371}
372
373API_CALLABLE(BattleFadeInMerlee) {
375
376 if (isInitialCall) {
378 merlee->alpha = 0;
379 }
380
381 merlee->alpha += 17;
382 if (merlee->alpha >= 255) {
383 merlee->alpha = 255;
384 return ApiStatus_DONE1;
385 }
386
387 return ApiStatus_BLOCK;
388}
389
390API_CALLABLE(BattleFadeOutMerlee) {
392
393 merlee->alpha -= 17;
394 if (merlee->alpha == 0) {
395 merlee->alpha = 0;
396 return ApiStatus_DONE1;
397 }
398
399 return ApiStatus_BLOCK;
400}
401
402API_CALLABLE(BattleMerleeUpdateFX) {
405
406 if (isInitialCall) {
407 script->functionTemp[1] = 0;
409 BattleMerleeOrbEffect = fx_energy_orb_wave(0, merlee->pos.x, merlee->pos.y, merlee->pos.z, 0.4f, 0);
410 BattleMerleeWaveEffect = fx_energy_orb_wave(3, merlee->pos.x, merlee->pos.y, merlee->pos.z, 0.00001f, 0);
414 }
415 merlee->pos.y = BattleMerleeBasePosY + (sin_rad(DEG_TO_RAD(script->functionTemp[1])) * 3.0f);
416
417 script->functionTemp[1] += 10;
418 script->functionTemp[1] = clamp_angle(script->functionTemp[1]);
419
421 data->pos.x = merlee->pos.x;
422 data->pos.y = merlee->pos.y + 16.0f;
423 data->pos.z = merlee->pos.z;
424
426 data->pos.x = merlee->pos.x;
427 data->pos.y = merlee->pos.y + 16.0f;
428 data->pos.z = merlee->pos.z + 5.0f;
429
435 return ApiStatus_DONE1;
436 }
437
440 data->scale += 0.35;
441 if (data->scale > 3.5) {
442 data->scale = 3.5;
443 }
444
445 if (BattleMerleeEffectsTime != 0) {
447 } else {
449 data->scale += 0.5;
450 if (data->scale > 5.0) {
452 }
453 }
454 }
455 return ApiStatus_BLOCK;
456}
457
458API_CALLABLE(BattleMerleeStopFX) {
460 return ApiStatus_DONE2;
461}
462
463API_CALLABLE(HasMerleeCastsLeft) {
465
466 script->varTable[0] = FALSE;
467 if (playerData->merleeCastsLeft > 0) {
468 script->varTable[0] = TRUE;
469 }
470 return ApiStatus_DONE2;
471}
472
473API_CALLABLE(SpawnTurnEndFX) {
474 Bytecode* args = script->ptrReadPos;
475 s32 x = evt_get_variable(script, *args++);
476 s32 y = evt_get_variable(script, *args++);
477 s32 z = evt_get_variable(script, *args++);
478 s32 screenX;
479 s32 screenY;
480 s32 screenZ;
481
483
484 screenX += 30;
485 screenY -= 19;
486
487 if (script->varTable[10] > 0) {
490 screenY += 9;
491 }
492
493 if (script->varTable[11] > 0 || script->varTable[12] > 0) {
496 }
497 return ApiStatus_DONE2;
498}
499
500API_CALLABLE(RemoveTurnEndFX) {
501 if (script->varTable[10] > 0) {
503 }
504 if (script->varTable[11] > 0 || script->varTable[12] > 0) {
506 }
507 return ApiStatus_DONE2;
508}
509
510API_CALLABLE(SpawnRecoverHeartFX) {
511 Bytecode* args = script->ptrReadPos;
512 s32 var1 = evt_get_variable(script, *args++);
513 s32 var2 = evt_get_variable(script, *args++);
514 s32 var3 = evt_get_variable(script, *args++);
515 s32 var4 = evt_get_variable(script, *args++);
516
517 fx_recover(0, var1, var2, var3, var4);
518 return ApiStatus_DONE2;
519}
520
521API_CALLABLE(SpawnRecoverFlowerFX) {
522 Bytecode* args = script->ptrReadPos;
523 s32 var1 = evt_get_variable(script, *args++);
524 s32 var2 = evt_get_variable(script, *args++);
525 s32 var3 = evt_get_variable(script, *args++);
526 s32 var4 = evt_get_variable(script, *args++);
527
528 fx_recover(1, var1, var2, var3, var4);
529 return ApiStatus_DONE2;
530}
531
532API_CALLABLE(IncrementPlayerHP) {
534
535 playerData->curHP++;
536 if (playerData->curHP > playerData->curMaxHP) {
537 playerData->curHP = playerData->curMaxHP;
538 }
539 return ApiStatus_DONE2;
540}
541
542API_CALLABLE(IncrementPlayerFP) {
544
545 playerData->curFP++;
546 if (playerData->curFP > playerData->curMaxFP) {
547 playerData->curFP = playerData->curMaxFP;
548 }
549 return ApiStatus_DONE2;
550}
551
552API_CALLABLE(InflictDizzyAttackStatus) {
555 return ApiStatus_DONE2;
556}
557
558API_CALLABLE(GetLostHammerAndBootsLevel) {
560
561 script->varTable[11] = playerData->bootsLevel;
562 script->varTable[12] = playerData->hammerLevel;
563 return ApiStatus_DONE2;
564}
565
566API_CALLABLE(DropAbilityItem) {
567 ItemEntity* item = get_item_entity(script->varTable[10]);
568
569 if (isInitialCall) {
570 script->functionTemp[0] = 0;
571 script->functionTemp[1] = 0;
572 }
573
574 switch (script->functionTemp[1]) {
575 case 0:
576 script->functionTemp[0]--;
577 item->pos.y += script->functionTemp[0];
578 if (item->pos.y < 0.0f) {
579 item->pos.y = 0.0f;
580 script->functionTemp[0] = 8;
581 script->functionTemp[1] = 1;
582 }
583 break;
584 case 1:
585 script->functionTemp[0]--;
586 item->pos.y += script->functionTemp[0];
587 item->pos.x += 1.5;
588 if (item->pos.y < 0.0f) {
589 item->pos.y = 0.0f;
590 script->functionTemp[0] = 4;
591 script->functionTemp[1] = 2;
592 }
593 break;
594 case 2:
595 script->functionTemp[0]--;
596 item->pos.y += script->functionTemp[0];
597 item->pos.x += 1.2;
598 if (item->pos.y < 0.0f) {
599 item->pos.y = 0.0f;
600 script->functionTemp[1] = 3;
601 }
602 break;
603 case 3:
604 D_8029FBB0[0] = 20;
605 D_8029FBB0[1] = 20;
606 D_8029FBB0[2] = 20;
607 return ApiStatus_DONE2;
608 }
609 return ApiStatus_BLOCK;
610}
611
612API_CALLABLE(PlayerGatherAbilityItem) {
613 ItemEntity* item = get_item_entity(script->varTable[10]);
616 f32 deltaX;
617 f32 deltaY;
618 f32 deltaZ;
619
620 if (isInitialCall) {
621 script->functionTemp[0] = 0;
622 script->functionTemp[1] = 10;
623 }
624
625 switch (script->functionTemp[0]) {
626 case 0:
627 interpAmt = script->functionTemp[1];
628 deltaX = player->curPos.x - item->pos.x;
629 deltaY = player->curPos.y + 12.0f - item->pos.y;
630 deltaZ = player->curPos.z - 5.0f - item->pos.z;
631
632 item->pos.x += deltaX / interpAmt;
633 item->pos.y += deltaY / interpAmt;
634 item->pos.z += deltaZ / interpAmt;
635
636 item->pos.y += dist2D(item->pos.x, item->pos.y, player->curPos.x,
637 player->curPos.y + 12.0f) / 5.0f;
638
639 if (script->functionTemp[1] == 1) {
640 script->functionTemp[0] = 1;
641 }
642
643 script->functionTemp[1]--;
644 break;
645 case 1:
646 return ApiStatus_DONE2;
647 }
648 return ApiStatus_BLOCK;
649}
650
651API_CALLABLE(AbilityItemUnkDelay) {
652 s32* delayCounter = &D_8029FBB0[script->varTable[14]];
653
654 if (*delayCounter != 0) {
655 (*delayCounter)--;
656 return ApiStatus_BLOCK;
657 }
658
659 return ApiStatus_DONE2;
660}
661
666
671
674 Call(SetBattleCamTarget, -80, 35, 8)
677 Sub(LVar0, 100)
679 Call(RandInt, 100, LVar0)
681 CaseGt(50)
686 CaseGt(20)
691 Call(PlayerHopToGoal, 18, 0, 0)
693 Wait(7)
701 Call(ShakeCam, 1, 0, 5, Float(1.0))
705 Wait(10)
707 Wait(10)
710 Return
711 End
712};
713
740
772
782
806
819
836
842
860 Sub(LVar0, 60)
861 Add(LVar1, 40)
865 Call(PlayerHopToGoal, 5, 0, 1)
867 Set(LVar2, 0)
872 Add(LVar0, 30)
873 Set(LVar1, 0)
876 Call(PlayerHopToGoal, 10, 0, 2)
877 Sub(LVar0, 20)
879 Call(PlayerHopToGoal, 7, 0, 2)
880 Sub(LVar0, 10)
882 Call(PlayerHopToGoal, 4, 0, 2)
883 IfEq(LVarF, 39)
884 Return
885 EndIf
892 Sub(LVar0, 60)
893 Add(LVar1, 40)
897 Call(PlayerHopToGoal, 5, 0, 1)
900 Add(LVar5, 5)
901 Add(LVar6, 4)
902 Add(LVar7, 5)
904 Wait(2)
906 Add(LVar5, -5)
907 Add(LVar6, 18)
908 Add(LVar7, 5)
912 Set(LVar2, 0)
917 Add(LVar0, 30)
918 Set(LVar1, 0)
921 Call(PlayerHopToGoal, 10, 0, 2)
922 Sub(LVar0, 20)
924 Call(PlayerHopToGoal, 7, 0, 2)
925 Sub(LVar0, 10)
927 Call(PlayerHopToGoal, 4, 0, 2)
928 IfEq(LVarF, 36)
929 Return
930 EndIf
937 Sub(LVar0, 60)
938 Add(LVar1, 40)
942 Call(PlayerHopToGoal, 5, 0, 1)
945 Set(LVar2, 0)
950 Add(LVar0, 30)
951 Set(LVar1, 0)
954 Call(PlayerHopToGoal, 10, 0, 2)
955 Sub(LVar0, 20)
957 Call(PlayerHopToGoal, 7, 0, 2)
958 Sub(LVar0, 10)
960 Call(PlayerHopToGoal, 4, 0, 2)
961 IfEq(LVarF, 38)
962 Return
963 EndIf
969 Wait(30)
971 Else
972 Wait(30)
973 EndIf
979 Call(PlayerHopToGoal, 15, 0, 0)
987 Wait(10)
993 Call(PlayerHopToGoal, 15, 0, 0)
1003 Set(LVar2, 0)
1016 SetConst(LVar0, 1)
1019 Wait(10)
1023 Set(LVar2, 0)
1028 Set(LVar2, 0)
1031 Return
1034 Set(LVar2, 0)
1036 Return
1042 Call(PlayerHopToGoal, 15, 0, 0)
1045 EndSwitch
1047 Return
1048 End
1049};
1050
1052 Set(LVar0, 0)
1053 Loop(5)
1054 Add(LVar0, 72)
1056 Wait(1)
1057 EndLoop
1060 Wait(31)
1061 Return
1062 End
1063};
1064
1069 Wait(1)
1071 Wait(1)
1073 Wait(1)
1075 Wait(1)
1077 Wait(1)
1079 Wait(5)
1080 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1081 Wait(2)
1082 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1083 Wait(5)
1084 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1085 Wait(2)
1086 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1087 Wait(2)
1088 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1089 Wait(5)
1090 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1091 Wait(2)
1092 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1093 Wait(5)
1094 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1095 Wait(15)
1100 Call(PlayerHopToGoal, 8, 0, 0)
1102 IfEq(LVar0, 1)
1105 Call(SetGoalPos, ACTOR_PLAYER, -240, 0, 10)
1108 Wait(5)
1109 Else
1111 Call(ShakeCam, 1, 0, 5, Float(1.0))
1115 Call(SetGoalPos, ACTOR_PLAYER, -100, 0, 10)
1118 Set(LVar3, 6)
1121 Loop(2)
1124 Wait(5)
1125 EndLoop
1127 Loop(10)
1128 Sub(LVar0, LVar3)
1129 Sub(LVar3, 1)
1130 IfLt(LVar3, 1)
1131 Set(LVar3, 1)
1132 EndIf
1134 Wait(1)
1135 EndLoop
1136 Wait(15)
1139 Wait(20)
1142 Wait(7)
1143 Loop(2)
1145 Sub(LVar0, 8)
1146 Add(LVar1, 14)
1147 Add(LVar2, 5)
1149 Wait(5)
1150 EndLoop
1152 Wait(5)
1154 Wait(10)
1155 EndIf
1157 Return
1158 End
1159};
1160
1167 Return
1168 EndIf
1173 Call(SetupMashMeter, 1, 100, 0, 0, 0, 0)
1178 Wait(1)
1180 Wait(1)
1182 Wait(1)
1184 Wait(1)
1186 Wait(1)
1188 Wait(5)
1191 Wait(5)
1192 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1193 Wait(2)
1194 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1195 Wait(5)
1196 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1197 Wait(2)
1198 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1199 Wait(2)
1200 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1201 Wait(5)
1202 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1203 Wait(2)
1204 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1205 Wait(5)
1206 Call(AddActorPos, ACTOR_PLAYER, 2, 0, 0)
1207 Wait(15)
1208 Wait(30)
1213 Call(PlayerHopToGoal, 8, 0, 0)
1216 IfEq(LVar0, 1)
1219 Call(SetGoalPos, ACTOR_PLAYER, -240, 0, 10)
1222 Wait(5)
1223 Else
1225 Call(ShakeCam, 1, 0, 5, Float(1.0))
1229 Call(SetGoalPos, ACTOR_PLAYER, -100, 0, 10)
1232 Set(LVar3, 6)
1235 Loop(2)
1238 Wait(5)
1239 EndLoop
1241 Loop(10)
1242 Sub(LVar0, LVar3)
1243 Sub(LVar3, 1)
1244 IfLt(LVar3, 1)
1245 Set(LVar3, 1)
1246 EndIf
1248 Wait(1)
1249 EndLoop
1250 Wait(15)
1253 Wait(20)
1256 Wait(7)
1257 Loop(2)
1259 Sub(LVar0, 8)
1260 Add(LVar1, 14)
1261 Add(LVar2, 5)
1263 Wait(5)
1264 EndLoop
1266 Wait(5)
1268 Wait(10)
1269 EndIf
1271 Return
1272 End
1273};
1274
1287
1334
1376
1397
1409
1422
1435
1440 IfEq(LVar0, 1)
1443 Set(LVar0, 255)
1444 Loop(10)
1445 Sub(LVar0, 25)
1446 IfLt(LVar0, 0)
1447 Set(LVar0, 0)
1448 EndIf
1450 Wait(1)
1451 EndLoop
1453 EndIf
1458 Set(LVarA, LVar0)
1460 Set(LVar3, 30)
1461 Set(LVar4, 16)
1462 Loop(LVar3)
1463 Add(LVar4, 8)
1464 IfGt(LVar4, 255)
1465 Set(LVar4, 255)
1466 EndIf
1467 AddF(LVar1, Float(1.0))
1469 Wait(1)
1470 EndLoop
1471 Set(LVar3, LVar0)
1472 Set(LVar4, LVar1)
1473 Set(LVar5, LVar2)
1476 IfGt(LVar0, 0)
1477 Wait(LVar0)
1478 Wait(15)
1480 EndIf
1482 Add(LVar4, 15)
1484 Set(LVar0, LVarF)
1485 Loop(4)
1486 Call(SetItemFlags, LVarA, 64, 1)
1487 Wait(2)
1488 Call(SetItemFlags, LVarA, 64, 0)
1489 Wait(8)
1490 EndLoop
1494 PlayEffect(EFFECT_STARS_SHIMMER, 1, LVar3, LVar4, LVar5, 70, 70, 10, 20)
1495 Wait(20)
1498 PlayEffect(EFFECT_STARS_SHIMMER, 2, LVar0, LVar1, LVar2, 50, 20, 32, 30)
1499 Wait(40)
1500 PlayEffect(EFFECT_STARS_SHIMMER, 2, LVar0, LVar1, LVar2, 30, 50, 32, 30)
1502 Loop(3)
1504 Wait(4)
1506 Wait(4)
1507 EndLoop
1508 Loop(3)
1510 Wait(2)
1512 Wait(2)
1513 EndLoop
1514 Loop(7)
1516 Wait(1)
1518 Wait(1)
1519 EndLoop
1521 Wait(50)
1530 Add(LVar1, 25)
1537 IfEq(LVar0, 1)
1539 Set(LVar0, 0)
1540 Loop(10)
1541 Add(LVar0, 25)
1542 IfGt(LVar0, 255)
1543 Set(LVar0, 255)
1544 EndIf
1546 Wait(1)
1547 EndLoop
1550 EndIf
1553 Loop(5)
1554 Wait(2)
1556 PlayEffect(EFFECT_MISC_PARTICLES, 2, LVar0, LVar1, LVar2, 20, 20, Float(1.0), 10, 50)
1557 EndLoop
1563 Set(LVar1, 0)
1566 Call(PlayerHopToGoal, 20, 0, 0)
1568 Wait(4)
1570 Wait(10)
1573 Return
1574 End
1575};
1576
1588
1592 Wait(10)
1594 Call(SetBattleCamTarget, 0, 80, 0)
1598 Wait(10)
1602 Call(SetNpcPos, NPC_BTL_MERLEE, 0, 65, 20)
1607 Wait(30)
1613 Wait(20)
1622 Wait(15)
1627 Call(PlayerHopToGoal, 18, 0, 0)
1629 Wait(4)
1634 Return
1635 End
1636};
1637
1641 Wait(10)
1643 Call(SetBattleCamTarget, 0, 80, 0)
1647 Wait(10)
1651 Call(SetNpcPos, NPC_BTL_MERLEE, 0, 65, 20)
1656 Wait(30)
1662 Wait(20)
1671 Wait(15)
1674 Wait(22)
1675 Else
1680 Call(PlayerHopToGoal, 18, 0, 0)
1682 Wait(4)
1684 EndIf
1688 Return
1689 End
1690};
1691
1695 Wait(10)
1697 Call(SetBattleCamTarget, 0, 80, 0)
1701 Wait(10)
1705 Call(SetNpcPos, NPC_BTL_MERLEE, 0, 65, 20)
1710 Wait(30)
1716 Wait(20)
1725 Wait(15)
1730 Call(PlayerHopToGoal, 18, 0, 0)
1732 Wait(4)
1737 Return
1738 End
1739};
1740
1794
1796 Set(LVar0, 0)
1797 Loop(40)
1798 Add(LVar0, 72)
1800 Wait(1)
1801 EndLoop
1804 Return
1805 End
1806};
1807
BSS s32 PopupMenu_SelectedIndex
@ AC_DIFFICULTY_3
Definition action_cmd.h:45
@ AC_MODE_NOT_LEARNED
Definition action_cmd.h:60
u32 * idleAnimations
ActorState state
struct ActorPart * partsTable
s32 HudElemID
Vec2bu size
Vec3f curPos
Bytecode EvtScript[]
#define rand_int
#define clamp_angle
EffectInstanceDataPtr data
Definition effects.h:2605
struct EnergyOrbWaveFXData * energyOrbWave
Definition effects.h:2546
#define STATUS_FLAGS_IMMOBILIZED
Definition enums.h:2868
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3551
@ ACTION_RATING_LUCKY
clears nice hits
Definition enums.h:2007
@ ENV_TINT_SHROUD
Definition enums.h:3972
@ ACTION_COMMAND_FLEE
Definition enums.h:3509
@ BS_FLAGS1_BATTLE_FLED
Definition enums.h:3620
@ BS_FLAGS1_PLAYER_DEFENDING
Definition enums.h:3624
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3601
@ BS_FLAGS1_4000
Definition enums.h:3616
@ BS_FLAGS1_EXECUTING_MOVE
Definition enums.h:3611
@ BTL_MSG_MERLEE_ATK_UP
Definition enums.h:3700
@ BTL_MSG_MERLEE_EXP_UP
Definition enums.h:3702
@ BTL_MSG_ACTION_TIP_MASH_BUTTON
Definition enums.h:3750
@ BTL_MSG_MERLEE_DONE
Definition enums.h:3703
@ BTL_MSG_MERLEE_DEF_UP
Definition enums.h:3701
@ RUSH_FLAG_NONE
Definition enums.h:4915
@ RUSH_FLAG_MEGA
Definition enums.h:4916
@ RUSH_FLAG_POWER
Definition enums.h:4917
@ ITEM_SPAWN_MODE_TOSS_FADE1
Definition enums.h:2300
@ PHASE_PLAYER_HAPPY
Definition enums.h:2106
@ PHASE_MERLEE_ATTACK_BONUS
Definition enums.h:2103
@ PHASE_USE_DEFEND
Definition enums.h:2096
@ PHASE_RUN_AWAY_START
Definition enums.h:2093
@ PHASE_EXECUTE_ACTION
Definition enums.h:2091
@ PHASE_MERLEE_EXP_BONUS
Definition enums.h:2105
@ PHASE_CELEBRATE
Definition enums.h:2095
@ PHASE_USE_LIFE_SHROOM
Definition enums.h:2098
@ PHASE_MERLEE_DEFENSE_BONUS
Definition enums.h:2104
@ PHASE_DEATH
Definition enums.h:2094
@ PHASE_RUN_AWAY_FAIL
Definition enums.h:2097
@ PHASE_FIRST_STRIKE
Definition enums.h:2092
@ BTL_MENU_TYPE_SMASH
Definition enums.h:3827
@ BTL_MENU_TYPE_JUMP
Definition enums.h:3826
@ BTL_MENU_TYPE_STAR_POWERS
Definition enums.h:3834
@ BTL_MENU_TYPE_ITEMS
Definition enums.h:3828
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3654
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ STATUS_KEY_PARALYZE
Definition enums.h:2806
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ STATUS_KEY_UNUSED
Definition enums.h:2804
@ STATUS_KEY_STONE
Definition enums.h:2813
@ STATUS_KEY_STOP
Definition enums.h:2809
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BTL_CAM_PLAYER_ENTRY
Definition enums.h:4429
@ BTL_CAM_PLAYER_HIT_HAZARD
Definition enums.h:4438
@ BTL_CAM_REPOSITION
Definition enums.h:4426
@ BTL_CAM_PLAYER_WISH
Definition enums.h:4476
@ BTL_CAM_PLAYER_HIT_SPIKE
Definition enums.h:4437
@ BTL_CAM_PLAYER_DIES
Definition enums.h:4431
@ NPC_BTL_MERLEE
Definition enums.h:2515
@ ABILITY_POWER_RUSH
Definition enums.h:466
@ ABILITY_REFUND
Definition enums.h:465
@ ABILITY_MEGA_RUSH
Definition enums.h:456
@ SOUND_PLAYER_RUN_IN_PLACE
Definition enums.h:783
@ SOUND_MAGIC_DESCENDING
Definition enums.h:1417
@ SOUND_REVIVAL_MAGIC
Definition enums.h:1190
@ SOUND_NO_DAMGE
Definition enums.h:1436
@ SOUND_START_RECOVERY
Definition enums.h:1388
@ SOUND_PLAYER_REVIVE
Definition enums.h:1191
@ SOUND_MAGIC_ASCENDING
Definition enums.h:1416
@ SOUND_LUCKY
Definition enums.h:1316
@ SOUND_EAT_OR_DRINK
Definition enums.h:1444
@ SOUND_TRIP
Definition enums.h:787
@ SOUND_MERLEE_APPEAR
Definition enums.h:975
@ SOUND_PLAYER_COLLAPSE
Definition enums.h:1315
@ SOUND_DUST_OFF
Definition enums.h:794
@ SOUND_LIFE_SHROOM_CHIME
Definition enums.h:1189
@ SOUND_USE_ITEM
Definition enums.h:1437
@ SOUND_PLAYER_RUN_AWAY
Definition enums.h:784
@ SOUND_LONG_PLAYER_JUMP
Definition enums.h:785
@ SOUND_PLAYER_SPINNING
Definition enums.h:1188
@ GEAR_RANK_SUPER
Definition enums.h:2046
@ GEAR_RANK_ULTRA
Definition enums.h:2047
@ GEAR_RANK_NORMAL
Definition enums.h:2045
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_PARTNER
Definition enums.h:2119
@ ACTOR_ENEMY0
Definition enums.h:2120
@ ACTOR_SELF
Definition enums.h:2117
@ ACTOR_FLAG_NO_SHADOW
Hide shadow.
Definition enums.h:3359
@ ACTOR_BLUR_ENABLE
Definition enums.h:6005
@ ACTOR_BLUR_DISABLE
Definition enums.h:6004
@ EVENT_LUCKY
Definition enums.h:2205
@ EVENT_HIT
Definition enums.h:2165
@ EVENT_SPIKE_DEATH
Definition enums.h:2193
@ EVENT_BURN_HIT
Definition enums.h:2169
@ EVENT_SPIKE_CONTACT
Definition enums.h:2196
@ EVENT_FIRE_DEATH
Definition enums.h:2195
@ EVENT_IMMUNE
Definition enums.h:2179
@ EVENT_BURN_DEATH
Definition enums.h:2190
@ EVENT_ZERO_DAMAGE
Definition enums.h:2177
@ EVENT_SHOCK_DEATH
Definition enums.h:2192
@ EVENT_BLOCK
Definition enums.h:2180
@ EVENT_REVIVE
Definition enums.h:2213
@ EVENT_18
Definition enums.h:2178
@ EVENT_HIT_COMBO
Definition enums.h:2164
@ EVENT_DEATH
Definition enums.h:2186
@ EVENT_RECOVER_FROM_KO
Definition enums.h:2203
@ EVENT_LIFE_SHROOM_PROC
Definition enums.h:2212
@ EVENT_SHOCK_HIT
Definition enums.h:2198
@ EVENT_BURN_CONTACT
Definition enums.h:2197
@ EVENT_RECOVER_STATUS
Definition enums.h:2200
@ EVENT_RECOVER_FROZEN
Definition enums.h:2201
@ NPC_FLAG_IGNORE_CAMERA_FOR_YAW
Definition enums.h:3050
#define ApiStatus_DONE2
Definition evt.h:119
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:117
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1725
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2497
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:409
void sort_consumables(void)
Bubbles up player inventory items such that all ITEM_NONE values are at the bottom.
Definition inventory.c:409
ItemEntity * get_item_entity(s32 itemEntityIndex)
void btl_update_ko_status(void)
Definition 190B20.c:2601
void mdl_set_all_tint_type(s32)
Definition model.c:4519
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:668
s32 make_item_entity(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupVar)
s32 find_item(s32)
Search player inventory for itemID and return first matching array index.
Definition inventory.c:263
void set_actor_anim(s32 actorID, s32 partID, AnimID animID)
Definition 190B20.c:737
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void btl_show_battle_message(s32 messageIndex, s32 duration)
void deduct_current_move_fp(void)
Definition 190B20.c:693
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2313
f32 sin_rad(f32 x)
Definition 43F0.c:711
s32 add_coins(s32 amt)
Definition inventory.c:2075
void btl_cam_unfreeze(void)
Definition camera.c:2002
void show_action_rating(s32, Actor *, f32, f32, f32)
Definition 190B20.c:2092
HudScript HES_Refund
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)
s32 HudScript[]
Definition hud_element.h:9
void mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
Definition model.c:3905
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:993
BSS s32 BattleMerleeEffectsTime
EvtScript EVS_MerleeRunOut
EvtScript EVS_Player_NoDamageHit
BSS EffectInstance * BattleMerleeWaveEffect
EvtScript EVS_Player_SimpleHit
HudScript HES_Happy
EvtScript EVS_Player_HandleEvent
BSS HudElemID HID_HPDrain
EvtScript EVS_PlayerFirstStrike
EvtScript EVS_MerleeExpBonus
EvtScript EVS_PeachEnterStage
EvtScript EVS_ApplyDizzyAttack
EvtScript EVS_ExecuteMarioAction
EvtScript EVS_PlayerRegainAbility
EvtScript EVS_Peach_HandlePhase
EvtScript EVS_PlayerDies
void btl_set_player_idle_anims(void)
EvtScript EVS_Unused_UseItemWithEffect
BSS s16 BattleMerleeEffectsState
BSS s32 D_8029FBB0[3]
EvtScript EVS_Unused_PlayerGoHome
@ MERLEE_EFFECTS_DISMISS
@ MERLEE_EFFECTS_RELEASE
@ MERLEE_EFFECTS_HOLD
EvtScript EVS_Mario_HandlePhase
EvtScript EVS_Peach_OnActorCreate
EvtScript EVS_Unused_UseItem
HudScript HES_HPDrain
EvtScript EVS_MerleeDefenseBonus
EvtScript EVS_Player_ComplexHit
EvtScript EVS_Unused_DrinkItem
EvtScript EVS_MarioEnterStage
BSS EffectInstance * BattleMerleeOrbEffect
EvtScript EVS_Player_Celebrate
BSS HudElemID HID_Refund
EvtScript EVS_StartDefend
EvtScript EVS_PlayerHappy
EvtScript EVS_Mario_OnActorCreate
EvtScript EVS_UseLifeShroom
BSS HudElemID HID_Happy
EvtScript EVS_RunAwayFail
EvtScript EVS_MerleeAttackBonus
EvtScript EVS_RunAwayStart
EvtScript EVS_Unused_EatItem
BSS f32 BattleMerleeBasePosY
EvtScript EVS_ExecutePeachAction
CelebrationAnimOptions bPlayerCelebrations
Definition actors.c:5
EvtScript EVS_RunAwayNoCommand
void sfx_play_sound(s32 soundID)
ApiStatus RemoveItemEntity(Evt *script, b32 isInitialCall)
ApiStatus DeleteNpc(Evt *script, b32 isInitialCall)
ApiStatus SetItemPos(Evt *script, b32 isInitialCall)
ApiStatus SetItemFlags(Evt *script, b32 isInitialCall)
ApiStatus RemoveEffect(Evt *script, b32 isInitialCall)
ApiStatus SetNpcAnimation(Evt *script, b32 isInitialCall)
ApiStatus SetNpcRenderMode(Evt *script, b32 isInitialCall)
ApiStatus CreateNpc(Evt *script, b32 isInitialCall)
ApiStatus SetNpcPos(Evt *script, b32 isInitialCall)
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
ApiStatus ShowStartRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus SetNpcFlagBits(Evt *script, b32 isInitialCall)
#define Else
Marks the end of an if statement and the start of the else block.
Definition macros.h:296
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:312
#define LVar6
Definition macros.h:155
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:366
#define AddF(VAR, FLOAT_VALUE)
Definition macros.h:384
#define CaseEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR. It also marks the end of any pre...
Definition macros.h:320
#define CaseNe(RVAR)
Marks the start of a switch case that executes only if LVAR != RVAR. It also marks the end of any pre...
Definition macros.h:323
#define EndChildThread
Marks the end of a child thread block.
Definition macros.h:564
#define Sub(VAR, INT_VALUE)
Definition macros.h:378
#define LVarF
Definition macros.h:164
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:214
#define Add(VAR, INT_VALUE)
Definition macros.h:377
#define IfFalse(b)
Definition macros.h:650
#define EndLoop
Marks the end of a loop.
Definition macros.h:249
#define EndCaseGroup
Marks the end of a switch case group (CaseOrEq and/or CaseAndEq), stopping fallthrough.
Definition macros.h:353
#define BSS
Definition macros.h:7
#define LVarC
Definition macros.h:161
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:279
#define IfLt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR < RVAR.
Definition macros.h:276
#define Float(DOUBLE)
Definition macros.h:52
#define CaseOrEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR.
Definition macros.h:342
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:299
#define LVar5
Definition macros.h:154
#define CaseDefault
Marks the start of a switch case that executes unconditionally. It also marks the end of any previous...
Definition macros.h:338
#define LVarB
Definition macros.h:160
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:476
#define LVar7
Definition macros.h:156
#define BreakLoop
Breaks out of the innermost loop.
Definition macros.h:252
#define Thread
Marks the start of a thread block.
Definition macros.h:545
#define EndThread
Marks the end of a thread block.
Definition macros.h:548
#define IfFlag(LVAR, RVAR)
Marks the beginning of an if statement that only executes if the RVAR flag is set on LVAR,...
Definition macros.h:289
#define LVar8
Definition macros.h:157
#define LVar2
Definition macros.h:151
#define DEG_TO_RAD(deg)
Definition macros.h:146
#define LVar1
Definition macros.h:150
#define LVarA
Definition macros.h:159
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:255
#define LVar9
Definition macros.h:158
#define PlayEffect(args...)
Definition macros.h:811
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:363
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:270
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:577
#define ChildThread
Marks the start of a child thread block.
Definition macros.h:561
#define CaseGt(RVAR)
Marks the start of a switch case that executes only if LVAR <= RVAR. It also marks the end of any pre...
Definition macros.h:329
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:246
#define LVar4
Definition macros.h:153
#define LVar3
Definition macros.h:152
#define LVarE
Definition macros.h:163
#define LVar0
Definition macros.h:149
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
Definition macros.h:371
#define Return
Kills the current EVT thread.
Definition macros.h:218
#define PERIL_THRESHOLD
Definition battle.h:277
#define DANGER_THRESHOLD
Definition battle.h:276
struct Actor * partnerActor
struct Actor * playerActor
s32 gBattleState
Definition battle.cpp:13
s32 gDefeatedBattleState
Definition battle.cpp:18
ItemData gItemTable[]
s32 bPeachIdleAnims[]
Definition actors.c:99
s32 bMarioDefendAnims[]
Definition actors.c:53
PlayerData gPlayerData
Definition 77480.c:39
u8 * gBackgroundTintModePtr
Definition model.c:105
BattleStatus gBattleStatus
Definition battle.cpp:14
u32 bMarioIdleAnims[]
Definition actors.c:30
s32 gCurrentCameraID
Definition cam_math.c:5
s32 gBattleSubState
Definition battle.cpp:17
s32 gDefeatedBattleSubstate
Definition battle.cpp:16