Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
food.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_food
8
10
12
13API_CALLABLE(N(func_802A123C_73330C)) {
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_7333BC)) {
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(SpawnFlowerRecoveryFX)) {
64 Bytecode* args = script->ptrReadPos;
65 s32 a = evt_get_variable(script, *args++);
66 s32 b = evt_get_variable(script, *args++);
67 s32 c = evt_get_variable(script, *args++);
68 s32 d = evt_get_variable(script, *args++);
69
70 fx_recover(1, a, b, c, d);
71
72 return ApiStatus_DONE2;
73}
74
75#include "common/AddHP.inc.c"
76#include "common/AddFP.inc.c"
77
78API_CALLABLE(N(GetFoodParameters)) {
79 Bytecode* args = script->ptrReadPos;
80 s32 itemIdx = evt_get_variable(script, *args++);
81 ItemData* item = &gItemTable[itemIdx];
82 b32 isHarmful;
83
84 script->varTable[11] = item->potencyA;
85 script->varTable[12] = item->potencyB;
86 script->varTable[13] = FALSE;
87
89 script->varTable[13] = TRUE;
90 }
91
92 isHarmful = FALSE;
93 if ((script->varTable[11] < 0) || (script->varTable[11] <= 0 && script->varTable[12] < 0)) {
94 isHarmful = TRUE;
95 }
96
97 script->varTable[15] = isHarmful;
98
99 return ApiStatus_DONE2;
100}
101
103
104EvtScript N(EVS_UseOnPartner) = {
105 Call(SetActorYaw, ACTOR_PLAYER, 30)
106 Wait(1)
107 Call(SetActorYaw, ACTOR_PLAYER, 60)
108 Wait(1)
109 Call(SetActorYaw, ACTOR_PLAYER, 90)
110 Wait(1)
111 Call(SetActorYaw, ACTOR_PLAYER, 120)
112 Wait(1)
113 Call(SetActorYaw, ACTOR_PLAYER, 150)
114 Wait(1)
115 Call(SetActorYaw, ACTOR_PLAYER, 180)
116 Wait(10)
117 Set(LVar1, LVarF)
118 ExecWait(N(UseItem))
119 Set(LVarE, LVarA)
120 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Throw)
121 Thread
122 Wait(20)
123 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
126 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
127 Add(LVar0, 0)
128 Add(LVar1, 30)
129 Add(LVar2, 5)
132 Thread
133 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
134 Add(LVar1, 45)
136 Set(LVarE, LVar0)
137 Loop(25)
139 Call(N(func_802A123C_73330C), LVar0, LVar1, LVar2)
140 Wait(1)
141 EndLoop
144 Call(InitTargetIterator)
145 Call(SetGoalToTarget, ACTOR_SELF)
146 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
147 Call(SetBattleCamTarget, -125, 1, 0)
148 Call(SetBattleCamOffsetY, 41)
149 Call(SetBattleCamDist, 248)
150 Call(MoveBattleCamOver, 25)
152 Add(LVar2, 5)
154 Call(AddBattleCamDist, 100)
155 Call(MoveBattleCamOver, 30)
156 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
157 Add(LVar1, 25)
159 IfGt(LVarB, 0)
160 Call(N(func_802A12EC_7333BC), LVarB)
161 EndIf
162 Wait(30)
163 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
165 Wait(20)
166 Call(SetActorYaw, ACTOR_PLAYER, 150)
167 Wait(1)
168 Call(SetActorYaw, ACTOR_PLAYER, 120)
169 Wait(1)
170 Call(SetActorYaw, ACTOR_PLAYER, 90)
171 Wait(1)
172 Call(SetActorYaw, ACTOR_PLAYER, 60)
173 Wait(1)
174 Call(SetActorYaw, ACTOR_PLAYER, 30)
175 Wait(1)
176 Call(SetActorYaw, ACTOR_PLAYER, 0)
177 Wait(10)
178 Return
179 End
180};
181
182EvtScript N(EVS_UseItem) = {
183 #define LV_ItemID LVarA
184 #define LV_HPAmt LVarB
185 #define LV_FPAmt LVarC
186 #define LV_IsDrink LVarD
187 #define LV_NoRefund LVarE
188 #define LV_IsHarmful LVarF
189
191 Call(GetMenuSelection, LVar0, LVar1, LVar2)
193 Call(N(GetFoodParameters), LV_ItemID)
194 Call(InitTargetIterator)
195 Call(GetOwnerTarget, LVar0, LVar1)
197 ExecWait(N(EVS_UseOnPartner))
198 Return
199 EndIf
201 ExecWait(N(UseItemWithEffect))
202 IfEq(LV_IsDrink, FALSE)
203 ExecWait(N(EatItem))
204 Else
205 ExecWait(N(DrinkItem))
206 EndIf
207 IfEq(LV_IsHarmful, TRUE)
208 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_StickOutTongue)
209 EndIf
210 IfGt(LV_HPAmt, 0)
211 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
212 Add(LVar0, 0)
213 Add(LVar1, 35)
214 Call(N(SpawnHeartRecoveryFX), LVar0, LVar1, LVar2, LV_HPAmt)
215 EndIf
216 IfLt(LV_HPAmt, 0)
217 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
218 Add(LVar0, 0)
219 Add(LVar1, 35)
220 Call(N(SpawnHeartRecoveryFX), LVar0, LVar1, LVar2, LV_HPAmt)
221 EndIf
222 IfGt(LV_FPAmt, 0)
223 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
224 Add(LVar0, 20)
225 Add(LVar1, 25)
226 Call(N(SpawnFlowerRecoveryFX), LVar0, LVar1, LVar2, LV_FPAmt)
227 EndIf
228 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
229 Add(LVar1, 25)
231 IfNe(LV_HPAmt, 0)
232 Call(N(AddHP), LV_HPAmt)
233 EndIf
234 IfNe(LV_FPAmt, 0)
235 Call(N(AddFP), LV_FPAmt)
236 EndIf
237 IfEq(LV_IsHarmful, FALSE)
238 Wait(10)
239 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_ThumbsUp)
240 Wait(30)
241 Else
242 Wait(30)
243 EndIf
244 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
246 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
247 Wait(20)
248 ExecWait(N(PlayerGoHome))
249 Return
250 End
251};
struct EffectInstance * disableEffect
s32 b32
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
@ ITEM_TYPE_FLAG_USE_DRINK_ANIMATION
Definition enums.h:1841
@ 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
#define LV_IsDrink
#define LV_ItemID
#define LV_HPAmt
#define LV_FPAmt
#define LV_IsHarmful
#define LV_NoRefund
EntityModelScript EMS_StarIcon
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
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 Else
Marks the end of an if statement and the start of the else block.
Definition macros.h:295
#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 IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:272
#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 IfLt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR < RVAR.
Definition macros.h:275
#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 LVarE
Definition macros.h:162
#define LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
struct Actor * partnerActor
ItemData gItemTable[]
BattleStatus gBattleStatus
Definition battle.c:11