Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
world_use_item.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3#include "script_api/battle.h"
4#include "sprite/player.h"
5
6API_CALLABLE(WorldItem_ShowUseSparkles) {
7 Bytecode* args = script->ptrReadPos;
8 s32 x = evt_get_variable(script, *args++);
9 s32 y = evt_get_variable(script, *args++);
10 s32 z = evt_get_variable(script, *args++);
11
12 fx_sparkles(FX_SPARKLES_0, x, y, z, 60.0f);
13 return ApiStatus_DONE2;
14}
15
16API_CALLABLE(WorldItem_ShowHPGain) {
17 Bytecode* args = script->ptrReadPos;
18 s32 x = evt_get_variable(script, *args++);
19 s32 y = evt_get_variable(script, *args++);
20 s32 z = evt_get_variable(script, *args++);
21 s32 amt = evt_get_variable(script, *args++);
22
23 fx_recover(0, x, y, z, amt);
24 return ApiStatus_DONE2;
25}
26
27API_CALLABLE(WorldItem_ShowFPGain) {
28 Bytecode* args = script->ptrReadPos;
29 s32 x = evt_get_variable(script, *args++);
30 s32 y = evt_get_variable(script, *args++);
31 s32 z = evt_get_variable(script, *args++);
32 s32 amt = evt_get_variable(script, *args++);
33
34 fx_recover(1, x, y, z, amt);
35 return ApiStatus_DONE2;
36}
37
38API_CALLABLE(WorldItem_RestoreHP) {
40 s32 newHP = playerData->curHP + evt_get_variable(script, *script->ptrReadPos);
41
42 if (newHP > playerData->curMaxHP) {
43 newHP = playerData->curMaxHP;
44 }
45
46 if (newHP <= 0) {
47 newHP = 1;
48 }
49
50 playerData->curHP = newHP;
51 return ApiStatus_DONE2;
52}
53
54API_CALLABLE(WorldItem_RestoreFP) {
56 s32 newFP = playerData->curFP + evt_get_variable(script, *script->ptrReadPos);
57
58 if (newFP > playerData->curMaxFP) {
59 newFP = playerData->curMaxFP;
60 }
61
62 if (newFP <= 0) {
63 newFP = 1;
64 }
65
66 playerData->curFP = newFP;
67 return ApiStatus_DONE2;
68}
69
70API_CALLABLE(WorldItem_PauseTime) {
72#if !VERSION_JP
74#endif
75 return ApiStatus_DONE2;
76}
77
78API_CALLABLE(WorldItem_UnpauseTime) {
80#if !VERSION_JP
82#endif
83 return ApiStatus_DONE2;
84}
85
86API_CALLABLE(WorldItem_GetItemProperties) {
87 s32 itemIdx = evt_get_variable(script, *script->ptrReadPos);
88 s32 var15;
89
90 script->varTable[11] = (&gItemTable[itemIdx])->potencyA;
91 script->varTable[12] = (&gItemTable[itemIdx])->potencyB;
92 script->varTable[13] = FALSE;
93
95 script->varTable[13] = TRUE;
96 }
97
98 var15 = 0;
99 if (script->varTable[11] < 0 || (script->varTable[11] <= 0 && script->varTable[12] < 0)) {
100 var15 = 1;
101 }
102 script->varTable[15] = var15;
103
104 return ApiStatus_DONE2;
105}
106
107API_CALLABLE(WorldItem_ConsumeItem) {
109 return ApiStatus_DONE2;
110}
111
127
140
153
158 IfNe(LVar0, 0)
160 Wait(20)
161 EndIf
165 IfEq(LVarD, 0)
167 Else
169 EndIf
170 IfEq(LVarF, 1)
172 EndIf
173 IfGt(LVarB, 0)
175 Add(LVar0, 0)
176 Add(LVar1, 35)
178 EndIf
179 IfGt(LVarC, 0)
181 Add(LVar0, 20)
182 Add(LVar1, 25)
184 EndIf
186 Add(LVar1, 25)
188 IfNe(LVarB, 0)
190 EndIf
191 IfNe(LVarC, 0)
193 EndIf
194 IfEq(LVarF, 0)
195 Wait(10)
197 Wait(30)
198 Else
199 Wait(30)
200 EndIf
204 Wait(20)
208 Return
209 End
210};
BSS s32 PopupMenu_SelectedIndex
Bytecode EvtScript[]
@ FX_SPARKLES_0
Definition effects.h:234
@ ITEM_TYPE_FLAG_USE_DRINK_ANIMATION
Definition enums.h:1841
@ TIME_FREEZE_FULL
Definition enums.h:3466
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ SOUND_EAT_OR_DRINK
Definition enums.h:1441
@ GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS
Definition enums.h:4338
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
@ EVT_GROUP_NEVER_PAUSE
Definition evt.h:142
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1689
void remove_consumable(void)
Definition partners.c:490
void set_time_freeze_mode(s32)
Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move,...
Definition main_loop.c:358
ApiStatus GetPartnerInUse(Evt *script, b32 isInitialCall)
ApiStatus RemoveItemEntity(Evt *script, b32 isInitialCall)
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus ShowRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerAnimation(Evt *script, b32 isInitialCall)
ApiStatus DisablePlayerInput(Evt *script, b32 isInitialCall)
Disables player and partner input, and disables the status menu.
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
ApiStatus ShowStartRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus InterruptUsePartner(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerPos(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 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 LVarC
Definition macros.h:160
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#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 LVarD
Definition macros.h:161
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define SetGroup(GROUP)
Sets the current thread's group. Group value meanings are currently not known.
Definition macros.h:519
#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 LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
s32 gOverrideFlags
Definition main_loop.c:11
ItemData gItemTable[]
PlayerData gPlayerData
Definition 77480.c:40
EvtScript EVS_WorldItem_ShowUsedItem
EvtScript EVS_WorldItem_PlayEatingSounds
EvtScript EVS_WorldItem_PlayDrinkingSounds
EvtScript EVS_World_UseItem