Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
chill_out.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "sprite/npc/BattleMuskular.h"
4#include "sprite/player.h"
5
6#define NAMESPACE battle_move_chill_out
7
9
11
12API_CALLABLE(N(InitHitCheck)) {
13 DidChillOutHit = FALSE;
14 return ApiStatus_DONE2;
15}
16
17API_CALLABLE(N(DidMoveHit)) {
18 script->varTable[0] = DidChillOutHit;
19 return ApiStatus_DONE2;
20}
21
22API_CALLABLE(N(SpawnChillOutFX)) {
23 f32 x = rand_int(200) - 25;
24 f32 y = rand_int(120) + 7;
25 f32 z = rand_int(50) - 25;
26
27 fx_cold_breath(2, x, y, z, 2.0f, 20);
28
29 x = rand_int(200) - 25;
30 y = rand_int(120) + 7;
31 z = rand_int(50) - 25;
32
33 fx_sparkles(FX_SPARKLES_4, x, y, z, 40.0f);
34
35 return ApiStatus_DONE2;
36}
37
38API_CALLABLE(N(CanChillOutHit)) {
39 Actor* actor = get_actor(script->owner1.actorID);
40 Actor* target = get_actor(actor->targetActorID);
41 ActorPart* part = get_actor_part(target, actor->targetPartID);
42
43 script->varTable[0] = FALSE;
44
45 if (target->flags & ACTOR_FLAG_TARGET_ONLY) {
46 return ApiStatus_DONE2;
47 }
48
49 if (target->flags & ACTOR_FLAG_NO_DMG_APPLY) {
50 return ApiStatus_DONE2;
51 }
52
53 if (target->flags & ACTOR_FLAG_DAMAGE_IMMUNE) {
54 return ApiStatus_DONE2;
55 }
56
58 return ApiStatus_DONE2;
59 }
60
62 return ApiStatus_DONE2;
63 }
64
65 script->varTable[0] = TRUE;
66 return ApiStatus_DONE2;
67}
68
69API_CALLABLE(N(InflictChillOutHit)) {
70 Actor* enemy = get_actor(script->owner1.enemyID);
71 Actor* target = get_actor(enemy->targetActorID);
72 ActorPart* targetPart = get_actor_part(target, enemy->targetPartID);
73 f32 x, y, z;
74
75 if (target->flags & ACTOR_FLAG_TARGET_ONLY) {
76 return ApiStatus_DONE2;
77 }
78
79 if (target->flags & ACTOR_FLAG_NO_DMG_APPLY) {
80 return ApiStatus_DONE2;
81 }
82
83 if (target->flags & ACTOR_FLAG_DAMAGE_IMMUNE) {
84 return ApiStatus_DONE2;
85 }
86
87 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ENCHANTED) {
88 return ApiStatus_DONE2;
89 }
90
92 return ApiStatus_DONE2;
93 }
94
95 target->chillOutTurns = 4;
96 target->chillOutAmount = 3;
97
99
100 x = target->curPos.x + target->headOffset.x + (target->size.x / 2);
101 if (target->flags & ACTOR_FLAG_UPSIDE_DOWN) {
102 y = target->curPos.y + target->headOffset.y - target->size.y;
103 } else if (!(target->flags & ACTOR_FLAG_HALF_HEIGHT)) {
104 y = target->curPos.y + target->headOffset.y + target->size.y;
105 } else {
106 y = target->curPos.y + target->headOffset.y + target->size.y * 2;
107 }
108 z = target->curPos.z + target->headOffset.z + 5.0f;
109
110 fx_stat_change(5, x, y, z, 1.0f, 60);
112 DidChillOutHit = TRUE;
113
114 return ApiStatus_DONE2;
115}
116
117EvtScript N(EVS_UsePower) = {
118 Call(N(InitHitCheck))
119 ExecWait(N(EVS_StarPower_WishForSpirit))
120 SetConst(LVar0, ANIM_BattleMuskular_Idle)
121 ExecWait(N(EVS_StarPower_SpiritSummoned))
122 Call(SetNpcAnimation, NPC_BTL_SPIRIT, ANIM_BattleMuskular_Shout)
123 Wait(16)
124 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
126 Call(InitTargetIterator)
127 Label(10)
128 Call(ItemCheckHit, LVar0, 0, 0, 0, 0)
130 Goto(11)
131 EndIf
132 Call(N(CanChillOutHit))
133 IfEq(LVar0, TRUE)
134 Call(GetOwnerTarget, LVarA, LVarB)
135 Thread
136 Loop(5)
137 Call(SetActorScaleModifier, LVarA, Float(1.0), Float(1.0), Float(1.0))
138 Wait(1)
139 Call(SetActorScaleModifier, LVarA, Float(1.1), Float(1.0), Float(1.0))
140 Wait(1)
141 Call(SetActorScaleModifier, LVarA, Float(1.2), Float(0.95), Float(1.0))
142 Wait(1)
143 Call(SetActorScaleModifier, LVarA, Float(1.3), Float(0.9), Float(1.0))
144 Wait(1)
145 Call(SetActorScaleModifier, LVarA, Float(1.35), Float(0.85), Float(1.0))
146 Wait(1)
147 Call(SetActorScaleModifier, LVarA, Float(1.38), Float(0.8), Float(1.0))
148 Wait(1)
149 Call(SetActorScaleModifier, LVarA, Float(1.4), Float(0.8), Float(1.0))
150 Wait(1)
151 Call(SetActorScaleModifier, LVarA, Float(1.3), Float(0.85), Float(1.0))
152 Wait(1)
153 Call(SetActorScaleModifier, LVarA, Float(1.2), Float(0.9), Float(1.0))
154 Wait(1)
155 Call(SetActorScaleModifier, LVarA, Float(1.1), Float(0.95), Float(1.0))
156 Wait(1)
157 EndLoop
158 Call(SetActorScaleModifier, LVarA, Float(1.0), Float(1.0), Float(1.0))
160 EndIf
161 Label(11)
162 Call(ChooseNextTarget, ITER_NEXT, LVar0)
164 Goto(10)
165 EndIf
166 Loop(30)
167 Call(N(SpawnChillOutFX))
168 Wait(2)
169 EndLoop
170 Call(ChooseNextTarget, ITER_FIRST, 0)
171 Label(0)
172 Call(SetGoalToTarget, ACTOR_SELF)
173 Call(ItemCheckHit, LVar0, 0, 0, 0, 0)
175 Goto(1)
176 EndIf
177 Call(N(CanChillOutHit))
178 IfEq(LVar0, TRUE)
179 Call(N(InflictChillOutHit))
180 Else
182 EndIf
183 Label(1)
184 Wait(5)
185 Call(ChooseNextTarget, ITER_NEXT, LVar0)
187 Goto(0)
188 EndIf
189 Wait(5)
190 Call(N(DidMoveHit))
191 IfEq(LVar0, TRUE)
192 Call(ShowMessageBox, BTL_MSG_CHILL_OUT_BEGIN, 60)
193 EndIf
194 Call(PlayerYieldTurn)
195 ExecWait(N(EVS_StarPower_SpiritDeparts))
196 ExecWait(N(EVS_StarPower_EndWish))
197 Call(N(DidMoveHit))
198 IfEq(LVar0, TRUE)
199 Call(WaitForMessageBoxDone)
200 EndIf
201 Return
202 End
203};
BSS b32 DidChillOutHit
Definition chill_out.c:8
Vec3s headOffset
s16 targetActorID
s8 chillOutAmount
s32 b32
Vec2bu size
Vec3f curPos
Bytecode EvtScript[]
#define rand_int
@ FX_SPARKLES_4
Definition effects.h:238
@ BS_FLAGS1_FORCE_IMMUNE_HIT
Definition enums.h:3580
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BTL_MSG_CHILL_OUT_BEGIN
Definition enums.h:4102
@ ITER_FIRST
Definition enums.h:2024
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
Actor glows and listens for Star Beam and Peach Beam events.
Definition enums.h:3386
@ ACTOR_EVENT_FLAG_ENCHANTED
Actor glows and listens for the Star Beam event.
Definition enums.h:3385
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ SUPPRESS_EVENT_ALL
Definition enums.h:2907
@ NPC_BTL_SPIRIT
Definition enums.h:2531
@ SOUND_CHILL_OUT
Definition enums.h:965
@ SOUND_INFLICT_CHILL_OUT
Definition enums.h:1544
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_DAMAGE_IMMUNE
Definition enums.h:3333
@ ACTOR_FLAG_HALF_HEIGHT
Definition enums.h:3335
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
Definition enums.h:3331
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3334
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ EVENT_HIT
Definition enums.h:2132
#define ApiStatus_DONE2
Definition evt.h:118
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:889
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus SetNpcAnimation(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 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 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 BSS
Definition macros.h:7
#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 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 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