From a35f091505b1d744d3e397b46839f5b408795cd9 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 8 Aug 2021 19:05:52 +0100 Subject: [PATCH] En_Dno (#238) * En_Dno * NBS * PR * PR --- include/functions.h | 10 +- include/macros.h | 1 + include/variables.h | 2 +- include/z64actor.h | 25 + include/z64item.h | 1 + spec | 3 +- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h | 4 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 998 +++++++++++++++++- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 51 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 8 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 8 +- undefined_syms.txt | 20 + 12 files changed, 1061 insertions(+), 70 deletions(-) diff --git a/include/functions.h b/include/functions.h index 58d3abde2d..e81ad1cfd6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2725,17 +2725,17 @@ Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, struct Actor* act void func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, UNK_TYPE arg3); u8 func_8013DB90(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); // void func_8013DC40(void); -// void func_8013DCE0(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_TYPE1 param_10); -// void func_8013DE04(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8013DF3C(void); +void func_8013DCE0(GlobalContext* globalCtx, Vec3f* param_2, Actor* actor, EnDno_ActorUnkStruct* param_4, Path* param_5, s32 param_6, s32 param_7, s32 param_8, s32 param_9, s32 param_10); +void func_8013DE04(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1, EnDno_ActorUnkFunc arg2, EnDno_ActorUnkFunc arg3, EnDno_ActorUnkFunc arg4, EnDno_ActorUnkFunc arg5); +s32 func_8013DF3C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1); // void func_8013E054(void); // void func_8013E07C(void); -// void func_8013E0A4(void); +s32 func_8013E0A4(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1); void func_8013E1C8(SkelAnime* skelAnime, struct_80B8E1A8 animations[], s32 animationIndex, s32* actorAnimationIndex); s32 func_8013E2D4(Actor* actor, s16 arg1, s32 arg2, s32 arg3); s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s32 cutsceneArrayLen); // void func_8013E4B0(void); -// void func_8013E5CC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +s32 func_8013E5CC(Vec3f* param_1, Vec3s* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6); // void func_8013E640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8013E748(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); // void func_8013E7C0(void); diff --git a/include/macros.h b/include/macros.h index 90bba74e97..6188a085fd 100644 --- a/include/macros.h +++ b/include/macros.h @@ -49,6 +49,7 @@ #define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg) - 4) diff --git a/include/variables.h b/include/variables.h index f3643ef203..531ab0eafb 100644 --- a/include/variables.h +++ b/include/variables.h @@ -4063,7 +4063,7 @@ extern Gfx D_04077480[]; extern UNK_TYPE D_04079B10; extern UNK_TYPE D_0407AB10; extern UNK_TYPE D_0407AFB0; -extern UNK_TYPE D_0407D590; +extern Gfx D_0407D590[]; extern UNK_TYPE D_0407D650; extern UNK_TYPE D_0407F218; extern UNK_TYPE D_040815D0; diff --git a/include/z64actor.h b/include/z64actor.h index 59255a42ad..a39411bbbb 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -76,6 +76,31 @@ typedef struct { /* 0x3A */ s16 unk3A; } ActorEnTest20C; // size = 0x3C +struct EnDno_ActorUnkStruct; +typedef s32 (*EnDno_ActorUnkFunc)(struct GlobalContext*, struct EnDno_ActorUnkStruct*); + +typedef struct EnDno_ActorUnkStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ UNK_TYPE1 unk_0C[0x4]; + /* 0x10 */ s16 unk_10; + /* 0x12 */ UNK_TYPE1 unk_12[0xA]; + /* 0x1C */ u8 unk_1C; + /* 0x1D */ u8 unk_1D; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; + /* 0x38 */ UNK_TYPE1 unk_38[0x10]; + /* 0x48 */ struct Actor* unk_48; + /* 0x4C */ f32 unk_4C; + /* 0x50 */ f32 unk_50; + /* 0x54 */ s16 unk_54; + /* 0x56 */ s16 unk_56; + /* 0x58 */ s32 unk_58; + /* 0x5C */ EnDno_ActorUnkFunc unk_5C; + /* 0x60 */ EnDno_ActorUnkFunc unk_60; + /* 0x64 */ EnDno_ActorUnkFunc unk_64; + /* 0x68 */ EnDno_ActorUnkFunc unk_68; +} EnDno_ActorUnkStruct; // size >= 0x6C + typedef struct { /* 0x00 */ s16 id; /* 0x02 */ u8 type; diff --git a/include/z64item.h b/include/z64item.h index 93bc507245..3e7095efb7 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -37,6 +37,7 @@ typedef enum { /* 0x3B */ ITEM_MASK_GARO, /* 0x3C */ ITEM_MASK_ROMANIS, /* 0x46 */ ITEM_MASK_BREMEN = 0x46, + /* 0x48 */ ITEM_MASK_SCENTS = 0x48, /* 0x4D */ ITEM_SWORD_KOKIRI = 0x4D, /* 0x4E */ ITEM_SWORD_RAZOR, /* 0x4F */ ITEM_SWORD_GILDED, diff --git a/spec b/spec index fb65f7e208..df2d705b2e 100644 --- a/spec +++ b/spec @@ -3206,8 +3206,7 @@ beginseg name "ovl_En_Dno" compress include "build/src/overlays/actors/ovl_En_Dno/z_en_dno.o" - include "build/data/ovl_En_Dno/ovl_En_Dno.data.o" - include "build/data/ovl_En_Dno/ovl_En_Dno.reloc.o" + include "build/src/overlays/actors/ovl_En_Dno/ovl_En_Dno_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h index d13258d48e..7e8c1c2967 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h @@ -11,7 +11,9 @@ typedef struct BgCraceMovebg { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x18]; /* 0x015C */ BgCraceMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x34]; + /* 0x0160 */ char unk_160[0x10]; + /* 0x0170 */ s32 unk_170; + /* 0x0174 */ char unk_174[0x20]; } BgCraceMovebg; // size = 0x194 extern const ActorInit Bg_Crace_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 4b6dc51d54..b39ac66408 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -1,4 +1,11 @@ +/* + * File: z_en_dno.c + * Overlay: ovl_En_Dno + * Description: Deku Butler + */ + #include "z_en_dno.h" +#include "overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h" #define FLAGS 0x00000039 @@ -10,20 +17,60 @@ void EnDno_Update(Actor* thisx, GlobalContext* globalCtx); void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80A71B04(EnDno* this, GlobalContext* globalCtx); -void func_80A71B58(EnDno* this, GlobalContext* globalCtx); +void EnDno_DoNothing(EnDno* this, GlobalContext* globalCtx); void func_80A71B68(EnDno* this, GlobalContext* globalCtx); void func_80A71C3C(EnDno* this, GlobalContext* globalCtx); +void func_80A71E54(EnDno* this, GlobalContext* globalCtx); void func_80A71F18(EnDno* this, GlobalContext* globalCtx); void func_80A72438(EnDno* this, GlobalContext* globalCtx); void func_80A724B8(EnDno* this, GlobalContext* globalCtx); -void func_80A72598(EnDno* this, GlobalContext* globalCtx); +void func_80A725E0(EnDno* this, GlobalContext* globalCtx); void func_80A725F8(EnDno* this, GlobalContext* globalCtx); +void func_80A72AE4(EnDno* this, GlobalContext* globalCtx); void func_80A72B3C(EnDno* this, GlobalContext* globalCtx); +void func_80A72B84(EnDno* this, GlobalContext* globalCtx); void func_80A72BA4(EnDno* this, GlobalContext* globalCtx); +void func_80A72C04(EnDno* this, GlobalContext* globalCtx); +void func_80A72CF8(EnDno* this, GlobalContext* globalCtx); void func_80A730A0(EnDno* this, GlobalContext* globalCtx); +void func_80A73244(EnDno* this, GlobalContext* globalCtx); void func_80A732C8(EnDno* this, GlobalContext* globalCtx); +s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); + +extern AnimationHeader D_06000470; +extern AnimationHeader D_060008F0; +extern AnimationHeader D_06000F6C; +extern AnimationHeader D_06001A50; +extern AnimationHeader D_06002530; +extern AnimationHeader D_06003320; +extern AnimationHeader D_060036D0; +extern AnimationHeader D_060041CC; +extern AnimationHeader D_06004DD8; +extern AnimationHeader D_060051E4; +extern AnimationHeader D_06005E20; +extern AnimationHeader D_06005F98; +extern AnimationHeader D_06006488; +extern AnimationHeader D_06006F84; +extern AnimationHeader D_060073E4; +extern AnimationHeader D_060077A8; +extern AnimationHeader D_06007CA4; +extern AnimationHeader D_06008324; +extern AnimationHeader D_06008AE4; +extern AnimationHeader D_06009100; +extern FlexSkeletonHeader D_0600E1F8; +extern u8 D_801C20C0; + +static struct_80B8E1A8 sAnimations[] = { + { &D_06000470, 1.0f, 2, 0.0f }, { &D_060008F0, 1.0f, 2, 0.0f }, { &D_06000F6C, 1.0f, 0, 0.0f }, + { &D_06001A50, 1.0f, 2, 0.0f }, { &D_06002530, 1.0f, 2, 0.0f }, { &D_06003320, 1.0f, 2, 0.0f }, + { &D_060036D0, 1.0f, 0, 0.0f }, { &D_060041CC, 1.0f, 2, 0.0f }, { &D_06004DD8, 1.0f, 2, 0.0f }, + { &D_06005F98, 1.0f, 0, 0.0f }, { &D_06006488, 1.0f, 2, 0.0f }, { &D_060073E4, 1.0f, 0, 0.0f }, + { &D_060077A8, 1.0f, 0, 0.0f }, { &D_06007CA4, 1.0f, 0, 0.0f }, { &D_06008324, 1.0f, 0, 0.0f }, + { &D_06008AE4, 1.0f, 2, 0.0f }, { &D_06009100, 1.0f, 2, 0.0f }, { &D_060051E4, 1.0f, 2, 0.0f }, + { &D_06005E20, 1.0f, 0, 0.0f }, { &D_06006F84, 1.0f, 0, 0.0f }, +}; -#if 0 const ActorInit En_Dno_InitVars = { ACTOR_EN_DNO, ACTORCAT_NPC, @@ -36,94 +83,947 @@ const ActorInit En_Dno_InitVars = { (ActorFunc)EnDno_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A73B00 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, 58, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A73B38[] = { +static Vec3f D_80A73B2C = { 0.0f, 0.0f, 1.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 80, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -#endif +void func_80A711D0(EnDno* this, GlobalContext* globalCtx, Vec3f* vec) { + f32 rand = Rand_ZeroOne() * 0.5f; -extern ColliderCylinderInit D_80A73B00; -extern InitChainEntry D_80A73B38[]; + Lights_PointGlowSetInfo(&this->lightInfo, vec->x, vec->y, vec->z, (127.5f * rand) + 127.5f, + (100.0f * rand) + 100.0f, (40.0f * rand) + 40.0f, 320); +} -extern UNK_TYPE D_06007CA4; +s32 func_80A71424(s16* arg0, s16 arg1, s16 yawToPlayer, s16 rotY, s16 arg4, s16 arg5) { + s16 temp_v0 = yawToPlayer - rotY; + s32 ret; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A711D0.s") + if (arg4 >= ABS(temp_v0)) { + ret = Math_ScaledStepToS(arg0, arg1 + temp_v0, arg5); + } else { + ret = Math_ScaledStepToS(arg0, arg1, arg5); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71424.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A714B4.s") +void func_80A714B4(EnDno* this, GlobalContext* globalCtx) { + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A7153C.s") + do { + actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + if (actor != NULL) { + if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { + Actor_SetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); + } + actor = actor->next; + } + } while (actor != NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A715DC.s") +// Unused? +void func_80A7153C(EnDno* this, Vec3f* arg1, Vec3f* arg2) { + f32 sp1C = Math_CosS(this->actor.home.rot.y); + f32 sp18 = Math_SinS(this->actor.home.rot.y); + f32 temp_f2 = arg2->x - this->actor.home.pos.x; + f32 temp_f12 = arg2->z - this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71788.s") + arg1->x = (temp_f2 * sp1C) - (temp_f12 * sp18); + arg1->z = (temp_f12 * sp1C) + (temp_f2 * sp18); + arg1->y = arg2->y - this->actor.home.pos.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/EnDno_Init.s") +void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { + BgCraceMovebg* crace = NULL; + s32 pad[2]; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/EnDno_Destroy.s") + do { + crace = + (BgCraceMovebg*)func_ActorCategoryIterateById(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + if (crace != NULL) { + if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { + if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, + &this->actor.world.pos, &sp88)) { + Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); + Matrix_RotateY(-crace->actor.home.rot.y, 0); + SysMatrix_MultiplyVector3fByState(&sp7C, &sp70); + if ((fabsf(sp70.x) < 100.0f) && (sp70.y >= -10.0f) && (sp70.y <= 180.0f) && (sp70.z < 0.0f)) { + crace->unk_170 |= 1; + } + } + } + crace = (BgCraceMovebg*)crace->actor.next; + } + } while (crace != NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71B04.s") +void func_80A71788(EnDno* this, GlobalContext* globalCtx) { + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71B58.s") + do { + actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + if (actor != NULL) { + Actor_UnsetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); + actor = actor->next; + } + } while (actor != NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71B68.s") +void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDno* this = THIS; + s32 pad; + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71C3C.s") + while (true) { + actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_DNO); + if (actor != NULL) { + if (actor != thisx) { + Actor_MarkForDeath(thisx); + break; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71E54.s") + if (actor == NULL) { + Actor_ProcessInitChain(thisx, sInitChain); + ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 21.0f); + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600E1F8, &D_06007CA4, this->jointTable, this->morphTable, + 28); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[14].animationSeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(&(sAnimations[14].animationSeg)->common), sAnimations[14].mode, + sAnimations[14].transitionRate); + this->unk_3BE = 0x3E93; + this->unk_3C0 = 60.0f; + this->unk_3B0 = 0; + this->unk_468 = 99; + this->skelAnime.animPlaybackSpeed = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A71F18.s") + switch (ENDNO_GET_C000(thisx)) { + case ENDNO_GET_C000_0: + func_80A71788(this, globalCtx); + if (!(gSaveContext.weekEventReg[23] & 0x20) || (gSaveContext.weekEventReg[93] & 2)) { + Actor_MarkForDeath(thisx); + } else { + func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + thisx->room = -1; + gSaveContext.unk_3DD0[1] = 5; + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->unk_3B0 |= 1; + this->actionFunc = func_80A72438; + this->unk_454 = 0.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72438.s") + case ENDNO_GET_C000_1: + if (gSaveContext.weekEventReg[23] & 0x20) { + Actor_MarkForDeath(thisx); + } else { + func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + this->unk_460 = func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); + if (this->unk_460 == NULL) { + Actor_MarkForDeath(thisx); + } else { + this->actionFunc = func_80A71B68; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A724B8.s") + default: + this->actionFunc = func_80A71B04; + break; + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A7256C.s") +void EnDno_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDno* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72598.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A725E0.s") +void func_80A71B04(EnDno* this, GlobalContext* globalCtx) { + this->unk_452 = 0; + func_8013E1C8(&this->skelAnime, sAnimations, 19, &this->unk_32C); + this->actionFunc = EnDno_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A725F8.s") +void EnDno_DoNothing(EnDno* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72AE4.s") +void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { + this->unk_452 = 0; + this->actor.textId = 0; + if (CHECK_QUEST_ITEM(6)) { + if (gSaveContext.weekEventReg[27] & 1) { + if (!(this->unk_3B0 & 0x20)) { + func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); + } + } else { + func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + } + } else { + func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + } + this->actionFunc = func_80A71C3C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72B3C.s") +void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { + switch (this->unk_32C) { + case 9: + case 16: + func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72B84.s") + case 3: + case 10: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72BA4.s") + case 11: + func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72C04.s") + case 15: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72CF8.s") + case 6: + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 2, 0xE38, + 0x222); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72D8C.s") + if ((this->unk_32C == 13) && (this->actor.xzDistToPlayer <= 120.0f)) { + func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.shape.rot.y, 0x2000, 0x16C); + } else { + Math_ScaledStepToS(&this->unk_466, 0, 0x16C); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A72FAC.s") + if ((this->unk_32C != 3) && (this->unk_32C != 15) && (this->unk_32C != 6)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x222); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A730A0.s") + if (func_800B84D0(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80A71E54(this, globalCtx); + } else if (this->actor.xzDistToPlayer < 60.0f) { + func_800B8614(&this->actor, globalCtx, 60.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A73244.s") +void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { + if (CHECK_QUEST_ITEM(6)) { + if (gSaveContext.weekEventReg[27] & 1) { + this->unk_464 = 0x811; + } else { + this->unk_464 = 0x80F; + gSaveContext.weekEventReg[27] |= 1; + } + } else if (gSaveContext.weekEventReg[26] & 0x80) { + this->unk_464 = 0x80B; + } else { + this->unk_464 = 0x80C; + gSaveContext.weekEventReg[26] |= 0x80; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A732C8.s") + if (this->unk_464 != 0x811) { + this->unk_3B0 |= 0x10; + } else { + this->unk_3B0 &= ~0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A73408.s") + this->actionFunc = func_80A71F18; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/EnDno_Update.s") +void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { + Math_ScaledStepToS(&this->unk_466, 0, 0x16C); + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + if (!(this->unk_3B0 & 0x10) || + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { + switch (this->unk_464) { + case 0x80B: + func_8013E1C8(&this->skelAnime, sAnimations, 16, &this->unk_32C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/EnDno_Draw.s") + case 0x811: + func_801518B0(globalCtx, this->unk_464, &this->actor); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A7361C.s") + case 0x80C: + case 0x80F: + if (this->unk_32C == 13) { + func_8013E1C8(&this->skelAnime, sAnimations, 4, &this->unk_32C); + } else if ((this->unk_32C == 4) && + (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount)) { + func_8013E1C8(&this->skelAnime, sAnimations, 11, &this->unk_32C); + func_801518B0(globalCtx, this->unk_464, &this->actor); + } + break; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dno/func_80A73654.s") + case 3: + if (globalCtx->msgCtx.unk11F04 == 0x80B) { + switch (this->unk_32C) { + case 16: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + } + Math_ScaledStepToS(&this->actor.shape.rot.y, + Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); + break; + + case 10: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_801477B4(globalCtx); + func_8013E1C8(&this->skelAnime, sAnimations, 0xD, &this->unk_32C); + func_80A71B68(this, globalCtx); + } + break; + } + } + break; + + case 4: + case 5: + case 6: + switch (globalCtx->msgCtx.unk11F04) { + case 0x80B: + switch (this->unk_32C) { + case 16: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + } + break; + + case 9: + if (func_80147624(globalCtx)) { + func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + globalCtx->msgCtx.unk11F22 = 0x44; + } + break; + + case 10: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_801477B4(globalCtx); + func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + func_80A71B68(this, globalCtx); + } + break; + } + break; + + case 0x80C: + if (func_80147624(globalCtx)) { + func_80151938(globalCtx, 0x80D); + } + break; + + case 0x80D: + if (func_80147624(globalCtx)) { + func_80151938(globalCtx, 0x80E); + } + break; + + case 0x80E: + if (this->unk_32C == 11) { + func_8013E1C8(&this->skelAnime, sAnimations, 3, &this->unk_32C); + } else if (this->unk_32C == 3) { + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + } + } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80A71B68(this, globalCtx); + } + break; + + case 0x80F: + if (func_80147624(globalCtx)) { + func_80151938(globalCtx, 0x810); + } + break; + + case 0x810: + if (func_80147624(globalCtx)) { + this->unk_3B0 |= 0x20; + func_801477B4(globalCtx); + func_80A71B68(this, globalCtx); + break; + } + + switch (this->unk_32C) { + case 11: + func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + break; + + case 15: + if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + } + break; + } + break; + + case 0x811: + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80A71B68(this, globalCtx); + } + break; + } + break; + } +} + +void func_80A72438(EnDno* this, GlobalContext* globalCtx) { + this->unk_452 = 1; + func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + this->actor.textId = 0; + if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { + this->unk_454 = 1.0f; + } + this->actionFunc = func_80A724B8; +} + +void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 120.0f) { + func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.home.rot.y, 0x2000, 0x2D8); + } + + if (func_800B84D0(&this->actor, globalCtx)) { + func_80A725E0(this, globalCtx); + } else if (this->actor.xzDistToPlayer < 60.0f) { + func_800B8614(&this->actor, globalCtx, 60.0f); + } +} + +void func_80A7256C(EnDno* this, GlobalContext* globalCtx) { + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, -1); +} + +void func_80A72598(EnDno* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + func_80A725E0(this, globalCtx); + } else { + func_80A7256C(this, globalCtx); + } +} + +void func_80A725E0(EnDno* this, GlobalContext* globalCtx) { + this->actionFunc = func_80A725F8; +} + +void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { + s32 pad[2]; + + func_80A71424(&this->unk_466, 0, 0, 0, 0x2000, 0x16C); + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + switch (this->unk_328) { + case 0: + if (this->unk_32C == 14) { + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { + func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + } + } else if ((this->unk_32C == 5) && + func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { + func_801518B0(globalCtx, 0x801, &this->actor); + } else if (Player_GetMask(globalCtx) == PLAYER_MASK_MASK_OF_SCENTS) { + func_801518B0(globalCtx, 0x806, &this->actor); + } else { + func_801518B0(globalCtx, 0x800, &this->actor); + } + func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + } + break; + + case 2: + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { + gSaveContext.weekEventReg[93] |= 2; + func_801518B0(globalCtx, 0x802, &this->actor); + } + break; + + case 3: + func_801518B0(globalCtx, 0x804, &this->actor); + break; + } + break; + + case 1: + case 2: + case 3: + if (((globalCtx->msgCtx.unk11F04 == 0x800) || (globalCtx->msgCtx.unk11F04 == 0x801)) && + (this->unk_32C == 8)) { + Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); + if (this->skelAnime.animCurrentFrame <= 23.0f) { + this->unk_452 = 3; + if (func_801378B8(&this->skelAnime, 23.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_OPEN_AMBRELLA); + } + } else if (this->skelAnime.animCurrentFrame <= 24.0f) { + this->unk_452 = 4; + } else if (this->skelAnime.animCurrentFrame >= 25.0f) { + this->unk_452 = 2; + } + + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + func_8013E1C8(&this->skelAnime, sAnimations, 12, &this->unk_32C); + func_801518B0(globalCtx, 0x803, &this->actor); + } + } + break; + + case 4: + case 5: + case 6: + switch (globalCtx->msgCtx.unk11F04) { + case 0x800: + case 0x801: + if (func_80147624(globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0x44; + this->unk_452 = 1; + this->unk_454 = 0.0f; + func_8013E1C8(&this->skelAnime, sAnimations, 8, &this->unk_32C); + } + break; + + case 0x802: + if (func_80147624(globalCtx)) { + if (gSaveContext.inventory.items[D_801C20C0] == ITEM_MASK_SCENTS) { + this->unk_458 = 4; + } else { + this->unk_458 = 142; + } + func_800B8A1C(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + func_801477B4(globalCtx); + func_80A72B84(this, globalCtx); + } + break; + + case 0x803: + if (func_80147624(globalCtx)) { + func_80A72AE4(this, globalCtx); + } + break; + + case 0x804: + if (this->unk_32C == 14) { + if (func_80147624(globalCtx)) { + func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + if (!(this->unk_3B0 & 0x40)) { + func_80A72CF8(this, globalCtx); + this->unk_3B0 |= 0x40; + } + } + } else if ((this->unk_32C == 5) && + (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount)) { + func_801477B4(globalCtx); + func_80A72438(this, globalCtx); + } + break; + + case 0x806: + if (func_80147624(globalCtx)) { + func_80151938(globalCtx, 0x800); + } + break; + + default: + func_80A72438(this, globalCtx); + break; + } + break; + } +} + +void func_80A72AE4(EnDno* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); + func_80A714B4(this, globalCtx); + this->actionFunc = func_80A72B3C; +} + +void func_80A72B3C(EnDno* this, GlobalContext* globalCtx) { + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + this->unk_44E = 0; + func_80A72C04(this, globalCtx); + } +} + +void func_80A72B84(EnDno* this, GlobalContext* globalCtx) { + this->unk_328 = 3; + this->actionFunc = func_80A72BA4; +} + +void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80A72598; + } else { + func_800B8A1C(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + } +} + +void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); + this->actor.flags |= 0x8000000; + this->actor.flags &= ~(8 | 1); + Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); + func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, + ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + func_8013DF3C(globalCtx, &this->unk_340); + this->actor.world.rot.y = this->unk_340.unk_56; + this->actor.world.rot.x = this->unk_340.unk_54; + Actor_SetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); + this->actionFunc = func_80A730A0; +} + +void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, this->actor.world.pos.x + 80.0f, + this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); +} + +s32 func_80A72D8C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { + Actor* actor = arg1->unk_48; + s32 pad; + s32 ret = false; + f32 sp38; + s16 temp_v0; + s32 temp_v0_2; + s32 sp2C; + + actor->gravity = 0.0f; + temp_v0 = actor->yawTowardsPlayer - actor->world.rot.y; + if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { + Math_SmoothStepToF(&actor->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + } else { + if (actor->xzDistToPlayer <= 80.0f) { + Math_SmoothStepToF(&actor->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); + } else if (actor->xzDistToPlayer <= 360.0f) { + Math_SmoothStepToF(&actor->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + } else { + Math_SmoothStepToF(&actor->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + } + } + + if (arg1->unk_50 < SQ(actor->speedXZ)) { + ret = true; + } else { + sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); + sp2C = ABS(arg1->unk_54 - actor->world.rot.x); + temp_v0_2 = sp2C; + temp_v0_2 *= sp38; + temp_v0_2 += 0x71C; + sp2C = ABS(arg1->unk_56 - actor->world.rot.y); + + Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54, temp_v0_2); + Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_56, (s32)(sp2C * sp38) + 0x71C); + } + + return ret; +} + +s32 func_80A72FAC(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { + Actor* actor = arg1->unk_48; + EnDno* dno = (EnDno*)actor; + f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; + f32 sp20 = gFramerateDivisorHalf; + + actor->velocity.x = Math_SinS(actor->world.rot.y) * sp24; + actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; + actor->velocity.z = Math_CosS(actor->world.rot.y) * sp24; + + dno->unk_334.x += (dno->actor.velocity.x * sp20) + dno->actor.colChkInfo.displacement.x; + dno->unk_334.y += (dno->actor.velocity.y * sp20) + dno->actor.colChkInfo.displacement.y; + dno->unk_334.z += (dno->actor.velocity.z * sp20) + dno->actor.colChkInfo.displacement.z; + + return 0; +} + +void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { + f32 temp_f10; + s32 phi_a2; + + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + phi_a2 = -1; + switch (this->unk_32C) { + case 0: + if (this->unk_44E >= 20) { + phi_a2 = 1; + } else { + this->unk_44E = 20; + } + break; + + case 1: + phi_a2 = 2; + break; + } + + if (phi_a2 >= 0) { + func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + } + } + + func_8013DE04(globalCtx, &this->unk_340, func_8013DF3C, func_80A72D8C, func_80A72FAC, func_8013E0A4); + this->unk_45C += 6553; + this->unk_340.unk_2C.x = 0.0f; + this->unk_340.unk_2C.y = 0.0f; + this->unk_340.unk_2C.z = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); + temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); + this->actor.world.pos.y += temp_f10; + this->unk_3AC += 4500; + this->unk_3AE += 1000; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + func_80A715DC(this, globalCtx); + func_800B9010(&this->actor, 0x2153); + if (this->unk_340.unk_1C & 0x20) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); + this->actor.speedXZ = 0.0f; + this->actor.velocity.x = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.z = 0.0f; + func_80A73244(this, globalCtx); + } +} + +void func_80A73244(EnDno* this, GlobalContext* globalCtx) { + this->actor.flags &= ~0x8000000; + this->actor.flags |= (8 | 1); + this->unk_328 = 2; + this->actor.speedXZ = 0.0f; + Actor_UnsetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); + gSaveContext.unk_3DD0[1] = 5; + this->unk_44E = 0; + this->actionFunc = func_80A732C8; +} + +void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { + s32 pad; + + if (this->unk_44E == 0) { + if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { + this->unk_3B0 |= 4; + this->unk_44E = 3; + func_8013E1C8(&this->skelAnime, sAnimations, 7, &this->unk_32C); + } + } else if (this->unk_44E == 3) { + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + func_80A72438(this, globalCtx); + } else { + if (this->skelAnime.animCurrentFrame >= 20.0f) { + Math_SmoothStepToF(&this->unk_454, 0.0f, 1.0f, 0.125f, 0.01f); + } + + if (func_801378B8(&this->skelAnime, 4.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); + this->unk_452 = 4; + } else if (func_801378B8(&this->skelAnime, 5.0f)) { + this->unk_452 = 3; + } + } + } + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); +} + +void func_80A73408(EnDno* this, GlobalContext* globalCtx) { + s32 phi_a2; + u8 sp33 = true; + u32 temp_v0; + + if (func_800EE29C(globalCtx, 0x1DB)) { + temp_v0 = func_800EE200(globalCtx, 0x1DB); + if (this->unk_468 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + phi_a2 = 13; + break; + + case 2: + phi_a2 = 17; + break; + + default: + phi_a2 = 0; + sp33 = false; + break; + } + + if (sp33) { + func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + } + } + func_800EDF24(&this->actor, globalCtx, temp_v0); + } + + if ((func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) && (this->unk_32C == 17)) { + if (0) {}; + func_8013E1C8(&this->skelAnime, sAnimations, 18, &this->unk_32C); + } +} + +void EnDno_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDno* this = THIS; + s32 pad; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + func_80A73408(this, globalCtx); + this->actionFunc(this, globalCtx); + if (this->unk_3B0 & 4) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_SetHeight(&this->actor, 51.0f); +} + +void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDno* this = THIS; + + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnDno_OverrideLimbDraw, EnDno_PostLimbDraw, &this->actor); +} + +s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnDno* this = THIS; + + *dList = NULL; + if (limbIndex == 9) { + rot->x += this->unk_466; + } + return false; +} + +void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80A73B40 = { 0.0f, 0.0f, 0.0f }; + Gfx* gfxOpa; + Gfx* gfxXlu; + Vec3f sp84; + EnDno* this = THIS; + s32 pad; + s32 phi_v0 = false; + + if (*dList != NULL) { + switch (this->unk_452) { + case 0: + if ((limbIndex != 25) && (limbIndex != 26) && (limbIndex != 13) && (limbIndex != 15) && + (limbIndex != 16) && (limbIndex != 14)) { + phi_v0 = true; + } + break; + + case 1: + if ((limbIndex != 26) && (limbIndex != 13) && (limbIndex != 15) && (limbIndex != 16) && + (limbIndex != 14)) { + phi_v0 = true; + } + break; + + case 2: + if ((limbIndex != 15) && (limbIndex != 16)) { + phi_v0 = true; + } + break; + + case 3: + if ((limbIndex != 16) && (limbIndex != 14)) { + phi_v0 = true; + } + break; + + case 4: + if ((limbIndex != 15) && (limbIndex != 14)) { + phi_v0 = true; + } + break; + } + } + + if (phi_v0 == true) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (limbIndex == 13) { + Matrix_Scale(this->unk_454, this->unk_454, this->unk_454, 1); + SysMatrix_InsertXRotation_s(this->unk_45C, 1); + } + + gfxOpa = POLY_OPA_DISP; + gSPMatrix(gfxOpa, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfxOpa[1], *dList); + + POLY_OPA_DISP = gfxOpa + 2; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if ((this->unk_3B0 & 1) && (limbIndex == 26)) { + u32 frames; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + SysMatrix_StatePush(); + frames = globalCtx->gameplayFrames; + SysMatrix_MultiplyVector3fByState(&D_80A73B40, &sp84); + func_80A711D0(this, globalCtx, &sp84); + SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(0.15f, 0.15f, 1.0f, 1); + SysMatrix_InsertTranslation(0.0f, -3200.0f, 0.0f, 1); + gfxXlu = func_8012C2B4(POLY_XLU_DISP); + + gSPMatrix(gfxXlu, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(&gfxXlu[1], 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); + gDPSetPrimColor(&gfxXlu[2], 0x80, 0x80, 255, 255, 0, 255); + gDPSetEnvColor(&gfxXlu[3], 255, 0, 0, 0); + gSPDisplayList(&gfxXlu[4], D_0407D590); + + POLY_XLU_DISP = gfxXlu + 5; + + SysMatrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index 9f0dd0d369..a99162694b 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -5,12 +5,55 @@ struct EnDno; -typedef void (*EnDnoActionFunc)(struct EnDno* this, GlobalContext* globalCtx); +typedef void (*EnDnoActionFunc)(struct EnDno*, GlobalContext*); + +#define ENDNO_GET_F(thisx) (u32)((thisx)->params & 0xF) +#define ENDNO_GET_7F(thisx) ((thisx)->params & 0x7F) +#define ENDNO_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) +#define ENDNO_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define ENDNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) + +enum { + /* 0x0 */ ENDNO_GET_F_0, + /* 0x1 */ ENDNO_GET_F_1, +}; + +enum { + /* 0x0 */ ENDNO_GET_C000_0, + /* 0x1 */ ENDNO_GET_C000_1, +}; typedef struct EnDno { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnDnoActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x324]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnDnoActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[28]; + /* 0x280 */ Vec3s morphTable[28]; + /* 0x328 */ s32 unk_328; + /* 0x32C */ s32 unk_32C; + /* 0x330 */ UNK_TYPE1 unk_330[0x4]; + /* 0x334 */ Vec3f unk_334; + /* 0x340 */ EnDno_ActorUnkStruct unk_340; + /* 0x3AC */ s16 unk_3AC; + /* 0x3AE */ s16 unk_3AE; + /* 0x3B0 */ u16 unk_3B0; + /* 0x3B2 */ UNK_TYPE1 unk_3B2[0xC]; + /* 0x3BE */ s16 unk_3BE; + /* 0x3C0 */ f32 unk_3C0; + /* 0x3C4 */ UNK_TYPE1 unk_3C4[0x78]; + /* 0x43C */ LightNode* lightNode; + /* 0x440 */ LightInfo lightInfo; + /* 0x44E */ u8 unk_44E; + /* 0x44F */ UNK_TYPE1 unk_44F[0x3]; + /* 0x452 */ s16 unk_452; + /* 0x454 */ f32 unk_454; + /* 0x458 */ s32 unk_458; + /* 0x45C */ s16 unk_45C; + /* 0x460 */ Actor* unk_460; + /* 0x464 */ u16 unk_464; + /* 0x466 */ s16 unk_466; + /* 0x468 */ u8 unk_468; } EnDno; // size = 0x46C extern const ActorInit En_Dno_InitVars; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index d3e2471e1b..e9de781c5e 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1003,7 +1003,7 @@ void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (((void)0, gSaveContext.inventory.questItems) & gBitFlags[18]) { + if (CHECK_QUEST_ITEM(18)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_HandleSetupResumeInteraction(this, globalCtx); } @@ -1183,7 +1183,7 @@ void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { - if (((void)0, gSaveContext.inventory.questItems) & gBitFlags[18]) { + if (CHECK_QUEST_ITEM(18)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); } else { @@ -1255,7 +1255,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } } } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { - if (((void)0, gSaveContext.inventory.questItems) & gBitFlags[18]) { + if (CHECK_QUEST_ITEM(18)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); } else { @@ -1302,7 +1302,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } } } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { - if (((void)0, gSaveContext.inventory.questItems) & gBitFlags[18]) { + if (CHECK_QUEST_ITEM(18)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); } else { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index be4eaf75d3..9badebfe16 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -439,7 +439,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { func_8019F208(); func_801518B0(globalCtx, 0x334E, &this->actor); this->textId = 0x334E; - if ((aux = gSaveContext.inventory.questItems) & gBitFlags[0xE]) { + if (CHECK_QUEST_ITEM(14)) { func_80151BB4(globalCtx, 0x1C); } func_80151BB4(globalCtx, 5); @@ -611,7 +611,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { EnMa4_SetFaceExpression(this, 0, 0); // Check if player has Epona's song - if ((aux = gSaveContext.inventory.questItems) & gBitFlags[0xE]) { + if (CHECK_QUEST_ITEM(14)) { func_801518B0(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } else { @@ -624,7 +624,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x3358: if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || - !((aux = gSaveContext.inventory.questItems) & gBitFlags[0xE])) { + !(CHECK_QUEST_ITEM(14))) { func_801518B0(globalCtx, 0x335C, &this->actor); this->textId = 0x335C; func_80151BB4(globalCtx, 5); @@ -664,7 +664,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { case 6: // End conversation if (func_80147624(globalCtx) != 0) { if ((globalCtx->msgCtx.unk120B1 == 0) || - (((temp_v0 = gSaveContext.inventory.questItems) & gBitFlags[0x12]) == 0)) { + !CHECK_QUEST_ITEM(18)) { EnMa4_SetupWait(this); } } diff --git a/undefined_syms.txt b/undefined_syms.txt index 79a80f84da..840a6c911d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1833,6 +1833,26 @@ D_06002848 = 0x06002848; D_06007CA4 = 0x06007CA4; D_0600E1F8 = 0x0600E1F8; +D_801C20C0 = 0x801C20C0; +D_06000470 = 0x06000470; +D_060008F0 = 0x060008F0; +D_06000F6C = 0x06000F6C; +D_06001A50 = 0x06001A50; +D_06002530 = 0x06002530; +D_06003320 = 0x06003320; +D_060036D0 = 0x060036D0; +D_060041CC = 0x060041CC; +D_06004DD8 = 0x06004DD8; +D_06005F98 = 0x06005F98; +D_06006488 = 0x06006488; +D_060073E4 = 0x060073E4; +D_060077A8 = 0x060077A8; +D_06008324 = 0x06008324; +D_06008AE4 = 0x06008AE4; +D_06009100 = 0x06009100; +D_060051E4 = 0x060051E4; +D_06005E20 = 0x06005E20; +D_06006F84 = 0x06006F84; // ovl_En_Dnp