From 837eb1c80687fe9b57a3c7b841547c33feeed6c7 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 20 Nov 2021 15:10:37 +0000 Subject: [PATCH] En_Tk (#338) * En_Tk * PR * Warnings Co-authored-by: root --- include/functions.h | 8 +- include/z64.h | 2 +- spec | 4 +- src/code/z_en_item00.c | 2 +- .../ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h | 7 +- src/overlays/actors/ovl_En_Door/z_en_door.h | 2 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 2 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 2 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 4 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 2 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 1361 ++++++++++++++++- src/overlays/actors/ovl_En_Tk/z_en_tk.h | 53 +- undefined_syms.txt | 9 + 15 files changed, 1374 insertions(+), 88 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2c64cc9ca..231056fc8 100644 --- a/include/functions.h +++ b/include/functions.h @@ -970,7 +970,7 @@ f32 func_800C3D50(s32 arg0, CollisionContext* colCtx, s32 arg2, CollisionPoly** f32 func_800C3FA0(CollisionContext* colCtx, CollisionPoly** arg1, Vec3f* arg2); f32 func_800C4000(GlobalContext* globalCtx, CollisionContext* colCtx, s32* arg2, Vec3f* arg3); // void func_800C4058(void); -f32 func_800C40B4(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Vec3f* pos); +f32 func_800C40B4(CollisionContext* colCtx, CollisionPoly** poly, s32* arg2, Vec3f* arg3); f32 func_800C411C(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Actor* actor, Vec3f* pos); f32 func_800C4188(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); // void func_800C41E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -1002,7 +1002,7 @@ s32 func_800C576C(CollisionContext* colCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg // void func_800C58C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_800C5954(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8); s32 func_800C5A20(CollisionContext* colCtx, Vec3f* arg1, f32 arg2); -s32 func_800C5A64(CollisionContext* colCtx, Vec3f* arg1, f32 arg2, Actor* actor); +s32 func_800C5A64(CollisionContext* colCtx, Vec3f* arg1, f32 arg2); void BgCheck_ScenePolygonListsInit(SSNodeList* arg0); void BgCheck_ScenePolygonListsAlloc(GlobalContext* globalCtx, SSNodeList* lists, s32 numNodes, u32 numPolygons); s32 func_800C5B80(u16* arg0); @@ -1079,7 +1079,7 @@ u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); u32 func_800C9B40(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); u32 func_800C9B68(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); u32 func_800C9B90(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); +s32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); u32 func_800C9BDC(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); // u32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* polygon, s32 index, UNK_TYPE4 param_4); u32 func_800C9C74(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); @@ -1774,7 +1774,7 @@ u32 func_800FE4B8(GlobalContext* globalCtx); // void func_800FE590(void); // void func_800FE5D0(void); // UNK_TYPE4 func_800FE610(void); -s32 func_800FE620(GlobalContext* globalCtx); +u32 func_800FE620(GlobalContext* globalCtx); void func_800FE658(f32 arg0); // UNK_TYPE4 func_800FE6F8(UNK_TYPE4 param_1, s16 param_2, s16 param_3); // void func_800FE778(void); diff --git a/include/z64.h b/include/z64.h index e1dda2fb5..408193610 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1339,7 +1339,7 @@ struct TargetContext { /* 0x50 */ TargetContextEntry unk50[3]; /* 0x8C */ Actor* unk8C; /* 0x90 */ Actor* unk90; - /* 0x94 */ UNK_TYPE1 pad94[0x4]; + /* 0x94 */ Actor* unk_94; }; // size = 0x98 struct s800B948C { diff --git a/spec b/spec index 7e17eeefd..ef82b6573 100644 --- a/spec +++ b/spec @@ -3756,9 +3756,7 @@ beginseg name "ovl_En_Tk" compress include "build/src/overlays/actors/ovl_En_Tk/z_en_tk.o" - include "build/data/ovl_En_Tk/ovl_En_Tk.data.o" - include "build/data/ovl_En_Tk/ovl_En_Tk.bss.o" - include "build/data/ovl_En_Tk/ovl_En_Tk.reloc.o" + include "build/src/overlays/actors/ovl_En_Tk/ovl_En_Tk_reloc.o" endseg beginseg diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 00d5be638..acd827f8e 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -460,7 +460,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); - if (this->actor.floorHeight <= -32000.0f) { + if (this->actor.floorHeight <= BGCHECK_Y_MIN) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h index 297a01cd8..28dafc099 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h @@ -8,10 +8,11 @@ struct BgDanpeiMovebg; typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, GlobalContext*); typedef struct BgDanpeiMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgDanpeiMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x78]; + /* 0x0160 */ char unk_160[0x6C]; + /* 0x01CC */ u16 unk_1CC; + /* 0x01CE */ char unk_1CE[0xA]; } BgDanpeiMovebg; // size = 0x1D8 extern const ActorInit Bg_Danpei_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 08ec52be6..1dbc470dc 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -10,7 +10,7 @@ typedef void (*EnDoorActionFunc)(struct EnDoor*, GlobalContext*); typedef struct EnDoor { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x63]; - /* 0x01A7 */ s8 unk1A7; + /* 0x01A7 */ s8 unk_1A7; /* 0x01A8 */ char unk_1A8[0x20]; /* 0x01C8 */ EnDoorActionFunc actionFunc; } EnDoor; // size = 0x1CC diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index 6846bfb92..825f60cbe 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -268,7 +268,7 @@ s32 func_80B288E8(EnFish2* this, Vec3f vec, s32 arg2) { } s32 func_80B2899C(EnFish2* this, GlobalContext* globalCtx) { - if (func_800C5A64(&globalCtx->colCtx, &this->unk_2F4, this->unk_33C, &this->actor)) { + if (func_800C5A64(&globalCtx->colCtx, &this->unk_2F4, this->unk_33C)) { return true; } diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index b10894b16..09b5cb9ae 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1385,7 +1385,7 @@ s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 ar if ((actorIterator->id == ACTOR_EN_DOOR) && (actorIterator->update != NULL) && (actorIterator->room == this->actor.room) && Math3D_DistanceSquared(&actorIterator->world.pos, &this->actor.world.pos) < range) { - ((EnDoor*)actorIterator)->unk1A7 = arg3; + ((EnDoor*)actorIterator)->unk_1A7 = arg3; retVal = true; break; } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 129b1c94d..14ad82b2d 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -486,7 +486,7 @@ void func_80BD9338(EnPamera* this, GlobalContext* globalCtx) { func_80BD84F0(this, globalCtx); actor = this->actor.child; if ((actor != NULL) && (actor->id == ACTOR_EN_DOOR)) { - ((EnDoor*)actor)->unk1A7 = -0x32; + ((EnDoor*)actor)->unk_1A7 = -0x32; } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 8acba6f8a..b4f84e902 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -742,7 +742,7 @@ void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { EnPametfrog_SetupRunToSnapper(this); - } else if (this->actor.floorHeight == -32000.0f) { + } else if (this->actor.floorHeight == BGCHECK_Y_MIN) { yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 5.0f * Math_SinS(yaw); this->actor.world.pos.z += 5.0f * Math_CosS(yaw); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 62749bf09..2cf6b353f 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1417,9 +1417,9 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { if ((sp44 != NULL) && (sp44->actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { - sp44->unk1A7 = this->unk_260; + sp44->unk_1A7 = this->unk_260; } else { - sp44->unk1A7 = 0; + sp44->unk_1A7 = 0; } } this->unk_36E = CLAMP(this->unk_36E, 0, this->unk_36C); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index de55cbbca..10994fe10 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -703,7 +703,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg this->unk434 = sp44 - unkStruct->unk4; this->unk436 = unkStruct->unk8 - unkStruct->unk4; if (unkStruct->unk0 != 10 && unkStruct->unk0 != 11) { - sp48->unk1A7 = 0x4B; + sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); Math_Vec3f_Copy(&this->unk444, &sp2C); diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 6db72b074..0fd752c43 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -5,6 +5,8 @@ */ #include "z_en_tk.h" +#include "overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" #define FLAGS 0x00000009 @@ -15,20 +17,70 @@ void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTk_Update(Actor* thisx, GlobalContext* globalCtx); void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80AECA3C(EnTk* this, GlobalContext* globalCtx); void func_80AECA90(EnTk* this, GlobalContext* globalCtx); +void func_80AECB0C(EnTk* this, GlobalContext* globalCtx); void func_80AECB6C(EnTk* this, GlobalContext* globalCtx); +void func_80AECE0C(EnTk* this, GlobalContext* globalCtx); +s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx); +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); void func_80AED610(EnTk* this, GlobalContext* globalCtx); +void func_80AED898(EnTk* this, GlobalContext* globalCtx); void func_80AED940(EnTk* this, GlobalContext* globalCtx); void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx); +void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx); void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx); +void func_80AEDE10(EnTk* this, GlobalContext* globalCtx); void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx); +void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx); void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx); +void func_80AEE374(EnTk* this, GlobalContext* globalCtx); void func_80AEE414(EnTk* this, GlobalContext* globalCtx); +void func_80AEE478(EnTk* this, GlobalContext* globalCtx); void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx); +void func_80AEE650(EnTk* this, GlobalContext* globalCtx); void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx); +void func_80AEE784(EnTk* this, GlobalContext* globalCtx); void func_80AEE9B0(EnTk* this, GlobalContext* globalCtx); +void func_80AEEAD4(EnTk* this, GlobalContext* globalCtx); +void func_80AEEB88(EnTk* this, GlobalContext* globalCtx); +void func_80AEED38(EnTk* this, GlobalContext* globalCtx); +void func_80AEF048(EnTk* this, GlobalContext* globalCtx); +void func_80AEF094(EnTk* this, GlobalContext* globalCtx); +void func_80AEF15C(EnTk* this, GlobalContext* globalCtx); +void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx); +void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx); +void func_80AEF210(EnTk* this, GlobalContext* globalCtx); +void func_80AEF220(EnTk* this, GlobalContext* globalCtx); +void func_80AEF278(EnTk* this, GlobalContext* globalCtx); +void func_80AEF2C8(Actor* thisx, GlobalContext* globalCtx); +void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx); +void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); + +extern AnimationHeader D_06001144; +extern AnimationHeader D_06001FA8; +extern AnimationHeader D_060020C8; +extern AnimationHeader D_060030A4; +extern AnimationHeader D_06003724; +extern AnimationHeader D_06003B10; +extern AnimationHeader D_06003FB8; +extern UNK_PTR D_06004390; +extern UNK_PTR D_06004B90; +extern UNK_PTR D_06005390; +extern Gfx D_0600B530[]; +extern FlexSkeletonHeader D_0600B9E8; + +static s32 D_80AF0050; + +static u32 D_80AEF800[] = { + 0x03060012, + 0x00000105, + 0x0E060012, + 0x00010500, +}; -#if 0 const ActorInit En_Tk_InitVars = { ACTOR_EN_TK, ACTORCAT_NPC, @@ -41,130 +93,1307 @@ const ActorInit En_Tk_InitVars = { (ActorFunc)EnTk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AEF830 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 30, 52, 0, { 0, 0, 0 } }, }; -#endif +// part of the collider?? +static u32 D_80AEF85C[] = { + 0x00000000, + 0x00000000, + 0xFF000000, +}; -extern ColliderCylinderInit D_80AEF830; +static struct_80B8E1A8 D_80AEF868[] = { + { &D_06001FA8, 1.0f, 0, -10.0f }, { &D_06001FA8, 2.0f, 0, -10.0f }, { &D_060030A4, 1.0f, 0, -10.0f }, + { &D_06001144, 1.0f, 2, -10.0f }, { &D_06003724, 1.0f, 2, -10.0f }, { &D_06003FB8, 1.0f, 0, -10.0f }, + { &D_060020C8, 1.0f, 0, -10.0f }, { &D_06003B10, 1.0f, 0, -10.0f }, +}; -extern UNK_TYPE D_0600B530; -extern UNK_TYPE D_0600B9E8; +static s32 D_80AEF8E8[2] = { 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEC460.s") +static f32 D_80AEF8F0[] = { + 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, + 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, + 1.88639998436f, 3.44770002365f, 5.29629993439f, 7.39470005035f, 9.60550022125f, 11.9537000656f, + 14.30189991f, 16.6000995636f, 18.8108997345f, 20.8342990875f, 22.6203994751f, 24.1441993713f, + 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, + 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, + 25.3057994843f, 26.5048999786f, 28.0412006378f, 29.9146995544f, 31.9881000519f, 34.2238998413f, + 36.572101593f, 38.932800293f, 41.28099823f, 43.5416984558f, 45.6276016235f, 47.4511985779f, + 49.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEC524.s") +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ f32 unk_04; +} EnTkStruct; // size = 0x8? -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEC658.s") +void func_80AEC460(EnTk* this) { + if (DECR(this->unk_2C4) == 0) { + this->unk_2C2++; + if (this->unk_2C2 >= 3) { + this->unk_2C0--; + if (this->unk_2C0 < 0) { + this->unk_2C4 = Rand_S16Offset(30, 30); + this->unk_2C0 = 2; + if (Rand_ZeroOne() > 0.5f) { + this->unk_2C0++; + } + } + this->unk_2C2 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Init.s") +f32 func_80AEC524(f32 arg0) { + f32 temp_f0; + f32 ret; + s32 temp_a0; + s32 temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Destroy.s") + while ((arg0 >= ARRAY_COUNT(D_80AEF8F0)) || (arg0 < 0.0f)) { + if (arg0 >= ARRAY_COUNT(D_80AEF8F0)) { + arg0 -= ARRAY_COUNT(D_80AEF8F0); + } else if (arg0 < 0.0f) { + arg0 += ARRAY_COUNT(D_80AEF8F0); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECA3C.s") + // temp_f0 always becomes 0 + temp_a1 = arg0; + temp_a0 = temp_a1 + 1; + temp_f0 = arg0 - temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECA90.s") + if (arg0 != temp_a1) { + if (temp_a0 >= ARRAY_COUNT(D_80AEF8F0)) { + temp_a0 -= ARRAY_COUNT(D_80AEF8F0); + ret = (((D_80AEF8F0[temp_a0] + D_80AEF8F0[ARRAY_COUNT(D_80AEF8F0) - 1]) - D_80AEF8F0[temp_a1]) * temp_f0) + + D_80AEF8F0[temp_a1]; + } else { + ret = ((D_80AEF8F0[temp_a0] - D_80AEF8F0[temp_a1]) * temp_f0) + D_80AEF8F0[temp_a1]; + } + } else { + ret = D_80AEF8F0[temp_a1]; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECB0C.s") +void func_80AEC658(SkelAnime* skelAnime, f32 arg1, f32 arg2, f32* arg3, f32* arg4) { + static f32 D_80AEF9B4[] = { 0.95f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 1.25f, 1.48f, 1.68f, 1.77f, 1.88f, 1.88f, 1.84f, + 1.77f, 1.62f, 1.43f, 1.22f, 0.93f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.96f, 1.23f, 1.5f, + 1.66f, 1.79f, 1.88f, 1.89f, 1.88f, 1.81f, 1.67f, 1.46f, 1.24f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECB6C.s") + *arg3 = D_80AEF9B4[(s32)skelAnime->curFrame] * 0.5f * skelAnime->playSpeed * arg2; + *arg4 = (func_80AEC524(skelAnime->curFrame) - func_80AEC524(arg1)) * arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECE0C.s") + while (*arg4 < 0.0f) { + *arg4 += D_80AEF8F0[(s32)skelAnime->animLength - 1] * arg2; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECE60.s") +void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED354.s") + this->unk_2B0 = ENTK_GET_F(&this->actor); + this->unk_2B1 = ENTK_GET_7F0(&this->actor); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED38C.s") + if (Flags_GetSwitch(globalCtx, this->unk_2B1)) { + if (this->unk_2B0 == 0) { + Actor_MarkForDeath(&this->actor); + return; + } + } else if (this->unk_2B0 == 2) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED4F8.s") + if ((this->unk_2B0 == 1) || (this->unk_2B0 == 3)) { + this->actor.flags &= ~(0x8 | 0x1); + this->actor.update = func_80AEF2C8; + this->actor.draw = NULL; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED544.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B9E8, NULL, this->jointTable, this->morphTable, 18); + Animation_Change(&this->skelAnime, &D_060030A4, 1.0f, 0.0f, Animation_GetLastFrame(&D_060030A4.common), 0, 0.0f); + this->unk_318 = 0; + this->unk_2D4 = -1; + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 1; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED610.s") + if (this->unk_2B0 == 2) { + this->unk_316 = 0; + this->actor.update = func_80AEF5F4; + func_80AECA3C(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED898.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.gravity = -1.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.flags |= 0x10; + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED940.s") + switch (this->unk_2B0) { + case 4: + if (D_80AF0050 != 0) { + Actor_MarkForDeath(&this->actor); + return; + } + D_80AF0050 = 1; + this->actor.room = -1; + this->actor.update = func_80AEF2D8; + this->unk_2D8 = 0.0f; + func_80AECB0C(this, globalCtx); + func_80AEF2D8(&this->actor, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDBEC.s") + case 0: + this->unk_2D0 = -1; + this->unk_310 = 0; + this->unk_2E4 = 0; + func_80AED898(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDC4C.s") + default: + Actor_MarkForDeath(&this->actor); + return; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDCBC.s") +void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDD4C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDDA0.s") +void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { + this->unk_316 = 0; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actionFunc = func_80AECA90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDE10.s") +void func_80AECA90(EnTk* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80AEDE10(this, globalCtx); + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDF5C.s") +void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->unk_3CC = 0xFF; + this->unk_2DC = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + this->actionFunc = func_80AECB6C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE2A8.s") +void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { + f32 temp_f0; + s32 temp2; + s32 temp3; + f32 sp48; + f32 sp44; + u8 temp4; + struct_80133038_arg2 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE2C0.s") + this->actor.textId = 0; + if (func_800B84D0(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80AED4F8(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE300.s") + if (REG(15) != 0.0f) { + this->skelAnime.playSpeed = (f32)func_800FE620(globalCtx) / REG(15); + } else { + this->skelAnime.playSpeed = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE374.s") + if (this->unk_2CA & 0x10) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + sp48 = 1.0f; + sp44 = 22.0f; + } else { + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &sp48, &sp44); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE414.s") + temp2 = REG(15) * sp44; + temp_f0 = temp2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE478.s") + this->unk_2DC += (REG(15) * sp44) - temp2; + temp3 = this->unk_2DC; + this->unk_3D0 = temp2 + temp3; + this->unk_2DC -= temp3; + this->unk_2E0 += REG(15); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE4D0.s") + if (func_80133038(globalCtx, (UNK_TYPE*)D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.unk0) && !func_80AED354(this, globalCtx, &sp34)) { + return; + } + temp4 = sp34.unk0; + } else { + sp34.unk0 = 0; + temp4 = sp34.unk0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE650.s") + if (!temp4 && (this->unk_3CC != 0)) { + this->actor.draw = NULL; + this->actor.flags &= ~1; + } else if (temp4 && (this->unk_3CC == 0)) { + this->actor.flags |= 1; + this->actor.draw = EnTk_Draw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE6B8.s") + this->unk_3CC = sp34.unk0; + func_80AECE0C(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE784.s") + if (this->unk_3CE & 8) { + this->actor.flags &= ~1; + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE7E0.s") +void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { + if (this->unk_3CC != 0) { + if (1) {} + func_80AECE60(this, globalCtx); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1555, 0xB6); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE86C.s") +s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { + EnDoor* sp4C4; + f32 spA0[265]; + Vec3f sp94; + Vec3f sp88; + Vec3f sp7C; + s32 sp78; + s32 sp74; + Actor* door2; + Actor* door1; + s32 pad2[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE9B0.s") + func_8013AF00(spA0, 3, this->unk_3C8->count + 3); + if (!(this->unk_3CE & 4)) { + sp7C = D_801D15B0; + func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, + &sp7C, this->unk_3D0); + func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); + this->actor.world.pos.y = sp7C.y; + } else { + sp7C = this->unk_3D4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEEA4C.s") + this->actor.world.pos.x = sp7C.x; + this->actor.world.pos.z = sp7C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEEAD4.s") + if (!(this->unk_3CE & 4)) { + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + this->unk_3CE |= 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEEB88.s") + if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { + sp78 = this->unk_3F0; + sp74 = this->unk_3EC; + sp7C = this->actor.world.pos; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEED38.s") + this->unk_3D4 = D_801D15B0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF048.s") + if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, + &this->unk_3D4, this->unk_3D0)) { + this->unk_3CE |= 8; + } else { + sp94 = this->actor.world.pos; + sp88 = this->unk_3D4; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF094.s") + if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { + this->unk_3F0 = sp78; + this->unk_3EC = sp74; + this->unk_3D4 = sp7C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF15C.s") + sp4C4 = NULL; + if (!(this->unk_2CA & 0xC00)) { + door1 = NULL; + label: + do { + door1 = func_ActorCategoryIterateById(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (door1 != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= + 0x2000) { + this->unk_2CA |= 0x400; + sp4C4 = (EnDoor*)door1; + break; + } + } + door1 = door1->next; + } + } while (door1 != NULL); + } else { + door2 = NULL; + do { + door2 = func_ActorCategoryIterateById(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (door2 != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { + sp4C4 = (EnDoor*)door2; + break; + } + door2 = door2->next; + } + } while (door2 != NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF1B4.s") + if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { + Vec3f sp5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF1C4.s") + Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &sp5C, &sp4C4->actor.world.pos); + sp4C4->unk_1A7 = 2; + if (sp5C.z < -20.0f) { + this->unk_2CA &= ~0x400; + this->unk_2CA |= 0x800; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF210.s") + if (sp4C4 != NULL) { + if ((this->unk_2CA & 0x800) && (sp4C4->unk_1A7 == 0)) { + this->unk_2CA &= ~0x800; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF220.s") + if (!(this->unk_3CE & 8) && !(this->unk_2CA & 0x10) && (this->actor.xzDistToPlayer < 100.0f)) { + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF278.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF2C8.s") +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 phi_v1 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF2D8.s") + if (arg2->unk0 != 0) { + phi_v1 = func_80AED38C(this, globalCtx, arg2); + } + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Update.s") +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp1E = gSaveContext.time - 0x3FFC; + u8 params = ENTK_GET_F800(&this->actor); + u16 phi_a1; + s32 idx = arg2->unk0 - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF5F4.s") + this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); + if (this->unk_3C8 == 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF65C.s") + if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { + phi_a1 = sp1E; + } else { + phi_a1 = arg2->unk4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF6A4.s") + this->unk_3E4 = arg2->unk8 - phi_a1; + this->unk_3F0 = sp1E - phi_a1; + phi_a1 = this->unk_3C8->count - 2; + this->unk_3E8 = this->unk_3E4 / phi_a1; + this->unk_3EC = (this->unk_3F0 / this->unk_3E8) + 2; + this->unk_3CE &= ~4; + this->unk_3CE &= ~8; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Draw.s") +void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actionFunc = func_80AED610; +} + +void func_80AED544(EnTk* this, GlobalContext* globalCtx) { + if (!(gSaveContext.weekEventReg[31] & 0x10)) { + func_801518B0(globalCtx, 0x13FE, &this->actor); + gSaveContext.weekEventReg[31] |= 0x10; + } else if (gSaveContext.time < CLOCK_TIME(9, 0)) { + func_801518B0(globalCtx, 0x13FF, &this->actor); + } else if (gSaveContext.time < CLOCK_TIME(12, 0)) { + func_801518B0(globalCtx, 0x1400, &this->actor); + } else if (gSaveContext.time < CLOCK_TIME(15, 0)) { + func_801518B0(globalCtx, 0x1401, &this->actor); + } else { + func_801518B0(globalCtx, 0x1402, &this->actor); + } +} + +void func_80AED610(EnTk* this, GlobalContext* globalCtx) { + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + func_801518B0(globalCtx, 0x13FD, &this->actor); + } else if (CURRENT_DAY != 2) { + func_80AED544(this, globalCtx); + } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { + func_801518B0(globalCtx, 0x1403, &this->actor); + } else if (gSaveContext.weekEventReg[60] & 2) { + func_80AED544(this, globalCtx); + } else { + func_801518B0(globalCtx, 0x1413, &this->actor); + } + break; + } + + case 1: + case 2: + case 3: + break; + + case 4: + case 5: + case 6: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x13FD: + this->unk_2CA |= 0x10; + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + this->skelAnime.playSpeed = 10.0f; + this->actionFunc = func_80AECB6C; + break; + + case 0x13FE: + func_80151938(globalCtx, 0x13FF); + break; + + case 0x1413: + func_801159EC(30); + gSaveContext.weekEventReg[60] |= 2; + func_80151938(globalCtx, 0x13FF); + break; + + case 0x13FF: + case 0x1400: + case 0x1401: + case 0x1402: + case 0x1403: + case 0x1404: + case 0x1405: + case 0x1406: + case 0x1407: + case 0x1408: + case 0x1409: + case 0x140A: + case 0x140B: + case 0x140C: + case 0x140D: + case 0x140E: + case 0x140F: + case 0x1410: + case 0x1411: + case 0x1412: + default: + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + this->actionFunc = func_80AECB6C; + break; + } + } + break; + } +} + +void func_80AED898(EnTk* this, GlobalContext* globalCtx) { + this->unk_316 = 0; + this->actor.speedXZ = 0.0f; + if (this->unk_2CA & 0x1000) { + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } + this->actionFunc = func_80AED940; +} + +void func_80AED940(EnTk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + Vec3f sp44; + + if ((this->unk_2D4 != 4) && (this->unk_2D4 != 7)) { + s16 temp_v0 = (this->actor.shape.rot.y - this->actor.yawTowardsPlayer) + 0x1555; + + if (ABS(temp_v0) < 0x1800) { + Math_SmoothStepToS(&this->unk_31C, temp_v0, 3, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 0); + } + + Math_Vec3f_Copy(&sp44, &player->actor.world.pos); + sp44.y = player->bodyPartsPos[7].y + 3.0f; + temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp44); + if (ABS(temp_v0) < 0x800) { + Math_SmoothStepToS(&this->unk_31A, temp_v0, 3, 0x16C, 0); + } else { + Math_SmoothStepToS(&this->unk_31A, 0, 3, 0x16C, 0); + } + } + + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + + if (!(this->unk_2CA & 0x40)) { + actor = NULL; + + do { + actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); + if (actor != NULL) { + if (ENTK_GET_F(actor) == 1) { + Math_Vec3f_Copy(&this->unk_2EC, &actor->world.pos); + Math_Vec3s_Copy(&this->unk_2F8, &actor->world.rot); + Actor_MarkForDeath(actor); + this->unk_2CA |= 0x40; + break; + } + actor = actor->next; + } + } while (actor != NULL); + } + + if (func_800B84D0(&this->actor, globalCtx)) { + this->unk_2CA &= ~0x80; + this->actor.flags &= ~0x10000; + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80AEDE10(this, globalCtx); + } else if (!(this->unk_2CA & 0x80)) { + if (this->actor.xzDistToPlayer < 100.0f) { + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + } + } else { + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + } +} + +void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { + this->actor.params = -1; + this->unk_2E8 = 0; + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actionFunc = func_80AEDC4C; +} + +void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { + if ((this->actor.params >= 0) && func_8013E2D4(&this->actor, this->cutscenes[1], this->actor.params, 0)) { + this->unk_2E8 = ActorCutscene_GetLength(this->cutscenes[1]); + func_80151938(globalCtx, 0x1411); + func_80AEDCBC(this, globalCtx); + } +} + +void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 10.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2EC); + Math_Vec3f_Copy(&this->actor.prevPos, &this->unk_2EC); + Math_Vec3s_Copy(&this->actor.world.rot, &this->unk_2F8); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->unk_2F8); + this->actionFunc = func_80AEDD4C; +} + +void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { + this->unk_2E8--; + if (this->unk_2E8 <= 0) { + ActorCutscene_Stop(this->cutscenes[1]); + func_801477B4(globalCtx); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actor.flags |= 0x10000; + this->unk_2CA |= 0x80; + this->actionFunc = func_80AED940; +} + +void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { + switch (this->unk_2B0) { + case 0: + if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + this->unk_2E6 = 0x1404; + break; + } + + switch (this->unk_310) { + case 0: + this->unk_2CA &= ~0x1000; + if (!(gSaveContext.weekEventReg[52] & 0x80)) { + this->unk_2E6 = 0x1405; + } else { + this->unk_2E6 = 0x140B; + } + break; + + case 2: + this->unk_2E6 = 0x140D; + break; + + case 4: + func_801518B0(globalCtx, 0x140F, &this->actor); + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + break; + + case 3: + func_801518B0(globalCtx, 0x1410, &this->actor); + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + break; + } + break; + + case 2: + this->unk_2E6 = 0x1414; + break; + } + + this->actionFunc = func_80AEDF5C; +} + +void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + switch (this->unk_2E6) { + case 0x1404: + case 0x1405: + case 0x140B: + case 0x140D: + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 1, 0x71C, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!Math_SmoothStepToS(&this->unk_31A, 0, 3, 0x16C, 10) && + !Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 10) && + (this->actor.shape.rot.y == (s16)(this->actor.yawTowardsPlayer - 0x1555))) { + if (this->unk_2E6 == 0x1404) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } + func_801518B0(globalCtx, this->unk_2E6, &this->actor); + } + break; + + case 0x1414: + func_801518B0(globalCtx, this->unk_2E6, &this->actor); + break; + } + break; + + case 1: + case 2: + case 3: + break; + + case 4: + case 5: + case 6: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1404: + this->unk_2CA |= 0x1000; + func_80AED898(this, globalCtx); + break; + + case 0x1405: + func_80151938(globalCtx, 0x1406); + break; + + case 0x1406: + func_80151938(globalCtx, 0x1407); + break; + + case 0x1407: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_80151938(globalCtx, 0x1409); + } else { + func_8019F230(); + func_80151938(globalCtx, 0x1408); + } + break; + + case 0x1408: + func_80151938(globalCtx, 0x1407); + break; + + case 0x1409: + func_80151938(globalCtx, 0x140A); + break; + + case 0x140A: + gSaveContext.weekEventReg[52] |= 0x80; + + case 0x140B: + func_80AEE784(this, globalCtx); + break; + + case 0x140D: + this->unk_2CA |= 2; + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + globalCtx->msgCtx.unk11F22 = 0x44; + func_80AEE2A8(this, globalCtx); + } else { + func_8019F230(); + func_80151938(globalCtx, 0x140E); + } + break; + + case 0x140E: + case 0x140F: + case 0x1410: + func_80AEE784(this, globalCtx); + break; + + case 0x1414: + func_80AECA3C(this, globalCtx); + break; + } + } + break; + } +} + +void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx) { + this->actionFunc = func_80AEE2C0; +} + +void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx) { + if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 0)) { + func_80AEE374(this, globalCtx); + } +} + +s32 func_80AEE300(GlobalContext* globalCtx, Actor* arg1, Actor* arg2, void* _arg3) { + EnTkStruct* arg3 = (EnTkStruct*)_arg3; + f32 temp_f0; + + if ((arg2 != arg1) && (ENTK_GET_F(arg2) == 3)) { + temp_f0 = Actor_DistanceBetweenActors(arg1, arg2); + if (temp_f0 < arg3->unk_04) { + arg3->unk_00 = arg2; + arg3->unk_04 = temp_f0; + } + } + return false; +} + +void func_80AEE374(EnTk* this, GlobalContext* globalCtx) { + EnTkStruct sp30; + + sp30.unk_00 = NULL; + sp30.unk_04 = FLT_MAX; + + func_8013E640(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); + if (sp30.unk_00 == 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2CC = Actor_YawToPoint(&this->actor, &sp30.unk_00->world.pos); + this->actionFunc = func_80AEE414; + } +} + +void func_80AEE414(EnTk* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_2CC, 2, 0xE38, 0x5B); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->actor.shape.rot.y == this->unk_2CC) { + func_80AEE478(this, globalCtx); + } +} + +void func_80AEE478(EnTk* this, GlobalContext* globalCtx) { + this->unk_310 = 2; + func_8013E1C8(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); + this->actionFunc = func_80AEE4D0; +} + +void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { + Actor* bigPoe; + + if ((this->skelAnime.curFrame > 33.0f) && (this->skelAnime.curFrame < 41.0f)) { + func_800BBFB0(globalCtx, &this->unk_2B4, 10.0f, 2, 50, 30, 1); + } + + if (Animation_OnFrame(&this->skelAnime, 33.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIG_UP); + } + + if (!(this->unk_2CA & 0x20)) { + if (Animation_OnFrame(&this->skelAnime, 37.0f)) { + bigPoe = NULL; + do { + bigPoe = func_ActorCategoryIterateById(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); + + if (bigPoe != NULL) { + if ((bigPoe->params == 3) && (Actor_DistanceBetweenActors(&this->actor, bigPoe) < 80.0f)) { + bigPoe->params = 4; + this->unk_2CA |= 0x20; + this->unk_2E4++; + } + bigPoe = bigPoe->next; + } + } while (bigPoe != NULL); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AEE650(this, globalCtx); + } +} + +void func_80AEE650(EnTk* this, GlobalContext* globalCtx) { + if (this->unk_36C < ARRAY_COUNT(this->unk_324)) { + Math_Vec3f_Copy(&this->unk_324[this->unk_36C], &this->actor.world.pos); + this->unk_36C++; + } + this->actionFunc = func_80AEE6B8; +} + +void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx) { + if (this->unk_2CA & 0x20) { + if (this->unk_2E4 >= 3) { + ActorCutscene_Stop(this->cutscenes[0]); + func_801477B4(globalCtx); + func_80AEDBEC(this, globalCtx); + } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + this->unk_310 = 3; + func_80AEDE10(this, globalCtx); + this->unk_2CA &= ~0x20; + } + } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + this->unk_310 = 4; + func_80AEDE10(this, globalCtx); + } +} + +void func_80AEE784(EnTk* this, GlobalContext* globalCtx) { + this->unk_2D0 = -1; + this->unk_310 = 1; + Math_Vec3s_Copy(&this->actor.world.rot, &this->actor.shape.rot); + func_80AEEAD4(this, globalCtx); + this->actionFunc = func_80AEE9B0; +} + +s32 func_80AEE7E0(Vec3f* arg0, f32 arg1, Vec3f* arg2, s32 arg3) { + s32 i; + s32 ret = true; + + for (i = 0; i < arg3; i++) { + if (Math_Vec3f_DistXZ(arg0, &arg2[i]) < arg1) { + ret = false; + break; + } + } + return ret; +} + +s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { + static Vec3f D_80AEFA78 = { 0.0f, 20.0f, 32.0f }; + s32 pad; + s32 ret = false; + s32 pad2; + CollisionPoly* sp38; + s32 sp34; + Vec3f sp28; + + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80AEFA78, &sp28); + if ((func_800C40B4(&globalCtx->colCtx, &sp38, &sp34, &sp28) != BGCHECK_Y_MIN) && + (func_800C9BB8(&globalCtx->colCtx, sp38, sp34) == 1) && (this->unk_2D0 == 1) && + (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && + func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && + (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && + !func_801690CC(globalCtx)) { + Math_Vec3f_Copy(&this->unk_300, &sp28); + ret = true; + } + return ret; +} + +void func_80AEE9B0(EnTk* this, GlobalContext* globalCtx) { + this->unk_30C(this, globalCtx); + + func_80AEEAD4(this, globalCtx); + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_300) >= 100.0f) { + this->unk_2CA &= ~2; + } + + if (func_80AEE86C(this, globalCtx)) { + this->unk_310 = 2; + func_80AEDDA0(this, globalCtx); + } +} + +s32 func_80AEEA4C(EnTk* this, GlobalContext* globalCtx) { + s32 ret; + + if (this->unk_2CA & 1) { + ret = 3; + } else if (this->actor.xyzDistToPlayerSq < SQ(60.0f)) { + ret = 0; + } else if (this->actor.isTargeted || (globalCtx->actorCtx.targetContext.unk_94 == &this->actor) || + (this->actor.xyzDistToPlayerSq < SQ(80.0f))) { + ret = 1; + } else { + ret = 2; + } + return ret; +} + +void func_80AEEAD4(EnTk* this, GlobalContext* globalCtx) { + s32 sp24 = func_80AEEA4C(this, globalCtx); + + if (sp24 != this->unk_2D0) { + switch (sp24) { + case 0: + func_80AEF220(this, globalCtx); + break; + + case 1: + func_80AEF048(this, globalCtx); + break; + + case 2: + func_80AEEB88(this, globalCtx); + break; + + case 3: + func_80AEF15C(this, globalCtx); + break; + + case 4: + func_80AEF1C4(this, globalCtx); + break; + } + this->unk_2D0 = sp24; + } +} + +void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { + s32 sp74; + Vec3f sp68; + s32 i; + f32 temp; + + for (i = 0; i < 8; i++) { + sp68.x = Math_SinS(this->actor.world.rot.y + (i * 0x2000)) * 80.0f; + sp68.z = Math_CosS(this->actor.world.rot.y + (i * 0x2000)) * 80.0f; + + sp68.x += this->actor.world.pos.x; + sp68.y = this->actor.world.pos.y + 50.0f; + sp68.z += this->actor.world.pos.z; + + temp = func_800C40B4(&globalCtx->colCtx, &this->actor.floorPoly, &sp74, &sp68) - this->actor.world.pos.y; + if (temp <= -80.0f) { + break; + } + } + + if (i == 8) { + this->unk_2CC = BINANG_ROT180((Rand_Centered() * 0x8000) + this->actor.yawTowardsPlayer); + } else { + this->unk_2CC = this->actor.world.rot.y + (i * 0x2000); + } + + this->unk_2C6 = 100; + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + this->unk_30C = func_80AEED38; +} + +void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { + f32 sp64; + Vec3f sp58; + s16 sp56 = this->actor.shape.rot.y; + Vec3f sp48; + Vec3f sp3C; + + Math_Vec3f_Copy(&sp58, &this->actor.world.pos); + sp58.x += (Math_SinS(sp56) * 20.0f); + sp58.y += 30.0f; + sp58.z += Math_CosS(sp56) * 20.0f; + + if (func_800C5A64(&globalCtx->colCtx, &sp58, 20.0f)) { + Math_Vec3f_Copy(&sp48, &this->actor.world.pos); + sp56 = BINANG_ADD(this->actor.shape.rot.y, 0x4000); + sp48.x += (Math_SinS(sp56) * 20.0f); + sp48.y += 30.0f; + sp48.z += Math_CosS(sp56) * 20.0f; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp56 = BINANG_SUB(this->actor.shape.rot.y, 0x4000); + sp3C.x += (Math_SinS(sp56) * 20.0f); + sp3C.y += 30.0f; + sp3C.z += Math_CosS(sp56) * 20.0f; + + if (func_800C5A64(&globalCtx->colCtx, &sp48, 20.0f)) { + if (func_800C5A64(&globalCtx->colCtx, &sp3C, 20.0f)) { + this->unk_2CC = this->actor.shape.rot.y - 0x4000; + } else { + this->unk_2CC = this->actor.shape.rot.y - 0x4000; + } + } else { + this->unk_2CC = this->actor.shape.rot.y + 0x4000; + } + } + + if (this->unk_2CA & 0x200) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp64); + } + + if (this->actor.speedXZ > 0.5f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, 0xAAA, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (!func_80152498(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + func_801518B0(globalCtx, 0x140C, NULL); + this->unk_2CA |= 0x4000; + this->unk_2C6 = 200; + } +} + +void func_80AEF048(EnTk* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + this->unk_30C = func_80AEF094; +} + +void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { + f32 sp2C; + + if (this->unk_2CA & 0x200) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp2C); + } + + if (this->actor.speedXZ >= 0.5f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 0x38E, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} + +void func_80AEF15C(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->unk_30C = func_80AEF1B4; +} + +void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx) { +} + +void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->unk_30C = func_80AEF210; +} + +void func_80AEF210(EnTk* this, GlobalContext* globalCtx) { +} + +void func_80AEF220(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->unk_30C = func_80AEF278; +} + +void func_80AEF278(EnTk* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 3, 0x1C7, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80AEF2C8(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTk* this = THIS; + + if (this->actor.draw != NULL) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->unk_320 = this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + + if ((this->actor.draw != NULL) && ((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + } + + this->actionFunc(this, globalCtx); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 4); + func_80AEC460(this); +} + +void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTk* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + this->unk_320 = this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + func_80AEC460(this); + + if (((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + } + + this->unk_2CA &= ~1; + + if (this->actor.floorBgId != BGCHECK_SCENE) { + BgDanpeiMovebg* platform = (BgDanpeiMovebg*)BgCheck_GetActorOfMesh(&globalCtx->colCtx, this->actor.floorBgId); + + if (platform != NULL) { + if (platform->dyna.actor.id == ACTOR_BG_DANPEI_MOVEBG) { + platform->unk_1CC |= 1; + if (platform->unk_1CC & 2) { + this->unk_2CA |= 1; + } + } + } else { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.home.pos); + } + } + + this->actionFunc(this, globalCtx); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); + + if ((this->unk_2B0 == 0) && + (func_800C9B40(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 12)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + this->unk_2CA |= 0x200; + this->actor.velocity.y = 0.0f; + } else { + this->unk_2CA &= ~0x200; + } + + if (!(this->unk_2CA & 0x200)) { + if (!(this->actor.bgCheckFlags & 1)) { + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } else if (this->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + } + } +} + +void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx) { + EnTk* this = THIS; + + this->unk_316 += 0x46C8; + this->unk_318 = Math_SinS(this->unk_316) * 900.0f; + this->actionFunc(this, globalCtx); +} + +s32 func_80AEF65C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTk* this = THIS; + + if (limbIndex == 16) { + rot->z += this->unk_31A; + rot->y += this->unk_31C; + } + return false; +} + +void func_80AEF6A4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80AEFA84 = { 0.0f, 0.0f, 4600.0f }; + EnTk* this = THIS; + + if (this->unk_2B0 != 2) { + switch (limbIndex) { + case 16: + Matrix_GetStateTranslation(&this->actor.focus.pos); + break; + + case 14: + Matrix_MultiplyVector3fByState(&D_80AEFA84, &this->unk_2B4); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, D_0600B530); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + } + } +} + +void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { + static UNK_PTR D_80AEFA90[] = { + &D_06004390, + &D_06004B90, + &D_06005390, + }; + s32 pad; + EnTk* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 25); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AEFA90[this->unk_2C2])); + + Matrix_RotateY(this->unk_318, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80AEF65C, func_80AEF6A4, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 0f79cba14..119ae2b2b 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -6,12 +6,61 @@ struct EnTk; typedef void (*EnTkActionFunc)(struct EnTk*, GlobalContext*); +typedef void (*EnTkUnkFunc)(struct EnTk*, GlobalContext*); + +#define ENTK_GET_F(thisx) ((thisx)->params & 0xF) +#define ENTK_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) +#define ENTK_GET_F800(thisx) ((((thisx)->params >> 0xB) & 0x1F) & 0xFF) typedef struct EnTk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnTkActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x268]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ Vec3s jointTable[18]; + /* 0x0244 */ Vec3s morphTable[18]; + /* 0x02B0 */ s8 unk_2B0; + /* 0x02B1 */ s8 unk_2B1; + /* 0x02B4 */ Vec3f unk_2B4; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C6 */ s16 unk_2C6; + /* 0x02C8 */ UNK_TYPE1 unk2C8[0x2]; + /* 0x02CA */ u16 unk_2CA; + /* 0x02CC */ s16 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; + /* 0x02D8 */ f32 unk_2D8; + /* 0x02DC */ f32 unk_2DC; + /* 0x02E0 */ s32 unk_2E0; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ u16 unk_2E6; + /* 0x02E8 */ s16 unk_2E8; + /* 0x02EC */ Vec3f unk_2EC; + /* 0x02F8 */ Vec3s unk_2F8; + /* 0x0300 */ Vec3f unk_300; + /* 0x030C */ EnTkUnkFunc unk_30C; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 cutscenes[2]; + /* 0x0316 */ s16 unk_316; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ s16 unk_31A; + /* 0x031C */ s16 unk_31C; + /* 0x0320 */ f32 unk_320; + /* 0x0324 */ Vec3f unk_324[6]; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ UNK_TYPE1 unk370[0x58]; + /* 0x03C8 */ Path* unk_3C8; + /* 0x03CC */ u8 unk_3CC; + /* 0x03CE */ u16 unk_3CE; + /* 0x03D0 */ s32 unk_3D0; + /* 0x03D4 */ Vec3f unk_3D4; + /* 0x03E0 */ f32 unk_3E0; + /* 0x03E4 */ s32 unk_3E4; + /* 0x03E8 */ s32 unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ s32 unk_3F0; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 211f78865..d54482337 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3697,7 +3697,16 @@ D_06002100 = 0x06002100; // ovl_En_Tk +D_06001144 = 0x06001144; +D_06001FA8 = 0x06001FA8; +D_060020C8 = 0x060020C8; D_060030A4 = 0x060030A4; +D_06003724 = 0x06003724; +D_06003B10 = 0x06003B10; +D_06003FB8 = 0x06003FB8; +D_06004390 = 0x06004390; +D_06004B90 = 0x06004B90; +D_06005390 = 0x06005390; D_0600B530 = 0x0600B530; D_0600B9E8 = 0x0600B9E8;