diff --git a/include/functions.h b/include/functions.h index 0ccda1bc51..eac92c3208 100644 --- a/include/functions.h +++ b/include/functions.h @@ -912,9 +912,9 @@ u8 Actor_ApplyDamage(Actor* actor); // returns current health void func_800BE258(Actor* actor, UNK_PTR arg1); void func_800BE2B8(Actor* actor, ColliderJntSph* jntSphere); void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); -// void func_800BE3D0(void); +void func_800BE3D0(Actor* actor, s16 arg1, s16* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); -// void func_800BE568(void); +void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 arg2); // void func_800BE63C(void); void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 arg4, f32 arg5, f32 arg6, u8 mode); diff --git a/spec b/spec index c282c24e0a..c92c79741d 100644 --- a/spec +++ b/spec @@ -880,8 +880,7 @@ beginseg name "ovl_En_Tite" compress include "build/src/overlays/actors/ovl_En_Tite/z_en_tite.o" - include "build/data/ovl_En_Tite/ovl_En_Tite.data.o" - include "build/data/ovl_En_Tite/ovl_En_Tite.reloc.o" + include "build/src/overlays/actors/ovl_En_Tite/ovl_En_Tite_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 2108a5a8f5..ee88a7a315 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tite.c + * Overlay: ovl_En_Tite + * Description: Tektites + */ + #include "z_en_tite.h" #define FLAGS 0x00000205 @@ -9,7 +15,50 @@ void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTite_Update(Actor* thisx, GlobalContext* globalCtx); void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80893ED4(EnTite* this); +void func_80893F30(EnTite* this, GlobalContext* globalCtx); +void func_80893FD0(EnTite* this); +void func_80894024(EnTite* this, GlobalContext* globalCtx); +void func_8089408C(EnTite* this, GlobalContext* globalCtx); +void func_808942B4(EnTite* this, GlobalContext* globalCtx); +void func_80894414(EnTite* this); +void func_80894454(EnTite* this, GlobalContext* globalCtx); +void func_8089452C(EnTite* this, GlobalContext* globalCtx); +void func_808945B4(EnTite* this, GlobalContext* globalCtx); +void func_808945EC(EnTite* this); +void func_80894638(EnTite* this, GlobalContext* globalCtx); +void func_8089484C(EnTite* this); +void func_80894910(EnTite* this, GlobalContext* globalCtx); +void func_80894B2C(EnTite* this); +void func_80894BC8(EnTite* this, GlobalContext* globalCtx); +void func_80894E0C(EnTite* this, GlobalContext* globalCtx); +void func_80895020(EnTite* this, GlobalContext* globalCtx); +void func_808951B8(EnTite* this, GlobalContext* globalCtx); +void func_80895424(EnTite* this, GlobalContext* globalCtx); +void func_808955E4(EnTite* this); +void func_80895640(EnTite* this, GlobalContext* globalCtx); +void func_808956B8(EnTite* this); +void func_80895738(EnTite* this, GlobalContext* globalCtx); +void func_80895A10(EnTite* this); +void func_80895AC0(EnTite* this, GlobalContext* globalCtx); +void func_80895CB0(EnTite* this); +void func_80895D08(EnTite* this, GlobalContext* globalCtx); +void func_80895E28(EnTite* this, GlobalContext* globalCtx); + +extern AnimationHeader D_060004F8; +extern AnimationHeader D_0600069C; +extern AnimationHeader D_0600083C; +extern AnimationHeader D_06000A14; +extern AnimationHeader D_06000C70; +extern AnimationHeader D_060012E4; +extern SkeletonHeader D_06003A20; +extern UNK_PTR D_06001300; +extern UNK_PTR D_06001700; +extern UNK_PTR D_06001900; +extern UNK_PTR D_06001B00; +extern UNK_PTR D_06001F00; +extern UNK_PTR D_06002100; + const ActorInit En_Tite_InitVars = { ACTOR_EN_TITE, ACTORCAT_ENEMY, @@ -22,15 +71,27 @@ const ActorInit En_Tite_InitVars = { (ActorFunc)EnTite_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80896AD0 = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 1500, 0 }, 20 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80896AFC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -65,129 +126,1066 @@ static DamageTable D_80896AFC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80896B1C = { 2, 40, 40, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 40, 40, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80896B50[] = { +static UNK_PTR D_80896B24[2][3] = { + { &D_06001300, &D_06001700, &D_06001900 }, + { &D_06001B00, &D_06001F00, &D_06002100 }, +}; + +static Color_RGBA8 D_80896B3C = { 250, 250, 250, 255 }; +static Color_RGBA8 D_80896B40 = { 180, 180, 180, 255 }; +static Vec3f D_80896B44 = { 0.0f, 0.45f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 70, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +static s32 D_80896B60 = 0; +static Vec3f D_80896B64 = { 0.0f, 0.3f, 0.0f }; -extern ColliderSphereInit D_80896AD0; -extern DamageTable D_80896AFC; -extern CollisionCheckInfoInit D_80896B1C; -extern InitChainEntry D_80896B50[]; +void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; + s32 i; + s32 j; -extern UNK_TYPE D_060004F8; -extern UNK_TYPE D_0600069C; -extern UNK_TYPE D_0600083C; -extern UNK_TYPE D_06000A14; -extern UNK_TYPE D_06000C70; -extern UNK_TYPE D_060012E4; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_06003A20, &D_060012E4, this->jointTable, this->morphTable, 25); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); + Actor_SetHeight(&this->actor, 20.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; + this->unk_2C0 = 0x1D; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Init.s") + if (!D_80896B60) { + for (i = 0; i < ARRAY_COUNT(D_80896B24); i++) { + for (j = 0; j < ARRAY_COUNT(D_80896B24[0]); j++) { + D_80896B24[i][j] = Lib_SegmentedToVirtual(D_80896B24[i][j]); + } + } + D_80896B60 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Destroy.s") + if (this->actor.params == ENTITE_MINUS_3) { + this->actor.params = ENTITE_MINUS_2; + this->unk_2BE = 240; + this->actor.flags &= ~1; + this->actor.shape.yOffset = -3000.0f; + this->actor.shape.shadowDraw = NULL; + func_80895A10(this); + } else { + if (this->actor.params == ENTITE_MINUS_4) { + this->actor.params = ENTITE_MINUS_2; + this->unk_2BE = 240; + } else if (this->actor.params == ENTITE_MINUS_2) { + this->unk_2BE = 128; + } else { + this->unk_2BE = 64; + } + func_80893ED4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893A18.s") + if (this->actor.params == ENTITE_MINUS_2) { + this->unk_2C0 |= 0x40; + this->actor.colChkInfo.health = 3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893A34.s") +void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893A9C.s") + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893ADC.s") +void func_80893A18(EnTite* this) { + this->collider.base.colType = COLTYPE_HIT6; + this->collider.base.acFlags &= ~AC_HARD; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893B10.s") +s32 func_80893A34(EnTite* this, GlobalContext* globalCtx) { + if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 1) && + (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 5)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893B70.s") +void func_80893A9C(EnTite* this, GlobalContext* globalCtx) { + if (func_80893A34(this, globalCtx)) { + func_808956B8(this); + } else { + func_80893FD0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893BCC.s") +s32 func_80893ADC(EnTite* this) { + if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 0x20)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893DD4.s") +s32 func_80893B10(EnTite* this) { + Math_StepToF(&this->actor.velocity.y, 0.0f, 2.0f); + return Math_StepToF(&this->actor.world.pos.y, (this->actor.world.pos.y + this->actor.yDistToWater) - 1.0f, 2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893E54.s") +void func_80893B70(EnTite* this) { + if (this->actor.params == ENTITE_MINUS_2) { + if (this->actor.bgCheckFlags & 0x20) { + this->actor.gravity = 0.0f; + func_80893B10(this); + } else { + this->actor.gravity = -1.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893ED4.s") +void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp7C; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893F30.s") + if (this->actor.bgCheckFlags & 2) { + u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893FD0.s") + if ((temp_v0 == 0) || (temp_v0 == 1)) { + for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); + } + } else if (temp_v0 == 14) { + Vec3f* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894024.s") + for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + for (j = 0; j < 2; j++) { + ptr = &this->unk_2D0[i]; + sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); + sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); + sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); + func_800B0DE0(globalCtx, &sp7C, &D_801D15B0, &D_80896B64, &D_80896B3C, &D_80896B40, + (s32)Rand_ZeroFloat(16.0f) + 80, 15); + } + } + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089408C.s") +void func_80893DD4(EnTite* this) { + this->unk_2BB = 10; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_2BC = 80; + this->unk_2C8 = 0.5f; + this->unk_2CC = 0.75f; + this->unk_2C4 = 1.0f; + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + this->actor.flags &= ~0x200; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808942B4.s") +void func_80893E54(EnTite* this, GlobalContext* globalCtx) { + if (this->unk_2BB == 10) { + this->unk_2BB = 0; + this->collider.base.colType = COLTYPE_HIT6; + this->unk_2C4 = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); + this->actor.flags |= 0x200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894414.s") +void func_80893ED4(EnTite* this) { + Animation_MorphToLoop(&this->skelAnime, &D_060012E4, 4.0f); + this->unk_2BC = Rand_S16Offset(15, 30); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80893F30; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894454.s") +void func_80893F30(EnTite* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + func_80893B70(this); + if (this->unk_2BC > 0) { + this->unk_2BC--; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.xzDistToPlayer < 300.0f) && + (this->actor.yDistToPlayer < 80.0f)) { + func_808945EC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089452C.s") +void func_80893FD0(EnTite* this) { + Animation_PlayOnce(&this->skelAnime, &D_0600083C); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80894024; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808945B4.s") +void func_80894024(EnTite* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + func_8089408C(this, globalCtx); + } else { + func_80893B70(this); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1000); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808945EC.s") +void func_8089408C(EnTite* this, GlobalContext* globalCtx) { + Animation_PlayOnce(&this->skelAnime, &D_060004F8); + if (!func_80893ADC(this)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + } else { + this->actor.world.pos.y += this->actor.yDistToWater; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894638.s") + if (this->actor.shape.yOffset < 0.0f) { + s32 i; + Vec3f sp70; + Vec3f sp64; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089484C.s") + sp64.y = 3.0f; + this->actor.shape.yOffset = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894910.s") + for (i = 0; i < 4; i++) { + sp64.x = 2.0f * Math_SinS(this->actor.shape.rot.y); + sp64.z = 2.0f * Math_CosS(this->actor.shape.rot.y); + sp70.x = this->actor.world.pos.x + (12.5f * sp64.x); + sp70.y = this->actor.world.pos.y + 15.0f; + sp70.z = this->actor.world.pos.z + (12.5f * sp64.z); + func_800B0DE0(globalCtx, &sp70, &sp64, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + this->actor.shape.rot.y += 0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894B2C.s") + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.flags |= 1; + this->actor.velocity.y = 10.0f; + } else { + this->actor.velocity.y = 8.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894BC8.s") + this->actor.bgCheckFlags &= ~(0x40 | 0x20 | 0x2 | 0x1); + this->actor.gravity = -1.0f; + this->actor.speedXZ = 4.0f; + this->actionFunc = func_808942B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894DD0.s") +void func_808942B4(EnTite* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater > 0.0f))) && + (this->actor.velocity.y <= 0.0f)) { + this->actor.speedXZ = 0.0f; + this->collider.base.atFlags &= ~AT_HIT; + if (!func_80893ADC(this)) { + func_80893BCC(this, globalCtx); + func_80894414(this); + } else { + this->actor.gravity = 0.0f; + if (this->actor.velocity.y < -8.0f) { + func_8089452C(this, globalCtx); + } else { + this->actor.velocity.y = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + func_80894414(this); + } + } + } else if (!(this->collider.base.atFlags & AT_HIT)) { + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.atFlags &= ~AT_HIT; + func_80894B2C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894E0C.s") +void func_80894414(EnTite* this) { + Animation_PlayOnce(&this->skelAnime, &D_0600069C); + this->actionFunc = func_80894454; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895020.s") +void func_80894454(EnTite* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + func_808945EC(this); + } else { + func_80893A9C(this, globalCtx); + } + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1500); + func_80893B70(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808951B8.s") +void func_8089452C(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808952EC.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + sp2C.y += this->actor.yDistToWater; + this->actor.velocity.y *= 0.75f; + EffectSsGRipple_Spawn(globalCtx, &sp2C, 0, 500, 0); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + this->actionFunc = func_808945B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895424.s") +void func_808945B4(EnTite* this, GlobalContext* globalCtx) { + if (func_80893B10(this)) { + func_80894414(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808955E4.s") +void func_808945EC(EnTite* this) { + Animation_PlayLoop(&this->skelAnime, &D_06000A14); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80894638; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895640.s") +void func_80894638(EnTite* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808956B8.s") + func_80893B70(this); + temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (temp_v0 > 0) { + temp_v1 = (s32)(temp_v0 * (1.0f / 42.0f)) + 10; + } else { + temp_v1 = (s32)(temp_v0 * (1.0f / 42.0f)) - 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808956FC.s") + this->actor.shape.rot.y = this->actor.shape.rot.y + (temp_v1 * 2); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->skelAnime.playSpeed = temp_v1 * 0.01f; + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895738.s") + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + if (func_80893ADC(this)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK_WATER); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089595C.s") + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater < 10.0f))) && + Actor_IsActorFacingLink(&this->actor, 0xE38)) { + if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { + func_80893A9C(this, globalCtx); + } else { + func_8089484C(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895A10.s") +void func_8089484C(EnTite* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000C70, -3.0f); + if (this->actionFunc != func_80894910) { + this->unk_2B8 = Rand_S16Offset(1, 3); + } + this->actor.velocity.y = 9.5f; + this->actor.gravity = -1.0f; + this->actor.speedXZ = 4.0f; + if (func_80893ADC(this)) { + this->actor.world.pos.y += this->actor.yDistToWater; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + } + this->actionFunc = func_80894910; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895AC0.s") +void func_80894910(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895CB0.s") + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); + SkelAnime_Update(&this->skelAnime); + if (this->actor.bgCheckFlags & 0x40) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895D08.s") + if (func_80893ADC(this)) { + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y += this->actor.yDistToWater; + this->actor.velocity.y *= 0.75f; + EffectSsGRipple_Spawn(globalCtx, &sp34, 0, 500, 0); + } + } else { + func_80893BCC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895DE8.s") + if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater > 0.0f))) && + (this->actor.velocity.y <= 0.0f)) { + this->actor.speedXZ = 0.0f; + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4000); + this->actor.world.rot.y = this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895E28.s") + if (func_80893ADC(this)) { + this->actor.gravity = 0.0f; + if (!func_80893B10(this)) { + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895FF8.s") + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { + func_808945EC(this); + } else { + func_8089484C(this); + } + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1000); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808963B4.s") +void func_80894B2C(EnTite* this) { + Animation_MorphToLoop(&this->skelAnime, &D_060012E4, 4.0f); + this->actor.speedXZ = -6.0f; + this->actor.gravity = -1.0f; + if (this->collider.base.ac != NULL) { + func_800BE568(&this->actor, &this->collider); + } else { + this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); + } + this->actor.world.rot.y += 0x8000; + this->actionFunc = func_80894BC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Update.s") +void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + SkelAnime_Update(&this->skelAnime); + if (func_80893ADC(this) && (this->actor.velocity.y <= 0.0f)) { + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.yDistToWater - 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80896750.s") + if (this->actor.bgCheckFlags & 0x40) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + } else { + func_80893BCC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80896788.s") + if ((this->actor.speedXZ == 0.0f) && ((this->actor.bgCheckFlags & 1) || func_80893ADC(this))) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->collider.base.acFlags |= AC_ON; + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || + (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.yDistToPlayer > 80.0f)) && + (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { + func_80893ED4(this); + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && + Actor_IsActorFacingLink(&this->actor, 0x1770)) { + func_80893A9C(this, globalCtx); + } else { + func_8089484C(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Draw.s") +void func_80894DD0(EnTite* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80894E0C; +} + +void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { + if (this->unk_2BC != 0) { + this->unk_2BC--; + } + + if ((func_80893ADC(this) != 0) && (this->actor.velocity.y <= 0.0f)) { + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.yDistToWater; + } + + if (this->actor.bgCheckFlags & 0x40) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + } else { + func_80893BCC(this, globalCtx); + } + + if (this->unk_2BC == 0) { + func_80893E54(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80895020(this, globalCtx); + } else if (this->unk_2B9 != 0) { + func_808955E4(this); + } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || + (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.yDistToPlayer > 80.0f)) && + (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { + func_80893ED4(this); + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && + Actor_IsActorFacingLink(&this->actor, 0x1770)) { + func_80893A9C(this, globalCtx); + } else { + func_8089484C(this); + } + } +} + +void func_80895020(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp74; + s32 i; + f32 temp_f0; + Vec3f* ptr; + + this->actor.speedXZ = 0.0f; + this->collider.base.acFlags &= ~AC_ON; + this->actor.colorFilterTimer = 0; + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); + this->actor.flags &= ~1; + this->actor.flags |= 0x10; + this->unk_2BA = 1; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, this->unk_2BE); + this->unk_2BC = 25; + this->actor.gravity = -0.58f; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + + ptr = &this->unk_33C[0]; + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + Math_Vec3f_Diff(&this->unk_2D0[i], &this->actor.world.pos, &sp74); + temp_f0 = Math3D_Vec3fMagnitude(&sp74); + if (temp_f0 > 1.0f) { + temp_f0 = 1.2f / temp_f0; + } + + ptr->x = sp74.x * temp_f0; + ptr->z = sp74.z * temp_f0; + ptr->y = Rand_ZeroFloat(3.5f) + 5.5f; + } + this->actionFunc = func_808951B8; +} + +void func_808951B8(EnTite* this, GlobalContext* globalCtx) { + s32 i; + + this->unk_2BC--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->unk_2BC == 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + func_800B3030(globalCtx, &this->unk_2D0[i], &D_801D15B0, &D_801D15B0, 40, 7, 1); + Audio_PlaySoundAtPosition(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + } + Actor_MarkForDeath(&this->actor); + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { + Math_Vec3f_Sum(&this->unk_2D0[i], &this->unk_33C[i], &this->unk_2D0[i]); + this->unk_33C[i].y += this->actor.gravity; + } + } +} + +void func_808952EC(EnTite* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &D_06000A14, 1.5f); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + this->collider.base.acFlags &= ~AC_ON; + func_80893A18(this); + this->unk_2B9 = 1; + this->unk_2BC = 400; + this->actor.speedXZ = 0.0f; + this->actor.gravity = -1.0f; + this->unk_2B8 = Rand_ZeroOne() * 50.0f; + this->actor.bgCheckFlags &= ~1; + this->actor.velocity.y = 11.0f; + this->actionFunc = func_80895424; +} + +void func_80895424(EnTite* this, GlobalContext* globalCtx) { + Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 4000); + if (this->unk_2B8 != 0) { + this->unk_2B8--; + } else { + this->unk_2B8 = Rand_ZeroOne() * 30.0f; + this->skelAnime.curFrame = Rand_ZeroOne() * 5.0f; + } + + SkelAnime_Update(&this->skelAnime); + + if (this->actor.bgCheckFlags & 1) { + this->collider.base.acFlags |= AC_ON; + if (this->actor.bgCheckFlags & 2) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + if (this->unk_2BC == 0) { + func_808955E4(this); + } else { + this->unk_2BC--; + } + } else if (this->actor.shape.yOffset < 2800.0f) { + this->actor.shape.yOffset += 400.0f; + } +} + +void func_808955E4(EnTite* this) { + this->unk_2B9 = 0; + this->actor.velocity.y = 13.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + this->actor.bgCheckFlags &= ~1; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_80895640; +} + +void func_80895640(EnTite* this, GlobalContext* globalCtx) { + Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 4000); + SkelAnime_Update(&this->skelAnime); + if (this->actor.bgCheckFlags & 1) { + this->collider.base.acFlags |= AC_ON; + this->actor.shape.yOffset = 0.0f; + func_80893BCC(this, globalCtx); + func_80893ED4(this); + } +} + +void func_808956B8(EnTite* this) { + this->unk_2BC = 400; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->collider.base.colType = COLTYPE_HARD; + this->collider.base.acFlags |= AC_HARD; + this->actor.gravity = -1.0f; + this->actionFunc = func_80895738; +} + +void func_808956FC(EnTite* this) { + this->unk_2BC = -1; + this->actor.bgCheckFlags &= ~1; + this->actor.velocity.y = 7.5f; + func_80893A18(this); +} + +void func_80895738(EnTite* this, GlobalContext* globalCtx) { + func_80893BCC(this, globalCtx); + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); + if (this->collider.base.atFlags & AT_BOUNCED) { + func_808956FC(this); + } + } else if (this->actor.bgCheckFlags & 8) { + this->actor.world.rot.y = BINANG_SUB((this->actor.wallYaw * 2) - this->actor.world.rot.y, 0x8000); + } + + if (this->unk_2BC == -1) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f); + if (this->actor.bgCheckFlags & 1) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80893ED4(this); + this->unk_2BC = 100; + } + } else if (this->unk_2BC > 0) { + this->unk_2BC--; + Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (!func_80893A34(this, globalCtx)) { + this->unk_2BC = 0; + } + } else if ((this->unk_2BC == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80893A18(this); + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + func_808945EC(this); + } else { + func_80893A9C(this, globalCtx); + } + } + this->actor.shape.rot.y += (s16)(this->actor.speedXZ * 768.0f); +} + +void func_8089595C(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + sp2C.x = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.x; + sp2C.y = this->actor.world.pos.y + 15.0f; + sp2C.z = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &sp2C, &D_801D15B0, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); +} + +void func_80895A10(EnTite* this) { + s32 pad; + s16 rand; + + Animation_Change(&this->skelAnime, &D_06000A14, 2.0f, 0.0f, 0.0f, 0, 4.0f); + this->actor.speedXZ = 0.0f; + rand = Rand_S16Offset(20, 20); + this->unk_2BC = ((Rand_ZeroOne() < 0.5f) ? -1 : 1) * rand; + this->actionFunc = func_80895AC0; +} + +void func_80895AC0(EnTite* this, GlobalContext* globalCtx) { + s16 temp_v1; + s32 temp_v0; + + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + if (Rand_ZeroOne() < 0.25f) { + func_8089595C(this, globalCtx); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + } + + if ((this->unk_2BC == 1) || (this->unk_2BC == -1)) { + if (this->actor.bgCheckFlags & 8) { + temp_v1 = this->actor.shape.rot.y - this->actor.wallYaw; + temp_v0 = ABS_ALT(temp_v1); + if (temp_v0 > 0x3000) { + this->unk_2BC = (temp_v0 >> 9) * this->unk_2BC; + } + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { + temp_v1 = this->actor.shape.rot.y - Actor_YawToPoint(&this->actor, &this->actor.home.pos); + temp_v0 = ABS_ALT(temp_v1); + if (temp_v0 > 0x2000) { + this->unk_2BC = (temp_v0 >> 9) * this->unk_2BC; + } + } + } + + if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + func_8089408C(this, globalCtx); + } else if (this->unk_2BC > 0) { + this->unk_2BC--; + this->actor.shape.rot.y += 0x100; + } else if (this->unk_2BC < 0) { + this->unk_2BC++; + this->actor.shape.rot.y -= 0x100; + } else { + func_80895CB0(this); + } +} + +void func_80895CB0(EnTite* this) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_2BC = Rand_S16Offset(20, 20); + this->actionFunc = func_80895D08; +} + +void func_80895D08(EnTite* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + if (Rand_ZeroOne() < 0.5f) { + func_8089595C(this, globalCtx); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + } + if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + func_8089408C(this, globalCtx); + } else { + this->unk_2BC--; + if (this->unk_2BC == 0) { + func_80895A10(this); + } + } +} + +void func_80895DE8(EnTite* this) { + this->collider.base.acFlags &= ~AC_ON; + this->actor.shape.shadowDraw = func_800B3FC0; + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80895E28; +} + +void func_80895E28(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp44; + Vec3f sp38; + s16 sp36; + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y += 0x1E00; + + sp44.x = (Math_SinS(this->actor.shape.rot.y) * 25.0f) + this->actor.world.pos.x; + sp44.y = this->actor.world.pos.y + 15.0f; + sp44.z = (Math_CosS(this->actor.shape.rot.y) * 25.0f) + this->actor.world.pos.z; + + sp36 = BINANG_SUB(this->actor.shape.rot.y, 0x4000); + + sp38.x = 2.0f * Math_SinS(sp36); + sp38.y = 3.0f; + sp38.z = 2.0f * Math_CosS(sp36); + + func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + + sp44.x = (2.0f * this->actor.world.pos.x) - sp44.x; + sp44.z = (2.0f * this->actor.world.pos.z) - sp44.z; + sp38.x *= -1.0f; + sp38.z *= -1.0f; + + func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + + if (Math_StepToF(&this->actor.shape.yOffset, 0.0f, 200.0f)) { + this->actor.flags |= 1; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->collider.base.acFlags |= AC_ON; + func_808945EC(this); + } +} + +void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~AT_HIT; + if (this->collider.base.colType == COLTYPE_HARD) { + func_808956FC(this); + func_800BE568(&this->actor, &this->collider); + return; + } + + func_800BE258(&this->actor, &this->collider.info); + + if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + func_80893E54(this, globalCtx); + if (this->actor.shape.yOffset < 0.0f) { + func_80895DE8(this); + return; + } + + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect != 0xF) { + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2BC = 40; + func_800BCB70(&this->actor, 0, 200, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2BB = 32; + this->unk_2C8 = 0.5f; + this->unk_2C4 = 2.0f; + func_80894DD0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2BC = 40; + func_800BCB70(&this->actor, 0, 200, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80894DD0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 3) { + func_80893DD4(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_2BC = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_80894DD0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2BB = 0; + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2BB = 0x14; + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.5f; + 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); + } + + func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + + if (this->actor.colChkInfo.health == 0) { + func_80895020(this, globalCtx); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_DAMAGE); + + if (this->unk_2B9 == 0) { + func_80894B2C(this); + this->collider.base.acFlags &= ~AC_ON; + } else { + func_808955E4(this); + } + } + } + } + } else if ((this->actor.bgCheckFlags & 1) && (this->collider.base.acFlags & AC_ON) && + (this->actor.colChkInfo.health != 0) && (globalCtx->actorCtx.unk2 != 0) && + (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { + this->actor.flags |= 1; + if (this->actor.shape.yOffset < 0.0f) { + this->actor.shape.yOffset = 0.0f; + this->actor.shape.shadowDraw = func_800B3FC0; + } + if (this->unk_2B9 != 0) { + func_808955E4(this); + } else { + func_808952EC(this); + } + } +} + +void func_808963B4(EnTite* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp48; + + if (this->actor.bgCheckFlags & 0x40) { + for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); + sp48.y = this->actor.world.pos.y + this->actor.yDistToWater; + EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); + } + } else if (this->actor.bgCheckFlags & 0x20) { + s32 temp = globalCtx->gameplayFrames & 7; + + if (!(temp & 1) && (this->actor.yDistToWater < 10.0f)) { + Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); + sp48.y = this->actor.world.pos.y + this->actor.yDistToWater; + EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); + } + } +} + +void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; + + func_80895FF8(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_808951B8) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); + func_808963B4(this, globalCtx); + if (this->actor.bgCheckFlags & 1) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot.x); + if (this->unk_2B9 != 0) { + this->actor.shape.rot.z = BINANG_ROT180(this->actor.shape.rot.z); + } + } else { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 1000); + if (this->unk_2B9 == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 1000); + if (this->actor.shape.yOffset > 0.0f) { + this->actor.shape.yOffset -= 400.0f; + } + } + } + + Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 15; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + + 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_2C4 > 0.0f) { + if (this->unk_2BB != 10) { + Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); + this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.25f; + this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.5f); + } else if (!Math_StepToF(&this->unk_2CC, 0.5f, 0.0125f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnTite_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnTite* this = THIS; + + if (this->unk_2BA == -1) { + this->unk_3A8 = *dList; + *dList = NULL; + } + return false; +} + +void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static s8 D_80896B70[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, -1, -1, -1, 3, -1, -1, -1, -1, 4, -1, + }; + static s8 D_80896B8C[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, -1, -1, -1, 2, 6, -1, -1, -1, 3, 7, -1, -1, -1, 4, 8, + }; + EnTite* this = THIS; + MtxF* matrix; + s8 idx; + + if (this->unk_2BA == 0) { + idx = D_80896B70[limbIndex]; + if (idx != -1) { + Matrix_GetStateTranslation(&this->unk_2D0[idx]); + if (idx >= 1) { + Matrix_GetStateTranslationAndScaledX(2500.0f, &this->unk_2D0[idx + 4]); + } + } + } else if (this->unk_2BA > 0) { + if (D_80896B8C[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2D0[D_80896B8C[limbIndex]]); + } + + if (limbIndex == 24) { + this->unk_2BA = -1; + } + } else if (D_80896B8C[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + matrix = Matrix_GetCurrentState(); + matrix->wx = this->unk_2D0[D_80896B8C[limbIndex]].x; + matrix->wy = this->unk_2D0[D_80896B8C[limbIndex]].y; + matrix->wz = this->unk_2D0[D_80896B8C[limbIndex]].z; + Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_3A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + + if (this->actor.params == ENTITE_MINUS_2) { + gSPSegment(&gfx[1], 0x08, D_80896B24[0][0]); + gSPSegment(&gfx[2], 0x09, D_80896B24[0][1]); + gSPSegment(&gfx[3], 0x0A, D_80896B24[0][2]); + } else { + gSPSegment(&gfx[1], 0x08, D_80896B24[1][0]); + gSPSegment(&gfx[2], 0x09, D_80896B24[1][1]); + gSPSegment(&gfx[3], 0x0A, D_80896B24[1][2]); + } + + POLY_OPA_DISP = &gfx[4]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, + EnTite_PostLimbDraw, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), this->unk_2C8, this->unk_2CC, + this->unk_2C4, this->unk_2BB); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index cf69394255..91bbfc7c2d 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -7,11 +7,34 @@ struct EnTite; typedef void (*EnTiteActionFunc)(struct EnTite*, GlobalContext*); +enum { + /* -4 */ ENTITE_MINUS_4 = -4, + /* -3 */ ENTITE_MINUS_3, + /* -2 */ ENTITE_MINUS_2, + /* -1 */ ENTITE_MINUS_1, + /* 0 */ ENTITE_MINUS_0, +}; + typedef struct EnTite { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x170]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[25]; + /* 0x021E */ Vec3s morphTable[25]; /* 0x02B4 */ EnTiteActionFunc actionFunc; - /* 0x02B8 */ char unk_2B8[0x14C]; + /* 0x02B8 */ u8 unk_2B8; + /* 0x02B9 */ u8 unk_2B9; + /* 0x02BA */ s8 unk_2BA; + /* 0x02BB */ u8 unk_2BB; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s32 unk_2C0; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ Vec3f unk_2D0[9]; + /* 0x033C */ Vec3f unk_33C[9]; + /* 0x03A8 */ Gfx* unk_3A8; + /* 0x03AC */ ColliderSphere collider; } EnTite; // size = 0x404 extern const ActorInit En_Tite_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ec3e89a90e..b1fb037ee9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5498,8 +5498,8 @@ 0x80895FF8:("func_80895FF8",), 0x808963B4:("func_808963B4",), 0x808964E8:("EnTite_Update",), - 0x80896750:("func_80896750",), - 0x80896788:("func_80896788",), + 0x80896750:("EnTite_OverrideLimbDraw",), + 0x80896788:("EnTite_PostLimbDraw",), 0x8089695C:("EnTite_Draw",), 0x80896F30:("EnPeehat_Init",), 0x808970F4:("EnPeehat_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d83bf24ed0..6f792044ad 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3618,6 +3618,12 @@ D_06000A14 = 0x06000A14; D_06000C70 = 0x06000C70; D_060012E4 = 0x060012E4; D_06003A20 = 0x06003A20; +D_06001300 = 0x06001300; +D_06001700 = 0x06001700; +D_06001900 = 0x06001900; +D_06001B00 = 0x06001B00; +D_06001F00 = 0x06001F00; +D_06002100 = 0x06002100; // ovl_En_Tk