From 2ec808cfb6431241591e8456f976a11fe23ec7a6 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Mon, 31 Aug 2026 21:17:34 +0200 Subject: [PATCH] [cc0 oot] BgHakaHuta --- .../actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c | 232 +++++++++--------- .../actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.h | 10 +- 2 files changed, 127 insertions(+), 115 deletions(-) diff --git a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c index 4e6d67df949..b59640cc55a 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c +++ b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c @@ -1,11 +1,6 @@ -/* - * File: z_bg_haka_huta.c - * Overlay: ovl_Bg_Haka_Huta - * Description: Coffin Lid - */ - #include "z_bg_haka_huta.h" -#include "overlays/actors/ovl_En_Rd/z_en_rd.h" +#include "src/overlays/actors/ovl_En_Firefly/z_en_firefly.h" +#include "src/overlays/actors/ovl_En_Rd/z_en_rd.h" #include "libc64/qrand.h" #include "ichain.h" @@ -27,12 +22,10 @@ void BgHakaHuta_Destroy(Actor* thisx, PlayState* play); void BgHakaHuta_Update(Actor* thisx, PlayState* play); void BgHakaHuta_Draw(Actor* thisx, PlayState* play); -void BgHakaHuta_SpawnDust(BgHakaHuta* this, PlayState* play); -void BgHakaHuta_PlaySfx(BgHakaHuta* this, PlayState* play, u16 sfx); -void BgHakaHuta_SpawnEnemies(BgHakaHuta* this, PlayState* play); -void BgHakaHuta_Open(BgHakaHuta* this, PlayState* play); -void BgHakaHuta_SlideOpen(BgHakaHuta* this, PlayState* play); -void func_8087D720(BgHakaHuta* this, PlayState* play); +void BgHakaHuta_WaitSwitchFlag(BgHakaHuta* this, PlayState* play); +void BgHakaHuta_OpenStartSlide(BgHakaHuta* this, PlayState* play); +void BgHakaHuta_OpenSlide(BgHakaHuta* this, PlayState* play); +void BgHakaHuta_OpenFallOff(BgHakaHuta* this, PlayState* play); void BgHakaHuta_DoNothing(BgHakaHuta* this, PlayState* play); ActorProfile Bg_Haka_Huta_Profile = { @@ -53,165 +46,176 @@ static InitChainEntry sInitChain[] = { void BgHakaHuta_Init(Actor* thisx, PlayState* play) { BgHakaHuta* this = (BgHakaHuta*)thisx; - s16 pad; + s32 pad; CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(thisx, sInitChain); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&gBotwCoffinLidCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); - this->unk_16A = PARAMS_GET_U(thisx->params, 8, 8); - thisx->params &= 0xFF; - if (Flags_GetSwitch(play, thisx->params)) { - this->counter = -1; - this->actionFunc = func_8087D720; + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->hiddenContent = PARAMS_GET_U(thisx->params, 8, 8); + thisx->params = PARAMS_GET_U(thisx->params, 0, 8); + if (Flags_GetSwitch(play, this->dyna.actor.params)) { + this->timer = -1; + this->actionFunc = BgHakaHuta_OpenFallOff; } else { - this->actionFunc = BgHakaHuta_SpawnEnemies; + this->actionFunc = BgHakaHuta_WaitSwitchFlag; } } void BgHakaHuta_Destroy(Actor* thisx, PlayState* play) { BgHakaHuta* this = (BgHakaHuta*)thisx; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgHakaHuta_SpawnDust(BgHakaHuta* this, PlayState* play) { - static Vec3f sEffectAccel[] = { 0.0f, 0.0f, 0.0f }; - static Color_RGBA8 primColor = { 30, 20, 50, 255 }; - static Color_RGBA8 envColor = { 0, 0, 0, 255 }; - f32 scale; - f32 phi_f20; - Vec3f effectPos; - Vec3f effectVel; +void BgHakaHuta_SpawnEffects(BgHakaHuta* this, PlayState* play) { + static Vec3f sEffAccel = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 sEffPrimColor = { 30, 20, 50, 255 }; + static Color_RGBA8 sEffEnvColor = { 0, 0, 0, 255 }; s32 i; - f32 new_Xpos; - f32 xPosOffset; - - phi_f20 = (this->dyna.actor.world.rot.y == 0) ? 1.0f : -1.0f; - effectVel.y = 0.0f; - effectVel.z = 0.0f; - effectVel.x = -0.5f * phi_f20; - effectPos.y = this->dyna.actor.world.pos.y; - effectPos.z = this->dyna.actor.world.pos.z; - new_Xpos = 50 - ((this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x) * phi_f20); - xPosOffset = new_Xpos * phi_f20; - + f32 dxMax; + Vec3f effPos; + Vec3f effVel; + f32 direction; + f32 dxMaxAbs; + + if (this->dyna.actor.world.rot.y == 0) { + direction = 1.0f; + } else { + direction = -1.0f; + } + effVel.x = -0.5f * direction; + effVel.y = 0.0f; + effVel.z = 0.0f; + effPos.y = this->dyna.actor.world.pos.y; + effPos.z = this->dyna.actor.world.pos.z; + dxMaxAbs = 50 - ((this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x) * direction); + dxMax = dxMaxAbs * direction; for (i = 0; i < 4; i++) { if (i == 2) { - effectPos.z += 120.0f * phi_f20; + effPos.z += 120.0f * direction; } - effectPos.x = this->dyna.actor.home.pos.x - (Rand_ZeroOne() * xPosOffset); - scale = ((Rand_ZeroOne() * 10.0f) + 50.0f); - func_8002829C(play, &effectPos, &effectVel, sEffectAccel, &primColor, &envColor, scale, 0xA); + effPos.x = this->dyna.actor.home.pos.x - (Rand_ZeroOne() * dxMax); + func_8002829C(play, &effPos, &effVel, &sEffAccel, &sEffPrimColor, &sEffEnvColor, + (Rand_ZeroOne() * 10.0f) + 50.0f, 10); } } -void BgHakaHuta_PlaySfx(BgHakaHuta* this, PlayState* play, u16 sfx) { +void BgHakaHuta_PlaySound(BgHakaHuta* this, PlayState* play, u16 sfxId) { Vec3f pos; - pos.z = (this->dyna.actor.shape.rot.y == 0) ? this->dyna.actor.world.pos.z + 120.0f - : this->dyna.actor.world.pos.z - 120.0f; + if (this->dyna.actor.shape.rot.y == 0) { + pos.z = this->dyna.actor.world.pos.z + 120.0f; + } else { + pos.z = this->dyna.actor.world.pos.z - 120.0f; + } pos.x = this->dyna.actor.world.pos.x; pos.y = this->dyna.actor.world.pos.y; - SfxSource_PlaySfxAtFixedWorldPos(play, &pos, 30, sfx); + SfxSource_PlaySfxAtFixedWorldPos(play, &pos, 30, sfxId); } -void BgHakaHuta_SpawnEnemies(BgHakaHuta* this, PlayState* play) { +void BgHakaHuta_WaitSwitchFlag(BgHakaHuta* this, PlayState* play) { if (Flags_GetSwitch(play, this->dyna.actor.params) && !Player_InCsMode(play)) { - this->counter = 25; - this->actionFunc = BgHakaHuta_Open; + this->timer = 25; + this->actionFunc = BgHakaHuta_OpenStartSlide; OnePointCutscene_Init(play, 6001, 999, &this->dyna.actor, CAM_ID_MAIN); - if (this->unk_16A == 2) { + if (this->hiddenContent == BG_HAKA_HUTA_HIDDEN_CONTENT_KEESES) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_FIREFLY, - (this->dyna.actor.world.pos.x + (-25.0f) * Math_CosS(this->dyna.actor.shape.rot.y) + - 40.0f * Math_SinS(this->dyna.actor.shape.rot.y)), + this->dyna.actor.world.pos.x + (-25.0f * Math_CosS(this->dyna.actor.shape.rot.y)) + + (40.0f * Math_SinS(this->dyna.actor.shape.rot.y)), this->dyna.actor.world.pos.y - 10.0f, - (this->dyna.actor.world.pos.z - (-25.0f) * Math_SinS(this->dyna.actor.shape.rot.y) + - Math_CosS(this->dyna.actor.shape.rot.y) * 40.0f), - 0, this->dyna.actor.shape.rot.y + 0x8000, 0, 2); - + this->dyna.actor.world.pos.z - (-25.0f * Math_SinS(this->dyna.actor.shape.rot.y)) + + (40.0f * Math_CosS(this->dyna.actor.shape.rot.y)), + 0, this->dyna.actor.shape.rot.y + 0x8000, 0, EN_FIREFLY_TYPE_NORMAL); Actor_Spawn(&play->actorCtx, play, ACTOR_EN_FIREFLY, - (this->dyna.actor.world.pos.x + (-25.0f) * (Math_CosS(this->dyna.actor.shape.rot.y)) + - Math_SinS(this->dyna.actor.shape.rot.y) * 80.0f), + this->dyna.actor.world.pos.x + (-25.0f * Math_CosS(this->dyna.actor.shape.rot.y)) + + (80.0f * Math_SinS(this->dyna.actor.shape.rot.y)), this->dyna.actor.world.pos.y - 10.0f, - (this->dyna.actor.world.pos.z - (-25.0f) * (Math_SinS(this->dyna.actor.shape.rot.y)) + - Math_CosS(this->dyna.actor.shape.rot.y) * 80.0f), - 0, this->dyna.actor.shape.rot.y, 0, 2); - - } else if (this->unk_16A == 1) { + this->dyna.actor.world.pos.z - (-25.0f * Math_SinS(this->dyna.actor.shape.rot.y)) + + (80.0f * Math_CosS(this->dyna.actor.shape.rot.y)), + 0, this->dyna.actor.shape.rot.y, 0, EN_FIREFLY_TYPE_NORMAL); + } else if (this->hiddenContent == BG_HAKA_HUTA_HIDDEN_CONTENT_GIBDO) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_RD, - (this->dyna.actor.home.pos.x + (-25.0f) * (Math_CosS(this->dyna.actor.shape.rot.y)) + - Math_SinS(this->dyna.actor.shape.rot.y) * 100.0f), + this->dyna.actor.home.pos.x + (-25.0f * Math_CosS(this->dyna.actor.shape.rot.y)) + + (100.0f * Math_SinS(this->dyna.actor.shape.rot.y)), this->dyna.actor.home.pos.y - 40.0f, - (this->dyna.actor.home.pos.z - (-25.0f) * (Math_SinS(this->dyna.actor.shape.rot.y)) + - Math_CosS(this->dyna.actor.shape.rot.y) * 100.0f), + this->dyna.actor.home.pos.z - (-25.0f * Math_SinS(this->dyna.actor.shape.rot.y)) + + (100.0f * Math_CosS(this->dyna.actor.shape.rot.y)), 0, this->dyna.actor.shape.rot.y, 0, (u8)REDEAD_TYPE_GIBDO_RISING_OUT_OF_COFFIN); } } } -void BgHakaHuta_Open(BgHakaHuta* this, PlayState* play) { - f32 posOffset; +void BgHakaHuta_OpenStartSlide(BgHakaHuta* this, PlayState* play) { + f32 dx; - if (this->counter != 0) { - this->counter--; + if (this->timer != 0) { + this->timer--; + } + if (this->dyna.actor.world.rot.y == 0) { + dx = 4.0f; + } else { + dx = -4.0f; } - posOffset = (this->dyna.actor.world.rot.y == 0) ? 4.0f : -4.0f; - Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + posOffset, 2.0f); - if (this->counter == 0) { - this->counter = 37; - BgHakaHuta_PlaySfx(this, play, NA_SE_EV_COFFIN_CAP_OPEN); - this->actionFunc = BgHakaHuta_SlideOpen; + Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + dx, 2.0f); + if (this->timer == 0) { + this->timer = 37; + BgHakaHuta_PlaySound(this, play, NA_SE_EV_COFFIN_CAP_OPEN); + this->actionFunc = BgHakaHuta_OpenSlide; } } -void BgHakaHuta_SlideOpen(BgHakaHuta* this, PlayState* play) { - f32 posOffset; +void BgHakaHuta_OpenSlide(BgHakaHuta* this, PlayState* play) { + f32 dx; - if (this->counter != 0) { - this->counter--; + if (this->timer != 0) { + this->timer--; + } + if (this->dyna.actor.world.rot.y == 0) { + dx = 24.0f; + } else { + dx = -24.0f; } - posOffset = (this->dyna.actor.world.rot.y == 0) ? 24.0f : -24.0f; - if (!Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + posOffset, 0.5f)) { - BgHakaHuta_SpawnDust(this, play); + if (!Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x + dx, 0.5f)) { + BgHakaHuta_SpawnEffects(this, play); } - if (this->counter == 0) { - BgHakaHuta_PlaySfx(this, play, NA_SE_EV_COFFIN_CAP_BOUND); - this->actionFunc = func_8087D720; + if (this->timer == 0) { + BgHakaHuta_PlaySound(this, play, NA_SE_EV_COFFIN_CAP_BOUND); + this->actionFunc = BgHakaHuta_OpenFallOff; } } -void func_8087D720(BgHakaHuta* this, PlayState* play) { - static Vec3f D_8087D958 = { 30.0f, 0.0f, 0.0f }; - static Vec3f D_8087D964 = { 0.03258f, 0.3258f, -0.9449f }; - MtxF mtx; - Vec3f vec; +void BgHakaHuta_OpenFallOff(BgHakaHuta* this, PlayState* play) { + static Vec3f sOffset = { 30.0f, 0.0f, 0.0f }; + static Vec3f sRotAxis = { 0.03258f, 0.3258f, -0.9449f }; + MtxF mf; + Vec3f posOffset; s32 quakeIndex; - this->counter++; - if (this->counter == 6) { + this->timer++; + if (this->timer == 6) { this->actionFunc = BgHakaHuta_DoNothing; - quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quakeIndex, 0x7530); + quakeIndex = Quake_Request(play->cameraPtrs[play->activeCamId], QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 30000); Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0); Quake_SetDuration(quakeIndex, 2); - } else if (this->counter == 0) { - this->counter = 6; + } else if (this->timer == 0) { + this->timer = 6; this->actionFunc = BgHakaHuta_DoNothing; } - - D_8087D958.x = this->counter + 24.0f; - if (D_8087D958.x > 30.0f) { - D_8087D958.x = 30.0f; + sOffset.x = this->timer + 24.0f; + if (sOffset.x > 30.0f) { + sOffset.x = 30.0f; } Matrix_RotateY(BINANG_TO_RAD(this->dyna.actor.world.rot.y), MTXMODE_NEW); - Matrix_RotateAxis(this->counter * (191 * M_PI / 3750), &D_8087D964, MTXMODE_APPLY); - Matrix_MultVec3f(&D_8087D958, &vec); - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + vec.x; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + vec.y; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + vec.z; - Matrix_Get(&mtx); - Matrix_MtxFToYXZRotS(&mtx, &this->dyna.actor.shape.rot, 0); + Matrix_RotateAxis(this->timer * 0.16001178f, &sRotAxis, MTXMODE_APPLY); + Matrix_MultVec3f(&sOffset, &posOffset); + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + posOffset.x; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + posOffset.y; + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + posOffset.z; + Matrix_Get(&mf); + Matrix_MtxFToYXZRotS(&mf, &this->dyna.actor.shape.rot, 0); } void BgHakaHuta_DoNothing(BgHakaHuta* this, PlayState* play) { @@ -224,5 +228,7 @@ void BgHakaHuta_Update(Actor* thisx, PlayState* play) { } void BgHakaHuta_Draw(Actor* thisx, PlayState* play) { + BgHakaHuta* this = (BgHakaHuta*)thisx; + Gfx_DrawDListOpa(play, gBotwCoffinLidDL); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.h b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.h index 3d691f3fad0..51501c30484 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.h +++ b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.h @@ -4,6 +4,12 @@ #include "ultra64.h" #include "actor.h" +typedef enum BgHakaHutaHiddenContent { + BG_HAKA_HUTA_HIDDEN_CONTENT_NONE, + BG_HAKA_HUTA_HIDDEN_CONTENT_GIBDO, + BG_HAKA_HUTA_HIDDEN_CONTENT_KEESES +} BgHakaHutaHiddenContent; + struct BgHakaHuta; typedef void (*BgHakaHutaActionFunc)(struct BgHakaHuta*, struct PlayState*); @@ -11,8 +17,8 @@ typedef void (*BgHakaHutaActionFunc)(struct BgHakaHuta*, struct PlayState*); typedef struct BgHakaHuta { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgHakaHutaActionFunc actionFunc; - /* 0x0168 */ s16 counter; - /* 0x016A */ s16 unk_16A; + /* 0x0168 */ s16 timer; + /* 0x016A */ s16 hiddenContent; } BgHakaHuta; // size = 0x016C #endif