diff --git a/spec b/spec index 9d846e3902..4d94ff7a46 100644 --- a/spec +++ b/spec @@ -2124,8 +2124,7 @@ beginseg name "ovl_Obj_Makekinsuta" compress include "build/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.o" - include "build/data/ovl_Obj_Makekinsuta/ovl_Obj_Makekinsuta.data.o" - include "build/data/ovl_Obj_Makekinsuta/ovl_Obj_Makekinsuta.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Makekinsuta/ovl_Obj_Makekinsuta_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index 6c2d8a3567..90aa5fa405 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -14,7 +14,10 @@ void ObjMakekinsuta_Init(Actor* thisx, PlayState* play); void ObjMakekinsuta_Destroy(Actor* thisx, PlayState* play); void ObjMakekinsuta_Update(Actor* thisx, PlayState* play); -#if 0 +s32 func_8099FA40(ObjMakekinsuta* this, PlayState* play); +void func_8099FB64(Actor* thisx, PlayState* play); +void func_8099FD7C(Actor* thisx, PlayState* play); + const ActorInit Obj_Makekinsuta_InitVars = { ACTOR_OBJ_MAKEKINSUTA, ACTORCAT_ITEMACTION, @@ -27,25 +30,112 @@ const ActorInit Obj_Makekinsuta_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8099FE30[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1, ICHAIN_STOP), }; -#endif +s32 func_8099FA40(ObjMakekinsuta* this, PlayState* play) { + s32 chestFlag = -1; + s32 skulltulaParams = (OBJMAKEKINSUTA_GET_1F(&this->actor) << 2) | 0xFF01; -extern InitChainEntry D_8099FE30[]; + if (OBJMAKEKINSUTA_GETS_3(skulltulaParams)) { + chestFlag = OBJMAKEKINSUTA_GETS_3FC(skulltulaParams); + } + return (chestFlag < 0) == true || !Flags_GetTreasure(play, chestFlag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/func_8099FA40.s") +void ObjMakekinsuta_Init(Actor* thisx, PlayState* play) { + ObjMakekinsuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/ObjMakekinsuta_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + if (!func_8099FA40(this, play)) { + this->unk144 = -1; + } + if (Flags_GetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/ObjMakekinsuta_Destroy.s") +void ObjMakekinsuta_Destroy(Actor* thisx, PlayState* play) { + ObjMakekinsuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/func_8099FB64.s") + if (func_8099FA40(this, play)) { + Flags_UnsetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/ObjMakekinsuta_Update.s") +void func_8099FB64(Actor* thisx, PlayState* play) { + s32 pad[0x2]; + Actor* actor; + Vec3f destVec; + s16 rotY; + f32 speedXZ; + s32 rotCheck; + static Vec3f D_8099FE3C = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/func_8099FD7C.s") + rotCheck = thisx->shape.rot.x == 0; + if (rotCheck) { + rotCheck = thisx->shape.rot.z == 0; + } + + if (rotCheck) { + rotY = thisx->shape.rot.y; + } else { + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_8099FE3C, &destVec); + rotY = Math_FAtan2F(destVec.z, destVec.x); + } + actor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, + 0, rotY, 0, (OBJMAKEKINSUTA_GET_1F(thisx) << 2) | 0xFF01); + if (actor != NULL) { + actor->parent = thisx; + if (rotCheck) { + actor->velocity.y = 10.0f; + actor->speedXZ = 3.0f; + } else { + speedXZ = sqrtf((destVec.x * destVec.x) + (destVec.z * destVec.z)); + actor->velocity.y = (4 * destVec.y) + 4.0f; + actor->speedXZ = (2 * speedXZ) + 2.0f; + } + } +} + +void ObjMakekinsuta_Update(Actor* thisx, PlayState* play) { + ObjMakekinsuta* this = THIS; + + if (Flags_GetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx))) { + this->actor.update = func_8099FD7C; + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else { + if (this->unk144 >= 0) { + if (this->unk144 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk144 = Rand_S16Offset(0x28, 0x50); + } else { + this->unk144 = 8; + } + } else { + this->unk144--; + } + } + } +} + +void func_8099FD7C(Actor* thisx, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(thisx->cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); + if (thisx->cutscene >= 0) { + func_800B7298(play, thisx, 4); + } + func_8099FB64(thisx, play); + thisx->update = Actor_Noop; + thisx->flags &= ~ACTOR_FLAG_10; + } else { + ActorCutscene_SetIntentToPlay(thisx->cutscene); + } +} diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h index 57c855179d..d5bc998f03 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h @@ -5,9 +5,14 @@ struct ObjMakekinsuta; +#define OBJMAKEKINSUTA_GET_1F(thisx) (((thisx)->params >> 8) & 0x1F) +#define OBJMAKEKINSUTA_GETS_3(params) ((params & 3) & 0xFF) +#define OBJMAKEKINSUTA_GETS_3FC(params) (((params & 0x3FC) >> 2) & 0xFF) +#define OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx) ((thisx)->params & 0x7F) + typedef struct ObjMakekinsuta { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s8 unk144; } ObjMakekinsuta; // size = 0x148 extern const ActorInit Obj_Makekinsuta_InitVars;