From 481c7f7e7e32c63abf71084bdf794d375d3994ce Mon Sep 17 00:00:00 2001 From: Hunter Shelton <82550703+EpochFlame@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:15:28 -0500 Subject: [PATCH] match breadbug isReachToGoal thanks broc Co-Authored-By: Mr-Brocoli <59612417+Mr-Brocoli@users.noreply.github.com> --- include/Game/EnemyBase.h | 8 ++ src/plugProjectMorimuraU/miulin.cpp | 4 +- src/plugProjectMorimuraU/panModoki.cpp | 124 +------------------------ 3 files changed, 14 insertions(+), 122 deletions(-) diff --git a/include/Game/EnemyBase.h b/include/Game/EnemyBase.h index 4cbbc9aea..418a116c7 100644 --- a/include/Game/EnemyBase.h +++ b/include/Game/EnemyBase.h @@ -704,6 +704,14 @@ struct EnemyBase : public Creature, public SysShape::MotionListener, virtual pub return SQUARE(diffX) + SQUARE(diffZ); } + inline bool isCreatureIn2DRadius(f32 rad, Vector3f& pos) + { + Vector3f targetCreaturePos; + targetCreaturePos.z = mTargetCreature->getPosition().z; + targetCreaturePos.x = mTargetCreature->getPosition().x; + return inRadius(rad, pos, targetCreaturePos); + } + inline bool isAlertLife() { return bool(mHealth < static_cast(mParms)->mGeneral.mLifeBeforeAlert); } inline bool isLongLegs() diff --git a/src/plugProjectMorimuraU/miulin.cpp b/src/plugProjectMorimuraU/miulin.cpp index cae6bb649..c7d5acb12 100644 --- a/src/plugProjectMorimuraU/miulin.cpp +++ b/src/plugProjectMorimuraU/miulin.cpp @@ -163,12 +163,12 @@ bool Obj::isAttackStart() if (FABS(getAngDist(mTargetCreature)) <= contAtkAngle) { Vector3f pos; getPosition2D(pos); - + // similar to isCreatureIn2DRadius, used in panModoki.cpp's Obj::isReachToGoal Vector3f targetPos = Vector3f(mTargetCreature->getPosition().x, 0.0f, mTargetCreature->getPosition().z); // Vector3f pos = Vector3f(mPosition.x, 0.0f, mPosition.z); // Vector3f targetPos = Vector3f(mTargetCreature->getPosition().x, 0.0f, mTargetCreature->getPosition().z); - f32 sqrDist = sqrDistanceXZ(targetPos, pos); + f32 sqrDist = sqrDistanceXZ(targetPos, pos); // Kinda want to be able to use Vector3f's inRadius here. -EpochFlame if (sqrDist < minAtkRange + atkRadius && sqrDist > minAtkRange - atkRadius) { return true; } diff --git a/src/plugProjectMorimuraU/panModoki.cpp b/src/plugProjectMorimuraU/panModoki.cpp index 87866d838..87798dee4 100644 --- a/src/plugProjectMorimuraU/panModoki.cpp +++ b/src/plugProjectMorimuraU/panModoki.cpp @@ -987,7 +987,6 @@ void Obj::walkFunc() */ bool Obj::isReachToGoal(f32 radius) { - f32 rad = radius; if (isDead()) { return false; } @@ -995,16 +994,14 @@ bool Obj::isReachToGoal(f32 radius) Creature* creature = mTargetCreature; if (creature) { P2ASSERTLINE(1200, creature); - rad += static_cast(creature)->mConfig->mParams.mRadius.mData; + radius += static_cast(creature)->mConfig->mParams.mRadius.mData; } else { - rad *= 2.0f; + radius *= 2.0f; } - rad *= rad; - if (sqrDistanceXZ(mPosition, mNextWayPointPosition) < rad) { + if (inRadius(radius, mPosition, mNextWayPointPosition)) { if (getStateID() == PANMODOKI_Walk && mTargetCreature) { - Vector3f targetPos(mTargetCreature->getPosition().x, 0.0f, mTargetCreature->getPosition().z); - if (sqrDistanceXZ(mPosition, targetPos) < rad) { + if (isCreatureIn2DRadius(radius, mPosition)) { mFsm->transit(this, PANMODOKI_Stick, nullptr); } } @@ -1012,119 +1009,6 @@ bool Obj::isReachToGoal(f32 radius) return true; } return false; - /* - stwu r1, -0x50(r1) - mflr r0 - stw r0, 0x54(r1) - stfd f31, 0x40(r1) - psq_st f31, 72(r1), 0, qr0 - stfd f30, 0x30(r1) - psq_st f30, 56(r1), 0, qr0 - stw r31, 0x2c(r1) - stw r30, 0x28(r1) - mr r30, r3 - lfs f0, lbl_8051E490@sda21(r2) - lfs f2, 0x200(r3) - fmr f30, f1 - fcmpo cr0, f2, f0 - cror 2, 0, 2 - bne lbl_80351710 - li r3, 0 - b lbl_80351824 - -lbl_80351710: - lwz r31, 0x230(r30) - cmplwi r31, 0 - beq lbl_8035174C - bne lbl_8035173C - lis r3, lbl_80490EF8@ha - lis r5, lbl_80490F08@ha - addi r3, r3, lbl_80490EF8@l - li r4, 0x4b0 - addi r5, r5, lbl_80490F08@l - crclr 6 - bl panic_f__12JUTExceptionFPCciPCce - -lbl_8035173C: - lwz r3, 0x35c(r31) - lfs f0, 0xa0(r3) - fadds f30, f30, f0 - b lbl_80351754 - -lbl_8035174C: - lfs f0, lbl_8051E4D4@sda21(r2) - fmuls f30, f30, f0 - -lbl_80351754: - lfs f1, 0x194(r30) - fmuls f30, f30, f30 - lfs f0, 0x2c4(r30) - lfs f2, 0x18c(r30) - fsubs f1, f1, f0 - lfs f0, 0x2bc(r30) - fsubs f2, f2, f0 - fmuls f0, f1, f1 - fmadds f0, f2, f2, f0 - fcmpo cr0, f0, f30 - bge lbl_80351820 - mr r3, r30 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 1 - bne lbl_80351810 - lwz r4, 0x230(r30) - cmplwi r4, 0 - beq lbl_80351810 - lwz r12, 0(r4) - addi r3, r1, 8 - lwz r12, 8(r12) - mtctr r12 - bctrl - lwz r4, 0x230(r30) - addi r3, r1, 0x14 - lfs f31, 0x10(r1) - lwz r12, 0(r4) - lwz r12, 8(r12) - mtctr r12 - bctrl - lfs f0, 0x194(r30) - lfs f2, 0x14(r1) - fsubs f1, f0, f31 - lfs f0, 0x18c(r30) - fsubs f2, f0, f2 - fmuls f0, f1, f1 - fmadds f0, f2, f2, f0 - fcmpo cr0, f0, f30 - bge lbl_80351810 - lwz r3, 0x380(r30) - mr r4, r30 - li r5, 8 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - -lbl_80351810: - li r0, 0 - li r3, 1 - stw r0, 0x318(r30) - b lbl_80351824 - -lbl_80351820: - li r3, 0 - -lbl_80351824: - psq_l f31, 72(r1), 0, qr0 - lfd f31, 0x40(r1) - psq_l f30, 56(r1), 0, qr0 - lfd f30, 0x30(r1) - lwz r31, 0x2c(r1) - lwz r0, 0x54(r1) - lwz r30, 0x28(r1) - mtlr r0 - addi r1, r1, 0x50 - blr - */ } /**