Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
shooting_star.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3
4#include "effects.h"
5#include "model.h"
6
7#define NAMESPACE battle_item_shooting_star
8
10
11API_CALLABLE(N(SpawnShootingStarFX)) {
12 s32 x = rand_int(200) + 100;
13 s32 y = 200;
14 s32 z = rand_int(40);
15
16 if ((script->varTable[0] % 4) != 0) {
17 fx_star(FX_STAR_LARGE_BOUNCING, x, y, z,
18 x - (rand_int(100) + y),
19 0.0f,
20 z + 50 - rand_int(100),
21 rand_int(10) + 7);
22 } else {
23 fx_star(FX_STAR_SMALL_BOUNCING, x, y, z,
24 x - (rand_int(100) + y),
25 0.0f,
26 z + 50 - rand_int(100),
27 rand_int(10) + 7);
28 }
29 return ApiStatus_DONE2;
30}
31
32API_CALLABLE(N(SpawnDamageStarsFX)) {
33 Bytecode* args = script->ptrReadPos;
34 s32 x = evt_get_variable(script, *args++);
35 s32 y = evt_get_variable(script, *args++);
36 s32 z = evt_get_variable(script, *args++);
37
38 fx_damage_stars(FX_DAMAGE_STARS_2, x, y, z, 0, -1.0f, 0, 5);
39
40 return ApiStatus_DONE2;
41}
42
43API_CALLABLE(N(CustomFadeBackgroundDarken)) {
44 if (isInitialCall) {
48 script->functionTemp[0] = 10;
49 }
50
51 mdl_set_shroud_tint_params(0, 0, 0, ((10 - script->functionTemp[0]) * 16) & 240);
52 script->functionTemp[0]--;
53
54 if (script->functionTemp[0] == 0) {
55 return ApiStatus_DONE2;
56 } else {
57 return ApiStatus_BLOCK;
58 }
59}
60
61API_CALLABLE(N(CustomFadeBackgroundLighten)) {
62 if (isInitialCall) {
63 script->functionTemp[0] = 10;
64 }
65 mdl_set_shroud_tint_params(0, 0, 0, (script->functionTemp[0] * 16) & 240);
66
67 script->functionTemp[0]--;
68 if (script->functionTemp[0] == 0) {
70 return ApiStatus_DONE2;
71 }
72 return ApiStatus_BLOCK;
73}
74
76
77EvtScript N(EVS_UseItem) = {
78 SetConst(LVarA, ITEM_SHOOTING_STAR)
79 ExecWait(N(UseItemWithEffect))
80 Thread
81 Wait(5)
82 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
83 Call(MoveBattleCamOver, 20)
85 Call(N(CustomFadeBackgroundDarken))
86 Thread
87 Set(LVar0, 0)
88 Loop(10)
90 Call(N(SpawnShootingStarFX))
91 Add(LVar0, 1)
92 Wait(5)
94 Call(N(SpawnShootingStarFX))
95 Add(LVar0, 1)
96 Wait(5)
99 Thread
100 Set(LVar0, 0)
101 Wait(50)
102 Loop(10)
103 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_STAR_BOUNCE_A)
104 Add(LVar0, 1)
105 Wait(5)
106 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_STAR_BOUNCE_B)
107 Add(LVar0, 1)
108 Wait(5)
109 EndLoop
111 Thread
112 Loop(5)
113 Wait(15)
114 Call(StartRumble, BTL_RUMBLE_PLAYER_LIGHT)
115 Call(ShakeCam, CAM_BATTLE, 0, 5, Float(1.0))
116 EndLoop
118 Wait(90)
119 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
120 Call(MoveBattleCamOver, 20)
121 Call(InitTargetIterator)
122 Label(0)
123 Call(SetGoalToTarget, ACTOR_SELF)
124 Call(ItemCheckHit, LVar0, DAMAGE_TYPE_NO_CONTACT, 0, LVar0, 0)
126 Goto(1)
127 EndIf
128 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
129 Call(N(SpawnDamageStarsFX), LVar0, LVar1, LVar2)
130 Call(GetItemPower, ITEM_SHOOTING_STAR, LVar0, LVar1)
132 Label(1)
133 Wait(10)
134 Call(ChooseNextTarget, ITER_NEXT, LVar0)
136 Goto(0)
137 EndIf
138 Wait(20)
139 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
140 Call(MoveBattleCamOver, 20)
141 ExecWait(N(PlayerGoHome))
142 Thread
143 Call(N(CustomFadeBackgroundLighten))
145 Wait(30)
146 Return
147 End
148};
Bytecode EvtScript[]
#define rand_int
@ FX_STAR_LARGE_BOUNCING
Definition effects.h:175
@ FX_STAR_SMALL_BOUNCING
Definition effects.h:176
@ FX_DAMAGE_STARS_2
Definition effects.h:358
@ ENV_TINT_SHROUD
Definition enums.h:4387
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ SOUND_STAR_BOUNCE_A
Definition enums.h:975
@ SOUND_SHOOTING_STAR_FALL_B
Definition enums.h:974
@ SOUND_SHOOTING_STAR_FALL_A
Definition enums.h:973
@ SOUND_STAR_BOUNCE_B
Definition enums.h:976
@ BTL_RUMBLE_PLAYER_LIGHT
Definition enums.h:4260
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ CAM_BATTLE
Definition enums.h:1801
@ DAMAGE_TYPE_COSMIC
Definition enums.h:2859
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
@ DAMAGE_TYPE_MULTIPLE_POPUPS
Definition enums.h:2879
#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 mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
Definition model.c:3906
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus GetItemPower(Evt *script, b32 isInitialCall)
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#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 Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define Float(DOUBLE)
Definition macros.h:51
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#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 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
u8 * gBackgroundTintModePtr
Definition model.c:105
void fx_damage_stars(s32, f32, f32, f32, f32, f32, f32, s32)