2022-03-21 21:51:23 -04:00
|
|
|
/*
|
|
|
|
* File: z_magic_wind.c
|
|
|
|
* Overlay: ovl_Magic_Wind
|
|
|
|
* Description: Farore's Wind
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "z_magic_wind.h"
|
|
|
|
|
2023-05-30 15:05:04 -04:00
|
|
|
#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_NO_FREEZE_OCARINA)
|
2022-03-21 21:51:23 -04:00
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Init(Actor* thisx, PlayState* play);
|
|
|
|
void MagicWind_Destroy(Actor* thisx, PlayState* play);
|
|
|
|
void MagicWind_Update(Actor* thisx, PlayState* play);
|
|
|
|
void MagicWind_Draw(Actor* thisx, PlayState* play);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Shrink(MagicWind* this, PlayState* play);
|
|
|
|
void MagicWind_WaitForTimer(MagicWind* this, PlayState* play);
|
|
|
|
void MagicWind_FadeOut(MagicWind* this, PlayState* play);
|
|
|
|
void MagicWind_WaitAtFullSize(MagicWind* this, PlayState* play);
|
|
|
|
void MagicWind_Grow(MagicWind* this, PlayState* play);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
const ActorInit Magic_Wind_InitVars = {
|
|
|
|
ACTOR_MAGIC_WIND,
|
|
|
|
ACTORCAT_ITEMACTION,
|
|
|
|
FLAGS,
|
|
|
|
OBJECT_GAMEPLAY_KEEP,
|
|
|
|
sizeof(MagicWind),
|
|
|
|
(ActorFunc)MagicWind_Init,
|
|
|
|
(ActorFunc)MagicWind_Destroy,
|
|
|
|
(ActorFunc)MagicWind_Update,
|
|
|
|
(ActorFunc)MagicWind_Draw,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
#include "overlays/ovl_Magic_Wind/ovl_Magic_Wind.h"
|
|
|
|
|
|
|
|
static u8 sAlphaUpdVals[] = {
|
|
|
|
0x00, 0x03, 0x04, 0x07, 0x09, 0x0A, 0x0D, 0x0F, 0x11, 0x12, 0x15, 0x16, 0x19, 0x1B, 0x1C, 0x1F, 0x21, 0x23,
|
|
|
|
};
|
|
|
|
|
|
|
|
void MagicWind_SetupAction(MagicWind* this, MagicWindFunc actionFunc) {
|
|
|
|
this->actionFunc = actionFunc;
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Init(Actor* thisx, PlayState* play) {
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind* this = (MagicWind*)thisx;
|
2022-11-06 03:24:34 -05:00
|
|
|
Player* player = GET_PLAYER(play);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
if (SkelCurve_Init(play, &this->skelCurve, &sSkel, &sAnim) == 0) {
|
2022-03-21 21:51:23 -04:00
|
|
|
// "Magic_Wind_Actor_ct (): Construct failed"
|
|
|
|
osSyncPrintf("Magic_Wind_Actor_ct():コンストラクト失敗\n");
|
|
|
|
}
|
|
|
|
this->actor.room = -1;
|
|
|
|
switch (this->actor.params) {
|
|
|
|
case 0:
|
|
|
|
SkelCurve_SetAnim(&this->skelCurve, &sAnim, 0.0f, 60.0f, 0.0f, 1.0f);
|
|
|
|
this->timer = 29;
|
|
|
|
MagicWind_SetupAction(this, MagicWind_WaitForTimer);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
SkelCurve_SetAnim(&this->skelCurve, &sAnim, 60.0f, 0.0f, 60.0f, -1.0f);
|
|
|
|
MagicWind_SetupAction(this, MagicWind_Shrink);
|
|
|
|
// "Means start"
|
2022-07-05 19:29:34 -04:00
|
|
|
LOG_STRING("表示開始");
|
2023-09-15 14:39:46 -04:00
|
|
|
Player_PlaySfx(&player->actor, NA_SE_PL_MAGIC_WIND_WARP);
|
2022-03-21 21:51:23 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Destroy(Actor* thisx, PlayState* play) {
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind* this = (MagicWind*)thisx;
|
2022-11-06 03:24:34 -05:00
|
|
|
SkelCurve_Destroy(play, &this->skelCurve);
|
2023-10-19 19:13:33 -04:00
|
|
|
Magic_Reset(play);
|
2022-03-21 21:51:23 -04:00
|
|
|
// "wipe out"
|
2022-07-05 19:29:34 -04:00
|
|
|
LOG_STRING("消滅");
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MagicWind_UpdateAlpha(f32 alpha) {
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
Vtx* vtx = ResourceMgr_LoadVtxByName(sCylinderVtx);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sAlphaUpdVals); i++) {
|
|
|
|
vtx[sAlphaUpdVals[i]].n.a = alpha * 255.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_WaitForTimer(MagicWind* this, PlayState* play) {
|
|
|
|
Player* player = GET_PLAYER(play);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
if (this->timer > 0) {
|
|
|
|
this->timer--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// "Means start"
|
2022-07-05 19:29:34 -04:00
|
|
|
LOG_STRING("表示開始");
|
2023-09-15 14:39:46 -04:00
|
|
|
Player_PlaySfx(&player->actor, NA_SE_PL_MAGIC_WIND_NORMAL);
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind_UpdateAlpha(1.0f);
|
|
|
|
MagicWind_SetupAction(this, MagicWind_Grow);
|
2022-11-06 03:24:34 -05:00
|
|
|
SkelCurve_Update(play, &this->skelCurve);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Grow(MagicWind* this, PlayState* play) {
|
|
|
|
if (SkelCurve_Update(play, &this->skelCurve)) {
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind_SetupAction(this, MagicWind_WaitAtFullSize);
|
|
|
|
this->timer = 50;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_WaitAtFullSize(MagicWind* this, PlayState* play) {
|
2022-03-21 21:51:23 -04:00
|
|
|
if (this->timer > 0) {
|
|
|
|
this->timer--;
|
|
|
|
} else {
|
|
|
|
MagicWind_SetupAction(this, MagicWind_FadeOut);
|
|
|
|
this->timer = 30;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_FadeOut(MagicWind* this, PlayState* play) {
|
2022-03-21 21:51:23 -04:00
|
|
|
if (this->timer > 0) {
|
|
|
|
MagicWind_UpdateAlpha((f32)this->timer * (1.0f / 30.0f));
|
|
|
|
this->timer--;
|
|
|
|
} else {
|
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Shrink(MagicWind* this, PlayState* play) {
|
|
|
|
if (SkelCurve_Update(play, &this->skelCurve)) {
|
2022-03-21 21:51:23 -04:00
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Update(Actor* thisx, PlayState* play) {
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind* this = (MagicWind*)thisx;
|
2022-11-06 03:24:34 -05:00
|
|
|
if (play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK ||
|
|
|
|
play->msgCtx.msgMode == MSGMODE_SONG_PLAYED) {
|
2022-03-21 21:51:23 -04:00
|
|
|
Actor_Kill(thisx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
this->actionFunc(this, play);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
s32 MagicWind_OverrideLimbDraw(PlayState* play, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) {
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind* this = (MagicWind*)thisx;
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
OPEN_DISPS(play->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
if (limbIndex == 1) {
|
|
|
|
gSPSegment(POLY_XLU_DISP++, 8,
|
2022-11-06 03:24:34 -05:00
|
|
|
Gfx_TwoTexScroll(play->state.gfxCtx, 0, (play->state.frames * 9) & 0xFF,
|
|
|
|
0xFF - ((play->state.frames * 0xF) & 0xFF), 0x40, 0x40, 1,
|
|
|
|
(play->state.frames * 0xF) & 0xFF,
|
|
|
|
0xFF - ((play->state.frames * 0x1E) & 0xFF), 0x40, 0x40));
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
} else if (limbIndex == 2) {
|
|
|
|
gSPSegment(POLY_XLU_DISP++, 9,
|
2022-11-06 03:24:34 -05:00
|
|
|
Gfx_TwoTexScroll(play->state.gfxCtx, 0, (play->state.frames * 3) & 0xFF,
|
|
|
|
0xFF - ((play->state.frames * 5) & 0xFF), 0x40, 0x40, 1,
|
|
|
|
(play->state.frames * 6) & 0xFF,
|
|
|
|
0xFF - ((play->state.frames * 0xA) & 0xFF), 0x40, 0x40));
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
CLOSE_DISPS(play->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-11-06 03:24:34 -05:00
|
|
|
void MagicWind_Draw(Actor* thisx, PlayState* play) {
|
|
|
|
GraphicsContext* gfxCtx = play->state.gfxCtx;
|
2022-03-21 21:51:23 -04:00
|
|
|
MagicWind* this = (MagicWind*)thisx;
|
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
OPEN_DISPS(gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
if (this->actionFunc != MagicWind_WaitForTimer) {
|
2022-11-29 18:29:36 -05:00
|
|
|
POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, 25);
|
2022-11-06 03:24:34 -05:00
|
|
|
SkelCurve_Draw(thisx, play, &this->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
CLOSE_DISPS(gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|