diff options
| author | petrie911 <69443847+petrie911@users.noreply.github.com> | 2021-03-27 14:50:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-27 15:50:26 -0400 |
| commit | cf78de2b1106c5fb720550f29d81d5ceeaff44f5 (patch) | |
| tree | cd05419e8a3759eefc600a8e4a2573a609663e14 /src | |
| parent | 8b57f36d32b9b5e5e53f77dfc6291a1fdfc32b67 (diff) | |
Obj_Mure3 OK (#720)
* matched
* format
* review
Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
Co-authored-by: fig02 <fig02srl@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c | 195 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h | 7 |
2 files changed, 175 insertions, 27 deletions
diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c index d58642b1f..2bf0a398e 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c @@ -14,7 +14,13 @@ void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx); void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx); -/* +void func_80B9AF24(ObjMure3* this); +void func_80B9AF34(ObjMure3* this, GlobalContext* globalCtx); +void func_80B9AF54(ObjMure3* this); +void func_80B9AF64(ObjMure3* this, GlobalContext* globalCtx); +void func_80B9AFEC(ObjMure3* this); +void func_80B9AFFC(ObjMure3* this, GlobalContext* globalCtx); + const ActorInit Obj_Mure3_InitVars = { ACTOR_OBJ_MURE3, ACTORCAT_BG, @@ -26,31 +32,168 @@ const ActorInit Obj_Mure3_InitVars = { (ActorFunc)ObjMure3_Update, NULL, }; -*/ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9A9D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AA90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9ABA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9ACE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9ADCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/ObjMure3_Init.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/ObjMure3_Destroy.s") +static s16 sRupeeCounts[] = { 5, 5, 7, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AF24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AF34.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AF54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AF64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AFEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/func_80B9AFFC.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 1800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure3/ObjMure3_Update.s") +void func_80B9A9D0(ObjMure3* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spawnPos; + + Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos); + for (i = 0; i < 5; i++, spawnPos.y += 20.0f) { + if (!((this->unk_16C >> i) & 1)) { + this->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_BLUE); + if (this->unk_150[i] != NULL) { + this->unk_150[i]->actor.room = this->actor.room; + } + } + } +} + +void func_80B9AA90(ObjMure3* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spawnPos; + f32 sn = Math_SinS(this->actor.world.rot.y); + f32 cos = Math_CosS(this->actor.world.rot.y); + f32 radius; + + spawnPos.y = this->actor.world.pos.y; + + for (i = 0, radius = -40.0f; i < 5; i++, radius += 20.0f) { + if (!((this->unk_16C >> i) & 1)) { + spawnPos.x = this->actor.world.pos.x + (sn * radius); + spawnPos.z = this->actor.world.pos.z + (cos * radius); + this->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_GREEN); + if (this->unk_150[i] != NULL) { + this->unk_150[i]->actor.room = this->actor.room; + } + } + } +} + +void func_80B9ABA0(ObjMure3* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spawnPos; + s16 yRot; + + spawnPos.y = this->actor.world.pos.y; + yRot = this->actor.world.rot.y; + for (i = 0; i < 6; i++) { + if (!((this->unk_16C >> i) & 1)) { + spawnPos.x = (Math_SinS(yRot) * 40.0f) + this->actor.world.pos.x; + spawnPos.z = (Math_CosS(yRot) * 40.0f) + this->actor.world.pos.z; + this->unk_150[i] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_GREEN); + if (this->unk_150[i] != NULL) { + this->unk_150[i]->actor.room = this->actor.room; + } + } + yRot += 0x2AAA; + } + if (!((this->unk_16C >> 6) & 1)) { + spawnPos.x = this->actor.world.pos.x; + spawnPos.z = this->actor.world.pos.z; + this->unk_150[6] = Item_DropCollectible2(globalCtx, &spawnPos, 0x4000 | ITEM00_RUPEE_RED); + if (this->unk_150[6] != NULL) { + this->unk_150[6]->actor.room = this->actor.room; + } + } +} + +void func_80B9ACE4(ObjMure3* this, GlobalContext* globalCtx) { + s16 count = sRupeeCounts[(this->actor.params >> 13) & 7]; + s32 i; + + for (i = 0; i < count; i++) { + EnItem00** collectible = &this->unk_150[i]; + + if (!((this->unk_16C >> i) & 1) && (*collectible != NULL)) { + if (Actor_HasParent(&(*collectible)->actor, globalCtx) || ((*collectible)->actor.update == NULL)) { + this->unk_16C |= (1 << i); + } else { + Actor_Kill(&(*collectible)->actor); + } + } + *collectible = NULL; + } +} + +void func_80B9ADCC(ObjMure3* this, GlobalContext* globalCtx) { + s16 count = sRupeeCounts[(this->actor.params >> 13) & 7]; + s32 i; + + for (i = 0; i < count; i++) { + EnItem00** collectible = &this->unk_150[i]; + + if ((*collectible != NULL) && !((this->unk_16C >> i) & 1)) { + if (Actor_HasParent(&(*collectible)->actor, globalCtx)) { + Flags_SetSwitch(globalCtx, this->actor.params & 0x3F); + } + if ((*collectible)->actor.update == NULL) { + this->unk_16C |= (1 << i); + this->unk_150[i] = NULL; + } + } + } +} + +void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjMure3* this = THIS; + + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x3F)) { + Actor_Kill(&this->actor); + return; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + func_80B9AF24(this); +} + +void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80B9AF24(ObjMure3* this) { + this->actionFunc = func_80B9AF34; +} + +void func_80B9AF34(ObjMure3* this, GlobalContext* globalCtx) { + func_80B9AF54(this); +} + +void func_80B9AF54(ObjMure3* this) { + this->actionFunc = func_80B9AF64; +} + +void func_80B9AF64(ObjMure3* this, GlobalContext* globalCtx) { + static ObjMure3SpawnFunc spawnFuncs[] = { func_80B9A9D0, func_80B9AA90, func_80B9ABA0 }; + + if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1150.0f)) { + this->actor.flags |= 0x10; + spawnFuncs[(this->actor.params >> 13) & 7](this, globalCtx); + func_80B9AFEC(this); + } +} + +void func_80B9AFEC(ObjMure3* this) { + this->actionFunc = func_80B9AFFC; +} + +void func_80B9AFFC(ObjMure3* this, GlobalContext* globalCtx) { + func_80B9ADCC(this, globalCtx); + if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) >= SQ(1450.0f)) { + this->actor.flags &= ~0x10; + func_80B9ACE4(this, globalCtx); + func_80B9AF54(this); + } +} + +void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjMure3* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h index ec4fd273a..63122daee 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h @@ -6,9 +6,14 @@ struct ObjMure3; +typedef void (*ObjMure3ActionFunc)(struct ObjMure3*, GlobalContext*); +typedef void (*ObjMure3SpawnFunc)(struct ObjMure3*, GlobalContext*); + typedef struct ObjMure3 { /* 0x0000 */ Actor actor; - /* 0x014C */ char unk_14C[0x24]; + /* 0x014C */ ObjMure3ActionFunc actionFunc; + /* 0x0150 */ EnItem00* unk_150[7]; + /* 0x016C */ u16 unk_16C; } ObjMure3; // size = 0x0170 extern const ActorInit Obj_Mure3_InitVars; |
