3#include "sprite/player.h"
21s32 N(SpiritsFlyDelay)[] = { 35, 0, 5, 10, 15, 20, 25, 30 };
22s32 N(SpiritsFlyAwayDelay)[] = { 35, 0, 5, 10, 15, 20, 25, 30 };
24f32 N(SpiritsScatterPos)[] = {
52BSS char N(padding)[4];
53BSS s32 N(MiscParticlesTimeLeft)[8];
54BSS s32 N(SpiritsMoveTime)[8];
55BSS s32 N(StarBeamStage);
57API_CALLABLE(N(ProcessPeachStarBeam)) {
64 f32 currentPosX, currentPosY, currentPosZ;
65 f32 targetPosX, targetPosY, targetPosZ;
66 f32 goalPosX, goalPosY, goalPosZ;
104 switch (script->functionTemp[FT_STATE]) {
114 effectData = N(BeamEffect)->data.peachStarBeam;
116 if (script->functionTemp[FT_IS_PEACH_BEAM] || i != 0) {
117 spirit = &effectData->
spirits[i];
118 if (N(MiscParticlesTimeLeft)[i] != 0) {
119 N(MiscParticlesTimeLeft)[i]--;
121 N(MiscParticlesTimeLeft)[i] = 20;
122 if (N(SpiritsFlyDelay)[i] <= 0) {
125 fx_misc_particles(4, spirit->
pos.
x, spirit->
pos.
y, spirit->
pos.
z, 20.0f, 20.0f, 1.0f, 10, 20);
132 effectData = N(BeamEffect)->data.peachStarBeam;
134 if (script->functionTemp[FT_IS_PEACH_BEAM] || i != 0) {
135 spirit = &effectData->
spirits[i];
136 if (N(MiscParticlesTimeLeft)[i] != 0) {
137 N(MiscParticlesTimeLeft)[i]--;
139 N(MiscParticlesTimeLeft)[i] = 20;
140 if (N(SpiritsFlyAwayDelay)[i] <= 0) {
143 fx_misc_particles(4, spirit->
pos.
x, spirit->
pos.
y, spirit->
pos.
z, 20.0f, 20.0f, 1.0f, 10, 20);
151 switch (script->functionTemp[FT_STATE]) {
153 currentPosX = player->
curPos.
x;
154 currentPosY = player->
curPos.
y + player->
size.
y + 30.0f;
155 currentPosZ = player->
curPos.
z;
157 playerState->
curPos.
x = currentPosX;
158 playerState->
curPos.
y = currentPosY + 150.0f;
159 playerState->
curPos.
z = currentPosZ;
161 playerState->
goalPos.
x = currentPosX;
162 playerState->
goalPos.
y = currentPosY;
163 playerState->
goalPos.
z = currentPosZ;
165 if (!script->functionTemp[FT_IS_PEACH_BEAM]) {
166 N(BeamEffect) = fx_peach_star_beam(0, currentPosX, currentPosY, currentPosZ, 1.0f, 0);
168 N(BeamEffect) = fx_peach_star_beam(1, currentPosX, currentPosY, currentPosZ, 1.0f, 0);
170 playerState->
dist = 48.0f;
171 N(BeamEffect)->data.peachStarBeam->unk_3C = 0;
172 N(BeamEffect)->data.peachStarBeam->circleRadius = playerState->
dist;
173 N(BeamEffect)->data.peachStarBeam->beamAlpha = 0;
174 N(BeamEffect)->data.peachStarBeam->twinkYOffset = 30.0f;
175 N(BeamEffect)->data.peachStarBeam->rotSpeed = 5.0f;
176 for (i = 0; i <
ARRAY_COUNT(N(MiscParticlesTimeLeft)); i++) {
177 N(MiscParticlesTimeLeft)[i] =
rand_int(20);
180 script->functionTemp[FT_DELAY] = 40;
181 if (!script->functionTemp[FT_IS_PEACH_BEAM]) {
190 N(BeamEffect)->data.peachStarBeam->circleCenter.x = playerState->
curPos.
x;
191 N(BeamEffect)->data.peachStarBeam->circleCenter.y = playerState->
curPos.
y;
192 N(BeamEffect)->data.peachStarBeam->circleCenter.z = playerState->
curPos.
z;
193 N(BeamEffect)->data.peachStarBeam->unk_3C = 0;
194 N(BeamEffect)->data.peachStarBeam->circleRadius = playerState->
dist;
195 N(BeamEffect)->data.peachStarBeam->beamAlpha = 0;
196 if (script->functionTemp[FT_DELAY] == 0) {
197 script->functionTemp[FT_DELAY] = 20;
200 script->functionTemp[FT_DELAY]--;
204 if (script->functionTemp[FT_DELAY] == 0) {
207 script->functionTemp[FT_DELAY] = 15;
210 script->functionTemp[FT_DELAY]--;
214 playerState->
dist += (24.0f - playerState->
dist) * 0.125f;
215 N(BeamEffect)->data.peachStarBeam->circleRadius = playerState->
dist;
216 if (script->functionTemp[FT_DELAY] == 0) {
217 playerState->
goalPos.
x = targetPosX;
218 playerState->
goalPos.
y = targetPosY;
219 playerState->
goalPos.
z = targetPosZ;
220 for (i = 0; i <
ARRAY_COUNT(N(SpiritsMoveTime)); i++) {
221 N(SpiritsMoveTime)[i] = 30;
224 if (!script->functionTemp[FT_IS_PEACH_BEAM]) {
231 script->functionTemp[FT_DELAY]--;
236 playerState->
dist += (48.0f - playerState->
dist) * 0.25f;
237 N(BeamEffect)->data.peachStarBeam->circleRadius = playerState->
dist;
238 for (i = 0; i < 2; i++) {
240 spirit = &effectData->
spirits[i];
241 if (N(SpiritsFlyDelay)[i] < 0) {
242 currentPosX = playerState->
curPos.
x;
243 currentPosY = playerState->
curPos.
y;
244 currentPosZ = playerState->
curPos.
z;
250 playerState->
curPos.
x += goalPosX - currentPosX;
251 playerState->
curPos.
y += goalPosY - currentPosY;
252 playerState->
curPos.
z += goalPosZ - currentPosZ;
255 if (N(SpiritsFlyDelay)[i] != 0) {
256 N(SpiritsFlyDelay)[i]--;
258 currentPosX = playerState->
curPos.
x;
259 currentPosY = playerState->
curPos.
y;
260 currentPosZ = playerState->
curPos.
z;
264 dist =
dist2D(currentPosX, currentPosZ, goalPosX, goalPosZ);
265 playerState->
curPos.
x += (goalPosX - currentPosX) / N(SpiritsMoveTime)[i];
266 playerState->
curPos.
y += (goalPosY - currentPosY) / N(SpiritsMoveTime)[i];
267 playerState->
curPos.
z += (goalPosZ - currentPosZ) / N(SpiritsMoveTime)[i];
268 if (N(SpiritsMoveTime)[i] == 1) {
269 N(SpiritsFlyDelay)[i] = -1;
270 playerState->
curPos.
x = goalPosX;
271 playerState->
curPos.
y = goalPosY;
272 playerState->
curPos.
z = goalPosZ;
274 playerState->
curPos.
y += dist / 60.0f;
276 N(SpiritsMoveTime)[i]--;
282 N(BeamEffect)->data.peachStarBeam->circleCenter.x = playerState->
curPos.
x;
283 N(BeamEffect)->data.peachStarBeam->circleCenter.y = playerState->
curPos.
y;
284 N(BeamEffect)->data.peachStarBeam->circleCenter.z = playerState->
curPos.
z;
285 N(BeamEffect)->data.peachStarBeam->pos.x = playerState->
curPos.
x;
286 N(BeamEffect)->data.peachStarBeam->pos.y = 0.0f;
287 N(BeamEffect)->data.peachStarBeam->pos.z = playerState->
curPos.
z;
292 N(BeamEffect)->data.peachStarBeam->circleCenter.x = playerState->
curPos.
x;
293 N(BeamEffect)->data.peachStarBeam->circleCenter.y = playerState->
curPos.
y;
294 N(BeamEffect)->data.peachStarBeam->circleCenter.z = playerState->
curPos.
z;
295 N(BeamEffect)->data.peachStarBeam->pos.x = playerState->
curPos.
x;
296 N(BeamEffect)->data.peachStarBeam->pos.y = 0.0f;
297 N(BeamEffect)->data.peachStarBeam->pos.z = playerState->
curPos.
z;
298 effectData = N(BeamEffect)->data.peachStarBeam;
300 if (script->functionTemp[FT_IS_PEACH_BEAM] || i != 0) {
301 spirit = &effectData->
spirits[i];
302 N(SpiritsFlyDelay)[i] = 1;
309 script->functionTemp[FT_DELAY] = 15;
314 if (script->functionTemp[FT_DELAY] == 0) {
316 N(BeamEffect)->data.peachStarBeam->unk_3C = 0;
317 N(BeamEffect)->data.peachStarBeam->beamAlpha = 0;
318 if (script->functionTemp[FT_IS_PEACH_BEAM]) {
319 N(BeamEffect)->data.peachStarBeam->primR = 240;
320 N(BeamEffect)->data.peachStarBeam->primG = 80;
321 N(BeamEffect)->data.peachStarBeam->primB = 200;
322 N(BeamEffect)->data.peachStarBeam->envR = 240;
323 N(BeamEffect)->data.peachStarBeam->envG = 240;
324 N(BeamEffect)->data.peachStarBeam->envB = 240;
328 newScript->varTable[0] = playerState->
curPos.
x;
329 newScript->varTable[1] = playerState->
curPos.
y * 0.5f;
330 newScript->varTable[2] = playerState->
curPos.
z;
331 newScript->varTable[10] = script->functionTemp[FT_IS_PEACH_BEAM];
334 script->functionTemp[FT_DELAY] = 45;
337 script->functionTemp[FT_DELAY]--;
345 N(BeamEffect)->data.peachStarBeam->unk_3C = playerState->
moveTime;
346 N(BeamEffect)->data.peachStarBeam->beamAlpha = playerState->
moveTime;
347 if (script->functionTemp[FT_DELAY] == 0) {
348 N(StarBeamStage) = 1;
349 if (!script->functionTemp[FT_IS_PEACH_BEAM] && player->
targetListLength == 1) {
353 script->functionTemp[FT_DELAY] = 15;
357 script->functionTemp[FT_DELAY] = 15;
361 script->functionTemp[FT_DELAY]--;
365 if (script->functionTemp[FT_DELAY] == 0) {
366 script->functionTemp[FT_DELAY] = 10;
369 script->functionTemp[FT_DELAY]--;
377 N(BeamEffect)->data.peachStarBeam->unk_3C = playerState->
moveTime;
378 N(BeamEffect)->data.peachStarBeam->beamAlpha = playerState->
moveTime;
379 if (script->functionTemp[FT_DELAY] == 0) {
380 script->functionTemp[FT_DELAY] = 10;
383 script->functionTemp[FT_DELAY]--;
387 if (script->functionTemp[FT_DELAY] != 0) {
388 script->functionTemp[FT_DELAY]--;
391 playerState->
goalPos.
x = targetPosX;
392 playerState->
goalPos.
y = targetPosY + 170.0f;
393 playerState->
goalPos.
z = targetPosZ;
394 script->functionTemp[FT_DELAY] = 20;
398 if (script->functionTemp[FT_DELAY] != 0) {
399 script->functionTemp[FT_DELAY]--;
400 if (script->functionTemp[FT_DELAY] == 0) {
401 if (!script->functionTemp[FT_IS_PEACH_BEAM]) {
411 effectData = N(BeamEffect)->data.peachStarBeam;
413 if (script->functionTemp[FT_IS_PEACH_BEAM] || i != 0) {
414 spirit = &effectData->
spirits[i];
415 if (N(SpiritsFlyAwayDelay)[i] >= 0) {
417 if (N(SpiritsFlyAwayDelay)[i] != 0) {
418 N(SpiritsFlyAwayDelay)[i]--;
424 N(SpiritsFlyAwayDelay)[i] = -1;
432 N(StarBeamStage) = 2;
438 N(BeamEffect)->data.peachStarBeam->unk_3C = 0;
439 N(BeamEffect)->data.peachStarBeam->beamAlpha = 0;
440 for (i = 0; i <
ARRAY_COUNT(N(SpiritsMoveTime)); i++) {
441 N(SpiritsMoveTime)[i] = 15;
444 if (!script->functionTemp[FT_IS_PEACH_BEAM]) {
453 effectData = N(BeamEffect)->data.peachStarBeam;
455 if (script->functionTemp[FT_IS_PEACH_BEAM] || i != 0) {
456 spirit = &effectData->
spirits[i];
457 if (N(SpiritsFlyDelay)[i] < 0) {
462 goalPosX = N(SpiritsScatterPos)[3 * i + 0];
463 goalPosY = N(SpiritsScatterPos)[3 * i + 1];
464 goalPosZ = N(SpiritsScatterPos)[3 * i + 2];
466 spirit->
lockedPos.
x += goalPosX - currentPosX;
467 spirit->
lockedPos.
y += goalPosY - currentPosY;
468 spirit->
lockedPos.
z += goalPosZ - currentPosZ;
471 if (N(SpiritsFlyDelay)[i] != 0) {
472 N(SpiritsFlyDelay)[i]--;
480 goalPosX = N(SpiritsScatterPos)[3 * i + 0];
481 goalPosY = N(SpiritsScatterPos)[3 * i + 1];
482 goalPosZ = N(SpiritsScatterPos)[3 * i + 2];
483 dist =
dist2D(currentPosX, currentPosZ, goalPosX, goalPosZ);
484 spirit->
lockedPos.
x += (goalPosX - currentPosX) / N(SpiritsMoveTime)[i];
485 spirit->
lockedPos.
y += (goalPosY - currentPosY) / N(SpiritsMoveTime)[i];
486 spirit->
lockedPos.
z += (goalPosZ - currentPosZ) / N(SpiritsMoveTime)[i];
487 if (N(SpiritsMoveTime)[i] == 1) {
488 N(SpiritsFlyDelay)[i] = -1;
495 N(SpiritsMoveTime)[i]--;
502 N(StarBeamStage) = 2;
511API_CALLABLE(N(GetStage)) {
512 script->varTable[0] = N(StarBeamStage);
516API_CALLABLE(N(unkStarBeamBgFunc)) {
518 script->functionTemp[0] = 230;
523 script->functionTemp[0] -= 5;
524 if (script->functionTemp[0] <= 200) {
@ PEACH_STAR_BEAM_START_FLY_AWAY
@ PEACH_STAR_BEAM_ZOOM_OUT
@ PEACH_STAR_BEAM_SPIRITS_FLY_AWAY
@ PEACH_STAR_BEAM_SPIRITS_APPEAR
@ PEACH_STAR_BEAM_CREATE_EFFECT
@ PEACH_STAR_BEAM_FADE_OUT_BEAM
@ PEACH_STAR_BEAM_MAKE_BEAM
@ PEACH_STAR_BEAM_SHRINK_CIRCLE
@ PEACH_STAR_BEAM_FLY_TO_TARGET
@ PEACH_STAR_BEAM_MAKE_ADDITIONAL_EFFECTS
@ PEACH_STAR_BEAM_SPIRITS_SCATTER
PeachStarBeamSpirit spirits[8]
@ FX_INSTANCE_FLAG_DISMISS
@ ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
Actor glows and listens for Star Beam and Peach Beam events.
@ SOUND_ID_TRIGGER_CHANGE_SOUND
@ SOUND_LRAW_USE_PEACH_BEAM
@ SOUND_LRAW_USE_STAR_BEAM
@ SOUND_LOOP_USE_PEACH_BEAM
@ SOUND_LOOP_USE_STAR_BEAM
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
s32 evt_get_variable(Evt *script, Bytecode var)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
void btl_cam_use_preset(s32)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
ActorPart * get_actor_part(Actor *actor, s32 partID)
Actor * get_actor(s32 actorID)
void mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
void snd_stop_tracking_env_sound_pos(s32 soundID, s32 keepPlaying)
void sfx_play_sound(s32 soundID)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
#define EndIf
Marks the end of an if statement or an else block.
#define Thread
Marks the start of a thread block.
#define EndThread
Marks the end of a thread block.
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
#define PlayEffect(args...)
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
#define Return
Kills the current EVT thread.
struct Actor * playerActor
BattleStatus gBattleStatus