From 710e1a7d50a1f987f5fc55abca37f7fdcc8ee43d Mon Sep 17 00:00:00 2001 From: Ozero4 <114027116+Ozero4@users.noreply.github.com> Date: Wed, 21 Oct 2026 03:33:26 +0200 Subject: [PATCH] Document `EnInsect` (#1861) * Document `EnInsect` * Rename ENINSECT_GET_1 to ENINSECT_GET_INIT_FLAGS * Keep values in hex Co-authored-by: Derek Hensley * Apply reviews in EnInsect --------- Co-authored-by: Derek Hensley --- .../actors/ovl_En_Insect/z_en_insect.c | 318 +++++++++--------- .../actors/ovl_En_Insect/z_en_insect.h | 20 +- tools/disasm/n64-jp-1.1/functions.txt | 32 +- tools/disasm/n64-us/functions.txt | 32 +- 4 files changed, 205 insertions(+), 197 deletions(-) diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index ddbcd54d09..9a87c5b0fb 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -13,21 +13,24 @@ void EnInsect_Destroy(Actor* thisx, PlayState* play2); void EnInsect_Update(Actor* thisx, PlayState* play); void EnInsect_Draw(Actor* thisx, PlayState* play); -void func_8091AC78(EnInsect* this); -void func_8091ACC4(EnInsect* this, PlayState* play); -void func_8091AE10(EnInsect* this); -void func_8091AE5C(EnInsect* this, PlayState* play); -void func_8091B030(EnInsect* this); -void func_8091B07C(EnInsect* this, PlayState* play); -void func_8091B2D8(EnInsect* this, PlayState* play); -void func_8091B3D0(EnInsect* this); -void func_8091B440(EnInsect* this, PlayState* play); -void func_8091B618(EnInsect* this); -void func_8091B670(EnInsect* this, PlayState* play); -void func_8091B928(EnInsect* this); -void func_8091B984(EnInsect* this, PlayState* play); +void EnInsect_SetupSlowDown(EnInsect* this); +void EnInsect_SlowDown(EnInsect* this, PlayState* play); +void EnInsect_SetupCrawl(EnInsect* this); +void EnInsect_Crawl(EnInsect* this, PlayState* play); +void EnInsect_SetupRunFromPlayer(EnInsect* this); +void EnInsect_RunFromPlayer(EnInsect* this, PlayState* play); +void EnInsect_Caught(EnInsect* this, PlayState* play); +void EnInsect_SetupDig(EnInsect* this); +void EnInsect_Dig(EnInsect* this, PlayState* play); +void EnInsect_SetupWalkOnWater(EnInsect* this); +void EnInsect_WalkOnWater(EnInsect* this, PlayState* play); +void EnInsect_SetupDrown(EnInsect* this); +void EnInsect_Drown(EnInsect* this, PlayState* play); -s16 D_8091BD60 = 0; +/** + * The number of bugs caught this frame. + */ +static s16 sCaughtCount = 0; ActorProfile En_Insect_Profile = { /**/ ACTOR_EN_INSECT, @@ -68,7 +71,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -u16 D_8091BDB8[] = { 0, 5 }; +static u16 sInitInsectFlags[] = { 0, INSECT_FLAG_0 | INSECT_FLAG_IS_SHORT_LIVED }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), @@ -77,10 +80,10 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(cullingVolumeDownward, 30, ICHAIN_STOP), }; -Vec3f D_8091BDCC = { 0.0f, 0.0f, 0.0f }; +static Vec3f sAccel = { 0.0f, 0.0f, 0.0f }; -void func_8091A8A0(EnInsect* this) { - this->unk_30C = D_8091BDB8[ENINSECT_GET_1(&this->actor)]; +void EnInsect_InitFlags(EnInsect* this) { + this->insectFlags = sInitInsectFlags[ENINSECT_GET_INIT_FLAGS(&this->actor)]; } f32 EnInsect_XZDistanceSquared(Vec3f* arg0, Vec3f* arg1) { @@ -90,30 +93,30 @@ f32 EnInsect_XZDistanceSquared(Vec3f* arg0, Vec3f* arg1) { s32 EnInsect_InBottleRange(EnInsect* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - Vec3f sp1C; + Vec3f pos; if (this->actor.xzDistToPlayer < 32.0f) { - sp1C.x = player->actor.world.pos.x + (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); - sp1C.y = player->actor.world.pos.y; - sp1C.z = player->actor.world.pos.z + (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); - if (EnInsect_XZDistanceSquared(&sp1C, &this->actor.world.pos) <= SQ(20.0f)) { + pos.x = player->actor.world.pos.x + (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + pos.y = player->actor.world.pos.y; + pos.z = player->actor.world.pos.z + (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + if (EnInsect_XZDistanceSquared(&pos, &this->actor.world.pos) <= SQ(20.0f)) { return true; } } return false; } -void func_8091A9E4(EnInsect* this) { - if (this->unk_316 > 0) { - this->unk_316--; +void EnInsect_UpdateCrawlSfx(EnInsect* this) { + if (this->crawlSoundDelay > 0) { + this->crawlSoundDelay--; return; } Actor_PlaySfx(&this->actor, NA_SE_EN_MUSI_WALK); - this->unk_316 = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); - if (this->unk_316 < 2) { - this->unk_316 = 2; + this->crawlSoundDelay = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); + if (this->crawlSoundDelay < 2) { + this->crawlSoundDelay = 2; } } @@ -126,7 +129,7 @@ void EnInsect_Init(Actor* thisx, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; Actor_ProcessInitChain(&this->actor, sInitChain); - func_8091A8A0(this); + EnInsect_InitFlags(this); SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, this->jointTable, this->morphTable, BUG_LIMB_MAX); @@ -142,23 +145,23 @@ void EnInsect_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = 30; - if (this->unk_30C & 1) { + if (this->insectFlags & INSECT_FLAG_0) { this->actor.gravity = -0.2f; this->actor.terminalVelocity = -2.0f; } - if (this->unk_30C & 4) { - this->unk_314 = Rand_S16Offset(200, 40); + if (this->insectFlags & INSECT_FLAG_IS_SHORT_LIVED) { + this->lifeTimer = Rand_S16Offset(200, 40); this->actor.flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED; } rand = Rand_ZeroOne(); if (rand < 0.3f) { - func_8091AC78(this); + EnInsect_SetupSlowDown(this); } else if (rand < 0.4f) { - func_8091AE10(this); + EnInsect_SetupCrawl(this); } else { - func_8091B030(this); + EnInsect_SetupRunFromPlayer(this); } } @@ -169,102 +172,97 @@ void EnInsect_Destroy(Actor* thisx, PlayState* play2) { Collider_DestroyJntSph(play, &this->collider); } -void func_8091AC78(EnInsect* this) { - this->unk_312 = Rand_S16Offset(5, 35); - this->actionFunc = func_8091ACC4; - this->unk_30C |= 0x100; +void EnInsect_SetupSlowDown(EnInsect* this) { + this->actionTimer = Rand_S16Offset(5, 35); + this->actionFunc = EnInsect_SlowDown; + this->insectFlags |= INSECT_FLAG_CRAWLING; } -void func_8091ACC4(EnInsect* this, PlayState* play) { - f32 temp_f2; +void EnInsect_SlowDown(EnInsect* this, PlayState* play) { + f32 playSpeed; Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.1f, 0.5f, 0.0f); - temp_f2 = (Rand_ZeroOne() * 0.8f) + (this->actor.speed * 1.2f); - if (temp_f2 < 0.0f) { - this->skelAnime.playSpeed = 0.0f; - } else { - f32 clamped = CLAMP_MAX(temp_f2, 1.9f); - - this->skelAnime.playSpeed = clamped; - } + playSpeed = (Rand_ZeroOne() * 0.8f) + (this->actor.speed * 1.2f); + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.0f, 1.9f); SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_312 <= 0) { - func_8091AE10(this); + if (this->actionTimer <= 0) { + EnInsect_SetupCrawl(this); } - if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { - func_8091B3D0(this); - } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { - func_8091B618(this); + if ((this->insectFlags & INSECT_FLAG_IS_SHORT_LIVED) && (this->lifeTimer <= 0)) { + EnInsect_SetupDig(this); + } else if ((this->insectFlags & INSECT_FLAG_0) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { + EnInsect_SetupWalkOnWater(this); } else if (this->actor.xzDistToPlayer < 40.0f) { - func_8091B030(this); + EnInsect_SetupRunFromPlayer(this); } } -void func_8091AE10(EnInsect* this) { - this->unk_312 = Rand_S16Offset(10, 45); - this->actionFunc = func_8091AE5C; - this->unk_30C |= 0x100; +void EnInsect_SetupCrawl(EnInsect* this) { + this->actionTimer = Rand_S16Offset(10, 45); + this->actionFunc = EnInsect_Crawl; + this->insectFlags |= INSECT_FLAG_CRAWLING; } -void func_8091AE5C(EnInsect* this, PlayState* play) { +void EnInsect_Crawl(EnInsect* this, PlayState* play) { s32 pad; - f32 temp_f0; + f32 playSpeed; + s16 yaw; Math_SmoothStepToF(&this->actor.speed, 1.5f, 0.1f, 0.5f, 0.0f); if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(40.0f)) || - (this->unk_312 < 4)) { - Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), - 0x7D0); + (this->actionTimer < 4)) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); } else if ((this->actor.child != NULL) && (&this->actor != this->actor.child)) { - Math_ScaledStepToS(&this->actor.world.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos), 0x7D0); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); } this->actor.shape.rot.y = this->actor.world.rot.y; - temp_f0 = this->actor.speed * 1.4f; - this->skelAnime.playSpeed = CLAMP(temp_f0, 0.7f, 1.9f); + playSpeed = this->actor.speed * 1.4f; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.7f, 1.9f); SkelAnime_Update(&this->skelAnime); - if (this->unk_312 <= 0) { - func_8091AC78(this); + if (this->actionTimer <= 0) { + EnInsect_SetupSlowDown(this); } - if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { - func_8091B3D0(this); - } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { - func_8091B618(this); + if ((this->insectFlags & INSECT_FLAG_IS_SHORT_LIVED) && (this->lifeTimer <= 0)) { + EnInsect_SetupDig(this); + } else if ((this->insectFlags & INSECT_FLAG_0) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { + EnInsect_SetupWalkOnWater(this); } else if (this->actor.xzDistToPlayer < 40.0f) { - func_8091B030(this); + EnInsect_SetupRunFromPlayer(this); } } -void func_8091B030(EnInsect* this) { - this->unk_312 = Rand_S16Offset(10, 40); - this->actionFunc = func_8091B07C; - this->unk_30C |= 0x100; +void EnInsect_SetupRunFromPlayer(EnInsect* this) { + this->actionTimer = Rand_S16Offset(10, 40); + this->actionFunc = EnInsect_RunFromPlayer; + this->insectFlags |= INSECT_FLAG_CRAWLING; } -void func_8091B07C(EnInsect* this, PlayState* play) { +void EnInsect_RunFromPlayer(EnInsect* this, PlayState* play) { s32 pad; - f32 speed; + f32 playSpeed; s16 frames; s16 yaw; - s32 sp38 = this->actor.xzDistToPlayer < 40.0f; + s32 playerIsClose = this->actor.xzDistToPlayer < 40.0f; Math_SmoothStepToF(&this->actor.speed, 1.8f, 0.1f, 0.5f, 0.0f); if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(160.0f)) || - (this->unk_312 < 4)) { + (this->actionTimer < 4)) { Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), - 0x7D0); - } else if (sp38) { + 2000); + } else if (playerIsClose) { frames = play->state.frames; yaw = BINANG_ROT180(this->actor.yawTowardsPlayer); if ((frames & 0x10) != 0) { @@ -278,62 +276,62 @@ void func_8091B07C(EnInsect* this, PlayState* play) { //! FAKE: if (play) {} - Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 0x7D0); + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000); } this->actor.shape.rot.y = this->actor.world.rot.y; - speed = this->actor.speed * 1.6f; - this->skelAnime.playSpeed = CLAMP(speed, 0.8f, 1.9f); + playSpeed = this->actor.speed * 1.6f; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.8f, 1.9f); SkelAnime_Update(&this->skelAnime); - if ((this->unk_312 <= 0) || !sp38) { - func_8091AC78(this); - } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { - func_8091B618(this); + if ((this->actionTimer <= 0) || !playerIsClose) { + EnInsect_SetupSlowDown(this); + } else if ((this->insectFlags & INSECT_FLAG_0) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { + EnInsect_SetupWalkOnWater(this); } } -void func_8091B274(EnInsect* this) { - this->unk_312 = 200; +void EnInsect_SetupCaught(EnInsect* this) { + this->actionTimer = 200; Actor_SetScale(&this->actor, 0.001f); this->actor.draw = NULL; this->actor.speed = 0.0f; this->skelAnime.playSpeed = 0.3f; - this->actionFunc = func_8091B2D8; - this->unk_30C &= ~0x100; + this->actionFunc = EnInsect_Caught; + this->insectFlags &= ~INSECT_FLAG_CRAWLING; } -void func_8091B2D8(EnInsect* this, PlayState* play) { - if ((this->unk_312 == 20) && !(this->unk_30C & 4)) { +void EnInsect_Caught(EnInsect* this, PlayState* play) { + if ((this->actionTimer == 20) && !(this->insectFlags & INSECT_FLAG_IS_SHORT_LIVED)) { this->actor.draw = EnInsect_Draw; - } else if (this->unk_312 == 0) { - if (this->unk_30C & 4) { + } else if (this->actionTimer == 0) { + if (this->insectFlags & INSECT_FLAG_IS_SHORT_LIVED) { Actor_Kill(&this->actor); return; } Actor_SetScale(&this->actor, 0.01f); - func_8091AC78(this); - } else if (this->unk_312 < 20) { + EnInsect_SetupSlowDown(this); + } else if (this->actionTimer < 20) { Actor_SetScale(&this->actor, CLAMP_MAX(this->actor.scale.x + 0.001f, 0.01f)); SkelAnime_Update(&this->skelAnime); } } -void func_8091B3D0(EnInsect* this) { - this->unk_312 = 60; +void EnInsect_SetupDig(EnInsect* this) { + this->actionTimer = 60; this->skelAnime.playSpeed = 1.9f; Actor_PlaySfx(&this->actor, NA_SE_EN_STALTURA_BOUND); Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - this->actionFunc = func_8091B440; - this->unk_30C &= ~0x100; - this->unk_30C |= 8; + this->actionFunc = EnInsect_Dig; + this->insectFlags &= ~INSECT_FLAG_CRAWLING; + this->insectFlags |= INSECT_FLAG_UNCATCHABLE; } -void func_8091B440(EnInsect* this, PlayState* play) { +void EnInsect_Dig(EnInsect* this, PlayState* play) { s32 pad[2]; - Vec3f sp34; + Vec3f velocity; Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.1f, 0.5f, 0.0f); Math_StepToS(&this->actor.shape.rot.x, 0x2AAA, 0x160); @@ -345,33 +343,33 @@ void func_8091B440(EnInsect* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((this->unk_312 > 20) && (Rand_ZeroOne() < 0.1f)) { - sp34.x = Math_SinS(this->actor.shape.rot.y) * -0.6f; - sp34.y = Math_SinS(this->actor.shape.rot.x) * 0.6f; - sp34.z = Math_CosS(this->actor.shape.rot.y) * -0.6f; - func_800B1210(play, &this->actor.world.pos, &sp34, &D_8091BDCC, (Rand_ZeroOne() * 5.0f) + 8.0f, + if ((this->actionTimer > 20) && (Rand_ZeroOne() < 0.1f)) { + velocity.x = Math_SinS(this->actor.shape.rot.y) * -0.6f; + velocity.y = Math_SinS(this->actor.shape.rot.x) * 0.6f; + velocity.z = Math_CosS(this->actor.shape.rot.y) * -0.6f; + func_800B1210(play, &this->actor.world.pos, &velocity, &sAccel, (Rand_ZeroOne() * 5.0f) + 8.0f, (Rand_ZeroOne() * 5.0f) + 8.0f); } - if (this->unk_312 <= 0) { + if (this->actionTimer <= 0) { Actor_Kill(&this->actor); } } -void func_8091B618(EnInsect* this) { - this->unk_312 = Rand_S16Offset(120, 50); +void EnInsect_SetupWalkOnWater(EnInsect* this) { + this->actionTimer = Rand_S16Offset(120, 50); this->unk_310 = 0; this->unk_30E = this->unk_310; - this->actionFunc = func_8091B670; - this->unk_30C &= ~0x100; + this->actionFunc = EnInsect_WalkOnWater; + this->insectFlags &= ~INSECT_FLAG_CRAWLING; } -void func_8091B670(EnInsect* this, PlayState* play) { +void EnInsect_WalkOnWater(EnInsect* this, PlayState* play) { s32 pad[2]; s16 temp; - Vec3f sp40; + Vec3f ripplePos; - if (this->unk_312 > 80) { + if (this->actionTimer > 80) { Math_StepToF(&this->actor.speed, 0.6f, 0.08f); } else { Math_StepToF(&this->actor.speed, 0.0f, 0.02f); @@ -380,10 +378,10 @@ void func_8091B670(EnInsect* this, PlayState* play) { this->actor.velocity.y = 0.0f; this->actor.world.pos.y += this->actor.depthInWater; - this->skelAnime.playSpeed = CLAMP(this->unk_312 * 0.018f, 0.1f, 1.9f); + this->skelAnime.playSpeed = CLAMP(this->actionTimer * 0.018f, 0.1f, 1.9f); SkelAnime_Update(&this->skelAnime); - if (this->unk_312 > 80) { + if (this->actionTimer > 80) { this->unk_30E += Rand_S16Offset(-50, 100); this->unk_310 += Rand_S16Offset(-300, 600); } @@ -396,45 +394,45 @@ void func_8091B670(EnInsect* this, PlayState* play) { this->unk_310 = CLAMP(this->unk_310, -temp, temp); this->actor.shape.rot.y += this->unk_310; - Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0xBB8); + Math_ScaledStepToS(&this->actor.world.rot.x, 0, 3000); this->actor.shape.rot.x = this->actor.world.rot.x; if (Rand_ZeroOne() < 0.03f) { - sp40.x = this->actor.world.pos.x; - sp40.y = this->actor.world.pos.y + this->actor.depthInWater; - sp40.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(play, &sp40, 40, 200, 4); + ripplePos.x = this->actor.world.pos.x; + ripplePos.y = this->actor.world.pos.y + this->actor.depthInWater; + ripplePos.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(play, &ripplePos, 40, 200, 4); } - if ((this->unk_312 <= 0) || ((this->unk_30C & 4) && (this->unk_314 <= 0))) { - func_8091B928(this); + if ((this->actionTimer <= 0) || ((this->insectFlags & INSECT_FLAG_IS_SHORT_LIVED) && (this->lifeTimer <= 0))) { + EnInsect_SetupDrown(this); } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { - func_8091AC78(this); + EnInsect_SetupSlowDown(this); } } -void func_8091B928(EnInsect* this) { - this->unk_312 = 100; +void EnInsect_SetupDrown(EnInsect* this) { + this->actionTimer = 100; this->actor.velocity.y = 0.0f; this->actor.speed = 0.0f; this->actor.terminalVelocity = -0.8f; this->actor.gravity = -0.04f; - this->unk_30C &= ~1; - this->actionFunc = func_8091B984; - this->unk_30C &= ~0x100; - this->unk_30C |= 8; + this->insectFlags &= ~INSECT_FLAG_0; + this->actionFunc = EnInsect_Drown; + this->insectFlags &= ~INSECT_FLAG_CRAWLING; + this->insectFlags |= INSECT_FLAG_UNCATCHABLE; } -void func_8091B984(EnInsect* this, PlayState* play) { - this->actor.shape.rot.x -= 0x1F4; - this->actor.shape.rot.y += 0xC8; +void EnInsect_Drown(EnInsect* this, PlayState* play) { + this->actor.shape.rot.x -= 500; + this->actor.shape.rot.y += 200; Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.00005f, 0.001f)); if ((this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && (Rand_ZeroOne() < 0.3f)) { EffectSsBubble_Spawn(play, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); } - if (this->unk_312 <= 0) { + if (this->actionTimer <= 0) { Actor_Kill(&this->actor); } } @@ -447,30 +445,30 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { this->actor.child = NULL; } - if (this->unk_312 > 0) { - this->unk_312--; + if (this->actionTimer > 0) { + this->actionTimer--; } - if (this->unk_314 > 0) { - this->unk_314--; + if (this->lifeTimer > 0) { + this->lifeTimer--; } this->actionFunc(this, play); if (this->actor.update != NULL) { Actor_MoveWithGravity(&this->actor); - if (this->unk_30C & 0x100) { - if (this->unk_30C & 1) { + if (this->insectFlags & INSECT_FLAG_CRAWLING) { + if (this->insectFlags & INSECT_FLAG_0) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - func_8091A9E4(this); + EnInsect_UpdateCrawlSfx(this); } } else { - func_8091A9E4(this); + EnInsect_UpdateCrawlSfx(this); } } updBgCheckInfoFlags = 0; - if (this->unk_30C & 1) { + if (this->insectFlags & INSECT_FLAG_0) { updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4; } @@ -481,9 +479,9 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - func_8091B274(this); - } else if ((this->actor.xzDistToPlayer < 50.0f) && (this->actionFunc != func_8091B2D8)) { - if (!(this->unk_30C & 0x20) && (this->unk_314 < 180)) { + EnInsect_SetupCaught(this); + } else if ((this->actor.xzDistToPlayer < 50.0f) && (this->actionFunc != EnInsect_Caught)) { + if (!(this->insectFlags & INSECT_FLAG_SOIL_CLOSE) && (this->lifeTimer < 180)) { ColliderJntSphElement* jntSphElem = &this->collider.elements[0]; jntSphElem->dim.worldSphere.center.x = this->actor.world.pos.x; @@ -492,9 +490,9 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } - if (!(this->unk_30C & 8) && (D_8091BD60 < 4) && EnInsect_InBottleRange(this, play) && - Actor_OfferGetItem(&this->actor, play, GI_MAX, 60.0f, 30.0f)) { - D_8091BD60++; + if (!(this->insectFlags & INSECT_FLAG_UNCATCHABLE) && (sCaughtCount < 4) && + EnInsect_InBottleRange(this, play) && Actor_OfferGetItem(&this->actor, play, GI_MAX, 60.0f, 30.0f)) { + sCaughtCount++; } } @@ -507,5 +505,5 @@ void EnInsect_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL25_Opa(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - D_8091BD60 = 0; + sCaughtCount = 0; } diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.h b/src/overlays/actors/ovl_En_Insect/z_en_insect.h index 48c6a17ea5..5ae84f0996 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -8,7 +8,17 @@ struct EnInsect; typedef void (*EnInsectActionFunc)(struct EnInsect*, PlayState*); -#define ENINSECT_GET_1(thisx) ((thisx)->params & 1) +#define INSECT_FLAG_0 (1 << 0) +#define INSECT_FLAG_1 (1 << 1) +#define INSECT_FLAG_IS_SHORT_LIVED (1 << 2) +#define INSECT_FLAG_UNCATCHABLE (1 << 3) // Set when the bug is about to disappear and can no longer be caught. +#define INSECT_FLAG_FOUND_SOIL (1 << 4) +#define INSECT_FLAG_SOIL_CLOSE (1 << 5) +#define INSECT_FLAG_DROPPED_HAS_LANDED (1 << 6) // Set when the landing sound has been played. +#define INSECT_FLAG_7 (1 << 7) +#define INSECT_FLAG_CRAWLING (1 << 8) + +#define ENINSECT_GET_INIT_FLAGS(thisx) ((thisx)->params & 1) #define ENINSECT_PARAMS(param) (param) @@ -20,12 +30,12 @@ typedef struct EnInsect { /* 0x1E8 */ Vec3s jointTable[BUG_LIMB_MAX]; /* 0x278 */ Vec3s morphTable[BUG_LIMB_MAX]; /* 0x308 */ EnInsectActionFunc actionFunc; - /* 0x30C */ u16 unk_30C; + /* 0x30C */ u16 insectFlags; /* 0x30E */ s16 unk_30E; /* 0x310 */ s16 unk_310; - /* 0x312 */ s16 unk_312; - /* 0x314 */ s16 unk_314; - /* 0x316 */ s16 unk_316; + /* 0x312 */ s16 actionTimer; + /* 0x314 */ s16 lifeTimer; + /* 0x316 */ s16 crawlSoundDelay; } EnInsect; // size = 0x318 #endif // Z_EN_INSECT_H diff --git a/tools/disasm/n64-jp-1.1/functions.txt b/tools/disasm/n64-jp-1.1/functions.txt index c4ae42ba4e..a382f5e87b 100644 --- a/tools/disasm/n64-jp-1.1/functions.txt +++ b/tools/disasm/n64-jp-1.1/functions.txt @@ -6904,26 +6904,26 @@ BgUmajump_Destroy = 0x8091C50C; // type:func size:0x34 BgUmajump_Update = 0x8091C540; // type:func size:0x260 func_8091A5A0 = 0x8091C7A0; // type:func size:0x210 BgUmajump_Draw = 0x8091C9B0; // type:func size:0x40 -func_8091A8A0 = 0x8091CAB0; // type:func size:0x24 +EnInsect_InitFlags = 0x8091CAB0; // type:func size:0x24 EnInsect_XZDistanceSquared = 0x8091CAD4; // type:func size:0x30 EnInsect_InBottleRange = 0x8091CB04; // type:func size:0xF0 -func_8091A9E4 = 0x8091CBF4; // type:func size:0x94 +EnInsect_UpdateCrawlSfx = 0x8091CBF4; // type:func size:0x94 EnInsect_Init = 0x8091CC88; // type:func size:0x1D4 EnInsect_Destroy = 0x8091CE5C; // type:func size:0x2C -func_8091AC78 = 0x8091CE88; // type:func size:0x4C -func_8091ACC4 = 0x8091CED4; // type:func size:0x14C -func_8091AE10 = 0x8091D020; // type:func size:0x4C -func_8091AE5C = 0x8091D06C; // type:func size:0x1D4 -func_8091B030 = 0x8091D240; // type:func size:0x4C -func_8091B07C = 0x8091D28C; // type:func size:0x1F8 -func_8091B274 = 0x8091D484; // type:func size:0x64 -func_8091B2D8 = 0x8091D4E8; // type:func size:0xF8 -func_8091B3D0 = 0x8091D5E0; // type:func size:0x70 -func_8091B440 = 0x8091D650; // type:func size:0x1D8 -func_8091B618 = 0x8091D828; // type:func size:0x58 -func_8091B670 = 0x8091D880; // type:func size:0x2B8 -func_8091B928 = 0x8091DB38; // type:func size:0x5C -func_8091B984 = 0x8091DB94; // type:func size:0x130 +EnInsect_SetupSlowDown = 0x8091CE88; // type:func size:0x4C +EnInsect_SlowDown = 0x8091CED4; // type:func size:0x14C +EnInsect_SetupCrawl = 0x8091D020; // type:func size:0x4C +EnInsect_Crawl = 0x8091D06C; // type:func size:0x1D4 +EnInsect_SetupRunFromPlayer = 0x8091D240; // type:func size:0x4C +EnInsect_RunFromPlayer = 0x8091D28C; // type:func size:0x1F8 +EnInsect_SetupCaught = 0x8091D484; // type:func size:0x64 +EnInsect_Caught = 0x8091D4E8; // type:func size:0xF8 +EnInsect_SetupDig = 0x8091D5E0; // type:func size:0x70 +EnInsect_Dig = 0x8091D650; // type:func size:0x1D8 +EnInsect_SetupWalkOnWater = 0x8091D828; // type:func size:0x58 +EnInsect_WalkOnWater = 0x8091D880; // type:func size:0x2B8 +EnInsect_SetupDrown = 0x8091DB38; // type:func size:0x5C +EnInsect_Drown = 0x8091DB94; // type:func size:0x130 EnInsect_Update = 0x8091DCC4; // type:func size:0x250 EnInsect_Draw = 0x8091DF14; // type:func size:0x5C func_8091C0A0 = 0x8091E2B0; // type:func size:0x84 diff --git a/tools/disasm/n64-us/functions.txt b/tools/disasm/n64-us/functions.txt index 73ce68a592..13773a6a89 100644 --- a/tools/disasm/n64-us/functions.txt +++ b/tools/disasm/n64-us/functions.txt @@ -6908,26 +6908,26 @@ BgUmajump_Destroy = 0x8091A2D8; // type:func BgUmajump_Update = 0x8091A30C; // type:func func_8091A5A0 = 0x8091A5A0; // type:func BgUmajump_Draw = 0x8091A7B0; // type:func -func_8091A8A0 = 0x8091A8A0; // type:func +EnInsect_InitFlags = 0x8091A8A0; // type:func EnInsect_XZDistanceSquared = 0x8091A8C4; // type:func EnInsect_InBottleRange = 0x8091A8F4; // type:func -func_8091A9E4 = 0x8091A9E4; // type:func +EnInsect_UpdateCrawlSfx = 0x8091A9E4; // type:func EnInsect_Init = 0x8091AA78; // type:func EnInsect_Destroy = 0x8091AC4C; // type:func -func_8091AC78 = 0x8091AC78; // type:func -func_8091ACC4 = 0x8091ACC4; // type:func -func_8091AE10 = 0x8091AE10; // type:func -func_8091AE5C = 0x8091AE5C; // type:func -func_8091B030 = 0x8091B030; // type:func -func_8091B07C = 0x8091B07C; // type:func -func_8091B274 = 0x8091B274; // type:func -func_8091B2D8 = 0x8091B2D8; // type:func -func_8091B3D0 = 0x8091B3D0; // type:func -func_8091B440 = 0x8091B440; // type:func -func_8091B618 = 0x8091B618; // type:func -func_8091B670 = 0x8091B670; // type:func -func_8091B928 = 0x8091B928; // type:func -func_8091B984 = 0x8091B984; // type:func +EnInsect_SetupSlowDown = 0x8091AC78; // type:func +EnInsect_SlowDown = 0x8091ACC4; // type:func +EnInsect_SetupCrawl = 0x8091AE10; // type:func +EnInsect_Crawl = 0x8091AE5C; // type:func +EnInsect_SetupRunFromPlayer = 0x8091B030; // type:func +EnInsect_RunFromPlayer = 0x8091B07C; // type:func +EnInsect_SetupCaught = 0x8091B274; // type:func +EnInsect_Caught = 0x8091B2D8; // type:func +EnInsect_SetupDig = 0x8091B3D0; // type:func +EnInsect_Dig = 0x8091B440; // type:func +EnInsect_SetupWalkOnWater = 0x8091B618; // type:func +EnInsect_WalkOnWater = 0x8091B670; // type:func +EnInsect_SetupDrown = 0x8091B928; // type:func +EnInsect_Drown = 0x8091B984; // type:func EnInsect_Update = 0x8091BAB4; // type:func EnInsect_Draw = 0x8091BD04; // type:func func_8091C0A0 = 0x8091C0A0; // type:func