From 4f6967b02778e61ed0e9fa471f9ba7d67524c908 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sun, 20 Mar 2022 00:42:11 +0100 Subject: [PATCH] Doc misc 4 (#1177) * Doc/cleanup misc * Name `prevFrame`/`beforeCurFrame`/`afterPrevFrame` and related variables * Actually this pad variable I renamed can be removed --- src/overlays/actors/ovl_En_Du/z_en_du.c | 21 +---- src/overlays/actors/ovl_En_Fw/z_en_fw.c | 16 ++-- src/overlays/actors/ovl_En_GeldB/z_en_geldb.c | 79 ++++++++++--------- src/overlays/actors/ovl_En_Test/z_en_test.c | 51 ++++++------ src/overlays/actors/ovl_En_Wf/z_en_wf.c | 50 ++++++------ src/overlays/actors/ovl_En_Zf/z_en_zf.c | 59 +++++++------- 6 files changed, 133 insertions(+), 143 deletions(-) diff --git a/src/overlays/actors/ovl_En_Du/z_en_du.c b/src/overlays/actors/ovl_En_Du/z_en_du.c index fdcfa71d98..2a57b1c4b6 100644 --- a/src/overlays/actors/ovl_En_Du/z_en_du.c +++ b/src/overlays/actors/ovl_En_Du/z_en_du.c @@ -373,15 +373,7 @@ void func_809FE638(EnDu* this, GlobalContext* globalCtx) { } void func_809FE6CC(EnDu* this, GlobalContext* globalCtx) { - s16 phi_v1; - - if (this->unk_1E2 == 0) { - phi_v1 = 0; - } else { - this->unk_1E2--; - phi_v1 = this->unk_1E2; - } - if (phi_v1 == 0) { + if (DECR(this->unk_1E2) == 0) { this->actor.textId = 0x3039; Message_StartTextbox(globalCtx, this->actor.textId, NULL); this->unk_1F4.unk_00 = 1; @@ -398,15 +390,7 @@ void func_809FE740(EnDu* this, GlobalContext* globalCtx) { } void func_809FE798(EnDu* this, GlobalContext* globalCtx) { - s32 phi_v0; - - if (this->unk_1E2 == 0) { - phi_v0 = 0; - } else { - this->unk_1E2--; - phi_v0 = this->unk_1E2; - } - if (phi_v0 != 0) { + if (DECR(this->unk_1E2) != 0) { switch (this->unk_1E2) { case 0x50: Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); @@ -536,6 +520,7 @@ void func_809FEC70(EnDu* this, GlobalContext* globalCtx) { EnDu_SetupAction(this, func_809FECE4); } else { f32 xzRange = this->actor.xzDistToPlayer + 1.0f; + func_8002F434(&this->actor, globalCtx, GI_BRACELET, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); } } diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.c b/src/overlays/actors/ovl_En_Fw/z_en_fw.c index 35826f10d5..4ace60c661 100644 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.c +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.c @@ -78,8 +78,6 @@ static AnimationInfo sAnimationInfo[] = { }; s32 EnFw_DoBounce(EnFw* this, s32 totalBounces, f32 yVelocity) { - s16 temp_v1; - if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.velocity.y > 0.0f)) { // not on the ground or moving upwards. return false; @@ -96,8 +94,8 @@ s32 EnFw_DoBounce(EnFw* this, s32 totalBounces, f32 yVelocity) { this->bounceCnt = totalBounces; } this->actor.velocity.y = yVelocity; - this->actor.velocity.y *= ((f32)this->bounceCnt / totalBounces); - return 1; + this->actor.velocity.y *= (f32)this->bounceCnt / totalBounces; + return true; } s32 EnFw_PlayerInRange(EnFw* this, GlobalContext* globalCtx) { @@ -138,7 +136,6 @@ Vec3f* EnFw_GetPosAdjAroundCircle(Vec3f* dst, EnFw* this, f32 radius, s16 dir) { s32 EnFw_CheckCollider(EnFw* this, GlobalContext* globalCtx) { ColliderInfo* info; - s32 phi_return; if (this->collider.base.acFlags & AC_HIT) { info = &this->collider.elements[0].info; @@ -205,6 +202,7 @@ void EnFw_Init(Actor* thisx, GlobalContext* globalCtx) { void EnFw_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnFw* this = (EnFw*)thisx; + Collider_DestroyJntSph(globalCtx, &this->collider); } @@ -217,7 +215,7 @@ void EnFw_Bounce(EnFw* this, GlobalContext* globalCtx) { void EnFw_Run(EnFw* this, GlobalContext* globalCtx) { f32 tmpAngle; - s16 phi_v0; + s16 curFrame; f32 facingDir; EnBom* bomb; Actor* flareDancer; @@ -295,6 +293,7 @@ void EnFw_Run(EnFw* this, GlobalContext* globalCtx) { this->turnAround = false; } else { Vec3f sp48; + EnFw_GetPosAdjAroundCircle(&sp48, this, this->runRadius, this->runDirection); Math_SmoothStepToS(&this->actor.shape.rot.y, RADF_TO_BINANG(Math_FAtan2F(sp48.x, sp48.z)), 4, 0xFA0, 1); } @@ -322,8 +321,8 @@ void EnFw_Run(EnFw* this, GlobalContext* globalCtx) { } } else { Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.1f, 1.0f, 0.0f); - phi_v0 = this->skelAnime.curFrame; - if (phi_v0 == 1 || phi_v0 == 4) { + curFrame = this->skelAnime.curFrame; + if (curFrame == 1 || curFrame == 4) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLAME_MAN_RUN); EnFw_SpawnDust(this, 8, 0.16f, 0.1f, 1, 0.0f, 20.0f, 0.0f); } @@ -359,6 +358,7 @@ void EnFw_JumpToParentInitPos(EnFw* this, GlobalContext* globalCtx) { void EnFw_Update(Actor* thisx, GlobalContext* globalCtx) { EnFw* this = (EnFw*)thisx; + SkelAnime_Update(&this->skelAnime); if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { // not attached to hookshot. diff --git a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c index 9fa9873012..eb6e5fe6e5 100644 --- a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c +++ b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c @@ -481,9 +481,9 @@ void EnGeldB_SetupAdvance(EnGeldB* this, GlobalContext* globalCtx) { } void EnGeldB_Advance(EnGeldB* this, GlobalContext* globalCtx) { - s32 thisKeyFrame; - s32 prevKeyFrame; - s32 playSpeed; + s32 prevFrame; + s32 beforeCurFrame; + s32 absPlaySpeed; s16 facingAngletoLink; Player* player = GET_PLAYER(globalCtx); @@ -507,10 +507,12 @@ void EnGeldB_Advance(EnGeldB* this, GlobalContext* globalCtx) { return; } } - thisKeyFrame = (s32)this->skelAnime.curFrame; + + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); + if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { if (Rand_ZeroOne() > 0.5f) { EnGeldB_SetupCircle(this); @@ -528,7 +530,7 @@ void EnGeldB_Advance(EnGeldB* this, GlobalContext* globalCtx) { } } if (!EnGeldB_ReactToPlayer(globalCtx, this, 0)) { - if ((210.0f > this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 150.0f) && + if ((this->actor.xzDistToPlayer < 210.0f) && (this->actor.xzDistToPlayer > 150.0f) && Actor_IsFacingPlayer(&this->actor, 0x71C)) { if (Actor_IsTargeted(globalCtx, &this->actor)) { if (Rand_ZeroOne() > 0.5f) { @@ -544,10 +546,10 @@ void EnGeldB_Advance(EnGeldB* this, GlobalContext* globalCtx) { if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); } - if (thisKeyFrame != (s32)this->skelAnime.curFrame) { - s32 temp = playSpeed + thisKeyFrame; + if (prevFrame != (s32)this->skelAnime.curFrame) { + s32 afterPrevFrame = absPlaySpeed + prevFrame; - if (((prevKeyFrame < 0) && (temp > 0)) || ((prevKeyFrame < 4) && (temp > 4))) { + if (((beforeCurFrame < 0) && (afterPrevFrame > 0)) || ((beforeCurFrame < 4) && (afterPrevFrame > 4))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); } } @@ -646,10 +648,10 @@ void EnGeldB_SetupCircle(EnGeldB* this) { void EnGeldB_Circle(EnGeldB* this, GlobalContext* globalCtx) { s16 angleBehindLink; s16 phi_v1; - s32 nextKeyFrame; - s32 thisKeyFrame; + s32 afterPrevFrame; + s32 prevFrame; s32 pad; - s32 prevKeyFrame; + s32 beforeCurFrame; Player* player = GET_PLAYER(globalCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); @@ -708,15 +710,16 @@ void EnGeldB_Circle(EnGeldB* this, GlobalContext* globalCtx) { } this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - thisKeyFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + afterPrevFrame = (s32)ABS(this->skelAnime.playSpeed) + prevFrame; - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - nextKeyFrame = (s32)ABS(this->skelAnime.playSpeed) + thisKeyFrame; - if ((thisKeyFrame != (s32)this->skelAnime.curFrame) && - ((prevKeyFrame < 0 && 0 < nextKeyFrame) || (prevKeyFrame < 5 && 5 < nextKeyFrame))) { + if ((prevFrame != (s32)this->skelAnime.curFrame) && + (((beforeCurFrame < 0) && (afterPrevFrame > 0)) || ((beforeCurFrame < 5) && (afterPrevFrame > 5)))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); } @@ -761,10 +764,10 @@ void EnGeldB_SetupSpinDodge(EnGeldB* this, GlobalContext* globalCtx) { void EnGeldB_SpinDodge(EnGeldB* this, GlobalContext* globalCtx) { s16 phi_v1; - s32 thisKeyFrame; + s32 prevFrame; s32 pad; - s32 lastKeyFrame; - s32 nextKeyFrame; + s32 beforeCurFrame; + s32 afterPrevFrame; this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x3A98; if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || @@ -802,14 +805,17 @@ void EnGeldB_SpinDodge(EnGeldB* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = -this->approachRate * 0.5f; } this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - thisKeyFrame = this->skelAnime.curFrame; + + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - lastKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - nextKeyFrame = (s32)ABS(this->skelAnime.playSpeed) + thisKeyFrame; - if ((thisKeyFrame != (s32)this->skelAnime.curFrame) && - ((lastKeyFrame < 0 && 0 < nextKeyFrame) || (lastKeyFrame < 5 && 5 < nextKeyFrame))) { + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + afterPrevFrame = (s32)ABS(this->skelAnime.playSpeed) + prevFrame; + + if ((prevFrame != (s32)this->skelAnime.curFrame) && + (((beforeCurFrame < 0) && (afterPrevFrame > 0)) || ((beforeCurFrame < 5) && (afterPrevFrame > 5)))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); } + if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_BREATH); } @@ -1206,9 +1212,9 @@ void EnGeldB_Sidestep(EnGeldB* this, GlobalContext* globalCtx) { s16 behindLinkAngle; s16 phi_v1; Player* player = GET_PLAYER(globalCtx); - s32 thisKeyFrame; - s32 prevKeyFrame; - f32 playSpeed; + s32 prevFrame; + s32 beforeCurFrame; + f32 absPlaySpeed; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 1); behindLinkAngle = player->actor.shape.rot.y + 0x8000; @@ -1262,11 +1268,11 @@ void EnGeldB_Sidestep(EnGeldB* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = -this->approachRate * 0.5f; } this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - thisKeyFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = ((void)0, ABS(this->skelAnime.playSpeed)); // Needed to match for some reason + prevFrame = (s32)this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = ((void)0, ABS(this->skelAnime.playSpeed)); // Needed to match for some reason if (!EnGeldB_DodgeRanged(globalCtx, this) && !EnGeldB_ReactToPlayer(globalCtx, this, 0)) { if (--this->timer == 0) { @@ -1297,9 +1303,9 @@ void EnGeldB_Sidestep(EnGeldB* this, GlobalContext* globalCtx) { } } } - if ((thisKeyFrame != (s32)this->skelAnime.curFrame) && - (((prevKeyFrame < 0) && (((s32)playSpeed + thisKeyFrame) > 0)) || - ((prevKeyFrame < 5) && (((s32)playSpeed + thisKeyFrame) > 5)))) { + if ((prevFrame != (s32)this->skelAnime.curFrame) && + (((beforeCurFrame < 0) && (((s32)absPlaySpeed + prevFrame) > 0)) || + ((beforeCurFrame < 5) && (((s32)absPlaySpeed + prevFrame) > 5)))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_LAND); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -1618,7 +1624,6 @@ s32 EnGeldB_DodgeRanged(GlobalContext* globalCtx, EnGeldB* this) { if (actor != NULL) { s16 angleToFacing; - s16 pad18; f32 dist; angleToFacing = Actor_WorldYawTowardActor(&this->actor, actor) - this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 30f672835d..8ca271ec8b 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -568,7 +568,7 @@ void EnTest_WalkAndBlock(EnTest* this, GlobalContext* globalCtx) { f32 checkDist = 0.0f; s32 pad1; s32 prevFrame; - s32 temp_f16; + s32 beforeCurFrame; f32 playSpeed; Player* player = GET_PLAYER(globalCtx); s32 absPlaySpeed; @@ -636,16 +636,15 @@ void EnTest_WalkAndBlock(EnTest* this, GlobalContext* globalCtx) { } } - prevFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - - temp_f16 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 temp_v0_2 = absPlaySpeed + prevFrame; + s32 afterPrevFrame = absPlaySpeed + prevFrame; - if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { + if (((afterPrevFrame > 1) && (beforeCurFrame < 1)) || ((beforeCurFrame < 7) && (afterPrevFrame > 7))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); } } @@ -719,8 +718,8 @@ void func_80860C24(EnTest* this, GlobalContext* globalCtx) { s16 yawChange; f32 playSpeed; s32 prevFrame; - s32 temp1; - s32 temp2; + s32 beforeCurFrame; + s32 afterPrevFrame; s32 absPlaySpeed; if (!EnTest_ReactToProjectile(globalCtx, this)) { @@ -747,15 +746,15 @@ void func_80860C24(EnTest* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = playSpeed; } - prevFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - temp1 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if ((s32)this->skelAnime.curFrame != prevFrame) { - temp2 = absPlaySpeed + prevFrame; + afterPrevFrame = absPlaySpeed + prevFrame; - if (((temp2 > 2) && (temp1 <= 0)) || ((temp1 < 7) && (temp2 >= 9))) { + if (((afterPrevFrame > 2) && (beforeCurFrame <= 0)) || ((beforeCurFrame < 7) && (afterPrevFrame >= 9))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); } } @@ -790,7 +789,7 @@ void func_80860F84(EnTest* this, GlobalContext* globalCtx) { s16 playerYaw180; s32 pad; s32 prevFrame; - s32 temp_f16; + s32 beforeCurFrame; s16 yawDiff; Player* player = GET_PLAYER(globalCtx); f32 checkDist = 0.0f; @@ -862,15 +861,15 @@ void func_80860F84(EnTest* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = this->actor.speedXZ * 0.5f; - prevFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - temp_f16 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - absPlaySpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 temp_v0_2 = absPlaySpeed + prevFrame; + s32 afterPrevFrame = absPlaySpeed + prevFrame; - if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { + if (((afterPrevFrame > 1) && (beforeCurFrame < 1)) || ((beforeCurFrame < 7) && (afterPrevFrame > 7))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); } } @@ -1364,7 +1363,7 @@ void func_808628C8(EnTest* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad1; s32 prevFrame; - s32 temp_f16; + s32 beforeCurFrame; s32 pad2; f32 checkDist = 0.0f; s16 newYaw; @@ -1437,19 +1436,19 @@ void func_808628C8(EnTest* this, GlobalContext* globalCtx) { } this->skelAnime.playSpeed = this->actor.speedXZ * 0.5f; - prevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - temp_f16 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); + prevFrame = (s32)this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); absPlaySpeed = ABS(this->skelAnime.playSpeed); if ((this->timer % 32) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WARAU); } if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 temp_v0_2 = (s32)absPlaySpeed + prevFrame; + s32 afterPrevFrame = (s32)absPlaySpeed + prevFrame; - if (((temp_v0_2 > 1) && (temp_f16 <= 0)) || ((temp_f16 < 7) && (temp_v0_2 >= 8))) { + if (((afterPrevFrame > 1) && (beforeCurFrame < 1)) || ((beforeCurFrame < 7) && (afterPrevFrame > 7))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL_WALK); } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 28792d2b1a..32f3331404 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -490,13 +490,13 @@ void EnWf_SetupRunAtPlayer(EnWf* this, GlobalContext* globalCtx) { } void EnWf_RunAtPlayer(EnWf* this, GlobalContext* globalCtx) { - s32 animPrevFrame; - s32 sp58; + s32 prevFrame; + s32 beforeCurFrame; s32 pad; f32 baseRange = 0.0f; s16 playerFacingAngleDiff; Player* player = GET_PLAYER(globalCtx); - s32 playSpeed; + s32 absPlaySpeed; if (!EnWf_DodgeRanged(globalCtx, this)) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x2EE, 0); @@ -528,10 +528,10 @@ void EnWf_RunAtPlayer(EnWf* this, GlobalContext* globalCtx) { } } - animPrevFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - sp58 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { if (Rand_ZeroOne() > 0.5f) { @@ -556,7 +556,8 @@ void EnWf_RunAtPlayer(EnWf* this, GlobalContext* globalCtx) { if ((globalCtx->gameplayFrames & 95) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); } - if ((animPrevFrame != (s32)this->skelAnime.curFrame) && (sp58 <= 0) && ((playSpeed + animPrevFrame) > 0)) { + if ((prevFrame != (s32)this->skelAnime.curFrame) && (beforeCurFrame <= 0) && + ((absPlaySpeed + prevFrame) > 0)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, true); } @@ -632,9 +633,9 @@ void EnWf_RunAroundPlayer(EnWf* this, GlobalContext* globalCtx) { s16 angle2; s32 pad; f32 baseRange = 0.0f; - s32 animPrevFrame; - s32 animFrameSpeedDiff; - s32 animSpeed; + s32 prevFrame; + s32 beforeCurFrame; + s32 absPlaySpeed; Player* player = GET_PLAYER(globalCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->runAngle, 1, 4000, 1); @@ -679,15 +680,14 @@ void EnWf_RunAroundPlayer(EnWf* this, GlobalContext* globalCtx) { } else { this->skelAnime.playSpeed = this->runSpeed * 0.175f; } - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - animPrevFrame = this->skelAnime.curFrame; - SkelAnime_Update(&this->skelAnime); - animFrameSpeedDiff = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - animSpeed = (f32)ABS(this->skelAnime.playSpeed); - if ((animPrevFrame != (s32)this->skelAnime.curFrame) && (animFrameSpeedDiff <= 0) && - (animSpeed + animPrevFrame > 0)) { + prevFrame = (s32)this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); + + if ((prevFrame != (s32)this->skelAnime.curFrame) && (beforeCurFrame <= 0) && (absPlaySpeed + prevFrame > 0)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, true); } @@ -1091,9 +1091,9 @@ void EnWf_SetupSidestep(EnWf* this, GlobalContext* globalCtx) { void EnWf_Sidestep(EnWf* this, GlobalContext* globalCtx) { s16 angleDiff1; Player* player = GET_PLAYER(globalCtx); - s32 animPrevFrame; - s32 animFrameSpeedDiff; - s32 animSpeed; + s32 prevFrame; + s32 beforeCurFrame; + s32 absPlaySpeed; f32 baseRange = 0.0f; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->runAngle, 1, 3000, 1); @@ -1136,13 +1136,12 @@ void EnWf_Sidestep(EnWf* this, GlobalContext* globalCtx) { } else { this->skelAnime.playSpeed = this->runSpeed * 0.175f; } - this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, -3.0f, 3.0f); - animPrevFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - animFrameSpeedDiff = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - animSpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if (!EnWf_ChangeAction(globalCtx, this, false)) { this->actionTimer--; @@ -1169,8 +1168,7 @@ void EnWf_Sidestep(EnWf* this, GlobalContext* globalCtx) { } } - if ((animPrevFrame != (s32)this->skelAnime.curFrame) && (animFrameSpeedDiff <= 0) && - ((animSpeed + animPrevFrame) > 0)) { + if ((prevFrame != (s32)this->skelAnime.curFrame) && (beforeCurFrame <= 0) && ((absPlaySpeed + prevFrame) > 0)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 3, 3.0f, 50, 50, true); } diff --git a/src/overlays/actors/ovl_En_Zf/z_en_zf.c b/src/overlays/actors/ovl_En_Zf/z_en_zf.c index a6ad044114..a041b5372b 100644 --- a/src/overlays/actors/ovl_En_Zf/z_en_zf.c +++ b/src/overlays/actors/ovl_En_Zf/z_en_zf.c @@ -773,15 +773,15 @@ void EnZf_SetupApproachPlayer(EnZf* this, GlobalContext* globalCtx) { } void EnZf_ApproachPlayer(EnZf* this, GlobalContext* globalCtx) { - s32 sp54; - s32 sp50; - s32 temp; + s32 prevFrame; + s32 beforeCurFrame; + s32 afterPrevFrame; s16 temp_v1; s16 sp48 = -1; f32 sp44 = 350.0f; f32 sp40 = 0.0f; Player* player = GET_PLAYER(globalCtx); - s32 sp30; + s32 absPlaySpeed; if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss sp48 = EnZf_FindPlatform(&player->actor.world.pos, sp48); @@ -854,10 +854,10 @@ void EnZf_ApproachPlayer(EnZf* this, GlobalContext* globalCtx) { } } - sp54 = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - sp50 = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - sp30 = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if (sp48 == this->curPlatform) { if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { @@ -907,10 +907,10 @@ void EnZf_ApproachPlayer(EnZf* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); } - if (sp54 != (s32)this->skelAnime.curFrame) { - temp = sp30 + sp54; + if (prevFrame != (s32)this->skelAnime.curFrame) { + afterPrevFrame = absPlaySpeed + prevFrame; - if (((sp50 < 2) && (temp >= 4)) || ((sp50 < 32) && (temp >= 34))) { + if (((beforeCurFrame < 2) && (afterPrevFrame >= 4)) || ((beforeCurFrame < 32) && (afterPrevFrame >= 34))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -1052,9 +1052,9 @@ void func_80B463E4(EnZf* this, GlobalContext* globalCtx) { s16 angleBehindPlayer; s16 phi_v0_3; s32 pad; - s32 curKeyFrame; - s32 prevKeyFrame; - s32 playSpeed; + s32 prevFrame; + s32 beforeCurFrame; + s32 absPlaySpeed; Player* player = GET_PLAYER(globalCtx); f32 baseRange = 0.0f; @@ -1131,15 +1131,16 @@ void func_80B463E4(EnZf* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = this->unk_408 * 0.75f; } - curKeyFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); - if (curKeyFrame != (s32)this->skelAnime.curFrame) { - s32 nextKeyFrame = playSpeed + curKeyFrame; + if (prevFrame != (s32)this->skelAnime.curFrame) { + s32 afterPrevFrame = absPlaySpeed + prevFrame; - if (((prevKeyFrame < 14) && (nextKeyFrame > 15)) || ((prevKeyFrame < 27) && (nextKeyFrame > 28))) { + if (((beforeCurFrame < 14) && (afterPrevFrame >= 16)) || + ((beforeCurFrame < 27) && (afterPrevFrame >= 29))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -1770,9 +1771,9 @@ void EnZf_CircleAroundPlayer(EnZf* this, GlobalContext* globalCtx) { s16 playerRot; s16 phi_v0_4; Player* player = GET_PLAYER(globalCtx); - s32 curKeyFrame; - s32 prevKeyFrame; - s32 playSpeed; + s32 prevFrame; + s32 beforeCurFrame; + s32 absPlaySpeed; f32 baseRange = 0.0f; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 1); @@ -1841,10 +1842,10 @@ void EnZf_CircleAroundPlayer(EnZf* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = this->unk_408 * 0.75f; } - curKeyFrame = this->skelAnime.curFrame; + prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - prevKeyFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); - playSpeed = (f32)ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); this->curPlatform = EnZf_FindPlatform(&this->actor.world.pos, this->curPlatform); @@ -1889,9 +1890,11 @@ void EnZf_CircleAroundPlayer(EnZf* this, GlobalContext* globalCtx) { } else { this->unk_3F0--; } - if (curKeyFrame != (s32)this->skelAnime.curFrame) { - s32 nextKeyFrame = playSpeed + curKeyFrame; - if (((prevKeyFrame < 14) && (nextKeyFrame >= 16)) || ((prevKeyFrame < 27) && (nextKeyFrame >= 29))) { + if (prevFrame != (s32)this->skelAnime.curFrame) { + s32 afterPrevFrame = absPlaySpeed + prevFrame; + + if (((beforeCurFrame < 14) && (afterPrevFrame >= 16)) || + ((beforeCurFrame < 27) && (afterPrevFrame >= 29))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } }