Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
life_shroom.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "entity.h"
5#include "sprite/player.h"
6
7#define NAMESPACE battle_item_life_shroom
8
10
12
13API_CALLABLE(N(func_802A123C_72E76C)) {
14 Bytecode* args = script->ptrReadPos;
15 s32 a = evt_get_variable(script, *args++);
16 s32 b = evt_get_variable(script, *args++);
17 s32 c = evt_get_variable(script, *args++);
18 ItemEntity* item = get_item_entity(script->varTable[14]);
19
20 item->pos.x = a;
21 item->pos.y = b;
22 item->pos.z = c;
23
24 return ApiStatus_DONE2;
25}
26
27API_CALLABLE(N(func_802A12EC_72E81C)) {
28 BattleStatus* battleStatus = &gBattleStatus;
29 Actor* partner = battleStatus->partnerActor;
30 Bytecode* args = script->ptrReadPos;
31
32 if (partner->koDuration == 0) {
33 return ApiStatus_DONE2;
34 }
35
36 partner->koDuration -= evt_get_variable(script, *args++);
37 if (partner->koDuration < 0) {
38 partner->koDuration = 0;
39 }
40 if (partner->koDuration > 0) {
41 partner->disableEffect->data.disableX->koDuration = partner->koDuration;
42 } else {
43 partner->koStatus = 0;
46 }
47
48 return ApiStatus_DONE2;
49}
50
51API_CALLABLE(N(SpawnHeartRecoveryFX)) {
52 Bytecode* args = script->ptrReadPos;
53 s32 a = evt_get_variable(script, *args++);
54 s32 b = evt_get_variable(script, *args++);
55 s32 c = evt_get_variable(script, *args++);
56 s32 d = evt_get_variable(script, *args++);
57
58 fx_recover(0, a, b, c, d);
59
60 return ApiStatus_DONE2;
61}
62
63API_CALLABLE(N(func_802A1438_72E968)) {
64 ItemData* item = &gItemTable[ITEM_LIFE_SHROOM];
65 PlayerData* playerData = &gPlayerData;
66
67 playerData->curHP += item->potencyA;
68 if (playerData->curHP > playerData->curMaxHP) {
69 playerData->curHP = playerData->curMaxHP;
70 }
71
72 script->varTable[3] = item->potencyA;
73
74 return ApiStatus_DONE2;
75}
76
77API_CALLABLE(N(func_802A1484_72E9B4)) {
78 Bytecode* args = script->ptrReadPos;
79 s32 itemIdx = evt_get_variable(script, *args++);
80 ItemData* itemTable = gItemTable;
81 ItemData* item = &itemTable[itemIdx];
82
83 script->varTable[11] = item->potencyA;
84 script->varTable[12] = item->potencyB;
85
86 itemIdx = script->varTable[11] < 0 || (script->varTable[11] <= 0 && script->varTable[12] < 0);
87 script->varTable[15] = itemIdx;
88
89 return ApiStatus_DONE2;
90}
91
93
94EvtScript N(EVS_UseOnPartner) = {
95 Call(SetActorYaw, ACTOR_PLAYER, 30)
96 Wait(1)
97 Call(SetActorYaw, ACTOR_PLAYER, 60)
98 Wait(1)
99 Call(SetActorYaw, ACTOR_PLAYER, 90)
100 Wait(1)
101 Call(SetActorYaw, ACTOR_PLAYER, 120)
102 Wait(1)
103 Call(SetActorYaw, ACTOR_PLAYER, 150)
104 Wait(1)
105 Call(SetActorYaw, ACTOR_PLAYER, 180)
106 Wait(10)
107 Set(LVar1, LVarF)
108 ExecWait(N(UseItem))
109 Set(LVarE, LVarA)
110 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Throw)
111 Thread
112 Wait(20)
113 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
116 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
117 Add(LVar0, 0)
118 Add(LVar1, 30)
119 Add(LVar2, 5)
122 Thread
123 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
124 Add(LVar1, 45)
126 Set(LVarE, LVar0)
127 Loop(25)
129 Call(N(func_802A123C_72E76C), LVar0, LVar1, LVar2)
130 Wait(1)
131 EndLoop
134 Call(InitTargetIterator)
135 Call(SetGoalToTarget, ACTOR_SELF)
136 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
137 Call(SetBattleCamTarget, -125, 1, 0)
138 Call(SetBattleCamOffsetY, 41)
139 Call(SetBattleCamDist, 248)
140 Call(MoveBattleCamOver, 25)
142 Add(LVar2, 5)
144 Call(AddBattleCamDist, 100)
145 Call(MoveBattleCamOver, 30)
146 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
147 Add(LVar1, 25)
149 IfGt(LVarB, 0)
150 Call(N(func_802A12EC_72E81C), LVarB)
151 EndIf
152 Wait(30)
153 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
155 Wait(20)
156 Call(SetActorYaw, ACTOR_PLAYER, 150)
157 Wait(1)
158 Call(SetActorYaw, ACTOR_PLAYER, 120)
159 Wait(1)
160 Call(SetActorYaw, ACTOR_PLAYER, 90)
161 Wait(1)
162 Call(SetActorYaw, ACTOR_PLAYER, 60)
163 Wait(1)
164 Call(SetActorYaw, ACTOR_PLAYER, 30)
165 Wait(1)
166 Call(SetActorYaw, ACTOR_PLAYER, 0)
167 Wait(10)
168 Return
169 End
170};
171
172EvtScript N(EVS_UseItem) = {
173 Set(LVarF, LVar1)
174 Call(GetMenuSelection, LVar0, LVar1, LVar2)
175 Set(LVarA, LVar1)
176 Call(N(func_802A1484_72E9B4), LVarA)
177 Call(InitTargetIterator)
178 Call(GetOwnerTarget, LVar0, LVar1)
180 ExecWait(N(EVS_UseOnPartner))
181 Return
182 EndIf
183 SetConst(LVarA, ITEM_LIFE_SHROOM)
184 Set(LVar1, LVarF)
185 ExecWait(N(UseItemWithEffect))
186 ExecWait(N(EatItem))
187 Call(N(func_802A1438_72E968))
188 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
189 Add(LVar0, 0)
190 Add(LVar1, 35)
191 Call(N(SpawnHeartRecoveryFX), LVar0, LVar1, LVar2, LVar3)
192 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
193 Add(LVar1, 25)
195 Wait(10)
196 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_ThumbsUp)
197 Wait(30)
198 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
200 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
201 Wait(20)
202 ExecWait(N(PlayerGoHome))
203 Return
204 End
205};
struct EffectInstance * disableEffect
Bytecode EvtScript[]
struct DisableXFXData * disableX
Definition effects.h:2529
EffectData data
Definition effects.h:2605
s32 EntityModelScript[]
Definition entity.h:7
@ ITEM_SPAWN_MODE_DECORATION
Definition enums.h:2292
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_PARTNER
Definition enums.h:2086
@ ACTOR_SELF
Definition enums.h:2084
@ EVENT_RECOVER_FROM_KO
Definition enums.h:2170
#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
ItemEntity * get_item_entity(s32 itemEntityIndex)
void dispatch_event_partner(s32)
Definition dmg_partner.c:7
EntityModelScript EMS_StarIcon
ApiStatus RemoveItemEntity(Evt *script, b32 isInitialCall)
ApiStatus ShowRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus CreateVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityFlags(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
ApiStatus GetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus ShowStartRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityJumpGravity(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityJumpTo(Evt *script, b32 isInitialCall)
#define Ref(sym)
Address/pointer constant.
Definition macros.h:60
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#define LVarF
Definition macros.h:163
#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 EndLoop
Marks the end of a loop.
Definition macros.h:248
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#define Float(DOUBLE)
Definition macros.h:51
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVarB
Definition macros.h:159
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define Thread
Marks the start of a thread block.
Definition macros.h:544
#define EndThread
Marks the end of a thread block.
Definition macros.h:547
#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 IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:269
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVar3
Definition macros.h:151
#define LVarE
Definition macros.h:162
#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 * partnerActor
ItemData gItemTable[]
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11