From 1789cee1c90aed23b4fb3584fcc8fe3a8292fee0 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 8 Aug 2021 18:28:13 +0100 Subject: [PATCH] En_Dekunuts (#232) * En_Dekunuts * PR * Macros * NBS * PR * PR * PR --- spec | 3 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 700 ++++++++++++++++-- .../actors/ovl_En_Dekunuts/z_en_dekunuts.h | 31 +- 3 files changed, 665 insertions(+), 69 deletions(-) diff --git a/spec b/spec index 1861e3ec70..fb65f7e208 100644 --- a/spec +++ b/spec @@ -1105,8 +1105,7 @@ beginseg name "ovl_En_Dekunuts" compress include "build/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.o" - include "build/data/ovl_En_Dekunuts/ovl_En_Dekunuts.data.o" - include "build/data/ovl_En_Dekunuts/ovl_En_Dekunuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Dekunuts/ovl_En_Dekunuts_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index e264df696c..fcf906cc7b 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -1,4 +1,11 @@ +/* + * File: z_en_dekunuts.c + * Overlay: ovl_En_Dekunuts + * Description: Mad Scrub + */ + #include "z_en_dekunuts.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS 0x00000005 @@ -9,20 +16,42 @@ void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_808BD428(EnDekunuts* this); void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BD78C(EnDekunuts* this); void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BD870(EnDekunuts* this); void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BDA08(EnDekunuts* this); void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BDC9C(EnDekunuts* this); void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx); void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BDF60(EnDekunuts* this); void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BE1CC(EnDekunuts* this); void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx); void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx); void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BE484(EnDekunuts* this); void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BE680(EnDekunuts* this); void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_06000168; +extern Gfx D_06001E50[]; +extern Gfx D_06001F50[]; +extern SkeletonHeader D_06002468; +extern AnimationHeader D_0600259C; +extern AnimationHeader D_06002A5C; +extern AnimationHeader D_06002BD4; +extern AnimationHeader D_06002DD4; +extern AnimationHeader D_06002FA4; +extern AnimationHeader D_06003180; +extern AnimationHeader D_0600326C; +extern AnimationHeader D_060033E4; +extern AnimationHeader D_06003780; + const ActorInit En_Dekunuts_InitVars = { ACTOR_EN_DEKUNUTS, ACTORCAT_ENEMY, @@ -35,18 +64,29 @@ const ActorInit En_Dekunuts_InitVars = { (ActorFunc)EnDekunuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808BEF30 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, 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_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + 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, + }, { 18, 32, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808BEF5C = { 1, 18, 32, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 18, 32, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_808BEF64 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -81,97 +121,633 @@ static DamageTable D_808BEF64 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808BEF84[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -#endif +void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* this = THIS; -extern ColliderCylinderInit D_808BEF30; -extern CollisionCheckInfoInit D_808BEF5C; -extern DamageTable D_808BEF64; -extern InitChainEntry D_808BEF84[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_06002468, &D_0600326C, this->jointTable, this->morphTable, 10); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_194 = ENDEKUNUTS_GET_FF00(&this->actor); + thisx->params &= 0xFF; + if ((this->unk_194 == ENDEKUNUTS_GET_FF00_FF) || (this->unk_194 == ENDEKUNUTS_GET_FF00_0)) { + this->unk_194 = ENDEKUNUTS_GET_FF00_1; + } -extern UNK_TYPE D_06000168; -extern UNK_TYPE D_06001E50; -extern UNK_TYPE D_06001F50; -extern UNK_TYPE D_0600259C; -extern UNK_TYPE D_06002A5C; -extern UNK_TYPE D_06002BD4; -extern UNK_TYPE D_06002DD4; -extern UNK_TYPE D_06002FA4; -extern UNK_TYPE D_06003180; -extern UNK_TYPE D_0600326C; -extern UNK_TYPE D_060033E4; -extern UNK_TYPE D_06003780; + if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { + this->actor.flags &= ~1; + this->collider.base.colType = COLTYPE_NONE; + this->collider.info.bumperFlags |= (BUMP_NO_HITMARK | BUMP_NO_SWORD_SFX | BUMP_NO_DAMAGE | BUMP_NO_AT_INFO); + } else if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { + this->actor.targetMode = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/EnDekunuts_Init.s") + func_808BD428(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/EnDekunuts_Destroy.s") +void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD348.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD3B4.s") +void func_808BD348(EnDekunuts* this) { + this->unk_18E = 10; + this->unk_214 = 0.55f; + this->unk_218 = 0.82500005f; + this->unk_210 = 1.0f; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_190 = 80; + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD428.s") +void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_18E == 10) { + this->unk_18E = 0; + this->collider.base.colType = COLTYPE_HIT6; + this->unk_210 = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD49C.s") +void func_808BD428(EnDekunuts* this) { + SkelAnime_ChangeAnimPlaybackStop(&this->skelAnime, &D_06003180, 0.0f); + this->unk_190 = Rand_S16Offset(100, 50); + this->collider.dim.height = 5; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_808BD49C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD78C.s") +void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { + s32 phi_v1 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD7D4.s") + if (this->skelAnime.animPlaybackSpeed < 0.5f) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD870.s") + if (phi_v1 && (this->unk_190 != 0)) { + this->unk_190--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BD8D8.s") + if (func_801378B8(&this->skelAnime, 9.0f)) { + this->collider.base.acFlags |= AC_ON; + } else if (func_801378B8(&this->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDA08.s") + this->collider.dim.height = (s32)((CLAMP(this->skelAnime.animCurrentFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDA4C.s") + if (!phi_v1 && (this->actor.params == ENDEKUNUTS_GET_FF00_0) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.xzDistToPlayer < 120.0f)) { + func_808BDC9C(this); + } else if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (((this->unk_190 == 0) && (this->actor.xzDistToPlayer > 320.0f)) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK)) { + func_808BD78C(this); + } else { + if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { + func_808BE680(this); + } else if ((this->actor.params == ENDEKUNUTS_GET_FF00_0) && (this->actor.xzDistToPlayer < 120.0f)) { + func_808BDC9C(this); + } else { + func_808BD870(this); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDC9C.s") + if (phi_v1 && ((this->actor.xzDistToPlayer > 160.0f) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) && + (((this->actor.params == ENDEKUNUTS_GET_FF00_0) && (fabsf(this->actor.yDistToPlayer) < 120.0f)) || + ((this->actor.params == ENDEKUNUTS_GET_FF00_2) && (this->actor.yDistToPlayer > -60.0f)) || + (this->actor.params == ENDEKUNUTS_GET_FF00_1)) && + ((this->unk_190 == 0) || (this->actor.xzDistToPlayer < 480.0f))) { + this->skelAnime.animPlaybackSpeed = 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDCF0.s") +void func_808BD78C(EnDekunuts* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06002FA4); + this->unk_190 = 2; + this->actionFunc = func_808BD7D4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDD54.s") +void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 0.0f)) { + if (this->unk_190 != 0) { + this->unk_190--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDE7C.s") + if ((this->unk_190 == 0) || + ((this->actor.xzDistToPlayer < 120.0f) && Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + func_808BDC9C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDEF8.s") +void func_808BD870(EnDekunuts* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600326C, -3.0f); + if (this->actionFunc == func_808BDA4C) { + this->unk_190 = 4098; + } else { + this->unk_190 = 1; + } + this->actionFunc = func_808BD8D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDF60.s") +void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 0.0f)) { + if (this->unk_190 != 0) { + this->unk_190--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BDFB8.s") + if (!(this->unk_190 & 0x1000)) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE1CC.s") + if (this->unk_190 == 0x1000) { + if ((this->actor.xzDistToPlayer > 480.0f) || + ((this->actor.params == ENDEKUNUTS_GET_FF00_0) && (this->actor.xzDistToPlayer < 120.0f)) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK)) { + func_808BDC9C(this); + } else { + func_808BDA08(this); + } + } else if (this->unk_190 == 0) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) { + func_808BDC9C(this); + } else { + func_808BDA08(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE22C.s") +void func_808BDA08(EnDekunuts* this) { + SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000168); + this->unk_190 = this->unk_194; + this->actionFunc = func_808BDA4C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE294.s") +void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { + Player* player; + Vec3f sp58; + s16 pitch; + Vec3f pos; + f32 val; + s16 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE358.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); + if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { + player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE3A8.s") + sp58.x = player->actor.world.pos.x; + sp58.z = player->actor.world.pos.z; + sp58.y = player->actor.world.pos.y + 40.0f; + pitch = Actor_PitchToPoint(&this->actor, &sp58); + pitch = CLAMP(pitch, -0x3800, -0x2000); + if (this->skelAnime.animCurrentFrame < 7.0f) { + Math_ScaledStepToS(&this->actor.world.rot.x, pitch, 0x800); + } else { + Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0x800); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE3FC.s") + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->actor.world.rot.x = 0; + func_808BD870(this); + } else if (func_801378B8(&this->skelAnime, 7.0f)) { + val = Math_CosS(this->actor.world.rot.x) * 15.0f; + pos.x = (Math_SinS(this->actor.shape.rot.y) * val) + this->actor.world.pos.x; + pos.y = (this->actor.world.pos.y + 12.0f) - (Math_SinS(this->actor.world.rot.x) * 15.0f); + pos.z = (Math_CosS(this->actor.shape.rot.y) * val) + this->actor.world.pos.z; + params = (this->actor.params == ENDEKUNUTS_GET_FF00_2) ? ENDEKUNUTS_GET_FF00_2 : ENDEKUNUTS_GET_FF00_0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE484.s") + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, pos.x, pos.y, pos.z, + this->actor.world.rot.x, this->actor.shape.rot.y, 0, params) != NULL) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); + } + } else if ((this->unk_190 >= 2) && func_801378B8(&this->skelAnime, 12.0f)) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06000168, -3.0f); + if (this->unk_190 != 0) { + this->unk_190--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE4D4.s") +void func_808BDC9C(EnDekunuts* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002A5C, -5.0f); + this->unk_190 = 0; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + this->actionFunc = func_808BDD54; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE680.s") +void func_808BDCF0(EnDekunuts* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002A5C, -5.0f); + this->collider.base.acFlags &= ~AC_ON; + this->unk_190 = 80; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + this->actionFunc = func_808BDD54; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE6C4.s") +void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->unk_190 != 0) { + this->unk_190--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BE73C.s") + if (this->unk_190 == 0) { + func_808BD428(this); + } + } else { + this->collider.dim.height = (s32)((3.0f - CLAMP(this->skelAnime.animCurrentFrame, 1.0f, 3.0f)) * 12.0f) + 5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/EnDekunuts_Update.s") + if (func_801378B8(&this->skelAnime, 4.0f)) { + this->collider.base.acFlags &= ~AC_ON; + } + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.5f, 3.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.5f, 3.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BEBD0.s") +void func_808BDE7C(EnDekunuts* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002DD4, -3.0f); + this->collider.dim.height = 37; + this->actor.colChkInfo.mass = 50; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); + this->actor.world.rot.x = 0; + this->actor.flags |= 0x20; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_808BDEF8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/func_808BED30.s") +void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); + this->unk_18D = 3; + func_808BDF60(this); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekunuts/EnDekunuts_Draw.s") +void func_808BDF60(EnDekunuts* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06003780); + this->unk_190 = 2; + this->unk_18C = 0; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = func_808BDFB8; +} + +void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { + s16 yaw; + s16 yaw2; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 0.0f)) { + if (this->unk_190 != 0) { + this->unk_190--; + } + } + + if (this->unk_18C != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + this->unk_18C = 0; + } else { + this->unk_18C = 1; + } + + Math_StepToF(&this->actor.speedXZ, 7.5f, 1.0f); + if (!Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_192, 1, 0xE38, 0xB6)) { + if (this->actor.bgCheckFlags & 0x20) { + this->unk_192 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } else if (this->actor.bgCheckFlags & 8) { + this->unk_192 = this->actor.wallYaw; + } else if (this->unk_18D == 0) { + yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yaw2 = yaw - this->actor.yawTowardsPlayer; + if (ABS_ALT(yaw2) > 0x2000) { + this->unk_192 = yaw; + } else { + this->unk_192 = (((yaw2 >= 0) ? 1 : -1) * -0x2000) + this->actor.yawTowardsPlayer; + } + } else { + this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); + } + } + + this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); + if ((this->unk_18D == 0) && (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 20.0f) && + (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f)) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.flags &= ~0x20; + this->actor.speedXZ = 0.0f; + func_808BDC9C(this); + } else if (this->unk_190 == 0) { + func_808BE1CC(this); + } +} + +void func_808BE1CC(EnDekunuts* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060033E4); + this->unk_190 = 3; + this->actor.speedXZ = 0.0f; + if (this->unk_18D != 0) { + this->unk_18D--; + } + this->actionFunc = func_808BE22C; +} + +void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 0.0f)) { + if (this->unk_190 != 0) { + this->unk_190--; + } + } + + if (this->unk_190 == 0) { + func_808BDF60(this); + } +} + +void func_808BE294(EnDekunuts* this, s32 arg1) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_0600259C, -3.0f); + if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { + this->actor.speedXZ = 10.0f; + if (arg1 != 0) { + func_800BE504(&this->actor, &this->collider); + } + } + + this->actor.world.rot.x = 0; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_808BE358; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_CUTBODY); + func_800BCB70(&this->actor, 0x4000, 255, 0, SkelAnime_GetFrameCount(&D_0600259C.common)); +} + +void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + func_808BE484(this); + } +} + +void func_808BE3A8(EnDekunuts* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + func_800BE504(&this->actor, &this->collider); + this->actionFunc = func_808BE3FC; +} + +void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_190 != 0) { + this->unk_190--; + } + + if (this->unk_190 == 0) { + func_808BD3B4(this, globalCtx); + if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { + func_808BDCF0(this); + } else if (this->actor.colChkInfo.health == 0) { + func_808BE294(this, 0); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_808BDF60(this); + } + } +} + +void func_808BE484(EnDekunuts* this) { + SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06002BD4); + this->actionFunc = func_808BE4D4; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DEAD); +} + +void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_808BEF90 = { 255, 255, 255, 255 }; + static Color_RGBA8 D_808BEF94 = { 150, 150, 150, 0 }; + s32 pad; + Vec3f sp40; + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 18.0f; + sp40.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &sp40, &D_801D15B0, &D_801D15B0, &D_808BEF90, &D_808BEF94, 200, 0, 13); + func_800F0568(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + sp40.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, 0x80); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, 64, 10, D_06001F50); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808BE680(EnDekunuts* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600326C, -3.0f); + this->actionFunc = func_808BE6C4; +} + +void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); + } + + if (this->actor.xzDistToPlayer > 480.0f) { + func_808BDC9C(this); + } +} + +void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + func_800BE258(&this->actor, &this->collider.info); + if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + func_808BD3B4(this, globalCtx); + if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { + if ((this->actor.params != ENDEKUNUTS_GET_FF00_1) && !func_800BE22C(&this->actor)) { + func_800BBA88(globalCtx, &this->actor); + } + + if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { + func_808BDCF0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 3) { + func_808BD348(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_190 = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_808BE3A8(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_190 = 40; + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_808BE3A8(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_210 = 4.0f; + this->unk_214 = 0.55f; + this->unk_18E = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_210 = 4.0f; + this->unk_214 = 0.55f; + this->unk_18E = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_18E = 32; + this->unk_210 = 4.0f; + this->unk_214 = 0.55f; + } + + func_808BE294(this, 1); + } else if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { + func_808BDE7C(this); + } + } + } else if ((this->actor.colChkInfo.mass == MASS_IMMOVABLE) && (globalCtx->actorCtx.unk2 != 0) && + (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { + if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { + func_808BDCF0(this); + } else if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { + func_808BDE7C(this); + } else if (this->actor.colChkInfo.health != 0) { + this->actor.colChkInfo.health = 0; + func_800BBA88(globalCtx, &this->actor); + func_808BE294(this, 0); + } + } +} + +void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* this = THIS; + s32 pad; + + func_808BE73C(this, globalCtx); + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 0x1D); + Collider_UpdateCylinder(&this->actor, &this->collider); + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->unk_210 > 0.0f) { + if (this->unk_18E != 10) { + Math_StepToF(&this->unk_210, 0.0f, 0.05f); + this->unk_214 = (this->unk_210 + 1.0f) * 0.275f; + this->unk_214 = CLAMP_MAX(this->unk_214, 0.55f); + } else if ((this->unk_18E == 10) && !Math_StepToF(&this->unk_218, 0.55f, (33.0f / 1600.0f))) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 func_808BEBD0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnDekunuts* this = THIS; + f32 arg1, arg2, arg3; + f32 currentFrame; + + if (this->actionFunc == func_808BDA4C) { + if (limbIndex == 5) { + currentFrame = this->skelAnime.animCurrentFrame; + if (currentFrame <= 6.0f) { + arg2 = 1.0f - (currentFrame * 0.0833f); + arg1 = (currentFrame * 0.1167f) + 1.0f; + arg3 = (currentFrame * 0.1167f) + 1.0f; + } else if (currentFrame <= 7.0f) { + currentFrame -= 6.0f; + arg2 = 0.5f + currentFrame; + arg1 = 1.7f - (currentFrame * 0.7f); + arg3 = 1.7f - (currentFrame * 0.7f); + } else if (currentFrame <= 10.0f) { + arg2 = 1.5f - ((currentFrame - 7.0f) * 0.1667f); + arg1 = 1.0f; + arg3 = 1.0f; + } else { + return 0; + } + Matrix_Scale(arg1, arg2, arg3, MTXMODE_APPLY); + } else if ((limbIndex == 2) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { + rot->z = this->actor.world.rot.x; + } + } + return 0; +} + +void func_808BED30(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static s8 D_808BEF98[] = { + -1, -1, -1, 3, -1, 0, -1, 1, -1, 2, 0, 0, + }; + static Vec3f D_808BEFA4[] = { + { -1500.0f, 0.0f, -1700.0f }, { -1500.0f, 0.0f, 1700.0f }, { -2500.0f, -2000.0f, 0.0f }, + { -1000.0f, 1000.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + }; + EnDekunuts* this = THIS; + s32 i; + Vec3f* ptr1; + Vec3f* ptr2; + s32 value = D_808BEF98[limbIndex]; + + if (value != -1) { + if (value < 3) { + SysMatrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); + } else { + SysMatrix_GetStateTranslation(&this->unk_21C[value]); + ptr1 = &D_808BEFA4[0]; + ptr2 = &this->unk_21C[value + 1]; + for (i = value + 1; i < ARRAY_COUNT(this->unk_21C); i++) { + SysMatrix_MultiplyVector3fByState(ptr1, ptr2); + ptr1++, ptr2++; + } + } + } + + if (limbIndex == 2) { + SysMatrix_GetStateTranslation(&this->actor.focus.pos); + } +} + +void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDekunuts* this = THIS; + + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, func_808BEBD0, func_808BED30, + &this->actor); + SysMatrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + func_800BDFC0(globalCtx, D_06001E50); + func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, + this->unk_18E); +} diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index 3cd88d129e..aa0b3e1bff 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -5,13 +5,34 @@ struct EnDekunuts; -typedef void (*EnDekunutsActionFunc)(struct EnDekunuts* this, GlobalContext* globalCtx); +typedef void (*EnDekunutsActionFunc)(struct EnDekunuts*, GlobalContext*); + +#define ENDEKUNUTS_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); + +enum { + /* 0x0 */ ENDEKUNUTS_GET_FF00_0, + /* 0x1 */ ENDEKUNUTS_GET_FF00_1, + /* 0x2 */ ENDEKUNUTS_GET_FF00_2, + /* 0xFF*/ ENDEKUNUTS_GET_FF00_FF = 0xFF, +}; typedef struct EnDekunuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDekunutsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x13C]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnDekunutsActionFunc actionFunc; + /* 0x18C */ u8 unk_18C; + /* 0x18D */ u8 unk_18D; + /* 0x18E */ u8 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ s16 unk_194; + /* 0x196 */ Vec3s jointTable[10]; + /* 0x1D2 */ Vec3s morphTable[10]; + /* 0x210 */ f32 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ f32 unk_218; + /* 0x21C */ Vec3f unk_21C[8]; + /* 0x27C */ ColliderCylinder collider; } EnDekunuts; // size = 0x2C8 extern const ActorInit En_Dekunuts_InitVars;