diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index 39eefbd45..ca71e0844 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -124,9 +124,9 @@ | File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | bomb.cpp | 12903 | tamagoMushiMgr.cpp | 13197 | -| hurryUp2D.cpp | 26921 | panModokiState.cpp | 27115 | -| dayEndCount.cpp | 39857 | miulin.cpp | 40256 | -| scrollList.cpp | 41187 | jigumoState.cpp | 44498 | +| hurryUp2D.cpp | 26921 | panModokiState.cpp | 27075 | +| jigumoState.cpp | 39381 | dayEndCount.cpp | 39857 | +| miulin.cpp | 40256 | scrollList.cpp | 41187 | | kingChappyState.cpp | 59593 | tamagoMushi.cpp | 72662 | | tyre.cpp | 83627 | kingChappy.cpp | 86600 | | umiMushi.cpp | 97877 | @@ -137,21 +137,21 @@ | nslibmath.cpp | 4592 | Tadpole.cpp | 6758 | | TyreShadow.cpp | 7234 | MaroFrog.cpp | 7517 | | UmimushiShadow.cpp | 7565 | ContRumble.cpp | 9005 | -| SnakeJointMgr.cpp | 10097 | BabyState.cpp | 12965 | +| SnakeJointMgr.cpp | 10097 | BabyState.cpp | 12955 | | Tank.cpp | 13328 | JointShadowBase.cpp | 14958 | -| ElecBugState.cpp | 15381 | Kogane.cpp | 15652 | +| Kogane.cpp | 15652 | ElecBugState.cpp | 15737 | | RandMapMgr.cpp | 17083 | TadpoleState.cpp | 17799 | -| OtakaraBase.cpp | 18394 | FuefukiState.cpp | 19023 | +| OtakaraBase.cpp | 18394 | FuefukiState.cpp | 19013 | | SnakeWholeShadow.cpp | 19376 | SnakeCrowShadow.cpp | 19385 | -| ImomushiState.cpp | 19911 | UjiaState.cpp | 20959 | +| ImomushiState.cpp | 19911 | UjiaState.cpp | 20954 | | RumbleMgr.cpp | 21534 | Rock.cpp | 21766 | -| ElecHiba.cpp | 21900 | QueenState.cpp | 22549 | -| ElecBug.cpp | 24345 | ArmorState.cpp | 24720 | -| SaraiState.cpp | 24929 | TobiState.cpp | 24992 | -| UjibState.cpp | 25560 | Armor.cpp | 28880 | -| TankState.cpp | 29299 | RandItemUnit.cpp | 29622 | -| IKSystemBase.cpp | 30077 | FrogState.cpp | 30933 | -| BigTreasureShadow.cpp | 32591 | MarState.cpp | 33440 | +| ElecHiba.cpp | 21900 | Frog.cpp | 22143 | +| QueenState.cpp | 22549 | ElecBug.cpp | 24345 | +| ArmorState.cpp | 24720 | SaraiState.cpp | 24929 | +| TobiState.cpp | 24992 | UjibState.cpp | 25555 | +| Armor.cpp | 28880 | TankState.cpp | 29299 | +| RandItemUnit.cpp | 29622 | IKSystemBase.cpp | 30077 | +| FrogState.cpp | 30933 | BigTreasureShadow.cpp | 32591 | ###
plugProjectOgawaU
| File | Size (bytes) | File | Size (bytes) | diff --git a/include/Game/EnemyBase.h b/include/Game/EnemyBase.h index c5591af35..6b2385771 100644 --- a/include/Game/EnemyBase.h +++ b/include/Game/EnemyBase.h @@ -500,6 +500,69 @@ struct EnemyBase : public Creature, public SysShape::MotionListener, virtual pub sep.y = mPosition.z - point.z; } + inline f32 getCreatureViewAngle(Creature* target) + { + Vector3f targetPos = target->getPosition(); + Vector3f pos = getPosition(); + f32 ang = _angXZ(targetPos.x, targetPos.z, pos.x, pos.z); + return angDist(ang, getFaceDir()); + } + + inline f32 getCreatureViewAngle(Vector3f& targetPos) + { + Vector3f pos = getPosition(); + f32 ang = _angXZ(targetPos.x, targetPos.z, pos.x, pos.z); + return angDist(ang, getFaceDir()); + } + + // this seems necessary and correct based on BombSarai::Obj::throwBomb + inline void updateFaceDir(f32 angle) + { + mFaceDir = angle; + mRotation.y = mFaceDir; + } + + inline f32 turnToTarget(Creature* target, f32 turnFactor, f32 maxTurnSpeed) + { + f32 angleDist = getAngDist(target); + f32 turnSpeed = angleDist * turnFactor; + f32 limit = PI * (DEG2RAD * maxTurnSpeed); + if (FABS(turnSpeed) > limit) { + turnSpeed = (turnSpeed > 0.0f) ? limit : -limit; + } + + updateFaceDir(roundAng(turnSpeed + getFaceDir())); + + return angleDist; + } + + inline f32 turnToTarget(Vector3f& targetPos, f32 turnFactor, f32 maxTurnSpeed) + { + f32 angleDist = getAngDist(targetPos); + f32 turnSpeed = angleDist * turnFactor; + f32 limit = PI * (DEG2RAD * maxTurnSpeed); + if (FABS(turnSpeed) > limit) { + turnSpeed = (turnSpeed > 0.0f) ? limit : -limit; + } + + updateFaceDir(roundAng(turnSpeed + getFaceDir())); + + return angleDist; + } + + inline bool checkDistAndAngle(Creature* target, f32 angle, f32 distRange, f32 angRange) + { + bool result = false; + Vector3f sep; + sep.x = target->getPosition().x - getPosition().x; + sep.y = target->getPosition().y - getPosition().y; + sep.z = target->getPosition().z - getPosition().z; + if ((sep.sqrMagnitude() < SQUARE(distRange)) && FABS(angle) <= PI * (DEG2RAD * angRange)) { + result = true; + } + return result; + } + inline f32 changeFaceDir(Vector3f& XYZ) { f32 approxSpeed; @@ -584,118 +647,8 @@ struct EnemyBase : public Creature, public SysShape::MotionListener, virtual pub return angleDist; } - inline f32 turnToTarget(Vector3f& XZ, f32 angLimit, f32 scale) - { - Vector3f pos = getPosition(); - Vector3f targetPos = XZ; - - f32 angleDist = angDist(_angXZ(targetPos.x, targetPos.z, pos.x, pos.z), getFaceDir()); - angleDist *= scale; - f32 limit = angLimit; - if (FABS(angleDist) > limit) { - angleDist = (angleDist > 0.0f) ? limit : -limit; - } - return angleDist; - } - - inline f32 turnToTarget2(Vector3f& XZ, f32 scale, f32 angLimit) - { - Vector3f pos = getPosition(); - Vector3f targetPos = XZ; - - f32 angleDist = angDist(angXZ(targetPos.x, targetPos.z, pos), getFaceDir()); - f32 approxSpeed = angleDist * scale; - f32 limit = (DEG2RAD * angLimit) * PI; - if (FABS(approxSpeed) > limit) { - approxSpeed = boundVal(approxSpeed, limit); - } - - mFaceDir = roundAng(approxSpeed + getFaceDir()); - mRotation.y = mFaceDir; - - return angleDist; - } - - // this seems necessary and correct based on BombSarai::Obj::throwBomb - inline void updateFaceDir(f32 angle) - { - mFaceDir = angle; - mRotation.y = mFaceDir; - } - - inline f32 turnToTargetNishi(Creature* target, f32 turnFactor, f32 maxTurnSpeed) - { - f32 angleDist = getAngDist(target); - f32 turnSpeed = angleDist * turnFactor; - f32 limit = PI * (DEG2RAD * maxTurnSpeed); - if (FABS(turnSpeed) > limit) { - turnSpeed = (turnSpeed > 0.0f) ? limit : -limit; - } - - updateFaceDir(roundAng(turnSpeed + getFaceDir())); - - return angleDist; - } - inline f32 turnToTargetNishi(Vector3f& targetPos, f32 turnFactor, f32 maxTurnSpeed) - { - f32 angleDist = getAngDist(targetPos); - f32 turnSpeed = angleDist * turnFactor; - f32 limit = PI * (DEG2RAD * maxTurnSpeed); - if (FABS(turnSpeed) > limit) { - turnSpeed = (turnSpeed > 0.0f) ? limit : -limit; - } - - updateFaceDir(roundAng(turnSpeed + getFaceDir())); - - return angleDist; - } - inline void forceMovePosition(Vector3f offset) { mPosition += offset; } - inline f32 turnToTargetMori(Vector3f& targetPos, f32 turnFactor, f32 maxTurnSpeed) - { - Vector3f pos = getPosition(); - - f32 angleDist = angDist(angXZ(targetPos.x, targetPos.z, pos), getFaceDir()); - f32 turnSpeed = angleDist * turnFactor; - f32 limit = PI * (DEG2RAD * maxTurnSpeed); - if (FABS(turnSpeed) > limit) { - turnSpeed = (turnSpeed > 0.0f) ? limit : -limit; - } - - updateFaceDir(roundAng(turnSpeed + getFaceDir())); - - return angleDist; - } - - inline bool checkDistAndAngle(Creature* target, f32 angle, f32 distRange, f32 angRange) - { - bool result = false; - Vector3f sep; - sep.x = target->getPosition().x - getPosition().x; - sep.y = target->getPosition().y - getPosition().y; - sep.z = target->getPosition().z - getPosition().z; - if ((sep.sqrMagnitude() < SQUARE(distRange)) && FABS(angle) <= PI * (DEG2RAD * angRange)) { - result = true; - } - return result; - } - - inline f32 getCreatureViewAngle(Creature* target) - { - Vector3f targetPos = target->getPosition(); - Vector3f pos = getPosition(); - f32 ang = _angXZ(targetPos.x, targetPos.z, pos.x, pos.z); - return angDist(ang, getFaceDir()); - } - - inline f32 getCreatureViewAngle(Vector3f& targetPos) - { - Vector3f pos = getPosition(); - f32 ang = _angXZ(targetPos.x, targetPos.z, pos.x, pos.z); - return angDist(ang, getFaceDir()); - } - inline f32 getDamageAnimFrac(f32 scale) { return (mDamageAnimTimer / scale); } inline f32 getSqrHomeRadius() const diff --git a/include/Game/Entities/Frog.h b/include/Game/Entities/Frog.h index 9717138cb..f3cc69ee0 100644 --- a/include/Game/Entities/Frog.h +++ b/include/Game/Entities/Frog.h @@ -21,6 +21,21 @@ namespace Game { namespace Frog { struct FSM; +enum StateID { + FROG_NULL = -1, + FROG_Dead = 0, + FROG_Wait = 1, + FROG_Turn = 2, + FROG_Jump = 3, + FROG_JumpWait = 4, + FROG_Fall = 5, + FROG_Attack = 6, + FROG_Fail = 7, + FROG_TurnToHome = 8, + FROG_GoHome = 9, + FROG_StateCount, // 10 +}; + struct Obj : public EnemyBase { Obj(); @@ -74,7 +89,7 @@ struct Obj : public EnemyBase { f32 mAirTimer; // _2C0 f32 _2C4; // _2C4 Vector3f mTargetPosition; // _2C8 - int mNextState; // _2D4 + StateID mNextState; // _2D4 bool mIsInAir; // _2D8 bool mIsFalling; // _2D9 efx::TFrogPota* mEfxPota; // _2DC @@ -141,21 +156,6 @@ struct ProperAnimator : public EnemyAnimatorBase { ///////////////////////////////////////////////////////////////// // STATE MACHINE DEFINITIONS -enum StateID { - FROG_NULL = -1, - FROG_Dead = 0, - FROG_Wait = 1, - FROG_Turn = 2, - FROG_Jump = 3, - FROG_JumpWait = 4, - FROG_Fall = 5, - FROG_Attack = 6, - FROG_Fail = 7, - FROG_TurnToHome = 8, - FROG_GoHome = 9, - FROG_StateCount, // 10 -}; - struct FSM : public EnemyStateMachine { virtual void init(EnemyBase*); // _08 diff --git a/include/Vector3.h b/include/Vector3.h index 0e93dc0ef..3869cec04 100644 --- a/include/Vector3.h +++ b/include/Vector3.h @@ -307,7 +307,7 @@ inline void _normaliseScale(Vector3f& vec, f32 scale) vec.z *= scale; } -inline void _normaliseXZ(Vector3f& vec) +inline f32 _normaliseXZ(Vector3f& vec) { Vector2f sqr(vec.z * vec.z, vec.x * vec.x + vec.y * vec.y); f32 length = sqr.x + sqr.y; @@ -318,6 +318,8 @@ inline void _normaliseXZ(Vector3f& vec) vec.x *= norm; vec.z *= norm; } + + return length; } inline f32 _normaliseVec(Vector3f& vec) diff --git a/include/efx/TSimple.h b/include/efx/TSimple.h index dd32b5a77..dcf6ebb50 100644 --- a/include/efx/TSimple.h +++ b/include/efx/TSimple.h @@ -80,9 +80,9 @@ struct TSimple4 : public TBase { mEmitters[3] = nullptr; } - virtual bool create(Arg*); // _08 - virtual void forceKill(); // _0C (weak) - virtual void fade(); // _10 (weak) + virtual bool create(Arg*); // _08 + virtual void forceKill() { } // _0C (weak) + virtual void fade() { } // _10 (weak) /** * @fabricated diff --git a/src/plugProjectMorimuraU/jigumoState.cpp b/src/plugProjectMorimuraU/jigumoState.cpp index 22507bce4..b2cf36ae2 100644 --- a/src/plugProjectMorimuraU/jigumoState.cpp +++ b/src/plugProjectMorimuraU/jigumoState.cpp @@ -152,13 +152,8 @@ void StateAppear::exec(EnemyBase* enemy) FakePiki* target = OBJ(enemy)->getNearestPikiOrNavi(360.0f, terrRad); enemy->mTargetCreature = target; if (target) { - Vector3f targetPos = target->getPosition(); - // this inline needs fixing but seems the most real - f32 angleDist = enemy->turnToTarget(targetPos, TAU, 1.0f); - - enemy->mFaceDir = roundAng(angleDist + enemy->getFaceDir()); - enemy->mRotation.y = enemy->mFaceDir; - OBJ(enemy)->_2EC = enemy->mFaceDir; + f32 angleDist = enemy->turnToTarget(target, 1.0f, TAU); + OBJ(enemy)->_2EC = enemy->mFaceDir; } } @@ -180,231 +175,6 @@ void StateAppear::exec(EnemyBase* enemy) } } } - /* - stwu r1, -0x80(r1) - mflr r0 - stw r0, 0x84(r1) - stfd f31, 0x70(r1) - psq_st f31, 120(r1), 0, qr0 - stw r31, 0x6c(r1) - stw r30, 0x68(r1) - mr r30, r3 - mr r31, r4 - lwz r3, 0x10(r3) - addi r0, r3, 1 - stw r0, 0x10(r30) - lwz r3, 0xc0(r4) - lwz r4, 0x10(r30) - lwz r0, 0x8e4(r3) - cmpw r4, r0 - ble lbl_8036680C - mr r3, r31 - bl isStopMotion__Q24Game9EnemyBaseFv - clrlwi. r0, r3, 0x18 - beq lbl_80366724 - lwz r5, 0xc0(r31) - mr r3, r31 - li r4, 0 - lfs f31, 0x35c(r5) - fmr f1, f31 - bl -"isThereOlimar__Q24Game9EnemyFuncFPQ24Game8CreaturefP23Condition" - clrlwi. r0, r3, 0x18 - beq lbl_80366584 - li r0, 1 - b lbl_803665A8 - -lbl_80366584: - fmr f1, f31 - mr r3, r31 - li r4, 0 - bl -"isTherePikmin__Q24Game9EnemyFuncFPQ24Game8CreaturefP23Condition" - clrlwi. r0, r3, 0x18 - beq lbl_803665A4 - li r0, 1 - b lbl_803665A8 - -lbl_803665A4: - li r0, 0 - -lbl_803665A8: - clrlwi. r0, r0, 0x18 - beq lbl_8036680C - mr r3, r31 - bl startMotion__Q24Game9EnemyBaseFv - mr r4, r31 - addi r3, r1, 0x44 - lwz r12, 0(r31) - lwz r12, 8(r12) - mtctr r12 - bctrl - lfs f2, 0x44(r1) - addi r5, r1, 0x5c - lfs f1, 0x48(r1) - li r4, 8 - lfs f0, 0x4c(r1) - li r6, 2 - stfs f2, 0x5c(r1) - lwz r3, rumbleMgr__4Game@sda21(r13) - stfs f1, 0x60(r1) - stfs f0, 0x64(r1) - bl "startRumble__Q24Game9RumbleMgrFiR10Vector3i" - fmr f2, f31 - lfs f1, lbl_8051E88C@sda21(r2) - mr r3, r31 - bl getNearestPikiOrNavi__Q34Game6Jigumo3ObjFff - cmplwi r3, 0 - stw r3, 0x230(r31) - beq lbl_8036680C - mr r4, r3 - addi r3, r1, 0x20 - lwz r12, 0(r4) - lwz r12, 8(r12) - mtctr r12 - bctrl - mr r4, r31 - lfs f2, 0x20(r1) - lwz r12, 0(r31) - addi r3, r1, 0x2c - lfs f1, 0x24(r1) - lfs f0, 0x28(r1) - lwz r12, 8(r12) - stfs f2, 8(r1) - stfs f1, 0xc(r1) - stfs f0, 0x10(r1) - mtctr r12 - bctrl - lfs f5, 0x2c(r1) - lis r3, atanTable___5JMath@ha - lfs f3, 0x34(r1) - addi r3, r3, atanTable___5JMath@l - lfs f1, 8(r1) - lfs f0, 0x10(r1) - lfs f4, 0x30(r1) - fsubs f1, f1, f5 - fsubs f2, f0, f3 - stfs f5, 0x14(r1) - stfs f4, 0x18(r1) - stfs f3, 0x1c(r1) - bl "atan2___Q25JMath18TAtanTable<1024,f>CFff" - bl roundAng__Ff - lwz r12, 0(r31) - fmr f31, f1 - mr r3, r31 - lwz r12, 0x64(r12) - mtctr r12 - bctrl - fmr f2, f1 - fmr f1, f31 - bl angDist__Fff - lfs f0, lbl_8051E884@sda21(r2) - lfs f2, lbl_8051E890@sda21(r2) - fmuls f31, f1, f0 - fabs f0, f31 - frsp f0, f0 - fcmpo cr0, f0, f2 - ble lbl_803666F0 - lfs f0, lbl_8051E880@sda21(r2) - fcmpo cr0, f31, f0 - ble lbl_803666EC - fmr f31, f2 - b lbl_803666F0 - -lbl_803666EC: - fneg f31, f2 - -lbl_803666F0: - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 0x64(r12) - mtctr r12 - bctrl - fadds f1, f31, f1 - bl roundAng__Ff - stfs f1, 0x1fc(r31) - lfs f0, 0x1fc(r31) - stfs f0, 0x1a8(r31) - lfs f0, 0x1fc(r31) - stfs f0, 0x2ec(r31) - b lbl_8036680C - -lbl_80366724: - lwz r3, 0x188(r31) - lbz r0, 0x24(r3) - cmplwi r0, 0 - beq lbl_8036680C - lwz r0, 0x1c(r3) - cmplwi r0, 2 - bne lbl_803667B8 - lwz r0, 0x280(r31) - cmplwi r0, 0 - beq lbl_80366764 - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 0x250(r12) - mtctr r12 - bctrl - b lbl_803667AC - -lbl_80366764: - mr r4, r31 - addi r3, r1, 0x38 - lwz r12, 0(r31) - lwz r12, 8(r12) - mtctr r12 - bctrl - lfs f1, 0x38(r1) - mr r3, r31 - lfs f2, 0x3c(r1) - addi r4, r1, 0x50 - lfs f0, 0x40(r1) - stfs f1, 0x50(r1) - lfs f1, lbl_8051E894@sda21(r2) - stfs f2, 0x54(r1) - stfs f0, 0x58(r1) - lfs f0, 0x1f8(r31) - fmuls f1, f1, f0 - bl "createDropEffect__Q24Game9EnemyBaseFRC10Vector3f" - -lbl_803667AC: - lwz r0, 0x1e0(r31) - rlwinm r0, r0, 0, 0xa, 8 - stw r0, 0x1e0(r31) - -lbl_803667B8: - lwz r3, 0x188(r31) - lwz r0, 0x1c(r3) - cmplwi r0, 0x3e8 - bne lbl_8036680C - mr r3, r30 - mr r4, r31 - lwz r12, 0(r30) - li r5, 0 - li r6, 0 - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - mr r3, r31 - li r4, 1 - lwz r12, 0(r31) - lwz r12, 0xac(r12) - mtctr r12 - bctrl - lwz r0, 0x1e0(r31) - ori r0, r0, 0x800 - stw r0, 0x1e0(r31) - -lbl_8036680C: - psq_l f31, 120(r1), 0, qr0 - lwz r0, 0x84(r1) - lfd f31, 0x70(r1) - lwz r31, 0x6c(r1) - lwz r30, 0x68(r1) - mtlr r0 - addi r1, r1, 0x80 - blr - */ } /* @@ -561,8 +331,8 @@ void StateAttack::exec(EnemyBase* enemy) FakePiki* target = OBJ(enemy)->getNearestPikiOrNavi(CG_PARMS(enemy)->mGeneral.mSearchAngle.mValue, CG_PARMS(enemy)->mGeneral.mSearchDistance.mValue); if (target) { - enemy->changeFaceDir(target); - OBJ(enemy)->mGoalPosition = Vector3f(enemy->getPosition()); + enemy->turnToTarget(target, *CG_PARMS(enemy)->mGeneral.mRotationalAccel(), *CG_PARMS(enemy)->mGeneral.mRotationalSpeed()); + OBJ(enemy)->mGoalPosition = Vector3f(target->getPosition()); } } @@ -608,7 +378,7 @@ void StateAttack::exec(EnemyBase* enemy) Vector3f pos = OBJ(enemy)->getPosition(); Vector3f goalPos = OBJ(enemy)->getGoalPos(); Vector3f diff = pos - goalPos; - if (diff.x * diff.x + diff.y * diff.y + diff.z * diff.z < 100.0f) { + if (diff.sqrMagnitude() < 100.0f) { _10 = 0; OBJ(enemy)->effectStop(); enemy->mTargetVelocity = Vector3f(0.0f); diff --git a/src/plugProjectMorimuraU/panModokiState.cpp b/src/plugProjectMorimuraU/panModokiState.cpp index 63a230fd7..ee6eaaa20 100644 --- a/src/plugProjectMorimuraU/panModokiState.cpp +++ b/src/plugProjectMorimuraU/panModokiState.cpp @@ -974,8 +974,7 @@ void StateCarryEnd::exec(EnemyBase* enemy) } } else { - enemy->turnToTargetMori(_10, CG_PARMS(enemy)->mGeneral.mRotationalAccel.mValue, - CG_PARMS(enemy)->mGeneral.mRotationalSpeed.mValue); + enemy->turnToTarget(_10, *CG_PARMS(enemy)->mGeneral.mRotationalAccel(), *CG_PARMS(enemy)->mGeneral.mRotationalSpeed()); diff.x *= 0.05f; diff.y *= 0.05f; diff.z *= 0.05f; diff --git a/src/plugProjectNishimuraU/BabyState.cpp b/src/plugProjectNishimuraU/BabyState.cpp index 9c3f5bc12..e2891e52b 100644 --- a/src/plugProjectNishimuraU/BabyState.cpp +++ b/src/plugProjectNishimuraU/BabyState.cpp @@ -168,8 +168,8 @@ void StateMove::exec(EnemyBase* enemy) if (creature) { - f32 angleDist = baby->turnToTargetNishi(creature, CG_PARMS(baby)->mGeneral.mRotationalAccel.mValue, - CG_PARMS(baby)->mGeneral.mRotationalSpeed.mValue); + f32 angleDist = baby->turnToTarget(creature, CG_PARMS(baby)->mGeneral.mRotationalAccel.mValue, + CG_PARMS(baby)->mGeneral.mRotationalSpeed.mValue); f32 limit = PI * (DEG2RAD * *CG_PARMS(baby)->mGeneral.mMinAttackRange()); f32 absDist = FABS(angleDist); diff --git a/src/plugProjectNishimuraU/DangoMushi.cpp b/src/plugProjectNishimuraU/DangoMushi.cpp index 04d12f510..d8ac436a9 100644 --- a/src/plugProjectNishimuraU/DangoMushi.cpp +++ b/src/plugProjectNishimuraU/DangoMushi.cpp @@ -422,7 +422,7 @@ void Obj::rollingMove() } Parms* parms = static_cast(mParms); - turnToTargetMori(targetPos, C_PROPERPARMS.mRollingTurnAccel.mValue, C_PROPERPARMS.mRollingTurnSpeed.mValue); + turnToTarget(targetPos, C_PROPERPARMS.mRollingTurnAccel.mValue, C_PROPERPARMS.mRollingTurnSpeed.mValue); f32 rollSpeed = C_PROPERPARMS.mRollingMoveSpeed.mValue; f32 x = (f32)sin(getFaceDir()); diff --git a/src/plugProjectNishimuraU/DangoMushiState.cpp b/src/plugProjectNishimuraU/DangoMushiState.cpp index a82bf9a67..91795ddde 100644 --- a/src/plugProjectNishimuraU/DangoMushiState.cpp +++ b/src/plugProjectNishimuraU/DangoMushiState.cpp @@ -849,7 +849,7 @@ void StateMove::exec(EnemyBase* enemy) crab->finishMotion(); } else { - crab->turnToTargetNishi(target, *CG_PARMS(crab)->mGeneral.mRotationalAccel(), *CG_PARMS(crab)->mGeneral.mRotationalSpeed()); + crab->turnToTarget(target, *CG_PARMS(crab)->mGeneral.mRotationalAccel(), *CG_PARMS(crab)->mGeneral.mRotationalSpeed()); if (FABS(viewAngle) <= PI * (DEG2RAD * *CG_PARMS(crab)->mGeneral.mMinAttackRange())) { f32 moveSpeed = *CG_PARMS(crab)->mGeneral.mMoveSpeed(); f32 x = sin(crab->getFaceDir()); @@ -872,7 +872,7 @@ void StateMove::exec(EnemyBase* enemy) } else { Vector3f targetPos = crab->mTargetPosition; f32 viewAngle = crab->getCreatureViewAngle(targetPos); - crab->turnToTargetNishi(targetPos, *CG_PARMS(crab)->mGeneral.mRotationalAccel(), *CG_PARMS(crab)->mGeneral.mRotationalSpeed()); + crab->turnToTarget(targetPos, *CG_PARMS(crab)->mGeneral.mRotationalAccel(), *CG_PARMS(crab)->mGeneral.mRotationalSpeed()); if (FABS(viewAngle) <= HALF_PI) { f32 moveSpeed = *CG_PARMS(crab)->mGeneral.mMoveSpeed(); diff --git a/src/plugProjectNishimuraU/ElecBugState.cpp b/src/plugProjectNishimuraU/ElecBugState.cpp index 9fa105ce3..04f83c6ba 100644 --- a/src/plugProjectNishimuraU/ElecBugState.cpp +++ b/src/plugProjectNishimuraU/ElecBugState.cpp @@ -124,10 +124,15 @@ void StateTurn::exec(EnemyBase* enemy) { Obj* bug = static_cast(enemy); Vector3f targetPos = bug->mTargetPosition; - f32 dist - = bug->turnToTarget2(targetPos, CG_PARMS(bug)->mGeneral.mRotationalAccel.mValue, CG_PARMS(bug)->mGeneral.mRotationalSpeed.mValue); + Vector2f XZ; + XZ.x = targetPos.x; + XZ.y = targetPos.z; - if (FABS(dist) <= PI / 6.0f) { + // f32 dist = bug->changeFaceDir(targetPos); + + f32 dist = bug->turnToTarget(targetPos, *CG_PARMS(bug)->mGeneral.mRotationalAccel(), *CG_PARMS(bug)->mGeneral.mRotationalSpeed()); + f64 abs = fabs(dist); + if ((f32)(abs) <= PI / 6.0f) { bug->finishMotion(); } @@ -254,8 +259,11 @@ void StateCharge::exec(EnemyBase* enemy) } Obj* partner = bug->mPartner; if (partner) { - // Vector3f partnerPos = partner->getPosition(); - partner->turnToTargetNishi(partner, 0.15f, CG_PARMS(bug)->mGeneral.mRotationalSpeed.mValue); + Vector3f bugPos = bug->getPosition(); + Vector3f partnerPos = partner->getPosition(); + Vector3f pos = bugPos - partnerPos; + pos += bugPos; + partner->turnToTarget(pos, 0.15f, *CG_PARMS(bug)->mGeneral.mRotationalSpeed()); } if (bug->mStateTimer > 3.0f) { if (bug->mPartner) { @@ -372,7 +380,11 @@ void StateChildCharge::exec(EnemyBase* enemy) Obj* bug = static_cast(enemy); Obj* partner = bug->mPartner; if (partner) { - partner->turnToTargetNishi(partner, 0.15f, CG_PARMS(bug)->mGeneral.mRotationalSpeed.mValue); + Vector3f bugPos = bug->getPosition(); + Vector3f partnerPos = partner->getPosition(); + Vector3f pos = bugPos - partnerPos; + pos += bugPos; + partner->turnToTarget(pos, 0.15f, *CG_PARMS(bug)->mGeneral.mRotationalSpeed()); } if (bug->mStateTimer > 3.0f) { if (partner) { diff --git a/src/plugProjectNishimuraU/Frog.cpp b/src/plugProjectNishimuraU/Frog.cpp index 16bc3e7ed..df49a582b 100644 --- a/src/plugProjectNishimuraU/Frog.cpp +++ b/src/plugProjectNishimuraU/Frog.cpp @@ -1,330 +1,8 @@ -#include "types.h" -#include "nans.h" #include "Game/Entities/Frog.h" - -/* - Generated from dpostproc - - .section .ctors, "wa" # 0x80472F00 - 0x804732C0 - .4byte __sinit_Frog_cpp - - .section .data, "wa" # 0x8049E220 - 0x804EFC20 - .global lbl_804C2450 - lbl_804C2450: - .4byte 0x00000000 - .4byte 0x00000000 - .4byte 0x00000000 - .global __vt__Q23efx9TFrogPota - __vt__Q23efx9TFrogPota: - .4byte 0 - .4byte 0 - .4byte create__Q23efx5TSyncFPQ23efx3Arg - .4byte forceKill__Q23efx5TSyncFv - .4byte fade__Q23efx5TSyncFv - .4byte 0 - .4byte 0 - .4byte "@4@__dt__Q23efx9TFrogPotaFv" - .4byte "@4@execute__Q23efx5TSyncFP14JPABaseEmitter" - .4byte "@4@executeAfter__Q23efx5TSyncFP14JPABaseEmitter" - .4byte draw__18JPAEmitterCallBackFP14JPABaseEmitter - .4byte drawAfter__18JPAEmitterCallBackFP14JPABaseEmitter - .4byte execute__Q23efx5TSyncFP14JPABaseEmitter - .4byte executeAfter__Q23efx5TSyncFP14JPABaseEmitter - .4byte doExecuteEmitterOperation__Q23efx9TChasePosFP14JPABaseEmitter - .4byte doExecuteAfter__Q23efx5TSyncFP14JPABaseEmitter - .4byte startDemoDrawOff__Q23efx5TSyncFv - .4byte endDemoDrawOn__Q23efx5TSyncFv - .4byte __dt__Q23efx9TFrogPotaFv - .global __vt__Q23efx13TFrogLanddrop - __vt__Q23efx13TFrogLanddrop: - .4byte 0 - .4byte 0 - .4byte create__Q23efx8TSimple2FPQ23efx3Arg - .4byte forceKill__Q23efx8TSimple2Fv - .4byte fade__Q23efx8TSimple2Fv - .global __vt__Q23efx9TFrogDive - __vt__Q23efx9TFrogDive: - .4byte 0 - .4byte 0 - .4byte create__Q23efx8TSimple4FPQ23efx3Arg - .4byte forceKill__Q23efx8TSimple4Fv - .4byte fade__Q23efx8TSimple4Fv - .global __vt__Q34Game4Frog3Obj - __vt__Q34Game4Frog3Obj: - .4byte 0 - .4byte 0 - .4byte getPosition__Q24Game9EnemyBaseFv - .4byte checkCollision__Q24Game8CreatureFPQ24Game10CellObject - .4byte getBoundingSphere__Q24Game9EnemyBaseFRQ23Sys6Sphere - .4byte collisionUpdatable__Q24Game8CreatureFv - .4byte isPiki__Q24Game8CreatureFv - .4byte isNavi__Q24Game8CreatureFv - .4byte deferPikiCollision__Q24Game10CellObjectFv - .4byte getTypeName__Q24Game8CreatureFv - .4byte getObjType__Q24Game8CreatureFv - .4byte constructor__Q24Game9EnemyBaseFv - .4byte onInit__Q34Game4Frog3ObjFPQ24Game15CreatureInitArg - .4byte onKill__Q34Game4Frog3ObjFPQ24Game15CreatureKillArg - .4byte onInitPost__Q24Game9EnemyBaseFPQ24Game15CreatureInitArg - .4byte doAnimation__Q24Game9EnemyBaseFv - .4byte doEntry__Q24Game9EnemyBaseFv - .4byte doSetView__Q24Game9EnemyBaseFi - .4byte doViewCalc__Q24Game9EnemyBaseFv - .4byte doSimulation__Q24Game9EnemyBaseFf - .4byte doDirectDraw__Q34Game4Frog3ObjFR8Graphics - .4byte getBodyRadius__Q24Game9EnemyBaseFv - .4byte getCellRadius__Q24Game9EnemyBaseFv - .4byte "initPosition__Q24Game8CreatureFR10Vector3" - .4byte "onInitPosition__Q24Game8CreatureFR10Vector3" - .4byte getFaceDir__Q24Game9EnemyBaseFv - .4byte "setVelocity__Q24Game9EnemyBaseFR10Vector3" - .4byte getVelocity__Q24Game9EnemyBaseFv - .4byte "onSetPosition__Q24Game9EnemyBaseFR10Vector3" - .4byte "onSetPositionPost__Q24Game9EnemyBaseFR10Vector3" - .4byte updateTrMatrix__Q24Game9EnemyBaseFv - .4byte isTeki__Q24Game9EnemyBaseFv - .4byte isPellet__Q24Game8CreatureFv - .4byte inWaterCallback__Q34Game4Frog3ObjFPQ24Game8WaterBox - .4byte outWaterCallback__Q34Game4Frog3ObjFv - .4byte inWater__Q24Game9EnemyBaseFv - .4byte getFlockMgr__Q24Game8CreatureFv - .4byte onStartCapture__Q24Game8CreatureFv - .4byte onUpdateCapture__Q24Game8CreatureFR7Matrixf - .4byte onEndCapture__Q24Game8CreatureFv - .4byte isAtari__Q24Game8CreatureFv - .4byte setAtari__Q24Game8CreatureFb - .4byte isAlive__Q24Game8CreatureFv - .4byte setAlive__Q24Game8CreatureFb - .4byte isCollisionFlick__Q24Game8CreatureFv - .4byte setCollisionFlick__Q24Game8CreatureFb - .4byte isMovieActor__Q24Game8CreatureFv - .4byte isMovieExtra__Q24Game8CreatureFv - .4byte isMovieMotion__Q24Game8CreatureFv - .4byte setMovieMotion__Q24Game8CreatureFb - .4byte isBuried__Q24Game8CreatureFv - .4byte isFlying__Q24Game9EnemyBaseFv - .4byte isUnderground__Q24Game8CreatureFv - .4byte isLivingThing__Q24Game8CreatureFv - .4byte isDebugCollision__Q24Game8CreatureFv - .4byte setDebugCollision__Q24Game8CreatureFb - .4byte doSave__Q24Game8CreatureFR6Stream - .4byte doLoad__Q24Game8CreatureFR6Stream - .4byte bounceCallback__Q24Game8CreatureFPQ23Sys8Triangle - .4byte collisionCallback__Q34Game4Frog3ObjFRQ24Game9CollEvent - .4byte platCallback__Q24Game8CreatureFRQ24Game9PlatEvent - .4byte getJAIObject__Q24Game9EnemyBaseFv - .4byte getPSCreature__Q24Game9EnemyBaseFv - .4byte getSound_AILOD__Q24Game8CreatureFv - .4byte getSound_PosPtr__Q24Game9EnemyBaseFv - .4byte sound_culling__Q24Game9EnemyBaseFv - .4byte getSound_CurrAnimFrame__Q24Game9EnemyBaseFv - .4byte getSound_CurrAnimSpeed__Q24Game9EnemyBaseFv - .4byte on_movie_begin__Q24Game8CreatureFb - .4byte on_movie_end__Q24Game8CreatureFb - .4byte movieStartAnimation__Q24Game8CreatureFUl - .4byte movieStartDemoAnimation__Q24Game8CreatureFPQ28SysShape8AnimInfo - .4byte movieSetAnimationLastFrame__Q24Game8CreatureFv - .4byte "movieSetTranslation__Q24Game8CreatureFR10Vector3f" - .4byte movieSetFaceDir__Q24Game8CreatureFf - .4byte "movieGotoPosition__Q24Game8CreatureFR10Vector3" - .4byte movieUserCommand__Q24Game8CreatureFUlPQ24Game11MoviePlayer - .4byte getShadowParam__Q34Game4Frog3ObjFRQ24Game11ShadowParam - .4byte needShadow__Q24Game9EnemyBaseFv - .4byte getLifeGaugeParam__Q24Game9EnemyBaseFRQ24Game14LifeGaugeParam - .4byte getLODSphere__Q24Game9EnemyBaseFRQ23Sys6Sphere - .4byte getLODCylinder__Q24Game8CreatureFRQ23Sys8Cylinder - .4byte startPick__Q24Game8CreatureFv - .4byte endPick__Q24Game8CreatureFb - .4byte getMabiki__Q24Game8CreatureFv - .4byte getFootmarks__Q24Game8CreatureFv - .4byte onStickStart__Q24Game9EnemyBaseFPQ24Game8Creature - .4byte onStickEnd__Q24Game9EnemyBaseFPQ24Game8Creature - .4byte onStickStartSelf__Q24Game8CreatureFPQ24Game8Creature - .4byte onStickEndSelf__Q24Game8CreatureFPQ24Game8Creature - .4byte isSlotFree__Q24Game8CreatureFs - .4byte getFreeStickSlot__Q24Game8CreatureFv - .4byte "getNearFreeStickSlot__Q24Game8CreatureFR10Vector3" - .4byte getRandomFreeStickSlot__Q24Game8CreatureFv - .4byte onSlotStickStart__Q24Game8CreatureFPQ24Game8Creatures - .4byte onSlotStickEnd__Q24Game8CreatureFPQ24Game8Creatures - .4byte "calcStickSlotGlobal__Q24Game8CreatureFsR10Vector3" - .4byte "getVelocityAt__Q24Game9EnemyBaseFR10Vector3R10Vector3" - .4byte "getAngularEffect__Q24Game8CreatureFR10Vector3R10Vector3" - .4byte "applyImpulse__Q24Game8CreatureFR10Vector3R10Vector3" - .4byte ignoreAtari__Q24Game8CreatureFPQ24Game8Creature - .4byte getSuckPos__Q24Game8CreatureFv - .4byte getGoalPos__Q24Game8CreatureFv - .4byte isSuckReady__Q24Game8CreatureFv - .4byte isSuckArriveWait__Q24Game8CreatureFv - .4byte stimulate__Q24Game9EnemyBaseFRQ24Game11Interaction - .4byte getCreatureName__Q24Game9EnemyBaseFv - .4byte getCreatureID__Q24Game9EnemyBaseFv - .4byte 0 - .4byte 0 - .4byte "@376@onKeyEvent__Q24Game9EnemyBaseFRCQ28SysShape8KeyEvent" - .4byte __dt__Q34Game4Frog3ObjFv - .4byte "birth__Q24Game9EnemyBaseFR10Vector3f" - .4byte - setInitialSetting__Q34Game4Frog3ObjFPQ24Game21EnemyInitialParamBase .4byte - update__Q24Game9EnemyBaseFv .4byte doUpdate__Q34Game4Frog3ObjFv .4byte - doUpdateCommon__Q24Game9EnemyBaseFv .4byte - doUpdateCarcass__Q24Game9EnemyBaseFv .4byte - doAnimationUpdateAnimator__Q24Game9EnemyBaseFv .4byte - doAnimationCullingOff__Q24Game9EnemyBaseFv .4byte - doAnimationCullingOn__Q24Game9EnemyBaseFv .4byte - doAnimationStick__Q24Game9EnemyBaseFv .4byte - doSimulationCarcass__Q24Game9EnemyBaseFf .4byte - doDebugDraw__Q34Game4Frog3ObjFR8Graphics .4byte - doSimpleDraw__Q24Game9EnemyBaseFP8Viewport .4byte - doSimulationGround__Q24Game9EnemyBaseFf .4byte - doSimulationFlying__Q34Game4Frog3ObjFf .4byte - doSimulationStick__Q24Game9EnemyBaseFf .4byte - changeMaterial__Q24Game9EnemyBaseFv .4byte - "getCommonEffectPos__Q34Game4Frog3ObjFR10Vector3" .4byte - getFitEffectPos__Q24Game9EnemyBaseFv .4byte viewGetShape__Q24Game9EnemyBaseFv - .4byte view_start_carrymotion__Q24Game9EnemyBaseFv - .4byte view_finish_carrymotion__Q24Game9EnemyBaseFv - .4byte viewStartPreCarryMotion__Q24Game9EnemyBaseFv - .4byte viewStartCarryMotion__Q24Game9EnemyBaseFv - .4byte viewOnPelletKilled__Q24Game9EnemyBaseFv - .4byte getOffsetForMapCollision__Q34Game4Frog3ObjFv - .4byte setParameters__Q24Game9EnemyBaseFv - .4byte initMouthSlots__Q24Game9EnemyBaseFv - .4byte initWalkSmokeEffect__Q24Game9EnemyBaseFv - .4byte getWalkSmokeEffectMgr__Q24Game9EnemyBaseFv - .4byte onKeyEvent__Q24Game9EnemyBaseFRCQ28SysShape8KeyEvent - .4byte injure__Q24Game9EnemyBaseFv - .4byte setCollEvent__Q24Game9EnemyBaseFRQ24Game9CollEvent - .4byte "getEfxHamonPos__Q24Game9EnemyBaseFP10Vector3" - .4byte createInstanceEfxHamon__Q24Game9EnemyBaseFv - .4byte updateEfxHamon__Q24Game9EnemyBaseFv - .4byte createEfxHamon__Q24Game9EnemyBaseFv - .4byte fadeEfxHamon__Q24Game9EnemyBaseFv - .4byte getEnemyTypeID__Q34Game4Frog3ObjFv - .4byte getMouthSlots__Q24Game9EnemyBaseFv - .4byte doGetLifeGaugeParam__Q24Game9EnemyBaseFRQ24Game14LifeGaugeParam - .4byte throwupItem__Q24Game9EnemyBaseFv - .4byte "getThrowupItemPosition__Q24Game9EnemyBaseFP10Vector3" - .4byte "getThrowupItemVelocity__Q24Game9EnemyBaseFP10Vector3" - .4byte throwupItemInDeathProcedure__Q24Game9EnemyBaseFv - .4byte setLODSphere__Q24Game9EnemyBaseFRQ23Sys6Sphere - .4byte damageCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart - .4byte pressCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart - .4byte - flyCollisionCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart .4byte - hipdropCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart .4byte - dropCallBack__Q24Game9EnemyBaseFPQ24Game8Creature .4byte - earthquakeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - farmCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - "bombCallBack__Q24Game9EnemyBaseFPQ24Game8CreatureR10Vector3f" .4byte - eatWhitePikminCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - dopeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturei .4byte - doDopeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturei .4byte - doStartStoneState__Q34Game4Frog3ObjFv .4byte - doFinishStoneState__Q34Game4Frog3ObjFv .4byte - getDamageCoeStoneState__Q24Game9EnemyBaseFv .4byte - doStartEarthquakeState__Q24Game9EnemyBaseFf .4byte - doFinishEarthquakeState__Q24Game9EnemyBaseFv .4byte - doStartEarthquakeFitState__Q34Game4Frog3ObjFv .4byte - doFinishEarthquakeFitState__Q34Game4Frog3ObjFv .4byte - lifeRecover__Q24Game9EnemyBaseFv .4byte - startCarcassMotion__Q34Game4Frog3ObjFv .4byte - setCarcassArg__Q24Game9EnemyBaseFRQ24Game13PelletViewArg .4byte - getCarcassArgHeight__Q24Game9EnemyBaseFv .4byte - doBecomeCarcass__Q24Game9EnemyBaseFv .4byte - startWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - finishWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - isFinishableWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - doStartWaitingBirthTypeDrop__Q34Game4Frog3ObjFv .4byte - doFinishWaitingBirthTypeDrop__Q34Game4Frog3ObjFv .4byte - wallCallback__Q24Game9EnemyBaseFRCQ24Game8MoveInfo .4byte - getDownSmokeScale__Q34Game4Frog3ObjFv .4byte doStartMovie__Q34Game4Frog3ObjFv - .4byte doEndMovie__Q34Game4Frog3ObjFv - .4byte setFSM__Q34Game4Frog3ObjFPQ34Game4Frog3FSM - .4byte viewGetCollTreeOffset__Q34Game4Frog3ObjFv - .4byte attackNaviPosition__Q34Game4Frog3ObjFv - .4byte 0 - .4byte 0 - .4byte viewGetBaseScale__Q24Game10PelletViewFv - .4byte "@736@12@viewGetShape__Q24Game9EnemyBaseFv" - .4byte viewGetCollTreeJointIndex__Q24Game10PelletViewFv - .4byte "@736@12@viewGetCollTreeOffset__Q34Game4Frog3ObjFv" - .4byte "@736@12@view_start_carrymotion__Q24Game9EnemyBaseFv" - .4byte "@736@12@view_finish_carrymotion__Q24Game9EnemyBaseFv" - .4byte "@736@12@viewStartPreCarryMotion__Q24Game9EnemyBaseFv" - .4byte "@736@12@viewStartCarryMotion__Q24Game9EnemyBaseFv" - .4byte "@736@12@viewOnPelletKilled__Q24Game9EnemyBaseFv" - .4byte "viewEntryShape__Q24Game10PelletViewFR7MatrixfR10Vector3" - .4byte 0 - - .section .sbss # 0x80514D80 - 0x80516360 - .global lbl_80515D38 - lbl_80515D38: - .skip 0x4 - .global lbl_80515D3C - lbl_80515D3C: - .skip 0x4 - - .section .sdata2, "a" # 0x80516360 - 0x80520E40 - .global lbl_8051AAC8 - lbl_8051AAC8: - .4byte 0x43000000 - .global lbl_8051AACC - lbl_8051AACC: - .4byte 0x00000000 - .global lbl_8051AAD0 - lbl_8051AAD0: - .4byte 0x40000000 - .global lbl_8051AAD4 - lbl_8051AAD4: - .4byte 0x40490FDB - .global lbl_8051AAD8 - lbl_8051AAD8: - .4byte 0x3BB60B61 - .global lbl_8051AADC - lbl_8051AADC: - .4byte 0x40A00000 - .global lbl_8051AAE0 - lbl_8051AAE0: - .4byte 0x42960000 - .global lbl_8051AAE4 - lbl_8051AAE4: - .4byte 0x42480000 - .global lbl_8051AAE8 - lbl_8051AAE8: - .4byte 0x418C0000 - .global lbl_8051AAEC - lbl_8051AAEC: - .4byte 0x3F400000 - .global lbl_8051AAF0 - lbl_8051AAF0: - .4byte 0x41B40000 - .global lbl_8051AAF4 - lbl_8051AAF4: - .float 1.0 - .global lbl_8051AAF8 - lbl_8051AAF8: - .4byte 0x41A00000 - .global lbl_8051AAFC - lbl_8051AAFC: - .4byte 0xC1700000 - .global lbl_8051AB00 - lbl_8051AB00: - .4byte 0x43340000 - .global lbl_8051AB04 - lbl_8051AB04: - .float 0.5 - .global lbl_8051AB08 - lbl_8051AB08: - .4byte 0xC3A2F983 - .global lbl_8051AB0C - lbl_8051AB0C: - .4byte 0x43A2F983 - .global lbl_8051AB10 - lbl_8051AB10: - .4byte 0xC47A0000 - .4byte 0x00000000 -*/ +#include "Game/CameraMgr.h" +#include "Game/rumble.h" +#include "efx/TFrog.h" +#include "nans.h" namespace Game { namespace Frog { @@ -336,92 +14,9 @@ namespace Frog { */ Obj::Obj() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - extsh. r0, r4 - stw r31, 0xc(r1) - mr r31, r3 - stw r30, 8(r1) - beq lbl_80258588 - addi r0, r31, 0x2e0 - lis r3, __vt__Q24Game10PelletView@ha - stw r0, 0x17c(r31) - addi r3, r3, __vt__Q24Game10PelletView@l - li r0, 0 - stw r3, 0x2e0(r31) - stw r0, 0x2e4(r31) - stw r0, 0x2e8(r31) - -lbl_80258588: - mr r3, r31 - li r4, 0 - bl __ct__Q24Game9EnemyBaseFv - lis r3, __vt__Q34Game4Frog3Obj@ha - addi r0, r31, 0x2e0 - addi r5, r3, __vt__Q34Game4Frog3Obj@l - li r3, 0x2c - stw r5, 0(r31) - addi r4, r5, 0x1b0 - addi r5, r5, 0x304 - stw r4, 0x178(r31) - lwz r4, 0x17c(r31) - stw r5, 0(r4) - lwz r4, 0x17c(r31) - subf r0, r4, r0 - stw r0, 0xc(r4) - bl __nw__FUl - or. r30, r3, r3 - beq lbl_80258614 - bl __ct__Q24Game17EnemyAnimatorBaseFv - lis r3, __vt__Q34Game4Frog14ProperAnimator@ha - lis r4, __vt__Q28SysShape12BaseAnimator@ha - addi r0, r3, __vt__Q34Game4Frog14ProperAnimator@l - lis r3, __vt__Q28SysShape8Animator@ha - stw r0, 0(r30) - addi r4, r4, __vt__Q28SysShape12BaseAnimator@l - addi r3, r3, __vt__Q28SysShape8Animator@l - li r0, 0 - stw r4, 0x10(r30) - stw r3, 0x10(r30) - stb r0, 0x28(r30) - stw r0, 0x1c(r30) - stw r0, 0x14(r30) - stb r0, 0x28(r30) - stw r0, 0x20(r30) - -lbl_80258614: - stw r30, 0x184(r31) - li r3, 0x1c - bl __nw__FUl - or. r4, r3, r3 - beq lbl_80258648 - lis r5, __vt__Q24Game17EnemyStateMachine@ha - lis r3, __vt__Q34Game4Frog3FSM@ha - addi r0, r5, __vt__Q24Game17EnemyStateMachine@l - li r5, -1 - stw r0, 0(r4) - addi r0, r3, __vt__Q34Game4Frog3FSM@l - stw r5, 0x18(r4) - stw r0, 0(r4) - -lbl_80258648: - lwz r12, 0(r31) - mr r3, r31 - lwz r12, 0x2f8(r12) - mtctr r12 - bctrl - mr r3, r31 - bl createEffect__Q34Game4Frog3ObjFv - lwz r0, 0x14(r1) - mr r3, r31 - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + mAnimator = new ProperAnimator(); + setFSM(new FSM); + createEffect(); } /* @@ -445,7 +40,7 @@ void Obj::onInit(CreatureInitArg* initArg) mIsInAir = false; mIsFalling = false; setupEffect(); - mFsm->start(this, 1, nullptr); + mFsm->start(this, FROG_Wait, nullptr); } /* @@ -466,9 +61,8 @@ void Obj::onKill(CreatureKillArg* killArg) */ void Obj::doUpdate() { - EnemyBase* frog = static_cast(this); updateCaution(); - mFsm->exec(frog); + mFsm->exec(this); } /* @@ -476,7 +70,7 @@ void Obj::doUpdate() * Address: 80258784 * Size: 000280 */ -void Obj::doSimulationFlying(f32) +void Obj::doSimulationFlying(f32 p1) { /* stwu r1, -0x60(r1) @@ -685,29 +279,11 @@ void Obj::doDebugDraw(Graphics& gfx) { EnemyBase::doDebugDraw(gfx); } * Address: 80258A28 * Size: 00004C */ -void Obj::setFSM(FSM*) +void Obj::setFSM(FSM* fsm) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - stw r4, 0x2bc(r3) - mr r4, r31 - lwz r3, 0x2bc(r3) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - li r0, 0 - stw r0, 0x2b4(r31) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + mFsm = fsm; + mFsm->init(this); + mCurrentLifecycleState = nullptr; } /* @@ -1469,186 +1045,47 @@ lbl_802593D4: * Address: 802593E8 * Size: 0000B0 */ -void Obj::createEffect() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - li r3, 0x14 - bl __nw__FUl - cmplwi r3, 0 - beq lbl_80259480 - lis r4, __vt__Q23efx5TBase@ha - lis r5, __vt__18JPAEmitterCallBack@ha - addi r0, r4, __vt__Q23efx5TBase@l - lis r4, __vt__Q23efx5TSync@ha - stw r0, 0(r3) - addi r0, r5, __vt__18JPAEmitterCallBack@l - addi r5, r4, __vt__Q23efx5TSync@l - lis r4, __vt__Q23efx9TChasePos@ha - stw r0, 4(r3) - addi r7, r4, __vt__Q23efx9TChasePos@l - lis r4, __vt__Q23efx9TFrogPota@ha - addi r0, r5, 0x14 - stw r5, 0(r3) - addi r4, r4, __vt__Q23efx9TFrogPota@l - li r9, 0 - li r8, 0x2b2 - stw r0, 4(r3) - addi r6, r7, 0x14 - li r5, 0x62 - addi r0, r4, 0x14 - stw r9, 8(r3) - sth r8, 0xc(r3) - stb r9, 0xe(r3) - stw r7, 0(r3) - stw r6, 4(r3) - stw r9, 0x10(r3) - sth r5, 0xc(r3) - stw r4, 0(r3) - stw r0, 4(r3) - -lbl_80259480: - stw r3, 0x2dc(r31) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::createEffect() { mEfxPota = new efx::TFrogPota; } /* * --INFO-- * Address: 80259498 * Size: 000010 */ -void Obj::setupEffect() -{ - // mEfxPota - /* - lwz r4, 0x2dc(r3) - addi r0, r3, 0x18c - stw r0, 0x10(r4) - blr - */ -} +void Obj::setupEffect() { mEfxPota->mPosition = &mPosition; } /* * --INFO-- * Address: 802594A8 * Size: 000034 */ -void Obj::startJumpEffect() -{ - // mEfxPota->create(nullptr); - // incomplete class - /* - stwu r1, -0x10(r1) - mflr r0 - li r4, 0 - stw r0, 0x14(r1) - lwz r3, 0x2dc(r3) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::startJumpEffect() { mEfxPota->create(nullptr); } /* * --INFO-- * Address: 802594DC * Size: 000030 */ -void Obj::finishJumpEffect() -{ - // mEfxPota->fade(); - // incomplete class - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x2dc(r3) - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::finishJumpEffect() { mEfxPota->fade(); } /* * --INFO-- * Address: 8025950C * Size: 0000C0 */ -void Obj::createDownEffect(f32) +void Obj::createDownEffect(f32 scale) { - /* - stwu r1, -0x40(r1) - mflr r0 - stw r0, 0x44(r1) - stfd f31, 0x30(r1) - psq_st f31, 56(r1), 0, qr0 - stw r31, 0x2c(r1) - lwz r12, 0(r3) - fmr f31, f1 - mr r31, r3 - addi r4, r1, 0x14 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - lfs f2, 0x190(r31) - lfs f1, 0x14(r1) - lfs f0, 0x1c(r1) - stfs f1, 8(r1) - stfs f2, 0xc(r1) - stfs f0, 0x10(r1) - lwz r0, 0x280(r31) - cmplwi r0, 0 - beq lbl_80259578 - fmr f1, f31 - mr r3, r31 - addi r4, r1, 8 - bl "createSplashDownEffect__Q24Game9EnemyBaseFRC10Vector3f" - b lbl_80259588 + Sys::Sphere sphere; + getBoundingSphere(sphere); + Vector3f fxPos(sphere.mPosition.x, mPosition.y, sphere.mPosition.z); + if (mWaterBox) { + createSplashDownEffect(fxPos, scale); + } else { + createDropEffect(fxPos, scale); + } -lbl_80259578: - fmr f1, f31 - mr r3, r31 - addi r4, r1, 8 - bl "createDropEffect__Q24Game9EnemyBaseFRC10Vector3f" - -lbl_80259588: - lwz r3, cameraMgr__4Game@sda21(r13) - addi r5, r31, 0x18c - li r4, 0 - li r6, 2 - bl "startVibration__Q24Game9CameraMgrFiR10Vector3i" - lwz r3, rumbleMgr__4Game@sda21(r13) - addi r5, r31, 0x18c - li r4, 0xb - li r6, 2 - bl "startRumble__Q24Game9RumbleMgrFiR10Vector3i" - psq_l f31, 56(r1), 0, qr0 - lwz r0, 0x44(r1) - lfd f31, 0x30(r1) - lwz r31, 0x2c(r1) - mtlr r0 - addi r1, r1, 0x40 - blr - */ + cameraMgr->startVibration(0, mPosition, 2); + rumbleMgr->startRumble(11, mPosition, 2); } /* @@ -1656,48 +1093,14 @@ lbl_80259588: * Address: 802595CC * Size: 000030 */ -void Obj::effectDrawOn() -{ - // mEfxPota - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x2dc(r3) - lwz r12, 0(r3) - lwz r12, 0x44(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::effectDrawOn() { mEfxPota->endDemoDrawOn(); } /* * --INFO-- * Address: 802595FC * Size: 000030 */ -void Obj::effectDrawOff() -{ - // mEfxPota - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x2dc(r3) - lwz r12, 0(r3) - lwz r12, 0x40(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::effectDrawOff() { mEfxPota->startDemoDrawOff(); } } // namespace Frog } // namespace Game diff --git a/src/plugProjectNishimuraU/FuefukiState.cpp b/src/plugProjectNishimuraU/FuefukiState.cpp index 6a9143712..70da7544a 100644 --- a/src/plugProjectNishimuraU/FuefukiState.cpp +++ b/src/plugProjectNishimuraU/FuefukiState.cpp @@ -359,8 +359,8 @@ void StateTurn::exec(EnemyBase* enemy) Vector3f targetPos = Vector3f(fuefuki->mTargetPosition); // this is close. - f32 angleDist = fuefuki->turnToTarget2(targetPos, CG_PARMS(fuefuki)->mGeneral.mRotationalAccel.mValue, - CG_PARMS(fuefuki)->mGeneral.mRotationalSpeed.mValue); + f32 angleDist = fuefuki->turnToTarget(targetPos, *CG_PARMS(fuefuki)->mGeneral.mRotationalAccel(), + *CG_PARMS(fuefuki)->mGeneral.mRotationalSpeed()); if (FABS(angleDist) <= PI / 6) { fuefuki->mNextState = FUEFUKI_Walk; diff --git a/src/plugProjectNishimuraU/KumaKochappyState.cpp b/src/plugProjectNishimuraU/KumaKochappyState.cpp index 163e56a2e..ccfa29d60 100644 --- a/src/plugProjectNishimuraU/KumaKochappyState.cpp +++ b/src/plugProjectNishimuraU/KumaKochappyState.cpp @@ -121,8 +121,8 @@ void StateWait::exec(EnemyBase* enemy) Creature* target = kuma->getSearchedTarget(); if (target) { // more nonsense going on in here than this - f32 dist = kuma->turnToTargetNishi(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, - CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); + f32 dist = kuma->turnToTarget(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, + CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); // this isn't the comparison, probably a bool spat out from an inline if (FABS(dist) <= CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue) { @@ -475,8 +475,8 @@ void StateAttack::exec(EnemyBase* enemy) Creature* target = kuma->getSearchedTarget(); if (target) { // more nonsense going on in here than this - f32 dist = kuma->turnToTargetNishi(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, - CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); + f32 dist = kuma->turnToTarget(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, + CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); // this isn't the comparison, probably a bool spat out from an inline if (FABS(dist) <= CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue) { @@ -888,8 +888,8 @@ void StateFlick::exec(EnemyBase* enemy) Creature* target = kuma->getSearchedTarget(); if (target) { // more nonsense going on in here than this - f32 dist = kuma->turnToTargetNishi(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, - CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); + f32 dist = kuma->turnToTarget(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, + CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); // this isn't the comparison, probably a bool spat out from an inline if (FABS(dist) <= CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue) { @@ -1293,8 +1293,8 @@ void StateWalk::exec(EnemyBase* enemy) Creature* target = kuma->getSearchedTarget(); if (target) { // more nonsense going on in here than this - f32 dist = kuma->turnToTargetNishi(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, - CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); + f32 dist = kuma->turnToTarget(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, + CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); // this isn't the comparison, probably a bool spat out from an inline if (FABS(dist) <= CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue) { @@ -1749,12 +1749,10 @@ void StateWalkPath::exec(EnemyBase* enemy) Creature* target = kuma->getSearchedTarget(); if (target) { - // more nonsense going on in here than this - f32 dist = kuma->turnToTargetNishi(target, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, - CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); - - // this isn't the comparison, probably a bool spat out from an inline - if (FABS(dist) <= CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue) { + f32 minRange = *CG_PARMS(kuma)->mGeneral.mMinAttackRange(); + f32 maxRange = *CG_PARMS(kuma)->mGeneral.mMaxAttackRange(); + f32 dist = kuma->getAngDist(target); + if (kuma->checkDistAndAngle(target, dist, minRange, maxRange)) { kuma->mNextState = KUMAKOCHAPPY_Attack; kuma->finishMotion(); kuma->setAnimSpeed(60.0f); @@ -1771,8 +1769,8 @@ void StateWalkPath::exec(EnemyBase* enemy) kuma->mNextState = KUMAKOCHAPPY_Wait; kuma->finishMotion(); } else { - f32 dist = kuma->turnToTarget2(*parentPos, CG_PARMS(kuma)->mGeneral.mRotationalSpeed.mValue, - CG_PARMS(kuma)->mGeneral.mRotationalAccel.mValue); + f32 dist = kuma->turnToTarget(*parentPos, *CG_PARMS(kuma)->mGeneral.mRotationalAccel(), + *CG_PARMS(kuma)->mGeneral.mRotationalSpeed()); } } else { kuma->mNextState = KUMAKOCHAPPY_Wait; diff --git a/src/plugProjectNishimuraU/UjiaState.cpp b/src/plugProjectNishimuraU/UjiaState.cpp index b7cf5d17c..ff536219d 100644 --- a/src/plugProjectNishimuraU/UjiaState.cpp +++ b/src/plugProjectNishimuraU/UjiaState.cpp @@ -288,7 +288,7 @@ void StateMove::exec(EnemyBase* enemy) uji->mFaceDir = roundAng(turnSpeed + uji->getFaceDir()); uji->mRotation.y = uji->mFaceDir; - // uji->turnToTargetNishi(target, CG_PARMS(uji)->mGeneral.mRotationalAccel.mValue, + // uji->turnToTarget(target, CG_PARMS(uji)->mGeneral.mRotationalAccel.mValue, // CG_PARMS(uji)->mGeneral.mRotationalSpeed.mValue); uji->changeFaceDir(target); f32 speed = CG_PARMS(uji)->mGeneral.mMoveSpeed.mValue; diff --git a/src/plugProjectNishimuraU/UjibState.cpp b/src/plugProjectNishimuraU/UjibState.cpp index f63821044..863f0a0a5 100644 --- a/src/plugProjectNishimuraU/UjibState.cpp +++ b/src/plugProjectNishimuraU/UjibState.cpp @@ -281,7 +281,7 @@ void StateMove::exec(EnemyBase* enemy) uji->mFaceDir = roundAng(turnSpeed + uji->getFaceDir()); uji->mRotation.y = uji->mFaceDir; - // uji->turnToTargetNishi(target, CG_PARMS(uji)->mGeneral.mRotationalAccel.mValue, CG_PARMS(uji)->mGeneral.mRotationalSpeed.mValue); + // uji->turnToTarget(target, CG_PARMS(uji)->mGeneral.mRotationalAccel.mValue, CG_PARMS(uji)->mGeneral.mRotationalSpeed.mValue); // uji->changeFaceDir(target); f32 speed = CG_PARMS(uji)->mGeneral.mMoveSpeed.mValue;