From 89829b99052c0aa083010906e8b6bfa1addb1696 Mon Sep 17 00:00:00 2001 From: Electrk Date: Sun, 19 Dec 2021 10:47:08 -0800 Subject: [PATCH] EnInvisibleRuppe OK (#508) * EnInvisibleRuppe OK * Style changes as per review * Update reloc * Apply feedback --- spec | 3 +- .../z_en_invisible_ruppe.c | 96 ++++++++++++++++--- .../z_en_invisible_ruppe.h | 7 +- 3 files changed, 90 insertions(+), 16 deletions(-) diff --git a/spec b/spec index debfa85bf..5c84ef301 100644 --- a/spec +++ b/spec @@ -5504,8 +5504,7 @@ beginseg name "ovl_En_Invisible_Ruppe" compress include "build/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.o" - include "build/data/ovl_En_Invisible_Ruppe/ovl_En_Invisible_Ruppe.data.o" - include "build/data/ovl_En_Invisible_Ruppe/ovl_En_Invisible_Ruppe.reloc.o" + include "build/src/overlays/actors/ovl_En_Invisible_Ruppe/ovl_En_Invisible_Ruppe_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c index 24aa7d33b..f459fbf53 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c @@ -14,10 +14,10 @@ void EnInvisibleRuppe_Init(Actor* thisx, GlobalContext* globalCtx); void EnInvisibleRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnInvisibleRuppe_Update(Actor* thisx, GlobalContext* globalCtx); +void func_80C258A0(EnInvisibleRuppe* this, GlobalContext* globalCtx); void func_80C2590C(EnInvisibleRuppe* this, GlobalContext* globalCtx); void func_80C259E8(EnInvisibleRuppe* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Invisible_Ruppe_InitVars = { ACTOR_EN_INVISIBLE_RUPPE, ACTORCAT_NPC, @@ -30,25 +30,95 @@ const ActorInit En_Invisible_Ruppe_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C25B50 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +void func_80C258A0(EnInvisibleRuppe* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 0.0f, 4); +} -extern ColliderCylinderInit D_80C25B50; +void func_80C2590C(EnInvisibleRuppe* this, GlobalContext* globalCtx) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + switch (INVISIBLERUPPE_GET_3(this)) { + case 0: + play_sound(NA_SE_SY_GET_RUPY); + Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_GREEN); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invisible_Ruppe/func_80C258A0.s") + case 1: + play_sound(NA_SE_SY_GET_RUPY); + Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_BLUE); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invisible_Ruppe/func_80C2590C.s") + case 2: + play_sound(NA_SE_SY_GET_RUPY); + Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_RED); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invisible_Ruppe/func_80C259E8.s") + if (this->unk_190 >= 0) { + Actor_SetSwitchFlag(globalCtx, this->unk_190); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invisible_Ruppe/EnInvisibleRuppe_Init.s") + this->actionFunc = func_80C259E8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invisible_Ruppe/EnInvisibleRuppe_Destroy.s") +void func_80C259E8(EnInvisibleRuppe* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invisible_Ruppe/EnInvisibleRuppe_Update.s") +void EnInvisibleRuppe_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnInvisibleRuppe* this = THIS; + + this->unk_190 = INVISIBLERUPPE_GET_1FC(this); + + if (this->unk_190 == 0x7F) { + this->unk_190 = -1; + } + + if ((this->unk_190 >= 0) && Flags_GetSwitch(globalCtx, this->unk_190)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + + this->actionFunc = func_80C2590C; +} + +void EnInvisibleRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnInvisibleRuppe* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnInvisibleRuppe_Update(Actor* thisx, GlobalContext* globalCtx) { + EnInvisibleRuppe* this = THIS; + + this->actionFunc(this, globalCtx); + func_80C258A0(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h index 66b42d520..eef1acbfe 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h @@ -7,9 +7,14 @@ struct EnInvisibleRuppe; typedef void (*EnInvisibleRuppeActionFunc)(struct EnInvisibleRuppe*, GlobalContext*); +#define INVISIBLERUPPE_GET_3(thisx) ((thisx)->actor.params & 3) +#define INVISIBLERUPPE_GET_1FC(thisx) (((thisx)->actor.params & 0x1FC) >> 2) + typedef struct EnInvisibleRuppe { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ s16 unk_190; + /* 0x0192 */ s16 unk_192; /* 0x0194 */ EnInvisibleRuppeActionFunc actionFunc; } EnInvisibleRuppe; // size = 0x198