Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
stone_cap.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "sprite/player.h"
5
6#define NAMESPACE battle_item_stone_cap
7
9
10API_CALLABLE(N(func_802A123C_7217DC)) {
11 BattleStatus* battleStatus = &gBattleStatus;
12 Actor* player = battleStatus->playerActor;
13 s32 i;
14
15 if (isInitialCall) {
16 script->functionTemp[0] = 0;
17 }
18
19 switch (script->functionTemp[0]) {
20 case 0:
21 inflict_status(player, STATUS_KEY_STONE, script->varTable[0]);
22 player->statusAfflicted = 0;
23 script->functionTemp[1] = 3;
24 script->functionTemp[0] = 1;
25 break;
26
27 case 1:
28 for (i = 0; i < 10; i++) {
29 f32 x = player->curPos.x + ((rand_int(20) - 10) * player->scalingFactor);
30 f32 y = player->curPos.y + ((rand_int(20) + 10) * player->scalingFactor);
31 f32 z = player->curPos.z + 5.0f;
32 fx_floating_cloud_puff(0, x, y, z, 1.0f, 25);
33 }
34
35 if (script->functionTemp[1] == 0) {
36 BattleStatus* battleStatus2 = &gBattleStatus;
37
38 battleStatus2->flags1 &= ~BS_FLAGS1_HUSTLED;
39 battleStatus->hustleTurns = 0;
40 battleStatus->itemUsesLeft = 0;
41
42 return ApiStatus_DONE2;
43 }
44
45 script->functionTemp[1]--;
46 break;
47 }
48
49 return ApiStatus_BLOCK;
50}
51
53
54EvtScript N(EVS_UseItem) = {
55 SetConst(LVarA, ITEM_STONE_CAP)
56 ExecWait(N(UseItemWithEffect))
58 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_MarioB1_AdjustCap)
59 Wait(30)
60 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Crouch)
61 Call(GetItemPower, ITEM_STONE_CAP, LVar0, LVar1)
63 Call(N(func_802A123C_7217DC))
64 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
65 Wait(20)
66 Return
67 End
68};
f32 scalingFactor
Vec3f curPos
Bytecode EvtScript[]
s8 statusAfflicted
#define rand_int
@ STATUS_KEY_STONE
Definition enums.h:2208
@ SOUND_PUT_ON_CAP
Definition enums.h:1169
@ SOUND_BECOME_STONE
Definition enums.h:1170
@ ACTOR_PLAYER
Definition enums.h:2085
#define ApiStatus_DONE2
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:116
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:2084
ApiStatus PlaySound(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 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 Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#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
BattleStatus gBattleStatus
Definition battle.c:11