diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index f44ec3246..dcdb75748 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -23,9 +23,9 @@ - - - + + + diff --git a/include/functions.h b/include/functions.h index 69c30a5a1..9be97247f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1625,7 +1625,7 @@ ActorCutscene* ActorCutscene_GetCutscene(s16 index); s16 ActorCutscene_GetAdditionalCutscene(s16 index); s16 ActorCutscene_GetLength(s16 index); // void func_800F2138(void); -// void func_800F2178(void); +s32 func_800F2178(s16 arg0); s16 ActorCutscene_GetCurrentCamera(s16 index); // void func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); diff --git a/spec b/spec index 792e0a8ca..be0a88425 100644 --- a/spec +++ b/spec @@ -2419,8 +2419,7 @@ beginseg name "ovl_En_Aob_01" compress include "build/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.o" - include "build/data/ovl_En_Aob_01/ovl_En_Aob_01.data.o" - include "build/data/ovl_En_Aob_01/ovl_En_Aob_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Aob_01/ovl_En_Aob_01_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index e434c69c2..c26081e0d 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -5,6 +5,9 @@ */ #include "z_en_aob_01.h" +#include "overlays/actors/ovl_En_Racedog/z_en_racedog.h" +#include "overlays/actors/ovl_En_Dg/z_en_dg.h" +#include "objects/object_aob/object_aob.h" #define FLAGS 0x00000019 @@ -28,8 +31,8 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx); void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx); void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx); void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx); +s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Aob_01_InitVars = { ACTOR_EN_AOB_01, ACTORCAT_NPC, @@ -42,92 +45,1012 @@ const ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809C3820 = { - { COLTYPE_NONE, 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 ActorAnimationEntry D_809C3790[6] = { + { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, -6.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + 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, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -#endif +typedef struct { + Vec3f unk_00; + s16 unk_04; + s16 unk_06; +} EnAobStruct; -extern ColliderCylinderInit D_809C3820; +static EnAobStruct D_809C384C[] = { + { { -4130.0f, 150.0f, 1367.0f }, 84, 0 }, { { -4861.0f, 172.0f, 1606.0f }, 94, 4 }, + { { -4139.0f, 155.0f, 2133.0f }, 73, 6 }, { { -4406.0f, 144.0f, 1416.0f }, 88, 2 }, + { { -4156.0f, 155.0f, 1731.0f }, 42, 0 }, { { -4033.0f, 157.0f, 1994.0f }, -65, 1 }, + { { -4582.0f, 158.0f, 1206.0f }, 144, 2 }, { { -4595.0f, 156.0f, 1493.0f }, 61, 3 }, + { { -4526.0f, 146.0f, 1702.0f }, 61, 4 }, { { -3820.0f, 162.0f, 1965.0f }, 109, 5 }, + { { -4395.0f, 147.0f, 1569.0f }, -24, 0 }, { { -4315.0f, 150.0f, 2048.0f }, 61, 6 }, + { { -4827.0f, 168.0f, 1328.0f }, 115, 4 }, { { -4130.0f, 150.0f, 1367.0f }, 112, 0 }, +}; -extern UNK_TYPE D_06000180; -extern UNK_TYPE D_06003D18; +void func_809C10B0(EnAob01* this, s32 arg1) { + if (DECR(this->unk_3F0) == 0) { + this->unk_3EE++; + if (this->unk_3EE >= arg1) { + this->unk_3EE = 0; + this->unk_3F0 = Rand_S16Offset(30, 30); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C10B0.s") +void func_809C1124(void) { + u16 time = gSaveContext.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1124.s") + gSaveContext.time = (u16)REG(15) + time; + time = gSaveContext.time; + gSaveContext.time = (u16)gSaveContext.unk_14 + time; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1158.s") +void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { + s32 temp_s0 = ENAOB01_GET_7E00_2(&this->actor); + s16 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C11EC.s") + if (temp_s0 != 0x3F) { + do { + this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + temp_s0 = this->unk_1D8[i]->unk1; + i++; + } while (temp_s0 != 0xFF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1304.s") +void func_809C11EC(EnAob01* this, GlobalContext* globalCtx) { + s32 unk; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1424.s") + func_809C1158(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C14D0.s") + for (i = 0; i < ARRAY_COUNT(D_809C384C); i++) { + unk = (this->unk_1D8[D_809C384C[i].unk_06]->unk1 << 0xA) | (i << 5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C15BC.s") + this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_DG, D_809C384C[i].unk_00.x, D_809C384C[i].unk_00.y, + D_809C384C[i].unk_00.z, 0, D_809C384C[i].unk_04 * 182.04445f, 0, unk, 0xFFFF, this->actor.unk20, NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C165C.s") +void func_809C1304(EnAob01* this, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C16DC.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++) { + this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_RACEDOG, (i * 15.0f) + -3897.0f, 130.0f, 1290.0f - (i * 10.0f), 0, + 0x1555, 0, (i << 5) | ENAOB01_GET_7E00_1(&this->actor), 0xFFFF, this->actor.unk20, NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1C9C.s") +s32 func_809C1424(EnAob01* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1D64.s") + if (this->unk_43C == 1) { + if (curFrame == lastFrame) { + this->unk_43C = 2; + func_800BDC5C(&this->skelAnime, D_809C3790, 2); + return true; + } + } else if (this->unk_43C == 2) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1EC8.s") +s32 func_809C14D0(EnAob01* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2060.s") + if ((this->unk_43C == 0) || (this->unk_43C == 5)) { + if (curFrame == lastFrame) { + this->unk_43C = 3; + func_800BDC5C(&this->skelAnime, D_809C3790, 3); + return true; + } + } else if (this->unk_43C == 3) { + if (curFrame == lastFrame) { + this->unk_43C = 4; + func_800BDC5C(&this->skelAnime, D_809C3790, 4); + return true; + } + } else if (this->unk_43C == 4) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C21E0.s") +s32 func_809C15BC(EnAob01* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2504.s") + if ((this->unk_43C != 0) && (this->unk_43C != 5)) { + if (curFrame == lastFrame) { + this->unk_43C = 5; + func_800BDC5C(&this->skelAnime, D_809C3790, 5); + return true; + } + } else { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2594.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C25E4.s") +void func_809C165C(EnAob01* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2680.s") +void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C26E4.s") + switch (this->unk_210) { + case 0: + case 0x3524: + case 0x3535: + case 0x3548: + case 0x3549: + case 0x354A: + switch (gSaveContext.day) { + case 1: + if (!gSaveContext.isNight) { + if (!(gSaveContext.weekEventReg[64] & 0x80)) { + gSaveContext.weekEventReg[64] |= 0x80; + this->unk_210 = 0x3520; + } else { + this->unk_210 = 0x352F; + } + } else { + if (!(gSaveContext.weekEventReg[65] & 1)) { + gSaveContext.weekEventReg[65] |= 1; + this->unk_210 = 0x3530; + } else { + this->unk_210 = 0x352F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2730.s") + case 2: + if (!gSaveContext.isNight) { + if (!(gSaveContext.weekEventReg[65] & 2)) { + gSaveContext.weekEventReg[65] |= 2; + this->unk_210 = 0x3531; + } else { + this->unk_210 = 0x352F; + } + } else { + if (!(gSaveContext.weekEventReg[65] & 4)) { + gSaveContext.weekEventReg[65] |= 4; + this->unk_210 = 0x3532; + } else { + this->unk_210 = 0x352F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2788.s") + case 3: + if (!gSaveContext.isNight) { + if (!(gSaveContext.weekEventReg[65] & 8)) { + gSaveContext.weekEventReg[65] |= 8; + this->unk_210 = 0x3533; + } else { + this->unk_210 = 0x352F; + } + } else { + if (!(gSaveContext.weekEventReg[65] & 0x10)) { + gSaveContext.weekEventReg[65] |= 0x10; + this->unk_210 = 0x3534; + } else { + this->unk_210 = 0x352F; + } + } + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2824.s") + case 0x3520: + case 0x352F: + case 0x3530: + case 0x3531: + case 0x3532: + case 0x3533: + case 0x3534: + this->unk_210 = 0x3521; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C28B8.s") + case 0x3521: + if (this->unk_2D2 & 2) { + this->unk_2D2 &= ~2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2A64.s") + switch (player->transformation) { + case PLAYER_FORM_GORON: + this->unk_210 = 0x3548; + this->unk_2D2 |= 0x10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2BE4.s") + case PLAYER_FORM_ZORA: + this->unk_210 = 0x3549; + this->unk_2D2 |= 0x10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2C9C.s") + case PLAYER_FORM_DEKU: + this->unk_210 = 0x354A; + this->unk_2D2 |= 0x10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2D0C.s") + case PLAYER_FORM_HUMAN: + if (gSaveContext.rupees < 10) { + this->unk_210 = 0x3524; + this->unk_2D2 |= 0x10; + } else { + this->unk_210 = 0x3522; + this->unk_2D2 |= 4; + this->unk_2D2 |= 0x10; + } + } + } else { + this->unk_2D2 |= 0x10; + this->unk_210 = 0x3535; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2EC4.s") + case 0x3522: + case 0x3523: + if (this->unk_2D2 & 8) { + this->unk_210 = 0x3525; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2F34.s") + this->unk_210 = 0x3523; + this->unk_2D2 |= 0x40; + this->unk_2D2 |= 0x10; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2FA0.s") + case 0x3525: + case 0x3526: + if (this->unk_2D2 & 4) { + if (this->unk_2D2 & 8) { + this->unk_210 = 0x3525; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Init.s") + this->unk_210 = 0x3523; + this->unk_2D2 |= 0x40; + this->unk_2D2 |= 0x10; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Destroy.s") + if (this->unk_2D2 & 2) { + this->unk_2D2 &= ~2; + this->unk_210 = 0x3527; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Update.s") + this->unk_210 = 0x3526; + this->unk_2D2 |= 0x40; + this->unk_2D2 |= 4; + this->unk_2D2 |= 0x10; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C33D8.s") + case 0x3527: + this->unk_210 = 0x3528; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C35B4.s") + case 0x3528: + if (gSaveContext.rupees < this->unk_434) { + this->unk_210 = 0x3536; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C35F4.s") + if (this->unk_434 == 0) { + this->unk_210 = 0x3537; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Draw.s") + gSaveContext.unk_3F5C = this->unk_434; + globalCtx->msgCtx.bankRupees = this->unk_434; + this->unk_210 = 0x3529; + break; + + case 0x3529: + if (this->unk_2D2 & 2) { + this->unk_2D2 &= ~2; + func_801159EC(-this->unk_434); + func_800B7298(globalCtx, NULL, 7); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_809C1C9C; + return; + } + this->unk_210 = 0x3528; + break; + + case 0x3536: + case 0x3537: + this->unk_210 = 0x3528; + break; + } + + func_801518B0(globalCtx, this->unk_210, &this->actor); +} + +void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { + if (gSaveContext.rupeeAccumulator == 0) { + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->unk_2D2 |= 0x20; + func_800FD750(0x40); + globalCtx->nextEntranceIndex = 0x7C10; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 2; + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (this->unk_432 * 8); + globalCtx->sceneLoadFlag = 0x14; + } +} + +void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { + u8 temp_v0 = func_80152498(&globalCtx->msgCtx); + + if (temp_v0 == 4) { + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + this->unk_210 = 0x3524; + func_801518B0(globalCtx, this->unk_210, &this->actor); + } else { + func_8019F208(); + this->unk_2D2 |= 4; + this->unk_2D2 |= 0x10; + this->unk_210 = 0x3522; + func_801518B0(globalCtx, this->unk_210, &this->actor); + this->actionFunc = func_809C21E0; + } + break; + + case 1: + func_8019F230(); + this->unk_210 = 0x3535; + func_801518B0(globalCtx, this->unk_210, &this->actor); + break; + } + } + } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_210 = 0; + this->actionFunc = func_809C2060; + } +} + +void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { + static u16 D_809C392C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp30; + + SkelAnime_Update(&this->skelAnime); + if (func_8013D5E8(this->actor.shape.rot.y, 14000, this->actor.yawTowardsPlayer)) { + sp30.x = player->actor.world.pos.x; + sp30.y = player->bodyPartsPos[7].y + 3.0f; + sp30.z = player->actor.world.pos.z; + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2D4, &this->unk_2DA, + &this->unk_2E0, D_809C392C); + } else { + Math_SmoothStepToS(&this->unk_2D4.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2D4.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2DA.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2DA.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E0.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); + } + func_809C10B0(this, 3); + func_8013D9C8(globalCtx, this->unk_2F8, this->unk_318, 0x10); + func_809C165C(this, globalCtx); + if (player->stateFlags1 & 0x20) { + func_809C1124(); + } +} + +void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { + if (func_809C15BC(this)) { + if (func_809C2EC4(this, globalCtx) && !(this->unk_2D2 & 0x100)) { + if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + this->unk_2D2 |= 8; + this->actionFunc = func_809C21E0; + } + } else if (func_800B84D0(&this->actor, globalCtx) && (this->unk_2D2 & 0x100)) { + this->unk_2D2 &= ~0x100; + this->unk_2E6 = this->unk_2D4; + this->unk_2EC = this->unk_2DA; + this->unk_2F2 = this->unk_2E0; + func_809C16DC(this, globalCtx); + this->actionFunc = func_809C21E0; + } else { + this->unk_2D2 &= ~0x100; + if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { + this->unk_2D2 |= 0x100; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } + } +} + +void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { + u8 sp2F = func_80152498(&globalCtx->msgCtx); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); + + if ((this->unk_2D2 & 8) && !func_809C2EC4(this, globalCtx)) { + if ((this->unk_210 != 0) && (this->unk_210 != 0x3535) && (this->unk_210 != 0x3524) && + (this->unk_210 != 0x3548) && (this->unk_210 != 0x3549) && (this->unk_210 != 0x354A)) { + this->unk_210 = 0x3523; + } + this->actor.textId = 0; + this->unk_2D2 &= ~8; + this->actor.flags &= ~0x10000; + this->actionFunc = func_809C2060; + return; + } + + if (this->unk_2D2 & 0x40) { + if (!func_809C1424(this)) { + return; + } + } else if (!func_809C15BC(this)) { + return; + } + + if (this->unk_2D2 & 8) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + func_80123E90(globalCtx, &this->actor); + if (this->unk_2D2 & 4) { + func_809C16DC(this, globalCtx); + this->unk_2D2 &= ~4; + } else { + this->unk_2D2 |= 0x10; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + func_801518B0(globalCtx, 0x354B, &this->actor); + } + this->unk_2D2 &= ~8; + } + } else if (sp2F == 4) { + if (func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + this->unk_2D2 |= 2; + func_809C16DC(this, globalCtx); + break; + + case 1: + func_8019F230(); + func_809C16DC(this, globalCtx); + break; + } + } + } else if (sp2F == 5) { + if (func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + if (this->unk_2D2 & 0x10) { + this->unk_2D2 &= ~0x10; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_809C2060; + } else { + func_809C16DC(this, globalCtx); + } + } + } else if ((sp2F == 14) && func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; + func_809C16DC(this, globalCtx); + } +} + +s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { + ActorCutscene_Stop(this->unk_430); + this->unk_3F4 = npc; + this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + return true; + } + npc = npc->next; + } + + return false; +} + +s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { + this->unk_3F4 = npc; + return true; + } + npc = npc->next; + } + + return false; +} + +s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + s16 count = 0; + + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_29C == 3)) { + count++; + } + npc = npc->next; + } + + if (count >= 14) { + return true; + } + + if ((count >= 10) && (DECR(this->unk_440) == 0)) { + return true; + } + return false; +} + +s32 func_809C2680(EnAob01* this) { + if ((ActorCutscene_GetLength(this->unk_430) > 0) && (ActorCutscene_GetCurrentIndex() != this->unk_430)) { + this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + return true; + } + return false; +} + +void func_809C26E4(EnAob01* this, GlobalContext* globalCtx) { + ActorCutscene_Stop(this->unk_430); + this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + this->actionFunc = func_809C2824; +} + +void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { + if (func_809C2504(this, globalCtx) || func_809C2680(this)) { + ActorCutscene_SetIntentToPlay(this->unk_430); + this->actionFunc = func_809C2824; + } +} + +void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { + this->unk_2D2 |= 0x20; + if (func_809C25E4(this, globalCtx)) { + globalCtx = globalCtx; + if (func_801A8A50(0) != 0x41) { + globalCtx->nextEntranceIndex = 0x7C10; + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 3; + globalCtx->sceneLoadFlag = 0x14; + } + } +} + +void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_430)) { + ActorCutscene_Start(this->unk_430, this->unk_3F4); + switch (func_800F2178(this->unk_430)) { + case 255: + this->actionFunc = func_809C26E4; + break; + + case 99: + this->actionFunc = func_809C2788; + break; + + default: + this->actionFunc = func_809C2730; + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_430); + } +} + +void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + func_80123E90(globalCtx, &this->actor); + this->unk_434 = gSaveContext.unk_3F5C; + switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { + case 1: + this->unk_210 = 0x352A; + this->unk_2D2 |= 0x80; + this->unk_434 *= 3; + func_801159EC(this->unk_434); + globalCtx->msgCtx.bankRupees = this->unk_434; + break; + + case 2: + this->unk_210 = 0x352B; + this->unk_2D2 |= 0x80; + this->unk_434 *= 2; + func_801159EC(this->unk_434); + globalCtx->msgCtx.bankRupees = this->unk_434; + break; + + case 3: + case 4: + case 5: + this->unk_210 = 0x352C; + func_801159EC(this->unk_434); + break; + + default: + this->unk_210 = 0x352D; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + func_800BDC5C(&this->skelAnime, D_809C3790, 1); + break; + } + + func_801518B0(globalCtx, this->unk_210, &this->actor); + this->actionFunc = func_809C2D0C; + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} + +void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { + u8 sp2F = func_80152498(&globalCtx->msgCtx); + + if (func_809C15BC(this)) { + if ((sp2F == 5) && func_80147624(globalCtx)) { + this->unk_434 = 0; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_2D4 = this->unk_2E6; + this->unk_2DA = this->unk_2EC; + this->unk_2E0 = this->unk_2F2; + this->actor.parent = NULL; + this->actor.shape.rot.y = this->actor.world.rot.y; + if (gSaveContext.weekEventReg[8] & 0x20) { + this->actionFunc = func_809C2BE4; + } else { + gSaveContext.weekEventReg[8] |= 0x20; + this->actionFunc = func_809C2BE4; + } + } else if (gSaveContext.weekEventReg[8] & 0x20) { + func_800B8A1C(&this->actor, globalCtx, 4, 300.0f, 300.0f); + } else { + func_800B8A1C(&this->actor, globalCtx, 12, 300.0f, 300.0f); + } + } +} + +void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { + u8 temp_v0 = func_80152498(&globalCtx->msgCtx); + + if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { + if (gSaveContext.weekEventReg[63] & 2) { + gSaveContext.weekEventReg[63] &= (u8)~2; + } + + if (gSaveContext.weekEventReg[63] & 1) { + gSaveContext.weekEventReg[63] &= (u8)~1; + } + + this->unk_210 = 0; + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + gSaveContext.eventInf[0] &= (u8)~7; + this->actionFunc = func_809C2C9C; + } +} + +void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->unk_210 = 0x354C; + func_80151938(globalCtx, this->unk_210); + this->actionFunc = func_809C1D64; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { + u8 sp2F = func_80152498(&globalCtx->msgCtx); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); + + if (this->unk_2D2 & 0x40) { + if (!func_809C1424(this)) { + return; + } + } else if (this->unk_2D2 & 0x80) { + if (!func_809C14D0(this)) { + return; + } + } + + if ((sp2F == 5) && func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + this->unk_2D2 &= ~0x80; + if (this->unk_434 >= 150) { + this->unk_210 = 0x352E; + func_801518B0(globalCtx, this->unk_210, &this->actor); + this->actionFunc = func_809C2A64; + } else { + this->unk_2D4 = this->unk_2E6; + this->unk_2DA = this->unk_2EC; + this->unk_2E0 = this->unk_2F2; + + this->unk_434 = 0; + this->actor.shape.rot.y = this->actor.world.rot.y; + if (gSaveContext.weekEventReg[63] & 2) { + gSaveContext.weekEventReg[63] &= (u8)~2; + } + + if (gSaveContext.weekEventReg[63] & 1) { + gSaveContext.weekEventReg[63] &= (u8)~1; + } + + this->unk_210 = 0x354C; + func_801518B0(globalCtx, this->unk_210, &this->actor); + this->actionFunc = func_809C1D64; + gSaveContext.eventInf[0] &= (u8)~7; + } + } +} + +s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { + Actor* dog = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + + while (dog != NULL) { + if (dog->id == ACTOR_EN_DG) { + this->unk_432 = ((EnDg*)dog)->unk_288; + if (this->unk_432 == -1) { + return false; + } + + if (this->unk_432 == ENDG_GET_3E0(dog)) { + return true; + } + } + dog = dog->next; + } + + return false; +} + +void func_809C2F34(EnAob01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.world.pos.x = -4134.0f; + player->actor.world.pos.z = 1464.0f; + player->actor.shape.rot.y = player->actor.world.rot.y; + player->actor.draw = NULL; + player->stateFlags1 |= 0x20; + this->actor.world.pos.x = -4308.0f; + this->actor.world.pos.z = 1620.0f; + this->actor.prevPos = this->actor.world.pos; +} + +void func_809C2FA0(void) { + u8 i; + u8 idx; + u8 idx2; + u8 orig; + u8 orig2; + u8 sp44[7]; + u8 sp34[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + }; + + for (i = 0; i < ARRAY_COUNT(sp34); i++) { + idx = Rand_ZeroFloat(14.0f); + orig = sp34[i]; + + sp34[i] = sp34[idx]; + sp34[idx] = orig; + } + + for (i = 0; i < ARRAY_COUNT(sp44); i++) { + gSaveContext.weekEventReg[42 + i] = 0; + sp44[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(sp34); i++) { + orig2 = sp34[i]; + idx2 = i / 2; + + if (i % 2) { + sp44[idx2] |= orig2 << 0x4; + idx = gSaveContext.weekEventReg[42 + idx2]; + gSaveContext.weekEventReg[42 + idx2] = idx | sp44[idx2]; + } else { + sp44[idx2] |= orig2; + } + } +} + +void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAob01* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_aob_Skel_000180, NULL, this->jointTable, this->morphTable, + 16); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_43C = 0; + func_800BDC5C(&this->skelAnime, D_809C3790, 0); + Actor_SetScale(&this->actor, 0.01f); + + switch (gSaveContext.eventInf[0] & 7) { + case 0: + func_809C2FA0(); + func_809C11EC(this, globalCtx); + this->actor.flags |= 1; + this->actionFunc = func_809C2060; + break; + + case 2: + this->unk_440 = 500; + func_809C1304(this, globalCtx); + this->actor.draw = NULL; + this->unk_430 = this->actor.cutscene; + func_809C2594(this, globalCtx); + ActorCutscene_SetIntentToPlay(this->unk_430); + this->actor.flags &= ~1; + func_809C2F34(this, globalCtx); + this->actionFunc = func_809C2824; + break; + + case 3: + func_809C2FA0(); + func_809C11EC(this, globalCtx); + this->actor.flags |= 1; + this->actor.flags |= 0x10000; + this->actionFunc = func_809C28B8; + break; + } +} + +void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAob01* this = THIS; + + if (!(this->unk_2D2 & 0x20)) { + gSaveContext.weekEventReg[63] &= (u8)~1; + } + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAob01* this = THIS; + + this->actionFunc(this, globalCtx); + func_809C1EC8(this, globalCtx); +} + +s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAob01* this = THIS; + UNK_TYPE sp38[] = { + &object_aob_Tex_000658, + &object_aob_Tex_000E58, + &object_aob_Tex_001658, + }; + + if (limbIndex == 15) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + *dList = object_aob_DL_003D18; + + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sp38[this->unk_3EE])); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == 15) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == 8) { + Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); + } + + if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + rot->y += (s16)Math_SinS(this->unk_2F8[limbIndex]) * 200; + rot->z += (s16)Math_CosS(this->unk_318[limbIndex]) * 200; + } + return false; +} + +void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; + EnAob01* this = THIS; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); + } +} + +void EnAob01_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnAob01_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAob01* this = THIS; + Vec3f sp5C; + Vec3f sp50; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); + gDPPipeSync(POLY_OPA_DISP++); + + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAob01_OverrideLimbDraw, EnAob01_PostLimbDraw, EnAob01_UnkDraw, &this->actor); + + if (this->actor.draw != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + sp5C = this->actor.world.pos; + sp50.x = 0.5f; + sp50.y = 0.5f; + sp50.z = 0.5f; + func_800BC620(&sp5C, &sp50, 0xFF, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index 5f30ef196..be7655fad 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -7,10 +7,38 @@ struct EnAob01; typedef void (*EnAob01ActionFunc)(struct EnAob01*, GlobalContext*); +#define ENAOB01_GET_7E00_1(thisx) ((thisx)->params & 0x7E00) +#define ENAOB01_GET_7E00_2(thisx) (((thisx)->params & 0x7E00) >> 9) + typedef struct EnAob01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnAob01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x2FC]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnAob01ActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Path* unk_1D8[14]; + /* 0x210 */ u16 unk_210; + /* 0x212 */ Vec3s jointTable[16]; + /* 0x272 */ Vec3s morphTable[16]; + /* 0x2D2 */ u16 unk_2D2; + /* 0x2D4 */ Vec3s unk_2D4; + /* 0x2DA */ Vec3s unk_2DA; + /* 0x2E0 */ Vec3s unk_2E0; + /* 0x2E6 */ Vec3s unk_2E6; + /* 0x2EC */ Vec3s unk_2EC; + /* 0x2F2 */ Vec3s unk_2F2; + /* 0x2F8 */ s16 unk_2F8[16]; + /* 0x318 */ s16 unk_318[16]; + /* 0x338 */ UNK_TYPE1 unk338[0xB6]; + /* 0x3EE */ s16 unk_3EE; + /* 0x3F0 */ s16 unk_3F0; + /* 0x3F4 */ Actor* unk_3F4; + /* 0x3F8 */ Actor* unk_3F8[14]; + /* 0x430 */ s16 unk_430; + /* 0x432 */ s16 unk_432; + /* 0x434 */ s32 unk_434; + /* 0x438 */ UNK_TYPE1 unk438[4]; + /* 0x43C */ s32 unk_43C; + /* 0x440 */ s16 unk_440; } EnAob01; // size = 0x444 extern const ActorInit En_Aob_01_InitVars; diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index a4b721f5d..4008ba4e1 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -10,7 +10,14 @@ typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); typedef struct EnRacedog { /* 0x0000 */ Actor actor; /* 0x0144 */ EnRacedogActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x180]; + /* 0x0148 */ char unk_148[0xA0]; + /* 0x01E8 */ s32 unk_1E8; + /* 0x01EC */ char unk_1EC[0xA4]; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ s16 unk_292; + /* 0x0294 */ char unk_294[0x8]; + /* 0x029C */ s16 unk_29C; + /* 0x029E */ char unk_29E[0x2A]; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 573446a5f..9e63b2953 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9031,9 +9031,9 @@ 0x809C3190:("EnAob01_Init",), 0x809C3350:("EnAob01_Destroy",), 0x809C339C:("EnAob01_Update",), - 0x809C33D8:("func_809C33D8",), - 0x809C35B4:("func_809C35B4",), - 0x809C35F4:("func_809C35F4",), + 0x809C33D8:("EnAob01_OverrideLimbDraw",), + 0x809C35B4:("EnAob01_PostLimbDraw",), + 0x809C35F4:("EnAob01_UnkDraw",), 0x809C3608:("EnAob01_Draw",), 0x809C3D80:("EnBoj01_Init",), 0x809C3D90:("EnBoj01_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d2fa8045d..e2e11fa49 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1566,11 +1566,6 @@ D_060028A0 = 0x060028A0; D_06009220 = 0x06009220; D_06009D34 = 0x06009D34; -// ovl_En_Aob_01 - -D_06000180 = 0x06000180; -D_06003D18 = 0x06003D18; - // ovl_En_Attack_Niw D_060000E8 = 0x060000E8;