diff --git a/include/Game/Entities/SnakeCrow.h b/include/Game/Entities/SnakeCrow.h index 37530fba7..44ad2e78b 100644 --- a/include/Game/Entities/SnakeCrow.h +++ b/include/Game/Entities/SnakeCrow.h @@ -141,8 +141,8 @@ struct Obj : public EnemyBase { // _00-_2BC = EnemyBase FSM* mFsm; // _2BC bool mIsUnderground; // _2C0 - u8 _2C1; // _2C1, BGM related - u8 _2C2; // _2C2, BGM related + bool mIsFirstAttackBGM; // _2C1, controls whether first or repeated appearance fanfare plays + bool mIsAppearBGMEnabled; // _2C2, play appear BGM on next getup f32 mStateTimer; // _2C4 StateID mNextState; // _2C8, unused MouthSlots mMouthSlots; // _2CC diff --git a/include/Game/Entities/SnakeWhole.h b/include/Game/Entities/SnakeWhole.h index 6bbecc948..3e135ed25 100644 --- a/include/Game/Entities/SnakeWhole.h +++ b/include/Game/Entities/SnakeWhole.h @@ -62,9 +62,9 @@ struct Obj : public EnemyBase { //////////////// VTABLE virtual void onInit(CreatureInitArg* settings); // _30 virtual void doDirectDraw(Graphics& gfx); // _50 - virtual void inWaterCallback(WaterBox* wb); // _84 (weak) - virtual void outWaterCallback(); // _88 (weak) - virtual bool isUnderground(); // _D0 (weak) + virtual void inWaterCallback(WaterBox* wb) { } // _84 (weak) + virtual void outWaterCallback() { } // _88 (weak) + virtual bool isUnderground() { return mIsUnderground; } // _D0 (weak) virtual void getShadowParam(ShadowParam& settings); // _134 virtual ~Obj() { } // _1BC (weak) virtual void setInitialSetting(EnemyInitialParamBase* params); // _1C4 @@ -77,19 +77,22 @@ struct Obj : public EnemyBase { virtual void setParameters(); // _228 virtual void initMouthSlots(); // _22C virtual void createEfxHamon(); // _250 - virtual EnemyTypeID::EEnemyTypeID getEnemyTypeID(); // _258 (weak) - virtual MouthSlots* getMouthSlots(); // _25C (weak) virtual void getThrowupItemPosition(Vector3f* itemPos); // _268 - virtual void throwupItemInDeathProcedure(); // _270 (weak) virtual bool damageCallBack(Creature* source, f32 damage, CollPart* part); // _278 virtual void doStartStoneState(); // _2A4 virtual void doFinishStoneState(); // _2A8 - virtual f32 getDamageCoeStoneState(); // _2AC (weak) virtual void startCarcassMotion(); // _2C4 - virtual f32 getDownSmokeScale(); // _2EC (weak) virtual void doStartMovie(); // _2F0 virtual void doEndMovie(); // _2F4 virtual void setFSM(FSM* fsm); // _2F8 + virtual f32 getDamageCoeStoneState() { return 0.25f; } // _2AC (weak) + virtual MouthSlots* getMouthSlots() { return &mMouthSlots; } // _25C (weak) + virtual void throwupItemInDeathProcedure() { } // _270 (weak) + virtual f32 getDownSmokeScale() { return 0.9f; } // _2EC (weak) + virtual EnemyTypeID::EEnemyTypeID getEnemyTypeID() // _258 (weak) + { + return EnemyTypeID::EnemyID_SnakeWhole; + } //////////////// VTABLE END bool isOutTerritory(); @@ -138,16 +141,16 @@ struct Obj : public EnemyBase { // _00-_2BC = EnemyBase FSM* mFsm; // _2BC bool mIsUnderground; // _2C0 - bool _2C1; // _2C1, isOnGround? hasLanded? - u8 _2C2; // _2C2 - u8 _2C3; // _2C3 + bool mIsJumping; // _2C1 + bool mIsFirstAttackBGM; // _2C2, controls whether first or repeated appearance fanfare plays + bool mIsAppearBGMEnabled; // _2C3, play appear BGM on next getup f32 mStateTimer; // _2C4 - f32 _2C8; // _2C8 + f32 mFaceDirOffset; // _2C8, adjusts face dir while jumping StateID mNextState; // _2CC MouthSlots mMouthSlots; // _2D0 - Vector3f _2D8; // _2D8 + Vector3f mFitEffectPos; // _2D8 int mAttackAnimIdx; // _2E4 - Vector3f mAttackPositions[5]; // _2E8 + Vector3f mAttackPositions[5]; // _2E8, indexed by mAttackAnimIdx SnakeJointMgr* mSnakeJointMgr; // _324 SnakeWholeShadowMgr* mShadowMgr; // _328 efx::TCphebiDead* mEfxDead; // _32C diff --git a/include/efx/TCphebi.h b/include/efx/TCphebi.h index ad85bd37a..fe89da453 100644 --- a/include/efx/TCphebi.h +++ b/include/efx/TCphebi.h @@ -6,11 +6,21 @@ namespace efx { struct TCphebiDead : public TChaseMtx4 { + inline TCphebiDead() + : TChaseMtx4(nullptr, PID_CphebiDead_1, PID_CphebiDead_2, PID_CphebiDead_3, PID_CphebiDead_4) + { + } + // _00 = VTBL // _00-_54 = TChaseMtx4 }; struct TCphebiDeadHane : public TSimple1 { + inline TCphebiDeadHane() + : TSimple1(PID_CphebiDeadHane) + { + } + // _00 = VTBL // _00-_0C = TSimple1 }; diff --git a/src/plugProjectNishimuraU/SnakeCrow.cpp b/src/plugProjectNishimuraU/SnakeCrow.cpp index 26497f558..73f531c6c 100644 --- a/src/plugProjectNishimuraU/SnakeCrow.cpp +++ b/src/plugProjectNishimuraU/SnakeCrow.cpp @@ -40,8 +40,8 @@ Obj::Obj() void Obj::constructor() { EnemyBase::constructor(); - _2C1 = 1; - _2C2 = 0; + mIsFirstAttackBGM = true; + mIsAppearBGMEnabled = false; resetBossAppearBGM(); } @@ -72,8 +72,8 @@ void Obj::onInit(CreatureInitArg* initArg) setupCollision(); setupShadowSystem(); setupEffect(); - _2C1 = 1; - _2C2 = 0; + mIsFirstAttackBGM = true; + mIsAppearBGMEnabled = false; resetBossAppearBGM(); mFsm->start(this, SNAKECROW_Stay, nullptr); doAnimationCullingOff(); @@ -1520,8 +1520,8 @@ void Obj::deleteJointShadow() */ void Obj::startBossAttackBGM() { - if (_2C1) { - _2C1 = 0; + if (mIsFirstAttackBGM) { + mIsFirstAttackBGM = false; // don't play normal boss attack BGM on first getup } else { PSM::EnemyBoss* soundObj = static_cast(mSoundObj); PSM::checkBoss(soundObj); @@ -1564,8 +1564,8 @@ void Obj::updateBossBGM() */ void Obj::resetBossAppearBGM() { - if (!_2C2) { - _2C2 = 1; + if (!mIsAppearBGMEnabled) { + mIsAppearBGMEnabled = true; PSM::EnemyBoss* soundObj = static_cast(mSoundObj); PSM::checkBoss(soundObj); soundObj->setAppearFlag(false); @@ -1579,8 +1579,8 @@ void Obj::resetBossAppearBGM() */ void Obj::setBossAppearBGM() { - if (_2C2) { - _2C2 = 0; + if (mIsAppearBGMEnabled) { + mIsAppearBGMEnabled = false; PSM::EnemyBoss* soundObj = static_cast(mSoundObj); PSM::checkBoss(soundObj); soundObj->setAppearFlag(true); diff --git a/src/plugProjectNishimuraU/SnakeWhole.cpp b/src/plugProjectNishimuraU/SnakeWhole.cpp index b22967664..75f8670a7 100644 --- a/src/plugProjectNishimuraU/SnakeWhole.cpp +++ b/src/plugProjectNishimuraU/SnakeWhole.cpp @@ -7,6 +7,7 @@ #include "Game/SingleGameSection.h" #include "Game/CameraMgr.h" #include "Game/rumble.h" +#include "efx/THebi.h" #include "PSM/EnemyBoss.h" #include "PSSystem/PSMainSide_ObjSound.h" #include "Dolphin/rand.h" @@ -47,17 +48,17 @@ void Obj::onInit(CreatureInitArg* initArg) EnemyBase::onInit(initArg); shadowMgr->delNormalShadow(this); mIsUnderground = true; - _2C1 = 0; + mIsJumping = false; mStateTimer = 0.0f; mNextState = SNAKEWHOLE_NULL; mAttackAnimIdx = -1; - _2C8 = 0.0f; + mFaceDirOffset = 0.0f; setupJointCallBack(); setupCollision(); setupShadowSystem(); setupEffect(); - _2C2 = 1; - _2C3 = 0; + mIsFirstAttackBGM = true; + mIsAppearBGMEnabled = false; resetBossAppearBGM(); mFsm->start(this, SNAKEWHOLE_Stay, nullptr); doAnimationCullingOff(); @@ -294,209 +295,36 @@ bool Obj::isInHomeRange() * Address: 802CEEDC * Size: 0002AC */ -void Obj::setJumpMove(Vector3f&) +void Obj::setJumpMove(Vector3f& targetPos) { - /* - stwu r1, -0x50(r1) - mflr r0 - stw r0, 0x54(r1) - stfd f31, 0x40(r1) - psq_st f31, 72(r1), 0, qr0 - stw r31, 0x3c(r1) - stw r30, 0x38(r1) - mr r30, r3 - mr r31, r4 - mr r4, r30 - addi r3, r1, 0x14 - lwz r12, 0(r30) - lwz r12, 8(r12) - mtctr r12 - bctrl - lfs f5, 0x14(r1) - lis r3, atanTable___5JMath@ha - lfs f3, 0x1c(r1) - addi r3, r3, atanTable___5JMath@l - lfs f1, 0(r31) - lfs f0, 8(r31) - lfs f4, 0x18(r1) - fsubs f1, f1, f5 - fsubs f2, f0, f3 - stfs f5, 8(r1) - stfs f4, 0xc(r1) - stfs f3, 0x10(r1) - bl "atan2___Q25JMath18TAtanTable<1024,f>CFff" - bl roundAng__Ff - lwz r12, 0(r30) - fmr f31, f1 - mr r3, r30 - lwz r12, 0x64(r12) - mtctr r12 - bctrl - fmr f2, f1 - fmr f1, f31 - bl angDist__Fff - lfs f0, lbl_8051C868@sda21(r2) - fcmpo cr0, f1, f0 - ble lbl_802CEF88 - fmr f0, f1 - b lbl_802CEF8C - -lbl_802CEF88: - fneg f0, f1 - -lbl_802CEF8C: - lfs f4, lbl_8051C890@sda21(r2) - fcmpo cr0, f0, f4 - ble lbl_802CEFF0 - lfs f0, lbl_8051C868@sda21(r2) - fcmpu cr0, f0, f1 - bne lbl_802CEFAC - li r0, 0 - b lbl_802CEFC0 + f32 angleDist = getAngDist2(targetPos); + if (absVal(angleDist) > HALF_PI) { + int turnDir = (angleDist == 0.0f) ? 0 : (angleDist > 0.0f) ? 1 : -1; -lbl_802CEFAC: - fcmpo cr0, f1, f0 - ble lbl_802CEFBC - li r0, 1 - b lbl_802CEFC0 + mFaceDirOffset = (HALF_PI * (f32)turnDir) / 22.0f; + } else { + mFaceDirOffset = angleDist / 22.0f; + } -lbl_802CEFBC: - li r0, -1 + if (FABS(angleDist) <= TORADIANS(30.0f)) { + Vector3f velocity = Vector3f(targetPos.x - mPosition.x, 0.0f, targetPos.z - mPosition.z); + f32 dist = velocity.normalise(); + f32 moveSpeed = C_PARMS->mGeneral.mMoveSpeed.mValue; -lbl_802CEFC0: - xoris r3, r0, 0x8000 - lis r0, 0x4330 - stw r3, 0x34(r1) - lfd f3, lbl_8051C8A0@sda21(r2) - stw r0, 0x30(r1) - lfs f0, lbl_8051C894@sda21(r2) - lfd f2, 0x30(r1) - fsubs f2, f2, f3 - fmuls f2, f4, f2 - fdivs f0, f2, f0 - stfs f0, 0x2c8(r30) - b lbl_802CEFFC - -lbl_802CEFF0: - lfs f0, lbl_8051C894@sda21(r2) - fdivs f0, f1, f0 - stfs f0, 0x2c8(r30) - -lbl_802CEFFC: - fabs f1, f1 - lfs f0, lbl_8051C898@sda21(r2) - frsp f1, f1 - fcmpo cr0, f1, f0 - cror 2, 0, 2 - bne lbl_802CF130 - lfs f2, 0(r31) - lfs f0, 0x18c(r30) - lfs f1, lbl_8051C868@sda21(r2) - fsubs f2, f2, f0 - lfs f3, 8(r31) - lfs f0, 0x194(r30) - fmuls f4, f1, f1 - fsubs f3, f3, f0 - stfs f2, 0x20(r1) - fmuls f0, f2, f2 - stfs f1, 0x24(r1) - fmuls f5, f3, f3 - fadds f0, f0, f4 - stfs f3, 0x28(r1) - fadds f0, f5, f0 - fcmpo cr0, f0, f1 - ble lbl_802CF074 - fmadds f0, f2, f2, f4 - fadds f4, f5, f0 - fcmpo cr0, f4, f1 - ble lbl_802CF078 - frsqrte f0, f4 - fmuls f4, f0, f4 - b lbl_802CF078 - -lbl_802CF074: - fmr f4, f1 - -lbl_802CF078: - lfs f0, lbl_8051C868@sda21(r2) - fcmpo cr0, f4, f0 - ble lbl_802CF0B4 - lfs f0, lbl_8051C870@sda21(r2) - lfs f2, 0x20(r1) - fdivs f3, f0, f4 - lfs f1, 0x24(r1) - lfs f0, 0x28(r1) - fmuls f2, f2, f3 - fmuls f1, f1, f3 - fmuls f0, f0, f3 - stfs f2, 0x20(r1) - stfs f1, 0x24(r1) - stfs f0, 0x28(r1) - b lbl_802CF0B8 + f32 speed = dist; + if (dist > moveSpeed) { + speed = moveSpeed; + } -lbl_802CF0B4: - fmr f4, f0 + velocity *= (speed * (11.0f / 15.0f)); -lbl_802CF0B8: - lwz r3, 0xc0(r30) - fmr f1, f4 - lfs f0, 0x2e4(r3) - fcmpo cr0, f4, f0 - ble lbl_802CF0D0 - fmr f1, f0 + setVelocity(velocity); + mTargetVelocity = velocity; -lbl_802CF0D0: - lfs f0, lbl_8051C89C@sda21(r2) - mr r3, r30 - lfs f2, 0x20(r1) - addi r4, r1, 0x20 - fmuls f3, f0, f1 - lfs f1, 0x24(r1) - lfs f0, 0x28(r1) - fmuls f2, f2, f3 - fmuls f1, f1, f3 - fmuls f0, f0, f3 - stfs f2, 0x20(r1) - stfs f1, 0x24(r1) - stfs f0, 0x28(r1) - lwz r12, 0(r30) - lwz r12, 0x68(r12) - mtctr r12 - bctrl - lfs f0, 0x20(r1) - stfs f0, 0x1d4(r30) - lfs f0, 0x24(r1) - stfs f0, 0x1d8(r30) - lfs f0, 0x28(r1) - stfs f0, 0x1dc(r30) - b lbl_802CF168 - -lbl_802CF130: - lwz r12, 0(r30) - lis r4, "zero__10Vector3"@ha - mr r3, r30 - lwz r12, 0x68(r12) - addi r4, r4, "zero__10Vector3"@l - mtctr r12 - bctrl - lis r3, "zero__10Vector3"@ha - lfsu f0, "zero__10Vector3"@l(r3) - stfs f0, 0x1d4(r30) - lfs f0, 4(r3) - stfs f0, 0x1d8(r30) - lfs f0, 8(r3) - stfs f0, 0x1dc(r30) - -lbl_802CF168: - psq_l f31, 72(r1), 0, qr0 - lwz r0, 0x54(r1) - lfd f31, 0x40(r1) - lwz r31, 0x3c(r1) - lwz r30, 0x38(r1) - mtlr r0 - addi r1, r1, 0x50 - blr - */ + } else { + setVelocity(Vector3f::zero); + mTargetVelocity = Vector3f::zero; + } } /* @@ -506,42 +334,15 @@ void Obj::setJumpMove(Vector3f&) */ void Obj::updateFace() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lwz r12, 0(r3) - lwz r12, 0x64(r12) - mtctr r12 - bctrl - lfs f2, 0x2c8(r31) - lfs f0, lbl_8051C868@sda21(r2) - fadds f1, f1, f2 - fcmpo cr0, f1, f0 - bge lbl_802CF1CC - lfs f0, lbl_8051C8A8@sda21(r2) - fadds f1, f0, f1 - b lbl_802CF1E0 + f32 faceAngle = getFaceDir(); + faceAngle += mFaceDirOffset; + if (faceAngle < 0.0f) { + faceAngle = TAU + faceAngle; + } else if (faceAngle >= TAU) { + faceAngle -= TAU; + } -lbl_802CF1CC: - lfs f0, lbl_8051C8A8@sda21(r2) - fcmpo cr0, f1, f0 - cror 2, 1, 2 - bne lbl_802CF1E0 - fsubs f1, f1, f0 - -lbl_802CF1E0: - stfs f1, 0x1fc(r31) - lfs f0, 0x1fc(r31) - stfs f0, 0x1a8(r31) - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + updateFaceDir(faceAngle); } /* @@ -551,46 +352,17 @@ void Obj::updateFace() */ void Obj::updateConstraint() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 5 - blt lbl_802CF264 - lbz r0, 0x2c1(r31) - cmplwi r0, 0 - bne lbl_802CF264 - lwz r0, 0xc8(r31) - cmplwi r0, 0 - beq lbl_802CF264 - lfs f1, 0xd0(r31) - lfs f0, lbl_8051C8AC@sda21(r2) - fcmpo cr0, f1, f0 - ble lbl_802CF258 - lwz r0, 0x1e0(r31) - ori r0, r0, 0x400 - stw r0, 0x1e0(r31) - b lbl_802CF26C - -lbl_802CF258: - mr r3, r31 - bl constraintOff__Q24Game9EnemyBaseFv - b lbl_802CF26C - -lbl_802CF264: - mr r3, r31 - bl constraintOff__Q24Game9EnemyBaseFv - -lbl_802CF26C: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (getStateID() >= SNAKEWHOLE_Wait && !mIsJumping && mBounceTriangle) { + // i.e. snagret is fully above ground + is ON ground + if (mCollisionPosition.y > 0.5f) { + enableEvent(0, EB_Constrained); + } else { + constraintOff(); + } + return; + } + + constraintOff(); } /* @@ -969,6 +741,21 @@ void Obj::appearNearByTarget(Creature* target) */ void Obj::setAttackPosition() { + f32 angle = mFaceDir; + Vector3f dir = Vector3f(pikmin2_sinf(angle), 0.0f, pikmin2_cosf(angle)); + Vector3f orthoDir = Vector3f(-dir.z, 0.0f, dir.x); + + f32 array1[5] = { 40.0f, 120.0f, 190.0f, 90.0f, 90.0f }; + f32 array2[5] = { 0.0f, 0.0f, 0.0f, 80.0f, -80.0f }; + + for (int i = 0; i < 5; i++) { + f32 dirFactor = array1[i]; + f32 orthoDirFactor = array2[i]; + mAttackPositions[i] = mPosition; + mAttackPositions[i] += dir * dirFactor; + mAttackPositions[i] += orthoDir * orthoDirFactor; + mAttackPositions[i].y = mapMgr->getMinY(mAttackPositions[i]); + } /* stwu r1, -0x90(r1) mflr r0 @@ -1956,33 +1743,9 @@ Navi* Obj::getAttackNavi(int) */ Creature* Obj::getSearchedTarget() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, 0x1f4(r3) - cmpwi r0, 0 - beq lbl_802D0598 - lfs f1, lbl_8051C8CC@sda21(r2) - b lbl_802D05A0 - -lbl_802D0598: - lwz r4, 0xc0(r3) - lfs f1, 0x424(r4) + f32 searchAngle = (mStuckPikminCount != 0) ? 180.0f : C_PARMS->mGeneral.mViewAngle.mValue; -lbl_802D05A0: - lwz r7, 0xc0(r3) - li r4, 0 - li r5, 0 - li r6, 0 - lfs f2, 0x3d4(r7) - bl -"getNearestPikminOrNavi__Q24Game9EnemyFuncFPQ24Game8CreatureffPfP23ConditionP23Condition" - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + return EnemyFunc::getNearestPikminOrNavi(this, searchAngle, C_PARMS->mGeneral.mSightRadius.mValue, nullptr, nullptr, nullptr); } /* @@ -1992,42 +1755,15 @@ Creature* Obj::getSearchedTarget() */ CollPart* Obj::getSwallowSlot() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - li r31, 0 - stw r30, 8(r1) - mr r30, r3 - b lbl_802D0608 - -lbl_802D05E8: - mr r4, r31 - addi r3, r30, 0x2d0 - bl getSlot__10MouthSlotsFi - lwz r0, 0x64(r3) - cmplwi r0, 0 - bne lbl_802D0604 - b lbl_802D0618 - -lbl_802D0604: - addi r31, r31, 1 - -lbl_802D0608: - lwz r0, 0x2d0(r30) - cmpw r31, r0 - blt lbl_802D05E8 - li r3, 0 + for (int i = 0; i < mMouthSlots.getMax(); i++) { + MouthCollPart* slot = mMouthSlots.getSlot(i); + if (slot->mStuckCreature) { + continue; + } + return slot; + } -lbl_802D0618: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + return nullptr; } /* @@ -2037,43 +1773,15 @@ CollPart* Obj::getSwallowSlot() */ bool Obj::isSwallowPikmin() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - li r31, 0 - stw r30, 8(r1) - mr r30, r3 - b lbl_802D0674 - -lbl_802D0650: - mr r4, r31 - addi r3, r30, 0x2d0 - bl getSlot__10MouthSlotsFi - lwz r0, 0x64(r3) - cmplwi r0, 0 - beq lbl_802D0670 - li r3, 1 - b lbl_802D0684 - -lbl_802D0670: - addi r31, r31, 1 - -lbl_802D0674: - lwz r0, 0x2d0(r30) - cmpw r31, r0 - blt lbl_802D0650 - li r3, 0 + for (int i = 0; i < mMouthSlots.getMax(); i++) { + MouthCollPart* slot = mMouthSlots.getSlot(i); + if (!slot->mStuckCreature) { + continue; + } + return true; + } -lbl_802D0684: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + return false; } /* @@ -2083,173 +1791,18 @@ bool Obj::isSwallowPikmin() */ int Obj::getStickHeadPikmin() { - /* - stwu r1, -0x40(r1) - mflr r0 - mr r4, r3 - stw r0, 0x44(r1) - addi r3, r1, 0x18 - stw r31, 0x3c(r1) - li r31, 0 - stw r30, 0x38(r1) - bl __ct__Q24Game8StickersFPQ24Game8Creature - li r0, 0 - lis r3, "__vt__26Iterator"@ha - addi r4, r3, "__vt__26Iterator"@l - addi r3, r1, 0x18 - cmplwi r0, 0 - stw r4, 8(r1) - stw r0, 0x14(r1) - stw r0, 0xc(r1) - stw r3, 0x10(r1) - bne lbl_802D0700 - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - stw r3, 0xc(r1) - b lbl_802D08A0 - -lbl_802D0700: - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - stw r3, 0xc(r1) - b lbl_802D076C - -lbl_802D0718: - lwz r3, 0x10(r1) - lwz r4, 0xc(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x14(r1) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_802D08A0 - lwz r3, 0x10(r1) - lwz r4, 0xc(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0xc(r1) - -lbl_802D076C: - lwz r12, 8(r1) - addi r3, r1, 8 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_802D0718 - b lbl_802D08A0 - -lbl_802D078C: - lwz r3, 0x10(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - mr r30, r3 - lwz r12, 0xa8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_802D07E4 - lwz r3, 0xf8(r30) - cmplwi r3, 0 - beq lbl_802D07E4 - lis r4, 0x68656164@ha - addi r3, r3, 0x30 - addi r4, r4, 0x68656164@l - bl __eq__4ID32FUl - clrlwi. r0, r3, 0x18 - beq lbl_802D07E4 - addi r31, r31, 1 - -lbl_802D07E4: - lwz r0, 0x14(r1) - cmplwi r0, 0 - bne lbl_802D0810 - lwz r3, 0x10(r1) - lwz r4, 0xc(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0xc(r1) - b lbl_802D08A0 - -lbl_802D0810: - lwz r3, 0x10(r1) - lwz r4, 0xc(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0xc(r1) - b lbl_802D0884 - -lbl_802D0830: - lwz r3, 0x10(r1) - lwz r4, 0xc(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x14(r1) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_802D08A0 - lwz r3, 0x10(r1) - lwz r4, 0xc(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0xc(r1) - -lbl_802D0884: - lwz r12, 8(r1) - addi r3, r1, 8 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_802D0830 + int stickCount = 0; + Stickers stickers(this); + Iterator iter(&stickers); + CI_LOOP(iter) + { + Creature* piki = *iter; + if (piki->isAlive() && piki->mStuckCollPart && piki->mStuckCollPart->mCurrentID == 'head') { + stickCount++; + } + } -lbl_802D08A0: - lwz r3, 0x10(r1) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - lwz r4, 0xc(r1) - cmplw r4, r3 - bne lbl_802D078C - addi r3, r1, 0x18 - li r4, -1 - bl __dt__Q24Game8StickersFv - lwz r0, 0x44(r1) - mr r3, r31 - lwz r31, 0x3c(r1) - lwz r30, 0x38(r1) - mtlr r0 - addi r1, r1, 0x40 - blr - */ + return stickCount; } /* @@ -2257,91 +1810,28 @@ int Obj::getStickHeadPikmin() * Address: 802D08E8 * Size: 000048 */ -void Obj::createJointCallBack() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - li r3, 0x30 - bl __nw__FUl - or. r0, r3, r3 - beq lbl_802D0918 - mr r4, r31 - bl __ct__Q24Game13SnakeJointMgrFPQ24Game9EnemyBase - mr r0, r3 - -lbl_802D0918: - stw r0, 0x324(r31) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::createJointCallBack() { mSnakeJointMgr = new SnakeJointMgr(this); } /* * --INFO-- * Address: 802D0930 * Size: 000024 */ -void Obj::setupJointCallBack() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x324(r3) - bl setupCallBackJoint__Q24Game13SnakeJointMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::setupJointCallBack() { mSnakeJointMgr->setupCallBackJoint(); } /* * --INFO-- * Address: 802D0954 * Size: 000024 */ -void Obj::doAnimationJointCallBack() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x324(r3) - bl doAnimation__Q24Game13SnakeJointMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::doAnimationJointCallBack() { mSnakeJointMgr->doAnimation(); } /* * --INFO-- * Address: 802D0978 * Size: 000024 */ -void Obj::finishAnimationJointCallBack() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x324(r3) - bl finishAnimation__Q24Game13SnakeJointMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::finishAnimationJointCallBack() { mSnakeJointMgr->finishAnimation(); } /* * --INFO-- @@ -2350,54 +1840,10 @@ void Obj::finishAnimationJointCallBack() */ void Obj::startJointCallBack() { - /* - stwu r1, -0x30(r1) - mflr r0 - stw r0, 0x34(r1) - stfd f31, 0x20(r1) - psq_st f31, 40(r1), 0, qr0 - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r3 - lwz r0, 0x2e4(r3) - lwz r3, 0x184(r3) - mulli r0, r0, 0xc - lfs f0, 0x190(r30) - lwz r12, 0(r3) - add r4, r30, r0 - lwz r12, 0x10(r12) - lfs f1, 0x2ec(r4) - fsubs f31, f1, f0 - mtctr r12 - bctrl - lwz r3, 0xc(r3) - li r4, 3 - bl getAnimKeyByType__Q28SysShape8AnimInfoFUl - mr r31, r3 - mr r3, r30 - bl getMotionFrame__Q24Game9EnemyBaseFv - lwz r3, 0x18(r31) - lis r0, 0x4330 - fmr f3, f1 - stw r0, 8(r1) - xoris r0, r3, 0x8000 - lfd f2, lbl_8051C8A0@sda21(r2) - stw r0, 0xc(r1) - fmr f1, f31 - lfd f0, 8(r1) - lwz r3, 0x324(r30) - fsubs f0, f0, f2 - fsubs f2, f0, f3 - bl startModify__Q24Game13SnakeJointMgrFff - psq_l f31, 40(r1), 0, qr0 - lwz r0, 0x34(r1) - lfd f31, 0x20(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - mtlr r0 - addi r1, r1, 0x30 - blr - */ + f32 y = mAttackPositions[mAttackAnimIdx].y - mPosition.y; + SysShape::KeyEvent* event = mAnimator->getAnimator().mAnimInfo->getAnimKeyByType(3); + f32 frame = getMotionFrame(); + mSnakeJointMgr->startModify(y, (f32)event->mFrame - frame); } /* @@ -2407,42 +1853,9 @@ void Obj::startJointCallBack() */ void Obj::returnJointCallBack() { - /* - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r3 - lwz r3, 0x184(r3) - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - lwz r3, 0xc(r3) - li r4, 4 - bl getAnimKeyByType__Q28SysShape8AnimInfoFUl - mr r31, r3 - mr r3, r30 - bl getMotionFrame__Q24Game9EnemyBaseFv - lwz r3, 0x18(r31) - lis r0, 0x4330 - stw r0, 8(r1) - xoris r0, r3, 0x8000 - lfd f2, lbl_8051C8A0@sda21(r2) - stw r0, 0xc(r1) - lwz r3, 0x324(r30) - lfd f0, 8(r1) - fsubs f0, f0, f2 - fsubs f1, f0, f1 - bl returnModify__Q24Game13SnakeJointMgrFf - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + SysShape::KeyEvent* event = mAnimator->getAnimator().mAnimInfo->getAnimKeyByType(4); + f32 frame = getMotionFrame(); + mSnakeJointMgr->returnModify((f32)event->mFrame - frame); } /* @@ -2450,20 +1863,7 @@ void Obj::returnJointCallBack() * Address: 802D0ADC * Size: 000024 */ -void Obj::finishJointCallBack() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x324(r3) - bl finishModify__Q24Game13SnakeJointMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::finishJointCallBack() { mSnakeJointMgr->finishModify(); } /* * --INFO-- @@ -2472,24 +1872,10 @@ void Obj::finishJointCallBack() */ void Obj::setupCollision() { - /* - stwu r1, -0x10(r1) - mflr r0 - lis r4, 0x626F6431@ha - stw r0, 0x14(r1) - addi r4, r4, 0x626F6431@l - lwz r3, 0x114(r3) - bl getCollPart__8CollTreeFUl - cmplwi r3, 0 - beq lbl_802D0B28 - bl makeTubeTree__8CollPartFv - -lbl_802D0B28: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + CollPart* part = mCollTree->getCollPart('bod1'); + if (part) { + part->makeTubeTree(); + } } /* @@ -2499,24 +1885,13 @@ void Obj::setupCollision() */ void Obj::lifeIncrement() { - /* - lfs f1, lbl_8051C868@sda21(r2) - lfs f0, lbl_8051C884@sda21(r2) - stfs f1, 0x208(r3) - lwz r0, 0x1e0(r3) - rlwinm r0, r0, 0, 0x1f, 0x1d - stw r0, 0x1e0(r3) - lfs f1, 0x200(r3) - fadds f0, f1, f0 - stfs f0, 0x200(r3) - lwz r4, 0xc0(r3) - lfs f1, 0x200(r3) - lfs f0, 0x104(r4) - fcmpo cr0, f1, f0 - blelr - stfs f0, 0x200(r3) - blr - */ + mInstantDamage = 0.0f; + disableEvent(0, EB_TakingDamage); + mHealth += 10.0f; + + if (mHealth > *C_PARMS->mGeneral.mHealth()) { + mHealth = *C_PARMS->mGeneral.mHealth(); + } } /* @@ -2524,111 +1899,35 @@ void Obj::lifeIncrement() * Address: 802D0B78 * Size: 000048 */ -void Obj::createShadowSystem() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - li r3, 0x74 - bl __nw__FUl - or. r0, r3, r3 - beq lbl_802D0BA8 - mr r4, r31 - bl __ct__Q34Game10SnakeWhole19SnakeWholeShadowMgrFPQ34Game10SnakeWhole3Obj - mr r0, r3 - -lbl_802D0BA8: - stw r0, 0x328(r31) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::createShadowSystem() { mShadowMgr = new SnakeWholeShadowMgr(this); } /* * --INFO-- * Address: 802D0BC0 * Size: 000024 */ -void Obj::setupShadowSystem() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x328(r3) - bl init__Q34Game10SnakeWhole19SnakeWholeShadowMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::setupShadowSystem() { mShadowMgr->init(); } /* * --INFO-- * Address: 802D0BE4 * Size: 000024 */ -void Obj::doAnimationShadowSystem() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x328(r3) - bl update__Q34Game10SnakeWhole19SnakeWholeShadowMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::doAnimationShadowSystem() { mShadowMgr->update(); } /* * --INFO-- * Address: 802D0C08 * Size: 000024 */ -void Obj::startJointShadow() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x328(r3) - bl startJointShadow__Q34Game10SnakeWhole19SnakeWholeShadowMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::startJointShadow() { mShadowMgr->startJointShadow(); } /* * --INFO-- * Address: 802D0C2C * Size: 000024 */ -void Obj::finishJointShadow() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x328(r3) - bl finishJointShadow__Q34Game10SnakeWhole19SnakeWholeShadowMgrFv - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::finishJointShadow() { mShadowMgr->finishJointShadow(); } /* * --INFO-- @@ -2637,24 +1936,8 @@ void Obj::finishJointShadow() */ void Obj::deleteJointShadow() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - mr r4, r31 - lwz r3, shadowMgr__4Game@sda21(r13) - bl addNormalShadow__Q24Game9ShadowMgrFPQ24Game8Creature - lwz r3, shadowMgr__4Game@sda21(r13) - mr r4, r31 - bl delJointShadow__Q24Game9ShadowMgrFPQ24Game8Creature - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + shadowMgr->addNormalShadow(this); + shadowMgr->delJointShadow(this); } /* @@ -2664,74 +1947,13 @@ void Obj::deleteJointShadow() */ void Obj::startBossAttackBGM() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - stw r30, 8(r1) - lbz r0, 0x2c2(r3) - cmplwi r0, 0 - beq lbl_802D0CBC - li r0, 0 - stb r0, 0x2c2(r3) - b lbl_802D0D58 - -lbl_802D0CBC: - lwz r30, 0x28c(r3) - li r31, 0 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 5 - beq lbl_802D0D18 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 6 - beq lbl_802D0D18 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 7 - bne lbl_802D0D1C - -lbl_802D0D18: - li r31, 1 - -lbl_802D0D1C: - clrlwi. r0, r31, 0x18 - bne lbl_802D0D40 - lis r3, lbl_8048BC90@ha - lis r5, lbl_8048BCA8@ha - addi r3, r3, lbl_8048BC90@l - li r4, 0x454 - addi r5, r5, lbl_8048BCA8@l - crclr 6 - bl panic_f__12JUTExceptionFPCciPCce - -lbl_802D0D40: - mr r3, r30 - li r4, 3 - lwz r12, 0x28(r30) - lwz r12, 0xd4(r12) - mtctr r12 - bctrl - -lbl_802D0D58: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (mIsFirstAttackBGM) { + mIsFirstAttackBGM = false; // don't play normal boss attack BGM on first getup + } else { + PSM::EnemyBoss* soundObj = static_cast(mSoundObj); + PSM::checkBoss(soundObj); + soundObj->jumpRequest(3); + } } /* @@ -2741,64 +1963,9 @@ void Obj::startBossAttackBGM() */ void Obj::startBossFlickBGM() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - li r31, 0 - stw r30, 8(r1) - lwz r30, 0x28c(r3) - lwz r12, 0x28(r30) - mr r3, r30 - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 5 - beq lbl_802D0DE0 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 6 - beq lbl_802D0DE0 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 7 - bne lbl_802D0DE4 - -lbl_802D0DE0: - li r31, 1 - -lbl_802D0DE4: - clrlwi. r0, r31, 0x18 - bne lbl_802D0E08 - lis r3, lbl_8048BC90@ha - lis r5, lbl_8048BCA8@ha - addi r3, r3, lbl_8048BC90@l - li r4, 0x454 - addi r5, r5, lbl_8048BCA8@l - crclr 6 - bl panic_f__12JUTExceptionFPCciPCce - -lbl_802D0E08: - mr r3, r30 - li r4, 4 - lwz r12, 0x28(r30) - lwz r12, 0xd4(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + PSM::EnemyBoss* soundObj = static_cast(mSoundObj); + PSM::checkBoss(soundObj); + soundObj->jumpRequest(4); } /* @@ -2808,81 +1975,13 @@ void Obj::startBossFlickBGM() */ void Obj::updateBossBGM() { - /* - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - li r31, 0 - stw r30, 0x18(r1) - stw r29, 0x14(r1) - mr r29, r3 - lwz r30, 0x28c(r3) - lwz r12, 0x28(r30) - mr r3, r30 - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 5 - beq lbl_802D0EB0 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 6 - beq lbl_802D0EB0 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 7 - bne lbl_802D0EB4 - -lbl_802D0EB0: - li r31, 1 - -lbl_802D0EB4: - clrlwi. r0, r31, 0x18 - bne lbl_802D0ED8 - lis r3, lbl_8048BC90@ha - lis r5, lbl_8048BCA8@ha - addi r3, r3, lbl_8048BC90@l - li r4, 0x454 - addi r5, r5, lbl_8048BCA8@l - crclr 6 - bl panic_f__12JUTExceptionFPCciPCce - -lbl_802D0ED8: - lwz r0, 0x1f4(r29) - cmpwi r0, 0 - beq lbl_802D0F00 - mr r3, r30 - li r4, 1 - lwz r12, 0x28(r30) - lwz r12, 0xd8(r12) - mtctr r12 - bctrl - b lbl_802D0F18 - -lbl_802D0F00: - mr r3, r30 - li r4, 0 - lwz r12, 0x28(r30) - lwz r12, 0xd8(r12) - mtctr r12 - bctrl - -lbl_802D0F18: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + PSM::EnemyBoss* soundObj = static_cast(mSoundObj); + PSM::checkBoss(soundObj); + if (mStuckPikminCount != 0) { + soundObj->postPikiAttack(true); + } else { + soundObj->postPikiAttack(false); + } } /* @@ -2892,68 +1991,12 @@ void Obj::updateBossBGM() */ void Obj::resetBossAppearBGM() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - stw r30, 8(r1) - lbz r0, 0x2c3(r3) - cmplwi r0, 0 - bne lbl_802D0FEC - li r0, 1 - li r31, 0 - stb r0, 0x2c3(r3) - lwz r30, 0x28c(r3) - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 5 - beq lbl_802D0FB8 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 6 - beq lbl_802D0FB8 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 7 - bne lbl_802D0FBC - -lbl_802D0FB8: - li r31, 1 - -lbl_802D0FBC: - clrlwi. r0, r31, 0x18 - bne lbl_802D0FE0 - lis r3, lbl_8048BC90@ha - lis r5, lbl_8048BCA8@ha - addi r3, r3, lbl_8048BC90@l - li r4, 0x454 - addi r5, r5, lbl_8048BCA8@l - crclr 6 - bl panic_f__12JUTExceptionFPCciPCce - -lbl_802D0FE0: - mr r3, r30 - li r4, 0 - bl setAppearFlag__Q23PSM9EnemyBossFb - -lbl_802D0FEC: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (!mIsAppearBGMEnabled) { + mIsAppearBGMEnabled = true; + PSM::EnemyBoss* soundObj = static_cast(mSoundObj); + PSM::checkBoss(soundObj); + soundObj->setAppearFlag(false); + } } /* @@ -2963,67 +2006,12 @@ void Obj::resetBossAppearBGM() */ void Obj::setBossAppearBGM() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - stw r30, 8(r1) - lbz r0, 0x2c3(r3) - cmplwi r0, 0 - beq lbl_802D10B8 - li r31, 0 - stb r31, 0x2c3(r3) - lwz r30, 0x28c(r3) - lwz r12, 0x28(r30) - mr r3, r30 - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 5 - beq lbl_802D1084 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 6 - beq lbl_802D1084 - mr r3, r30 - lwz r12, 0x28(r30) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - cmpwi r3, 7 - bne lbl_802D1088 - -lbl_802D1084: - li r31, 1 - -lbl_802D1088: - clrlwi. r0, r31, 0x18 - bne lbl_802D10AC - lis r3, lbl_8048BC90@ha - lis r5, lbl_8048BCA8@ha - addi r3, r3, lbl_8048BC90@l - li r4, 0x454 - addi r5, r5, lbl_8048BCA8@l - crclr 6 - bl panic_f__12JUTExceptionFPCciPCce - -lbl_802D10AC: - mr r3, r30 - li r4, 1 - bl setAppearFlag__Q23PSM9EnemyBossFb - -lbl_802D10B8: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (mIsAppearBGMEnabled) { + mIsAppearBGMEnabled = false; + PSM::EnemyBoss* soundObj = static_cast(mSoundObj); + PSM::checkBoss(soundObj); + soundObj->setAppearFlag(true); + } } /* @@ -3031,39 +2019,7 @@ void Obj::setBossAppearBGM() * Address: 802D10D0 * Size: 000068 */ -void Obj::createEffect() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - stw r30, 8(r1) - mr r30, r3 - li r3, 0x54 - bl __nw__FUl - or. r31, r3, r3 - beq lbl_802D111C - li r4, 0 - li r5, 0x1f2 - li r6, 0x1f3 - li r7, 0x1f4 - li r8, 0x1f5 - bl __ct__Q23efx10TChaseMtx4FPA4_fUsUsUsUs - lis r3, __vt__Q23efx11TCphebiDead@ha - addi r0, r3, __vt__Q23efx11TCphebiDead@l - stw r0, 0(r31) - -lbl_802D111C: - stw r31, 0x32c(r30) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::createEffect() { mEfxDead = new efx::TCphebiDead; } /* * --INFO-- @@ -3072,38 +2028,10 @@ void Obj::createEffect() */ void Obj::setupEffect() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lis r3, lbl_8048BCB4@ha - addi r4, r3, lbl_8048BCB4@l - lwz r3, 0x174(r31) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - mr r0, r3 - lwz r3, 0x32c(r31) - mr r4, r0 - bl setMtxptr__Q23efx10TChaseMtx4FPA4_f - lis r4, lbl_8048BB48@ha - lwz r3, 0x174(r31) - addi r4, r4, lbl_8048BB48@l - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lfs f2, 0x2c(r3) - lfs f1, 0x1c(r3) - lfs f0, 0xc(r3) - stfs f0, 0x2d8(r31) - stfs f1, 0x2dc(r31) - stfs f2, 0x2e0(r31) - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + Matrixf* footMat = mModel->getJoint("foot_joint1")->getWorldMatrix(); + mEfxDead->setMtxptr(footMat->mMatrix.mtxView); + + mFitEffectPos = mModel->getJoint("kutijnt1")->getWorldMatrix()->getBasis(3); } /* @@ -3111,137 +2039,23 @@ void Obj::setupEffect() * Address: 802D11B0 * Size: 0001D4 */ -void Obj::createAppearEffect(int) +void Obj::createAppearEffect(int effectID) { - /* - stwu r1, -0x80(r1) - mflr r0 - lis r5, __vt__Q23efx3Arg@ha - cmpwi r4, 1 - stw r0, 0x84(r1) - addi r0, r5, __vt__Q23efx3Arg@l - stw r0, 8(r1) - lfs f0, 0x18c(r3) - stfs f0, 0xc(r1) - lfs f0, 0x190(r3) - stfs f0, 0x10(r1) - lfs f0, 0x194(r3) - stfs f0, 0x14(r1) - beq lbl_802D1280 - bge lbl_802D11F8 - cmpwi r4, 0 - bge lbl_802D1204 - b lbl_802D1374 - -lbl_802D11F8: - cmpwi r4, 3 - bge lbl_802D1374 - b lbl_802D12FC - -lbl_802D1204: - lis r3, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r3, __vt__Q23efx5TBase@l - lis r3, __vt__Q23efx8TSimple4@ha - stw r0, 0x58(r1) - addi r0, r3, __vt__Q23efx8TSimple4@l - lis r4, __vt__Q23efx14THebiAphd_base@ha - lis r3, __vt__Q23efx17THebiAphd_appear1@ha - stw r0, 0x58(r1) - addi r0, r4, __vt__Q23efx14THebiAphd_base@l - li r4, 0xa0 - li r9, 0xa1 - stw r0, 0x58(r1) - addi r0, r3, __vt__Q23efx17THebiAphd_appear1@l - li r8, 0xa2 - li r7, 0xa3 - li r5, 0x28 - sth r4, 0x5c(r1) - addi r3, r1, 0x58 - addi r4, r1, 8 - sth r9, 0x5e(r1) - sth r8, 0x60(r1) - sth r7, 0x62(r1) - stw r6, 0x64(r1) - stw r6, 0x68(r1) - stw r6, 0x6c(r1) - stw r6, 0x70(r1) - stw r5, 0x74(r1) - stw r0, 0x58(r1) - bl create__Q23efx14THebiAphd_baseFPQ23efx3Arg - b lbl_802D1374 - -lbl_802D1280: - lis r3, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r3, __vt__Q23efx5TBase@l - lis r3, __vt__Q23efx8TSimple4@ha - stw r0, 0x38(r1) - addi r0, r3, __vt__Q23efx8TSimple4@l - lis r4, __vt__Q23efx14THebiAphd_base@ha - lis r3, __vt__Q23efx23THebiAphd_appear2_first@ha - stw r0, 0x38(r1) - addi r0, r4, __vt__Q23efx14THebiAphd_base@l - li r4, 0xa0 - li r9, 0xa1 - stw r0, 0x38(r1) - addi r0, r3, __vt__Q23efx23THebiAphd_appear2_first@l - li r8, 0xa2 - li r7, 0xa3 - li r5, 0x41 - sth r4, 0x3c(r1) - addi r3, r1, 0x38 - addi r4, r1, 8 - sth r9, 0x3e(r1) - sth r8, 0x40(r1) - sth r7, 0x42(r1) - stw r6, 0x44(r1) - stw r6, 0x48(r1) - stw r6, 0x4c(r1) - stw r6, 0x50(r1) - stw r5, 0x54(r1) - stw r0, 0x38(r1) - bl create__Q23efx14THebiAphd_baseFPQ23efx3Arg - b lbl_802D1374 - -lbl_802D12FC: - lis r3, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r3, __vt__Q23efx5TBase@l - lis r3, __vt__Q23efx8TSimple4@ha - stw r0, 0x18(r1) - addi r0, r3, __vt__Q23efx8TSimple4@l - lis r4, __vt__Q23efx14THebiAphd_base@ha - lis r3, __vt__Q23efx22THebiAphd_appear2_late@ha - stw r0, 0x18(r1) - addi r0, r4, __vt__Q23efx14THebiAphd_base@l - li r4, 0xa0 - li r9, 0xa1 - stw r0, 0x18(r1) - addi r0, r3, __vt__Q23efx22THebiAphd_appear2_late@l - li r8, 0xa2 - li r7, 0xa3 - li r5, 0x23 - sth r4, 0x1c(r1) - addi r3, r1, 0x18 - addi r4, r1, 8 - sth r9, 0x1e(r1) - sth r8, 0x20(r1) - sth r7, 0x22(r1) - stw r6, 0x24(r1) - stw r6, 0x28(r1) - stw r6, 0x2c(r1) - stw r6, 0x30(r1) - stw r5, 0x34(r1) - stw r0, 0x18(r1) - bl create__Q23efx14THebiAphd_baseFPQ23efx3Arg - -lbl_802D1374: - lwz r0, 0x84(r1) - mtlr r0 - addi r1, r1, 0x80 - blr - */ + efx::Arg fxArg(mPosition); + switch (effectID) { + case 0: + efx::THebiAphd_appear1 appear1; + appear1.create(&fxArg); + break; + case 1: + efx::THebiAphd_appear2_first appear2; + appear2.create(&fxArg); + break; + case 2: + efx::THebiAphd_appear2_late appear3; + appear3.create(&fxArg); + break; + } } /* @@ -3249,24 +2063,7 @@ void Obj::createAppearEffect(int) * Address: 802D1384 * Size: 000034 */ -void Obj::createDeadStartEffect() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - li r4, 0 - stw r0, 0x14(r1) - lwz r3, 0x32c(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::createDeadStartEffect() { mEfxDead->create(nullptr); } /* * --INFO-- @@ -3275,45 +2072,10 @@ void Obj::createDeadStartEffect() */ void Obj::createDeadFinishEffect() { - /* - stwu r1, -0x30(r1) - mflr r0 - lis r4, lbl_8048BB48@ha - stw r0, 0x34(r1) - addi r4, r4, lbl_8048BB48@l - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lis r4, __vt__Q23efx5TBase@ha - lfs f2, 0x2c(r3) - lfs f1, 0x1c(r3) - addi r4, r4, __vt__Q23efx5TBase@l - lfs f0, 0xc(r3) - lis r3, __vt__Q23efx8TSimple1@ha - addi r0, r3, __vt__Q23efx8TSimple1@l - lis r5, __vt__Q23efx3Arg@ha - stw r4, 8(r1) - lis r3, __vt__Q23efx15TCphebiDeadHane@ha - addi r4, r5, __vt__Q23efx3Arg@l - li r6, 0x1f6 - li r5, 0 - stw r0, 8(r1) - addi r0, r3, __vt__Q23efx15TCphebiDeadHane@l - addi r3, r1, 8 - stw r4, 0x14(r1) - addi r4, r1, 0x14 - stfs f0, 0x18(r1) - stfs f1, 0x1c(r1) - stfs f2, 0x20(r1) - sth r6, 0xc(r1) - stw r5, 0x10(r1) - stw r0, 8(r1) - bl create__Q23efx8TSimple1FPQ23efx3Arg - lwz r0, 0x34(r1) - mtlr r0 - addi r1, r1, 0x30 - blr - */ + Vector3f fxPos = mModel->getJoint("kutijnt1")->getWorldMatrix()->getBasis(3); + efx::Arg fxArg(fxPos); + efx::TCphebiDeadHane deadFX; + deadFX.create(&fxArg); } /* @@ -3321,29 +2083,13 @@ void Obj::createDeadFinishEffect() * Address: 802D144C * Size: 00003C */ -void Obj::createWalkSmokeEffect(float) +void Obj::createWalkSmokeEffect(f32 scale) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, 0x280(r3) - cmplwi r0, 0 - beq lbl_802D1470 - addi r4, r3, 0x18c - bl "createSplashDownEffect__Q24Game9EnemyBaseFRC10Vector3f" - b lbl_802D1478 - -lbl_802D1470: - addi r4, r3, 0x18c - bl "createDropEffect__Q24Game9EnemyBaseFRC10Vector3f" - -lbl_802D1478: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (mWaterBox) { + createSplashDownEffect(mPosition, scale); + } else { + createDropEffect(mPosition, scale); + } } /* @@ -3351,46 +2097,14 @@ void Obj::createWalkSmokeEffect(float) * Address: 802D1488 * Size: 000030 */ -void Obj::effectDrawOn() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x32c(r3) - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::effectDrawOn() { mEfxDead->endDemoDrawOn(); } /* * --INFO-- * Address: 802D14B8 * Size: 000030 */ -void Obj::effectDrawOff() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r3, 0x32c(r3) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::effectDrawOff() { mEfxDead->startDemoDrawOff(); } /* * --INFO-- @@ -3399,41 +2113,9 @@ void Obj::effectDrawOff() */ void Obj::createEfxHamon() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lwz r12, 0(r3) - lwz r12, 0xd0(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_802D151C - mr r3, r31 - bl createEfxHamon__Q24Game9EnemyBaseFv - -lbl_802D151C: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} - -/* - * --INFO-- - * Address: 802D1530 - * Size: 000008 - */ -bool Obj::isUnderground() -{ - /* - lbz r3, 0x2c0(r3) - blr - */ + if (!isUnderground()) { + EnemyBase::createEfxHamon(); + } } /* @@ -3443,98 +2125,9 @@ bool Obj::isUnderground() */ Vector3f* Obj::getFitEffectPos() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lis r3, lbl_8048BB48@ha - addi r4, r3, lbl_8048BB48@l - lwz r3, 0x174(r31) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lfs f2, 0x2c(r3) - lfs f1, 0x1c(r3) - lfs f0, 0xc(r3) - addi r3, r31, 0x2d8 - stfs f0, 0x2d8(r31) - stfs f1, 0x2dc(r31) - stfs f2, 0x2e0(r31) - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + mFitEffectPos = mModel->getJoint("kutijnt1")->getWorldMatrix()->getBasis(3); + return &mFitEffectPos; } -/* - * --INFO-- - * Address: 802D1590 - * Size: 000004 - */ -void Obj::inWaterCallback(WaterBox*) { } - -/* - * --INFO-- - * Address: 802D1594 - * Size: 000004 - */ -void Obj::outWaterCallback() { } - -/* - * --INFO-- - * Address: 802D1598 - * Size: 000008 - */ -f32 Obj::getDamageCoeStoneState() -{ - /* - lfs f1, lbl_8051C8D0@sda21(r2) - blr - */ -} - -/* - * --INFO-- - * Address: 802D15A0 - * Size: 000008 - */ -MouthSlots* Obj::getMouthSlots() -{ - /* - addi r3, r3, 0x2d0 - blr - */ -} - -/* - * --INFO-- - * Address: 802D15A8 - * Size: 000004 - */ -void Obj::throwupItemInDeathProcedure() { } - -/* - * --INFO-- - * Address: 802D15AC - * Size: 000008 - */ -f32 Obj::getDownSmokeScale() -{ - /* - lfs f1, lbl_8051C8D4@sda21(r2) - blr - */ -} - -/* - * --INFO-- - * Address: 802D15B4 - * Size: 000008 - */ -EnemyTypeID::EEnemyTypeID Obj::getEnemyTypeID() { return EnemyTypeID::EnemyID_SnakeWhole; } - } // namespace SnakeWhole } // namespace Game diff --git a/src/plugProjectNishimuraU/SnakeWholeState.cpp b/src/plugProjectNishimuraU/SnakeWholeState.cpp index 32f2d87f9..6d015054a 100644 --- a/src/plugProjectNishimuraU/SnakeWholeState.cpp +++ b/src/plugProjectNishimuraU/SnakeWholeState.cpp @@ -1017,8 +1017,8 @@ void StateWait::cleanup(EnemyBase* enemy) { } void StateWalk::init(EnemyBase* enemy, StateArg* stateArg) { Obj* snagret = static_cast(enemy); - snagret->_2C1 = false; - snagret->_2C8 = 0.0f; + snagret->mIsJumping = false; + snagret->mFaceDirOffset = 0.0f; snagret->mTargetVelocity = Vector3f(0.0f); snagret->startMotion(12, nullptr); } @@ -1046,7 +1046,7 @@ void StateWalk::exec(EnemyBase* enemy) snagret->finishMotion(); } - if (snagret->_2C1) { + if (snagret->mIsJumping) { snagret->updateFace(); } else { snagret->mTargetVelocity = Vector3f(0.0f); @@ -1055,8 +1055,8 @@ void StateWalk::exec(EnemyBase* enemy) if (snagret->mCurAnim->mIsPlaying) { if ((u32)snagret->mCurAnim->mType == KEYEVENT_2) { snagret->enableEvent(0, EB_NoInterrupt); - snagret->_2C1 = true; - snagret->_2C8 = 0.0f; + snagret->mIsJumping = true; + snagret->mFaceDirOffset = 0.0f; Creature* target = snagret->getSearchedTarget(); if (target) { @@ -1071,7 +1071,7 @@ void StateWalk::exec(EnemyBase* enemy) } else if ((u32)snagret->mCurAnim->mType == KEYEVENT_3) { snagret->disableEvent(0, EB_NoInterrupt); - snagret->_2C1 = false; + snagret->mIsJumping = false; snagret->createWalkSmokeEffect(0.75f); Vector3f position = snagret->getPosition(); @@ -1103,8 +1103,8 @@ void StateWalk::cleanup(EnemyBase* enemy) { enemy->disableEvent(0, EB_NoInterrup void StateHome::init(EnemyBase* enemy, StateArg* stateArg) { Obj* snagret = static_cast(enemy); - snagret->_2C1 = false; - snagret->_2C8 = 0.0f; + snagret->mIsJumping = false; + snagret->mFaceDirOffset = 0.0f; snagret->mTargetVelocity = Vector3f(0.0f); snagret->startMotion(12, nullptr); } @@ -1130,7 +1130,7 @@ void StateHome::exec(EnemyBase* enemy) snagret->finishMotion(); } - if (snagret->_2C1) { + if (snagret->mIsJumping) { snagret->updateFace(); } else { snagret->mTargetVelocity = Vector3f(0.0f); @@ -1139,8 +1139,8 @@ void StateHome::exec(EnemyBase* enemy) if (snagret->mCurAnim->mIsPlaying) { if ((u32)snagret->mCurAnim->mType == KEYEVENT_2) { snagret->enableEvent(0, EB_NoInterrupt); - snagret->_2C1 = true; - snagret->_2C8 = 0.0f; + snagret->mIsJumping = true; + snagret->mFaceDirOffset = 0.0f; Vector3f targetPos = Vector3f(snagret->mHomePosition); snagret->setJumpMove(targetPos); @@ -1148,7 +1148,7 @@ void StateHome::exec(EnemyBase* enemy) } else if ((u32)snagret->mCurAnim->mType == KEYEVENT_3) { snagret->disableEvent(0, EB_NoInterrupt); - snagret->_2C1 = false; + snagret->mIsJumping = false; snagret->createWalkSmokeEffect(0.75f); } else if ((u32)snagret->mCurAnim->mType == KEYEVENT_END) {