Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
refresh.c
Go to the documentation of this file.
1#include "common.h"
2#include "hud_element.h"
3#include "script_api/battle.h"
4#include "sprite/npc/BattleEldstar.h"
5#include "sprite/player.h"
6
7#define NAMESPACE battle_move_refresh
8
10
11API_CALLABLE(N(FlyAroundPlayer)) {
12 Bytecode* args = script->ptrReadPos;
13 s32 npcID;
14 Npc* npc;
15
16 enum {
17 STATE_INIT = 0,
18 STATE_FLYING = 1,
19 STATE_DONE = 2,
20 };
21
22 if (isInitialCall) {
23 script->functionTemp[0] = STATE_INIT;
24 }
25
26 npc = script->functionTempPtr[1];
27
28 switch (script->functionTemp[0]) {
29 case STATE_INIT:
30 npcID = evt_get_variable(script, *args++);
31 script->functionTempPtr[1] = npc = get_npc_unsafe(npcID);
32 npc->planarFlyDist = 0;
33 npc->yaw = 0;
34 npc->duration = 0;
35 npc->jumpVel = -1.5f;
36 npc->jumpScale = 0.02f;
37 npc->moveSpeed = 1.0f;
38 npc->moveToPos.x = npc->pos.x;
39 npc->moveToPos.y = npc->pos.y;
40 npc->moveToPos.z = npc->pos.z;
41 script->functionTemp[0] = STATE_FLYING;
42 break;
43 case STATE_FLYING:
44 if (npc->jumpVel < 0.0f) {
45 npc->planarFlyDist += 3.0;
46 if (npc->planarFlyDist > 40.0f) {
47 npc->planarFlyDist = 40.0f;
48 }
49 } else {
50 npc->planarFlyDist -= 2.0;
51 if (npc->planarFlyDist < 20.0f) {
52 npc->planarFlyDist = 20.0f;
53 }
54 }
55
56 npc->moveSpeed += 0.75;
57 npc->jumpVel += npc->jumpScale;
58 npc->pos.y += npc->jumpVel;
59 if (npc->moveSpeed > 33.0f) {
60 npc->moveSpeed = 33.0f;
61 }
62
63 npc->yaw += npc->moveSpeed;
64 npc->pos.x = npc->moveToPos.x;
65 npc->pos.z = npc->moveToPos.z;
66 add_vec2D_polar(&npc->pos.x, &npc->pos.z, npc->planarFlyDist, npc->yaw);
67 if ((npc->duration % 14) == 0) {
68 fx_sparkles(0, npc->pos.x, npc->pos.y, npc->pos.z, 30.0f);
69 }
70
71 npc->duration++;
72 if (npc->duration > 40) {
73 npc->jumpScale = 0.5f;
74 }
75 if (npc->pos.y > 200.0f) {
76 script->functionTemp[0] = STATE_DONE;
77 }
78 break;
79 case STATE_DONE:
80 return ApiStatus_DONE2;
81 }
82
83 return ApiStatus_BLOCK;
84}
85
86API_CALLABLE(N(RemovePlayerDebuffs)) {
88
89 if (actor->debuff != 0) {
90 actor->debuffDuration = 0;
91 actor->debuff = 0;
93 }
94
95 if (actor->koStatus != 0) {
96 actor->koDuration = 0;
97 actor->koStatus = 0;
99 }
100
102 return ApiStatus_DONE2;
103}
104
105#include "common/AddHP.inc.c"
106
107#include "common/AddFP.inc.c"
108
109API_CALLABLE(N(SpawnHeartRecoverFX)) {
110 Bytecode* args = script->ptrReadPos;
111 s32 x = evt_get_variable(script, *args++);
112 s32 y = evt_get_variable(script, *args++);
113 s32 z = evt_get_variable(script, *args++);
114 s32 duration = evt_get_variable(script, *args++);
115
116 fx_recover(0, x, y, z, duration);
117
118 return ApiStatus_DONE2;
119}
120
121API_CALLABLE(N(SpawnFlowerRecoverFX)) {
122 Bytecode* args = script->ptrReadPos;
123 s32 x = evt_get_variable(script, *args++);
124 s32 y = evt_get_variable(script, *args++);
125 s32 z = evt_get_variable(script, *args++);
126 s32 duration = evt_get_variable(script, *args++);
127
128 fx_recover(1, x, y, z, duration);
129
130 return ApiStatus_DONE2;
131}
132
133EvtScript N(EVS_UsePower) = {
134 ExecWait(N(EVS_StarPower_WishForSpirit))
135 SetConst(LVar0, ANIM_BattleEldstar_Idle)
136 ExecWait(N(EVS_StarPower_SpiritSummoned))
137 Call(SetNpcAnimation, NPC_BTL_SPIRIT, ANIM_BattleEldstar_Shout)
138 Wait(16)
139 Thread
140 Wait(10)
141 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
145 Call(N(FlyAroundPlayer), NPC_BTL_SPIRIT)
148 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
149 Add(LVar0, 0)
150 Add(LVar1, 35)
151 Call(N(SpawnHeartRecoverFX), LVar0, LVar1, LVar2, 5)
152 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
153 Add(LVar0, 20)
154 Add(LVar1, 25)
155 Call(N(SpawnFlowerRecoverFX), LVar0, LVar1, LVar2, 5)
156 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
157 Add(LVar1, 25)
159 Call(N(AddHP), 5)
160 Call(N(AddFP), 5)
161 Call(N(RemovePlayerDebuffs))
162 Wait(30)
163 Call(PlayerYieldTurn)
164 ExecWait(N(EVS_StarPower_EndWish))
165 Return
166 End
167};
struct EffectInstance * disableEffect
s16 hudElementDataIndex
Bytecode EvtScript[]
s8 debuffDuration
struct DisableXFXData * disableX
Definition effects.h:2529
EffectData data
Definition effects.h:2605
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ NPC_BTL_SPIRIT
Definition enums.h:2531
@ SOUND_REFRESH
Definition enums.h:964
@ ACTOR_PLAYER
Definition enums.h:2085
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void remove_status_debuff(s32)
void btl_update_ko_status(void)
Definition 190B20.c:2869
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus DeleteNpc(Evt *script, b32 isInitialCall)
ApiStatus SetNpcAnimation(Evt *script, b32 isInitialCall)
ApiStatus ShowStartRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus EnableNpcBlur(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 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 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
f32 jumpScale
f32 jumpVel
Vec3f moveToPos
f32 planarFlyDist
Vec3f pos
f32 moveSpeed
s16 duration
BattleStatus gBattleStatus
Definition battle.c:11