diff --git a/spec b/spec index e248f2a406..3a691a3985 100644 --- a/spec +++ b/spec @@ -3616,8 +3616,7 @@ beginseg name "ovl_En_Kame" compress include "build/src/overlays/actors/ovl_En_Kame/z_en_kame.o" - include "build/data/ovl_En_Kame/ovl_En_Kame.data.o" - include "build/data/ovl_En_Kame/ovl_En_Kame.reloc.o" + include "build/src/overlays/actors/ovl_En_Kame/ovl_En_Kame_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index c8cceba619..71482f79ff 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -5,6 +5,7 @@ */ #include "z_en_kame.h" +#include "objects/object_tl/object_tl.h" #define FLAGS 0x00000405 @@ -15,21 +16,31 @@ void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKame_Update(Actor* thisx, GlobalContext* globalCtx); void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80AD70A0(EnKame* this); void func_80AD70EC(EnKame* this, GlobalContext* globalCtx); +void func_80AD71B4(EnKame* this); void func_80AD7254(EnKame* this, GlobalContext* globalCtx); +void func_80AD73A8(EnKame* this); void func_80AD7424(EnKame* this, GlobalContext* globalCtx); +void func_80AD76CC(EnKame* this); void func_80AD7798(EnKame* this, GlobalContext* globalCtx); +void func_80AD792C(EnKame* this); void func_80AD7948(EnKame* this, GlobalContext* globalCtx); +void func_80AD7B18(EnKame* this); void func_80AD7B90(EnKame* this, GlobalContext* globalCtx); void func_80AD7D40(EnKame* this, GlobalContext* globalCtx); +void func_80AD7DA4(EnKame* this); void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx); +void func_80AD7EC0(EnKame* this); void func_80AD7F10(EnKame* this, GlobalContext* globalCtx); void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx); void func_80AD810C(EnKame* this, GlobalContext* globalCtx); +void func_80AD8148(EnKame* this, GlobalContext* globalCtx); void func_80AD825C(EnKame* this, GlobalContext* globalCtx); +void func_80AD8364(EnKame* this); void func_80AD8388(EnKame* this, GlobalContext* globalCtx); +void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kame_InitVars = { ACTOR_EN_KAME, ACTORCAT_ENEMY, @@ -42,18 +53,29 @@ const ActorInit En_Kame_InitVars = { (ActorFunc)EnKame_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AD8DE0 = { - { COLTYPE_HARD, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CF7FFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CF7FFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 35, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80AD8E0C = { 3, 15, 30, 80 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 15, 30, 80 }; -// static DamageTable sDamageTable = { -static DamageTable D_80AD8E14 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,107 +110,733 @@ static DamageTable D_80AD8E14 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AD8E44[] = { +static TexturePtr D_80AD8E34[] = { object_tl_Tex_0055A0, object_tl_Tex_0057A0, object_tl_Tex_0059A0, + object_tl_Tex_0057A0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; -#endif +static s32 D_80AD8E50 = false; -extern ColliderCylinderInit D_80AD8DE0; -extern CollisionCheckInfoInit D_80AD8E0C; -extern DamageTable D_80AD8E14; -extern InitChainEntry D_80AD8E44[]; +void EnKame_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; -extern UNK_TYPE D_060008B4; -extern UNK_TYPE D_06000AF4; -extern UNK_TYPE D_06001C68; -extern UNK_TYPE D_06002510; -extern UNK_TYPE D_060027D8; -extern UNK_TYPE D_06002F88; -extern UNK_TYPE D_060031DC; -extern UNK_TYPE D_060035EC; -extern UNK_TYPE D_06004210; -extern UNK_TYPE D_0600823C; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &object_tl_Skel_007C70, &object_tl_Anim_004210, this->jointTable1, + this->morphTable1, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &object_tl_Skel_001A50, &object_tl_Anim_000B30, this->jointTable2, + this->morphTable2, 4); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 55.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Init.s") + if (!D_80AD8E50) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Destroy.s") + for (i = 0; i < ARRAY_COUNT(D_80AD8E34); i++) { + D_80AD8E34[i] = Lib_SegmentedToVirtual(D_80AD8E34[i]); + } + D_80AD8E50 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD6F34.s") + func_80AD70A0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD6F9C.s") +void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7018.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD70A0.s") +void func_80AD6F34(EnKame* this) { + if (this->unk_29C != 0) { + this->unk_29C++; + if (this->unk_29C == 4) { + this->unk_29C = 0; + } + } else if (Rand_ZeroOne() < 0.05f) { + this->unk_29C = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD70EC.s") +void func_80AD6F9C(EnKame* this) { + this->unk_29D = 10; + this->unk_2B4 = 0.6f; + this->unk_2B8 = 0.90000004f; + this->unk_2B0 = 1.0f; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_2A2 = 80; + this->actor.flags &= ~0x400; + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD71B4.s") +void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29D == 10) { + this->unk_29D = 0; + this->collider.base.colType = COLTYPE_HIT6; + this->unk_2B0 = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); + this->actor.flags |= 0x400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7254.s") +void func_80AD70A0(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_004210, -5.0f); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD70EC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD73A8.s") +void func_80AD70EC(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7424.s") + if (Animation_OnFrame(&this->skelAnime1, 10.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_VOICE); + this->unk_2A0 = 40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7568.s") + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + (this->actor.xzDistToPlayer < 240.0f)) { + func_80AD73A8(this); + } else if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD71B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD75A8.s") +void func_80AD71B4(EnKame* this) { + Animation_MorphToLoop(&this->skelAnime1, &object_tl_Anim_00823C, -5.0f); + this->actor.speedXZ = 0.5f; + this->unk_29E = Animation_GetLastFrame(&object_tl_Anim_00823C) * ((s32)Rand_ZeroFloat(5.0f) + 3); + this->unk_2A4 = this->actor.shape.rot.y; + this->collider.base.acFlags |= (AC_HARD | AC_ON); + this->collider.base.colType = COLTYPE_HARD; + this->actionFunc = func_80AD7254; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD76CC.s") +void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7798.s") + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + (this->actor.xzDistToPlayer < 240.0f)) { + func_80AD73A8(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD792C.s") + SkelAnime_Update(&this->skelAnime1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7948.s") + if (this->unk_2A4 != this->actor.shape.rot.y) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7B18.s") + this->unk_29E--; + if (this->unk_29E == 0) { + func_80AD70A0(this); + } else if (Animation_OnFrame(&this->skelAnime1, 0.0f) || Animation_OnFrame(&this->skelAnime1, 15.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7B90.s") +void func_80AD73A8(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_001C68, -3.0f); + this->unk_29E = 0; + this->unk_2AC = 1.0f; + this->unk_2A8 = 1.0f; + this->actor.speedXZ = 0.0f; + if (this->unk_2A0 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_VOICE); + } + this->actionFunc = func_80AD7424; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7C54.s") +void func_80AD7424(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7D40.s") + if (SkelAnime_Update(&this->skelAnime1)) { + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + ((this->unk_29E == 0) || (this->actor.xzDistToPlayer < 120.0f))) { + func_80AD76CC(this); + } else { + this->unk_29E--; + if (this->unk_29E == 0) { + func_80AD7B18(this); + } + } + } else if (this->skelAnime1.curFrame > 2.0f) { + this->unk_2AC = 1.5f - ((this->skelAnime1.curFrame - 2.0f) * (7.0f / 30)); + this->unk_2A8 = 1.5f - ((this->skelAnime1.curFrame - 2.0f) * (1.0f / 12)); + } else { + f32 frame = this->skelAnime1.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7DA4.s") + this->unk_2AC = (0.25f * frame) + 1.0f; + this->unk_2A8 = (0.25f * frame) + 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7E0C.s") +void func_80AD7568(EnKame* this) { + this->actor.speedXZ = this->unk_2A6 * (5.0f / 7552); + this->actor.shape.rot.z = this->unk_2A6 * 0.11016949f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7EC0.s") +void func_80AD75A8(EnKame* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80AD8E54 = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80AD8E58 = { 180, 180, 180, 255 }; + static Vec3f D_80AD8E5C = { 0.0f, 0.75f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7F10.s") + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 3.0f)) { + if ((globalCtx->gameplayFrames % 2) == 0) { + u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7FA4.s") + if ((temp_v0 == 0) || (temp_v0 == 1)) { + func_800B1210(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, 550, 100); + } else if (temp_v0 == 14) { + func_800B0DE0(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, &D_80AD8E54, &D_80AD8E58, + 550, 100); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7FF8.s") + if (this->unk_2A6 > 0x1200) { + func_800B9010(&this->actor, NA_SE_EN_PAMET_ROLL - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8060.s") +void func_80AD76CC(EnKame* this) { + if (this->actor.draw == EnKame_Draw) { + this->actor.draw = func_80AD8D64; + this->unk_2A6 = 0x3B00; + this->unk_2AC = 0.5f; + func_80AD7568(this); + this->unk_29E = 15; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_CUTTER_ON); + this->unk_2BC.y = this->actor.home.pos.y - 100.0f; + } else { + this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); + this->unk_29E = 0; + } + this->actor.flags |= 0x10; + this->actionFunc = func_80AD7798; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD810C.s") +void func_80AD7798(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29E == 15) { + this->unk_2AC += 0.2f; + if (this->unk_2AC > 1.1f) { + this->unk_29E--; + this->collider.base.atFlags |= AT_ON; + this->unk_2AC = 1.0f; + } + } else if (this->unk_29E > 0) { + this->unk_29E--; + } else if (Math_ScaledStepToS(&this->unk_2A6, 0x3B00, (s32)(this->unk_2A6 * 0.09f) + 45)) { + if (this->unk_2BC.y < this->actor.home.pos.y) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_2BC.x = (Math_SinS(this->actor.world.rot.y) * 360.0f) + this->actor.world.pos.x; + this->unk_2BC.z = (Math_CosS(this->actor.world.rot.y) * 360.0f) + this->actor.world.pos.z; + } + func_80AD792C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8148.s") + this->actor.shape.rot.y += this->unk_2A6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD825C.s") + if (!(this->unk_2BC.y < this->actor.home.pos.y) || (this->actionFunc != func_80AD7798)) { + func_80AD7568(this); + } + func_80AD75A8(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8364.s") +void func_80AD792C(EnKame* this) { + this->unk_29E = -1; + this->actionFunc = func_80AD7948; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8388.s") +void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD84C0.s") + this->actor.shape.rot.y += this->unk_2A6; + func_80AD75A8(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Update.s") + if (this->unk_29E == -1) { + s16 temp_v0 = Actor_YawToPoint(&this->actor, &this->unk_2BC) - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8A48.s") + temp_v1 = ABS_ALT(temp_v0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8AF8.s") + if ((this->actor.bgCheckFlags & 8) || (temp_v1 > 0x3000) || + (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f)) { + s8 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Draw.s") + if (this->unk_2BC.y < this->actor.home.pos.y) { + this->unk_29E = 0x300; + } else { + this->unk_29E = 0; + } + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8CEC.s") + if (Math_ScaledStepToS(&this->unk_2A6, this->unk_29E, (s32)(this->unk_2A6 * 0.09f) + 45)) { + if (this->unk_29E == 0) { + if (this->unk_2AC >= 1.0f) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); + } + this->unk_2AC -= 0.1f; + this->collider.base.atFlags &= ~AT_ON; + if (this->unk_2AC < 0.5f) { + this->actor.flags &= ~0x10; + func_80AD7B18(this); + } + } else { + func_80AD76CC(this); + } + } + func_80AD7568(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8D64.s") +void func_80AD7B18(EnKame* this) { + this->actor.draw = EnKame_Draw; + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0031DC, -3.0f); + this->actor.speedXZ = 0.0f; + this->unk_2AC = 0.1f; + this->unk_2A8 = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80AD7B90; +} + +void func_80AD7B90(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD71B4(this); + } else if (this->skelAnime1.curFrame > 7.0f) { + this->unk_2AC = 1.5f - ((this->skelAnime1.curFrame - 7.0f) * (1.0f / 6)); + this->unk_2A8 = 1.5f - ((this->skelAnime1.curFrame - 7.0f) * (1.0f / 6)); + } else { + f32 frame = this->skelAnime1.curFrame; + + this->unk_2AC = (0.2f * frame) + 0.1f; + this->unk_2A8 = ((1.0f / 14) * frame) + 1.0f; + } +} + +void func_80AD7C54(EnKame* this) { + if (this->actionFunc == func_80AD7E0C) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0035EC, -3.0f); + this->unk_29E = 1; + this->collider.info.bumper.dmgFlags &= ~0x8000; + } else { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0039C0, -3.0f); + this->unk_29E = 0; + this->collider.info.bumper.dmgFlags |= 0x8000; + } + + this->actor.draw = EnKame_Draw; + this->actor.speedXZ = 0.0f; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + this->actor.flags &= ~0x10; + this->actor.shape.rot.z = 0; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_REVERSE); + this->actionFunc = func_80AD7D40; +} + +void func_80AD7D40(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + if (this->unk_29E == 1) { + func_80AD71B4(this); + } else { + this->unk_29E = 200; + func_80AD7DA4(this); + } + } +} + +void func_80AD7DA4(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0027D8, -3.0f); + this->collider.base.acFlags |= AC_ON; + this->collider.base.acFlags &= ~AC_HARD; + this->collider.base.colType = COLTYPE_HIT6; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD7E0C; +} + +void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29E > 0) { + this->unk_29E--; + if (SkelAnime_Update(&this->skelAnime1)) { + if (Rand_ZeroOne() > 0.5f) { + Animation_PlayOnce(&this->skelAnime1, &object_tl_Anim_0027D8); + } else { + Animation_PlayOnce(&this->skelAnime1, &object_tl_Anim_002F88); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_ROAR); + } + } + } else { + func_80AD7EC0(this); + } +} + +void func_80AD7EC0(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_002510, -3.0f); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_WAKEUP); + this->actionFunc = func_80AD7F10; +} + +void func_80AD7F10(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + this->actor.shape.shadowDraw = func_800B3FC0; + func_80AD71B4(this); + } else if (this->skelAnime1.curFrame >= 10.0f) { + this->actor.shape.shadowDraw = NULL; + this->collider.base.acFlags &= ~AC_ON; + this->collider.info.bumper.dmgFlags &= ~0x8000; + } +} + +void func_80AD7FA4(EnKame* 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_80AD7FF8; +} + +void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_2A2 != 0) { + this->unk_2A2--; + } + + if (this->unk_2A2 == 0) { + func_80AD7018(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80AD8148(this, NULL); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80AD7DA4(this); + } + } +} + +void func_80AD8060(EnKame* this) { + s16 sp36 = Animation_GetLastFrame(&object_tl_Anim_0008B4); + + Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, 2, -3.0f); + func_800BCB70(&this->actor, 0x4000, 255, 0, sp36); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_DAMAGE); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_80AD810C; +} + +void func_80AD810C(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD7DA4(this); + } +} + +void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { + Animation_PlayLoop(&this->skelAnime1, &object_tl_Anim_000AF4); + func_800BCB70(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.atFlags &= ~(AC_HARD | AC_HIT); + this->actor.velocity.y = 15.0f; + this->actor.speedXZ = 1.5f; + if (globalCtx != NULL) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + if (this->actor.draw == func_80AD8D64) { + this->actor.draw = EnKame_Draw; + } else { + func_800BE504(&this->actor, &this->collider); + } + } + this->actor.bgCheckFlags &= ~0x1; + this->actor.flags &= ~0x1; + this->actor.flags |= 0x10; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PAMET_DEAD); + this->unk_29E = 0; + this->actionFunc = func_80AD825C; +} + +void func_80AD825C(EnKame* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime1); + if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_HIPLOOP_LAND); + func_80AD8364(this); + } else { + if (this->unk_29E == 1) { + this->actor.colorFilterTimer = 100; + } else if (this->actor.colorFilterTimer == 0) { + func_800BCB70(&this->actor, 0xC000, 255, 0, 100); + } + this->actor.shape.rot.x += Rand_S16Offset(0x700, 0x1400); + this->actor.shape.rot.y += (s16)Rand_ZeroFloat(5120.0f); + this->actor.shape.rot.z += Rand_S16Offset(0x700, 0x1400); + } +} + +void func_80AD8364(EnKame* this) { + this->unk_29E = 20; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD8388; +} + +void func_80AD8388(EnKame* this, GlobalContext* globalCtx) { + Vec3f sp34; + + SkelAnime_Update(&this->skelAnime1); + this->actor.colorFilterTimer = 100; + if (this->unk_29E > 0) { + this->unk_29E--; + if (this->unk_29E == 0) { + func_800F0590(globalCtx, &this->actor.world.pos, 21, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } + } else { + this->actor.scale.x -= 0.001f; + if (this->actor.scale.x <= 0.0f) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } + sp34.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x; + sp34.y = this->actor.world.pos.y + 15.0f; + sp34.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z; + func_800B3030(globalCtx, &sp34, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); + } +} + +void func_80AD84C0(EnKame* 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_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + return; + } + + func_80AD7018(this, globalCtx); + if (this->actor.colChkInfo.damageEffect == 13) { + return; + } + + if (this->actor.colChkInfo.damageEffect == 14) { + func_80AD8148(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == 15) { + if (this->collider.base.acFlags & AC_HARD) { + func_80AD7C54(this); + } else if (!Actor_ApplyDamage(&this->actor)) { + func_80AD8148(this, globalCtx); + } else { + func_80AD8060(this); + } + } else if ((this->actionFunc == func_80AD70EC) || (this->actionFunc == func_80AD7254)) { + func_80AD73A8(this); + this->unk_29E = 21; + } else if (!(this->collider.base.acFlags & AC_HARD)) { + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2A2 = 40; + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2B4 = 0.6f; + this->unk_2B0 = 2.0f; + this->unk_29D = 30; + func_80AD7FA4(this); + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2A2 = 40; + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80AD7FA4(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_80AD6F9C(this); + if (!Actor_ApplyDamage(&this->actor)) { + this->unk_2A2 = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_80AD7FA4(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2B4 = 0.6f; + this->unk_2B0 = 4.0f; + this->unk_29D = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2B4 = 0.6f; + this->unk_2B0 = 4.0f; + this->unk_29D = 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_LARGE_LIGHT_RAYS); + } + + if (!Actor_ApplyDamage(&this->actor)) { + func_80AD8148(this, globalCtx); + } else { + func_80AD8060(this); + } + } + } + } + + if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < 40000.0f) && + (this->collider.base.acFlags & AC_ON)) { + func_80AD7018(this, globalCtx); + func_80AD7C54(this); + } +} + +void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKame* this = THIS; + + func_80AD6F34(this); + + if (this->unk_2A0 != 0) { + this->unk_2A0--; + } + + func_80AD84C0(this, globalCtx); + + if ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_BOUNCED)) { + this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + func_80AD76CC(this); + if (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f) { + this->collider.base.atFlags &= ~AT_ON; + } + this->unk_2A6 = 0x3B00; + func_80AD7568(this); + } + + this->actionFunc(this, globalCtx); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 60.0f, 40.0f, 0x1F); + + if (this->actor.shape.shadowDraw != NULL) { + Actor_SetHeight(&this->actor, 25.0f); + Collider_UpdateCylinder(&this->actor, &this->collider); + } + + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + 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_2B0 > 0.0f) { + if (this->unk_29D != 10) { + Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); + this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; + if (this->unk_2B4 > 0.6f) { + this->unk_2B4 = 0.6f; + } else { + this->unk_2B4 = this->unk_2B4; + } + } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 func_80AD8A48(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKame* this = THIS; + + if ((this->actionFunc == func_80AD7424) || (this->actionFunc == func_80AD7B90)) { + if (limbIndex == 2) { + Matrix_Scale(this->unk_2A8, this->unk_2AC, this->unk_2A8, MTXMODE_APPLY); + } else if ((limbIndex == 11) || (limbIndex == 9) || (limbIndex == 7) || (limbIndex == 5)) { + Matrix_Scale(this->unk_2A8, this->unk_2AC, this->unk_2AC, MTXMODE_APPLY); + } + } + return false; +} + +void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80AD8E68[] = { + { 1500.0f, 0.0f, -2000.0f }, { 1500.0f, 0.0f, 2000.0f }, { 1500.0f, 2000.0f, 0.0f }, + { 1500.0f, -2000.0f, 0.0f }, { 2500.0f, 0.0f, 0.0f }, + }; + static s8 D_80AD8EA4[] = { -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, 3, -1, 4 }; + EnKame* this = THIS; + + if (D_80AD8EA4[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + } + + if (limbIndex == 1) { + s32 i; + Vec3f* ptr; + Vec3f* ptr2; + + if (this->actor.shape.shadowDraw == NULL) { + Matrix_GetStateTranslation(&this->actor.world.pos); + } + + ptr2 = D_80AD8E68; + ptr = &this->unk_2C8[5]; + for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { + Matrix_MultiplyVector3fByState(ptr2, ptr); + ptr2++; + ptr++; + } + } +} + +void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; + Vec3f sp40; + + if (this->actor.shape.shadowDraw == 0) { + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_80AD8E34[this->unk_29C]); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, + this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, + this->unk_29D); + + if (this->actor.shape.shadowDraw == NULL) { + func_800B3FC0(&this->actor, NULL, globalCtx); + Actor_SetHeight(&this->actor, 25.0f); + Collider_UpdateCylinder(&this->actor, &this->collider); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Enkame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnKame* this = THIS; + + if (limbIndex == 1) { + pos->y -= 700.0f; + } + + if ((this->unk_2AC != 1.0f) && (limbIndex == 3)) { + Matrix_Scale(1.0f, this->unk_2AC, this->unk_2AC, MTXMODE_APPLY); + } + return false; +} + +void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime2.skeleton, this->skelAnime2.jointTable, + this->skelAnime2.dListCount, Enkame_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index efdff38123..115bf137fd 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -9,9 +9,28 @@ typedef void (*EnKameActionFunc)(struct EnKame*, GlobalContext*); typedef struct EnKame { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x154]; + /* 0x0144 */ SkelAnime skelAnime1; + /* 0x0188 */ Vec3s jointTable1[13]; + /* 0x01D6 */ Vec3s morphTable1[13]; + /* 0x0224 */ SkelAnime skelAnime2; + /* 0x0268 */ Vec3s jointTable2[4]; + /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; - /* 0x029C */ char unk_29C[0xF0]; + /* 0x029C */ u8 unk_29C; + /* 0x029D */ u8 unk_29D; + /* 0x029E */ s16 unk_29E; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ f32 unk_2A8; + /* 0x02AC */ f32 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ Vec3f unk_2BC; + /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C extern const ActorInit En_Kame_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 91d765e04b..ef8f7630c3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12276,7 +12276,7 @@ 0x80AD8A48:("func_80AD8A48",), 0x80AD8AF8:("func_80AD8AF8",), 0x80AD8BC0:("EnKame_Draw",), - 0x80AD8CEC:("func_80AD8CEC",), + 0x80AD8CEC:("Enkame_OverrideLimbDraw",), 0x80AD8D64:("func_80AD8D64",), 0x80AD9240:("func_80AD9240",), 0x80AD92FC:("func_80AD92FC",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 193d637c12..d968f9f5cb 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2663,23 +2663,6 @@ D_0600686C = 0x0600686C; D_060081A4 = 0x060081A4; D_06000214 = 0x06000214; -// ovl_En_Kame - -D_060008B4 = 0x060008B4; -D_06000AF4 = 0x06000AF4; -D_06000B30 = 0x06000B30; -D_06001A50 = 0x06001A50; -D_06001C68 = 0x06001C68; -D_06002510 = 0x06002510; -D_060027D8 = 0x060027D8; -D_06002F88 = 0x06002F88; -D_060031DC = 0x060031DC; -D_060035EC = 0x060035EC; -D_060039C0 = 0x060039C0; -D_06004210 = 0x06004210; -D_06007C70 = 0x06007C70; -D_0600823C = 0x0600823C; - // ovl_En_Kanban D_06000C30 = 0x06000C30;