Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match breadbug isReachToGoal #226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/Game/EnemyBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnemyParmsBase*>(mParms)->mGeneral.mLifeBeforeAlert); }

inline bool isLongLegs()
Expand Down
4 changes: 2 additions & 2 deletions src/plugProjectMorimuraU/miulin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
124 changes: 4 additions & 120 deletions src/plugProjectMorimuraU/panModoki.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,144 +987,28 @@ void Obj::walkFunc()
*/
bool Obj::isReachToGoal(f32 radius)
{
f32 rad = radius;
if (isDead()) {
return false;
}

Creature* creature = mTargetCreature;
if (creature) {
P2ASSERTLINE(1200, creature);
rad += static_cast<Pellet*>(creature)->mConfig->mParams.mRadius.mData;
radius += static_cast<Pellet*>(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);
}
}
mMoveSpeedTimer = 0;
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
*/
}

/**
Expand Down
Loading