Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
electro_pop.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "sprite/player.h"
4
5#include "effects.h"
6
7#define NAMESPACE battle_item_electro_pop
8
10
11API_CALLABLE(N(func_802A123C_7307DC)) {
12 BattleStatus* battleStatus = &gBattleStatus;
13 Actor* player = battleStatus->playerActor;
14
15 inflict_status(player, STATUS_KEY_STATIC, script->varTable[0]);
16 player->statusAfflicted = 0;
17 return ApiStatus_DONE2;
18}
19
20API_CALLABLE(N(SpawnHeartRecoveryFX)) {
21 Bytecode* args = script->ptrReadPos;
22 s32 a = evt_get_variable(script, *args++);
23 s32 b = evt_get_variable(script, *args++);
24 s32 c = evt_get_variable(script, *args++);
25 s32 d = evt_get_variable(script, *args++);
26
27 fx_recover(0, a, b, c, d);
28
29 return ApiStatus_DONE2;
30}
31
32API_CALLABLE(N(SpawnFlowerRecoveryFX)) {
33 Bytecode* args = script->ptrReadPos;
34 s32 a = evt_get_variable(script, *args++);
35 s32 b = evt_get_variable(script, *args++);
36 s32 c = evt_get_variable(script, *args++);
37 s32 d = evt_get_variable(script, *args++);
38
39 fx_recover(1, a, b, c, d);
40
41 return ApiStatus_DONE2;
42}
43
44#if !VERSION_PAL
45#include "common/AddHP.inc.c"
46
47API_CALLABLE(N(func_802A1450_7309F0)) {
48 ItemData* item = &gItemTable[ITEM_ELECTRO_POP];
49 PlayerData* playerData = &gPlayerData;
50
51 playerData->curHP += item->potencyA;
52 if (playerData->curHP > playerData->curMaxHP) {
53 playerData->curHP = playerData->curMaxHP;
54 }
55
56 script->varTable[3] = item->potencyA;
57
58 return ApiStatus_DONE2;
59}
60
61API_CALLABLE(N(AddFP)) {
62 PlayerData* playerData = &gPlayerData;
63 s32 amt = evt_get_variable(script, *script->ptrReadPos);
64
65 s32 newFP = playerData->curFP + amt;
66
67 if (newFP > playerData->curMaxFP) {
68 newFP = playerData->curMaxFP;
69 }
70
71 playerData->curFP = newFP;
72
73 return ApiStatus_DONE2;
74}
75#endif
76
77API_CALLABLE(N(func_802A14F0_730A90)) {
78 ItemData* item = &gItemTable[ITEM_ELECTRO_POP];
79 PlayerData* playerData = &gPlayerData;
80
81#if VERSION_PAL
82 playerData->curFP += item->potencyB;
83#else
84 playerData->curFP += item->potencyA;
85#endif
86 if (playerData->curFP > playerData->curMaxFP) {
87 playerData->curFP = playerData->curMaxFP;
88 }
89
90 script->varTable[3] = item->potencyB;
91
92 return ApiStatus_DONE2;
93}
94
96
97EvtScript N(EVS_UseItem) = {
98 SetConst(LVarA, ITEM_ELECTRO_POP)
99 ExecWait(N(UseItemWithEffect))
100 ExecWait(N(EatItem))
101 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
102 Add(LVar1, 20)
103 PlayEffect(EFFECT_SNAKING_STATIC, 0, LVar0, LVar1, LVar2, Float(1.0), 30, 0)
105 Call(GetItemPower, ITEM_VOLT_SHROOM, LVar0, LVar1)
106 Call(N(func_802A123C_7307DC))
107 Wait(40)
108 Call(N(func_802A14F0_730A90))
109 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
110 Add(LVar0, 20)
111 Add(LVar1, 25)
112 Call(N(SpawnFlowerRecoveryFX), LVar0, LVar1, LVar2, LVar3)
113 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
114 Add(LVar1, 25)
116#if !VERSION_PAL
117 Call(N(AddFP), LVar3)
118#endif
119 Wait(10)
120 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_ThumbsUp)
121 Wait(30)
122 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
124 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
125 Wait(20)
126 Call(ShowMessageBox, BTL_MSG_PLAYER_CHARGED, 60)
127 Call(WaitForMessageBoxDone)
128 ExecWait(N(PlayerGoHome))
129 Return
130 End
131};
Bytecode EvtScript[]
s8 statusAfflicted
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:4074
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ SOUND_VOLT_SHROOM_APPLY
Definition enums.h:1193
@ ACTOR_PLAYER
Definition enums.h:2085
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:2084
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus ShowRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus ShowStartRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus GetItemPower(Evt *script, b32 isInitialCall)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define Float(DOUBLE)
Definition macros.h:51
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define PlayEffect(args...)
Definition macros.h:807
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define LVar3
Definition macros.h:151
#define LVar0
Definition macros.h:148
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
Definition macros.h:370
#define Return
Kills the current EVT thread.
Definition macros.h:217
struct Actor * playerActor
ItemData gItemTable[]
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11