From 9f5217c81f9d0c83d184c984906107b6edadf53e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:16:21 +0000 Subject: [PATCH] En_Zow (#607) * En_Zow * Matching * PR --- spec | 3 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 623 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Zow/z_en_zow.h | 28 +- tools/disasm/variables.txt | 4 +- undefined_syms.txt | 12 - 5 files changed, 613 insertions(+), 57 deletions(-) diff --git a/spec b/spec index ad40881087..9e891a30ce 100644 --- a/spec +++ b/spec @@ -4834,8 +4834,7 @@ beginseg name "ovl_En_Zow" compress include "build/src/overlays/actors/ovl_En_Zow/z_en_zow.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.data.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.reloc.o" + include "build/src/overlays/actors/ovl_En_Zow/ovl_En_Zow_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 2147bc5f4b..3ada9fc104 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -5,8 +5,9 @@ */ #include "z_en_zow.h" +#include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZow*)thisx) @@ -21,7 +22,6 @@ void func_80BDD634(EnZow* this, GlobalContext* globalCtx); void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx); void func_80BDD79C(EnZow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zow_InitVars = { ACTOR_EN_ZOW, ACTORCAT_NPC, @@ -34,72 +34,617 @@ const ActorInit En_Zow_InitVars = { (ActorFunc)EnZow_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDDCF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80BDDD1C = { 0.0f, 1.0f, 0.0f }; -extern ColliderCylinderInit D_80BDDCF0; +Vec3f D_80BDDD28 = { 0.0f, -1.0f, 0.0f }; -extern UNK_TYPE D_06002A50; -extern UNK_TYPE D_06002C10; -extern UNK_TYPE D_06004248; -extern UNK_TYPE D_0600D288; +void func_80BDC270(EnZowStruct* ptr, Vec3f* arg1, f32 arg2, f32 arg3, u8 arg4) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC270.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + ptr->unk_14 = *arg1; + ptr->unk_04 = arg2; + ptr->unk_08 = arg3; + ptr->unk_0F = arg4; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC2D8.s") +void func_80BDC2D8(EnZow* this, EnZowStruct* ptr, Vec3f* arg2) { + s16 i; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC3C0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 0) { + temp = this->actor.world.pos.y + this->actor.depthInWater; + if (temp <= arg2->y) { + continue; + } + ptr->unk_00 = 3; + ptr->unk_14 = *arg2; + ptr->unk_20 = *arg2; + ptr->unk_2C = D_80BDDD1C; + ptr->unk_04 = ((Rand_ZeroOne() - 0.5f) * 0.02f) + 0.12f; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC50C.s") +void func_80BDC3C0(EnZowStruct* ptr, Vec3f* arg1, Vec3f* arg2, f32 arg3) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC5C8.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 != 2) { + ptr->unk_00 = 2; + ptr->unk_14 = *arg1; + ptr->unk_20 = D_80BDDD28; + ptr->unk_2C = *arg2; + ptr->unk_0F = (Rand_ZeroOne() * 100.0f) + 100.0f; + ptr->unk_04 = arg3; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC6F8.s") +void func_80BDC50C(EnZowStruct* ptr) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC830.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + Math_ApproachF(&ptr->unk_04, ptr->unk_08, 0.2f, 0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC9DC.s") + if (ptr->unk_0F > 20) { + ptr->unk_0F -= 20; + } else { + ptr->unk_0F = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCB84.s") + if (ptr->unk_0F == 0) { + ptr->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCD38.s") +void func_80BDC5C8(EnZow* this, EnZowStruct* ptr) { + f32 temp_f2; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCDA8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 3) { + ptr->unk_14.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.x; + ptr->unk_14.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.z; + ptr->unk_14.y += ptr->unk_2C.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Init.s") + temp_f2 = this->actor.world.pos.y + this->actor.depthInWater; + if (temp_f2 <= ptr->unk_14.y) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Destroy.s") +void func_80BDC6F8(EnZow* this, EnZowStruct* ptr) { + s16 i; + f32 temp_f0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD04C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 2) { + ptr->unk_14.x += ptr->unk_2C.x; + ptr->unk_14.y += ptr->unk_2C.y; + ptr->unk_14.z += ptr->unk_2C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD154.s") + if (ptr->unk_2C.y >= -20.0f) { + ptr->unk_2C.y += ptr->unk_20.y; + } else { + ptr->unk_2C.y = -20.0f; + ptr->unk_20.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD1E0.s") + temp_f0_2 = this->actor.world.pos.y + this->actor.depthInWater; + if (ptr->unk_14.y < temp_f0_2) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f0_2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD350.s") +void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD490.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD570.s") + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD634.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + if (!flag) { + gDPPipeSync(POLY_XLU_DISP++); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D220); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + if (1) {} + flag = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD6BC.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD79C.s") + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04, 1.0f, ptr->unk_04, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Update.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D288); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDA7C.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAA0.s") +void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAE0.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Draw.s") + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_0029F0); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + if (1) {} + flag = true; + } + + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002A50); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 2) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002BA0); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); + if (1) {} + flag = true; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); + + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002C10); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCD38(EnZow* this, EnZowStruct* ptr, f32 arg2, f32 arg3, u8 arg4) { + static Vec3f D_80BDDD34 = { 0.0f, 0.0f, 0.0f }; + + D_80BDDD34.x = this->actor.world.pos.x; + D_80BDDD34.y = this->actor.world.pos.y + this->actor.depthInWater; + D_80BDDD34.z = this->actor.world.pos.z; + func_80BDC270(ptr, &D_80BDDD34, arg2, arg3, arg4); +} + +void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { + Vec3f sp84; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + s32 i; + + for (i = 0; i < 10; i++) { + temp_f20 = (Rand_ZeroOne() * 1.5f) + 0.5f; + temp_f22 = Rand_ZeroOne() * 6.28f; + + sp78.y = (Rand_ZeroOne() * 3.0f) + 3.0f; + sp78.x = __sinf(temp_f22) * temp_f20; + sp78.z = __cosf(temp_f22) * temp_f20; + + sp84 = this->actor.world.pos; + sp84.x += sp78.x * 6.0f; + sp84.z += sp78.z * 6.0f; + sp84.y += this->actor.depthInWater; + + func_80BDC3C0(ptr, &sp84, &sp78, 0.08f); + } +} + +void EnZow_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80BDD79C; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); + Animation_PlayOnce(&this->skelAnime, &gZoraSurfacingAnim); + this->unk_2C8 = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.shape.rot.z = 0; + this->unk_2CA = 0; + this->unk_2CC = 0; + this->unk_2CE = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.textId = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZow* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; + +void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { + if ((arg1 >= 0) && (arg1 < 3)) { + if (arg1 < 2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + arg2, -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, Animation_GetLastFrame(sAnimations[arg1]), + 0.0f, arg2, 0.0f); + } + this->unk_2C8 = arg1; + } +} + +s32 func_80BDD154(EnZow* this, GlobalContext* globalCtx) { + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && + (this->actor.xzDistToPlayer < 170.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + return true; + } + return false; +} + +void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { + u16 phi_a1; + + if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { + if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[78] & 4) { + phi_a1 = 0x12FD; + } else { + phi_a1 = 0x12FA; + gSaveContext.weekEventReg[78] |= 4; + } + } else if (gSaveContext.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[78] & 8) { + phi_a1 = 0x12F8; + } else { + phi_a1 = 0x12F3; + gSaveContext.weekEventReg[78] |= 8; + } + } else if (gSaveContext.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + phi_a1 = 0x12EC; + } else { + phi_a1 = 0x12F1; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[78] & 2) { + phi_a1 = 0x12EB; + } else { + phi_a1 = 0x12E8; + gSaveContext.weekEventReg[78] |= 2; + } + } else { + phi_a1 = 0x12EF; + } + func_801518B0(globalCtx, phi_a1, &this->actor); +} + +void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CA & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_WATER); + func_80BDCDA8(this, this->unk_2D0); + this->actor.flags &= ~ACTOR_FLAG_1; + this->skelAnime.playSpeed = 0.0f; + this->actor.velocity.y = -4.0f; + } + + if (this->actor.depthInWater > 120.0f) { + Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.4f, 0.6f); + if (this->actor.velocity.y > -0.1f) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > 180.0f)) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + + if (this->skelAnime.playSpeed <= 0.0f) { + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + return; + } else { + this->unk_2CE = 0; + } + } +} + +void func_80BDD490(EnZow* this, GlobalContext* globalCtx) { + this->actor.velocity.y = 0.0f; + if (this->actor.xzDistToPlayer > 440.0f) { + this->actionFunc = func_80BDD350; + func_80BDD04C(this, 2, 2); + } else if (this->unk_2CA & 2) { + func_80BDD04C(this, 0, 0); + } + + if ((globalCtx->gameplayFrames & 7) == 0) { + func_80BDCD38(this, this->unk_2D0, 0.2f, 1.0f, 200); + } + + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } +} + +void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x12E8: + case 0x12E9: + case 0x12EC: + case 0x12ED: + case 0x12EF: + case 0x12F1: + case 0x12F3: + case 0x12F4: + case 0x12F5: + case 0x12F6: + case 0x12F8: + case 0x12FA: + case 0x12FB: + case 0x12FD: + case 0x12FF: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + default: + func_801477B4(globalCtx); + break; + } + } + break; + + case 2: + this->actionFunc = func_80BDD634; + break; + } +} + +void func_80BDD634(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BDD570; + func_80BDD1E0(this, globalCtx); + } else if (func_80BDD154(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 180.0f); + } +} + +void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } + + if (this->actor.depthInWater < 54.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + func_80BDCDA8(this, this->unk_2D0); + func_80BDD04C(this, 1, 2); + this->actor.flags |= ACTOR_FLAG_1; + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD634; + } else if (this->actor.depthInWater < 80.0f) { + Math_ApproachF(&this->actor.velocity.y, 2.0f, 0.4f, 0.6f); + } +} + +void func_80BDD79C(EnZow* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 400.0f) { + this->actor.velocity.y = 4.0f; + this->actionFunc = func_80BDD6BC; + } + + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + } else { + this->unk_2CE = 0; + } + + if (this->actor.depthInWater > 180.0f) { + this->actor.world.pos.y = this->actor.world.pos.y + -180.0f + this->actor.depthInWater; + } +} + +void EnZow_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + Vec3f sp34; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); + + if (this->unk_2CE != 0) { + this->unk_2CA &= ~2; + if (SkelAnime_Update(&this->skelAnime)) { + this->unk_2CA |= 2; + } + } else { + this->unk_2CA |= 2; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + + this->actionFunc(this, globalCtx); + + if (this->unk_2CE != 0) { + if ((globalCtx->state.frames & 8) != 0) { + sp34 = this->actor.world.pos; + sp34.y += ((Rand_ZeroOne() - 0.5f) * 10.0f) + 18.0f; + sp34.x += (Rand_ZeroOne() - 0.5f) * 28.0f; + sp34.z += (Rand_ZeroOne() - 0.5f) * 28.0f; + func_80BDC2D8(this, this->unk_2D0, &sp34); + } + + if (DECR(this->unk_2C6) == 0) { + this->unk_2C6 = Rand_S16Offset(60, 60); + } + + this->unk_2C4 = this->unk_2C6; + if (this->unk_2C4 >= 3) { + this->unk_2C4 = 0; + } + } + + this->actor.shape.shadowAlpha = this->unk_2CE; + func_80BDC50C(this->unk_2D0); + func_80BDC5C8(this, this->unk_2D0); + func_80BDC6F8(this, this->unk_2D0); +} + +Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { + Gfx* gfx = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(gfx); + + return gfx; +} + +Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; + +void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_80BDDD4C, &thisx->focus.pos); + } +} + +void func_80BDDAE0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + func_80BDDAA0(globalCtx, limbIndex, dList, rot, thisx); +} + +void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr sp54[] = { + gZoraEyeOpenTex, + gZoraEyeHalfTex, + gZoraEyeClosedTex, + }; + EnZow* this = THIS; + + Matrix_StatePush(); + + func_80BDC830(this->unk_2D0, globalCtx); + func_80BDC9DC(this->unk_2D0, globalCtx); + func_80BDCB84(this->unk_2D0, globalCtx); + + Matrix_StatePop(); + + if (this->unk_2CE != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_2CE >= 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80BDDA7C(globalCtx->state.gfxCtx)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BDDAA0, &this->actor); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + + func_800BDAA0(globalCtx, &this->skelAnime, NULL, func_80BDDAE0, &this->actor, this->unk_2CE); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.h b/src/overlays/actors/ovl_En_Zow/z_en_zow.h index 976e4e29ba..e169e28160 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.h +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.h @@ -7,9 +7,35 @@ struct EnZow; typedef void (*EnZowActionFunc)(struct EnZow*, GlobalContext*); +#define ENZOW_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENZOW_F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ UNK_TYPE1 unk_0C[0x3]; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ UNK_TYPE1 unk_10[0x4]; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; +} EnZowStruct; // size = 0x38 + typedef struct EnZow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4D4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; + /* 0x01D4 */ Vec3s jointTable[20]; + /* 0x024C */ Vec3s morphTable[20]; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C6 */ s16 unk_2C6; + /* 0x02C8 */ s16 unk_2C8; + /* 0x02CA */ u16 unk_2CA; + /* 0x02CC */ s16 unk_2CC; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ EnZowStruct unk_2D0[15]; /* 0x0618 */ EnZowActionFunc actionFunc; } EnZow; // size = 0x61C diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d82b93e995..2ccca1ea75 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16049,9 +16049,7 @@ 0x80BDDCF0:("D_80BDDCF0","UNK_TYPE1","",0x1), 0x80BDDD1C:("D_80BDDD1C","UNK_TYPE4","",0x4), 0x80BDDD28:("D_80BDDD28","UNK_TYPE4","",0x4), - 0x80BDDD34:("D_80BDDD34","f32","",0x4), - 0x80BDDD38:("D_80BDDD38","f32","",0x4), - 0x80BDDD3C:("D_80BDDD3C","f32","",0x4), + 0x80BDDD34:("D_80BDDD34","Vec3f","",0xC), 0x80BDDD40:("D_80BDDD40","UNK_TYPE1","",0x1), 0x80BDDD4C:("D_80BDDD4C","UNK_TYPE1","",0x1), 0x80BDDD58:("D_80BDDD58","UNK_TYPE4","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 413b7d0513..61a474f463 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2027,18 +2027,6 @@ D_06004FE4 = 0x06004FE4; D_06005098 = 0x06005098; D_06005250 = 0x06005250; -// ovl_En_Zow - -D_060029F0 = 0x060029F0; -D_06002A50 = 0x06002A50; -D_06002BA0 = 0x06002BA0; -D_06002C10 = 0x06002C10; -D_06003610 = 0x06003610; -D_06004248 = 0x06004248; -D_0600D208 = 0x0600D208; -D_0600D220 = 0x0600D220; -D_0600D288 = 0x0600D288; - // ovl_Mir_Ray D_06000168 = 0x06000168;