From edb1dd46757979c5fd755c4f27bce7a69842fc9a Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 28 Sep 2021 14:28:06 +0100 Subject: [PATCH] En_Zot (#320) * En_Zot * PR --- include/functions.h | 8 +- include/macros.h | 1 + spec | 3 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 1399 ++++++++++++++++++++- src/overlays/actors/ovl_En_Zot/z_en_zot.h | 18 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 11 + 7 files changed, 1373 insertions(+), 71 deletions(-) diff --git a/include/functions.h b/include/functions.h index dc0d98e7e1..c87bfe03c7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -807,8 +807,8 @@ s32 func_800B863C(Actor* actor, GlobalContext* globalCtx); u32 func_800B867C(Actor* actor, GlobalContext* globalCtx); UNK_TYPE4 func_800B86C8(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); s32 func_800B8708(GlobalContext* globalCtx); -// void func_800B8718(void); -// void func_800B874C(void); +s32 func_800B8718(Actor* actor, GlobalContext* globalCtx); +void func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3); // void func_800B8804(void); // void func_800B882C(void); // void func_800B886C(void); @@ -3792,7 +3792,7 @@ void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019B38C(void); // void func_8019B3D0(void); // void func_8019B4B8(void); -// void func_8019B544(void); +void func_8019B544(u16 arg0); // void func_8019B568(void); // void func_8019B5AC(void); // void func_8019B5EC(void); @@ -3804,7 +3804,7 @@ void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019C1D0(void); // void func_8019C268(void); // void func_8019C2E4(void); -// void func_8019C300(void); +void func_8019C300(s32 arg0); // void func_8019C398(void); // void func_8019C5A0(void); // void func_8019C8D8(void); diff --git a/include/macros.h b/include/macros.h index e0e6c8e7c5..8b02cbfc5f 100644 --- a/include/macros.h +++ b/include/macros.h @@ -56,6 +56,7 @@ #define TAKE_EQUIPPED_ITEM(equip) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)(0 << gEquipShifts[equip]))) #define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[gSaveContext.playerForm == PLAYER_FORM_HUMAN ? 0 : gSaveContext.playerForm][button]) #define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg) - 4) diff --git a/spec b/spec index e958e08d09..daed42bf48 100644 --- a/spec +++ b/spec @@ -4484,8 +4484,7 @@ beginseg name "ovl_En_Zot" compress include "build/src/overlays/actors/ovl_En_Zot/z_en_zot.o" - include "build/data/ovl_En_Zot/ovl_En_Zot.data.o" - include "build/data/ovl_En_Zot/ovl_En_Zot.reloc.o" + include "build/src/overlays/actors/ovl_En_Zot/ovl_En_Zot_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 026a5a7bca..b49ccaef12 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zot.c + * Overlay: ovl_En_Zot + * Description: Great Bay - Zora With Directions to Zora Hall + */ + #include "z_en_zot.h" #define FLAGS 0x00000019 @@ -9,7 +15,36 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZot_Update(Actor* thisx, GlobalContext* globalCtx); void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2); +void func_80B97100(EnZot* this, GlobalContext* globalCtx); +void func_80B97240(EnZot* this, GlobalContext* globalCtx); +void func_80B97708(EnZot* this, GlobalContext* globalCtx); +void func_80B97B5C(EnZot* this, GlobalContext* globalCtx); +void func_80B97CC8(EnZot* this, GlobalContext* globalCtx); +void func_80B97FD0(EnZot* this, GlobalContext* globalCtx); +void func_80B980FC(EnZot* this, GlobalContext* globalCtx); +void func_80B98728(EnZot* this, GlobalContext* globalCtx); +void func_80B98998(EnZot* this, GlobalContext* globalCtx); +void func_80B98CA8(EnZot* this, GlobalContext* globalCtx); +void func_80B990A4(EnZot* this, GlobalContext* globalCtx); +void func_80B992C0(EnZot* this, GlobalContext* globalCtx); +void func_80B99384(EnZot* this, GlobalContext* globalCtx); + +extern AnimationHeader D_06002898; +extern AnimationHeader D_06004248; +extern UNK_PTR D_060050A0; +extern UNK_PTR D_060058A0; +extern UNK_PTR D_060060A0; +extern FlexSkeletonHeader D_0600D208; +extern AnimationHeader D_0600DE20; +extern AnimationHeader D_0600DF54; +extern AnimationHeader D_0600E400; +extern AnimationHeader D_0600EDF0; +extern AnimationHeader D_0600F4E8; +extern AnimationHeader D_0600FDF0; +extern AnimationHeader D_06010B18; +extern AnimationHeader D_06011424; + const ActorInit En_Zot_InitVars = { ACTOR_EN_ZOT, ACTORCAT_NPC, @@ -22,123 +57,1363 @@ const ActorInit En_Zot_InitVars = { (ActorFunc)EnZot_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B998E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { + s32 i; -extern ColliderCylinderInit D_80B998E0; + if ((this->path != NULL) && (this->path->count >= 5)) { + Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); -extern UNK_TYPE D_06004248; + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++, points++) { + if (this->unk_2D8[i] == NULL) { + this->unk_2D8[i] = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_TSUBO, points->x, points->y, + points->z, 0, 0, 0, 0x13F); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B965D0.s") +void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnZot* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80B97100; + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600D208, &D_06004248, this->jointTable, this->morphTable, 20); + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_0600DE20); + this->unk_2F0 = 0; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Destroy.s") + this->unk_2F2 = 0; + this->unk_2F4 = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.world.rot.z = this->actor.shape.rot.z = 0; + this->actor.targetMode = 6; + this->actor.minVelocityY = -4.0f; + this->actor.gravity = -4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96BEC.s") + switch (ENZOT_GET_1F(thisx)) { + case 0: + this->actionFunc = func_80B97240; + this->actor.textId = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96CE4.s") + case 1: + this->actionFunc = func_80B97708; + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++) { + this->unk_2D8[i] = NULL; + } + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->unk_2D4 = 0; + func_80B965D0(this, globalCtx); + } else { + this->path = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96D4C.s") + case 2: + case 3: + case 4: + this->actionFunc = func_80B97B5C; + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96DF0.s") + case 5: + this->unk_2F2 |= 4; + this->actionFunc = func_80B97FD0; + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + func_80B96BEC(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96E5C.s") + case 6: + this->actionFunc = func_80B98998; + func_80B96BEC(this, 2, 0); + this->actor.colChkInfo.cylRadius = 0; + this->actor.shape.yOffset = -1400.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96FB0.s") + case 7: + this->actionFunc = func_80B98998; + func_80B96BEC(this, 0, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97100.s") + case 8: + this->actor.flags |= 0x2000000; + this->actionFunc = func_80B98CA8; + func_80B96BEC(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97110.s") + case 9: + this->actionFunc = func_80B990A4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97194.s") + case 10: + this->actionFunc = func_80B992C0; + func_80B96BEC(this, 1, 0); + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97240.s") + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + this->actionFunc = func_80B98998; + func_80B96BEC(this, 2, 0); + this->actor.colChkInfo.cylRadius = 0; + this->actor.shape.yOffset = -1400.0f; + if (!(gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B972E8.s") + case 18: + this->actionFunc = func_80B99384; + if (!(gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B973BC.s") + case 19: + func_80B96BEC(this, 7, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B975F8.s") + case 20: + func_80B96BEC(this, 8, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9765C.s") + case 21: + func_80B96BEC(this, 9, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97708.s") + case 22: + this->actionFunc = func_80B980FC; + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + this->actor.home.rot.x = this->actor.home.rot.z; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9787C.s") + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B979DC.s") +void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZot* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97A44.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + if (ENZOT_GET_1F(&this->actor) == 8) { + gSaveContext.weekEventReg[41] &= (u8)~0x20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97B5C.s") +void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2) { + static AnimationHeader* sAnimations[] = { + &D_0600DE20, &D_06002898, &D_0600F4E8, &D_0600E400, &D_0600FDF0, + &D_06010B18, &D_06011424, &D_0600EDF0, &D_0600DF54, &D_0600DF54, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97BF8.s") + if ((arg1 >= 0) && (arg1 < 10)) { + if (arg1 >= 8) { + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[arg1], 0.0f, arg1 - 8, arg1 - 8, arg2, 0.0f); + } else { + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, + SkelAnime_GetFrameCount(&sAnimations[arg1]->common), arg2, -5.0f); + } + this->unk_2F0 = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97C40.s") +s32 func_80B96CE4(EnZot* this) { + s32 i; + s32 count = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97CC8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++) { + if (this->unk_2D8[i] == NULL) { + count++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97D6C.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97E0C.s") +void func_80B96D4C(EnZot* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97E4C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++) { + if ((this->unk_2D8[i] != NULL) && (this->unk_2D8[i]->update == NULL)) { + this->unk_2D8[i] = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97FD0.s") +s32 func_80B96DF0(EnZot* this, GlobalContext* globalCtx) { + if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x3000) && + (this->actor.xzDistToPlayer < 100.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B980FC.s") +s32 func_80B96E5C(EnZot* this) { + Path* path = this->path; + Vec3s* points; + f32 temp_f12; + f32 temp_f14; + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98178.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98348.s") + points = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2D4]; + temp_f12 = points->x - this->actor.world.pos.x; + temp_f14 = points->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(temp_f12, temp_f14); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 2000, 200); + phi_f2 = SQ(this->actor.speedXZ) * SQ(3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9849C.s") + if (this->unk_2D4 == 0) { + phi_f2 = SQ(20.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9854C.s") + if ((SQ(temp_f12) + SQ(temp_f14)) < phi_f2) { + this->unk_2D4++; + if (this->unk_2D4 >= path->count) { + this->actor.world.pos.x = points->x; + this->actor.world.pos.z = points->z; + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B985EC.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98728.s") +s32 func_80B96FB0(EnZot* this) { + Path* path = this->path; + Vec3s* points; + f32 temp_f12; + f32 temp_f14; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98998.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98A4C.s") + points = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2D4]; + temp_f12 = points->x - this->actor.world.pos.x; + temp_f14 = points->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(temp_f12, temp_f14); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 2000, 200); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98AD0.s") + if ((SQ(temp_f12) + SQ(temp_f14)) < SQ(10.0f)) { + if (this->unk_2F2 & 0x20) { + this->unk_2D4--; + if (this->unk_2D4 < 0) { + this->unk_2D4 = 1; + this->unk_2F2 &= ~0x20; + return true; + } + } else { + this->unk_2D4++; + if (this->unk_2D4 >= path->count) { + this->unk_2D4 = path->count - 1; + this->unk_2F2 |= 0x20; + return true; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98BF4.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98CA8.s") +void func_80B97100(EnZot* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98E10.s") +void func_80B97110(EnZot* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98F30.s") + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x125F; + if (gSaveContext.weekEventReg[28] & 0x80) { + textId = 0x1261; + } else { + gSaveContext.weekEventReg[28] |= 0x80; + } + } else { + textId = 0x125C; + if (gSaveContext.weekEventReg[28] & 0x40) { + textId = 0x125E; + } else { + gSaveContext.weekEventReg[28] |= 0x40; + } + } + func_801518B0(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98F94.s") +void func_80B97194(EnZot* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x125C: + case 0x125F: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B990A4.s") + case 0x125D: + case 0x125E: + case 0x1260: + case 0x1261: + func_801477B4(globalCtx); + this->actionFunc = func_80B97240; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99160.s") +void func_80B97240(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97194; + func_80B97110(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsActorFacingLink(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B991E4.s") +void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B992C0.s") + if (gSaveContext.weekEventReg[29] & 0x10) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x126A; + if (gSaveContext.weekEventReg[29] & 1) { + textId = 0x126D; + } else { + gSaveContext.weekEventReg[29] |= 1; + } + } else { + textId = 0x1267; + if (gSaveContext.weekEventReg[29] & 2) { + textId = 0x1269; + } else { + gSaveContext.weekEventReg[29] |= 2; + } + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x1265; + if (gSaveContext.weekEventReg[29] & 4) { + textId = 0x1266; + } else { + gSaveContext.weekEventReg[29] |= 4; + } + } else { + textId = 0x1262; + if (gSaveContext.weekEventReg[29] & 8) { + textId = 0x1264; + } else { + gSaveContext.weekEventReg[29] |= 8; + } + } + func_801518B0(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99384.s") +void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { + func_80B96D4C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x126E: + case 0x1270: + case 0x1273: + case 0x1274: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Update.s") + case 0x1272: + func_80151938(globalCtx, 0x126F); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99580.s") + case 0x126F: + func_801159EC(90); + func_80151938(globalCtx, 0x1270); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B995A4.s") + case 0x1275: + if (gSaveContext.rupees < 10) { + func_80151938(globalCtx, 0x1277); + } else { + func_80151938(globalCtx, 0x1278); + func_801159EC(-10); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99758.s") + case 0x1276: + func_80151938(globalCtx, 0x1275); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Draw.s") + case 0x1271: + case 0x1277: + case 0x1278: + case 0x1279: + func_801477B4(globalCtx); + func_80B965D0(this, globalCtx); + this->actor.flags &= ~0x10000; + this->actor.textId = 0; + this->actionFunc = func_80B97708; + if ((this->actor.cutscene != -1) && !(this->unk_2F2 & 1)) { + ActorCutscene_Stop(this->actor.cutscene); + } + this->unk_2F2 &= ~1; + break; + } + } + + if (this->unk_2F2 & 1) { + if (this->actor.cutscene == -1) { + this->unk_2F2 &= ~1; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_2F2 &= ~1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { + func_80B96D4C(this); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B973BC; + } else { + func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, 0); + } +} + +void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { + if (1) { + do { } while (0); } + + func_80B96D4C(this); + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + u16 temp = globalCtx->msgCtx.unk11F04; + u32 temp2; + + if ((temp == 0x1262) || (temp == 0x1267) || (temp == 0x126A) || (temp == 0x126B)) { + temp2 = temp; + func_80151938(globalCtx, temp2 + 1); + } else { + func_801477B4(globalCtx); + this->actionFunc = func_80B97708; + } + } +} + +void func_80B97708(EnZot* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 phi_v1; + + func_80B96D4C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B9765C; + func_80B972E8(this, globalCtx); + return; + } + + if (!(player->stateFlags1 & 0x2000000)) { + phi_v1 = func_80B96CE4(this); + } else { + phi_v1 = 0; + } + + if (phi_v1 != 0) { + gSaveContext.weekEventReg[29] |= 0x10; + this->actor.flags |= 0x10000; + if (phi_v1 == 5) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + this->actor.textId = 0x126E; + } else { + this->actor.textId = 0x1272; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + this->actor.textId = 0x1273; + } else { + this->actor.textId = 0x1276; + } + this->unk_2F2 |= 1; + func_80B975F8(this, globalCtx); + this->actionFunc = func_80B975F8; + } else if (func_80B96DF0(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (this->actor.textId == 0) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + switch (ENZOT_GET_1F(&this->actor)) { + case 2: + if (gSaveContext.weekEventReg[37] & 0x40) { + textId = 0x127E; + } else { + textId = 0x127C; + gSaveContext.weekEventReg[37] |= 0x40; + } + break; + + case 3: + if (gSaveContext.weekEventReg[38] & 1) { + textId = 0x1284; + } else { + textId = 0x1282; + gSaveContext.weekEventReg[38] |= 1; + } + break; + + default: + if (gSaveContext.weekEventReg[38] & 4) { + textId = 0x128A; + } else { + textId = 0x1288; + gSaveContext.weekEventReg[38] |= 4; + } + break; + } + } else { + switch (ENZOT_GET_1F(&this->actor)) { + case 2: + if (gSaveContext.weekEventReg[37] & 0x20) { + textId = 0x127B; + } else { + textId = 0x1279; + gSaveContext.weekEventReg[37] |= 0x20; + } + break; + + case 3: + if (gSaveContext.weekEventReg[37] & 0x80) { + textId = 0x1281; + } else { + textId = 0x127F; + gSaveContext.weekEventReg[37] |= 0x80; + } + break; + + default: + if (gSaveContext.weekEventReg[38] & 2) { + textId = 0x1287; + } else { + textId = 0x1285; + gSaveContext.weekEventReg[38] |= 2; + } + break; + } + } + func_801518B0(globalCtx, textId, &this->actor); + } +} + +void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { + if (func_80B96E5C(this)) { + this->actionFunc = func_80B97B5C; + func_80B96BEC(this, 0, 0); + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 1.5f; + } +} + +void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1279: + case 0x127C: + case 0x127F: + case 0x1282: + case 0x1285: + case 0x1288: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x127D: + case 0x127E: + case 0x1283: + case 0x1284: + case 0x1289: + case 0x128A: + func_801477B4(globalCtx); + if (!(this->unk_2F2 & 2)) { + this->unk_2F2 |= 2; + this->actionFunc = func_80B979DC; + func_80B96BEC(this, 1, 0); + } else { + this->actionFunc = func_80B97B5C; + } + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B97B5C; + break; + } + } +} + +void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97A44; + func_80B9787C(this, globalCtx); + } else if (func_80B96DF0(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x128C; + } else { + textId = 0x128B; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80B97CC8; + } +} + +void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97C40; + func_801518B0(globalCtx, 0x128B, &this->actor); + } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { + if (func_80B96E5C(this)) { + this->actionFunc = func_80B97CC8; + this->actor.speedXZ = 0.0f; + func_80B96BEC(this, 0, 0); + } else { + this->actor.speedXZ = 8.0f; + } + + if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 5.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_ZORA_WALK); + } +} + +void func_80B97E0C(EnZot* this, GlobalContext* globalCtx) { + if (this->unk_2F2 & 0x40) { + this->actionFunc = func_80B97D6C; + func_80B96BEC(this, 3, 0); + } +} + +void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { + if (1) { + do { } while (0); } + + if (this->unk_2F2 & 0x40) { + func_80B96BEC(this, 0, 0); + } + + if (!(this->unk_2F2 & 4)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x128C: + this->unk_2F2 &= ~4; + func_80B96BEC(this, 6, 2); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x128D: + case 0x128E: + case 0x128F: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1290: + func_801477B4(globalCtx); + this->actionFunc = func_80B97D6C; + this->unk_2F2 |= 4; + func_80B96BEC(this, 3, 0); + gSaveContext.weekEventReg[38] |= 8; + break; + + case 0x128B: + func_801477B4(globalCtx); + this->actionFunc = func_80B97FD0; + break; + } + } +} + +void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97E4C; + func_80B97BF8(this, globalCtx); + } else if (gSaveContext.weekEventReg[38] & 8) { + if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + this->unk_2F2 |= 4; + this->actionFunc = func_80B97E0C; + func_80B96BEC(this, 6, 2); + } + } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B980FC(EnZot* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.home.rot.x--; + } else if (func_80B96E5C(this)) { + this->actionFunc = func_80B97100; + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 8.0f; + if (this->unk_2F0 != 3) { + func_80B96BEC(this, 3, 0); + } + } +} + +void func_80B98178(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + s32 phi_v0; + + switch (ENZOT_GET_1F(&this->actor)) { + case 6: + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (CURRENT_DAY == 3) { + textId = 0x129D; + } else if (gSaveContext.weekEventReg[39] & 1) { + textId = 0x129C; + } else { + textId = 0x129B; + gSaveContext.weekEventReg[39] |= 1; + } + } else if (gSaveContext.weekEventReg[38] & 0x80) { + textId = 0x1293; + } else { + textId = 0x1291; + gSaveContext.weekEventReg[38] |= 0x80; + } + break; + + case 7: + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[39] & 4) { + textId = 0x12AA; + } else { + textId = 0x12A6; + gSaveContext.weekEventReg[39] |= 4; + } + } else if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + textId = 0x12A0; + } else if (gSaveContext.weekEventReg[39] & 2) { + textId = 0x12A5; + } else { + textId = 0x12A2; + gSaveContext.weekEventReg[39] |= 2; + } + break; + + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + phi_v0 = (ENZOT_GET_1F(&this->actor) * 4) - 44; + if (gSaveContext.weekEventReg[79] & 1) { + phi_v0 += 2; + } + + if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + phi_v0++; + } + textId = phi_v0 + 0x1302; + break; + + default: + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x129F; + } else { + textId = 0x1295; + } + break; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B98348(EnZot* this, GlobalContext* globalCtx) { + s16 y; + + if (ENZOT_GET_1F(&this->actor) == 7) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (Actor_IsActorFacingLink(&this->actor, 0x3000)) { + this->unk_2F2 &= ~8; + } else { + this->unk_2F2 |= 8; + Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.x, 0, 6, 6200, 100); + y = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (y > 0) { + Math_SmoothStepToS(&this->unk_2C4.y, 0x3000, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.y, 0x1000, 6, 6200, 100); + } else { + Math_SmoothStepToS(&this->unk_2C4.y, -0x3000, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.y, -0x1000, 6, 6200, 100); + } + } +} + +void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { + func_80B98348(this, globalCtx); + if (func_800B84D0(&this->actor, globalCtx)) { + if (this->unk_2D4 == 2) { + func_801518B0(globalCtx, 0x12AD, &this->actor); + } else { + func_801518B0(globalCtx, 0x12B0, &this->actor); + } + this->actionFunc = func_80B98728; + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { + func_80B98348(this, globalCtx); + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B9849C; + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + func_800B8A1C(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); + } +} + +void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { + s32 temp_v0; + Player* player = PLAYER; + + func_80B98348(this, globalCtx); + if (func_80152498(&globalCtx->msgCtx) == 0x10) { + temp_v0 = func_80123810(globalCtx); + if (temp_v0 > 0) { + func_801477B4(globalCtx); + if ((temp_v0 == 0x13) && CHECK_QUEST_ITEM(25) && func_8013A4C4(4)) { + if (func_8013A4C4(5) && func_8013A4C4(6)) { + player->actor.textId = 0x12AE; + } else { + player->actor.textId = 0x12AC; + } + REMOVE_QUEST_ITEM(25); + } else { + player->actor.textId = 0x12AB; + } + this->actionFunc = func_80B98728; + } else if (temp_v0 < 0) { + func_80151938(globalCtx, 0x12AB); + this->actionFunc = func_80B98728; + } + } +} + +void func_80B98728(EnZot* this, GlobalContext* globalCtx) { + func_80B98348(this, globalCtx); + + switch (func_80152498(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(globalCtx, 0x1294); + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0x1298); + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1291: + case 0x1292: + case 0x1296: + case 0x1298: + case 0x1299: + case 0x129B: + case 0x129D: + case 0x129E: + case 0x12A0: + case 0x12A2: + case 0x12A3: + case 0x12A4: + case 0x12A6: + case 0x12A7: + case 0x12A8: + case 0x12AE: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x12A9: + case 0x12AA: + func_80151938(globalCtx, 0xFF); + this->actionFunc = func_80B985EC; + break; + + case 0x1294: + if (CURRENT_DAY == 3) { + func_80151938(globalCtx, 0x1296); + } else { + func_80151938(globalCtx, 0x1295); + } + break; + + case 0x12AB: + func_801477B4(globalCtx); + this->actionFunc = func_80B98998; + break; + + case 0x12AC: + func_801477B4(globalCtx); + this->unk_2D4 = 2; + this->actionFunc = func_80B9854C; + func_80B9854C(this, globalCtx); + break; + + case 0x12AF: + func_801477B4(globalCtx); + this->unk_2D4 = 4; + this->actionFunc = func_80B9854C; + func_80B9854C(this, globalCtx); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B98998; + this->actor.flags &= ~0x10000; + break; + } + } + break; + } +} + +void func_80B98998(EnZot* this, GlobalContext* globalCtx) { + this->unk_2F2 &= ~8; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B98728; + func_80B98178(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsActorFacingLink(&this->actor, 0x7000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[39] & 0x80) { + textId = 0x12B6; + } else { + textId = 0x12B4; + gSaveContext.weekEventReg[39] |= 0x80; + } + } else if (gSaveContext.weekEventReg[39] & 0x40) { + textId = 0x12B3; + } else { + textId = 0x12B1; + gSaveContext.weekEventReg[39] |= 0x40; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x12B1: + case 0x12B4: + case 0x12B7: + case 0x12B9: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x12B8: + func_801477B4(globalCtx); + this->actionFunc = func_80B98CA8; + gSaveContext.weekEventReg[41] &= (u8)~0x20; + func_8019C300(0); + break; + + case 0x12BA: + func_801477B4(globalCtx); + this->actionFunc = func_80B98CA8; + gSaveContext.weekEventReg[41] |= 0x20; + func_8019C300(0); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B98CA8; + break; + } + } +} + +void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + if (gSaveContext.weekEventReg[41] & 0x20) { + func_801518B0(globalCtx, 0x12B7, &this->actor); + this->actionFunc = func_80B98AD0; + } else { + func_801518B0(globalCtx, 0x12B9, &this->actor); + this->actionFunc = func_80B98AD0; + } + } else { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { + if (func_800B8718(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk1202A = 4; + func_8019B544(0xFFFF); + this->actionFunc = func_80B98BF4; + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 120.0f); + } else if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B98AD0; + func_80B98A4C(this, globalCtx); + } else { + if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { + func_800B874C(&this->actor, globalCtx, 120.0, 100.0f); + } + } + + if (this->actor.xzDistToPlayer > 100.0f) { + gSaveContext.weekEventReg[41] &= (u8)~0x20; + } +} + +void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + if (gSaveContext.weekEventReg[40] & 4) { + textId = 0x12C5; + } else { + textId = 0x12C3; + gSaveContext.weekEventReg[40] |= 4; + } + } else if (gSaveContext.weekEventReg[40] & 2) { + textId = 0x12C2; + } else { + textId = 0x12C0; + gSaveContext.weekEventReg[40] |= 2; + } + } else { + if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + if (this->unk_2F2 & 0x10) { + textId = 0x12BF; + } else { + textId = 0x12BE; + this->unk_2F2 |= 0x10; + } + } else if (gSaveContext.weekEventReg[40] & 1) { + textId = 0x12BC; + } else { + gSaveContext.weekEventReg[40] |= 1; + this->unk_2F2 |= 4; + textId = 0x12BB; + } + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B990A4; + } else { + func_800B8A1C(&this->actor, globalCtx, 2, 10000.0f, 50.0f); + } +} + +void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { + if (!(this->unk_2F2 & 4)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x12BB: + this->unk_2F2 &= ~4; + + case 0x12BC: + case 0x12C0: + case 0x12C3: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x12BE: + func_801477B4(globalCtx); + this->actionFunc = func_80B98F30; + func_80B98F30(this, globalCtx); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B990A4; + break; + } + } +} + +void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B98F94; + func_80B98E10(this, globalCtx); + } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B99160(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[40] & 0x10) { + textId = 0x12CD; + } else { + textId = 0x12CA; + gSaveContext.weekEventReg[40] |= 0x10; + } + } else if (gSaveContext.weekEventReg[40] & 8) { + textId = 0x12C9; + } else { + textId = 0x12C6; + gSaveContext.weekEventReg[40] |= 8; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { + if (1) { + do { } while (0); } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + u16 temp = globalCtx->msgCtx.unk11F04; + u32 temp2; + + if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { + temp2 = temp; + func_80151938(globalCtx, temp2 + 1); + } else { + func_801477B4(globalCtx); + this->actionFunc = func_80B992C0; + func_80B96BEC(this, 1, 0); + } + } +} + +void func_80B992C0(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B991E4; + func_80B99160(this, globalCtx); + this->actor.speedXZ = 0.0f; + func_80B96BEC(this, 0, 0); + } else { + if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + this->actor.speedXZ = 1.5f; + func_80B96FB0(this); + } +} + +void func_80B99384(EnZot* this, GlobalContext* globalCtx) { +} + +void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZot* this = THIS; + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); + + this->unk_2F2 &= ~0x40; + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2F0 != 0)) { + this->unk_2F2 |= 0x40; + } + + this->actionFunc(this, globalCtx); + if (!(this->unk_2F2 & 8)) { + if (!(this->unk_2F2 & 4) && func_80B96DF0(this, globalCtx)) { + func_800E9250(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2C4.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.y, 0, 6, 6200, 100); + } + } + + if (DECR(this->unk_2EE) == 0) { + this->unk_2EE = Rand_S16Offset(60, 60); + } + + this->unk_2EC = this->unk_2EE; + if (this->unk_2EC > 2) { + this->unk_2EC = 0; + } +} + +Gfx* func_80B99580(GraphicsContext* gfxCtx) { + Gfx* dList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(dList); + + return dList; +} + +s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZot* this = THIS; + s32 pad; + + if (limbIndex == 15) { + SysMatrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); + SysMatrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == 8) { + SysMatrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); + } + + if (((this->unk_2F0 == 8) || (this->unk_2F0 == 9)) && + ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13))) { + rot->y += (s16)(Math_SinS(globalCtx->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(globalCtx->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); + } + return false; +} + +void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80B99934 = { 400.0f, 0.0f, 0.0f }; + EnZot* this = THIS; + + if (limbIndex == 15) { + SysMatrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + } +} + +void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx) { + UNK_PTR sp4C[] = { + &D_060050A0, + &D_060058A0, + &D_060060A0, + }; + EnZot* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk_2EC])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80B99580(globalCtx->state.gfxCtx)); + + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnZot_OverrideLimbDraw, EnZot_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.h b/src/overlays/actors/ovl_En_Zot/z_en_zot.h index 0a5b8137a2..06fb724ae2 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.h +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.h @@ -7,9 +7,25 @@ struct EnZot; typedef void (*EnZotActionFunc)(struct EnZot*, GlobalContext*); +#define ENZOT_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENZOT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnZot { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1B4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; + /* 0x01D4 */ Vec3s jointTable[20]; + /* 0x024C */ Vec3s morphTable[20]; + /* 0x02C4 */ Vec3s unk_2C4; + /* 0x02CA */ Vec3s unk_2CA; + /* 0x02D0 */ Path* path; + /* 0x02D4 */ s32 unk_2D4; + /* 0x02D8 */ Actor* unk_2D8[5]; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ u16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; /* 0x02F8 */ EnZotActionFunc actionFunc; } EnZot; // size = 0x2FC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 67d5f16321..2dd3d78eba 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14940,8 +14940,8 @@ 0x80B99384:("func_80B99384",), 0x80B99394:("EnZot_Update",), 0x80B99580:("func_80B99580",), - 0x80B995A4:("func_80B995A4",), - 0x80B99758:("func_80B99758",), + 0x80B995A4:("EnZot_OverrideLimbDraw",), + 0x80B99758:("EnZot_PostLimbDraw",), 0x80B99798:("EnZot_Draw",), 0x80B9A0B0:("ObjTree_Init",), 0x80B9A1BC:("ObjTree_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index a3ecdeadeb..4441d7553a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3783,9 +3783,20 @@ D_06015238 = 0x06015238; // ovl_En_Zot +D_06002898 = 0x06002898; D_06004248 = 0x06004248; +D_060050A0 = 0x060050A0; +D_060058A0 = 0x060058A0; +D_060060A0 = 0x060060A0; D_0600D208 = 0x0600D208; D_0600DE20 = 0x0600DE20; +D_0600DF54 = 0x0600DF54; +D_0600E400 = 0x0600E400; +D_0600EDF0 = 0x0600EDF0; +D_0600F4E8 = 0x0600F4E8; +D_0600FDF0 = 0x0600FDF0; +D_06010B18 = 0x06010B18; +D_06011424 = 0x06011424; // ovl_En_Zov