diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md
index 0893b6dfb..1e1b62f15 100644
--- a/docs/recommended_todo.md
+++ b/docs/recommended_todo.md
@@ -95,10 +95,10 @@
| File | Size (bytes) | File | Size (bytes) |
| ---- | ---- | ---- | ---- |
| aiTeki.cpp | 5890 | gamePelletList.cpp | 8282 |
-| mapMgrTraceMove.cpp | 9030 | cellIterator.cpp | 9433 |
+| mapMgrTraceMove.cpp | 9030 | cellIterator.cpp | 9434 |
| itemBarrel.cpp | 11148 | aiBreakGate.cpp | 13918 |
| flockMgr.cpp | 13955 | itemTreasure.cpp | 14296 |
-| naviWhistle.cpp | 16714 | aiBattle.cpp | 17396 |
+| naviWhistle.cpp | 16714 | aiBattle.cpp | 17401 |
| creatureLOD.cpp | 18468 | texCaster.cpp | 20776 |
| aiRescue.cpp | 21024 | gameResultTexMgr.cpp | 21442 |
| singleGS_CaveResult.cpp | 22846 | aiCrop.cpp | 26982 |
@@ -109,11 +109,11 @@
| aiEnter.cpp | 31721 | singleGS_DayEnd.cpp | 32347 |
| gameDynamics.cpp | 34058 | aiBore.cpp | 34883 |
| baseGameSectionKantei.cpp | 35202 | gamePlayDataMemCard.cpp | 36035 |
-| piki.cpp | 36418 | gameGeneratorCache.cpp | 36959 |
+| piki.cpp | 36397 | gameGeneratorCache.cpp | 36959 |
| aiWeed.cpp | 38056 | collinfo.cpp | 42246 |
| aiFormation.cpp | 43348 | gameCaveInfo.cpp | 43607 |
| gameCPlate.cpp | 43761 | itemGate.cpp | 50175 |
-| pelletCarcass.cpp | 55314 | gameGenerator.cpp | 55920 |
+| cellPyramid.cpp | 51345 | pelletCarcass.cpp | 55314 |
###
| File | Size (bytes) | File | Size (bytes) |
@@ -137,17 +137,17 @@
| nslibmath.cpp | 4592 | TyreShadow.cpp | 7234 |
| MaroFrog.cpp | 7314 | UmimushiShadow.cpp | 7565 |
| ContRumble.cpp | 9005 | SnakeJointMgr.cpp | 10097 |
-| KumaChappy.cpp | 11401 | Kabuto.cpp | 12286 |
-| BabyState.cpp | 12869 | Tank.cpp | 13334 |
+| KumaChappy.cpp | 11401 | Kabuto.cpp | 12291 |
+| BabyState.cpp | 12869 | Tank.cpp | 13339 |
| Kogane.cpp | 14614 | JointShadowBase.cpp | 14958 |
| ElecBugState.cpp | 15715 | RandMapMgr.cpp | 17083 |
| TadpoleState.cpp | 17593 | SnakeWholeShadow.cpp | 19376 |
-| SnakeCrowShadow.cpp | 19385 | ImomushiState.cpp | 19863 |
+| SnakeCrowShadow.cpp | 19385 | ImomushiState.cpp | 19876 |
| UjiaState.cpp | 20924 | RumbleMgr.cpp | 21534 |
-| Rock.cpp | 21671 | ElecHiba.cpp | 21844 |
+| Rock.cpp | 21671 | ElecHiba.cpp | 21849 |
| Frog.cpp | 22143 | QueenState.cpp | 22713 |
| Ujia.cpp | 22966 | Ujib.cpp | 23602 |
-| Queen.cpp | 23619 | ElecBug.cpp | 24345 |
+| Queen.cpp | 23624 | ElecBug.cpp | 24345 |
| ArmorState.cpp | 24714 | SaraiState.cpp | 24923 |
| TobiState.cpp | 24962 | UjibState.cpp | 25505 |
| Armor.cpp | 25780 | Tobi.cpp | 25937 |
diff --git a/include/Dolphin/math.h b/include/Dolphin/math.h
index e9fd3d618..ab0ab6638 100644
--- a/include/Dolphin/math.h
+++ b/include/Dolphin/math.h
@@ -35,6 +35,8 @@ extern "C" {
#define DEG2RAD (1.0f / 180.0f)
+#define TORADIANS(val) (PI * (DEG2RAD * val))
+
f64 cos(f64);
f32 cosf(f32);
f64 sin(f64);
diff --git a/include/Game/Creature.h b/include/Game/Creature.h
index 354629c5e..c9328e23a 100644
--- a/include/Game/Creature.h
+++ b/include/Game/Creature.h
@@ -289,13 +289,13 @@ struct Creature : public CellObject {
{
return getPosition();
}
- virtual bool isSuckReady() { return true; } // _19C (weak)
- virtual BOOL isSuckArriveWait() { return FALSE; } // _1A0 (weak)
- virtual bool stimulate(Interaction& data); // _1A4 (weak)
- virtual char* getCreatureName() { return "Creature"; } // _1A8 (weak)
- virtual s32 getCreatureID() { return -1; } // _1AC (weak)
- virtual u16 getObjType() { return mObjectTypeID; } // _28 (weak)
- virtual bool collisionUpdatable() // _14 (weak)
+ virtual bool isSuckReady() { return true; } // _19C (weak)
+ virtual BOOL isSuckArriveWait() { return FALSE; } // _1A0 (weak)
+ virtual bool stimulate(Interaction& data) { return false; } // _1A4 (weak)
+ virtual char* getCreatureName() { return "Creature"; } // _1A8 (weak)
+ virtual s32 getCreatureID() { return -1; } // _1AC (weak)
+ virtual u16 getObjType() { return mObjectTypeID; } // _28 (weak)
+ virtual bool collisionUpdatable() // _14 (weak)
{
return mUpdateContext.updatable();
}
diff --git a/include/Game/EnemyFunc.h b/include/Game/EnemyFunc.h
index bda6e6f46..ae3d9656f 100644
--- a/include/Game/EnemyFunc.h
+++ b/include/Game/EnemyFunc.h
@@ -16,9 +16,17 @@ struct Navi;
namespace Game {
namespace EnemyFunc {
struct ConditionPikminNearby : public Condition {
+ inline ConditionPikminNearby(Creature* creature, f32 dist)
+ : mCreature(creature)
+ , mSearchDist(dist)
+ {
+ }
+
virtual bool satisfy(Creature*); // 08 (weak)
// _00 = VTBL
+ Creature* mCreature; // _00
+ f32 mSearchDist; // _04
};
struct EatPikminDefaultCondition : public Condition {
@@ -27,11 +35,13 @@ struct EatPikminDefaultCondition : public Condition {
// _00 = VTBL
};
-Navi* getNearestNavi(Creature*, f32, f32, f32*, Condition*);
-Piki* getNearestPikmin(Creature*, f32, f32, f32*, Condition*);
-Creature* getNearestPikminOrNavi(Creature*, f32, f32, f32*, Condition*, Condition*);
+Navi* getNearestNavi(Creature* creature, f32 searchAngle, f32 searchRadius, f32* naviDist, Condition* condition);
+Piki* getNearestPikmin(Creature* creature, f32 searchAngle, f32 searchRadius, f32* pikiDist, Condition* condition);
+Creature* getNearestPikminOrNavi(Creature* creature, f32 searchAngle, f32 searchRadius, f32* targetDist, Condition* naviCond,
+ Condition* pikiCond);
-void flickStickPikmin(Creature*, f32, f32, f32, f32, Condition*);
+void flickCreature(Creature* flicker, Creature* toFlick, f32 knockback, f32 damage, f32 angle);
+void flickStickPikmin(Creature* creature, f32 flickChance, f32 knockback, f32 damage, f32 angle, Condition* condition);
void flickNearbyPikmin(Creature*, f32, f32, f32, f32, Condition*);
void flickNearbyNavi(Creature*, f32, f32, f32, f32, Condition*);
diff --git a/include/Game/FakePiki.h b/include/Game/FakePiki.h
index ed0dc3727..d06016209 100644
--- a/include/Game/FakePiki.h
+++ b/include/Game/FakePiki.h
@@ -105,7 +105,7 @@ struct FakePiki : public Creature, public SysShape::MotionListener {
inline bool isFPFlag(u32 flag) { return mFakePikiFlags.typeView & flag; }
// vtable 1 (Creature)
- virtual Vector3f getPosition(); // _08
+ virtual Vector3f getPosition() { return mPosition; } // _08
virtual void getBoundingSphere(Sys::Sphere& boundSphere); // _10 (weak)
virtual void doAnimation(); // _3C
virtual void doEntry(); // _40
@@ -201,7 +201,7 @@ struct FakePiki : public Creature, public SysShape::MotionListener {
Vector3f _1F0; // _1F0
f32 mFaceDir; // _1FC
Vector3f mSimVelocity; // _200
- Vector3f mPosition3; // _20C, was mShadowParam.mPosition
+ Vector3f mPosition; // _20C
Sys::Sphere mBoundingSphere; // _218, was mShadowParam.mBoundingSphere
int mBoundAnimIdx; // _228, current animIdx for held/bound object
int _22C; // _22C, anim id of some description?
diff --git a/include/Game/Interaction.h b/include/Game/Interaction.h
index 5cedc1987..7a7e685d9 100644
--- a/include/Game/Interaction.h
+++ b/include/Game/Interaction.h
@@ -235,7 +235,7 @@ struct InteractFlick : public Interaction {
inline InteractFlick(Creature* parent, f32 knockback, f32 damage, f32 angle)
: Interaction(parent)
, mKnockback(knockback)
- , mIntensity(damage)
+ , mNaviDamage(damage)
, mAngle(angle)
{
}
@@ -246,9 +246,9 @@ struct InteractFlick : public Interaction {
// _00 = VTBL
// _04 = Creature*
- f32 mKnockback; // _08
- f32 mIntensity; // _0C
- f32 mAngle; // _10
+ f32 mKnockback; // _08
+ f32 mNaviDamage; // _0C
+ f32 mAngle; // _10
};
struct InteractFlockAttack : public Interaction {
diff --git a/include/Game/NaviState.h b/include/Game/NaviState.h
index 466dfba63..a19b7d749 100644
--- a/include/Game/NaviState.h
+++ b/include/Game/NaviState.h
@@ -309,16 +309,16 @@ struct NaviFallMeckState : public NaviState {
};
struct NaviFlickArg : public StateArg {
- NaviFlickArg(Creature* c, Vector3f& d, f32 i)
+ NaviFlickArg(Creature* flicker, Vector3f& direction, f32 damage)
{
- mCreature = c;
- mDirection = d;
- mIntensity = i;
+ mCreature = flicker;
+ mDirection = direction;
+ mDamage = damage;
}
- Creature* mCreature; // _0C
- Vector3f mDirection; // _10
- f32 mIntensity; // _1C
+ Creature* mCreature; // _00
+ Vector3f mDirection; // _04
+ f32 mDamage; // _10
};
struct NaviFlickState : public NaviState {
@@ -337,10 +337,10 @@ struct NaviFlickState : public NaviState {
// _00 = VTBL
// _00-_10 = NaviState
- u32 _10; // _10
- Creature* mFlicker; // _14
- Vector3f _18; // _18
- u8 _24[0x4]; // _24, unknown
+ u32 _10; // _10
+ Creature* mFlicker; // _14
+ Vector3f mDirection; // _18
+ f32 mDamage; // _24
};
struct NaviFollowArg : public StateArg {
diff --git a/include/Game/Piki.h b/include/Game/Piki.h
index 9a2b338bc..d4cb58e72 100644
--- a/include/Game/Piki.h
+++ b/include/Game/Piki.h
@@ -227,6 +227,16 @@ struct Piki : public FakePiki {
inline u16 getKind() { return (u16)mPikiKind; }
inline u16 getHappa() { return (u16)mHappaKind; }
+ inline bool isSearchable()
+ {
+ bool result = false;
+ if (isPikmin() && isAlive() && !isStickToMouth()) {
+ result = true;
+ }
+
+ return result;
+ }
+
inline efx::TPkEffect* getEffectObj() { return mEffectsObj; }
static Color4 pikiColors[PikiColorCount + 1];
diff --git a/src/plugProjectKandoU/fakePiki.cpp b/src/plugProjectKandoU/fakePiki.cpp
index c4078af3d..656951f23 100644
--- a/src/plugProjectKandoU/fakePiki.cpp
+++ b/src/plugProjectKandoU/fakePiki.cpp
@@ -28,7 +28,7 @@ FakePiki::FakePiki()
mModel = nullptr;
mBoundingSphere.mRadius = 8.5f;
mFaceDir = 0.0f;
- mPosition3 = Vector3f(0.0f);
+ mPosition = Vector3f(0.0f);
mSimVelocity = Vector3f(0.0f);
mVelocity = Vector3f(0.0f);
_1F0 = Vector3f(0.0f);
@@ -53,7 +53,7 @@ void FakePiki::initFakePiki()
mDoAnimCallback = nullptr;
mWaterBox = nullptr;
mFaceDir = 0.0f;
- mPosition3 = Vector3f(0.0f);
+ mPosition = Vector3f(0.0f);
mVelocity = Vector3f(0.0f);
_1F0 = Vector3f(0.0f);
mSimVelocity = Vector3f(0.0f);
@@ -200,7 +200,7 @@ void FakePiki::clearDoAnimCallback() { mDoAnimCallback = nullptr; }
*/
void FakePiki::updateWalkAnimation()
{
- Vector3f sep = Vector3f(mPosition3.x - _238.x, 0.0f, mPosition3.z - _238.z);
+ Vector3f sep = Vector3f(mPosition.x - _238.x, 0.0f, mPosition.z - _238.z);
f32 updateTime = sys->mDeltaTime;
f32 animSpeed = _lenVec(sep) / updateTime;
@@ -1238,7 +1238,7 @@ void FakePiki::updateLook()
*/
void FakePiki::turnTo(Vector3f& targetPos)
{
- Vector3f diff = targetPos - mPosition3;
+ Vector3f diff = targetPos - mPosition;
if (diff.z != 0.0f) {
mFaceDir = roundAng(JMath::atanTable_.atan2_(diff.x, diff.z));
}
@@ -1603,7 +1603,7 @@ bool FakePiki::useMoveRotation() { return !isFPFlag(FPFLAGS_MoveRotationDisabled
void FakePiki::move(f32 p1)
{
f32 collRad = getMapCollisionRadius();
- Vector3f pos = mPosition3;
+ Vector3f pos = mPosition;
pos.y += collRad;
if (isFPFlag(FPFLAGS_Unk5) && mModel) {
@@ -2505,7 +2505,7 @@ void FakePiki::updateTrMatrix()
{
if (useUpdateTrMatrix() && !isStickTo()) {
Vector3f rotation(0.0f, mFaceDir, 0.0f);
- mObjMatrix.makeSRT(mScale, rotation, mPosition3);
+ mObjMatrix.makeSRT(mScale, rotation, mPosition);
}
}
@@ -3187,7 +3187,7 @@ void FakePiki::outWaterCallback() { }
*/
void FakePiki::onSetPosition(Vector3f& position)
{
- mPosition3 = position;
+ mPosition = position;
onSetPosition();
}
@@ -3224,7 +3224,7 @@ void FakePiki::getVelocityAt(Vector3f& vec, Vector3f& velocity) { velocity = mSi
* Address: 8013F690
* Size: 000008
*/
-Vector3f* FakePiki::getSound_PosPtr() { return &mPosition3; }
+Vector3f* FakePiki::getSound_PosPtr() { return &mPosition; }
/*
* --INFO--
diff --git a/src/plugProjectKandoU/interactNavi.cpp b/src/plugProjectKandoU/interactNavi.cpp
index 24df61a17..186ae4805 100644
--- a/src/plugProjectKandoU/interactNavi.cpp
+++ b/src/plugProjectKandoU/interactNavi.cpp
@@ -135,7 +135,7 @@ bool InteractFlick::actNavi(Game::Navi* navi)
f32 knockBack = (mKnockback * 0.1f) * randFloat() + mKnockback;
Vector3f direction(xRot * knockBack, randFloat() * 50.0f + 100.0f, zRot * knockBack);
- NaviFlickArg flickArg(mCreature, direction, mIntensity);
+ NaviFlickArg flickArg(mCreature, direction, mNaviDamage);
navi->transit(NSID_Flick, &flickArg);
return true;
}
diff --git a/src/plugProjectKandoU/navi.cpp b/src/plugProjectKandoU/navi.cpp
index 2eeda8aca..5fd523421 100644
--- a/src/plugProjectKandoU/navi.cpp
+++ b/src/plugProjectKandoU/navi.cpp
@@ -30,7 +30,7 @@ namespace Game {
*/
void Navi::getShadowParam(ShadowParam& param)
{
- param.mPosition = mPosition3;
+ param.mPosition = mPosition;
param.mPosition.y += 0.5f;
param.mBoundingSphere.mRadius = 10.0f;
@@ -68,7 +68,7 @@ Navi::Navi()
mEffectsObj = new efx::TNaviEffect;
mEffectsObj->init(nullptr, nullptr, nullptr, efx::TNaviEffect::NAVITYPE_Olimar);
- mEffectsObj->mPos = &mPosition3;
+ mEffectsObj->mPos = &mPosition;
mFsm = new NaviFSM;
mFsm->init(this);
@@ -190,7 +190,7 @@ void StateMachine::start(Navi* navi, int stateID, StateArg* stateArg
*/
void Navi::onSetPosition(Vector3f& position)
{
- mPosition3 = position;
+ mPosition = position;
static_cast(this)->onSetPosition(); // dumb.
if (mNaviIndex == 0) { // olimar
@@ -254,7 +254,7 @@ Vector3f Navi::getPosition()
return position;
} else {
- return mPosition3;
+ return mPosition;
}
}
diff --git a/src/plugProjectKandoU/navi_demoCheck.cpp b/src/plugProjectKandoU/navi_demoCheck.cpp
index c489682e8..164d60cbb 100644
--- a/src/plugProjectKandoU/navi_demoCheck.cpp
+++ b/src/plugProjectKandoU/navi_demoCheck.cpp
@@ -323,7 +323,7 @@ bool Navi::demoCheck()
ItemHole::Item* temp = static_cast(*holeIt);
Sys::Sphere bounds;
cHole->getBoundingSphere(bounds);
- Vector3f naviPos = cHole->mPosition - mPosition3;
+ Vector3f naviPos = cHole->mPosition - mPosition;
f32 len = naviPos.length();
if (len < checkrad) {
cHole = temp;
@@ -403,7 +403,7 @@ bool Navi::demoCheck()
if (temp->demoOK() && temp->mHoneyType == 1 && temp->isAlive()) {
Sys::Sphere bounds;
cHoney->getBoundingSphere(bounds);
- Vector3f naviPos = cHoney->mPosition - mPosition3;
+ Vector3f naviPos = cHoney->mPosition - mPosition;
f32 len = naviPos.length();
if (len < checkrad) {
cHoney = temp;
@@ -433,7 +433,7 @@ bool Navi::demoCheck()
if (temp->demoOK() && temp->mHoneyType == 2 && temp->isAlive()) {
Sys::Sphere bounds;
cHoney->getBoundingSphere(bounds);
- Vector3f naviPos = cHoney->mPosition - mPosition3;
+ Vector3f naviPos = cHoney->mPosition - mPosition;
f32 len = naviPos.length();
if (len < checkrad) {
cHoney = temp;
diff --git a/src/plugProjectKandoU/piki.cpp b/src/plugProjectKandoU/piki.cpp
index 431656908..1f7963632 100644
--- a/src/plugProjectKandoU/piki.cpp
+++ b/src/plugProjectKandoU/piki.cpp
@@ -254,7 +254,7 @@ void Piki::onKill(CreatureKillArg* killArg)
* Address: 80148498
* Size: 00001C
*/
-void Piki::onSetPosition() { mBoundingSphere.mPosition = mPosition3; }
+void Piki::onSetPosition() { mBoundingSphere.mPosition = mPosition; }
/*
* --INFO--
@@ -263,7 +263,7 @@ void Piki::onSetPosition() { mBoundingSphere.mPosition = mPosition3; }
*/
void Piki::getLODSphere(Sys::Sphere& sphere)
{
- sphere.mPosition = mPosition3;
+ sphere.mPosition = mPosition;
sphere.mRadius = 15.0f;
}
@@ -373,7 +373,7 @@ void Piki::movieSetTranslation(Vector3f& position, f32 faceDir)
mSimVelocity = Vector3f(0.0f);
mVelocity = Vector3f(0.0f);
mAcceleration = Vector3f(0.0f);
- _238 = mPosition3;
+ _238 = mPosition;
setPosition(position, false);
mFaceDir = faceDir;
}
@@ -648,7 +648,7 @@ bool Piki::might_bury()
return false;
}
- Sys::Sphere sphere(mPosition3, 100.0f);
+ Sys::Sphere sphere(mPosition, 100.0f);
CellIteratorArg iterArg(sphere);
CellIterator iter(iterArg);
@@ -658,7 +658,7 @@ bool Piki::might_bury()
if (creature->mObjectTypeID == OBJTYPE_Cave || creature->mObjectTypeID == OBJTYPE_BigFountain
|| creature->mObjectTypeID == OBJTYPE_Hole) {
Vector3f creaturePos = creature->getPosition();
- Vector3f sep = Vector3f(creaturePos.y - mPosition3.y, creaturePos.z - mPosition3.z, creaturePos.x - mPosition3.x);
+ Vector3f sep = Vector3f(creaturePos.y - mPosition.y, creaturePos.z - mPosition.z, creaturePos.x - mPosition.x);
if (_length2(sep) <= 100.0f) {
return false;
}
@@ -1454,7 +1454,7 @@ void Piki::changeShape(int color)
int count = GameStat::alivePikis;
mEffectsObj->mPikiColor = color;
- mEffectsObj->mHamonPosPtr = &mPosition3;
+ mEffectsObj->mHamonPosPtr = &mPosition;
mEffectsObj->_1C = &mObjMatrix;
mLeafStemJoint = mModel->getJoint("happajnt3");
@@ -1491,7 +1491,7 @@ void Piki::do_updateLookCreature()
mTargetLookTimer -= sys->mDeltaTime;
if (mTargetLookTimer > 0.0f) {
Vector3f targetPos = mLookAtTargetCreature->getPosition();
- Vector3f sep = Vector3f(targetPos.y - mPosition3.y, targetPos.z - mPosition3.z, targetPos.x - mPosition3.x);
+ Vector3f sep = Vector3f(targetPos.y - mPosition.y, targetPos.z - mPosition.z, targetPos.x - mPosition.x);
if (_length2(sep) > 200.0f) {
finishLook();
}
@@ -1520,7 +1520,7 @@ void Piki::do_updateLookCreature()
break;
}
- Sys::Sphere sphere(mPosition3, 200.0f);
+ Sys::Sphere sphere(mPosition, 200.0f);
CellIteratorArg iterArg(sphere);
iterArg.mUseCustomRadius = 1;
CellIterator iter(iterArg);
diff --git a/src/plugProjectKandoU/pikiState.cpp b/src/plugProjectKandoU/pikiState.cpp
index a2b331aab..2617686b4 100644
--- a/src/plugProjectKandoU/pikiState.cpp
+++ b/src/plugProjectKandoU/pikiState.cpp
@@ -4988,10 +4988,10 @@ void PikiDrownState::exec(Piki* piki)
Vector3f newPikiPos = piki->getPosition();
if (newPikiPos.y >= level - 5.0f) {
- piki->mPosition3.x = newPikiPos.x;
- piki->mPosition3.y = level - 5.0f;
- piki->mPosition3.z = newPikiPos.z;
- _10 = 1;
+ piki->mPosition.x = newPikiPos.x;
+ piki->mPosition.y = level - 5.0f;
+ piki->mPosition.z = newPikiPos.z;
+ _10 = 1;
piki->startMotion(IPikiAnims::OBORERU, IPikiAnims::OBORERU, piki, nullptr);
piki->mSoundObj->startFreePikiSetSound(PSSE_PK_VC_WATER_DROWN, PSGame::SeMgr::SETSE_PikiWorking, 0, 0);
}
@@ -5007,9 +5007,9 @@ void PikiDrownState::exec(Piki* piki)
} else {
Vector3f newPikiPos = piki->getPosition();
if (newPikiPos.y < level - 5.0f) {
- piki->mPosition3.x = newPikiPos.x;
- piki->mPosition3.y = level - 5.0f;
- piki->mPosition3.z = newPikiPos.z;
+ piki->mPosition.x = newPikiPos.x;
+ piki->mPosition.y = level - 5.0f;
+ piki->mPosition.z = newPikiPos.z;
}
piki->mSimVelocity.y = 0.0f;
piki->mVelocity.y = 0.0f;
diff --git a/src/plugProjectYamashitaU/enemyAction.cpp b/src/plugProjectYamashitaU/enemyAction.cpp
index 906f1087d..a5e7f689c 100644
--- a/src/plugProjectYamashitaU/enemyAction.cpp
+++ b/src/plugProjectYamashitaU/enemyAction.cpp
@@ -1,119 +1,66 @@
-#include "types.h"
-#include "nans.h"
#include "Game/EnemyFunc.h"
-
-/*
- Generated from dpostproc
-
- .section .ctors, "wa" # 0x80472F00 - 0x804732C0
- .4byte __sinit_enemyAction_cpp
-
- .section .rodata # 0x804732E0 - 0x8049E220
- .global lbl_8047AE88
- lbl_8047AE88:
- .asciz "teki-srch"
- .skip 2
- .global lbl_8047AE94
- lbl_8047AE94:
- .asciz "g2B_white_poison"
- .skip 3
-
- .section .data, "wa" # 0x8049E220 - 0x804EFC20
- .global lbl_804ABC48
- lbl_804ABC48:
- .4byte 0x00000000
- .4byte 0x00000000
- .4byte 0x00000000
- .global __vt__Q34Game9EnemyFunc25EatPikminDefaultCondition
- __vt__Q34Game9EnemyFunc25EatPikminDefaultCondition:
- .4byte 0
- .4byte 0
- .4byte
- satisfy__Q34Game9EnemyFunc25EatPikminDefaultConditionFPQ24Game4Piki .global
- "__vt__23Condition"
- "__vt__23Condition":
- .4byte 0
- .4byte 0
- .4byte 0
- .global __vt__Q34Game9EnemyFunc21ConditionPikminNearby
- __vt__Q34Game9EnemyFunc21ConditionPikminNearby:
- .4byte 0
- .4byte 0
- .4byte
- satisfy__Q34Game9EnemyFunc21ConditionPikminNearbyFPQ24Game8Creature .global
- "__vt__27Condition"
- "__vt__27Condition":
- .4byte 0
- .4byte 0
- .4byte 0
- .global "__vt__26Iterator"
- "__vt__26Iterator":
- .4byte 0
- .4byte 0
- .4byte "first__26IteratorFv"
- .4byte "next__26IteratorFv"
- .4byte "isDone__26IteratorFv"
- .4byte "__ml__26IteratorFv"
- .global "__vt__22Iterator"
- "__vt__22Iterator":
- .4byte 0
- .4byte 0
- .4byte "first__22IteratorFv"
- .4byte "next__22IteratorFv"
- .4byte "isDone__22IteratorFv"
- .4byte "__ml__22IteratorFv"
- .global "__vt__22Iterator"
- "__vt__22Iterator":
- .4byte 0
- .4byte 0
- .4byte "first__22IteratorFv"
- .4byte "next__22IteratorFv"
- .4byte "isDone__22IteratorFv"
- .4byte "__ml__22IteratorFv"
- .4byte 0
-
- .section .sbss # 0x80514D80 - 0x80516360
- .global lbl_80515878
- lbl_80515878:
- .skip 0x4
- .global lbl_8051587C
- lbl_8051587C:
- .skip 0x4
-
- .section .sdata2, "a" # 0x80516360 - 0x80520E40
- .global lbl_80517A78
- lbl_80517A78:
- .4byte 0x40490FDB
- .global lbl_80517A7C
- lbl_80517A7C:
- .4byte 0x3BB60B61
- .global lbl_80517A80
- lbl_80517A80:
- .4byte 0x00000000
- .global lbl_80517A84
- lbl_80517A84:
- .4byte 0x47000000
- .global lbl_80517A88
- lbl_80517A88:
- .4byte 0x43300000
- .4byte 0x80000000
- .global lbl_80517A90
- lbl_80517A90:
- .float 1.0
- .global lbl_80517A94
- lbl_80517A94:
- .float 0.5
-*/
+#include "Game/Navi.h"
+#include "Game/PikiMgr.h"
+#include "Game/Stickers.h"
+#include "stl/float.h"
+#include "Dolphin/rand.h"
+#include "nans.h"
namespace Game {
+namespace EnemyFunc {
/*
* --INFO--
* Address: 801126F4
* Size: 000424
*/
-Navi* EnemyFunc::getNearestNavi(Game::Creature*, float, float, float*, Condition*)
+Navi* getNearestNavi(Creature* creature, f32 searchAngle, f32 searchRadius, f32* naviDist, Condition* condition)
{
+ Navi* navi = nullptr;
+ f32 minDist;
+ searchAngle = TORADIANS(searchAngle);
+
+ if (searchRadius < 0.0f) {
+ searchRadius = FLT_MAX;
+ } else {
+ searchRadius = SQUARE(searchRadius);
+ }
+
+ if (naviDist) {
+ if (*naviDist < searchRadius) {
+ minDist = *naviDist;
+ } else {
+ minDist = searchRadius;
+ }
+ } else {
+ minDist = searchRadius;
+ }
+
+ Iterator iter(naviMgr, nullptr, condition);
+ CI_LOOP(iter)
+ {
+ Navi* currNavi = *iter;
+ if (currNavi->isAlive()) {
+ f32 angleDist = creature->getAngDist(currNavi);
+ if (FABS(angleDist) <= searchAngle) {
+ // something fucky here
+ Vector3f sep = Vector3f(currNavi->getPosition().x, 0.0f, currNavi->getPosition().z)
+ - Vector3f(creature->getPosition().x, 0.0f, creature->getPosition().z);
+ f32 newDist = SQUARE(sep.x) + SQUARE(sep.z);
+ if (newDist < minDist) {
+ navi = currNavi;
+ minDist = newDist;
+ }
+ }
+ }
+ }
+
+ if (navi && naviDist) {
+ *naviDist = minDist;
+ }
+
+ return navi;
+
/*
.loc_0x0:
stwu r1, -0xE0(r1)
@@ -419,8 +366,54 @@ Navi* EnemyFunc::getNearestNavi(Game::Creature*, float, float, float*, Condition
* Address: 80112B64
* Size: 000484
*/
-Piki* EnemyFunc::getNearestPikmin(Game::Creature*, float, float, float*, Condition*)
+Piki* getNearestPikmin(Creature* creature, f32 searchAngle, f32 searchRadius, f32* pikiDist, Condition* condition)
{
+ sys->mTimers->_start("teki-srch", true);
+ Piki* piki = nullptr;
+ f32 minDist;
+ searchAngle = TORADIANS(searchAngle);
+ if (searchRadius < 0.0f) {
+ searchRadius = FLT_MAX;
+ } else {
+ searchRadius = SQUARE(searchRadius);
+ }
+
+ if (pikiDist) {
+ if (*pikiDist < searchRadius) {
+ minDist = *pikiDist;
+ } else {
+ minDist = searchRadius;
+ }
+ } else {
+ minDist = searchRadius;
+ }
+
+ Iterator iter(pikiMgr, nullptr, condition);
+ CI_LOOP(iter)
+ {
+ Piki* currPiki = *iter;
+ if (currPiki->isSearchable()) {
+ f32 angleDist = creature->getAngDist(currPiki);
+ if (FABS(angleDist) <= searchAngle) {
+ // something fucky here
+ Vector3f sep = Vector3f(currPiki->getPosition().x, 0.0f, currPiki->getPosition().z)
+ - Vector3f(creature->getPosition().x, 0.0f, creature->getPosition().z);
+ f32 newDist = SQUARE(sep.x) + SQUARE(sep.z);
+ if (newDist < minDist) {
+ piki = currPiki;
+ minDist = newDist;
+ }
+ }
+ }
+ }
+
+ if (piki && pikiDist) {
+ *pikiDist = minDist;
+ }
+
+ sys->mTimers->_stop("teki-srch");
+
+ return piki;
/*
.loc_0x0:
stwu r1, -0xE0(r1)
@@ -749,87 +742,38 @@ Piki* EnemyFunc::getNearestPikmin(Game::Creature*, float, float, float*, Conditi
/*
* --INFO--
- * Address: 80112FE8
- * Size: 00001C
+ * Address: 80113050
+ * Size: 0000C4
*/
-Vector3f FakePiki::getPosition()
+Creature* getNearestPikminOrNavi(Creature* creature, f32 searchAngle, f32 searchRadius, f32* targetDist, Condition* naviCondition,
+ Condition* pikiCondition)
{
- /*
- lfs f0, 0x20c(r4)
- stfs f0, 0(r3)
- lfs f0, 0x210(r4)
- stfs f0, 4(r3)
- lfs f0, 0x214(r4)
- stfs f0, 8(r3)
- blr
- */
+ f32 dist = FLT_MAX;
+ if (!targetDist) {
+ targetDist = &dist;
+ }
+
+ Creature* navi = getNearestNavi(creature, searchAngle, searchRadius, targetDist, naviCondition);
+ Creature* piki = getNearestPikmin(creature, searchAngle, searchRadius, targetDist, pikiCondition);
+
+ if (piki) {
+ return piki;
+ }
+
+ return navi;
}
/*
* --INFO--
- * Address: 80113050
- * Size: 0000C4
+ * Address: ........
+ * Size: 000060
*/
-Creature* EnemyFunc::getNearestPikminOrNavi(Game::Creature*, float, float, float*, Condition*, Condition*)
+void flickCreature(Creature* flicker, Creature* toFlick, f32 knockback, f32 damage, f32 angle)
{
- /*
- .loc_0x0:
- stwu r1, -0x40(r1)
- mflr r0
- stw r0, 0x44(r1)
- stfd f31, 0x30(r1)
- psq_st f31,0x38(r1),0,0
- stfd f30, 0x20(r1)
- psq_st f30,0x28(r1),0,0
- stw r31, 0x1C(r1)
- stw r30, 0x18(r1)
- stw r29, 0x14(r1)
- stw r28, 0x10(r1)
- lis r7, 0x8051
- mr. r29, r4
- lfs f0, 0x48D8(r7)
- fmr f30, f1
- fmr f31, f2
- mr r28, r3
- stfs f0, 0x8(r1)
- mr r30, r6
- bne- .loc_0x54
- addi r29, r1, 0x8
-
- .loc_0x54:
- fmr f1, f30
- mr r3, r28
- fmr f2, f31
- mr r4, r29
- bl -0x9C0
- fmr f1, f30
- mr r31, r3
- fmr f2, f31
- mr r3, r28
- mr r4, r29
- mr r5, r30
- bl -0x56C
- cmplwi r3, 0
- beq- .loc_0x90
- b .loc_0x94
-
- .loc_0x90:
- mr r3, r31
-
- .loc_0x94:
- psq_l f31,0x38(r1),0,0
- lfd f31, 0x30(r1)
- psq_l f30,0x28(r1),0,0
- lfd f30, 0x20(r1)
- lwz r31, 0x1C(r1)
- lwz r30, 0x18(r1)
- lwz r29, 0x14(r1)
- lwz r0, 0x44(r1)
- lwz r28, 0x10(r1)
- mtlr r0
- addi r1, r1, 0x40
- blr
- */
+ if (toFlick->mSticker == flicker && !toFlick->isStickToMouth()) {
+ InteractFlick flick(flicker, knockback, damage, angle);
+ toFlick->stimulate(flick);
+ }
}
/*
@@ -837,250 +781,24 @@ Creature* EnemyFunc::getNearestPikminOrNavi(Game::Creature*, float, float, float
* Address: 8011311C
* Size: 00036C
*/
-void EnemyFunc::flickStickPikmin(Game::Creature*, float, float, float, float, Condition*)
+void flickStickPikmin(Creature* creature, f32 flickChance, f32 knockback, f32 damage, f32 angle, Condition* condition)
{
- /*
- .loc_0x0:
- stwu r1, -0xA0(r1)
- mflr r0
- stw r0, 0xA4(r1)
- stfd f31, 0x90(r1)
- psq_st f31,0x98(r1),0,0
- stfd f30, 0x80(r1)
- psq_st f30,0x88(r1),0,0
- stfd f29, 0x70(r1)
- psq_st f29,0x78(r1),0,0
- stfd f28, 0x60(r1)
- psq_st f28,0x68(r1),0,0
- stw r31, 0x5C(r1)
- stw r30, 0x58(r1)
- stw r29, 0x54(r1)
- fmr f28, f1
- mr r30, r3
- fmr f29, f2
- mr r31, r4
- fmr f30, f3
- mr r4, r30
- fmr f31, f4
- addi r3, r1, 0x2C
- bl 0x8CAE8
- lfs f0, -0x68E8(r2)
- li r3, 0
- lis r4, 0x804B
- addi r0, r1, 0x2C
- fadds f31, f31, f0
- subi r4, r4, 0x437C
- stw r4, 0x8(r1)
- fmr f1, f31
- stw r3, 0x14(r1)
- stw r3, 0xC(r1)
- stw r0, 0x10(r1)
- bl 0x2FEA2C
- lwz r0, 0x14(r1)
- fmr f31, f1
- cmplwi r0, 0
- bne- .loc_0xB8
- lwz r3, 0x10(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x18(r12)
- mtctr r12
- bctrl
- stw r3, 0xC(r1)
- b .loc_0x304
-
- .loc_0xB8:
- lwz r3, 0x10(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x18(r12)
- mtctr r12
- bctrl
- stw r3, 0xC(r1)
- b .loc_0x128
-
- .loc_0xD4:
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x20(r12)
- mtctr r12
- bctrl
- mr r4, r3
- lwz r3, 0x14(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x8(r12)
- mtctr r12
- bctrl
- rlwinm. r0,r3,0,24,31
- bne- .loc_0x304
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x14(r12)
- mtctr r12
- bctrl
- stw r3, 0xC(r1)
-
- .loc_0x128:
- lwz r12, 0x8(r1)
- addi r3, r1, 0x8
- lwz r12, 0x10(r12)
- mtctr r12
- bctrl
- rlwinm. r0,r3,0,24,31
- beq+ .loc_0xD4
- b .loc_0x304
-
- .loc_0x148:
- lwz r3, 0x10(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x20(r12)
- mtctr r12
- bctrl
- lwz r12, 0x0(r3)
- mr r29, r3
- lwz r12, 0x18(r12)
- mtctr r12
- bctrl
- rlwinm. r0,r3,0,24,31
- beq- .loc_0x248
- cmplwi r31, 0
- beq- .loc_0x1A4
- beq- .loc_0x248
- mr r3, r31
- mr r4, r29
- lwz r12, 0x0(r31)
- lwz r12, 0x8(r12)
- mtctr r12
- bctrl
- rlwinm. r0,r3,0,24,31
- beq- .loc_0x248
-
- .loc_0x1A4:
- bl -0x49D20
- xoris r3, r3, 0x8000
- lis r0, 0x4330
- stw r3, 0x4C(r1)
- lfd f2, -0x68D8(r2)
- stw r0, 0x48(r1)
- lfs f0, -0x68DC(r2)
- lfd f1, 0x48(r1)
- fsubs f1, f1, f2
- fdivs f0, f1, f0
- fcmpo cr0, f28, f0
- ble- .loc_0x248
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x20(r12)
- mtctr r12
- bctrl
- lwz r0, 0xF4(r3)
- mr r29, r3
- cmplw r0, r30
- bne- .loc_0x248
- bl 0x8C270
- rlwinm. r0,r3,0,24,31
- bne- .loc_0x248
- lis r4, 0x804B
- lis r3, 0x804B
- subi r4, r4, 0x5D00
- stw r30, 0x1C(r1)
- addi r0, r3, 0x4E04
- mr r3, r29
- stw r4, 0x18(r1)
- addi r4, r1, 0x18
- stw r0, 0x18(r1)
- stfs f29, 0x20(r1)
- stfs f30, 0x24(r1)
- stfs f31, 0x28(r1)
- lwz r12, 0x0(r29)
- lwz r12, 0x1A4(r12)
- mtctr r12
- bctrl
-
- .loc_0x248:
- lwz r0, 0x14(r1)
- cmplwi r0, 0
- bne- .loc_0x274
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x14(r12)
- mtctr r12
- bctrl
- stw r3, 0xC(r1)
- b .loc_0x304
-
- .loc_0x274:
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x14(r12)
- mtctr r12
- bctrl
- stw r3, 0xC(r1)
- b .loc_0x2E8
-
- .loc_0x294:
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x20(r12)
- mtctr r12
- bctrl
- mr r4, r3
- lwz r3, 0x14(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x8(r12)
- mtctr r12
- bctrl
- rlwinm. r0,r3,0,24,31
- bne- .loc_0x304
- lwz r3, 0x10(r1)
- lwz r4, 0xC(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x14(r12)
- mtctr r12
- bctrl
- stw r3, 0xC(r1)
-
- .loc_0x2E8:
- lwz r12, 0x8(r1)
- addi r3, r1, 0x8
- lwz r12, 0x10(r12)
- mtctr r12
- bctrl
- rlwinm. r0,r3,0,24,31
- beq+ .loc_0x294
-
- .loc_0x304:
- lwz r3, 0x10(r1)
- lwz r12, 0x0(r3)
- lwz r12, 0x1C(r12)
- mtctr r12
- bctrl
- lwz r4, 0xC(r1)
- cmplw r4, r3
- bne+ .loc_0x148
- addi r3, r1, 0x2C
- li r4, -0x1
- bl 0x8C91C
- psq_l f31,0x98(r1),0,0
- lfd f31, 0x90(r1)
- psq_l f30,0x88(r1),0,0
- lfd f30, 0x80(r1)
- psq_l f29,0x78(r1),0,0
- lfd f29, 0x70(r1)
- psq_l f28,0x68(r1),0,0
- lfd f28, 0x60(r1)
- lwz r31, 0x5C(r1)
- lwz r30, 0x58(r1)
- lwz r0, 0xA4(r1)
- lwz r29, 0x54(r1)
- mtlr r0
- addi r1, r1, 0xA0
- blr
- */
+ Stickers stickers(creature);
+
+ Iterator iter(&stickers);
+ angle += PI;
+ angle = roundAng(angle);
+ CI_LOOP(iter)
+ {
+ Creature* stuck = *iter;
+ if (stuck->isPiki()) {
+ if (!condition || (condition && condition->satisfy(static_cast(stuck)))) {
+ if (flickChance > randFloat()) {
+ flickCreature(creature, *iter, knockback, damage, angle);
+ }
+ }
+ }
+ }
}
/*
@@ -1088,8 +806,23 @@ void EnemyFunc::flickStickPikmin(Game::Creature*, float, float, float, float, Co
* Address: 801134D4
* Size: 0002BC
*/
-void EnemyFunc::flickNearbyPikmin(Game::Creature*, float, float, float, float, Condition*)
+void flickNearbyPikmin(Creature* creature, f32 searchRadius, f32 knockback, f32 damage, f32 angle, Condition* condition)
{
+ searchRadius *= searchRadius;
+
+ ConditionPikminNearby nearbyCondition(creature, searchRadius);
+ Iterator iter(pikiMgr, nullptr, condition);
+ angle += PI;
+
+ CI_LOOP(iter)
+ {
+ Piki* piki = *iter;
+ // need to get this to call a virtual rather than direct function
+ if (nearbyCondition.satisfy(piki)) {
+ InteractFlick flick(creature, knockback, damage, angle);
+ piki->stimulate(flick);
+ }
+ }
/*
.loc_0x0:
stwu r1, -0x70(r1)
@@ -1293,8 +1026,26 @@ void EnemyFunc::flickNearbyPikmin(Game::Creature*, float, float, float, float, C
* Address: 80113790
* Size: 0003A4
*/
-void EnemyFunc::flickNearbyNavi(Game::Creature*, float, float, float, float, Condition*)
+void flickNearbyNavi(Creature* creature, f32 searchRadius, f32 knockback, f32 damage, f32 angle, Condition* condition)
{
+ searchRadius *= searchRadius;
+
+ // ConditionPikminNearby nearbyCondition (creature, searchRadius);
+ Iterator iter(naviMgr, nullptr, condition);
+ angle += PI;
+
+ CI_LOOP(iter)
+ {
+ Navi* navi = *iter;
+ // this is fucky
+ Vector3f sep = Vector3f(creature->getPosition().x, creature->getPosition().y, creature->getPosition().z)
+ - Vector3f(navi->getPosition().x, navi->getPosition().y, navi->getPosition().z);
+ f32 newDist = SQUARE(sep.x) + SQUARE(sep.y) + SQUARE(sep.z);
+ if (newDist < searchRadius) {
+ InteractFlick flick(creature, knockback, damage, angle);
+ navi->stimulate(flick);
+ }
+ }
/*
.loc_0x0:
stwu r1, -0x110(r1)
@@ -1556,8 +1307,9 @@ void EnemyFunc::flickNearbyNavi(Game::Creature*, float, float, float, float, Con
* Address: 80113B34
* Size: 000350
*/
-int EnemyFunc::eatPikmin(Game::EnemyBase*, Condition*)
+int eatPikmin(EnemyBase* enemy, Condition* condition)
{
+
/*
stwu r1, -0x70(r1)
mflr r0
@@ -1811,7 +1563,7 @@ int EnemyFunc::eatPikmin(Game::EnemyBase*, Condition*)
* Address: 80113E84
* Size: 0003DC
*/
-void EnemyFunc::swallowPikmin(Game::Creature*, float, Condition*)
+void swallowPikmin(Creature*, float, Condition*)
{
/*
stwu r1, -0xa0(r1)
@@ -2089,7 +1841,7 @@ void EnemyFunc::swallowPikmin(Game::Creature*, float, Condition*)
* Address: 80114260
* Size: 0003F8
*/
-void EnemyFunc::attackNavi(Game::Creature*, float, float, float, CollPart*, Condition*)
+int attackNavi(Creature*, float, float, float, CollPart*, Condition*)
{
/*
.loc_0x0:
@@ -2379,79 +2131,42 @@ void EnemyFunc::attackNavi(Game::Creature*, float, float, float, CollPart*, Cond
* Address: 80114658
* Size: 0000DC
*/
-bool EnemyFunc::isStartFlick(Game::EnemyBase*, bool)
+bool isStartFlick(EnemyBase* enemy, bool doResetFlickCounter)
{
- /*
- stwu r1, -0x10(r1)
- li r7, 0
- lfs f0, lbl_80517A80@sda21(r2)
- lfs f1, 0x20c(r3)
- fcmpo cr0, f1, f0
- cror 2, 1, 2
- bne lbl_80114680
- lfs f0, lbl_80517A94@sda21(r2)
- fadds f0, f0, f1
- b lbl_80114688
-
-lbl_80114680:
- lfs f0, lbl_80517A94@sda21(r2)
- fsubs f0, f1, f0
-
-lbl_80114688:
- fctiwz f0, f0
- lwz r6, 0xc0(r3)
- lwz r5, 0x1f4(r3)
- lwz r0, 0x71c(r6)
- stfd f0, 8(r1)
- cmpw r5, r0
- lwz r0, 0xc(r1)
- clrlwi r8, r0, 0x18
- bge lbl_801146C0
- lwz r0, 0x6f4(r6)
- cmpw r8, r0
- ble lbl_80114710
- li r7, 1
- b lbl_80114710
-
-lbl_801146C0:
- lwz r0, 0x76c(r6)
- cmpw r5, r0
- bge lbl_801146E0
- lwz r0, 0x744(r6)
- cmpw r8, r0
- ble lbl_80114710
- li r7, 1
- b lbl_80114710
-
-lbl_801146E0:
- lwz r0, 0x7bc(r6)
- cmpw r5, r0
- bge lbl_80114700
- lwz r0, 0x794(r6)
- cmpw r8, r0
- ble lbl_80114710
- li r7, 1
- b lbl_80114710
-
-lbl_80114700:
- lwz r0, 0x7e4(r6)
- cmpw r8, r0
- ble lbl_80114710
- li r7, 1
-
-lbl_80114710:
- clrlwi. r0, r7, 0x18
- beq lbl_80114728
- clrlwi. r0, r4, 0x18
- beq lbl_80114728
- lfs f0, lbl_80517A80@sda21(r2)
- stfs f0, 0x20c(r3)
-
-lbl_80114728:
- mr r3, r7
- addi r1, r1, 0x10
- blr
- */
+ EnemyParmsBase* parms;
+ bool result = false;
+ f32 flickVal = 0.0f;
+ if (enemy->mToFlick >= 0.0f) {
+ flickVal = enemy->mToFlick + 0.5f;
+ } else {
+ flickVal = enemy->mToFlick - 0.5f;
+ }
+
+ // int stuckCount = enemy->mStuckPikminCount;
+ parms = static_cast(enemy->mParms);
+ u8 flickInt = (int)flickVal;
+
+ if (enemy->mStuckPikminCount < parms->mGeneral.mIp02.mValue) {
+ if (flickInt > parms->mGeneral.mIp01.mValue) {
+ result = true;
+ }
+ } else if (enemy->mStuckPikminCount < parms->mGeneral.mIp04.mValue) {
+ if (flickInt > parms->mGeneral.mIp03.mValue) {
+ result = true;
+ }
+ } else if (enemy->mStuckPikminCount < parms->mGeneral.mIp06.mValue) {
+ if (flickInt > parms->mGeneral.mIp05.mValue) {
+ result = true;
+ }
+ } else if (flickInt > parms->mGeneral.mIp07.mValue) {
+ result = true;
+ }
+
+ if (result && doResetFlickCounter) {
+ enemy->mToFlick = 0.0f;
+ }
+
+ return result;
}
/*
@@ -2459,7 +2174,7 @@ bool EnemyFunc::isStartFlick(Game::EnemyBase*, bool)
* Address: 80114734
* Size: 00038C
*/
-bool EnemyFunc::isTherePikmin(Game::Creature*, float, Condition*)
+bool isTherePikmin(Creature*, float, Condition*)
{
/*
stwu r1, -0xd0(r1)
@@ -2719,7 +2434,7 @@ bool EnemyFunc::isTherePikmin(Game::Creature*, float, Condition*)
* Address: 80114AC0
* Size: 000330
*/
-bool EnemyFunc::isThereOlimar(Game::Creature*, float, Condition*)
+bool isThereOlimar(Creature*, float, Condition*)
{
/*
stwu r1, -0xd0(r1)
@@ -2954,7 +2669,7 @@ bool EnemyFunc::isThereOlimar(Game::Creature*, float, Condition*)
* Address: 80114DF0
* Size: 0003C4
*/
-int EnemyFunc::getSurroundPikminNum(Game::Creature*, float, Condition*)
+int getSurroundPikminNum(Creature*, float, Condition*)
{
/*
.loc_0x0:
@@ -3227,7 +2942,7 @@ int EnemyFunc::getSurroundPikminNum(Game::Creature*, float, Condition