diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index 9b9d46fb8..b1072a4d1 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -147,12 +147,12 @@ | ImomushiState.cpp | 19863 | UjiaState.cpp | 20924 | | RumbleMgr.cpp | 21534 | Rock.cpp | 21671 | | ElecHiba.cpp | 21823 | Frog.cpp | 22143 | -| QueenState.cpp | 22549 | Ujia.cpp | 22950 | -| ElecBug.cpp | 24345 | ArmorState.cpp | 24714 | -| SaraiState.cpp | 24923 | TobiState.cpp | 24962 | -| UjibState.cpp | 25505 | Armor.cpp | 25769 | -| TankState.cpp | 29293 | RandItemUnit.cpp | 29622 | -| IKSystemBase.cpp | 30077 | +| QueenState.cpp | 22549 | Ujia.cpp | 22940 | +| Ujib.cpp | 23626 | ElecBug.cpp | 24345 | +| ArmorState.cpp | 24714 | SaraiState.cpp | 24923 | +| TobiState.cpp | 24962 | UjibState.cpp | 25505 | +| Armor.cpp | 25767 | Tobi.cpp | 25912 | +| TankState.cpp | 29293 | ###
plugProjectOgawaU
| File | Size (bytes) | File | Size (bytes) | diff --git a/include/Game/Entities/Tobi.h b/include/Game/Entities/Tobi.h index bcae3a8e7..f10ecfbb0 100644 --- a/include/Game/Entities/Tobi.h +++ b/include/Game/Entities/Tobi.h @@ -8,6 +8,10 @@ #include "Game/EnemyBase.h" #include "Collinfo.h" +#define GET_APPCHECK_VAL(check) ((u8)check) +#define GET_APPCHECK_MAX(check) (check >> 8) +#define SET_APPCHECK_MAX(check, val) (check = (val) << 8) + /** * --Header for Shearwigs (Tobi)-- */ @@ -91,15 +95,15 @@ struct Obj : public EnemyBase { // _00 = VTBL // _00-_2BC = EnemyBase FSM* mFsm; // _2BC - u8 _2C0; // _2C0, guess based on Ujia/b - bool mIsUnderground; // _2C1, guess based on Ujia/b - u16 _2C2; // _2C2, guess based on Ujia/b + u8 _2C0; // _2C0 + bool mIsUnderground; // _2C1 + u16 mAppearCheck; // _2C2 StateID mNextState; // _2C4 MouthSlots mMouthSlots; // _2C8 Vector3f mTargetPosition; // _2D0 - ItemBridge::Item* mBridge; // _2DC, guess based on Ujia/b - f32 _2E0; // _2E0, guess based on Ujia/b - f32 _2E4; // _2E4, guess based on Ujia/b + ItemBridge::Item* mBridge; // _2DC + f32 _2E0; // _2E0 + f32 _2E4; // _2E4 // _2E8 = PelletView }; @@ -124,19 +128,19 @@ struct Parms : public EnemyParmsBase { struct ProperParms : public Parameters { inline ProperParms() : Parameters(nullptr, "EnemyParmsBase") - , mFp01(this, 'fp01', "離陸ライフ", 0.5f, 0.0f, 1.0f) // 'takeoff life' - , mFp02(this, 'fp02', "着陸ライフ", 0.7f, 0.0f, 1.0f) // 'landing life' - , mFp03(this, 'fp03', "飛行オフセット", 60.0f, 0.0f, 300.0f) // 'flight offset' - , mPoisonDamage(this, 'fp11', "白ピクミン", 300.0f, 0.0f, 10000.0f) // 'white pikmin' - , mBridgeDamage(this, 'fp12', "橋食いパワー", 75.0f, 0.0f, 100.0f) // 'bridge eating power' + , mTakeOffHealthRatio(this, 'fp01', "離陸ライフ", 0.5f, 0.0f, 1.0f) // 'takeoff life' + , mLandHealthRatio(this, 'fp02', "着陸ライフ", 0.7f, 0.0f, 1.0f) // 'landing life' + , mFlightHeight(this, 'fp03', "飛行オフセット", 60.0f, 0.0f, 300.0f) // 'flight offset' + , mPoisonDamage(this, 'fp11', "白ピクミン", 300.0f, 0.0f, 10000.0f) // 'white pikmin' + , mBridgeDamage(this, 'fp12', "橋食いパワー", 75.0f, 0.0f, 100.0f) // 'bridge eating power' { } - Parm mFp01; // _804 - Parm mFp02; // _82C - Parm mFp03; // _854 - Parm mPoisonDamage; // _87C, fp11 - Parm mBridgeDamage; // _8A4, fp12 + Parm mTakeOffHealthRatio; // _804 + Parm mLandHealthRatio; // _82C + Parm mFlightHeight; // _854 + Parm mPoisonDamage; // _87C, fp11 + Parm mBridgeDamage; // _8A4, fp12 }; Parms() { } diff --git a/include/Game/Entities/Ujib.h b/include/Game/Entities/Ujib.h index f17928db2..b3fd986f6 100644 --- a/include/Game/Entities/Ujib.h +++ b/include/Game/Entities/Ujib.h @@ -8,6 +8,10 @@ #include "Game/EnemyBase.h" #include "Collinfo.h" +#define GET_APPCHECK_VAL(check) ((u8)check) +#define GET_APPCHECK_MAX(check) (check >> 8) +#define SET_APPCHECK_MAX(check, val) (check = (val) << 8) + /** * --Header for Male Sheargrub (Ujib)-- */ @@ -84,8 +88,8 @@ struct Obj : public EnemyBase { FSM* mFsm; // _2BC u8 _2C0; // _2C0 bool mIsUnderground; // _2C1 - u16 _2C2; // _2C2 - int mNextState; // _2C4 + u16 mAppearCheck; // _2C2 + StateID mNextState; // _2C4 MouthSlots mMouthSlots; // _2C8 ItemBridge::Item* mBridge; // _2D0 f32 _2CC; // _2D4 diff --git a/src/plugProjectNishimuraU/Tobi.cpp b/src/plugProjectNishimuraU/Tobi.cpp index e897bd060..e98ef5655 100644 --- a/src/plugProjectNishimuraU/Tobi.cpp +++ b/src/plugProjectNishimuraU/Tobi.cpp @@ -1,310 +1,9 @@ #include "Game/Entities/Tobi.h" #include "Game/Entities/ItemBridge.h" +#include "Game/MapMgr.h" +#include "efx/TUjinko.h" #include "Dolphin/rand.h" -/* - Generated from dpostproc - - .section .rodata # 0x804732E0 - 0x8049E220 - .global lbl_80485E80 - lbl_80485E80: - .4byte 0x746F6269 - .4byte 0x6E6E6B6F - .4byte 0x00000000 - .4byte 0x00000000 - - .section .data, "wa" # 0x8049E220 - 0x804EFC20 - .global __vt__Q34Game4Tobi3Obj - __vt__Q34Game4Tobi3Obj: - .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__Q34Game4Tobi3ObjFPQ24Game15CreatureInitArg - .4byte onKill__Q24Game9EnemyBaseFPQ24Game15CreatureKillArg - .4byte onInitPost__Q24Game9EnemyBaseFPQ24Game15CreatureInitArg - .4byte doAnimation__Q24Game9EnemyBaseFv - .4byte doEntry__Q24Game9EnemyBaseFv - .4byte doSetView__Q24Game9EnemyBaseFi - .4byte doViewCalc__Q24Game9EnemyBaseFv - .4byte doSimulation__Q24Game9EnemyBaseFf - .4byte doDirectDraw__Q34Game4Tobi3ObjFR8Graphics - .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__Q24Game9EnemyBaseFPQ24Game8WaterBox - .4byte outWaterCallback__Q24Game9EnemyBaseFv - .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__Q34Game4Tobi3ObjFv - .4byte isLivingThing__Q24Game8CreatureFv - .4byte isDebugCollision__Q24Game8CreatureFv - .4byte setDebugCollision__Q24Game8CreatureFb - .4byte doSave__Q24Game8CreatureFR6Stream - .4byte doLoad__Q24Game8CreatureFR6Stream - .4byte bounceCallback__Q24Game8CreatureFPQ23Sys8Triangle - .4byte collisionCallback__Q24Game9EnemyBaseFRQ24Game9CollEvent - .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__Q34Game4Tobi3ObjFRQ24Game11ShadowParam - .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__Q34Game4Tobi3ObjFv - .4byte "birth__Q24Game9EnemyBaseFR10Vector3f" - .4byte - setInitialSetting__Q34Game4Tobi3ObjFPQ24Game21EnemyInitialParamBase .4byte - update__Q24Game9EnemyBaseFv .4byte doUpdate__Q34Game4Tobi3ObjFv .4byte - doUpdateCommon__Q24Game9EnemyBaseFv .4byte - doUpdateCarcass__Q24Game9EnemyBaseFv .4byte - doAnimationUpdateAnimator__Q24Game9EnemyBaseFv .4byte - doAnimationCullingOff__Q24Game9EnemyBaseFv .4byte - doAnimationCullingOn__Q24Game9EnemyBaseFv .4byte - doAnimationStick__Q24Game9EnemyBaseFv .4byte - doSimulationCarcass__Q24Game9EnemyBaseFf .4byte - doDebugDraw__Q34Game4Tobi3ObjFR8Graphics .4byte - doSimpleDraw__Q24Game9EnemyBaseFP8Viewport .4byte - doSimulationGround__Q24Game9EnemyBaseFf .4byte - doSimulationFlying__Q24Game9EnemyBaseFf .4byte - doSimulationStick__Q24Game9EnemyBaseFf .4byte - changeMaterial__Q24Game9EnemyBaseFv .4byte - "getCommonEffectPos__Q24Game9EnemyBaseFR10Vector3" .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__Q24Game9EnemyBaseFv - .4byte setParameters__Q24Game9EnemyBaseFv - .4byte initMouthSlots__Q34Game4Tobi3ObjFv - .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__Q34Game4Tobi3ObjFv - .4byte getMouthSlots__Q34Game4Tobi3ObjFv - .4byte doGetLifeGaugeParam__Q24Game9EnemyBaseFRQ24Game14LifeGaugeParam - .4byte throwupItem__Q24Game9EnemyBaseFv - .4byte "getThrowupItemPosition__Q24Game9EnemyBaseFP10Vector3" - .4byte "getThrowupItemVelocity__Q24Game9EnemyBaseFP10Vector3" - .4byte throwupItemInDeathProcedure__Q24Game9EnemyBaseFv - .4byte setLODSphere__Q24Game9EnemyBaseFRQ23Sys6Sphere - .4byte damageCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart - .4byte pressCallBack__Q34Game4Tobi3ObjFPQ24Game8CreaturefP8CollPart - .4byte - flyCollisionCallBack__Q34Game4Tobi3ObjFPQ24Game8CreaturefP8CollPart .4byte - hipdropCallBack__Q34Game4Tobi3ObjFPQ24Game8CreaturefP8CollPart .4byte - dropCallBack__Q24Game9EnemyBaseFPQ24Game8Creature .4byte - earthquakeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - farmCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - "bombCallBack__Q24Game9EnemyBaseFPQ24Game8CreatureR10Vector3f" .4byte - eatWhitePikminCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - dopeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturei .4byte - doDopeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturei .4byte - doStartStoneState__Q34Game4Tobi3ObjFv .4byte - doFinishStoneState__Q34Game4Tobi3ObjFv .4byte - getDamageCoeStoneState__Q24Game9EnemyBaseFv .4byte - doStartEarthquakeState__Q24Game9EnemyBaseFf .4byte - doFinishEarthquakeState__Q24Game9EnemyBaseFv .4byte - doStartEarthquakeFitState__Q34Game4Tobi3ObjFv .4byte - doFinishEarthquakeFitState__Q34Game4Tobi3ObjFv .4byte - lifeRecover__Q34Game4Tobi3ObjFv .4byte startCarcassMotion__Q34Game4Tobi3ObjFv - .4byte setCarcassArg__Q24Game9EnemyBaseFRQ24Game13PelletViewArg - .4byte getCarcassArgHeight__Q24Game9EnemyBaseFv - .4byte doBecomeCarcass__Q24Game9EnemyBaseFv - .4byte startWaitingBirthTypeDrop__Q24Game9EnemyBaseFv - .4byte finishWaitingBirthTypeDrop__Q24Game9EnemyBaseFv - .4byte isFinishableWaitingBirthTypeDrop__Q24Game9EnemyBaseFv - .4byte doStartWaitingBirthTypeDrop__Q24Game9EnemyBaseFv - .4byte doFinishWaitingBirthTypeDrop__Q24Game9EnemyBaseFv - .4byte wallCallback__Q24Game9EnemyBaseFRCQ24Game8MoveInfo - .4byte getDownSmokeScale__Q34Game4Tobi3ObjFv - .4byte doStartMovie__Q24Game9EnemyBaseFv - .4byte doEndMovie__Q24Game9EnemyBaseFv - .4byte setFSM__Q34Game4Tobi3ObjFPQ34Game4Tobi3FSM - .4byte 0 - .4byte 0 - .4byte viewGetBaseScale__Q24Game10PelletViewFv - .4byte "@744@12@viewGetShape__Q24Game9EnemyBaseFv" - .4byte viewGetCollTreeJointIndex__Q24Game10PelletViewFv - .4byte viewGetCollTreeOffset__Q24Game10PelletViewFv - .4byte "@744@12@view_start_carrymotion__Q24Game9EnemyBaseFv" - .4byte "@744@12@view_finish_carrymotion__Q24Game9EnemyBaseFv" - .4byte "@744@12@viewStartPreCarryMotion__Q24Game9EnemyBaseFv" - .4byte "@744@12@viewStartCarryMotion__Q24Game9EnemyBaseFv" - .4byte "@744@12@viewOnPelletKilled__Q24Game9EnemyBaseFv" - .4byte "viewEntryShape__Q24Game10PelletViewFR7MatrixfR10Vector3" - .4byte 0 - - .section .sdata2, "a" # 0x80516360 - 0x80520E40 - .global lbl_8051AF68 - lbl_8051AF68: - .4byte 0x6B6F7369 - .4byte 0x6A6E7400 - .global lbl_8051AF70 - lbl_8051AF70: - .4byte 0x00000000 - .global lbl_8051AF74 - lbl_8051AF74: - .float 1.0 - .global lbl_8051AF78 - lbl_8051AF78: - .4byte 0x41100000 - .global lbl_8051AF7C - lbl_8051AF7C: - .4byte 0x42480000 - .global lbl_8051AF80 - lbl_8051AF80: - .4byte 0x40200000 - .global lbl_8051AF84 - lbl_8051AF84: - .4byte 0x41F00000 - .global lbl_8051AF88 - lbl_8051AF88: - .4byte 0x6B616D75 - .4byte 0x6A6E7400 - .global lbl_8051AF90 - lbl_8051AF90: - .4byte 0x41700000 - .global lbl_8051AF94 - lbl_8051AF94: - .4byte 0x3A83126F - .global lbl_8051AF98 - lbl_8051AF98: - .float 0.5 - .global lbl_8051AF9C - lbl_8051AF9C: - .4byte 0x40C90FDB - .global lbl_8051AFA0 - lbl_8051AFA0: - .4byte 0x47000000 - .global lbl_8051AFA4 - lbl_8051AFA4: - .4byte 0x43A2F983 - .global lbl_8051AFA8 - lbl_8051AFA8: - .4byte 0xC3A2F983 - .global lbl_8051AFAC - lbl_8051AFAC: - .4byte 0x40000000 - .global lbl_8051AFB0 - lbl_8051AFB0: - .4byte 0x43300000 - .4byte 0x80000000 - .global lbl_8051AFB8 - lbl_8051AFB8: - .4byte 0x41A00000 - .global lbl_8051AFBC - lbl_8051AFBC: - .4byte 0x40A00000 - .global lbl_8051AFC0 - lbl_8051AFC0: - .4byte 0xC1A00000 - .global lbl_8051AFC4 - lbl_8051AFC4: - .4byte 0x437A0000 - .global lbl_8051AFC8 - lbl_8051AFC8: - .4byte 0x3F400000 - .global lbl_8051AFCC - lbl_8051AFCC: - .4byte 0x40490FDB - .global lbl_8051AFD0 - lbl_8051AFD0: - .4byte 0x3BB60B61 - .global lbl_8051AFD4 - lbl_8051AFD4: - .float 0.7 - .global lbl_8051AFD8 - lbl_8051AFD8: - .4byte 0x3EB33333 - .4byte 0x00000000 -*/ - namespace Game { namespace Tobi { @@ -315,92 +14,8 @@ namespace Tobi { */ 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_802698EC - addi r0, r31, 0x2e8 - lis r3, __vt__Q24Game10PelletView@ha - stw r0, 0x17c(r31) - addi r3, r3, __vt__Q24Game10PelletView@l - li r0, 0 - stw r3, 0x2e8(r31) - stw r0, 0x2ec(r31) - stw r0, 0x2f0(r31) - -lbl_802698EC: - mr r3, r31 - li r4, 0 - bl __ct__Q24Game9EnemyBaseFv - lis r3, __vt__Q34Game4Tobi3Obj@ha - addi r0, r31, 0x2e8 - addi r5, r3, __vt__Q34Game4Tobi3Obj@l - addi r3, r31, 0x2c8 - stw r5, 0(r31) - addi r4, r5, 0x1b0 - addi r5, r5, 0x2fc - 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 __ct__10MouthSlotsFv - li r3, 0x2c - bl __nw__FUl - or. r30, r3, r3 - beq lbl_80269980 - bl __ct__Q24Game17EnemyAnimatorBaseFv - lis r3, __vt__Q34Game4Tobi14ProperAnimator@ha - lis r4, __vt__Q28SysShape12BaseAnimator@ha - addi r0, r3, __vt__Q34Game4Tobi14ProperAnimator@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_80269980: - stw r30, 0x184(r31) - li r3, 0x1c - bl __nw__FUl - or. r4, r3, r3 - beq lbl_802699B4 - lis r5, __vt__Q24Game17EnemyStateMachine@ha - lis r3, __vt__Q34Game4Tobi3FSM@ha - addi r0, r5, __vt__Q24Game17EnemyStateMachine@l - li r5, -1 - stw r0, 0(r4) - addi r0, r3, __vt__Q34Game4Tobi3FSM@l - stw r5, 0x18(r4) - stw r0, 0(r4) - -lbl_802699B4: - lwz r12, 0(r31) - mr r3, r31 - lwz r12, 0x2f8(r12) - mtctr r12 - bctrl - 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); } /* @@ -415,48 +30,17 @@ void Obj::setInitialSetting(EnemyInitialParamBase*) { } * Address: 802699E8 * Size: 000098 */ -void Obj::onInit(CreatureInitArg*) +void Obj::onInit(CreatureInitArg* initArg) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl onInit__Q24Game9EnemyBaseFPQ24Game15CreatureInitArg - lwz r0, 0x1e0(r31) - mr r3, r31 - rlwinm r0, r0, 0, 0x15, 0x13 - stw r0, 0x1e0(r31) - lwz r0, 0x1e0(r31) - rlwinm r0, r0, 0, 0x1a, 0x18 - stw r0, 0x1e0(r31) - bl resetAppearCheck__Q34Game4Tobi3ObjFv - li r3, 0 - li r0, -1 - stb r3, 0x2c1(r31) - mr r3, r31 - stw r0, 0x2c4(r31) - bl resetBridgeSearch__Q34Game4Tobi3ObjFv - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 2 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0xc(r12) - mtctr r12 - bctrl - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 0x1dc(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + EnemyBase::onInit(initArg); + disableEvent(0, EB_LifegaugeVisible); + disableEvent(0, EB_Cullable); + resetAppearCheck(); + mIsUnderground = false; + mNextState = TOBI_NULL; + resetBridgeSearch(); + mFsm->start(this, TOBI_Stay, nullptr); + doAnimationCullingOff(); } /* @@ -466,26 +50,8 @@ void Obj::onInit(CreatureInitArg*) */ void Obj::doUpdate() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - mr r4, r31 - lwz r3, 0x2bc(r3) - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - addi r3, r31, 0x2c8 - bl update__10MouthSlotsFv - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + mFsm->exec(this); + mMouthSlots.update(); } /* @@ -500,48 +66,18 @@ void Obj::doDirectDraw(Graphics&) { } * Address: 80269ACC * Size: 000020 */ -void Obj::doDebugDraw(Graphics&) -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - bl doDebugDraw__Q24Game9EnemyBaseFR8Graphics - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::doDebugDraw(Graphics& gfx) { EnemyBase::doDebugDraw(gfx); } /* * --INFO-- * Address: 80269AEC * 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; } /* @@ -549,72 +85,24 @@ void Obj::setFSM(FSM*) * Address: 80269B38 * Size: 0000E0 */ -void Obj::getShadowParam(ShadowParam&) +void Obj::getShadowParam(ShadowParam& shadowParam) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r4 - addi r4, r2, lbl_8051AF68@sda21 - stw r30, 8(r1) - mr r30, r3 - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lfs f3, 0x2c(r3) - lfs f2, 0x1c(r3) - lfs f0, 0xc(r3) - mr r3, r30 - lfs f1, lbl_8051AF70@sda21(r2) - stfs f0, 0(r31) - lfs f0, lbl_8051AF74@sda21(r2) - stfs f2, 4(r31) - stfs f3, 8(r31) - stfs f1, 0xc(r31) - stfs f0, 0x10(r31) - stfs f1, 0x14(r31) - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 0xa - bne lbl_80269BC8 - lfs f2, 4(r31) - lfs f0, lbl_8051AF78@sda21(r2) - lfs f1, lbl_8051AF7C@sda21(r2) - fsubs f0, f2, f0 - stfs f0, 4(r31) - lwz r3, 0xc0(r30) - lfs f0, 0x86c(r3) - fadds f0, f1, f0 - stfs f0, 0x18(r31) - b lbl_80269BF8 - -lbl_80269BC8: - lfs f1, 4(r31) - lfs f0, lbl_8051AF80@sda21(r2) - fsubs f0, f1, f0 - stfs f0, 4(r31) - lwz r0, 0x1e4(r30) - clrlwi. r0, r0, 0x1f - beq lbl_80269BF0 - lfs f0, lbl_8051AF7C@sda21(r2) - stfs f0, 0x18(r31) - b lbl_80269BF8 - -lbl_80269BF0: - lfs f0, lbl_8051AF84@sda21(r2) - stfs f0, 0x18(r31) - -lbl_80269BF8: - lfs f0, lbl_8051AF78@sda21(r2) - stfs f0, 0x1c(r31) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + shadowParam.mPosition = mModel->getJoint("kosijnt")->getWorldMatrix()->getBasis(3); + shadowParam.mBoundingSphere.mPosition = Vector3f(0.0f, 1.0f, 0.0f); + + if (getStateID() == TOBI_Fly) { + shadowParam.mPosition.y -= 9.0f; + shadowParam.mBoundingSphere.mRadius = C_PROPERPARMS.mFlightHeight.mValue + 50.0f; + } else { + shadowParam.mPosition.y -= 2.5f; + if (isEvent(1, EB2_Earthquake)) { + shadowParam.mBoundingSphere.mRadius = 50.0f; + } else { + shadowParam.mBoundingSphere.mRadius = 30.0f; + } + } + + shadowParam.mSize = 9.0f; } /* @@ -622,59 +110,18 @@ void Obj::getShadowParam(ShadowParam&) * Address: 80269C18 * Size: 0000A4 */ -bool Obj::pressCallBack(Creature*, f32, CollPart*) +bool Obj::pressCallBack(Creature* creature, f32 damage, CollPart* part) { - /* - stwu r1, -0x10(r1) - mflr r0 - cmplwi r4, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - beq lbl_80269CA4 - mr r3, r4 - lwz r12, 0(r4) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_80269CA4 - lwz r0, 0x1e0(r31) - rlwinm. r0, r0, 0, 0x16, 0x16 - bne lbl_80269CA4 - mr r3, r31 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 4 - ble lbl_80269C74 - cmpwi r3, 0xa - blt lbl_80269C7C - -lbl_80269C74: - cmpwi r3, 0xa - ble lbl_80269CA4 - -lbl_80269C7C: - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 1 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - li r3, 1 - b lbl_80269CA8 - -lbl_80269CA4: - li r3, 0 - -lbl_80269CA8: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (creature && creature->isPiki() && !isEvent(0, EB_Bittered)) { + int stateID = getStateID(); + if ((stateID > TOBI_Dive && stateID < TOBI_Fly) || (stateID > TOBI_Fly)) { + // i.e. not in dead, press, stay, appear, dive or fly states + mFsm->transit(this, TOBI_Press, nullptr); + return true; + } + } + + return false; } /* @@ -682,73 +129,22 @@ bool Obj::pressCallBack(Creature*, f32, CollPart*) * Address: 80269CBC * Size: 00002C */ -bool Obj::hipdropCallBack(Creature*, f32, CollPart*) -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r12, 0(r3) - lwz r12, 0x27c(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +bool Obj::hipdropCallBack(Creature* creature, f32 damage, CollPart* part) { return pressCallBack(creature, damage, part); } /* * --INFO-- * Address: 80269CE8 * Size: 000094 */ -bool Obj::flyCollisionCallBack(Creature*, f32, CollPart*) +bool Obj::flyCollisionCallBack(Creature* creature, f32 damage, CollPart* part) { - /* - stwu r1, -0x10(r1) - mflr r0 - cmplwi r4, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - beq lbl_80269D64 - mr r3, r4 - lwz r12, 0(r4) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_80269D64 - lwz r0, 0x1e0(r31) - rlwinm. r0, r0, 0, 0x16, 0x16 - bne lbl_80269D64 - mr r3, r31 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 0xa - bne lbl_80269D64 - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 0 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - li r3, 1 - b lbl_80269D68 - -lbl_80269D64: - li r3, 0 + if (creature && creature->isPiki() && !isEvent(0, EB_Bittered) && getStateID() == TOBI_Fly) { + // instakill if hit by piki while flying + mFsm->transit(this, TOBI_Dead, nullptr); + return true; + } -lbl_80269D68: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + return false; } /* @@ -758,22 +154,8 @@ bool Obj::flyCollisionCallBack(Creature*, f32, CollPart*) */ void Obj::doStartStoneState() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl doStartStoneState__Q24Game9EnemyBaseFv - lwz r0, 0x1e0(r31) - rlwinm r0, r0, 0, 0, 0x1e - stw r0, 0x1e0(r31) - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + EnemyBase::doStartStoneState(); + disableEvent(0, EB_Invulnerable); } /* @@ -783,33 +165,10 @@ void Obj::doStartStoneState() */ void Obj::doFinishStoneState() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl doFinishStoneState__Q24Game9EnemyBaseFv - mr r3, r31 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 0xa - bne lbl_80269DFC - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 5 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - -lbl_80269DFC: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + EnemyBase::doFinishStoneState(); + if (getStateID() == TOBI_Fly) { + mFsm->transit(this, TOBI_Move, nullptr); + } } /* @@ -819,22 +178,8 @@ void Obj::doFinishStoneState() */ void Obj::doStartEarthquakeFitState() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl doStartEarthquakeFitState__Q24Game9EnemyBaseFv - lwz r0, 0x1e0(r31) - rlwinm r0, r0, 0, 0, 0x1e - stw r0, 0x1e0(r31) - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + EnemyBase::doStartEarthquakeFitState(); + disableEvent(0, EB_Invulnerable); } /* @@ -844,33 +189,10 @@ void Obj::doStartEarthquakeFitState() */ void Obj::doFinishEarthquakeFitState() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl doFinishEarthquakeFitState__Q24Game9EnemyBaseFv - mr r3, r31 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 0xa - bne lbl_80269E90 - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 5 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - -lbl_80269E90: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + EnemyBase::doFinishEarthquakeFitState(); + if (getStateID() == TOBI_Fly) { + mFsm->transit(this, TOBI_Move, nullptr); + } } /* @@ -878,21 +200,7 @@ void Obj::doFinishEarthquakeFitState() * Address: 80269EA4 * Size: 000028 */ -void Obj::startCarcassMotion() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - li r4, 9 - li r5, 0 - stw r0, 0x14(r1) - bl startMotion__Q24Game9EnemyBaseFiPQ28SysShape14MotionListener - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::startCarcassMotion() { startMotion(9, nullptr); } /* * --INFO-- @@ -901,47 +209,11 @@ void Obj::startCarcassMotion() */ void Obj::initMouthSlots() { - /* - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stfd f31, 0x10(r1) - psq_st f31, 24(r1), 0, qr0 - stw r31, 0xc(r1) - stw r30, 8(r1) - mr r30, r3 - li r4, 1 - addi r3, r30, 0x2c8 - bl alloc__10MouthSlotsFi - lwz r5, 0x174(r30) - addi r3, r30, 0x2c8 - li r4, 0 - addi r6, r2, lbl_8051AF88@sda21 - bl setup__10MouthSlotsFiPQ28SysShape5ModelPc - lfs f31, lbl_8051AF90@sda21(r2) - li r31, 0 - b lbl_80269F2C - -lbl_80269F18: - mr r4, r31 - addi r3, r30, 0x2c8 - bl getSlot__10MouthSlotsFi - stfs f31, 0x1c(r3) - addi r31, r31, 1 - -lbl_80269F2C: - lwz r0, 0x2c8(r30) - cmpw r31, r0 - blt lbl_80269F18 - psq_l f31, 24(r1), 0, qr0 - lwz r0, 0x24(r1) - lfd f31, 0x10(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + mMouthSlots.alloc(1); + mMouthSlots.setup(0, mModel, "kamujnt"); + for (int i = 0; i < mMouthSlots.getMax(); i++) { + mMouthSlots.getSlot(i)->mRadius = 15.0f; + } } /* @@ -951,43 +223,14 @@ void Obj::initMouthSlots() */ void Obj::lifeRecover() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lwz r12, 0(r3) - lwz r12, 0xcc(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_80269FB8 - lwz r3, 0xc0(r31) - lfs f2, lbl_8051AF94@sda21(r2) - lfs f1, 0x104(r3) - lfs f0, 0x200(r31) - fmadds f0, f2, f1, f0 - stfs f0, 0x200(r31) - lwz r3, 0xc0(r31) - lfs f1, 0x200(r31) - lfs f0, 0x104(r3) - fcmpo cr0, f1, f0 - ble lbl_80269FC0 - stfs f0, 0x200(r31) - b lbl_80269FC0 - -lbl_80269FB8: - mr r3, r31 - bl lifeRecover__Q24Game9EnemyBaseFv - -lbl_80269FC0: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (isFlying()) { + mHealth += 0.001f * *C_PARMS->mGeneral.mHealth(); + if (mHealth > *C_PARMS->mGeneral.mHealth()) { + mHealth = *C_PARMS->mGeneral.mHealth(); + } + } else { + EnemyBase::lifeRecover(); + } } /* @@ -997,20 +240,11 @@ void Obj::lifeRecover() */ void Obj::lifeIncrement() { - /* - lfs f1, lbl_8051AF70@sda21(r2) - stfs f1, 0x208(r3) - lwz r0, 0x1e0(r3) - rlwinm r0, r0, 0, 0x1f, 0x1d - stw r0, 0x1e0(r3) - lfs f0, 0x200(r3) - fcmpo cr0, f0, f1 - cror 2, 0, 2 - bnelr - lfs f0, lbl_8051AF74@sda21(r2) - stfs f0, 0x200(r3) - blr - */ + mInstantDamage = 0.0f; + disableEvent(0, EB_TakingDamage); + if (mHealth <= 0.0f) { + mHealth = 1.0f; + } } /* @@ -1020,6 +254,26 @@ void Obj::lifeIncrement() */ void Obj::randomFlyingTarget() { + Vector3f targetPos = mTargetPosition; + Vector3f pos = getPosition(); + Vector3f vel = getVelocity(); + Vector3f zeroVec = Vector3f(0.0f, 0.0f, 0.0f); + + f32 targetDist = sqrDistanceXZ(targetPos, pos); + f32 speed = sqrDistanceXZ(zeroVec, vel) * 0.5f; + + if (targetDist < speed) { + f32 randAngle = randWeightFloat(TAU); + f32 randDist = randWeightFloat(C_PARMS->mGeneral.mTerritoryRadius.mValue); + + targetPos = Vector3f(randDist * pikmin2_sinf(randAngle), 0.0f, randDist * pikmin2_cosf(randAngle)); + targetPos += mHomePosition; + } + + f32 minY = mapMgr->getMinY(pos); + targetPos.y = minY + C_PROPERPARMS.mFlightHeight.mValue; + mTargetPosition = targetPos; + mTargetVelocity.y = (targetPos.y - pos.y) * 2.0f; /* stwu r1, -0x80(r1) mflr r0 @@ -1173,20 +427,7 @@ void Obj::randomFlyingTarget() * Address: 8026A224 * Size: 000024 */ -void Obj::isFlyingLife() -{ - /* - lwz r4, 0xc0(r3) - lfs f2, 0x200(r3) - lfs f1, 0x104(r4) - lfs f0, 0x81c(r4) - fdivs f1, f2, f1 - fcmpo cr0, f1, f0 - mfcr r0 - srwi r3, r0, 0x1f - blr - */ -} +bool Obj::isFlyingLife() { return ((mHealth / C_PARMS->mGeneral.mHealth.mValue) < C_PROPERPARMS.mTakeOffHealthRatio.mValue); } /* * --INFO-- @@ -1195,23 +436,9 @@ void Obj::isFlyingLife() */ void Obj::setInWaterDamage() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, 0x280(r3) - cmplwi r0, 0 - beq lbl_8026A26C - lfs f1, lbl_8051AF80@sda21(r2) - lfs f2, lbl_8051AF74@sda21(r2) - bl addDamage__Q24Game9EnemyBaseFff - -lbl_8026A26C: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (mWaterBox) { + addDamage(2.5f, 1.0f); + } } /* @@ -1221,57 +448,13 @@ void Obj::setInWaterDamage() */ void Obj::resetAppearCheck() { - /* - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r3 - lwz r4, gameSystem__4Game@sda21(r13) - cmplwi r4, 0 - beq lbl_8026A310 - lwz r0, 0x44(r4) - cmpwi r0, 4 - bne lbl_8026A310 - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0xc(r1) - mr r3, r30 - lwz r12, 0(r30) - stw r0, 8(r1) - lfd f2, lbl_8051AFB0@sda21(r2) - lfd f0, 8(r1) - lfs f1, lbl_8051AFA0@sda21(r2) - fsubs f2, f0, f2 - lfs f0, lbl_8051AF84@sda21(r2) - lwz r12, 0x1ac(r12) - fdivs f1, f2, f1 - fmuls f0, f0, f1 - fctiwz f0, f0 - stfd f0, 0x10(r1) - lwz r31, 0x14(r1) - mtctr r12 - bctrl - mulli r0, r3, 5 - add r0, r31, r0 - rlwinm r0, r0, 8, 0x10, 0x17 - sth r0, 0x2c2(r30) - b lbl_8026A318 - -lbl_8026A310: - li r0, 0 - sth r0, 0x2c2(r30) - -lbl_8026A318: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + if (Game::gameSystem && Game::gameSystem->mMode == GSM_PIKLOPEDIA) { + int weight = (rand() / RAND_MAX) * 30.0f; // does not match with inline + SET_APPCHECK_MAX(mAppearCheck, weight + 5 * getCreatureID()); + + } else { + mAppearCheck = 0; + } } /* @@ -1279,32 +462,18 @@ void Obj::resetAppearCheck() * Address: 8026A330 * Size: 000048 */ -void Obj::isAppearCheck() +bool Obj::isAppearCheck() { - /* - lhz r4, 0x2c2(r3) - cmplwi r4, 0 - beq lbl_8026A370 - addi r0, r4, 1 - sth r0, 0x2c2(r3) - lhz r0, 0x2c2(r3) - clrlwi r4, r0, 0x18 - rlwinm r0, r0, 0x18, 0x18, 0x1f - cmpw r4, r0 - ble lbl_8026A368 - li r0, 0 - sth r0, 0x2c2(r3) - li r3, 1 - blr - -lbl_8026A368: - li r3, 0 - blr - -lbl_8026A370: - li r3, 1 - blr - */ + if (mAppearCheck != 0) { + mAppearCheck++; + if (GET_APPCHECK_VAL(mAppearCheck) > GET_APPCHECK_MAX(mAppearCheck)) { + mAppearCheck = 0; + return true; + } + return false; + } + + return true; } /* @@ -1314,16 +483,10 @@ void Obj::isAppearCheck() */ void Obj::resetBridgeSearch() { - /* - li r4, 1 - li r0, 0 - stb r4, 0x2c0(r3) - lfs f0, lbl_8051AF70@sda21(r2) - stw r0, 0x2dc(r3) - stfs f0, 0x2e0(r3) - stfs f0, 0x2e4(r3) - blr - */ + _2C0 = 1; + mBridge = nullptr; + _2E0 = 0.0f; + _2E4 = 0.0f; } /* @@ -1333,239 +496,44 @@ void Obj::resetBridgeSearch() */ void Obj::setBridgeSearch() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lbz r0, 0x2c0(r3) - cmplwi r0, 0 - beq lbl_8026A3CC - li r0, 0 - stb r0, 0x2c0(r31) - bl setNearestBridge__Q34Game4Tobi3ObjFv - mr r3, r31 - bl setCullingCheck__Q34Game4Tobi3ObjFv - -lbl_8026A3CC: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (_2C0) { + _2C0 = 0; + setNearestBridge(); + setCullingCheck(); + } } /* * --INFO-- * Address: 8026A3E0 * Size: 0002C0 - */ -void Obj::setNearestBridge() -{ - /* - 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 r31, r3 - li r0, 0 - stw r0, 0x2dc(r3) - lfs f0, lbl_8051AF70@sda21(r2) - stfs f0, 0x2e0(r3) - stfs f0, 0x2e4(r3) - lwz r3, mgr__Q24Game10ItemBridge@sda21(r13) - cmplwi r3, 0 - beq lbl_8026A630 - lwz r4, 0xc0(r31) - lfs f0, 0x35c(r4) - fmuls f31, f0, f0 - beq lbl_8026A434 - addi r3, r3, 0x30 - -lbl_8026A434: - li r0, 0 - lis r4, "__vt__26Iterator"@ha - addi r4, r4, "__vt__26Iterator"@l - stw r0, 0x20(r1) - cmplwi r0, 0 - stw r4, 0x14(r1) - stw r0, 0x18(r1) - stw r3, 0x1c(r1) - bne lbl_8026A470 - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8026A610 - -lbl_8026A470: - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8026A4DC - -lbl_8026A488: - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x20(r1) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_8026A610 - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - -lbl_8026A4DC: - lwz r12, 0x14(r1) - addi r3, r1, 0x14 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_8026A488 - b lbl_8026A610 - -lbl_8026A4FC: - lwz r3, 0x1c(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r0, r3 - addi r3, r1, 8 - mr r30, r0 - mr r4, r30 - bl getStartPos__Q34Game10ItemBridge4ItemFv - lfs f1, 0x194(r31) - lfs f0, 0x10(r1) - lfs f2, 0x18c(r31) - fsubs f1, f1, f0 - lfs f0, 8(r1) - fsubs f2, f2, f0 - fmuls f0, f1, f1 - fmadds f0, f2, f2, f0 - fcmpo cr0, f0, f31 - bge lbl_8026A554 - stw r30, 0x2dc(r31) - fmr f31, f0 - -lbl_8026A554: - lwz r0, 0x20(r1) - cmplwi r0, 0 - bne lbl_8026A580 - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8026A610 - -lbl_8026A580: - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8026A5F4 - -lbl_8026A5A0: - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x20(r1) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_8026A610 - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - -lbl_8026A5F4: - lwz r12, 0x14(r1) - addi r3, r1, 0x14 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_8026A5A0 - -lbl_8026A610: - lwz r3, 0x1c(r1) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - lwz r4, 0x18(r1) - cmplw r4, r3 - bne lbl_8026A4FC - -lbl_8026A630: - lwz r3, 0x2dc(r31) - cmplwi r3, 0 - beq lbl_8026A680 - bl getStageWidth__Q34Game10ItemBridge4ItemFv - lfs f0, lbl_8051AFB8@sda21(r2) - fsubs f31, f1, f0 - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0x2c(r1) - lfd f3, lbl_8051AFB0@sda21(r2) - stw r0, 0x28(r1) - lfs f1, lbl_8051AFA0@sda21(r2) - lfd f2, 0x28(r1) - lfs f0, lbl_8051AF98@sda21(r2) - fsubs f2, f2, f3 - fmuls f2, f31, f2 - fdivs f1, f2, f1 - fnmsubs f0, f0, f31, f1 - stfs f0, 0x2e0(r31) - -lbl_8026A680: - 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 - */ + */ +void Obj::setNearestBridge() +{ + mBridge = nullptr; + _2E0 = 0.0f; + _2E4 = 0.0f; + + if (ItemBridge::mgr) { + f32 radius = C_PARMS->mGeneral.mTerritoryRadius.mValue; + radius = SQUARE(radius); + Iterator iter(ItemBridge::mgr); + CI_LOOP(iter) + { + ItemBridge::Item* bridge = static_cast(*iter); + Vector3f startPos = bridge->getStartPos(); + f32 newRad = sqrDistanceXZ(mPosition, startPos); + if (newRad < radius) { + mBridge = bridge; + radius = newRad; + } + } + } + + if (mBridge) { + f32 width = mBridge->getStageWidth() - 20.0f; + _2E0 = -(0.5f * width - randWeightFloat(width)); + } } /* @@ -1580,137 +548,42 @@ void Obj::setCullingCheck() { } * Address: 8026A6A4 * Size: 0001B4 */ -void Obj::checkBreakOrMove() +int Obj::checkBreakOrMove() { - /* - stwu r1, -0xa0(r1) - mflr r0 - stw r0, 0xa4(r1) - stfd f31, 0x90(r1) - psq_st f31, 152(r1), 0, qr0 - stfd f30, 0x80(r1) - psq_st f30, 136(r1), 0, qr0 - stfd f29, 0x70(r1) - psq_st f29, 120(r1), 0, qr0 - stfd f28, 0x60(r1) - psq_st f28, 104(r1), 0, qr0 - stfd f27, 0x50(r1) - psq_st f27, 88(r1), 0, qr0 - stfd f26, 0x40(r1) - psq_st f26, 72(r1), 0, qr0 - stw r31, 0x3c(r1) - mr r31, r3 - lwz r4, 0x2dc(r3) - cmplwi r4, 0 - beq lbl_8026A810 - addi r3, r1, 0x20 - bl getBridgeZVec__Q34Game10ItemBridge4ItemFv - lfs f28, 0x20(r1) - addi r3, r1, 0x14 - lfs f29, 0x24(r1) - lfs f27, 0x28(r1) - lwz r4, 0x2dc(r31) - bl getStartPos__Q34Game10ItemBridge4ItemFv - lfs f2, 0x18(r1) - lfs f0, 0x190(r31) - lfs f1, 0x14(r1) - fsubs f30, f2, f0 - lfs f0, 0x18c(r31) - lfs f2, 0x1c(r1) - fsubs f31, f1, f0 - lfs f0, 0x194(r31) - fmuls f1, f29, f30 - fsubs f29, f2, f0 - lfs f0, lbl_8051AF70@sda21(r2) - fmadds f1, f28, f31, f1 - fmadds f1, f27, f29, f1 - fcmpo cr0, f1, f0 - ble lbl_8026A758 - li r3, 7 - b lbl_8026A814 - -lbl_8026A758: - lwz r4, 0x2dc(r31) - addi r3, r1, 8 - bl getBridgeXVec__Q34Game10ItemBridge4ItemFv - lfs f27, 8(r1) - lfs f28, 0xc(r1) - lfs f26, 0x10(r1) - lwz r3, 0x2dc(r31) - bl getStageWidth__Q34Game10ItemBridge4ItemFv - fmuls f3, f28, f30 - lfs f0, lbl_8051AF98@sda21(r2) - lfs f2, lbl_8051AFB8@sda21(r2) - fmuls f4, f0, f1 - lfs f0, lbl_8051AF70@sda21(r2) - fmadds f1, f27, f31, f3 - fadds f2, f2, f4 - fmadds f1, f26, f29, f1 - fcmpo cr0, f1, f0 - bge lbl_8026A7A8 - stfs f2, 0x2e4(r31) - b lbl_8026A7B0 + if (mBridge) { + Vector3f zVec = mBridge->getBridgeZVec(); + Vector3f startPos = mBridge->getStartPos(); -lbl_8026A7A8: - fneg f0, f2 - stfs f0, 0x2e4(r31) + Vector3f bridgeDist = startPos - mPosition; + if (zVec.dot(bridgeDist) > 0.0f) { + return TOBI_MoveCentre; + } -lbl_8026A7B0: - lfs f0, lbl_8051AF70@sda21(r2) - fcmpo cr0, f1, f0 - ble lbl_8026A7C0 - b lbl_8026A7C4 + Vector3f xVec = mBridge->getBridgeXVec(); + f32 halfWidth = 0.5f * mBridge->getStageWidth(); + f32 dotX = xVec.dot(bridgeDist); + f32 width = 20.0f + halfWidth; -lbl_8026A7C0: - fneg f1, f1 + if (dotX < 0.0f) { + _2E4 = width; + } else { + _2E4 = -width; + } -lbl_8026A7C4: - fcmpo cr0, f1, f4 - ble lbl_8026A7D4 - li r3, 6 - b lbl_8026A814 + if (absVal(dotX) > halfWidth) { + return TOBI_MoveSide; + } -lbl_8026A7D4: - lwz r3, mapMgr__4Game@sda21(r13) - addi r4, r31, 0x18c - lwz r12, 4(r3) - lwz r12, 0x28(r12) - mtctr r12 - bctrl - lfs f0, lbl_8051AFBC@sda21(r2) - lfs f2, 0x190(r31) - fadds f0, f0, f1 - fcmpo cr0, f2, f0 - ble lbl_8026A808 - li r3, 8 - b lbl_8026A814 + f32 minY = mapMgr->getMinY(mPosition); -lbl_8026A808: - li r3, 6 - b lbl_8026A814 + if (mPosition.y > 5.0f + minY) { + return TOBI_MoveTop; + } -lbl_8026A810: - li r3, 7 + return TOBI_MoveSide; + } -lbl_8026A814: - psq_l f31, 152(r1), 0, qr0 - lfd f31, 0x90(r1) - psq_l f30, 136(r1), 0, qr0 - lfd f30, 0x80(r1) - psq_l f29, 120(r1), 0, qr0 - lfd f29, 0x70(r1) - psq_l f28, 104(r1), 0, qr0 - lfd f28, 0x60(r1) - psq_l f27, 88(r1), 0, qr0 - lfd f27, 0x50(r1) - psq_l f26, 72(r1), 0, qr0 - lfd f26, 0x40(r1) - lwz r0, 0xa4(r1) - lwz r31, 0x3c(r1) - mtlr r0 - addi r1, r1, 0xa0 - blr - */ + return TOBI_MoveCentre; } /* @@ -1718,22 +591,13 @@ void Obj::checkBreakOrMove() * Address: 8026A858 * Size: 000028 */ -void Obj::isBreakBridge() +bool Obj::isBreakBridge() { - /* - lwz r3, 0x2dc(r3) - cmplwi r3, 0 - beq lbl_8026A878 - lwz r0, 0x218(r3) - cmpwi r0, 0 - beq lbl_8026A878 - li r3, 1 - blr + if (mBridge && mBridge->mStagesRemaining != 0) { + return true; + } -lbl_8026A878: - li r3, 0 - blr - */ + return false; } /* @@ -1741,8 +605,44 @@ void Obj::isBreakBridge() * Address: 8026A880 * Size: 0002A8 */ -void Obj::moveBridgeSide() +bool Obj::moveBridgeSide() { + Vector3f startPos = mBridge->getStartPos(); + Vector3f xVec = mBridge->getBridgeXVec(); + Vector3f zVec = mBridge->getBridgeZVec(); + + xVec *= _2E4; + zVec *= -20.0f; + + startPos += xVec; + startPos += zVec; + + if (sqrDistanceXZ(mPosition, startPos) < 250.0f) { + f32 speed = 0.75f * C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return true; + + } else { + changeFaceDir(startPos); + + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return false; + } /* stwu r1, -0xa0(r1) mflr r0 @@ -1930,180 +830,41 @@ void Obj::moveBridgeSide() * Address: 8026AB28 * Size: 000288 */ -void Obj::moveBridgeCentre() +bool Obj::moveBridgeCentre() { - /* - stwu r1, -0x90(r1) - mflr r0 - stw r0, 0x94(r1) - stfd f31, 0x80(r1) - psq_st f31, 136(r1), 0, qr0 - stfd f30, 0x70(r1) - psq_st f30, 120(r1), 0, qr0 - stfd f29, 0x60(r1) - psq_st f29, 104(r1), 0, qr0 - stfd f28, 0x50(r1) - psq_st f28, 88(r1), 0, qr0 - stw r31, 0x4c(r1) - mr r31, r3 - addi r3, r1, 0x38 - lwz r4, 0x2dc(r31) - bl getStartPos__Q34Game10ItemBridge4ItemFv - lfs f29, 0x38(r1) - addi r3, r1, 0x2c - lfs f28, 0x40(r1) - lwz r4, 0x2dc(r31) - bl getBridgeXVec__Q34Game10ItemBridge4ItemFv - lfs f1, lbl_8051AFD4@sda21(r2) - lfs f0, 0x2e0(r31) - lfs f5, 0x34(r1) - fmuls f3, f1, f0 - lfs f4, 0x2c(r1) - lfs f1, 0x194(r31) - lfs f2, 0x18c(r31) - fmuls f5, f5, f3 - lfs f0, lbl_8051AFC4@sda21(r2) - fmuls f4, f4, f3 - fadds f28, f28, f5 - fadds f29, f29, f4 - fsubs f1, f1, f28 - fsubs f2, f2, f29 - fmuls f1, f1, f1 - fmadds f1, f2, f2, f1 - fcmpo cr0, f1, f0 - bge lbl_8026AC40 - mr r3, r31 - lwz r4, 0xc0(r31) - lwz r12, 0(r31) - lfs f1, lbl_8051AFC8@sda21(r2) - lfs f0, 0x2e4(r4) - lwz r12, 0x64(r12) - fmuls f30, f1, f0 - mtctr r12 - bctrl - bl sin - mr r3, r31 - lfs f2, 0x1d4(r31) - lwz r12, 0(r31) - frsp f29, f1 - lfs f31, 0x1d8(r31) - lfs f0, 0x1dc(r31) - lwz r12, 0x64(r12) - stfs f2, 0x20(r1) - stfs f31, 0x24(r1) - stfs f0, 0x28(r1) - mtctr r12 - bctrl - bl cos - fmuls f0, f30, f29 - li r3, 1 - frsp f1, f1 - stfs f0, 0x1d4(r31) - fmuls f0, f30, f1 - stfs f31, 0x1d8(r31) - stfs f0, 0x1dc(r31) - b lbl_8026AD7C + Vector3f startPos = mBridge->getStartPos(); + Vector3f xVec = mBridge->getBridgeXVec(); -lbl_8026AC40: - mr r4, r31 - lwz r5, 0xc0(r31) - lwz r12, 0(r31) - addi r3, r1, 8 - lfs f31, 0x334(r5) - lwz r12, 8(r12) - lfs f30, 0x30c(r5) - mtctr r12 - bctrl - lfs f1, 8(r1) - lis r3, atanTable___5JMath@ha - lfs f0, 0x10(r1) - addi r3, r3, atanTable___5JMath@l - fsubs f1, f29, f1 - fsubs f2, f28, f0 - bl "atan2___Q25JMath18TAtanTable<1024,f>CFff" - bl roundAng__Ff - lwz r12, 0(r31) - fmr f29, f1 - mr r3, r31 - lwz r12, 0x64(r12) - mtctr r12 - bctrl - fmr f2, f1 - fmr f1, f29 - bl angDist__Fff - fmuls f30, f1, f30 - lfs f0, lbl_8051AFD0@sda21(r2) - lfs f1, lbl_8051AFCC@sda21(r2) - fmuls f0, f0, f31 - fabs f2, f30 - fmuls f1, f1, f0 - frsp f0, f2 - fcmpo cr0, f0, f1 - ble lbl_8026ACE4 - lfs f0, lbl_8051AF70@sda21(r2) - fcmpo cr0, f30, f0 - ble lbl_8026ACE0 - fmr f30, f1 - b lbl_8026ACE4 + xVec *= 0.7f * _2E0; -lbl_8026ACE0: - fneg f30, f1 + startPos += xVec; -lbl_8026ACE4: - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 0x64(r12) - mtctr r12 - bctrl - fadds f1, f30, f1 - bl roundAng__Ff - stfs f1, 0x1fc(r31) - mr r3, r31 - lfs f0, 0x1fc(r31) - stfs f0, 0x1a8(r31) - lwz r12, 0(r31) - lwz r4, 0xc0(r31) - lwz r12, 0x64(r12) - lfs f30, 0x2e4(r4) - mtctr r12 - bctrl - bl sin - mr r3, r31 - lfs f2, 0x1d4(r31) - lwz r12, 0(r31) - frsp f29, f1 - lfs f31, 0x1d8(r31) - lfs f0, 0x1dc(r31) - lwz r12, 0x64(r12) - stfs f2, 0x14(r1) - stfs f31, 0x18(r1) - stfs f0, 0x1c(r1) - mtctr r12 - bctrl - bl cos - fmuls f0, f30, f29 - li r3, 0 - frsp f1, f1 - stfs f0, 0x1d4(r31) - fmuls f0, f30, f1 - stfs f31, 0x1d8(r31) - stfs f0, 0x1dc(r31) + if (sqrDistanceXZ(mPosition, startPos) < 250.0f) { + f32 speed = 0.75f * C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); -lbl_8026AD7C: - psq_l f31, 136(r1), 0, qr0 - lfd f31, 0x80(r1) - psq_l f30, 120(r1), 0, qr0 - lfd f30, 0x70(r1) - psq_l f29, 104(r1), 0, qr0 - lfd f29, 0x60(r1) - psq_l f28, 88(r1), 0, qr0 - lfd f28, 0x50(r1) - lwz r0, 0x94(r1) - lwz r31, 0x4c(r1) - mtlr r0 - addi r1, r1, 0x90 - blr - */ + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return true; + + } else { + changeFaceDir(startPos); + + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return false; + } } /* @@ -2111,8 +872,54 @@ void Obj::moveBridgeCentre() * Address: 8026ADB0 * Size: 0002F0 */ -void Obj::moveBridgeTop() +bool Obj::moveBridgeTop() { + int stageID = mBridge->mStagesRemaining - 1; + Vector3f stagePos = mBridge->getStagePos(stageID); + Vector3f xVec = mBridge->getBridgeXVec(); + + xVec *= _2E0; + + stagePos += xVec; + + if (stageID > 0) { + Vector3f zVec = mBridge->getBridgeZVec(); + zVec *= -20.0f; + stagePos += zVec; + } + + changeFaceDir(stagePos); + + f32 dist = sqrDistanceXZ(mPosition, stagePos); + + if (dist < 50.0f) { + mTargetVelocity = Vector3f(0.0f); + return true; + + } else if (dist < 250.0f) { + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return true; + + } else { + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + } + + return false; /* stwu r1, -0xb0(r1) mflr r0 @@ -2324,31 +1131,8 @@ void Obj::moveBridgeTop() */ void Obj::breakTargetBridge() { - /* - stwu r1, -0x20(r1) - mflr r0 - lis r4, __vt__Q24Game11Interaction@ha - lis r5, __vt__Q24Game19InteractBreakBridge@ha - stw r0, 0x24(r1) - addi r6, r4, __vt__Q24Game11Interaction@l - addi r0, r5, __vt__Q24Game19InteractBreakBridge@l - addi r4, r1, 8 - lwz r7, 0xc0(r3) - lfs f0, 0x8bc(r7) - stw r6, 8(r1) - stw r3, 0xc(r1) - stw r0, 8(r1) - stfs f0, 0x10(r1) - lwz r3, 0x2dc(r3) - lwz r12, 0(r3) - lwz r12, 0x1a4(r12) - mtctr r12 - bctrl - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + InteractBreakBridge breakBridge(this, C_PROPERPARMS.mBridgeDamage.mValue); + mBridge->stimulate(breakBridge); } /* @@ -2358,43 +1142,9 @@ void Obj::breakTargetBridge() */ void Obj::createAppearEffect() { - /* - stwu r1, -0x20(r1) - mflr r0 - lis r4, lbl_80485E80@ha - stw r0, 0x24(r1) - addi r4, r4, lbl_80485E80@l - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lis r4, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r4, __vt__Q23efx5TBase@l - lis r4, __vt__Q23efx8TSimple2@ha - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx8TSimple2@l - lis r5, __vt__Q23efx11TSimpleMtx2@ha - lis r4, __vt__Q23efx9TUjinkoAp@ha - stw r0, 8(r1) - addi r0, r5, __vt__Q23efx11TSimpleMtx2@l - li r7, 0x1ce - li r5, 0x1cf - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx9TUjinkoAp@l - li r4, 0 - stw r3, 0x18(r1) - addi r3, r1, 8 - sth r7, 0xc(r1) - sth r5, 0xe(r1) - stw r6, 0x10(r1) - stw r6, 0x14(r1) - stw r0, 8(r1) - bl create__Q23efx11TSimpleMtx2FPQ23efx3Arg - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + Matrixf* worldMat = mModel->getJoint("tobinnko")->getWorldMatrix(); + efx::TUjinkoAp appearFX(worldMat); + appearFX.create(nullptr); } /* @@ -2404,43 +1154,9 @@ void Obj::createAppearEffect() */ void Obj::createDisAppearEffect() { - /* - stwu r1, -0x20(r1) - mflr r0 - lis r4, lbl_80485E80@ha - stw r0, 0x24(r1) - addi r4, r4, lbl_80485E80@l - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lis r4, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r4, __vt__Q23efx5TBase@l - lis r4, __vt__Q23efx8TSimple2@ha - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx8TSimple2@l - lis r5, __vt__Q23efx11TSimpleMtx2@ha - lis r4, __vt__Q23efx9TUjinkoHd@ha - stw r0, 8(r1) - addi r0, r5, __vt__Q23efx11TSimpleMtx2@l - li r7, 0x1d1 - li r5, 0x1d2 - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx9TUjinkoHd@l - li r4, 0 - stw r3, 0x18(r1) - addi r3, r1, 8 - sth r7, 0xc(r1) - sth r5, 0xe(r1) - stw r6, 0x10(r1) - stw r6, 0x14(r1) - stw r0, 8(r1) - bl create__Q23efx11TSimpleMtx2FPQ23efx3Arg - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + Matrixf* worldMat = mModel->getJoint("tobinnko")->getWorldMatrix(); + efx::TUjinkoHd hideFX(worldMat); + hideFX.create(nullptr); } /* @@ -2450,44 +1166,10 @@ void Obj::createDisAppearEffect() */ void Obj::createBridgeEffect() { - /* - stwu r1, -0x30(r1) - mflr r0 - addi r4, r2, lbl_8051AF88@sda21 - stw r0, 0x34(r1) - 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__Q23efx10TUjinkoEat@ha - addi r4, r5, __vt__Q23efx3Arg@l - li r6, 0x1d0 - li r5, 0 - stw r0, 8(r1) - addi r0, r3, __vt__Q23efx10TUjinkoEat@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("kamujnt")->getWorldMatrix()->getBasis(3); + efx::Arg fxArg(fxPos); + efx::TUjinkoEat eatFX; + eatFX.create(&fxArg); } /* @@ -2497,44 +1179,10 @@ void Obj::createBridgeEffect() */ void Obj::createEatEffect() { - /* - stwu r1, -0x30(r1) - mflr r0 - addi r4, r2, lbl_8051AF88@sda21 - stw r0, 0x34(r1) - 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__Q23efx12TUjinkoPkate@ha - addi r4, r5, __vt__Q23efx3Arg@l - li r6, 0x25e - li r5, 0 - stw r0, 8(r1) - addi r0, r3, __vt__Q23efx12TUjinkoPkate@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("kamujnt")->getWorldMatrix()->getBasis(3); + efx::Arg fxArg(fxPos); + efx::TUjinkoPkate eatFX; + eatFX.create(&fxArg); } /* @@ -2542,39 +1190,21 @@ void Obj::createEatEffect() * Address: 8026B334 * Size: 000008 */ -bool Obj::isUnderground() -{ - /* - lbz r3, 0x2c1(r3) - blr - */ -} +bool Obj::isUnderground() { return mIsUnderground; } /* * --INFO-- * Address: 8026B33C * Size: 000008 */ -MouthSlots* Obj::getMouthSlots() -{ - /* - addi r3, r3, 0x2c8 - blr - */ -} +MouthSlots* Obj::getMouthSlots() { return &mMouthSlots; } /* * --INFO-- * Address: 8026B344 * Size: 000008 */ -f32 Obj::getDownSmokeScale() -{ - /* - lfs f1, lbl_8051AFD8@sda21(r2) - blr - */ -} +f32 Obj::getDownSmokeScale() { return 0.35f; } /* * --INFO-- diff --git a/src/plugProjectNishimuraU/Ujia.cpp b/src/plugProjectNishimuraU/Ujia.cpp index d4f016f8d..ce07e7f59 100644 --- a/src/plugProjectNishimuraU/Ujia.cpp +++ b/src/plugProjectNishimuraU/Ujia.cpp @@ -221,9 +221,9 @@ void Obj::setBridgeSearch() */ void Obj::setNearestBridge() { - this->mBridge = nullptr; - this->_2CC = 0.0f; - this->_2D0 = 0.0f; + mBridge = nullptr; + _2CC = 0.0f; + _2D0 = 0.0f; if (ItemBridge::mgr) { f32 radius = C_PARMS->mGeneral.mTerritoryRadius.mValue; diff --git a/src/plugProjectNishimuraU/Ujib.cpp b/src/plugProjectNishimuraU/Ujib.cpp index ae9d19421..b955ca923 100644 --- a/src/plugProjectNishimuraU/Ujib.cpp +++ b/src/plugProjectNishimuraU/Ujib.cpp @@ -1,419 +1,21 @@ -#include "types.h" - -/* - Generated from dpostproc - - .section .rodata # 0x804732E0 - 0x8049E220 - .global lbl_80485358 - lbl_80485358: - .4byte 0x756A696E - .4byte 0x6E6B6F5F - .4byte 0x6F000000 - .4byte 0x00000000 - - .section .data, "wa" # 0x8049E220 - 0x804EFC20 - .global __vt__Q23efx12TUjinkoPkate - __vt__Q23efx12TUjinkoPkate: - .4byte 0 - .4byte 0 - .4byte create__Q23efx8TSimple1FPQ23efx3Arg - .4byte forceKill__Q23efx8TSimple1Fv - .4byte fade__Q23efx8TSimple1Fv - .global __vt__Q23efx10TUjinkoEat - __vt__Q23efx10TUjinkoEat: - .4byte 0 - .4byte 0 - .4byte create__Q23efx8TSimple1FPQ23efx3Arg - .4byte forceKill__Q23efx8TSimple1Fv - .4byte fade__Q23efx8TSimple1Fv - .global __vt__Q23efx9TUjinkoHd - __vt__Q23efx9TUjinkoHd: - .4byte 0 - .4byte 0 - .4byte create__Q23efx11TSimpleMtx2FPQ23efx3Arg - .4byte forceKill__Q23efx8TSimple2Fv - .4byte fade__Q23efx8TSimple2Fv - .global __vt__Q23efx9TUjinkoAp - __vt__Q23efx9TUjinkoAp: - .4byte 0 - .4byte 0 - .4byte create__Q23efx11TSimpleMtx2FPQ23efx3Arg - .4byte forceKill__Q23efx8TSimple2Fv - .4byte fade__Q23efx8TSimple2Fv - .global __vt__Q34Game4Ujib3Obj - __vt__Q34Game4Ujib3Obj: - .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__Q34Game4Ujib3ObjFPQ24Game15CreatureInitArg - .4byte onKill__Q24Game9EnemyBaseFPQ24Game15CreatureKillArg - .4byte onInitPost__Q24Game9EnemyBaseFPQ24Game15CreatureInitArg - .4byte doAnimation__Q24Game9EnemyBaseFv - .4byte doEntry__Q24Game9EnemyBaseFv - .4byte doSetView__Q24Game9EnemyBaseFi - .4byte doViewCalc__Q24Game9EnemyBaseFv - .4byte doSimulation__Q24Game9EnemyBaseFf - .4byte doDirectDraw__Q34Game4Ujib3ObjFR8Graphics - .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__Q24Game9EnemyBaseFPQ24Game8WaterBox - .4byte outWaterCallback__Q24Game9EnemyBaseFv - .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__Q34Game4Ujib3ObjFv - .4byte isLivingThing__Q24Game8CreatureFv - .4byte isDebugCollision__Q24Game8CreatureFv - .4byte setDebugCollision__Q24Game8CreatureFb - .4byte doSave__Q24Game8CreatureFR6Stream - .4byte doLoad__Q24Game8CreatureFR6Stream - .4byte bounceCallback__Q24Game8CreatureFPQ23Sys8Triangle - .4byte collisionCallback__Q24Game9EnemyBaseFRQ24Game9CollEvent - .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__Q34Game4Ujib3ObjFRQ24Game11ShadowParam - .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__Q34Game4Ujib3ObjFv - .4byte "birth__Q24Game9EnemyBaseFR10Vector3f" - .4byte - setInitialSetting__Q34Game4Ujib3ObjFPQ24Game21EnemyInitialParamBase .4byte - update__Q24Game9EnemyBaseFv .4byte doUpdate__Q34Game4Ujib3ObjFv .4byte - doUpdateCommon__Q24Game9EnemyBaseFv .4byte - doUpdateCarcass__Q24Game9EnemyBaseFv .4byte - doAnimationUpdateAnimator__Q24Game9EnemyBaseFv .4byte - doAnimationCullingOff__Q24Game9EnemyBaseFv .4byte - doAnimationCullingOn__Q24Game9EnemyBaseFv .4byte - doAnimationStick__Q24Game9EnemyBaseFv .4byte - doSimulationCarcass__Q24Game9EnemyBaseFf .4byte - doDebugDraw__Q34Game4Ujib3ObjFR8Graphics .4byte - doSimpleDraw__Q24Game9EnemyBaseFP8Viewport .4byte - doSimulationGround__Q24Game9EnemyBaseFf .4byte - doSimulationFlying__Q24Game9EnemyBaseFf .4byte - doSimulationStick__Q24Game9EnemyBaseFf .4byte - changeMaterial__Q24Game9EnemyBaseFv .4byte - "getCommonEffectPos__Q24Game9EnemyBaseFR10Vector3" .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__Q24Game9EnemyBaseFv - .4byte setParameters__Q24Game9EnemyBaseFv - .4byte initMouthSlots__Q34Game4Ujib3ObjFv - .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__Q34Game4Ujib3ObjFv - .4byte getMouthSlots__Q34Game4Ujib3ObjFv - .4byte doGetLifeGaugeParam__Q24Game9EnemyBaseFRQ24Game14LifeGaugeParam - .4byte throwupItem__Q24Game9EnemyBaseFv - .4byte "getThrowupItemPosition__Q24Game9EnemyBaseFP10Vector3" - .4byte "getThrowupItemVelocity__Q24Game9EnemyBaseFP10Vector3" - .4byte throwupItemInDeathProcedure__Q24Game9EnemyBaseFv - .4byte setLODSphere__Q24Game9EnemyBaseFRQ23Sys6Sphere - .4byte damageCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart - .4byte pressCallBack__Q34Game4Ujib3ObjFPQ24Game8CreaturefP8CollPart - .4byte - flyCollisionCallBack__Q24Game9EnemyBaseFPQ24Game8CreaturefP8CollPart .4byte - hipdropCallBack__Q34Game4Ujib3ObjFPQ24Game8CreaturefP8CollPart .4byte - dropCallBack__Q24Game9EnemyBaseFPQ24Game8Creature .4byte - earthquakeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - farmCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - "bombCallBack__Q24Game9EnemyBaseFPQ24Game8CreatureR10Vector3f" .4byte - eatWhitePikminCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturef .4byte - dopeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturei .4byte - doDopeCallBack__Q24Game9EnemyBaseFPQ24Game8Creaturei .4byte - doStartStoneState__Q24Game9EnemyBaseFv .4byte - doFinishStoneState__Q24Game9EnemyBaseFv .4byte - getDamageCoeStoneState__Q24Game9EnemyBaseFv .4byte - doStartEarthquakeState__Q24Game9EnemyBaseFf .4byte - doFinishEarthquakeState__Q24Game9EnemyBaseFv .4byte - doStartEarthquakeFitState__Q24Game9EnemyBaseFv .4byte - doFinishEarthquakeFitState__Q24Game9EnemyBaseFv .4byte - lifeRecover__Q24Game9EnemyBaseFv .4byte - startCarcassMotion__Q34Game4Ujib3ObjFv .4byte - setCarcassArg__Q24Game9EnemyBaseFRQ24Game13PelletViewArg .4byte - getCarcassArgHeight__Q24Game9EnemyBaseFv .4byte - doBecomeCarcass__Q24Game9EnemyBaseFv .4byte - startWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - finishWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - isFinishableWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - doStartWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - doFinishWaitingBirthTypeDrop__Q24Game9EnemyBaseFv .4byte - wallCallback__Q24Game9EnemyBaseFRCQ24Game8MoveInfo .4byte - getDownSmokeScale__Q34Game4Ujib3ObjFv .4byte - doStartMovie__Q24Game9EnemyBaseFv .4byte doEndMovie__Q24Game9EnemyBaseFv - .4byte setFSM__Q34Game4Ujib3ObjFPQ34Game4Ujib3FSM - .4byte 0 - .4byte 0 - .4byte viewGetBaseScale__Q24Game10PelletViewFv - .4byte "@732@12@viewGetShape__Q24Game9EnemyBaseFv" - .4byte viewGetCollTreeJointIndex__Q24Game10PelletViewFv - .4byte viewGetCollTreeOffset__Q24Game10PelletViewFv - .4byte "@732@12@view_start_carrymotion__Q24Game9EnemyBaseFv" - .4byte "@732@12@view_finish_carrymotion__Q24Game9EnemyBaseFv" - .4byte "@732@12@viewStartPreCarryMotion__Q24Game9EnemyBaseFv" - .4byte "@732@12@viewStartCarryMotion__Q24Game9EnemyBaseFv" - .4byte "@732@12@viewOnPelletKilled__Q24Game9EnemyBaseFv" - .4byte "viewEntryShape__Q24Game10PelletViewFR7MatrixfR10Vector3" - .4byte 0 - - .section .sdata2, "a" # 0x80516360 - 0x80520E40 - .global lbl_8051AB30 - lbl_8051AB30: - .4byte 0x6B6F7369 - .4byte 0x6A6E7400 - .global lbl_8051AB38 - lbl_8051AB38: - .4byte 0x40200000 - .global lbl_8051AB3C - lbl_8051AB3C: - .4byte 0x00000000 - .global lbl_8051AB40 - lbl_8051AB40: - .float 1.0 - .global lbl_8051AB44 - lbl_8051AB44: - .4byte 0x42480000 - .global lbl_8051AB48 - lbl_8051AB48: - .4byte 0x41700000 - .global lbl_8051AB4C - lbl_8051AB4C: - .4byte 0x41000000 - .global lbl_8051AB50 - lbl_8051AB50: - .4byte 0x6B616D75 - .4byte 0x6A6E7400 - .global lbl_8051AB58 - lbl_8051AB58: - .4byte 0x40000000 - .global lbl_8051AB5C - lbl_8051AB5C: - .4byte 0x41F00000 - .global lbl_8051AB60 - lbl_8051AB60: - .4byte 0x47000000 - .4byte 0x00000000 - .global lbl_8051AB68 - lbl_8051AB68: - .4byte 0x43300000 - .4byte 0x80000000 - .global lbl_8051AB70 - lbl_8051AB70: - .4byte 0x41A00000 - .global lbl_8051AB74 - lbl_8051AB74: - .float 0.5 - .global lbl_8051AB78 - lbl_8051AB78: - .4byte 0x40A00000 - .global lbl_8051AB7C - lbl_8051AB7C: - .4byte 0xC1A00000 - .global lbl_8051AB80 - lbl_8051AB80: - .4byte 0x437A0000 - .global lbl_8051AB84 - lbl_8051AB84: - .4byte 0x3F400000 - .global lbl_8051AB88 - lbl_8051AB88: - .4byte 0x40490FDB - .global lbl_8051AB8C - lbl_8051AB8C: - .4byte 0x3BB60B61 - .global lbl_8051AB90 - lbl_8051AB90: - .float 0.7 - .global lbl_8051AB94 - lbl_8051AB94: - .4byte 0x3EB33333 -*/ +#include "Game/Entities/Ujib.h" +#include "Game/Entities/ItemBridge.h" +#include "Game/MapMgr.h" +#include "efx/TUjinko.h" +#include "Dolphin/rand.h" namespace Game { +namespace Ujib { /* * --INFO-- * Address: 80259B4C * Size: 000138 */ -Ujib::Obj::Obj() +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_80259B8C - addi r0, r31, 0x2dc - lis r3, __vt__Q24Game10PelletView@ha - stw r0, 0x17c(r31) - addi r3, r3, __vt__Q24Game10PelletView@l - li r0, 0 - stw r3, 0x2dc(r31) - stw r0, 0x2e0(r31) - stw r0, 0x2e4(r31) - -lbl_80259B8C: - mr r3, r31 - li r4, 0 - bl __ct__Q24Game9EnemyBaseFv - lis r3, __vt__Q34Game4Ujib3Obj@ha - addi r0, r31, 0x2dc - addi r5, r3, __vt__Q34Game4Ujib3Obj@l - addi r3, r31, 0x2c8 - stw r5, 0(r31) - addi r4, r5, 0x1b0 - addi r5, r5, 0x2fc - 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 __ct__10MouthSlotsFv - li r3, 0x2c - bl __nw__FUl - or. r30, r3, r3 - beq lbl_80259C20 - bl __ct__Q24Game17EnemyAnimatorBaseFv - lis r3, __vt__Q34Game4Ujib14ProperAnimator@ha - lis r4, __vt__Q28SysShape12BaseAnimator@ha - addi r0, r3, __vt__Q34Game4Ujib14ProperAnimator@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_80259C20: - stw r30, 0x184(r31) - li r3, 0x1c - bl __nw__FUl - or. r4, r3, r3 - beq lbl_80259C54 - lis r5, __vt__Q24Game17EnemyStateMachine@ha - lis r3, __vt__Q34Game4Ujib3FSM@ha - addi r0, r5, __vt__Q24Game17EnemyStateMachine@l - li r5, -1 - stw r0, 0(r4) - addi r0, r3, __vt__Q34Game4Ujib3FSM@l - stw r5, 0x18(r4) - stw r0, 0(r4) - -lbl_80259C54: - lwz r12, 0(r31) - mr r3, r31 - lwz r12, 0x2f8(r12) - mtctr r12 - bctrl - 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); } /* @@ -421,55 +23,24 @@ Ujib::Obj::Obj() * Address: 80259C84 * Size: 000004 */ -void Ujib::Obj::setInitialSetting(Game::EnemyInitialParamBase*) { } +void Obj::setInitialSetting(EnemyInitialParamBase*) { } /* * --INFO-- * Address: 80259C88 * Size: 000098 */ -void Ujib::Obj::onInit(Game::CreatureInitArg*) +void Obj::onInit(CreatureInitArg* initArg) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl onInit__Q24Game9EnemyBaseFPQ24Game15CreatureInitArg - lwz r0, 0x1e0(r31) - mr r3, r31 - rlwinm r0, r0, 0, 0x15, 0x13 - stw r0, 0x1e0(r31) - lwz r0, 0x1e0(r31) - rlwinm r0, r0, 0, 0x1a, 0x18 - stw r0, 0x1e0(r31) - bl resetAppearCheck__Q34Game4Ujib3ObjFv - li r3, 0 - li r0, -1 - stb r3, 0x2c1(r31) - mr r3, r31 - stw r0, 0x2c4(r31) - bl resetBridgeSearch__Q34Game4Ujib3ObjFv - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 2 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0xc(r12) - mtctr r12 - bctrl - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 0x1dc(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + EnemyBase::onInit(initArg); + disableEvent(0, EB_LifegaugeVisible); + disableEvent(0, EB_Cullable); + resetAppearCheck(); + mIsUnderground = false; + mNextState = UJIB_NULL; + resetBridgeSearch(); + mFsm->start(this, UJIB_Stay, nullptr); + doAnimationCullingOff(); } /* @@ -477,28 +48,10 @@ void Ujib::Obj::onInit(Game::CreatureInitArg*) * Address: 80259D20 * Size: 000048 */ -void Ujib::Obj::doUpdate() +void Obj::doUpdate() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - mr r4, r31 - lwz r3, 0x2bc(r3) - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - addi r3, r31, 0x2c8 - bl update__10MouthSlotsFv - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + mFsm->exec(this); + mMouthSlots.update(); } /* @@ -506,55 +59,25 @@ void Ujib::Obj::doUpdate() * Address: 80259D68 * Size: 000004 */ -void Ujib::Obj::doDirectDraw(Graphics&) { } +void Obj::doDirectDraw(Graphics&) { } /* * --INFO-- * Address: 80259D6C * Size: 000020 */ -void Ujib::Obj::doDebugDraw(Graphics&) -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - bl doDebugDraw__Q24Game9EnemyBaseFR8Graphics - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::doDebugDraw(Graphics& gfx) { EnemyBase::doDebugDraw(gfx); } /* * --INFO-- * Address: 80259D8C * Size: 00004C */ -void Ujib::Obj::setFSM(Game::Ujib::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; } /* @@ -562,56 +85,18 @@ void Ujib::Obj::setFSM(Game::Ujib::FSM*) * Address: 80259DD8 * Size: 0000A8 */ -void Ujib::Obj::getShadowParam(Game::ShadowParam&) +void Obj::getShadowParam(ShadowParam& shadowParam) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r4 - addi r4, r2, lbl_8051AB30@sda21 - stw r30, 8(r1) - mr r30, r3 - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lfs f4, 0x2c(r3) - lfs f3, 0x1c(r3) - lfs f0, 0xc(r3) - lfs f2, lbl_8051AB38@sda21(r2) - stfs f0, 0(r31) - lfs f1, lbl_8051AB3C@sda21(r2) - stfs f3, 4(r31) - lfs f0, lbl_8051AB40@sda21(r2) - stfs f4, 8(r31) - lfs f3, 4(r31) - fsubs f2, f3, f2 - stfs f2, 4(r31) - stfs f1, 0xc(r31) - stfs f0, 0x10(r31) - stfs f1, 0x14(r31) - lwz r0, 0x1e4(r30) - clrlwi. r0, r0, 0x1f - beq lbl_80259E58 - lfs f0, lbl_8051AB44@sda21(r2) - stfs f0, 0x18(r31) - b lbl_80259E60 - -lbl_80259E58: - lfs f0, lbl_8051AB48@sda21(r2) - stfs f0, 0x18(r31) - -lbl_80259E60: - lfs f0, lbl_8051AB4C@sda21(r2) - stfs f0, 0x1c(r31) - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + shadowParam.mPosition = mModel->getJoint("kosijnt")->getWorldMatrix()->getBasis(3); + shadowParam.mPosition.y -= 2.5f; + shadowParam.mBoundingSphere.mPosition = Vector3f(0.0f, 1.0f, 0.0f); + if (isEvent(1, EB2_Earthquake)) { + shadowParam.mBoundingSphere.mRadius = 50.0f; + } else { + shadowParam.mBoundingSphere.mRadius = 15.0f; + } + + shadowParam.mSize = 8.0f; } /* @@ -619,51 +104,15 @@ void Ujib::Obj::getShadowParam(Game::ShadowParam&) * Address: 80259E80 * Size: 000094 */ -void Ujib::Obj::pressCallBack(Game::Creature*, float, CollPart*) +bool Obj::pressCallBack(Creature* creature, f32 damage, CollPart* part) { - /* - stwu r1, -0x10(r1) - mflr r0 - cmplwi r4, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - beq lbl_80259EFC - mr r3, r4 - lwz r12, 0(r4) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_80259EFC - lwz r0, 0x1e0(r31) - rlwinm. r0, r0, 0, 0x16, 0x16 - bne lbl_80259EFC - mr r3, r31 - bl getStateID__Q24Game9EnemyBaseFv - cmpwi r3, 4 - ble lbl_80259EFC - lwz r3, 0x2bc(r31) - mr r4, r31 - li r5, 1 - li r6, 0 - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - li r3, 1 - b lbl_80259F00 - -lbl_80259EFC: - li r3, 0 + if (creature && creature->isPiki() && !isEvent(0, EB_Bittered) && getStateID() > UJIB_Dive) { + // i.e. not in dead, press, stay, appear, or dive states + mFsm->transit(this, UJIB_Press, nullptr); + return true; + } -lbl_80259F00: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + return false; } /* @@ -671,92 +120,27 @@ void Ujib::Obj::pressCallBack(Game::Creature*, float, CollPart*) * Address: 80259F14 * Size: 00002C */ -void Ujib::Obj::hipdropCallBack(Game::Creature*, float, CollPart*) -{ - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r12, 0(r3) - lwz r12, 0x27c(r12) - mtctr r12 - bctrl - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +bool Obj::hipdropCallBack(Creature* creature, f32 damage, CollPart* part) { return pressCallBack(creature, damage, part); } /* * --INFO-- * Address: 80259F40 * Size: 000028 */ -void Ujib::Obj::startCarcassMotion() -{ - /* - stwu r1, -0x10(r1) - mflr r0 - li r4, 8 - li r5, 0 - stw r0, 0x14(r1) - bl startMotion__Q24Game9EnemyBaseFiPQ28SysShape14MotionListener - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ -} +void Obj::startCarcassMotion() { startMotion(8, nullptr); } /* * --INFO-- * Address: 80259F68 * Size: 00008C */ -void Ujib::Obj::initMouthSlots() +void Obj::initMouthSlots() { - /* - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stfd f31, 0x10(r1) - psq_st f31, 24(r1), 0, qr0 - stw r31, 0xc(r1) - stw r30, 8(r1) - mr r30, r3 - li r4, 1 - addi r3, r30, 0x2c8 - bl alloc__10MouthSlotsFi - lwz r5, 0x174(r30) - addi r3, r30, 0x2c8 - li r4, 0 - addi r6, r2, lbl_8051AB50@sda21 - bl setup__10MouthSlotsFiPQ28SysShape5ModelPc - lfs f31, lbl_8051AB48@sda21(r2) - li r31, 0 - b lbl_80259FC8 - -lbl_80259FB4: - mr r4, r31 - addi r3, r30, 0x2c8 - bl getSlot__10MouthSlotsFi - stfs f31, 0x1c(r3) - addi r31, r31, 1 - -lbl_80259FC8: - lwz r0, 0x2c8(r30) - cmpw r31, r0 - blt lbl_80259FB4 - psq_l f31, 24(r1), 0, qr0 - lwz r0, 0x24(r1) - lfd f31, 0x10(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + mMouthSlots.alloc(1); + mMouthSlots.setup(0, mModel, "kamujnt"); + for (int i = 0; i < mMouthSlots.getMax(); i++) { + mMouthSlots.getSlot(i)->mRadius = 15.0f; + } } /* @@ -764,22 +148,13 @@ void Ujib::Obj::initMouthSlots() * Address: 80259FF4 * Size: 000030 */ -void Ujib::Obj::lifeIncrement() +void Obj::lifeIncrement() { - /* - lfs f1, lbl_8051AB3C@sda21(r2) - stfs f1, 0x208(r3) - lwz r0, 0x1e0(r3) - rlwinm r0, r0, 0, 0x1f, 0x1d - stw r0, 0x1e0(r3) - lfs f0, 0x200(r3) - fcmpo cr0, f0, f1 - cror 2, 0, 2 - bnelr - lfs f0, lbl_8051AB40@sda21(r2) - stfs f0, 0x200(r3) - blr - */ + mInstantDamage = 0.0f; + disableEvent(0, EB_TakingDamage); + if (mHealth <= 0.0f) { + mHealth = 1.0f; + } } /* @@ -787,25 +162,11 @@ void Ujib::Obj::lifeIncrement() * Address: 8025A024 * Size: 000034 */ -void Ujib::Obj::setInWaterDamage() +void Obj::setInWaterDamage() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, 0x280(r3) - cmplwi r0, 0 - beq lbl_8025A048 - lfs f1, lbl_8051AB58@sda21(r2) - lfs f2, lbl_8051AB40@sda21(r2) - bl addDamage__Q24Game9EnemyBaseFff - -lbl_8025A048: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (mWaterBox) { + addDamage(2.0f, 1.0f); + } } /* @@ -813,59 +174,15 @@ void Ujib::Obj::setInWaterDamage() * Address: 8025A058 * Size: 0000B4 */ -void Ujib::Obj::resetAppearCheck() +void Obj::resetAppearCheck() { - /* - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r3 - lwz r4, gameSystem__4Game@sda21(r13) - cmplwi r4, 0 - beq lbl_8025A0EC - lwz r0, 0x44(r4) - cmpwi r0, 4 - bne lbl_8025A0EC - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0xc(r1) - mr r3, r30 - lwz r12, 0(r30) - stw r0, 8(r1) - lfd f2, lbl_8051AB68@sda21(r2) - lfd f0, 8(r1) - lfs f1, lbl_8051AB60@sda21(r2) - fsubs f2, f0, f2 - lfs f0, lbl_8051AB5C@sda21(r2) - lwz r12, 0x1ac(r12) - fdivs f1, f2, f1 - fmuls f0, f0, f1 - fctiwz f0, f0 - stfd f0, 0x10(r1) - lwz r31, 0x14(r1) - mtctr r12 - bctrl - mulli r0, r3, 5 - add r0, r31, r0 - rlwinm r0, r0, 8, 0x10, 0x17 - sth r0, 0x2c2(r30) - b lbl_8025A0F4 - -lbl_8025A0EC: - li r0, 0 - sth r0, 0x2c2(r30) - -lbl_8025A0F4: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + if (Game::gameSystem && Game::gameSystem->mMode == GSM_PIKLOPEDIA) { + int weight = (rand() / RAND_MAX) * 30.0f; // does not match with inline + SET_APPCHECK_MAX(mAppearCheck, weight + 5 * getCreatureID()); + + } else { + mAppearCheck = 0; + } } /* @@ -873,32 +190,18 @@ void Ujib::Obj::resetAppearCheck() * Address: 8025A10C * Size: 000048 */ -void Ujib::Obj::isAppearCheck() +bool Obj::isAppearCheck() { - /* - lhz r4, 0x2c2(r3) - cmplwi r4, 0 - beq lbl_8025A14C - addi r0, r4, 1 - sth r0, 0x2c2(r3) - lhz r0, 0x2c2(r3) - clrlwi r4, r0, 0x18 - rlwinm r0, r0, 0x18, 0x18, 0x1f - cmpw r4, r0 - ble lbl_8025A144 - li r0, 0 - sth r0, 0x2c2(r3) - li r3, 1 - blr - -lbl_8025A144: - li r3, 0 - blr - -lbl_8025A14C: - li r3, 1 - blr - */ + if (mAppearCheck != 0) { + mAppearCheck++; + if (GET_APPCHECK_VAL(mAppearCheck) > GET_APPCHECK_MAX(mAppearCheck)) { + mAppearCheck = 0; + return true; + } + return false; + } + + return true; } /* @@ -906,18 +209,12 @@ void Ujib::Obj::isAppearCheck() * Address: 8025A154 * Size: 000020 */ -void Ujib::Obj::resetBridgeSearch() +void Obj::resetBridgeSearch() { - /* - li r4, 1 - li r0, 0 - stb r4, 0x2c0(r3) - lfs f0, lbl_8051AB3C@sda21(r2) - stw r0, 0x2d0(r3) - stfs f0, 0x2d4(r3) - stfs f0, 0x2d8(r3) - blr - */ + _2C0 = 1; + mBridge = nullptr; + _2CC = 0.0f; + _2D0 = 0.0f; } /* @@ -925,30 +222,13 @@ void Ujib::Obj::resetBridgeSearch() * Address: 8025A174 * Size: 000048 */ -void Ujib::Obj::setBridgeSearch() +void Obj::setBridgeSearch() { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lbz r0, 0x2c0(r3) - cmplwi r0, 0 - beq lbl_8025A1A8 - li r0, 0 - stb r0, 0x2c0(r31) - bl setNearestBridge__Q34Game4Ujib3ObjFv - mr r3, r31 - bl setCullingCheck__Q34Game4Ujib3ObjFv - -lbl_8025A1A8: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + if (_2C0) { + _2C0 = 0; + setNearestBridge(); + setCullingCheck(); + } } /* @@ -956,210 +236,32 @@ void Ujib::Obj::setBridgeSearch() * Address: 8025A1BC * Size: 0002C0 */ -void Ujib::Obj::setNearestBridge() +void Obj::setNearestBridge() { - /* - 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 r31, r3 - li r0, 0 - stw r0, 0x2d0(r3) - lfs f0, lbl_8051AB3C@sda21(r2) - stfs f0, 0x2d4(r3) - stfs f0, 0x2d8(r3) - lwz r3, mgr__Q24Game10ItemBridge@sda21(r13) - cmplwi r3, 0 - beq lbl_8025A40C - lwz r4, 0xc0(r31) - lfs f0, 0x35c(r4) - fmuls f31, f0, f0 - beq lbl_8025A210 - addi r3, r3, 0x30 - -lbl_8025A210: - li r0, 0 - lis r4, "__vt__26Iterator"@ha - addi r4, r4, "__vt__26Iterator"@l - stw r0, 0x20(r1) - cmplwi r0, 0 - stw r4, 0x14(r1) - stw r0, 0x18(r1) - stw r3, 0x1c(r1) - bne lbl_8025A24C - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8025A3EC - -lbl_8025A24C: - lwz r12, 0(r3) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8025A2B8 - -lbl_8025A264: - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x20(r1) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_8025A3EC - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - -lbl_8025A2B8: - lwz r12, 0x14(r1) - addi r3, r1, 0x14 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_8025A264 - b lbl_8025A3EC - -lbl_8025A2D8: - lwz r3, 0x1c(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r0, r3 - addi r3, r1, 8 - mr r30, r0 - mr r4, r30 - bl getStartPos__Q34Game10ItemBridge4ItemFv - lfs f1, 0x194(r31) - lfs f0, 0x10(r1) - lfs f2, 0x18c(r31) - fsubs f1, f1, f0 - lfs f0, 8(r1) - fsubs f2, f2, f0 - fmuls f0, f1, f1 - fmadds f0, f2, f2, f0 - fcmpo cr0, f0, f31 - bge lbl_8025A330 - stw r30, 0x2d0(r31) - fmr f31, f0 - -lbl_8025A330: - lwz r0, 0x20(r1) - cmplwi r0, 0 - bne lbl_8025A35C - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8025A3EC - -lbl_8025A35C: - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - b lbl_8025A3D0 - -lbl_8025A37C: - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x20(r12) - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x20(r1) - lwz r12, 0(r3) - lwz r12, 8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - bne lbl_8025A3EC - lwz r3, 0x1c(r1) - lwz r4, 0x18(r1) - lwz r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - -lbl_8025A3D0: - lwz r12, 0x14(r1) - addi r3, r1, 0x14 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_8025A37C - -lbl_8025A3EC: - lwz r3, 0x1c(r1) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - lwz r4, 0x18(r1) - cmplw r4, r3 - bne lbl_8025A2D8 - -lbl_8025A40C: - lwz r3, 0x2d0(r31) - cmplwi r3, 0 - beq lbl_8025A45C - bl getStageWidth__Q34Game10ItemBridge4ItemFv - lfs f0, lbl_8051AB70@sda21(r2) - fsubs f31, f1, f0 - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0x2c(r1) - lfd f3, lbl_8051AB68@sda21(r2) - stw r0, 0x28(r1) - lfs f1, lbl_8051AB60@sda21(r2) - lfd f2, 0x28(r1) - lfs f0, lbl_8051AB74@sda21(r2) - fsubs f2, f2, f3 - fmuls f2, f31, f2 - fdivs f1, f2, f1 - fnmsubs f0, f0, f31, f1 - stfs f0, 0x2d4(r31) - -lbl_8025A45C: - 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 - */ + mBridge = nullptr; + _2CC = 0.0f; + _2D0 = 0.0f; + + if (ItemBridge::mgr) { + f32 radius = C_PARMS->mGeneral.mTerritoryRadius.mValue; + radius = SQUARE(radius); + Iterator iter(ItemBridge::mgr); + CI_LOOP(iter) + { + ItemBridge::Item* bridge = static_cast(*iter); + Vector3f startPos = bridge->getStartPos(); + f32 newRad = sqrDistanceXZ(mPosition, startPos); + if (newRad < radius) { + mBridge = bridge; + radius = newRad; + } + } + } + + if (mBridge) { + f32 width = mBridge->getStageWidth() - 20.0f; + _2CC = -(0.5f * width - randWeightFloat(width)); + } } /* @@ -1167,144 +269,49 @@ void Ujib::Obj::setNearestBridge() * Address: 8025A47C * Size: 000004 */ -void Ujib::Obj::setCullingCheck() { } +void Obj::setCullingCheck() { } /* * --INFO-- * Address: 8025A480 * Size: 0001B4 */ -void Ujib::Obj::checkBreakOrMove() +int Obj::checkBreakOrMove() { - /* - stwu r1, -0xa0(r1) - mflr r0 - stw r0, 0xa4(r1) - stfd f31, 0x90(r1) - psq_st f31, 152(r1), 0, qr0 - stfd f30, 0x80(r1) - psq_st f30, 136(r1), 0, qr0 - stfd f29, 0x70(r1) - psq_st f29, 120(r1), 0, qr0 - stfd f28, 0x60(r1) - psq_st f28, 104(r1), 0, qr0 - stfd f27, 0x50(r1) - psq_st f27, 88(r1), 0, qr0 - stfd f26, 0x40(r1) - psq_st f26, 72(r1), 0, qr0 - stw r31, 0x3c(r1) - mr r31, r3 - lwz r4, 0x2d0(r3) - cmplwi r4, 0 - beq lbl_8025A5EC - addi r3, r1, 0x20 - bl getBridgeZVec__Q34Game10ItemBridge4ItemFv - lfs f28, 0x20(r1) - addi r3, r1, 0x14 - lfs f29, 0x24(r1) - lfs f27, 0x28(r1) - lwz r4, 0x2d0(r31) - bl getStartPos__Q34Game10ItemBridge4ItemFv - lfs f2, 0x18(r1) - lfs f0, 0x190(r31) - lfs f1, 0x14(r1) - fsubs f30, f2, f0 - lfs f0, 0x18c(r31) - lfs f2, 0x1c(r1) - fsubs f31, f1, f0 - lfs f0, 0x194(r31) - fmuls f1, f29, f30 - fsubs f29, f2, f0 - lfs f0, lbl_8051AB3C@sda21(r2) - fmadds f1, f28, f31, f1 - fmadds f1, f27, f29, f1 - fcmpo cr0, f1, f0 - ble lbl_8025A534 - li r3, 7 - b lbl_8025A5F0 + if (mBridge) { + Vector3f zVec = mBridge->getBridgeZVec(); + Vector3f startPos = mBridge->getStartPos(); -lbl_8025A534: - lwz r4, 0x2d0(r31) - addi r3, r1, 8 - bl getBridgeXVec__Q34Game10ItemBridge4ItemFv - lfs f27, 8(r1) - lfs f28, 0xc(r1) - lfs f26, 0x10(r1) - lwz r3, 0x2d0(r31) - bl getStageWidth__Q34Game10ItemBridge4ItemFv - fmuls f3, f28, f30 - lfs f0, lbl_8051AB74@sda21(r2) - lfs f2, lbl_8051AB70@sda21(r2) - fmuls f4, f0, f1 - lfs f0, lbl_8051AB3C@sda21(r2) - fmadds f1, f27, f31, f3 - fadds f2, f2, f4 - fmadds f1, f26, f29, f1 - fcmpo cr0, f1, f0 - bge lbl_8025A584 - stfs f2, 0x2d8(r31) - b lbl_8025A58C + Vector3f bridgeDist = startPos - mPosition; + if (zVec.dot(bridgeDist) > 0.0f) { + return UJIB_MoveCentre; + } -lbl_8025A584: - fneg f0, f2 - stfs f0, 0x2d8(r31) + Vector3f xVec = mBridge->getBridgeXVec(); + f32 halfWidth = 0.5f * mBridge->getStageWidth(); + f32 dotX = xVec.dot(bridgeDist); + f32 width = 20.0f + halfWidth; -lbl_8025A58C: - lfs f0, lbl_8051AB3C@sda21(r2) - fcmpo cr0, f1, f0 - ble lbl_8025A59C - b lbl_8025A5A0 - -lbl_8025A59C: - fneg f1, f1 - -lbl_8025A5A0: - fcmpo cr0, f1, f4 - ble lbl_8025A5B0 - li r3, 6 - b lbl_8025A5F0 - -lbl_8025A5B0: - lwz r3, mapMgr__4Game@sda21(r13) - addi r4, r31, 0x18c - lwz r12, 4(r3) - lwz r12, 0x28(r12) - mtctr r12 - bctrl - lfs f0, lbl_8051AB78@sda21(r2) - lfs f2, 0x190(r31) - fadds f0, f0, f1 - fcmpo cr0, f2, f0 - ble lbl_8025A5E4 - li r3, 8 - b lbl_8025A5F0 - -lbl_8025A5E4: - li r3, 6 - b lbl_8025A5F0 - -lbl_8025A5EC: - li r3, 7 - -lbl_8025A5F0: - psq_l f31, 152(r1), 0, qr0 - lfd f31, 0x90(r1) - psq_l f30, 136(r1), 0, qr0 - lfd f30, 0x80(r1) - psq_l f29, 120(r1), 0, qr0 - lfd f29, 0x70(r1) - psq_l f28, 104(r1), 0, qr0 - lfd f28, 0x60(r1) - psq_l f27, 88(r1), 0, qr0 - lfd f27, 0x50(r1) - psq_l f26, 72(r1), 0, qr0 - lfd f26, 0x40(r1) - lwz r0, 0xa4(r1) - lwz r31, 0x3c(r1) - mtlr r0 - addi r1, r1, 0xa0 - blr - */ + if (dotX < 0.0f) { + _2D0 = width; + } else { + _2D0 = -width; + } + + if (absVal(dotX) > halfWidth) { + return UJIB_MoveSide; + } + + f32 minY = mapMgr->getMinY(mPosition); + + if (mPosition.y > 5.0f + minY) { + return UJIB_MoveTop; + } + + return UJIB_MoveSide; + } + + return UJIB_MoveCentre; } /* @@ -1312,22 +319,13 @@ void Ujib::Obj::checkBreakOrMove() * Address: 8025A634 * Size: 000028 */ -void Ujib::Obj::isBreakBridge() +bool Obj::isBreakBridge() { - /* - lwz r3, 0x2d0(r3) - cmplwi r3, 0 - beq lbl_8025A654 - lwz r0, 0x218(r3) - cmpwi r0, 0 - beq lbl_8025A654 - li r3, 1 - blr + if (mBridge && mBridge->mStagesRemaining != 0) { + return true; + } -lbl_8025A654: - li r3, 0 - blr - */ + return false; } /* @@ -1335,8 +333,44 @@ void Ujib::Obj::isBreakBridge() * Address: 8025A65C * Size: 0002A8 */ -void Ujib::Obj::moveBridgeSide() +bool Obj::moveBridgeSide() { + Vector3f startPos = mBridge->getStartPos(); + Vector3f xVec = mBridge->getBridgeXVec(); + Vector3f zVec = mBridge->getBridgeZVec(); + + xVec *= _2D0; + zVec *= -20.0f; + + startPos += xVec; + startPos += zVec; + + if (sqrDistanceXZ(mPosition, startPos) < 250.0f) { + f32 speed = 0.75f * C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return true; + + } else { + changeFaceDir(startPos); + + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return false; + } /* stwu r1, -0xa0(r1) mflr r0 @@ -1524,8 +558,41 @@ void Ujib::Obj::moveBridgeSide() * Address: 8025A904 * Size: 000288 */ -void Ujib::Obj::moveBridgeCentre() +bool Obj::moveBridgeCentre() { + Vector3f startPos = mBridge->getStartPos(); + Vector3f xVec = mBridge->getBridgeXVec(); + + xVec *= 0.7f * _2CC; + + startPos += xVec; + + if (sqrDistanceXZ(mPosition, startPos) < 250.0f) { + f32 speed = 0.75f * C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return true; + + } else { + changeFaceDir(startPos); + + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return false; + } /* stwu r1, -0x90(r1) mflr r0 @@ -1705,8 +772,54 @@ void Ujib::Obj::moveBridgeCentre() * Address: 8025AB8C * Size: 0002F0 */ -void Ujib::Obj::moveBridgeTop() +bool Obj::moveBridgeTop() { + int stageID = mBridge->mStagesRemaining - 1; + Vector3f stagePos = mBridge->getStagePos(stageID); + Vector3f xVec = mBridge->getBridgeXVec(); + + xVec *= _2CC; + + stagePos += xVec; + + if (stageID > 0) { + Vector3f zVec = mBridge->getBridgeZVec(); + zVec *= -20.0f; + stagePos += zVec; + } + + changeFaceDir(stagePos); + + f32 dist = sqrDistanceXZ(mPosition, stagePos); + + if (dist < 50.0f) { + mTargetVelocity = Vector3f(0.0f); + return true; + + } else if (dist < 250.0f) { + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + + return true; + + } else { + f32 speed = C_PARMS->mGeneral.mMoveSpeed.mValue; + f32 sinTheta = sin(getFaceDir()); + f32 y = getTargetVelocity().y; + f32 cosTheta = cos(getFaceDir()); + + mTargetVelocity.x = speed * sinTheta; + mTargetVelocity.y = y; + mTargetVelocity.z = speed * cosTheta; + } + + return false; /* stwu r1, -0xb0(r1) mflr r0 @@ -1916,33 +1029,10 @@ void Ujib::Obj::moveBridgeTop() * Address: 8025AE7C * Size: 00005C */ -void Ujib::Obj::breakTargetBridge() +void Obj::breakTargetBridge() { - /* - stwu r1, -0x20(r1) - mflr r0 - lis r4, __vt__Q24Game11Interaction@ha - lis r5, __vt__Q24Game19InteractBreakBridge@ha - stw r0, 0x24(r1) - addi r6, r4, __vt__Q24Game11Interaction@l - addi r0, r5, __vt__Q24Game19InteractBreakBridge@l - addi r4, r1, 8 - lwz r7, 0xc0(r3) - lfs f0, 0x844(r7) - stw r6, 8(r1) - stw r3, 0xc(r1) - stw r0, 8(r1) - stfs f0, 0x10(r1) - lwz r3, 0x2d0(r3) - lwz r12, 0(r3) - lwz r12, 0x1a4(r12) - mtctr r12 - bctrl - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + InteractBreakBridge breakBridge(this, C_PROPERPARMS.mBridgeDamage.mValue); + mBridge->stimulate(breakBridge); } /* @@ -1950,45 +1040,11 @@ void Ujib::Obj::breakTargetBridge() * Address: 8025AED8 * Size: 00008C */ -void Ujib::Obj::createAppearEffect() +void Obj::createAppearEffect() { - /* - stwu r1, -0x20(r1) - mflr r0 - lis r4, lbl_80485358@ha - stw r0, 0x24(r1) - addi r4, r4, lbl_80485358@l - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lis r4, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r4, __vt__Q23efx5TBase@l - lis r4, __vt__Q23efx8TSimple2@ha - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx8TSimple2@l - lis r5, __vt__Q23efx11TSimpleMtx2@ha - lis r4, __vt__Q23efx9TUjinkoAp@ha - stw r0, 8(r1) - addi r0, r5, __vt__Q23efx11TSimpleMtx2@l - li r7, 0x1ce - li r5, 0x1cf - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx9TUjinkoAp@l - li r4, 0 - stw r3, 0x18(r1) - addi r3, r1, 8 - sth r7, 0xc(r1) - sth r5, 0xe(r1) - stw r6, 0x10(r1) - stw r6, 0x14(r1) - stw r0, 8(r1) - bl create__Q23efx11TSimpleMtx2FPQ23efx3Arg - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + Matrixf* worldMat = mModel->getJoint("ujinnko_m")->getWorldMatrix(); + efx::TUjinkoAp appearFX(worldMat); + appearFX.create(nullptr); } /* @@ -1996,45 +1052,11 @@ void Ujib::Obj::createAppearEffect() * Address: 8025AF64 * Size: 00008C */ -void Ujib::Obj::createDisAppearEffect() +void Obj::createDisAppearEffect() { - /* - stwu r1, -0x20(r1) - mflr r0 - lis r4, lbl_80485358@ha - stw r0, 0x24(r1) - addi r4, r4, lbl_80485358@l - lwz r3, 0x174(r3) - bl getJoint__Q28SysShape5ModelFPc - bl getWorldMatrix__Q28SysShape5JointFv - lis r4, __vt__Q23efx5TBase@ha - li r6, 0 - addi r0, r4, __vt__Q23efx5TBase@l - lis r4, __vt__Q23efx8TSimple2@ha - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx8TSimple2@l - lis r5, __vt__Q23efx11TSimpleMtx2@ha - lis r4, __vt__Q23efx9TUjinkoHd@ha - stw r0, 8(r1) - addi r0, r5, __vt__Q23efx11TSimpleMtx2@l - li r7, 0x1d1 - li r5, 0x1d2 - stw r0, 8(r1) - addi r0, r4, __vt__Q23efx9TUjinkoHd@l - li r4, 0 - stw r3, 0x18(r1) - addi r3, r1, 8 - sth r7, 0xc(r1) - sth r5, 0xe(r1) - stw r6, 0x10(r1) - stw r6, 0x14(r1) - stw r0, 8(r1) - bl create__Q23efx11TSimpleMtx2FPQ23efx3Arg - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr - */ + Matrixf* worldMat = mModel->getJoint("ujinnko_m")->getWorldMatrix(); + efx::TUjinkoHd hideFX(worldMat); + hideFX.create(nullptr); } /* @@ -2042,46 +1064,12 @@ void Ujib::Obj::createDisAppearEffect() * Address: 8025AFF0 * Size: 000090 */ -void Ujib::Obj::createBridgeEffect() +void Obj::createBridgeEffect() { - /* - stwu r1, -0x30(r1) - mflr r0 - addi r4, r2, lbl_8051AB50@sda21 - stw r0, 0x34(r1) - 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__Q23efx10TUjinkoEat@ha - addi r4, r5, __vt__Q23efx3Arg@l - li r6, 0x1d0 - li r5, 0 - stw r0, 8(r1) - addi r0, r3, __vt__Q23efx10TUjinkoEat@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("kamujnt")->getWorldMatrix()->getBasis(3); + efx::Arg fxArg(fxPos); + efx::TUjinkoEat eatFX; + eatFX.create(&fxArg); } /* @@ -2089,46 +1077,12 @@ void Ujib::Obj::createBridgeEffect() * Address: 8025B080 * Size: 000090 */ -void Ujib::Obj::createEatEffect() +void Obj::createEatEffect() { - /* - stwu r1, -0x30(r1) - mflr r0 - addi r4, r2, lbl_8051AB50@sda21 - stw r0, 0x34(r1) - 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__Q23efx12TUjinkoPkate@ha - addi r4, r5, __vt__Q23efx3Arg@l - li r6, 0x25e - li r5, 0 - stw r0, 8(r1) - addi r0, r3, __vt__Q23efx12TUjinkoPkate@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("kamujnt")->getWorldMatrix()->getBasis(3); + efx::Arg fxArg(fxPos); + efx::TUjinkoPkate eatFX; + eatFX.create(&fxArg); } /* @@ -2136,140 +1090,27 @@ void Ujib::Obj::createEatEffect() * Address: 8025B110 * Size: 000008 */ -void Ujib::Obj::isUnderground() -{ - /* - lbz r3, 0x2c1(r3) - blr - */ -} +bool Obj::isUnderground() { return mIsUnderground; } /* * --INFO-- * Address: 8025B118 * Size: 000008 */ -void Ujib::Obj::getMouthSlots() -{ - /* - addi r3, r3, 0x2c8 - blr - */ -} +MouthSlots* Obj::getMouthSlots() { return &mMouthSlots; } /* * --INFO-- * Address: 8025B120 * Size: 000008 */ -void Ujib::Obj::getDownSmokeScale() -{ - /* - lfs f1, lbl_8051AB94@sda21(r2) - blr - */ -} +f32 Obj::getDownSmokeScale() { return 0.35f; } /* * --INFO-- * Address: 8025B128 * Size: 000008 */ -u32 Ujib::Obj::getEnemyTypeID() { return 0xD; } - -/* - * --INFO-- - * Address: 8025B130 - * Size: 000014 - */ -void EnemyBase::@732 @12 @viewOnPelletKilled() -{ - /* - li r11, 0xc - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -732 - b viewOnPelletKilled__Q24Game9EnemyBaseFv - */ -} - -/* - * --INFO-- - * Address: 8025B144 - * Size: 000014 - */ -void EnemyBase::@732 @12 @viewStartCarryMotion() -{ - /* - li r11, 0xc - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -732 - b viewStartCarryMotion__Q24Game9EnemyBaseFv - */ -} - -/* - * --INFO-- - * Address: 8025B158 - * Size: 000014 - */ -void EnemyBase::@732 @12 @viewStartPreCarryMotion() -{ - /* - li r11, 0xc - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -732 - b viewStartPreCarryMotion__Q24Game9EnemyBaseFv - */ -} - -/* - * --INFO-- - * Address: 8025B16C - * Size: 000014 - */ -void EnemyBase::@732 @12 @view_finish_carrymotion() -{ - /* - li r11, 0xc - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -732 - b view_finish_carrymotion__Q24Game9EnemyBaseFv - */ -} - -/* - * --INFO-- - * Address: 8025B180 - * Size: 000014 - */ -void EnemyBase::@732 @12 @view_start_carrymotion() -{ - /* - li r11, 0xc - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -732 - b view_start_carrymotion__Q24Game9EnemyBaseFv - */ -} - -/* - * --INFO-- - * Address: 8025B194 - * Size: 000014 - */ -void EnemyBase::@732 @12 @viewGetShape() -{ - /* - li r11, 0xc - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -732 - b viewGetShape__Q24Game9EnemyBaseFv - */ -} +EnemyTypeID::EEnemyTypeID Obj::getEnemyTypeID() { return EnemyTypeID::EnemyID_UjiB; } +} // namespace Ujib } // namespace Game