From 4cb1c3345f3134670537682f4ada2c2a5bdc5a13 Mon Sep 17 00:00:00 2001 From: Kenton M Date: Sun, 12 Jun 2022 16:15:15 -0700 Subject: [PATCH] Small doc for Item00 actor (#1268) * EnItem00.unk_15A rename to despawnTimer * func_8001E5C8 rename to EnItem00_BounceAfterCollected * shorten to Item00_Collected --- include/z64actor.h | 2 +- src/code/z_en_item00.c | 51 ++++++++++--------- src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c | 2 +- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index fcf5e29b57..ee27191cee 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -282,7 +282,7 @@ typedef struct EnItem00 { /* 0x154 */ s16 unk_154; /* 0x156 */ s16 unk_156; /* 0x158 */ s16 unk_158; - /* 0x15A */ s16 unk_15A; + /* 0x15A */ s16 despawnTimer; /* 0x15C */ f32 scale; /* 0x160 */ ColliderCylinder collider; } EnItem00; // size = 0x1AC diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 862b7c7eac..c481c12f7f 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -13,7 +13,7 @@ void EnItem00_Draw(Actor* thisx, PlayState* play); void func_8001DFC8(EnItem00* this, PlayState* play); void func_8001E1C8(EnItem00* this, PlayState* play); void func_8001E304(EnItem00* this, PlayState* play); -void func_8001E5C8(EnItem00* this, PlayState* play); +void EnItem00_Collected(EnItem00* this, PlayState* play); void EnItem00_DrawRupee(EnItem00* this, PlayState* play); void EnItem00_DrawCollectible(EnItem00* this, PlayState* play); @@ -273,11 +273,11 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { if (!spawnParam8000) { EnItem00_SetupAction(this, func_8001DFC8); - this->unk_15A = -1; + this->despawnTimer = -1; return; } - this->unk_15A = 15; + this->despawnTimer = 15; this->unk_154 = 35; this->actor.speedXZ = 0.0f; @@ -354,7 +354,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { func_8002F554(&this->actor, play, getItemId); } - EnItem00_SetupAction(this, func_8001E5C8); + EnItem00_SetupAction(this, EnItem00_Collected); this->actionFunc(this, play); } @@ -365,20 +365,20 @@ void EnItem00_Destroy(Actor* thisx, PlayState* play) { } void func_8001DFC8(EnItem00* this, PlayState* play) { - if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk_15A < 0)) || + if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->despawnTimer < 0)) || (this->actor.params == ITEM00_HEART_PIECE)) { this->actor.shape.rot.y += 960; } else { if ((this->actor.params >= ITEM00_SHIELD_DEKU) && (this->actor.params != ITEM00_BOMBS_SPECIAL)) { - if (this->unk_15A == -1) { + if (this->despawnTimer == -1) { if (Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x - 0x4000, 2, 3000, 1500) == 0) { - this->unk_15A = -2; + this->despawnTimer = -2; } } else { if (Math_SmoothStepToS(&this->actor.shape.rot.x, -this->actor.world.rot.x - 0x4000, 2, 3000, 1500) == 0) { - this->unk_15A = -1; + this->despawnTimer = -1; } } Math_SmoothStepToS(&this->actor.world.rot.x, 0, 2, 2500, 500); @@ -398,7 +398,7 @@ void func_8001DFC8(EnItem00* this, PlayState* play) { } } - if (this->unk_15A == 0) { + if (this->despawnTimer == 0) { if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) && (this->actor.params != ITEM00_HEART_CONTAINER)) { Actor_Kill(&this->actor); @@ -443,7 +443,7 @@ void func_8001E304(EnItem00* this, PlayState* play) { Vec3f pos; s32 rotOffset; - this->unk_15A++; + this->despawnTimer++; if (this->actor.params == ITEM00_HEART) { if (this->actor.velocity.y < 0.0f) { @@ -492,19 +492,19 @@ void func_8001E304(EnItem00* this, PlayState* play) { } } -void func_8001E5C8(EnItem00* this, PlayState* play) { +void EnItem00_Collected(EnItem00* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, play)) { func_8002F434(&this->actor, play, this->getItemId, 50.0f, 80.0f); - this->unk_15A++; + this->despawnTimer++; } else { this->getItemId = GI_NONE; } } - if (this->unk_15A == 0) { + if (this->despawnTimer == 0) { Actor_Kill(&this->actor); return; } @@ -517,7 +517,8 @@ void func_8001E5C8(EnItem00* this, PlayState* play) { this->actor.shape.rot.y = 0; } - this->actor.world.pos.y += 40.0f + Math_SinS(this->unk_15A * 15000) * (this->unk_15A * 0.3f); + // bounces up and down above player's head + this->actor.world.pos.y += 40.0f + Math_SinS(this->despawnTimer * 15000) * (this->despawnTimer * 0.3f); if (LINK_IS_ADULT) { this->actor.world.pos.y += 20.0f; @@ -537,12 +538,12 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { EnItem00* this = (EnItem00*)thisx; s32 pad; - if (this->unk_15A > 0) { - this->unk_15A--; + if (this->despawnTimer > 0) { + this->despawnTimer--; } - if ((this->unk_15A > 0) && (this->unk_15A < 41) && (this->unk_154 <= 0)) { - this->unk_156 = this->unk_15A; + if ((this->despawnTimer > 0) && (this->despawnTimer < 41) && (this->unk_154 <= 0)) { + this->unk_156 = this->despawnTimer; } this->actionFunc(this, play); @@ -728,7 +729,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { Flags_SetCollectible(play, this->collectibleFlag); - this->unk_15A = 15; + this->despawnTimer = 15; this->unk_154 = 35; this->actor.shape.rot.z = 0; this->actor.speedXZ = 0; @@ -738,7 +739,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, this->scale); this->getItemId = GI_NONE; - EnItem00_SetupAction(this, func_8001E5C8); + EnItem00_SetupAction(this, EnItem00_Collected); } void EnItem00_Draw(Actor* thisx, PlayState* play) { @@ -761,14 +762,14 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) { EnItem00_DrawHeartContainer(this, play); break; case ITEM00_HEART: - if (this->unk_15A < 0) { - if (this->unk_15A == -1) { + if (this->despawnTimer < 0) { + if (this->despawnTimer == -1) { s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART); if (Object_IsLoaded(&play->objectCtx, bankIndex)) { this->actor.objBankIndex = bankIndex; Actor_SetObjectDependency(play, &this->actor); - this->unk_15A = -2; + this->despawnTimer = -2; } } else { mtxScale = 16.0f; @@ -972,7 +973,7 @@ EnItem00* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, s16 params) { spawnedActor->actor.world.rot.y = Rand_CenteredFloat(65536.0f); Actor_SetScale(&spawnedActor->actor, 0.0f); EnItem00_SetupAction(spawnedActor, func_8001E304); - spawnedActor->unk_15A = 220; + spawnedActor->despawnTimer = 220; if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) && (spawnedActor->actor.params != ITEM00_HEART_PIECE) && (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { @@ -1128,7 +1129,7 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { spawnedActor->actor.room = -1; } - spawnedActor->unk_15A = 220; + spawnedActor->despawnTimer = 220; } } } else { diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 868e753b79..0211cae395 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -173,7 +173,7 @@ void ShotSun_UpdateHyliaSun(ShotSun* this, PlayState* play) { collectible = Item_DropCollectible(play, &spawnPos, ITEM00_MAGIC_LARGE); if (collectible != NULL) { - collectible->unk_15A = 6000; + collectible->despawnTimer = 6000; collectible->actor.speedXZ = 0.0f; } }