Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
StarPowerSupport.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "model.h"
4#include "effects.h"
5#include "sprite/player.h"
6
7API_CALLABLE(N(SpawnStarSparkleFX)) {
8 Bytecode* args = script->ptrReadPos;
9 s32 x = evt_get_variable(script, *args++);
10 s32 y = evt_get_variable(script, *args++);
11 s32 z = evt_get_variable(script, *args++);
12
13 fx_sparkles(FX_SPARKLES_0, x, y, z, 40.0f);
14 return ApiStatus_DONE2;
15}
16
17API_CALLABLE(N(SpawnWishSparkleFX)) {
18 Bytecode* args = script->ptrReadPos;
19 s32 x = evt_get_variable(script, *args++);
20 s32 y = evt_get_variable(script, *args++);
21 s32 z = evt_get_variable(script, *args++);
22
23 fx_stars_shimmer(5, x, y, z, 50.0f, 50.0f, 40, 30);
24 return ApiStatus_DONE2;
25}
26
27API_CALLABLE(N(SpawnStarSpiritArriveFX)) {
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
33 fx_sparkles(FX_SPARKLES_0, x, y, z, 30.0f);
34 return ApiStatus_DONE2;
35}
36
37API_CALLABLE(N(SpawnStarSpiritDepartFX)) {
38 Bytecode* args = script->ptrReadPos;
39 s32 x = evt_get_variable(script, *args++);
40 s32 y = evt_get_variable(script, *args++);
41 s32 z = evt_get_variable(script, *args++);
42
43 fx_misc_particles(4, x, y, z, 20.0f, 20.0f, 1.0f, 10, 15);
44 return ApiStatus_DONE2;
45}
46
48
49API_CALLABLE(N(FadeBackgroundDarkenForBeam)) {
50 if (isInitialCall) {
54 script->functionTemp[0] = 0;
55 }
56
57 mdl_set_shroud_tint_params(0, 0, 0, script->functionTemp[0]);
58 script->functionTemp[0] += 10;
59
60 if (script->functionTemp[0] >= 230) {
61 mdl_set_shroud_tint_params(0, 0, 0, 230);
62 return ApiStatus_DONE2;
63 }
64
65 return ApiStatus_BLOCK;
66}
67
69
70API_CALLABLE(N(SetPartnerWishAnim)) {
71 PlayerData* playerData = &gPlayerData;
72 Bytecode* args = script->ptrReadPos;
73 s32 wishAnimIdx = evt_get_variable(script, *args++);
74 AnimID anim = PartnerWishAnims[playerData->curPartner][wishAnimIdx];
75
77
78 return ApiStatus_DONE2;
79}
80
81API_CALLABLE(N(SetStarSpiritSize)) {
83
84 npc->collisionHeight = 32;
85 npc->collisionDiameter = 32;
86 return ApiStatus_DONE2;
87}
88
89EvtScript N(EVS_StarPower_WishForSpirit) = {
90 Call(GetOwnerID, LVarA)
92 Call(UseBattleCamPreset, BTL_CAM_PLAYER_WISH)
93 Wait(10)
94 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_UsePower)
95 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
96 Add(LVar0, 16)
97 Call(SetActorSpeed, ACTOR_PLAYER, Float(4.0))
98 Call(SetGoalPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
99 Call(PlayerRunToGoal, 0)
100 Wait(8)
102 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
103 Add(LVar1, 15)
104 Call(N(SpawnStarSparkleFX), LVar0, LVar1, LVar2)
106 Wait(20)
107 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Pray)
108 Wait(10)
110 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
111 Call(N(SpawnWishSparkleFX), LVar0, LVar1, LVar2)
112 Wait(30)
113 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_LookUp)
114 Else
115 Call(UseBattleCamPreset, BTL_CAM_PLAYER_WISH)
116 Wait(10)
117 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_WALK)
118 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
119 Add(LVar0, 16)
120 Call(SetActorSpeed, ACTOR_PARTNER, Float(4.0))
121 Call(SetGoalPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
122 Call(RunToGoal, ACTOR_PARTNER, 0, FALSE)
123 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_IDLE)
124 Wait(8)
126 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_PRAY)
127 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
128 Add(LVar1, 15)
129 Call(N(SpawnStarSparkleFX), LVar0, LVar1, LVar2)
131 Wait(20)
133 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_PRAY)
134 Wait(10)
135 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
136 Call(N(SpawnWishSparkleFX), LVar0, LVar1, LVar2)
137 Wait(30)
138 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_IDLE)
139 EndIf
140 Return
141 End
142};
143
144EvtScript N(EVS_StarPower_WishForBeam) = {
145 Call(GetOwnerID, LVarA)
147 Call(UseBattleCamPreset, BTL_CAM_PLAYER_WISH)
148 Wait(10)
149 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_UsePower)
150 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
151 Add(LVar0, 16)
152 Call(SetActorSpeed, ACTOR_PLAYER, Float(4.0))
153 Call(SetGoalPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
154 Call(PlayerRunToGoal, 0)
155 Wait(8)
157 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
158 Add(LVar1, 15)
159 Call(N(SpawnStarSparkleFX), LVar0, LVar1, LVar2)
160 Call(N(FadeBackgroundDarkenForBeam))
161 Wait(20)
162 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Pray)
163 Wait(10)
165 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
166 Call(N(SpawnWishSparkleFX), LVar0, LVar1, LVar2)
167 Wait(30)
168 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_LookUp)
169 Else
170 Call(UseBattleCamPreset, BTL_CAM_PLAYER_WISH)
171 Wait(10)
172 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_WALK)
173 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
174 Add(LVar0, 16)
175 Call(SetActorSpeed, ACTOR_PARTNER, Float(4.0))
176 Call(SetGoalPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
177 Call(RunToGoal, ACTOR_PARTNER, 0, FALSE)
178 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_IDLE)
179 Wait(8)
181 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_PRAY)
182 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
183 Add(LVar1, 15)
184 Call(N(SpawnStarSparkleFX), LVar0, LVar1, LVar2)
185 Call(N(FadeBackgroundDarkenForBeam))
186 Wait(20)
188 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_PRAY)
189 Wait(10)
190 Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
191 Call(N(SpawnWishSparkleFX), LVar0, LVar1, LVar2)
192 Wait(30)
193 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_IDLE)
194 EndIf
195 Return
196 End
197};
198
199EvtScript N(EVS_StarPower_SpiritSummoned) = {
200 Wait(8)
201 Call(SetForegroundModelsVisible, FALSE)
202 Call(UseBattleCamPresetImmediately, BTL_CAM_STAR_SPIRIT)
203 Call(MoveBattleCamOver, 1)
206 Call(N(SetStarSpiritSize))
208 Call(SetNpcPos, NPC_BTL_SPIRIT, -75, 150, 0)
210 Call(N(SpawnStarSpiritArriveFX), -75, 167, 0)
211 Wait(10)
213 Set(LVar0, 0)
214 Loop(8)
215 Add(LVar0, 67)
217 Wait(1)
218 EndLoop
219 Wait(10)
221 Thread
222 Wait(10)
223 Call(UseBattleCamPreset, BTL_CAM_PLAYER_WISH)
225 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
226 Add(LVar1, 50)
228 Call(SetForegroundModelsVisible, TRUE)
229 Return
230 End
231};
232
233EvtScript N(EVS_StarPower_SpiritDeparts) = {
234 Call(GetOwnerID, LVarA)
236 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
238 Thread
239 Loop(5)
240 Wait(6)
242 Call(N(SpawnStarSpiritDepartFX), LVar0, LVar1, LVar2)
243 EndLoop
246 Thread
247 Set(LVar2, 0)
248 Set(LVar3, 720)
250 Loop(0)
253 Wait(1)
254 IfEq(LVar1, 0)
256 EndIf
257 EndLoop
260 Add(LVar1, 60)
262 Add(LVar1, 140)
264 Wait(10)
267 Else
268 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
270 Thread
271 Loop(5)
272 Wait(6)
274 Call(N(SpawnStarSpiritDepartFX), LVar0, LVar1, LVar2)
275 EndLoop
278 Thread
279 Set(LVar2, 0)
280 Set(LVar3, 720)
282 Loop(0)
285 Wait(1)
286 IfEq(LVar1, 0)
288 EndIf
289 EndLoop
292 Add(LVar1, 60)
294 Add(LVar1, 140)
296 Wait(10)
299 EndIf
300 Return
301 End
302};
303
304EvtScript N(EVS_StarPower_EndWish) = {
305 Call(GetOwnerID, LVarA)
308 Wait(15)
309 Call(SetGoalToHome, ACTOR_PLAYER)
310 Call(SetActorSpeed, ACTOR_PLAYER, Float(8.0))
311 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Run)
312 Call(PlayerRunToGoal, 0)
313 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
314 Else
316 Wait(15)
317 Call(SetGoalToHome, ACTOR_PARTNER)
318 Call(SetActorSpeed, ACTOR_PARTNER, Float(8.0))
319 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_RETURN)
320 Call(RunToGoal, ACTOR_PARTNER, 0)
321 Call(N(SetPartnerWishAnim), PARTNER_WISH_ANIM_IDLE)
322 EndIf
323 Return
324 End
325};
326
Bytecode EvtScript[]
u32 AnimID
@ FX_SPARKLES_0
Definition effects.h:234
@ ENV_TINT_SHROUD
Definition enums.h:4387
@ NPC_DECORATION_WHITE_GLOW_BEHIND
Definition enums.h:1923
PartnerWishAnims
Definition enums.h:3393
@ PARTNER_WISH_ANIM_IDLE
Definition enums.h:3398
@ PARTNER_WISH_ANIM_PRAY
Definition enums.h:3395
@ PARTNER_WISH_ANIM_WALK
Definition enums.h:3394
@ PARTNER_WISH_ANIM_RETURN
Definition enums.h:3397
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_PLAYER_WISH
Definition enums.h:4891
@ BTL_CAM_STAR_SPIRIT
Definition enums.h:4895
@ NPC_BTL_SPIRIT
Definition enums.h:2531
@ EASING_CUBIC_IN
Definition enums.h:512
@ EASING_COS_IN_OUT
Definition enums.h:520
@ SOUND_STAR_SPIRIT_APPEAR_A
Definition enums.h:1370
@ SOUND_BEGIN_WISH
Definition enums.h:963
@ SOUND_WISH_ASCENDING
Definition enums.h:1382
@ SOUND_STAR_SPIRIT_DEPART_3
Definition enums.h:1376
@ SOUND_STAR_SPIRIT_DEPART_1
Definition enums.h:1374
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_PARTNER
Definition enums.h:2086
@ NPC_FLAG_IGNORE_CAMERA_FOR_YAW
Definition enums.h:3016
#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 mdl_set_all_tint_type(s32)
Definition model.c:4521
void set_actor_anim(s32 actorID, s32 partID, AnimID animID)
Definition 190B20.c:1005
void mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
Definition model.c:3906
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus FadeBackgroundLighten(Evt *script, b32 isInitialCall)
ApiStatus DeleteNpc(Evt *script, b32 isInitialCall)
ApiStatus UpdateLerp(Evt *script, b32 isInitialCall)
ApiStatus GetNpcPos(Evt *script, b32 isInitialCall)
ApiStatus SetNpcDecoration(Evt *script, b32 isInitialCall)
ApiStatus SetNpcRotation(Evt *script, b32 isInitialCall)
ApiStatus FadeBackgroundDarken(Evt *script, b32 isInitialCall)
ApiStatus CreateNpc(Evt *script, b32 isInitialCall)
ApiStatus SetNpcPos(Evt *script, b32 isInitialCall)
ApiStatus MakeLerp(Evt *script, b32 isInitialCall)
ApiStatus SetNpcFlagBits(Evt *script, b32 isInitialCall)
ApiStatus EnableNpcBlur(Evt *script, b32 isInitialCall)
ApiStatus NpcFlyTo(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 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 Float(DOUBLE)
Definition macros.h:51
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define BreakLoop
Breaks out of the innermost loop.
Definition macros.h:251
#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 LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
s16 collisionDiameter
s16 collisionHeight
PlayerData gPlayerData
Definition 77480.c:40
u8 * gBackgroundTintModePtr
Definition model.c:105