diff --git a/include/Collision.h b/include/Collision.h index 8d5e2ab9..af39ff1d 100644 --- a/include/Collision.h +++ b/include/Collision.h @@ -127,19 +127,32 @@ struct CollPart { ID32 getCode(); Matrix4f getMatrix(); void update(struct Graphics&, bool); - void collide(CollPart*, struct Vector3f&); + bool collide(CollPart*, struct Vector3f&); void makeTube(struct Tube&); // unused/inlined: bool isDamagable(); CollPart* getNext(); - void collide(Creature*, Vector3f&); - void collide(Vector3f&, f32, Vector3f&); + bool collide(Creature*, Vector3f&); + bool collide(Vector3f&, f32, Vector3f&); void makeSphere(struct Sphere&); void makeCylinder(struct Cylinder&); - void samePlatShape(Shape*); + bool samePlatShape(Shape*); - inline bool isTubeLike() { return mPartType == PART_Tube || mPartType == PART_TubeChild; } // based on P2, maybe isTubeLike? who knows + bool isTubeType() { return mPartType == PART_Tube || mPartType == PART_TubeChild; } // based on P2, maybe isTubeLike? who knows + + bool isPlatformType() { return mPartType == PART_Platform; } + + /* + DLL inlines to make: + bool isBouncySphereType(); + bool isCollisionType(); + bool isPlatformType(); + bool isReferenceType(); + bool isSphereType(); + + Matrix4f getJointMatrix(); + */ f32 mRadius; // _00 Vector3f mCentre; // _04 @@ -158,9 +171,16 @@ struct CollPart { * @brief TODO */ struct CollEvent { - Creature* mCollider; // _00 - CollPart* mCollPart; // _04 - u32 _08; // _08, unknown + CollEvent(Creature* collider, CollPart* colliderPart, CollPart* selfPart) + { + mCollider = collider; + mColliderPart = colliderPart; + mSelfPart = selfPart; + } + + Creature* mCollider; // _00 + CollPart* mColliderPart; // _04 + CollPart* mSelfPart; // _08 }; /** @@ -194,15 +214,15 @@ struct CollInfo { void enableStick(); void disableStick(); void checkCollisionSpecial(Vector3f&, f32, CndCollPart*); - void checkCollision(Creature*, Vector3f&); - void checkCollisionRec(Creature*, int, Vector3f&); - void checkCollision(CollInfo*, CollPart**, CollPart**, Vector3f&); + CollPart* checkCollision(Creature*, Vector3f&); + CollPart* checkCollisionRec(Creature*, int, Vector3f&); + bool checkCollision(CollInfo*, CollPart**, CollPart**, Vector3f&); void checkCollisionRec(CollInfo*, int, int, CollPart**, CollPart**, Vector3f&); CollPart* getBoundingSphere(); CollPart* getSphere(u32 id); CollPart* getNearestCollPart(Vector3f&, u32); CollPart* getRandomCollPart(u32); - void getPlatform(DynCollObject*); + CollPart* getPlatform(DynCollObject*); void updateInfo(Graphics&, bool); bool hasInfo(); void initInfo(Shape*, CollPart*, u32*); diff --git a/include/ComplexCreature.h b/include/ComplexCreature.h index 586aa6d9..09f206a0 100644 --- a/include/ComplexCreature.h +++ b/include/ComplexCreature.h @@ -2,12 +2,14 @@ #define _COMPLEXCREATURE_H #include "types.h" -#include "Creature.h" + +struct Creature; +struct CreatureProp; /** * @brief TODO * - * @note Mostly stripped, very few references left. Necessary for complexCreature.cpp though. + * @note Mostly stripped, but necessary. This is the complete set of inlines from the DLL. */ template struct SmartPtr { @@ -32,10 +34,11 @@ struct SmartPtr { } } - // also need: - // void clear(); - // bool isNull(); - // T* getPtr(); + T* getPtr() { return mPtr; } + + bool isNull() { return mPtr == nullptr; } + + void clear() { mPtr = nullptr; } T* mPtr; // _00 }; diff --git a/include/Condition.h b/include/Condition.h index e242f3eb..81a4d3b8 100644 --- a/include/Condition.h +++ b/include/Condition.h @@ -23,7 +23,6 @@ struct CndIsAtari : public Condition { virtual bool satisfy(Creature*); // _08 // _00 = VTBL - // TODO: members }; /** diff --git a/include/Creature.h b/include/Creature.h index f9805fca..3cda122d 100644 --- a/include/Creature.h +++ b/include/Creature.h @@ -46,7 +46,7 @@ enum CreatureFlags { CF_Unk11 = 1 << 10, // 0x400 CF_IsAiDisabled = 1 << 11, // 0x800, aka aiSTOP CF_Free = 1 << 12, // 0x1000 - CF_Unk14 = 1 << 13, // 0x2000 + CF_IsClimbing = 1 << 13, // 0x2000 CF_StuckToObject = 1 << 14, // 0x4000, stuck to an object CF_StuckToMouth = 1 << 15, // 0x8000, stuck to mouth of some enemy CF_Unk16 = 1 << 16, // 0x10000 @@ -62,10 +62,10 @@ enum CreatureFlags { * @brief TODO */ enum CreatureStandType { - STANDTYPE_Unk0 = 0, - STANDTYPE_Unk1 = 1, - STANDTYPE_Unk2 = 2, - STANDTYPE_Unk3 = 3, + STANDTYPE_Ground = 0, // on a floor tri, no platform + STANDTYPE_TekiPlatform = 1, // on a platform which has an associated creature + STANDTYPE_Platform = 2, // on a platform with no associated creature + STANDTYPE_Air = 3, // no floor tri or platform }; /** @@ -165,12 +165,12 @@ struct Creature : public RefCountable, public EventTalker { void updateAI(); void collisionCheck(f32); void moveVelocity(); - u8 getAvoid(Vector3f&, Vector3f&); + bool getAvoid(Vector3f&, Vector3f&); void respondColl(Creature*, f32, CollPart*, CollPart*, const Vector3f&); void moveRotation(f32); void moveAttach(); void moveNew(f32); - void getNearestPlane(CollTriInfo*); + Plane* getNearestPlane(CollTriInfo*); void interactStickers(Creature*, Interaction&, Condition*); void killStickers(Creature*, Condition*, int); void startClimb(); @@ -182,9 +182,9 @@ struct Creature : public RefCountable, public EventTalker { void startStickObjectTube(Creature*, CollPart*); void startStickObject(Creature*, CollPart*, int, f32); void endStickObject(); - void startStick(Creature*, CollPart*); + bool startStick(Creature*, CollPart*); void endStick(); - void startRope(RopeCreature*, f32); + bool startRope(RopeCreature*, f32); void endRope(); void updateStickPlatform(); void updateStickNonPlatform(); @@ -195,33 +195,35 @@ struct Creature : public RefCountable, public EventTalker { // unused/inlined: void startFixPosition(); - void insideSphere(struct Sphere&); + bool insideSphere(struct Sphere&); void adjustDistance(Vector3f&, f32); - void getAtariType(); - void checkForward(Vector3f&, f32, f32&); - void getNextTri(CollTriInfo*, Vector3f&, int&); + int getAtariType(); + CollTriInfo* checkForward(Vector3f&, f32, f32&); + CollTriInfo* getNextTri(CollTriInfo*, Vector3f&, int&); void renderCollTriInfo(Graphics&, CollTriInfo*, Colour&); - void isStickToSphere(); + bool isStickToSphere(); void adjustStickObject(Vector3f&); void startStickObjectPellet(Pellet*, int, f32); - void isStickLeader(); - - // these are setFlag/resetFlag/isFlag in the DLL, but this is clearer. - void setCreatureFlag(u32 flag) { mCreatureFlags |= flag; } - void resetCreatureFlag(u32 flag) { mCreatureFlags &= ~flag; } - bool isCreatureFlag(u32 flag) const { return mCreatureFlags & flag; } - - inline Vector3f& getPosition() { return mPosition; } + bool isStickLeader(); + // fake according to the DLL inline void resetVelocity() { mVelocity.set(Vector3f(0.0f, 0.0f, 0.0f)); mTargetVelocity.set(Vector3f(0.0f, 0.0f, 0.0f)); } + // this is apparently fake, or not a creature inline? inline bool isStuckTo(Creature* creature) { return mStickTarget == creature; } - inline Creature* get2AC() { return _2AC; } + // these are setFlag/resetFlag/isFlag in the DLL, but this is clearer. + void setCreatureFlag(u32 flag) { mCreatureFlags |= flag; } + void resetCreatureFlag(u32 flag) { mCreatureFlags &= ~flag; } + bool isCreatureFlag(u32 flag) { return mCreatureFlags & flag; } + + Vector3f& getPosition() { return mPosition; } + + inline void disableFlag10000() { resetCreatureFlag(CF_Unk16); } // this should be one of the disable inlines inline void setFlag40UnsetFlag2() // name this better later PLEASE - definitely a DLL inline { @@ -229,13 +231,21 @@ struct Creature : public RefCountable, public EventTalker { resetCreatureFlag(CF_Unk2); } - // probably this name - definitely a DLL inline - bool isGrabbed() { return isCreatureFlag(CF_StuckToMouth); } - void disableAICulling() { resetCreatureFlag(CF_IsAICullingActive); } void enableAICulling() { setCreatureFlag(CF_IsAICullingActive); } bool aiCullable() { return !isCreatureFlag(CF_IsAICullingActive); } + // we're grabbed if we're held by something + bool isGrabbed() { return !mHoldingCreature.isNull(); } + Creature* getHolder() { return mHoldingCreature.getPtr(); } + + // we're holding if we've grabbed something + bool isHolding() { return !mGrabbedCreature.isNull(); } + Creature* getHoldCreature() { return mGrabbedCreature.getPtr(); } + + // idk why this is a BOOL and not bool but go figure + BOOL isStickToMouth() { return isCreatureFlag(CF_StuckToMouth); } + CollPart* getStickPart() { return mStickPart; } Creature* getStickObject() { return mStickTarget; } @@ -245,78 +255,132 @@ struct Creature : public RefCountable, public EventTalker { || mObjType == OBJTYPE_SluiceBombHard; } + bool isTeki() { return mObjType == OBJTYPE_Teki; } + + bool isPiki() { return mObjType == OBJTYPE_Piki; } + + void setRebirthDay(int day) { mRebirthDay = day; } + + bool roughCulling(Creature* other, f32 p2) { return mGrid.doCulling(other->mGrid, p2); } + + /* + DLL inlines to assign/make: + bool insideView(); + bool isAIActive(); + bool isDamaged(); + bool isHolding(); + bool isObjType(int); + bool isStickTo(); + bool roughCulling(Creature*, f32); + + Creature* getHoldCreature(); + Creature* getHolder(); + + f32 calcDistance(Creature&); + + int getRebirthDay(); + BOOL isFlying(); + BOOL isStickToMouth(); + + void disableFaceDirAdjust(); + void disableFixPos(); + void disableGravity(); + void disableGroundOffset(); + void enableAirResist(f32); + void enableFaceDirAdjust(); + void enableFixPos(); + void enableGravity(); + void enableGroundOffset(f32); + void finishFix(); + void finishFlying(); + void inputPosition(Vector3f&); + void outputPosition(Vector3f&); + void resetStateDamaged(); + void restartAI(); + void setCarryOver(); + void setFree(bool); + void setInsideView(); + void setOutsideView(); + void setStateDamaged(); + void startFix(); + void startFlying(); + void stopAI(); + void unsetCarryOver(); + + */ + // _00 = VTBL // _00-_08 = RefCountable // _08-_1C = EventTalker - Vector3f _1C; // _1C - u32 _28; // _28, unknown - SeContext* mSeContext; // _2C - u8 _30; // _30 - int _34; // _34 - u8 _38[0x40 - 0x38]; // _38, TODO: work out members - FastGrid mGrid; // _40 - f32 mHealth; // _58 - f32 mMaxHealth; // _5C - u8 _60; // _60 - Generator* mGenerator; // _64 - u32 _68; // _68, might be int - EObjType mObjType; // _6C - Vector3f mVelocity; // _70 - Vector3f mScale; // _7C - Vector3f mRotation; // _88 - Vector3f mPosition; // _94 - f32 mDirection; // _A0 - Vector3f mTargetVelocity; // _A4 - Vector3f _B0; // _B0 - Vector3f mVolatileVelocity; // _BC - u32 mCreatureFlags; // _C8, bitflag - u32 _CC; // _CC - f32 mAbsPickOffset; // _D0 - Vector3f _D4; // _D4 - Quat _E0; // _E0 - Quat mPreGrabRotation; // _F0 - Quat _100; // _100 - f32 _110; // _110 - Matrix4f _114; // _114 - Creature* _154; // _154 - u32 _158; // _158, maybe Rope* or RopeCreature*? - f32 _15C; // _15C - u32 _160; // _160, unknown - u32 _164; // _164, unknown - UpdateContext _168; // _168 - UpdateContext _174; // _174 - Creature* _180; // _180, unknown - Creature* mStickTarget; // _184, creature/object this creature is stuck to - CollPart* mStickPart; // _188 - Creature* _18C; // _18C, unknown - u32 _190; // _190, unknown - Vector3f _194; // _194 - int _1A0; // _1A0 - u32 _1A4; // _1A4 - u8 _1A8[0x4]; // _1A8, unknown - Vector3f _1AC; // _1AC - SearchBuffer mSearchBuffer; // _1B8 - LifeGauge mLifeGauge; // _1E0 - u32 _21C; // _21C, unknown - CollInfo* mCollInfo; // _220 - CreatureProp* mProps; // _224, creature properties - Matrix4f mTransformMatrix; // _228 - f32 _268; // _268 - f32 _26C; // _26C - f32 mCollisionRadius; // _270 - Vector3f _274; // _274 - DynCollObject* _280; // _280 - Vector3f* _284; // _284, coll plat normal maybe? - u32 _288; // _288, unknown - CollTriInfo* mFloorTri; // _28C - u32 _290; // _290, unknown - u8 _294[0x4]; // _294, unknown - u32 _298; // _298, unknown - Vector3f _29C; // _29C - Creature* _2A8; // _2A8 - Creature* _2AC; // _2AC - u32 _2B0; // _2B0, unknown - bool mIsBeingDamaged; // _2B4 + Vector3f mFixedPosition; // _1C + u32 _28; // _28, unknown + SeContext* mSeContext; // _2C + u8 _30; // _30 + int mRebirthDay; // _34 + u8 _38[0x40 - 0x38]; // _38, TODO: work out members + FastGrid mGrid; // _40 + f32 mHealth; // _58 + f32 mMaxHealth; // _5C + u8 _60; // _60 + Generator* mGenerator; // _64 + u32 _68; // _68, might be int + EObjType mObjType; // _6C + Vector3f mVelocity; // _70 + Vector3f mScale; // _7C, NB: these 3 vectors are an SRT according to DLL + Vector3f mRotation; // _88, but I really don't want that extra level to access these + Vector3f mPosition; // _94, just a heads up in case it becomes important + f32 mDirection; // _A0 + Vector3f mTargetVelocity; // _A4 + Vector3f _B0; // _B0 + Vector3f mVolatileVelocity; // _BC + u32 mCreatureFlags; // _C8, bitflag + u32 _CC; // _CC + f32 mAbsPickOffset; // _D0 + Vector3f _D4; // _D4 + Quat _E0; // _E0 + Quat mPreGrabRotation; // _F0 + Quat _100; // _100 + f32 _110; // _110 + Matrix4f _114; // _114 + Creature* mRopeListHead; // _154, first holder in list of holders holding onto this rope + RopeCreature* mRope; // _158 + f32 mRopeRatio; // _15C, how far along the rope are we + Creature* mNextRopeHolder; // _160, rope holder after this one in the rope list + Creature* mPrevRopeHolder; // _164, rope holder before this one in the rope list + UpdateContext _168; // _168 + UpdateContext _174; // _174 + Creature* mStickListHead; // _180, first sticker in list of stickers stuck to this creature + Creature* mStickTarget; // _184, creature/object this creature is stuck to + CollPart* mStickPart; // _188 + Creature* mNextSticker; // _18C, sticker after this one in the sticker list + Creature* mPrevSticker; // _190, sticker before this one in the sticker list + Vector3f _194; // _194 + int mPelletStickSlot; // _1A0 + u32 _1A4; // _1A4 + u32 _1A8; // _1A8, unknown + Vector3f _1AC; // _1AC + SearchBuffer mSearchBuffer; // _1B8 + LifeGauge mLifeGauge; // _1E0 + u32 _21C; // _21C, unknown + CollInfo* mCollInfo; // _220 + CreatureProp* mProps; // _224, creature properties + Matrix4f mTransformMatrix; // _228 + f32 _268; // _268 + f32 _26C; // _26C + f32 mCollisionRadius; // _270 + Vector3f _274; // _274, this is actually a wrapper around a Vector3f in the DLL, but idk what yet. + DynCollObject* mCollPlatform; // _280 + Vector3f* mCollPlatNormal; // _284 + u32 _288; // _288, unknown + CollTriInfo* mFloorTri; // _28C + u32 _290; // _290, unknown + u8 _294[0x4]; // _294, unknown + u32 _298; // _298, unknown + Vector3f _29C; // _29C + SmartPtr mHoldingCreature; // _2A8, what is holding this creature (e.g. what piki if this is a bomb) + SmartPtr mGrabbedCreature; // _2AC, what is this creature holding (e.g. what bomb if this is a piki) + u32 _2B0; // _2B0, unknown + bool mIsBeingDamaged; // _2B4 }; // Global helper functions: @@ -326,6 +390,7 @@ f32 qdist2(Creature*, Creature*); f32 circleDist(Creature*, Creature*); bool roughCull(Creature*, Creature*, f32); +// these are probably SmartPtr inlines, or creature inlines - TODO: fix. // these are the things that make the most sense so far, this code comes up in weird spots inline void resetCreature(Creature*& creature) { diff --git a/include/DynColl.h b/include/DynColl.h index af41d051..0035bd5d 100644 --- a/include/DynColl.h +++ b/include/DynColl.h @@ -17,9 +17,9 @@ struct DynCollObject : public Node { DynCollObject() : Node("") { - _20 = 0; - _24 = -1; - _28 = 0; + _20 = 0; + _24 = -1; + mCreature = nullptr; } virtual void adjust(Creature*); // _30 @@ -29,9 +29,9 @@ struct DynCollObject : public Node { // _00 = VTBL // _00-_20 = Node - u32 _20; // _20, unknown - u32 _24; // _24, maybe int? - Creature* _28; // _28 + u32 _20; // _20, unknown + u32 _24; // _24, maybe int? + Creature* mCreature; // _28 }; /** diff --git a/include/DynCreature.h b/include/DynCreature.h index 0bcf0006..830f5ab4 100644 --- a/include/DynCreature.h +++ b/include/DynCreature.h @@ -26,6 +26,17 @@ struct DynCreature : public Creature { void calcModelMatrix(Matrix4f&); void simulate2(f32); + f32 getPickOffset() { return mPickOffset; } + + // DLL inlines to make: + // bool isDynFlag(int); + // void resetDynFlag(int); + // void setDynFlag(int); + // f32 getPickOffset(); + // u8 getGroundFlag(); + // void disableFriction(); + // void enableFriction(); + // _00 = VTBL // _00-_2B8 = Creature Vector3f _2B8; // _2B8 diff --git a/include/Geometry.h b/include/Geometry.h index 75c7efbc..cd76d34a 100644 --- a/include/Geometry.h +++ b/include/Geometry.h @@ -10,12 +10,20 @@ struct Sphere; * @brief TODO */ struct Cylinder { + Cylinder(Vector3f& p1, Vector3f& p2, f32 p3) + : _00(p1) + , _0C(p2) + , _18(p3) + { + } void get2dDist(Vector3f&); void collide(const Sphere&, Vector3f&, f32&); - void getPosRatio(const Vector3f&); + f32 getPosRatio(const Vector3f&); - // TODO: members + Vector3f _00; // _00 + Vector3f _0C; // _0C + f32 _18; // _18 }; /** @@ -46,8 +54,8 @@ struct Sphere { { } - Vector3f mCentre; // _04 - f32 mRadius; // _00 + Vector3f mCentre; // _00 + f32 mRadius; // _04 }; /** diff --git a/include/ID32.h b/include/ID32.h index cec9effa..7e8801f6 100644 --- a/include/ID32.h +++ b/include/ID32.h @@ -87,8 +87,6 @@ struct ID32 { */ void write(RandomAccessStream& stream); - inline u32 getID() const { return mId; } - u32 mId; // _00 char mStringID[5]; // _04 }; diff --git a/include/MapCode.h b/include/MapCode.h index 9ef217a2..26be77d7 100644 --- a/include/MapCode.h +++ b/include/MapCode.h @@ -24,8 +24,8 @@ enum MapAttributes { */ namespace MapCode { -u32 getAttribute(CollTriInfo*); -u32 getSlipCode(CollTriInfo*); +int getAttribute(CollTriInfo*); +int getSlipCode(CollTriInfo*); bool isBald(CollTriInfo*); // unused/inlined diff --git a/include/Msg.h b/include/Msg.h index e31dc3d1..e91b38f9 100644 --- a/include/Msg.h +++ b/include/Msg.h @@ -85,13 +85,12 @@ struct MsgCollide : public Msg { * @brief TODO */ struct MsgDamage : public Msg { - inline MsgDamage() + inline MsgDamage() // this never gets called, funnily enough : Msg(MSG_Damage) { } // _00-_04 = Msg - // TODO: members }; /** @@ -104,20 +103,18 @@ struct MsgGround : public Msg { } // _00-_04 = Msg - // TODO: members }; /** * @brief TODO */ struct MsgHang : public Msg { - inline MsgHang() + inline MsgHang() // this also never gets called : Msg(MSG_Hang) { } // _00-_04 = Msg - // TODO: members }; /** @@ -144,7 +141,6 @@ struct MsgStick : public Msg { } // _00-_04 = Msg - // TODO: members }; /** @@ -165,28 +161,30 @@ struct MsgTarget : public Msg { * @brief TODO */ struct MsgUser : public Msg { - inline MsgUser(u32 val) + inline MsgUser(int val) : Msg(MSG_User) { mUserID = val; } // _00-_04 = Msg - u32 mUserID; // _04, could be int + int mUserID; // _04 }; /** * @brief TODO */ struct MsgWall : public Msg { - inline MsgWall() + inline MsgWall(Plane& plane, DynCollObject* wall) : Msg(MSG_Wall) { + mWallNormal = &plane.mNormal; + mWall = wall; } // _00-_04 = Msg - Vector3f* mWallNormal; // _04 - // TODO: members + Vector3f* mWallNormal; // _04, might be Plane*? + DynCollObject* mWall; // _08 }; #endif diff --git a/include/Pellet.h b/include/Pellet.h index 6086a83d..9f90c3c5 100644 --- a/include/Pellet.h +++ b/include/Pellet.h @@ -101,7 +101,7 @@ struct Pellet : public DualCreature { virtual void startAI(int); // _34 virtual f32 getiMass(); // _38 virtual f32 getSize(); // _3C - virtual f32 getCylinderHeight(); // _44 + virtual f32 getCylinderHeight(); // _44V virtual void doSave(RandomAccessStream&); // _50 virtual void doLoad(RandomAccessStream&); // _54 virtual Vector3f getCentre(); // _58 @@ -156,9 +156,12 @@ struct Pellet : public DualCreature { static bool isUfoPartsID(u32); + // this is the only DLL inline that takes no argument and returns a bool + bool isUfoParts() { return mIsUfoPart; } + // _00 = VTBL // _00-_43C = DualCreature? - // TODO: members + bool mIsUfoPart; // _43C }; /** diff --git a/include/RopeCreature.h b/include/RopeCreature.h index c32d6922..8577c2f9 100644 --- a/include/RopeCreature.h +++ b/include/RopeCreature.h @@ -35,7 +35,7 @@ struct RopeCreature : public Creature { virtual void doKill() = 0; // _10C void setRope(Creature*); - void getRopePos(f32); + Vector3f getRopePos(f32); // _00 = VTBL // _00-_2B8 = Creature diff --git a/include/SearchSystem.h b/include/SearchSystem.h index c7ecf473..226c7651 100644 --- a/include/SearchSystem.h +++ b/include/SearchSystem.h @@ -3,6 +3,7 @@ #include "types.h" #include "Traversable.h" +#include "ComplexCreature.h" struct Creature; @@ -18,12 +19,11 @@ struct SearchData { { _08 = 0; _04 = 12800.0f; - _00 = nullptr; } - Creature* _00; // _00 - f32 _04; // _04 - u32 _08; // _08, unknown + SmartPtr _00; // _00 + f32 _04; // _04 + u32 _08; // _08, unknown }; /** diff --git a/include/StateMachine.h b/include/StateMachine.h index b7d37ff4..117c8ccc 100644 --- a/include/StateMachine.h +++ b/include/StateMachine.h @@ -30,8 +30,9 @@ struct AState : public Receiver { mStateMachine->transit(obj, stateID); } - inline int getStateID() const { return mStateID; } - inline void setOwner(StateMachine* owner) { mStateMachine = owner; } + // only inlines according to the DLL + int getID() { return mStateID; } + void setMachine(StateMachine* owner) { mStateMachine = owner; } // _00 = VTBL int mStateID; // _04 diff --git a/include/UpdateMgr.h b/include/UpdateMgr.h index 2b1b53c4..6a8cce45 100644 --- a/include/UpdateMgr.h +++ b/include/UpdateMgr.h @@ -16,11 +16,13 @@ struct UpdateContext { void init(UpdateMgr*); void exit(); - inline bool isActive() { return mIsActive; } + // these are the two DLL inlines + bool isPiki() { return mIsPiki; } + void setPiki(bool isPiki) { mIsPiki = isPiki; } UpdateMgr* mMgr; // _00 int mMgrSlotIndex; // _04, what slot is client in in mMgr? - bool mIsActive; // _08 + bool mIsPiki; // _08 }; /** diff --git a/include/Vector.h b/include/Vector.h index c1326339..03497257 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -81,7 +81,7 @@ struct Vector3f { // TODO: void normalize(); // TODO: check if this is correct or if one of these needs adjusting - f32 DP(Vector3f& other) const { return x * other.x + y * other.y + z * other.z; } + f32 DP(Vector3f& other) { return x * other.x + y * other.y + z * other.z; } f32 dot(Vector3f& other) const { return x * other.x + y * other.y + z * other.z; } void CP(Vector3f& other) diff --git a/include/math.h b/include/math.h index 72acce1e..737cbc40 100644 --- a/include/math.h +++ b/include/math.h @@ -103,6 +103,10 @@ f32 sqrDistance(KSegment&, KSegment&, f32*, f32*); f32 sqrDistance(KSegment&, KRect&, f32*, f32*, f32*); f32 sqrDistance(KTri&, KRect&, f32*, f32*, f32*, f32*); f32 sqrDistance(Vector3f&, KTri&, f32*, f32*); + +// unused +f32 qdist3(f32 x0, f32 y0, f32 z0, f32 x1, f32 y1, f32 z1); + #endif #endif // _MATH_H diff --git a/src/plugPikiKando/aiActions.cpp b/src/plugPikiKando/aiActions.cpp index b8a5558a..8653dd02 100644 --- a/src/plugPikiKando/aiActions.cpp +++ b/src/plugPikiKando/aiActions.cpp @@ -106,7 +106,7 @@ int ActPick::exec() u32 badCompiler2; mActor->mTargetVelocity.set(0.0f, 0.0f, 0.0f); if (_1C) { - if (!mActor->_2AC) { + if (!mActor->mGrabbedCreature.mPtr) { mActor->startMotion(PaniMotionInfo(PIKIANIM_Walk), PaniMotionInfo(PIKIANIM_Walk)); mActor->mEmotion = 1; return ACTOUT_Fail; @@ -213,7 +213,7 @@ int ActPut::exec() { mActor->mTargetVelocity.set(0.0f, 0.0f, 0.0f); - Creature* obj = mActor->get2AC(); + Creature* obj = mActor->mGrabbedCreature.mPtr; if (!obj) { return ACTOUT_Fail; } diff --git a/src/plugPikiKando/aiAttack.cpp b/src/plugPikiKando/aiAttack.cpp index ffeb2dcf..421957c3 100644 --- a/src/plugPikiKando/aiAttack.cpp +++ b/src/plugPikiKando/aiAttack.cpp @@ -795,23 +795,23 @@ void ActJumpAttack::procCollideMsg(Piki* piki, MsgCollide* msg) return; } - if (msg->mEvent.mCollPart == 0) { + if (msg->mEvent.mColliderPart == 0) { return; } - if (msg->mEvent.mCollPart->mPartType == PART_Platform) { - if (msg->mEvent.mCollPart->isStickable()) { - piki->startStick(msg->mEvent.mCollider, msg->mEvent.mCollPart); + if (msg->mEvent.mColliderPart->mPartType == PART_Platform) { + if (msg->mEvent.mColliderPart->isStickable()) { + piki->startStick(msg->mEvent.mCollider, msg->mEvent.mColliderPart); } else { - if (!msg->mEvent.mCollPart->isClimbable()) { + if (!msg->mEvent.mColliderPart->isClimbable()) { return; } - piki->startStick(msg->mEvent.mCollider, msg->mEvent.mCollPart); + piki->startStick(msg->mEvent.mCollider, msg->mEvent.mColliderPart); } } else { - if (msg->mEvent.mCollPart->mPartType == PART_Collision || msg->mEvent.mCollPart->isTubeLike()) { - if (msg->mEvent.mCollPart->isStickable()) { - piki->startStickObject(msg->mEvent.mCollider, msg->mEvent.mCollPart, -1, 0.0f); + if (msg->mEvent.mColliderPart->mPartType == PART_Collision || msg->mEvent.mColliderPart->isTubeType()) { + if (msg->mEvent.mColliderPart->isStickable()) { + piki->startStickObject(msg->mEvent.mCollider, msg->mEvent.mColliderPart, -1, 0.0f); } else { return; } @@ -820,7 +820,7 @@ void ActJumpAttack::procCollideMsg(Piki* piki, MsgCollide* msg) } _18 = 5; - if (msg->mEvent.mCollPart && msg->mEvent.mCollPart->mPartType == PART_Platform && msg->mEvent.mCollPart->isClimbable()) { + if (msg->mEvent.mColliderPart && msg->mEvent.mColliderPart->mPartType == PART_Platform && msg->mEvent.mColliderPart->isClimbable()) { piki->startClimb(); piki->startMotion(PaniMotionInfo(PIKIANIM_Noboru, this), PaniMotionInfo(PIKIANIM_Noboru)); _18 = 6; diff --git a/src/plugPikiKando/aiBore.cpp b/src/plugPikiKando/aiBore.cpp index ac22c08d..6c2bd1e4 100644 --- a/src/plugPikiKando/aiBore.cpp +++ b/src/plugPikiKando/aiBore.cpp @@ -162,7 +162,7 @@ void ActFreeSelect::determine() int randIdx = selectRandomly(choices, CHILD_COUNT); - if (mActor->_2AC) { + if (mActor->mGrabbedCreature.mPtr) { randIdx = CHILD_Watch; } @@ -700,7 +700,7 @@ void ActBoreSelect::determine() int randIdx = selectRandomly(choices, CHILD_COUNT); - if (mActor->_2AC) { + if (mActor->mGrabbedCreature.mPtr) { randIdx = CHILD_Watch; } @@ -1079,8 +1079,8 @@ void ActBoreTalk::startTalk() mActor->enableMotionBlend(); _20 = randFloat(2.0f) + 5.0f; - if (mActor->mMode == 1 && mActor->mNavi->mPlateMgr && mActor->mNavi->mCurrState->getStateID() != NAVISTATE_DemoSunset - && mActor->mNavi->mCurrState->getStateID() != NAVISTATE_Dead) { + if (mActor->mMode == 1 && mActor->mNavi->mPlateMgr && mActor->mNavi->mCurrState->getID() != NAVISTATE_DemoSunset + && mActor->mNavi->mCurrState->getID() != NAVISTATE_Dead) { seMgr->setPikiNum(0); } /* diff --git a/src/plugPikiKando/aiBou.cpp b/src/plugPikiKando/aiBou.cpp index c85ec38a..58914aad 100644 --- a/src/plugPikiKando/aiBou.cpp +++ b/src/plugPikiKando/aiBou.cpp @@ -48,7 +48,7 @@ void ActBou::init(Creature* creature) mState = STATE_GotoLeg; mActor->startMotion(PaniMotionInfo(PIKIANIM_Walk), PaniMotionInfo(PIKIANIM_Walk)); - if (mActor->_2AC) { + if (mActor->mGrabbedCreature.mPtr) { mActor->_408 = 3; } else { mActor->_408 = 2; @@ -316,7 +316,7 @@ void ActBou::procCollideMsg(Piki* piki, MsgCollide* msg) return; } - if (!msg->mEvent.mCollPart) { + if (!msg->mEvent.mColliderPart) { return; } @@ -330,7 +330,7 @@ void ActBou::procCollideMsg(Piki* piki, MsgCollide* msg) Sphere sphere(centre, radius); Tube tube; - msg->mEvent.mCollPart->makeTube(tube); + msg->mEvent.mColliderPart->makeTube(tube); tube.getYRatio(10.0f + mClimbingStick->mPosition.y); @@ -338,7 +338,7 @@ void ActBou::procCollideMsg(Piki* piki, MsgCollide* msg) f32 f; if (tube.collide(sphere, vec, f)) { _16 = 120; - mActor->startStickObject(msg->mEvent.mCollider, msg->mEvent.mCollPart, -1, 0.0f); + mActor->startStickObject(msg->mEvent.mCollider, msg->mEvent.mColliderPart, -1, 0.0f); mActor->finishLook(); mActor->mOdometer.start(1.0f, 5.0f); diff --git a/src/plugPikiKando/aiBreakWall.cpp b/src/plugPikiKando/aiBreakWall.cpp index cafd0d00..4ae9e9e8 100644 --- a/src/plugPikiKando/aiBreakWall.cpp +++ b/src/plugPikiKando/aiBreakWall.cpp @@ -70,7 +70,7 @@ void ActBreakWall::init(Creature* creature) void ActBreakWall::procCollideMsg(Piki* piki, MsgCollide* msg) { if (piki->getState() != PIKISTATE_LookAt && msg->mEvent.mCollider == mWall && mState != STATE_BreakWall - && msg->mEvent.mCollPart->getID() == 'gate' && !piki->mStickTarget) { + && msg->mEvent.mColliderPart->getID() == 'gate' && !piki->mStickTarget) { _20 = piki->mPosition; initBreakWall(); } diff --git a/src/plugPikiKando/collInfo.cpp b/src/plugPikiKando/collInfo.cpp index d173ff69..33a08bd0 100644 --- a/src/plugPikiKando/collInfo.cpp +++ b/src/plugPikiKando/collInfo.cpp @@ -761,7 +761,7 @@ bool Tube::collide(const Sphere&, Vector3f&, f32&) * Address: 800876C8 * Size: 0000E4 */ -void Cylinder::getPosRatio(const Vector3f&) +f32 Cylinder::getPosRatio(const Vector3f&) { /* .loc_0x0: @@ -1177,7 +1177,7 @@ bool CollPart::isStickable() return true; } - if (isTubeLike() || mPartType == PART_Collision) { + if (isTubeType() || mPartType == PART_Collision) { if (getCode().match('s***', '*')) { return true; } @@ -1683,7 +1683,7 @@ void CollPart::update(Graphics&, bool) * Address: ........ * Size: 0001A4 */ -void CollPart::collide(Creature*, Vector3f&) +bool CollPart::collide(Creature*, Vector3f&) { // UNUSED FUNCTION } @@ -1693,7 +1693,7 @@ void CollPart::collide(Creature*, Vector3f&) * Address: ........ * Size: 000158 */ -void CollPart::collide(Vector3f&, f32, Vector3f&) +bool CollPart::collide(Vector3f&, f32, Vector3f&) { // UNUSED FUNCTION } @@ -1703,7 +1703,7 @@ void CollPart::collide(Vector3f&, f32, Vector3f&) * Address: 80088520 * Size: 00066C */ -void CollPart::collide(CollPart*, Vector3f&) +bool CollPart::collide(CollPart*, Vector3f&) { /* .loc_0x0: @@ -2273,7 +2273,7 @@ void CollPart::makeCylinder(Cylinder&) * Address: ........ * Size: 000048 */ -void CollPart::samePlatShape(Shape*) +bool CollPart::samePlatShape(Shape*) { // UNUSED FUNCTION } @@ -2524,14 +2524,14 @@ void CollInfo::checkCollisionSpecialRec(int, Vector3f&, f32, CndCollPart*) * Address: 80088F00 * Size: 000028 */ -void CollInfo::checkCollision(Creature* creature, Vector3f& p2) { checkCollisionRec(creature, 0, p2); } +CollPart* CollInfo::checkCollision(Creature* creature, Vector3f& p2) { return checkCollisionRec(creature, 0, p2); } /* * --INFO-- * Address: 80088F28 * Size: 000624 */ -void CollInfo::checkCollisionRec(Creature*, int, Vector3f&) +CollPart* CollInfo::checkCollisionRec(Creature*, int, Vector3f&) { /* .loc_0x0: @@ -2986,7 +2986,7 @@ void CollInfo::checkCollisionRec(Creature*, int, Vector3f&) * Address: 80089574 * Size: 000034 */ -void CollInfo::checkCollision(CollInfo*, CollPart**, CollPart**, Vector3f&) +bool CollInfo::checkCollision(CollInfo*, CollPart**, CollPart**, Vector3f&) { /* .loc_0x0: @@ -3360,7 +3360,7 @@ CollPart* CollInfo::getRandomCollPart(u32) * Address: 80089A1C * Size: 0000D0 */ -void CollInfo::getPlatform(DynCollObject*) +CollPart* CollInfo::getPlatform(DynCollObject*) { /* .loc_0x0: diff --git a/src/plugPikiKando/complexCreature.cpp b/src/plugPikiKando/complexCreature.cpp index dc3c10dc..9b2617f5 100644 --- a/src/plugPikiKando/complexCreature.cpp +++ b/src/plugPikiKando/complexCreature.cpp @@ -1,4 +1,5 @@ #include "ComplexCreature.h" +#include "Creature.h" #include "Collision.h" /* @@ -90,6 +91,6 @@ void ComplexCreature::postUpdate(int, f32) { // this is just here for the weak function generation mCreatures[0].mPtr->bounceCallback(); - mCreatures[0].mPtr->collisionCallback(CollEvent()); + mCreatures[0].mPtr->collisionCallback(CollEvent(nullptr, nullptr, nullptr)); // UNUSED FUNCTION } diff --git a/src/plugPikiKando/creature.cpp b/src/plugPikiKando/creature.cpp index fbd72269..f1b72c55 100644 --- a/src/plugPikiKando/creature.cpp +++ b/src/plugPikiKando/creature.cpp @@ -1,16 +1,22 @@ #include "Creature.h" #include "SearchSystem.h" - #include "Collision.h" #include "DynColl.h" #include "Geometry.h" #include "SoundMgr.h" +#include "Graphics.h" +#include "AIConstant.h" +#include "CreatureProp.h" #include "Generator.h" #include "Dolphin/os.h" #include "math.h" +#include "Pellet.h" +#include "timers.h" #include "BombItem.h" #include "RadarInfo.h" #include "AIPerf.h" +#include "MapCode.h" +#include "DebugLog.h" static CollTriInfo* triList[0x200]; @@ -23,21 +29,14 @@ static f32 checkRadius; * Address: ........ * Size: 00009C */ -static void _Error(char* fmt, ...) -{ - OSPanic(__FILE__, __LINE__, fmt); - // UNUSED FUNCTION -} +DEFINE_ERROR(); /* * --INFO-- * Address: ........ * Size: 0000F4 */ -static void _Print(char*, ...) -{ - // UNUSED FUNCTION -} +DEFINE_PRINT("Creature"); /* * --INFO-- @@ -46,7 +45,8 @@ static void _Print(char*, ...) */ void Creature::startFixPosition() { - // UNUSED FUNCTION + mFixedPosition = mPosition; + setCreatureFlag(CF_FixPosition); } /* @@ -61,30 +61,26 @@ void Creature::finishFixPosition() { resetCreatureFlag(CF_FixPosition); } * Address: 8008A050 * Size: 000048 */ -bool Creature::isTerrible() -{ - bool terror = true; - if (mObjType != OBJTYPE_Teki && !isBoss()) { - terror = false; - } - return terror; -} +bool Creature::isTerrible() { return isTeki() || isBoss(); } /* * --INFO-- * Address: 8008A098 * Size: 0000D8 */ -void Creature::load(RandomAccessStream& stream, bool p2) +void Creature::load(RandomAccessStream& stream, bool doLoadPosition) { - (ObjType::getName(mObjType)); - (stream.getPosition()); - if (p2) { - mPosition.read(stream); + PRINT("* loading creature %s\n", ObjType::getName(mObjType)); + int startPos = stream.getPosition(); + if (doLoadPosition) { + // idk why they didn't use the Vector3f::read inline here, but they didn't + mPosition.x = stream.readFloat(); + mPosition.y = stream.readFloat(); + mPosition.z = stream.readFloat(); } doLoad(stream); - (stream.getPosition()); + PRINT("******** done : %d\n", stream.getPosition() - startPos); } /* @@ -92,16 +88,19 @@ void Creature::load(RandomAccessStream& stream, bool p2) * Address: 8008A170 * Size: 0000D8 */ -void Creature::save(RandomAccessStream& stream, bool p2) +void Creature::save(RandomAccessStream& stream, bool doSavePosition) { - (ObjType::getName(mObjType)); - (stream.getPosition()); - if (p2) { - mPosition.write(stream); + PRINT("* saving creature %s\n", ObjType::getName(mObjType)); + int startPos = stream.getPosition(); + if (doSavePosition) { + // idk why they didn't use the Vector3f::write inline here but they didn't + stream.writeFloat(mPosition.x); + stream.writeFloat(mPosition.y); + stream.writeFloat(mPosition.z); } doSave(stream); - (stream.getPosition()); + PRINT("******** done : %d\n", stream.getPosition() - startPos); } /* @@ -111,8 +110,8 @@ void Creature::save(RandomAccessStream& stream, bool p2) */ Creature* Creature::getCollidePlatformCreature() { - if (_280) { - return _280->_28; + if (mCollPlatform) { + return mCollPlatform->mCreature; } return nullptr; } @@ -124,10 +123,10 @@ Creature* Creature::getCollidePlatformCreature() */ Vector3f Creature::getCollidePlatformNormal() { - if (!_284) { + if (!mCollPlatNormal) { return Vector3f(0.0, 0.0f, 0.0f); } - return *_284; + return *mCollPlatNormal; } /* @@ -153,6 +152,8 @@ void Creature::enableStick() { if (mCollInfo && mCollInfo->hasInfo()) { mCollInfo->enableStick(); + } else { + PRINT("enableStick * nothing is done\n"); } } @@ -165,6 +166,8 @@ void Creature::disableStick() { if (mCollInfo && mCollInfo->hasInfo()) { mCollInfo->disableStick(); + } else { + PRINT("disableStick * nothing is done\n"); } } @@ -202,10 +205,8 @@ CollPart* Creature::getRandomCollPart(u32 p1) */ Vector3f Creature::getBoundingSphereCentre() { - u32 badCompiler; - if (mCollInfo && mCollInfo->hasInfo()) { - if (mObjType != OBJTYPE_Navi && mObjType != OBJTYPE_Piki && isCreatureFlag(CF_IsAICullingActive) && mGrid.aiCulling()) { + if (mObjType != OBJTYPE_Navi && !isPiki() && !aiCullable() && mGrid.aiCulling()) { return mPosition; } @@ -223,11 +224,9 @@ Vector3f Creature::getBoundingSphereCentre() */ f32 Creature::getBoundingSphereRadius() { - u32 badCompiler; - if (mCollInfo && mCollInfo->hasInfo()) { CollPart* bound = mCollInfo->getBoundingSphere(); - if (mObjType != OBJTYPE_Navi && mObjType != OBJTYPE_Piki && isCreatureFlag(CF_IsAICullingActive) && mGrid.aiCulling()) { + if (mObjType != OBJTYPE_Navi && !isPiki() && !aiCullable() && mGrid.aiCulling()) { return 2.0f * bound->mRadius; } @@ -266,9 +265,13 @@ void Creature::stopEventSound(Creature* target, int soundID) * Address: ........ * Size: 0000C4 */ -void Creature::insideSphere(Sphere&) +bool Creature::insideSphere(Sphere& sphere) { - // UNUSED FUNCTION + Vector3f diff = sphere.mCentre - mPosition; + if (diff.length() <= sphere.mRadius) { + return true; + } + return false; } /* @@ -278,11 +281,9 @@ void Creature::insideSphere(Sphere&) */ Vector3f Creature::getCentre() { - u32 badCompiler; - if (mCollInfo && mCollInfo->hasInfo()) { CollPart* spherePart = mCollInfo->getSphere('cent'); - if (mObjType != OBJTYPE_Navi && mObjType != OBJTYPE_Piki && isCreatureFlag(CF_IsAICullingActive) && mGrid.aiCulling()) { + if (mObjType != OBJTYPE_Navi && !isPiki() && !aiCullable() && mGrid.aiCulling()) { return mPosition; } if (spherePart) { @@ -318,29 +319,29 @@ f32 Creature::getCentreSize() int Creature::getStandType() { if (!mFloorTri) { - if (_280) { - if (_280->_28) { + if (mCollPlatform) { + if (mCollPlatform->mCreature) { // standing on a platform creature? - return STANDTYPE_Unk1; + return STANDTYPE_TekiPlatform; } // standing on a platform with no creature? - return STANDTYPE_Unk2; + return STANDTYPE_Platform; } // no platform, _2BC == 0 - return STANDTYPE_Unk3; + return STANDTYPE_Air; } - if (_280) { - if (_280->_28) { + if (mCollPlatform) { + if (mCollPlatform->mCreature) { // standing on a platform creature? - return STANDTYPE_Unk1; + return STANDTYPE_TekiPlatform; } // standing on a platform with no creature? - return STANDTYPE_Unk2; + return STANDTYPE_Platform; } // no platform, _2BC != 0 - return STANDTYPE_Unk0; + return STANDTYPE_Ground; } /* @@ -349,13 +350,9 @@ int Creature::getStandType() * Size: 00005C */ SearchData::SearchData() - : _00(nullptr) - , _08(0) { - if (_00) { - _00->subCnt(); - _00 = nullptr; - } + _08 = 0; + _00.reset(); _04 = 12800.0f; } @@ -367,7 +364,7 @@ SearchData::SearchData() u32 Creature::getGeneratorID() { if (mGenerator) { - return mGenerator->_58.getID(); + return mGenerator->_58.mId; } return 'null'; } @@ -379,7 +376,7 @@ u32 Creature::getGeneratorID() */ bool Creature::stimulate(Interaction& interaction) { - (ObjType::getName(mObjType)); + PRINT("objType=%s creature %x got interaction %x\n", ObjType::getName(mObjType), &interaction); return false; } @@ -388,140 +385,27 @@ bool Creature::stimulate(Interaction& interaction) * Address: 8008A89C * Size: 000138 */ -bool Creature::setStateGrabbed(Creature* p1) +bool Creature::setStateGrabbed(Creature* holder) { - if (_2A8) { + if (isGrabbed()) { + // we're already being held by something return false; } - if (_2A8) { - if (_2A8) { - _2A8->subCnt(); - _2A8 = nullptr; - } - } - - _2A8 = p1; - if (_2A8) { - _2A8->addCnt(); - } - - // what is going on with this - Creature** list = &_2AC; - if (_2AC) { - if (list[0]) { - list[0]->subCnt(); - list[0] = nullptr; - } - list[0] = this; - if (list[0]) { - list[0]->addCnt(); - } - } + mHoldingCreature.set(holder); + holder->mGrabbedCreature.set(this); mPreGrabRotation = _E0; _100.fromEuler(Vector3f(0.39269909f, 0.0f, 0.0f)); _110 = 0.0f; + PRINT("setStateGrabbed : this=%x c=%x\n", this, holder); if (mObjType != OBJTYPE_Bomb) { + PRINT("*** THIS IS NOT BOMB !!\n"); dump(); - p1->dump(); + holder->dump(); } - return true; - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x38(r1) - stw r31, 0x34(r1) - stw r30, 0x30(r1) - addi r30, r4, 0 - stw r29, 0x2C(r1) - mr r29, r3 - lwz r3, 0x2A8(r3) - cmplwi r3, 0 - beq- .loc_0x34 - li r3, 0 - b .loc_0x11C - - .loc_0x34: - beq- .loc_0x48 - beq- .loc_0x48 - bl 0x59A94 - li r0, 0 - stw r0, 0x2A8(r29) - - .loc_0x48: - stw r30, 0x2A8(r29) - lwz r3, 0x2A8(r29) - cmplwi r3, 0 - beq- .loc_0x5C - bl 0x59A68 - - .loc_0x5C: - lwz r0, 0x2AC(r30) - addi r31, r30, 0x2AC - cmplwi r0, 0 - beq- .loc_0x84 - lwz r3, 0x0(r31) - cmplwi r3, 0 - beq- .loc_0x84 - bl 0x59A58 - li r0, 0 - stw r0, 0x0(r31) - - .loc_0x84: - stw r29, 0x0(r31) - lwz r3, 0x0(r31) - cmplwi r3, 0 - beq- .loc_0x98 - bl 0x59A2C - - .loc_0x98: - lwz r5, 0xE0(r29) - addi r4, r1, 0x18 - lwz r0, 0xE4(r29) - addi r3, r29, 0x100 - stw r5, 0xF0(r29) - stw r0, 0xF4(r29) - lwz r5, 0xE8(r29) - lwz r0, 0xEC(r29) - stw r5, 0xF8(r29) - stw r0, 0xFC(r29) - lfs f0, -0x5E3C(r13) - lfs f1, -0x5E38(r13) - stfs f0, 0x18(r1) - lfs f0, -0x5E34(r13) - stfs f1, 0x1C(r1) - stfs f0, 0x20(r1) - bl -0x5268C - lfs f0, -0x7584(r2) - stfs f0, 0x110(r29) - lwz r0, 0x6C(r29) - cmpwi r0, 0xE - beq- .loc_0x118 - mr r3, r29 - lwz r12, 0x0(r29) - lwz r12, 0xC8(r12) - mtlr r12 - blrl - mr r3, r30 - lwz r12, 0x0(r30) - lwz r12, 0xC8(r12) - mtlr r12 - blrl - .loc_0x118: - li r3, 0x1 - - .loc_0x11C: - lwz r0, 0x3C(r1) - lwz r31, 0x34(r1) - lwz r30, 0x30(r1) - lwz r29, 0x2C(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + return true; } /* @@ -531,16 +415,9 @@ bool Creature::setStateGrabbed(Creature* p1) */ void Creature::resetStateGrabbed() { - Creature** list = &_2A8->_2AC; - if (_2A8->_2AC) { - list[0]->subCnt(); - list[0] = nullptr; - } - - if (_2A8) { - _2A8->subCnt(); - _2A8 = nullptr; - } + mHoldingCreature.getPtr()->mGrabbedCreature.reset(); + mHoldingCreature.reset(); + PRINT("## resetStateGrabbed\n"); } /* @@ -555,9 +432,12 @@ void Creature::turnTo(Vector3f& targetDir) { mDirection = atan2f(targetDir.x - m * Address: ........ * Size: 0000FC */ -void Creature::adjustDistance(Vector3f&, f32) +void Creature::adjustDistance(Vector3f& targetPos, f32 targetDist) { - // UNUSED FUNCTION + Vector3f sep = targetPos - mPosition; + f32 dist = sep.length(); + sep = (targetDist / dist) * sep; + mPosition = targetPos - sep; } /* @@ -571,16 +451,16 @@ void Creature::init() _114.makeIdentity(); mTransformMatrix.makeIdentity(); _E0.set(0.0f, 0.0f, 0.0f, 1.0f); - _60 = 0; - mCreatureFlags = 0; - _1A0 = -1; - resetCreatureFlag(CF_IsAICullingActive); + _60 = 0; + mCreatureFlags = 0; + mPelletStickSlot = -1; + disableAICulling(); _21C = 0; setCreatureFlag(CF_Free); - resetCreatureFlag(CF_Unk9 | CF_IsAiDisabled | CF_Unk14 | CF_AIAlwaysActive); + resetCreatureFlag(CF_Unk9 | CF_IsAiDisabled | CF_IsClimbing | CF_AIAlwaysActive); mAbsPickOffset = 0.0f; - _2A8 = nullptr; - _2AC = nullptr; + mHoldingCreature.clear(); + mGrabbedCreature.clear(); resetCreatureFlag(CF_Unk6 | CF_Unk17); clearCnt(); mIsBeingDamaged = false; @@ -590,20 +470,21 @@ void Creature::init() mVolatileVelocity.set(0.0f, 0.0f, 0.0f); _1AC.set(0.0f, 0.0f, 0.0f); mStickTarget = nullptr; - mStickPart = 0; - _190 = 0; - _18C = 0; - _180 = 0; + mStickPart = nullptr; + + mPrevSticker = nullptr; + mNextSticker = nullptr; + mStickListHead = nullptr; resetCreatureFlag(CF_StuckToObject | CF_StuckToMouth); - _154 = 0; - _158 = 0; - _15C = 0.0f; - _164 = 0; - _160 = 0; + mRopeListHead = nullptr; + mRope = nullptr; + mRopeRatio = 0.0f; + mPrevRopeHolder = nullptr; + mNextRopeHolder = nullptr; if (searchUpdateMgr) { - if (mObjType == OBJTYPE_Piki) { - _168.mIsActive = true; + if (isPiki()) { + _168.setPiki(true); } _168.init(searchUpdateMgr); @@ -628,9 +509,9 @@ void Creature::init(Vector3f& pos) * Address: ........ * Size: 000008 */ -void Creature::getAtariType() +int Creature::getAtariType() { - // UNUSED FUNCTION + return 0; // from the DLL - lol. } /* @@ -665,17 +546,21 @@ void Creature::detachGenerator() void Creature::kill(bool p1) { finishWaterEffect(); + + if (mObjType == OBJTYPE_Teki) { + PRINT("TEKI DIED ************************************\n"); + } + detachGenerator(); - if (_2AC) { - Creature* bomb = _2AC; + + if (isHolding()) { + Creature* bomb = getHoldCreature(); bomb->resetStateGrabbed(); - if (bomb->mObjType == OBJTYPE_Bomb) { - AState* state = static_cast(bomb)->getCurrState(); - int currState = state->getStateID(); - if (currState != 1) { + if (static_cast(bomb)->mObjType == OBJTYPE_Bomb) { + if (static_cast(bomb)->getCurrState()->getID() != 1) { MsgUser msg(1); - static_cast(bomb)->_2D0 = 1; - static_cast(bomb)->mStateMachine->procMsg(static_cast(bomb), &msg); + static_cast(bomb)->_2D0 = 1; + static_cast(bomb)->mStateMachine->procMsg(static_cast(bomb), &msg); } } } @@ -694,27 +579,32 @@ void Creature::kill(bool p1) endStick(); } - if (_180) { - while (_180) { - if (_180->isCreatureFlag(CF_StuckToObject)) { - _180->endStickObject(); + if (mStickListHead) { + PRINT("%x(type%d) died : release all stickers ..\n", this, mObjType); + while (mStickListHead) { + if (mStickListHead->isCreatureFlag(CF_StuckToObject)) { + PRINT("stick off object\n"); + mStickListHead->endStickObject(); - } else if (_180->isCreatureFlag(CF_StuckToMouth)) { - _180->endStickMouth(); + } else if (mStickListHead->isCreatureFlag(CF_StuckToMouth)) { + PRINT("stick off mouth\n"); + mStickListHead->endStickMouth(); } else { - _180->endStick(); + PRINT("stick off\n"); + mStickListHead->endStick(); } } + PRINT("done\n"); } - if (_158) { + if (mRope) { endRope(); } - if (_154) { - while (_154) { - _154->endRope(); + if (mRopeListHead) { + while (mRopeListHead) { + mRopeListHead->endRope(); } } @@ -897,8 +787,6 @@ void Creature::kill(bool p1) * Size: 0002C0 */ Creature::Creature(CreatureProp* props) - : _2A8(nullptr) - , _2AC(0) { mObjType = OBJTYPE_INVALID; mSeContext = nullptr; @@ -907,11 +795,13 @@ Creature::Creature(CreatureProp* props) mCollInfo = nullptr; mFloorTri = nullptr; _30 = 0; - resetCreatureFlag(CF_Unk16); - _34 = 0; - _284 = 0; - _288 = 0; - mGenerator = nullptr; + + disableFlag10000(); + setRebirthDay(0); + + mCollPlatNormal = nullptr; + _288 = 0; + mGenerator = nullptr; mTargetVelocity.set(0.0f, 0.0f, 0.0f); _B0.set(0.0f, 0.0f, 0.0f); @@ -919,19 +809,24 @@ Creature::Creature(CreatureProp* props) mRotation.set(0.0f, 0.0f, 0.0f); mPosition.set(0.0f, 0.0f, 0.0f); mScale.set(1.0f, 1.0f, 1.0f); + mDirection = 0.0f; _26C = 10.0f; mCollisionRadius = 16.0f; mProps = props; _28 = 0; resetCreatureFlag(CF_Unk10); + _E0.fromEuler(Vector3f(0.0f, 0.0f, 0.0f)); _D4.set(0.0f, 0.0f, 0.0f); + resetCreatureFlag(CF_Unk1 | CF_Unk6); - _2A8 = nullptr; - _2AC = 0; + + mHoldingCreature.clear(); + mGrabbedCreature.clear(); + mIsBeingDamaged = false; - _280 = 0; + mCollPlatform = nullptr; _290 = 0; _298 = 0; _2B0 = 0; @@ -960,409 +855,129 @@ void Creature::updateStatic() */ void Creature::update() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0xA8(r1) - stfd f31, 0xA0(r1) - stfd f30, 0x98(r1) - stfd f29, 0x90(r1) - stfd f28, 0x88(r1) - stw r31, 0x84(r1) - mr r31, r3 - stw r30, 0x80(r1) - lwz r3, 0x2C(r3) - cmplwi r3, 0 - beq- .loc_0x38 - bl 0x18CB0 + if (mSeContext) { + mSeContext->update(); + } - .loc_0x38: - addi r3, r31, 0x40 - addi r4, r31, 0x94 - bl 0x92D8 - lwz r0, 0x6C(r31) - li r30, 0 - cmpwi r0, 0 - beq- .loc_0x5C - cmpwi r0, 0x36 - bne- .loc_0x60 + mGrid.updateGrid(mPosition); + bool isPikiOrNavi = false; + if (mObjType == OBJTYPE_Piki || mObjType == OBJTYPE_Navi) { + isPikiOrNavi = true; + } - .loc_0x5C: - li r30, 0x1 + mGrid.updateAIGrid(mPosition, isPikiOrNavi); - .loc_0x60: - addi r5, r30, 0 - addi r3, r31, 0x40 - addi r4, r31, 0x94 - bl 0x9348 - rlwinm. r0,r30,0,24,31 - bne- .loc_0xA0 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,11,11 - bne- .loc_0xA0 - addi r3, r31, 0x40 - bl 0x8F00 - rlwinm. r0,r3,0,24,31 - beq- .loc_0xA0 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,12,12 - bne- .loc_0x558 + // in the DLL this ONE TIME doesn't use the isCreatureFlag inline + // but it doesn't affect anything (for now) so i'm adding it in + if (!isPikiOrNavi && !isCreatureFlag(CF_AIAlwaysActive) && mGrid.aiCulling() && !aiCullable()) { + return; + } + _1A4 = 0; + _1A8 = 0; - .loc_0xA0: - li r0, 0 - stw r0, 0x1A4(r31) - stw r0, 0x1A8(r31) - lwz r0, 0x2B0(r31) - cmplwi r0, 0 - bne- .loc_0xD4 - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x108(r12) - mtlr r12 - blrl - mr r3, r31 - bl 0x6A4 + if (!_2B0) { + doAnimation(); + updateAI(); + } - .loc_0xD4: - lwz r0, 0x2A8(r31) - cmplwi r0, 0 - bne- .loc_0x558 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,16,16 - beq- .loc_0x12C - lwz r4, 0x180(r31) - cmplwi r4, 0 - beq- .loc_0x110 - lwz r3, 0x94(r4) - lwz r0, 0x98(r4) - stw r3, 0x94(r31) - stw r0, 0x98(r31) - lwz r0, 0x9C(r4) - stw r0, 0x9C(r31) + if (!mHoldingCreature.isNull()) { + return; + } - .loc_0x110: - lwz r0, 0x184(r31) - cmplwi r0, 0 - bne- .loc_0x558 - lwz r0, 0xC8(r31) - rlwinm r0,r0,0,17,15 - stw r0, 0xC8(r31) - b .loc_0x558 + if (isCreatureFlag(CF_StuckToMouth)) { + if (mStickListHead) { + mPosition = mStickListHead->mPosition; + } + if (!mStickTarget) { + resetCreatureFlag(CF_StuckToMouth); + PRINT("MOUTH RESET\n"); + } + return; + } - .loc_0x12C: - lwz r0, 0x158(r31) - cmplwi r0, 0 - beq- .loc_0x140 - mr r3, r31 - bl 0x66D8 + if (mRope) { + updateStickRope(); + } - .loc_0x140: - mr r3, r31 - bl 0x3180 - lwz r0, 0x184(r31) - cmplwi r0, 0 - beq- .loc_0x17C - mr r3, r31 - bl 0x4BF0 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x170 - mr r3, r31 - bl 0x5A94 - b .loc_0x558 + moveAttach(); - .loc_0x170: - mr r3, r31 - bl 0x5CDC - b .loc_0x558 + if (mStickTarget) { + if (isStickToPlatform()) { + updateStickPlatform(); + } else { + updateStickNonPlatform(); + } + return; + } - .loc_0x17C: - lwz r3, 0x28C(r31) - li r0, -0x1 - cmplwi r3, 0 - beq- .loc_0x194 - bl 0x8ACEC - mr r0, r3 - - .loc_0x194: - cmpwi r0, 0x5 - bne- .loc_0x1E0 - lbz r0, 0x60(r31) - cmplwi r0, 0 - bne- .loc_0x1BC - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0xCC(r12) - mtlr r12 - blrl + int attr = ATTR_NULL; + if (mFloorTri) { + attr = MapCode::getAttribute(mFloorTri); + } - .loc_0x1BC: - lbz r3, 0x60(r31) - addi r0, r3, 0x1 - stb r0, 0x60(r31) - lbz r0, 0x60(r31) - cmplwi r0, 0xF0 - ble- .loc_0x208 - li r0, 0xF0 - stb r0, 0x60(r31) - b .loc_0x208 - - .loc_0x1E0: - lbz r0, 0x60(r31) - cmplwi r0, 0 - beq- .loc_0x208 - li r0, 0 - stb r0, 0x60(r31) - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0xD0(r12) - mtlr r12 - blrl + if (attr == ATTR_Unk5) { + if (_60 == 0) { + startWaterEffect(); + } - .loc_0x208: - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,13,13 - bne- .loc_0x558 - lwz r4, 0x2DEC(r13) - mr r3, r31 - lfs f0, 0x70(r31) - lfs f31, 0x28C(r4) - stfs f0, 0x74(r1) - fmr f1, f31 - lfs f0, 0x74(r31) - stfs f0, 0x78(r1) - lfs f0, 0x78(r31) - stfs f0, 0x7C(r1) - lwz r4, 0xBC(r31) - lwz r0, 0xC0(r31) - stw r4, 0x70(r31) - stw r0, 0x74(r31) - lwz r0, 0xC4(r31) - stw r0, 0x78(r31) - bl 0x3180 - lfs f1, 0xBC(r31) - lfs f0, 0xC0(r31) - fmuls f2, f1, f1 - lfs f3, 0xC4(r31) - fmuls f1, f0, f0 - lfs f0, -0x7584(r2) - fmuls f3, f3, f3 - fadds f1, f2, f1 - fadds f4, f3, f1 - fcmpo cr0, f4, f0 - ble- .loc_0x2DC - fsqrte f1, f4 - lfd f3, -0x7580(r2) - lfd f2, -0x7578(r2) - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f0, f1, f0 - fmul f0, f4, f0 - frsp f0, f0 - stfs f0, 0x4C(r1) - lfs f4, 0x4C(r1) + _60++; - .loc_0x2DC: - lfs f0, -0x7584(r2) - fcmpo cr0, f4, f0 - ble- .loc_0x344 - lwz r3, 0xC8(r31) - rlwinm. r0,r3,0,9,9 - beq- .loc_0x344 - rlwinm. r0,r3,0,10,10 - beq- .loc_0x344 - lwz r3, 0x28C(r31) - cmplwi r3, 0 - beq- .loc_0x344 - bl 0x8AB7C - cmpwi r3, 0 - bne- .loc_0x344 - lfs f1, -0x7560(r2) - bl 0x1907C8 - lwz r3, 0x28C(r31) - lfs f0, 0x1C(r3) - fcmpo cr0, f0, f1 - ble- .loc_0x344 - lwz r3, 0x94(r31) - lwz r0, 0x98(r31) - stw r3, 0x1C(r31) - stw r0, 0x20(r31) - lwz r0, 0x9C(r31) - stw r0, 0x24(r31) - - .loc_0x344: - lwz r4, 0x74(r1) - fmr f1, f31 - lwz r0, 0x78(r1) - mr r3, r31 - stw r4, 0x70(r31) - stw r0, 0x74(r31) - lwz r0, 0x7C(r1) - stw r0, 0x78(r31) - bl 0x3070 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,9,9 - beq- .loc_0x534 - lwz r3, 0x28C(r31) - cmplwi r3, 0 - beq- .loc_0x474 - bl 0x8AB04 - cmpwi r3, 0 - bne- .loc_0x474 - lfs f1, -0x7560(r2) - bl 0x190750 - lwz r3, 0x28C(r31) - lfs f0, 0x1C(r3) - fcmpo cr0, f0, f1 - ble- .loc_0x474 - lfs f1, 0xA4(r31) - lfs f0, 0xA8(r31) - fmuls f2, f1, f1 - lfs f3, 0xAC(r31) - fmuls f1, f0, f0 - lfs f0, -0x7584(r2) - fmuls f3, f3, f3 - fadds f1, f2, f1 - fadds f4, f3, f1 - fcmpo cr0, f4, f0 - ble- .loc_0x428 - fsqrte f1, f4 - lfd f3, -0x7580(r2) - lfd f2, -0x7578(r2) - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f0, f1, f0 - fmul f0, f4, f0 - frsp f0, f0 - stfs f0, 0x48(r1) - lfs f4, 0x48(r1) - - .loc_0x428: - lfs f0, -0x755C(r2) - fcmpo cr0, f4, f0 - bge- .loc_0x464 - lwz r3, 0xC8(r31) - rlwinm. r0,r3,0,10,10 - bne- .loc_0x480 - oris r0, r3, 0x20 - stw r0, 0xC8(r31) - lwz r3, 0x94(r31) - lwz r0, 0x98(r31) - stw r3, 0x1C(r31) - stw r0, 0x20(r31) - lwz r0, 0x9C(r31) - stw r0, 0x24(r31) - b .loc_0x480 - - .loc_0x464: - lwz r0, 0xC8(r31) - rlwinm r0,r0,0,11,9 - stw r0, 0xC8(r31) - b .loc_0x480 - - .loc_0x474: - lwz r0, 0xC8(r31) - rlwinm r0,r0,0,11,9 - stw r0, 0xC8(r31) - - .loc_0x480: - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,10,10 - beq- .loc_0x534 - lfs f3, 0x1C(r31) - lfs f2, 0x94(r31) - lfs f1, 0x20(r31) - lfs f0, 0x98(r31) - fsubs f30, f3, f2 - lfs f2, 0x24(r31) - fsubs f29, f1, f0 - lfs f0, 0x9C(r31) - fmuls f1, f30, f30 - fsubs f28, f2, f0 - fmuls f0, f29, f29 - fmuls f2, f28, f28 - fadds f0, f1, f0 - fadds f1, f2, f0 - bl -0x7DA8C - lfs f0, -0x7584(r2) - fcmpu cr0, f0, f1 - beq- .loc_0x4E0 - fdivs f30, f30, f1 - fdivs f29, f29, f1 - fdivs f28, f28, f1 + if (_60 > 240) { + _60 = 240; + } + } else { + if (_60 != 0) { + _60 = 0; + finishWaterEffect(); + } + } - .loc_0x4E0: - lfs f0, -0x7558(r2) - fcmpo cr0, f1, f0 - blt- .loc_0x4F0 - lfs f1, -0x7584(r2) + if (isCreatureFlag(CF_Unk18)) { + return; + } - .loc_0x4F0: - lfs f0, -0x7584(r2) - fcmpo cr0, f1, f0 - ble- .loc_0x534 - lfs f0, -0x7568(r2) - fmuls f0, f0, f1 - fmuls f2, f30, f0 - fmuls f1, f29, f0 - fmuls f0, f28, f0 - stfs f2, 0x74(r1) - stfs f1, 0x78(r1) - stfs f0, 0x7C(r1) - lwz r3, 0x74(r1) - lwz r0, 0x78(r1) - stw r3, 0x70(r31) - stw r0, 0x74(r31) - lwz r0, 0x7C(r1) - stw r0, 0x78(r31) + f32 stepTime = gsys->getFrameTime(); + Vector3f vel(mVelocity); + mVelocity = mVolatileVelocity; + moveNew(stepTime); - .loc_0x534: - lfs f0, -0x5DB8(r13) - fmr f1, f31 - mr r3, r31 - stfs f0, 0xBC(r31) - lfs f0, -0x5DB4(r13) - stfs f0, 0xC0(r31) - lfs f0, -0x5DB0(r13) - stfs f0, 0xC4(r31) - bl 0x2B70 - - .loc_0x558: - lwz r0, 0xAC(r1) - lfd f31, 0xA0(r1) - lfd f30, 0x98(r1) - lfd f29, 0x90(r1) - lfd f28, 0x88(r1) - lwz r31, 0x84(r1) - lwz r30, 0x80(r1) - addi r1, r1, 0xA8 - mtlr r0 - blr - */ + if (mVolatileVelocity.length() > 0.0f && isCreatureFlag(CF_Unk22) && isCreatureFlag(CF_FixPosition) && mFloorTri + && MapCode::getSlipCode(mFloorTri) == 0 && mFloorTri->_18.y > sinf(THIRD_PI)) { + mFixedPosition = mPosition; + } + + mVelocity = vel; + moveNew(stepTime); + + if (isCreatureFlag(CF_Unk22)) { + if (mFloorTri && MapCode::getSlipCode(mFloorTri) == 0 && mFloorTri->_18.y > sinf(THIRD_PI)) { + if (mTargetVelocity.length() < 0.01f) { + if (!isCreatureFlag(CF_FixPosition)) { + setCreatureFlag(CF_FixPosition); + mFixedPosition = mPosition; + } + } else { + resetCreatureFlag(CF_FixPosition); + } + } else { + resetCreatureFlag(CF_FixPosition); + } + + if (isCreatureFlag(CF_FixPosition)) { + Vector3f fixedDir = mFixedPosition - mPosition; + f32 dist = fixedDir.normalise(); + if (!(dist < 30.0f)) { + dist = 0.0f; + } + if (dist > 0.0f) { + vel = (10.0f * dist) * fixedDir; + mVelocity = vel; + } + } + } + + mVolatileVelocity.set(0.0f, 0.0f, 0.0f); + moveRotation(stepTime); } /* @@ -1370,892 +985,201 @@ void Creature::update() * Address: 8008B788 * Size: 0001F4 */ -void Creature::postUpdate(int, f32) +void Creature::postUpdate(int, f32 p2) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x58(r1) - stfd f31, 0x50(r1) - fmr f31, f1 - stw r31, 0x4C(r1) - mr r31, r3 - stw r30, 0x48(r1) - stw r29, 0x44(r1) - lwz r0, 0x6C(r3) - li r3, 0 - cmpwi r0, 0 - beq- .loc_0x3C - cmpwi r0, 0x36 - bne- .loc_0x40 - - .loc_0x3C: - li r3, 0x1 - - .loc_0x40: - rlwinm. r0,r3,0,24,31 - bne- .loc_0x64 - addi r3, r31, 0x40 - bl 0x89BC - rlwinm. r0,r3,0,24,31 - beq- .loc_0x64 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,12,12 - bne- .loc_0x1D4 - - .loc_0x64: - lwz r0, 0x2A8(r31) - cmplwi r0, 0 - bne- .loc_0x1D4 - mr r3, r31 - fmr f1, f31 - bl 0x43C - lwz r3, 0x280(r31) - cmplwi r3, 0 - beq- .loc_0x164 - lwz r0, 0x28(r3) - cmplwi r0, 0 - mr r30, r0 - beq- .loc_0x164 - mr r3, r30 - lwz r12, 0x0(r30) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x164 - lwz r3, 0x220(r30) - li r29, 0 - cmplwi r3, 0 - beq- .loc_0xE0 - bl -0x1CFC - rlwinm. r0,r3,0,24,31 - beq- .loc_0xE0 - lwz r3, 0x220(r30) - lwz r4, 0x280(r31) - bl -0x1E44 - mr r29, r3 - - .loc_0xE0: - stw r30, 0x28(r1) - li r0, 0 - addi r3, r30, 0 - stw r31, 0x34(r1) - stw r0, 0x38(r1) - stw r29, 0x2C(r1) - stw r29, 0x3C(r1) - stw r0, 0x30(r1) - lwz r12, 0x0(r30) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x130 - mr r3, r30 - lwz r12, 0x0(r30) - addi r4, r1, 0x34 - lwz r12, 0xA8(r12) - mtlr r12 - blrl - - .loc_0x130: - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x164 - mr r3, r31 - lwz r12, 0x0(r31) - addi r4, r1, 0x28 - lwz r12, 0xA8(r12) - mtlr r12 - blrl + bool isPikiOrNavi = false; + if (mObjType == OBJTYPE_Piki || mObjType == OBJTYPE_Navi) { + isPikiOrNavi = true; + } - .loc_0x164: - lwz r3, 0x94(r31) - lwz r0, 0x98(r31) - stw r3, 0x1AC(r31) - stw r0, 0x1B0(r31) - lwz r0, 0x9C(r31) - stw r0, 0x1B4(r31) - lwz r30, 0x2AC(r31) - cmplwi r30, 0 - beq- .loc_0x1D4 - lwz r12, 0x0(r31) - mr r4, r31 - mr r5, r30 - lwz r12, 0x100(r12) - addi r3, r1, 0x1C - mtlr r12 - blrl - lwz r3, 0x1C(r1) - lwz r0, 0x20(r1) - stw r3, 0x94(r30) - stw r0, 0x98(r30) - lwz r0, 0x24(r1) - stw r0, 0x9C(r30) - lwz r3, 0x88(r31) - lwz r0, 0x8C(r31) - stw r3, 0x88(r30) - stw r0, 0x8C(r30) - lwz r0, 0x90(r31) - stw r0, 0x90(r30) - - .loc_0x1D4: - lwz r0, 0x5C(r1) - lfd f31, 0x50(r1) - lwz r31, 0x4C(r1) - lwz r30, 0x48(r1) - lwz r29, 0x44(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ -} + if (!isPikiOrNavi && mGrid.aiCulling() && !aiCullable()) { + return; + } -/* - * --INFO-- - * Address: 8008B97C - * Size: 0000B4 - */ -void Creature::updateAI() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - lwz r0, 0x2A8(r3) - cmplwi r0, 0 - bne- .loc_0xA0 - lbz r0, 0x2B4(r31) - cmplwi r0, 0 - bne- .loc_0x68 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,20,20 - bne- .loc_0x68 - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x1C(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x68 - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x104(r12) - mtlr r12 - blrl + if (!mHoldingCreature.isNull()) { + return; + } - .loc_0x68: - lwz r3, 0xC8(r31) - rlwinm. r0,r3,0,25,25 - bne- .loc_0x7C - rlwinm. r0,r3,0,29,29 - beq- .loc_0xA0 - - .loc_0x7C: - rlwinm. r0,r3,0,26,26 - bne- .loc_0xA0 - lbz r0, 0x2B4(r31) - cmplwi r0, 0 - bne- .loc_0xA0 - rlwinm. r0,r3,0,20,20 - bne- .loc_0xA0 - mr r3, r31 - bl 0x15E4 + collisionCheck(p2); - .loc_0xA0: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} + if (mCollPlatform) { + Creature* platCreature = mCollPlatform->mCreature; + if (platCreature && platCreature->isAlive()) { + CollPart* platPart = nullptr; + if (platCreature->mCollInfo && platCreature->mCollInfo->hasInfo()) { + platPart = platCreature->mCollInfo->getPlatform(mCollPlatform); + } -/* - * --INFO-- - * Address: 8008BA30 - * Size: 0000F0 - */ -f32 centreDist(Creature*, Creature*) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x68(r1) - stw r31, 0x64(r1) - addi r31, r3, 0 - addi r3, r1, 0x2C - lwz r12, 0x0(r4) - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r31 - lwz r12, 0x0(r31) - addi r3, r1, 0x38 - lwz r12, 0x58(r12) - mtlr r12 - blrl - lfs f3, 0x3C(r1) - lfs f2, 0x30(r1) - lfs f1, 0x38(r1) - lfs f0, 0x2C(r1) - fsubs f3, f3, f2 - lfs f2, 0x40(r1) - fsubs f4, f1, f0 - lfs f0, 0x34(r1) - fmuls f1, f3, f3 - fsubs f3, f2, f0 - lfs f0, -0x7584(r2) - fmuls f2, f4, f4 - fmuls f3, f3, f3 - fadds f1, f2, f1 - fadds f1, f3, f1 - fcmpo cr0, f1, f0 - ble- .loc_0xDC - fsqrte f2, f1 - lfd f4, -0x7580(r2) - lfd f3, -0x7578(r2) - fmul f0, f2, f2 - fmul f2, f4, f2 - fmul f0, f1, f0 - fsub f0, f3, f0 - fmul f2, f2, f0 - fmul f0, f2, f2 - fmul f2, f4, f2 - fmul f0, f1, f0 - fsub f0, f3, f0 - fmul f2, f2, f0 - fmul f0, f2, f2 - fmul f2, f4, f2 - fmul f0, f1, f0 - fsub f0, f3, f0 - fmul f0, f2, f0 - fmul f0, f1, f0 - frsp f0, f0 - stfs f0, 0x28(r1) - lfs f1, 0x28(r1) + CollEvent event1(this, nullptr, platPart); + CollEvent event2(platCreature, platPart, nullptr); - .loc_0xDC: - lwz r0, 0x6C(r1) - lwz r31, 0x64(r1) - addi r1, r1, 0x68 - mtlr r0 - blr - */ -} + if (platCreature->isAlive()) { + platCreature->collisionCallback(event1); + } + if (isAlive()) { + collisionCallback(event2); + } + } + } -/* - * --INFO-- - * Address: ........ - * Size: 0000DC - */ -void sphereDistQuick(Creature*, Creature*) -{ - // UNUSED FUNCTION -} + _1AC = mPosition; -/* - * --INFO-- - * Address: 8008BB20 - * Size: 00011C - */ -f32 sphereDist(Creature*, Creature*) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x80(r1) - stfd f31, 0x78(r1) - stfd f30, 0x70(r1) - stw r31, 0x6C(r1) - mr r31, r4 - stw r30, 0x68(r1) - addi r30, r3, 0 - addi r3, r1, 0x54 - lwz r12, 0x0(r31) - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r30 - lwz r12, 0x0(r30) - addi r3, r1, 0x48 - lwz r12, 0x58(r12) - mtlr r12 - blrl - lfs f2, 0x48(r1) - lfs f0, 0x54(r1) - lfs f1, 0x4C(r1) - fsubs f2, f2, f0 - lfs f0, 0x58(r1) - fsubs f0, f1, f0 - stfs f2, 0x24(r1) - lfs f1, 0x24(r1) - stfs f1, 0x3C(r1) - stfs f0, 0x40(r1) - lfs f1, 0x50(r1) - lfs f0, 0x5C(r1) - fsubs f0, f1, f0 - stfs f0, 0x44(r1) - lfs f0, 0x3C(r1) - stfs f0, 0x30(r1) - lfs f0, 0x40(r1) - stfs f0, 0x34(r1) - lfs f0, 0x44(r1) - stfs f0, 0x38(r1) - lfs f1, 0x30(r1) - lfs f0, 0x34(r1) - lfs f2, 0x38(r1) - fmuls f1, f1, f1 - fmuls f0, f0, f0 - fmuls f2, f2, f2 - fadds f0, f1, f0 - fadds f1, f2, f0 - bl -0x7DFA0 - mr r3, r31 - fmr f30, f1 - lwz r12, 0x0(r31) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - mr r3, r30 - fmr f31, f1 - lwz r12, 0x0(r30) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - fadds f0, f1, f31 - lwz r0, 0x84(r1) - lfd f31, 0x78(r1) - lwz r31, 0x6C(r1) - fsubs f1, f30, f0 - lfd f30, 0x70(r1) - lwz r30, 0x68(r1) - addi r1, r1, 0x80 - mtlr r0 - blr - */ + if (getHoldCreature()) { + Creature* held = getHoldCreature(); + held->mPosition = getCatchPos(held); + held->mRotation = mRotation; + } } -/* - * --INFO-- - * Address: 8008BC3C - * Size: 0006E8 - */ -void Creature::collisionCheck(f32) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x120(r1) - stfd f31, 0x118(r1) - stfd f30, 0x110(r1) - fmr f30, f1 - stfd f29, 0x108(r1) - stfd f28, 0x100(r1) - stfd f27, 0xF8(r1) - stmw r25, 0xDC(r1) - mr r31, r3 - lwz r12, 0x0(r31) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x6C0 - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x84(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x6C0 - lwz r0, 0xC8(r31) - rlwinm. r0,r0,0,26,26 - bne- .loc_0x6C0 - lis r3, 0x802B - subi r0, r3, 0xF68 - lis r3, 0x802C - stw r0, 0xAC(r1) - subi r0, r3, 0x5A14 - stw r0, 0xAC(r1) - addi r30, r31, 0x1B8 - mr r3, r30 - lwz r12, 0x0(r30) - addi r29, r1, 0xAC - lwz r12, 0xC(r12) - mtlr r12 - blrl - mr r27, r3 - b .loc_0xFC - - .loc_0xA8: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r12, 0x0(r29) - addi r4, r3, 0 - addi r3, r29, 0 - lwz r12, 0x8(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - bne- .loc_0x158 - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x10(r12) - mtlr r12 - blrl - mr r27, r3 - - .loc_0xFC: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x14(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x124 - li r0, 0x1 - b .loc_0x150 - - .loc_0x124: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x8(r12) - mtlr r12 - blrl - cmplwi r3, 0 - bne- .loc_0x14C - li r0, 0x1 - b .loc_0x150 - - .loc_0x14C: - li r0, 0 - - .loc_0x150: - rlwinm. r0,r0,0,24,31 - beq+ .loc_0xA8 - - .loc_0x158: - lfs f29, -0x7554(r2) - lfs f31, -0x7584(r2) - b .loc_0x664 - - .loc_0x164: - cmpwi r27, -0x1 - bne- .loc_0x18C - mr r3, r30 - lwz r12, 0x0(r30) - li r4, 0 - lwz r12, 0x8(r12) - mtlr r12 - blrl - mr r28, r3 - b .loc_0x1A8 - - .loc_0x18C: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x8(r12) - mtlr r12 - blrl - mr r28, r3 - - .loc_0x1A8: - lwz r12, 0x0(r28) - mr r3, r28 - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x56C - lwz r0, 0x2AC(r31) - cmplwi r0, 0 - beq- .loc_0x1D8 - cmplw r0, r28 - beq- .loc_0x56C - - .loc_0x1D8: - lwz r4, 0x2A8(r31) - neg r0, r4 - cntlzw r0, r0 - rlwinm r0,r0,27,24,31 - cntlzw r0, r0 - rlwinm r3,r0,27,5,31 - rlwinm. r0,r0,27,24,31 - beq- .loc_0x200 - cmplw r4, r28 - beq- .loc_0x56C - - .loc_0x200: - rlwinm. r0,r3,0,24,31 - bne- .loc_0x56C - lwz r0, 0x2A8(r28) - cmplwi r0, 0 - bne- .loc_0x56C - stfs f31, 0xC8(r1) - li r26, 0 - li r25, 0 - stfs f31, 0xC4(r1) - stfs f31, 0xC0(r1) - lwz r3, 0x220(r31) - cmplwi r3, 0 - beq- .loc_0x244 - bl -0x2320 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x244 - lwz r26, 0x220(r31) - - .loc_0x244: - lwz r0, 0x220(r28) - cmplwi r0, 0 - beq- .loc_0x264 - lwz r3, 0x220(r28) - bl -0x2340 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x264 - lwz r25, 0x220(r28) - - .loc_0x264: - cmplwi r26, 0 - bne- .loc_0x484 - cmplwi r25, 0 - bne- .loc_0x484 - mr r4, r28 - lwz r12, 0x0(r28) - addi r3, r1, 0x88 - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r31 - lwz r12, 0x0(r31) - addi r3, r1, 0x7C - lwz r12, 0x58(r12) - mtlr r12 - blrl - lfs f2, 0x7C(r1) - lfs f0, 0x88(r1) - lfs f1, 0x80(r1) - fsubs f2, f2, f0 - lfs f0, 0x8C(r1) - fsubs f0, f1, f0 - stfs f2, 0x44(r1) - lfs f1, 0x44(r1) - stfs f1, 0x70(r1) - stfs f0, 0x74(r1) - lfs f1, 0x84(r1) - lfs f0, 0x90(r1) - fsubs f0, f1, f0 - stfs f0, 0x78(r1) - lfs f0, 0x70(r1) - stfs f0, 0x64(r1) - lfs f0, 0x74(r1) - stfs f0, 0x68(r1) - lfs f0, 0x78(r1) - stfs f0, 0x6C(r1) - lfs f1, 0x64(r1) - lfs f0, 0x68(r1) - lfs f2, 0x6C(r1) - fmuls f1, f1, f1 - fmuls f0, f0, f0 - fmuls f2, f2, f2 - fadds f0, f1, f0 - fadds f1, f2, f0 - bl -0x7E310 - mr r3, r28 - fmr f28, f1 - lwz r12, 0x0(r28) - lwz r12, 0x3C(r12) - mtlr r12 - blrl - mr r3, r31 - fmr f27, f1 - lwz r12, 0x0(r31) - lwz r12, 0x3C(r12) - mtlr r12 - blrl - fadds f0, f1, f27 - fcmpo cr0, f28, f0 - bge- .loc_0x56C - mr r4, r28 - lwz r12, 0x0(r28) - addi r3, r1, 0x94 - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r31 - lwz r12, 0x0(r31) - addi r3, r1, 0xA0 - lwz r12, 0x58(r12) - mtlr r12 - blrl - lfs f2, 0xA0(r1) - lfs f0, 0x94(r1) - lfs f1, 0xA4(r1) - fsubs f2, f2, f0 - lfs f0, 0x98(r1) - fsubs f0, f1, f0 - stfs f2, 0xC0(r1) - stfs f0, 0xC4(r1) - lfs f1, 0xA8(r1) - lfs f0, 0x9C(r1) - fsubs f0, f1, f0 - stfs f0, 0xC8(r1) - lfs f1, 0xC0(r1) - lfs f0, 0xC4(r1) - lfs f2, 0xC8(r1) - fmuls f1, f1, f1 - fmuls f0, f0, f0 - fmuls f2, f2, f2 - fadds f0, f1, f0 - fadds f1, f2, f0 - bl -0x7E3D0 - fmr f27, f1 - fcmpu cr0, f31, f27 - beq- .loc_0x408 - lfs f0, 0xC0(r1) - fdivs f0, f0, f27 - stfs f0, 0xC0(r1) - lfs f0, 0xC4(r1) - fdivs f0, f0, f27 - stfs f0, 0xC4(r1) - lfs f0, 0xC8(r1) - fdivs f0, f0, f27 - stfs f0, 0xC8(r1) - - .loc_0x408: - mr r3, r28 - lwz r12, 0x0(r28) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - mr r3, r31 - fmr f28, f1 - lwz r12, 0x0(r31) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - fadds f4, f1, f28 - lfs f0, 0xC0(r1) - lfs f2, 0xC4(r1) - fmr f1, f30 - lfs f3, 0xC8(r1) - fsubs f4, f4, f27 - addi r3, r31, 0 - addi r4, r28, 0 - addi r7, r1, 0xC0 - fneg f4, f4 - li r5, 0 - li r6, 0 - fmuls f0, f0, f4 - fmuls f5, f2, f4 - fmuls f2, f3, f4 - stfs f0, 0xC0(r1) - stfs f5, 0xC4(r1) - stfs f2, 0xC8(r1) - bl 0x189C - b .loc_0x56C - - .loc_0x484: - cmplwi r26, 0 - beq- .loc_0x4C8 - cmplwi r25, 0 - bne- .loc_0x4C8 - addi r3, r26, 0 - addi r4, r28, 0 - addi r5, r1, 0xC0 - bl -0x31DC - mr. r5, r3 - beq- .loc_0x56C - fmr f1, f30 - addi r3, r31, 0 - addi r4, r28, 0 - addi r7, r1, 0xC0 - li r6, 0 - bl 0x1858 - b .loc_0x56C - - .loc_0x4C8: - cmplwi r26, 0 - bne- .loc_0x530 - cmplwi r25, 0 - beq- .loc_0x530 - addi r3, r25, 0 - addi r4, r31, 0 - addi r5, r1, 0xC0 - bl -0x3220 - mr. r6, r3 - beq- .loc_0x56C - lfs f0, 0xC0(r1) - fmr f1, f30 - mr r3, r31 - fmuls f0, f0, f29 - addi r4, r28, 0 - addi r7, r1, 0xC0 - li r5, 0 - stfs f0, 0xC0(r1) - lfs f0, 0xC4(r1) - fmuls f0, f0, f29 - stfs f0, 0xC4(r1) - lfs f0, 0xC8(r1) - fmuls f0, f0, f29 - stfs f0, 0xC8(r1) - bl 0x17F0 - b .loc_0x56C +/* + * --INFO-- + * Address: 8008B97C + * Size: 0000B4 + */ +void Creature::updateAI() +{ + if (!mHoldingCreature.isNull()) { + return; + } - .loc_0x530: - addi r3, r26, 0 - addi r4, r25, 0 - addi r5, r1, 0xB4 - addi r6, r1, 0xB0 - addi r7, r1, 0xC0 - bl -0x2C0C - rlwinm. r0,r3,0,24,31 - beq- .loc_0x56C - fmr f1, f30 - lwz r5, 0xB4(r1) - lwz r6, 0xB0(r1) - addi r3, r31, 0 - addi r4, r28, 0 - addi r7, r1, 0xC0 - bl 0x17B0 + if (!mIsBeingDamaged && !isCreatureFlag(CF_IsAiDisabled) && doDoAI()) { + doAI(); + } - .loc_0x56C: - cmplwi r29, 0 - beq- .loc_0x648 - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x10(r12) - mtlr r12 - blrl - mr r27, r3 - b .loc_0x5E8 + if (!isCreatureFlag(CF_Unk7) && !isCreatureFlag(CF_IsOnGround)) { + return; + } - .loc_0x594: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r12, 0x0(r29) - addi r4, r3, 0 - addi r3, r29, 0 - lwz r12, 0x8(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - bne- .loc_0x664 - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x10(r12) - mtlr r12 - blrl - mr r27, r3 + if (!isCreatureFlag(CF_Unk6) && !mIsBeingDamaged && !isCreatureFlag(CF_IsAiDisabled)) { + moveVelocity(); + } +} - .loc_0x5E8: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x14(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x610 - li r0, 0x1 - b .loc_0x63C +/* + * --INFO-- + * Address: 8008BA30 + * Size: 0000F0 + */ +f32 centreDist(Creature* c1, Creature* c2) +{ + Vector3f sep = c1->getCentre() - c2->getCentre(); + return sep.length(); +} - .loc_0x610: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x8(r12) - mtlr r12 - blrl - cmplwi r3, 0 - bne- .loc_0x638 - li r0, 0x1 - b .loc_0x63C +/* + * --INFO-- + * Address: ........ + * Size: 0000DC + */ +f32 sphereDistQuick(Creature* c1, Creature* c2) +{ + Vector3f c1Cent = c1->getCentre(); + Vector3f c2Cent = c2->getCentre(); + f32 dist = qdist3(c1Cent.x, c1Cent.y, c1Cent.z, c2Cent.x, c2Cent.y, c2Cent.z); + return dist - (c1->getCentreSize() + c2->getCentreSize()); +} - .loc_0x638: - li r0, 0 +/* + * --INFO-- + * Address: 8008BB20 + * Size: 00011C + */ +f32 sphereDist(Creature* c1, Creature* c2) +{ + f32 dist = centreDist(c1, c2); + return dist - (c1->getCentreSize() + c2->getCentreSize()); +} - .loc_0x63C: - rlwinm. r0,r0,0,24,31 - beq+ .loc_0x594 - b .loc_0x664 +/* + * --INFO-- + * Address: 8008BC3C + * Size: 0006E8 + */ +void Creature::collisionCheck(f32 p1) +{ + if (!isAlive()) { + return; + } - .loc_0x648: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x10(r12) - mtlr r12 - blrl - mr r27, r3 + if (!isAtari()) { + return; + } - .loc_0x664: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x14(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x68C - li r0, 0x1 - b .loc_0x6B8 + if (isCreatureFlag(CF_Unk6)) { + return; + } - .loc_0x68C: - mr r3, r30 - lwz r12, 0x0(r30) - mr r4, r27 - lwz r12, 0x8(r12) - mtlr r12 - blrl - cmplwi r3, 0 - bne- .loc_0x6B4 - li r0, 0x1 - b .loc_0x6B8 + Iterator iter(&mSearchBuffer, &CndIsAtari()); + CI_LOOP(iter) + { + Creature* collider = *iter; - .loc_0x6B4: - li r0, 0 + // don't worry about dead creatures. + if (!collider->isAlive()) { + continue; + } - .loc_0x6B8: - rlwinm. r0,r0,0,24,31 - beq+ .loc_0x164 - - .loc_0x6C0: - lmw r25, 0xDC(r1) - lwz r0, 0x124(r1) - lfd f31, 0x118(r1) - lfd f30, 0x110(r1) - lfd f29, 0x108(r1) - lfd f28, 0x100(r1) - lfd f27, 0xF8(r1) - addi r1, r1, 0x120 - mtlr r0 - blr - */ + // ignore held creatures (such as bombs) + if (isHolding() && getHoldCreature() == collider) { + continue; + } + + // ignore creatures holding us (such as if we're a bomb) + if (isGrabbed() && getHolder() == collider) { + continue; + } + + if (!isGrabbed() && !collider->isGrabbed()) { + CollInfo* ourInfo = nullptr; + CollInfo* colliderInfo = nullptr; + Vector3f collisionVec; + if (mCollInfo && mCollInfo->hasInfo()) { + ourInfo = mCollInfo; + } + + if (collider->mCollInfo && collider->mCollInfo->hasInfo()) { + colliderInfo = collider->mCollInfo; + } + + if (!ourInfo && !colliderInfo) { + // neither of us have collision information. great. treat us both as spheres. + if (centreDist(this, collider) < getSize() + collider->getSize()) { + collisionVec = getCentre() - collider->getCentre(); + f32 dist = collisionVec.normalise(); + collisionVec = -(getCentreSize() + collider->getCentreSize() - dist) * collisionVec; + respondColl(collider, p1, nullptr, nullptr, collisionVec); + } + continue; + } + + if (ourInfo && !colliderInfo) { + // we have our collision, but not the incoming object's collision. + CollPart* collisionPart = ourInfo->checkCollision(collider, collisionVec); + if (collisionPart) { + respondColl(collider, p1, collisionPart, nullptr, collisionVec); + } + continue; + } + + if (!ourInfo && colliderInfo) { + // we have the incoming object info, but none for us. + CollPart* collisionPart = colliderInfo->checkCollision(this, collisionVec); + if (collisionPart) { + collisionVec.multiply(-1.0f); + respondColl(collider, p1, nullptr, collisionPart, collisionVec); + } + continue; + } + u32 badCompiler; // there's an extra variable *somewhere* but idk where. + + // we have info for both of us, so pass it off to CollInfo to do the work + CollPart* ourPart; + CollPart* colliderPart; + if (ourInfo->checkCollision(colliderInfo, &ourPart, &colliderPart, collisionVec)) { + respondColl(collider, p1, ourPart, colliderPart, collisionVec); + } + } + } } /* @@ -2265,9 +1189,10 @@ void Creature::collisionCheck(f32) */ Vector3f Creature::getCatchPos(Creature* target) { + Vector3f catchPos; f32 rad = 0.95f * getSize(); - Vector3f catchPos = Vector3f(rad * sinf(mDirection), 0.0f, rad * cosf(mDirection)) + mPosition; + catchPos = Vector3f(rad * sinf(mDirection), 0.0f, rad * cosf(mDirection)) + mPosition; return catchPos; /* .loc_0x0: @@ -2319,7 +1244,13 @@ Vector3f Creature::getCatchPos(Creature* target) * Address: 8008C3C4 * Size: 000008 */ -bool Creature::needShadow() { return true; } +bool Creature::needShadow() +{ + if (mObjType == OBJTYPE_Piki) { + PRINT(" ????????? piki uses Creature::needShadow \n"); // lol + } + return true; +} /* * --INFO-- @@ -2343,7 +1274,7 @@ void showTri(Graphics&, Vector3f&, CollTriInfo*) * Address: 8008C40C * Size: 0002B4 */ -void recTraceShadowTris(Graphics&, Vector3f&, CollTriInfo*) +static void recTraceShadowTris(Graphics&, Vector3f&, CollTriInfo*) { /* .loc_0x0: @@ -3085,50 +2016,11 @@ void Creature::drawShadow(Graphics&) * Address: 8008CE7C * Size: 000094 */ -f32 qdist2(Creature*, Creature*) +f32 qdist2(Creature* c1, Creature* c2) { - /* - .loc_0x0: - stwu r1, -0x18(r1) - lfs f3, 0x94(r3) - lfs f0, 0x94(r4) - lfs f2, 0x9C(r3) - lfs f1, 0x9C(r4) - fsubs f3, f3, f0 - lfs f0, -0x7584(r2) - fsubs f1, f2, f1 - fmuls f2, f3, f3 - fmuls f1, f1, f1 - fadds f1, f2, f1 - fcmpo cr0, f1, f0 - ble- .loc_0x8C - fsqrte f2, f1 - lfd f4, -0x7580(r2) - lfd f3, -0x7578(r2) - fmul f0, f2, f2 - fmul f2, f4, f2 - fmul f0, f1, f0 - fsub f0, f3, f0 - fmul f2, f2, f0 - fmul f0, f2, f2 - fmul f2, f4, f2 - fmul f0, f1, f0 - fsub f0, f3, f0 - fmul f2, f2, f0 - fmul f0, f2, f2 - fmul f2, f4, f2 - fmul f0, f1, f0 - fsub f0, f3, f0 - fmul f0, f2, f0 - fmul f0, f1, f0 - frsp f0, f0 - stfs f0, 0x10(r1) - lfs f1, 0x10(r1) - - .loc_0x8C: - addi r1, r1, 0x18 - blr - */ + f32 xDiff = c1->mPosition.x - c2->mPosition.x; + f32 zDiff = c1->mPosition.z - c2->mPosition.z; + return std::sqrtf(SQUARE(xDiff) + SQUARE(zDiff)); } /* @@ -3136,70 +2028,10 @@ f32 qdist2(Creature*, Creature*) * Address: 8008CF10 * Size: 0000EC */ -f32 circleDist(Creature*, Creature*) +f32 circleDist(Creature* c1, Creature* c2) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x58(r1) - stfd f31, 0x50(r1) - stfd f30, 0x48(r1) - stw r31, 0x44(r1) - mr r31, r4 - stw r30, 0x40(r1) - addi r30, r3, 0 - addi r3, r1, 0x10 - lwz r12, 0x0(r31) - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r31 - lwz r12, 0x0(r31) - addi r3, r1, 0x1C - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r30 - lwz r12, 0x0(r30) - addi r3, r1, 0x28 - lwz r12, 0x58(r12) - mtlr r12 - blrl - mr r4, r30 - lwz r12, 0x0(r30) - addi r3, r1, 0x34 - lwz r12, 0x58(r12) - mtlr r12 - blrl - lfs f1, 0x34(r1) - lfs f2, 0x30(r1) - lfs f3, 0x1C(r1) - lfs f4, 0x18(r1) - bl -0x54978 - mr r3, r31 - fmr f30, f1 - lwz r12, 0x0(r31) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - mr r3, r30 - fmr f31, f1 - lwz r12, 0x0(r30) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - fsubs f0, f30, f1 - lwz r0, 0x5C(r1) - lfd f30, 0x48(r1) - lwz r31, 0x44(r1) - fsubs f1, f0, f31 - lfd f31, 0x50(r1) - lwz r30, 0x40(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ + f32 dist = qdist2(c1->getCentre().x, c1->getCentre().z, c2->getCentre().x, c2->getCentre().z); + return dist - c1->getCentreSize() - c2->getCentreSize(); } /* @@ -3209,6 +2041,54 @@ f32 circleDist(Creature*, Creature*) */ void Creature::moveVelocity() { + u32 badCompiler[6]; // this is a placeholder, something else has to get tweaked for this to match + + Vector3f vel(mTargetVelocity); + Vector3f vec(0.0f, 0.0f, 0.0f); + + if (mFloorTri) { + Vector3f normal(mFloorTri->_18); + f32 speed = vel.length(); + vel = vel - vel.DP(normal) * normal; + vel.normalise(); + vel = vel * speed; + + int slipCode = MapCode::getSlipCode(mFloorTri); + if (slipCode == 0) { + if (speed < 0.1f) { + Vector3f tmp1(0.0f, -(AIConstant::_instance->mConstants._24() * gsys->getFrameTime()), 0.0f); + tmp1 = tmp1 - (tmp1.DP(normal) * normal); + vec = -tmp1; + vec = vec * 1.0f; + } + } else { + + Vector3f tmp1(0.0f, -(AIConstant::_instance->mConstants._24() * gsys->getFrameTime()), 0.0f); + tmp1 = tmp1 - (tmp1.DP(normal) * normal); + tmp1.normalise(); + + f32 factor; + if (slipCode == 2) { + factor = AIConstant::_instance->mConstants._144(); + } else { + factor = AIConstant::_instance->mConstants._134(); + } + + if (mObjType == OBJTYPE_Navi) { + PRINT("navi slip!\n"); + } + + vec = tmp1 * AIConstant::_instance->mConstants._24() * gsys->getFrameTime() * factor; + } + } + + Vector3f vec2; + vec2 = vel + _B0 - mVelocity; + vec2.length(); + + mVelocity = mVelocity + vec2 * gsys->getFrameTime() / mProps->mCreatureProps.mAcceleration(); + mVelocity = mVelocity + vec; + /* .loc_0x0: mflr r0 @@ -3571,15 +2451,56 @@ void Creature::moveVelocity() * Address: 8008D53C * Size: 000008 */ -u8 Creature::getAvoid(Vector3f&, Vector3f&) { return 0; } +bool Creature::getAvoid(Vector3f&, Vector3f&) { return false; } /* * --INFO-- * Address: 8008D544 * Size: 00034C */ -void Creature::renderAtari(Graphics&) +void Creature::renderAtari(Graphics& gfx) { + u32 badCompiler[6]; // something needs adjusting. + + if (mObjType != OBJTYPE_Pellet) { + Matrix4f mtx1; + Matrix4f mtx2; + + mtx1.makeSRT(Vector3f(1.0f, 1.0f, 1.0f), Vector3f(0.0f, 0.0f, 0.0f), mPosition); + gfx.mCamera->mLookAtMtx.multiplyTo(mtx1, mtx2); + gfx.setColour(Colour(0, 255, 0, 255), true); + gfx.drawSphere(Vector3f(0.0f, -mAbsPickOffset, 0.0f), mCollisionRadius, mtx2); + return; + } + + if (static_cast(this)->isUfoParts()) { + f32 halfHeight = 0.5f * getCylinderHeight(); + f32 pickOffs = -static_cast(this)->getPickOffset(); + + Vector3f pos(0.0f, halfHeight, 0.0f); + Matrix4f mtx; + mtx.makeVQS(Vector3f(0.0f, 0.0f, 0.0f), _E0, Vector3f(1.0f, 1.0f, 1.0f)); + pos.multMatrix(mtx); + pos = pos + mPosition; + + Matrix4f mtx2; + Matrix4f mtx3; + + mtx2.makeSRT(Vector3f(1.0f, 1.0f, 1.0f), Vector3f(0.0f, 0.0f, 0.0f), pos); + gfx.mCamera->mLookAtMtx.multiplyTo(mtx2, mtx3); + + gfx.setColour(Colour(255, 0, 0, 255), true); + gfx.drawSphere(Vector3f(0.0f, 0.0f, 0.0f), halfHeight + pickOffs, mtx3); + return; + } + + // pellet but not a ufo part + Matrix4f mtx1; + Matrix4f mtx2; + mtx1.makeSRT(Vector3f(1.0f, 1.0f, 1.0f), Vector3f(0.0f, 0.0f, 0.0f), mPosition); + gfx.mCamera->mLookAtMtx.multiplyTo(mtx1, mtx2); + gfx.setColour(Colour(0, 255, 0, 255), true); + gfx.drawSphere(Vector3f(0.0f, -mAbsPickOffset, 0.0f), mCollisionRadius, mtx2); /* .loc_0x0: mflr r0 @@ -3809,39 +2730,11 @@ void Creature::renderAtari(Graphics&) */ bool roughCull(Creature* p1, Creature* p2, f32 p3) { - if (AIPerf::useGrid && AIPerf::iteratorCull && p1->mGrid.doCulling(p2->mGrid, p3)) { + if (AIPerf::useGrid && AIPerf::iteratorCull && p1->roughCulling(p2, p3)) { return true; } return false; - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r0, -0x5F10(r13) - cmpwi r0, 0 - beq- .loc_0x40 - lbz r0, -0x5F06(r13) - cmplwi r0, 0 - beq- .loc_0x40 - addi r3, r3, 0x40 - addi r4, r4, 0x40 - bl 0x6B34 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x40 - li r3, 0x1 - b .loc_0x44 - - .loc_0x40: - li r3, 0 - - .loc_0x44: - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ } /* @@ -3851,7 +2744,7 @@ bool roughCull(Creature* p1, Creature* p2, f32 p3) */ void Creature::stickUpdate() { - if (_158) { + if (mRope) { updateStickRope(); return; } diff --git a/src/plugPikiKando/creatureMove.cpp b/src/plugPikiKando/creatureMove.cpp index c1781f3f..c4265390 100644 --- a/src/plugPikiKando/creatureMove.cpp +++ b/src/plugPikiKando/creatureMove.cpp @@ -1215,7 +1215,7 @@ void Creature::moveNew(f32) * Address: ........ * Size: 0002E8 */ -void Creature::checkForward(Vector3f&, f32, f32&) +CollTriInfo* Creature::checkForward(Vector3f&, f32, f32&) { // UNUSED FUNCTION } @@ -1225,7 +1225,7 @@ void Creature::checkForward(Vector3f&, f32, f32&) * Address: ........ * Size: 000130 */ -void Creature::getNextTri(CollTriInfo*, Vector3f&, int&) +CollTriInfo* Creature::getNextTri(CollTriInfo*, Vector3f&, int&) { // UNUSED FUNCTION } @@ -1235,7 +1235,7 @@ void Creature::getNextTri(CollTriInfo*, Vector3f&, int&) * Address: 8008F33C * Size: 000100 */ -void Creature::getNearestPlane(CollTriInfo*) +Plane* Creature::getNearestPlane(CollTriInfo*) { /* .loc_0x0: diff --git a/src/plugPikiKando/creatureStick.cpp b/src/plugPikiKando/creatureStick.cpp index c42ac3e1..dade6166 100644 --- a/src/plugPikiKando/creatureStick.cpp +++ b/src/plugPikiKando/creatureStick.cpp @@ -2,7 +2,10 @@ #include "Iterator.h" #include "Stickers.h" #include "Interactions.h" +#include "Collision.h" +#include "RopeCreature.h" #include "Condition.h" +#include "Pellet.h" #include "DebugLog.h" /* @@ -19,6 +22,8 @@ DEFINE_ERROR(); */ DEFINE_PRINT("CreatureStick"); +char* _standType[] = { "GROUND", "TEKIPLAT", "PLAT", "AIR" }; + /* * --INFO-- * Address: 8008F9C4 @@ -57,39 +62,12 @@ void Creature::killStickers(Creature* stuckTo, Condition* cond, int p3) */ void Creature::startClimb() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - lwz r0, 0x184(r3) - cmplwi r0, 0 - beq- .loc_0x48 - lwz r3, 0x188(r31) - cmplwi r3, 0 - beq- .loc_0x48 - bl -0x8220 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x48 - lwz r0, 0xC8(r31) - ori r0, r0, 0x2000 - stw r0, 0xC8(r31) - b .loc_0x54 - - .loc_0x48: - lwz r0, 0xC8(r31) - rlwinm r0,r0,0,19,17 - stw r0, 0xC8(r31) - - .loc_0x54: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + if (mStickTarget && mStickPart && mStickPart->isClimbable()) { + setCreatureFlag(CF_IsClimbing); + } else { + PRINT("CANNOT CLIMB !\n"); + resetCreatureFlag(CF_IsClimbing); + } } /* @@ -97,16 +75,7 @@ void Creature::startClimb() * Address: 8008FF40 * Size: 000010 */ -void Creature::endClimb() -{ - /* - .loc_0x0: - lwz r0, 0xC8(r3) - rlwinm r0,r0,0,19,17 - stw r0, 0xC8(r3) - blr - */ -} +void Creature::endClimb() { resetCreatureFlag(CF_IsClimbing); } /* * --INFO-- @@ -115,34 +84,14 @@ void Creature::endClimb() */ bool Creature::isStickToPlatform() { - return false; - /* - .loc_0x0: - lwz r0, 0x184(r3) - cmplwi r0, 0 - beq- .loc_0x40 - lwz r4, 0x188(r3) - cmplwi r4, 0 - beq- .loc_0x24 - lbz r0, 0x5C(r4) - cmplwi r0, 0x3 - beq- .loc_0x38 - - .loc_0x24: - cmplwi r4, 0 - bne- .loc_0x40 - lwz r0, 0xC8(r3) - rlwinm. r0,r0,0,17,17 - bne- .loc_0x40 - - .loc_0x38: - li r3, 0x1 - blr + if (mStickTarget) { + CollPart* part = mStickPart; + if ((part && part->isPlatformType()) || (!part && !isCreatureFlag(CF_StuckToObject))) { + return true; + } + } - .loc_0x40: - li r3, 0 - blr - */ + return false; } /* @@ -150,10 +99,7 @@ bool Creature::isStickToPlatform() * Address: ........ * Size: 000054 */ -void Creature::isStickToSphere() -{ - // UNUSED FUNCTION -} +bool Creature::isStickToSphere() { return !isStickToPlatform(); } /* * --INFO-- @@ -170,48 +116,23 @@ void Creature::adjustStickObject(Vector3f&) * Address: 8008FF98 * Size: 000084 */ -void Creature::startStickMouth(Creature*, CollPart*) +void Creature::startStickMouth(Creature* mouthOwner, CollPart* mouthPart) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - addi r31, r5, 0 - stw r30, 0x20(r1) - addi r30, r4, 0 - stw r29, 0x1C(r1) - mr r29, r3 - lwz r0, 0xC8(r3) - rlwinm r0,r0,0,17,15 - stw r0, 0xC8(r3) - lwz r0, 0x184(r3) - cmplwi r0, 0 - beq- .loc_0x44 - mr r3, r29 - bl 0xA04 - - .loc_0x44: - addi r3, r29, 0 - addi r4, r30, 0 - addi r5, r31, 0 - bl 0x8FC - rlwinm. r0,r3,0,24,31 - beq- .loc_0x68 - lwz r0, 0xC8(r29) - ori r0, r0, 0x8000 - stw r0, 0xC8(r29) + resetCreatureFlag(CF_StuckToMouth); + if (mStickTarget) { + PRINT("startStickMouth:already stuck to %s : endStick\n", mStickPart->mCollInfo->mId.mStringID); + endStick(); + } - .loc_0x68: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - lwz r29, 0x1C(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + if (startStick(mouthOwner, mouthPart)) { + if (mObjType == OBJTYPE_Rope) { + PRINT("stick to mouth!!\n"); + } + setCreatureFlag(CF_StuckToMouth); + } else { + PRINT("stick mouth failed !!\n"); + ERROR("karl gotti!\n"); + } } /* @@ -221,25 +142,9 @@ void Creature::startStickMouth(Creature*, CollPart*) */ void Creature::endStickMouth() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl 0x848 - mr r3, r31 - bl 0x9A4 - lwz r0, 0xC8(r31) - rlwinm r0,r0,0,17,15 - stw r0, 0xC8(r31) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + endStickObject(); + endStick(); + resetCreatureFlag(CF_StuckToMouth); } /* @@ -247,219 +152,33 @@ void Creature::endStickMouth() * Address: 8009005C * Size: 000310 */ -void Creature::startStickObjectSphere(Creature*, CollPart*, f32) +void Creature::startStickObjectSphere(Creature* obj, CollPart* stickPart, f32 stickDist) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x1A8(r1) - stfd f31, 0x1A0(r1) - fmr f31, f1 - stw r31, 0x19C(r1) - addi r31, r3, 0 - stw r30, 0x198(r1) - mr. r30, r5 - stw r29, 0x194(r1) - addi r29, r4, 0 - beq- .loc_0x40 - addi r3, r1, 0x150 - lwz r4, 0x188(r31) - bl -0x817C - b .loc_0x54 + Matrix4f objMatrix; + Matrix4f invObjMatrix; + Vector3f vec; // unused lol + + if (stickPart) { + objMatrix = mStickPart->getMatrix(); // should this be uh. stickPart->getMatrix()?? + } else { + objMatrix.makeSRT(obj->mScale, obj->mRotation, obj->mPosition); + } - .loc_0x40: - addi r3, r1, 0x150 - addi r4, r29, 0x7C - addi r5, r29, 0x88 - addi r6, r29, 0x94 - bl -0x51FB8 + objMatrix.inverse(&invObjMatrix); - .loc_0x54: - addi r3, r1, 0x150 - addi r4, r1, 0x110 - bl -0x51C7C - lwz r3, 0x94(r31) - cmplwi r30, 0 - lwz r0, 0x98(r31) - stw r3, 0x194(r31) - stw r0, 0x198(r31) - lwz r0, 0x9C(r31) - stw r0, 0x19C(r31) - beq- .loc_0x1AC - lfs f1, 0x194(r31) - lfs f0, 0x4(r30) - fsubs f0, f1, f0 - stfs f0, 0xB0(r1) - lfs f0, 0xB0(r1) - stfs f0, 0xF8(r1) - lfs f1, 0x198(r31) - lfs f0, 0x8(r30) - fsubs f0, f1, f0 - stfs f0, 0xFC(r1) - lfs f1, 0x19C(r31) - lfs f0, 0xC(r30) - fsubs f0, f1, f0 - stfs f0, 0x100(r1) - lwz r3, 0xF8(r1) - lwz r0, 0xFC(r1) - stw r3, 0x194(r31) - stw r0, 0x198(r31) - lwz r0, 0x100(r1) - stw r0, 0x19C(r31) - lfs f1, 0x194(r31) - lfs f0, 0x198(r31) - lfs f2, 0x19C(r31) - fmuls f1, f1, f1 - fmuls f0, f0, f0 - fmuls f2, f2, f2 - fadds f0, f1, f0 - fadds f1, f2, f0 - bl -0x8250C - lfs f0, -0x74C8(r2) - fcmpu cr0, f0, f1 - beq- .loc_0x124 - lfs f0, 0x194(r31) - fdivs f0, f0, f1 - stfs f0, 0x194(r31) - lfs f0, 0x198(r31) - fdivs f0, f0, f1 - stfs f0, 0x198(r31) - lfs f0, 0x19C(r31) - fdivs f0, f0, f1 - stfs f0, 0x19C(r31) + _194 = mPosition; - .loc_0x124: - lfs f1, 0x0(r30) - lfs f0, 0x194(r31) - fadds f3, f1, f31 - lfs f1, 0x198(r31) - lfs f2, 0x19C(r31) - fmuls f0, f0, f3 - fmuls f4, f1, f3 - fmuls f1, f2, f3 - stfs f0, 0xA8(r1) - lfs f0, 0xA8(r1) - stfs f0, 0xE0(r1) - stfs f4, 0xE4(r1) - stfs f1, 0xE8(r1) - lfs f1, 0xE0(r1) - lfs f0, 0x4(r30) - fadds f0, f1, f0 - stfs f0, 0x9C(r1) - lfs f0, 0x9C(r1) - stfs f0, 0xEC(r1) - lfs f1, 0xE4(r1) - lfs f0, 0x8(r30) - fadds f0, f1, f0 - stfs f0, 0xF0(r1) - lfs f1, 0xE8(r1) - lfs f0, 0xC(r30) - fadds f0, f1, f0 - stfs f0, 0xF4(r1) - lwz r3, 0xEC(r1) - lwz r0, 0xF0(r1) - stw r3, 0x194(r31) - stw r0, 0x198(r31) - lwz r0, 0xF4(r1) - stw r0, 0x19C(r31) - b .loc_0x2E4 - - .loc_0x1AC: - lfs f1, 0x194(r31) - lfs f0, 0x94(r29) - fsubs f0, f1, f0 - stfs f0, 0x90(r1) - lfs f0, 0x90(r1) - stfs f0, 0xD4(r1) - lfs f1, 0x198(r31) - lfs f0, 0x98(r29) - fsubs f0, f1, f0 - stfs f0, 0xD8(r1) - lfs f1, 0x19C(r31) - lfs f0, 0x9C(r29) - fsubs f0, f1, f0 - stfs f0, 0xDC(r1) - lwz r3, 0xD4(r1) - lwz r0, 0xD8(r1) - stw r3, 0x194(r31) - stw r0, 0x198(r31) - lwz r0, 0xDC(r1) - stw r0, 0x19C(r31) - lfs f1, 0x194(r31) - lfs f0, 0x198(r31) - lfs f2, 0x19C(r31) - fmuls f1, f1, f1 - fmuls f0, f0, f0 - fmuls f2, f2, f2 - fadds f0, f1, f0 - fadds f1, f2, f0 - bl -0x82638 - lfs f0, -0x74C8(r2) - fcmpu cr0, f0, f1 - beq- .loc_0x250 - lfs f0, 0x194(r31) - fdivs f0, f0, f1 - stfs f0, 0x194(r31) - lfs f0, 0x198(r31) - fdivs f0, f0, f1 - stfs f0, 0x198(r31) - lfs f0, 0x19C(r31) - fdivs f0, f0, f1 - stfs f0, 0x19C(r31) + if (stickPart) { + _194 = _194 - stickPart->mCentre; + _194.normalise(); + _194 = _194 * (stickPart->mRadius + stickDist) + stickPart->mCentre; + } else { + _194 = _194 - obj->mPosition; + _194.normalise(); + _194 = _194 * (obj->getCentreSize() + stickDist) + obj->mPosition; + } - .loc_0x250: - mr r3, r29 - lwz r12, 0x0(r29) - lwz r12, 0x5C(r12) - mtlr r12 - blrl - fadds f3, f31, f1 - lfs f0, 0x194(r31) - lfs f1, 0x198(r31) - lfs f2, 0x19C(r31) - fmuls f0, f0, f3 - fmuls f4, f1, f3 - fmuls f1, f2, f3 - stfs f0, 0x88(r1) - lfs f0, 0x88(r1) - stfs f0, 0xBC(r1) - stfs f4, 0xC0(r1) - stfs f1, 0xC4(r1) - lfs f1, 0xBC(r1) - lfs f0, 0x94(r29) - fadds f0, f1, f0 - stfs f0, 0x7C(r1) - lfs f0, 0x7C(r1) - stfs f0, 0xC8(r1) - lfs f1, 0xC0(r1) - lfs f0, 0x98(r29) - fadds f0, f1, f0 - stfs f0, 0xCC(r1) - lfs f1, 0xC4(r1) - lfs f0, 0x9C(r29) - fadds f0, f1, f0 - stfs f0, 0xD0(r1) - lwz r3, 0xC8(r1) - lwz r0, 0xCC(r1) - stw r3, 0x194(r31) - stw r0, 0x198(r31) - lwz r0, 0xD0(r1) - stw r0, 0x19C(r31) - - .loc_0x2E4: - addi r3, r31, 0x194 - addi r4, r1, 0x110 - bl -0x58BFC - lwz r0, 0x1AC(r1) - lfd f31, 0x1A0(r1) - lwz r31, 0x19C(r1) - lwz r30, 0x198(r1) - lwz r29, 0x194(r1) - addi r1, r1, 0x1A8 - mtlr r0 - blr - */ + _194.multMatrix(invObjMatrix); } /* @@ -858,38 +577,18 @@ void Creature::startStickObject(Creature*, CollPart*, int, f32) */ void Creature::endStickObject() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - lwz r4, 0x1A0(r3) - cmpwi r4, -0x1 - beq- .loc_0x34 - lwz r0, 0x184(r31) - cmplwi r0, 0 - beq- .loc_0x34 - mr r3, r0 - bl 0x5A5C + if (mPelletStickSlot != -1 && mStickTarget) { + if (mStickTarget->mObjType != OBJTYPE_Pellet) { + ERROR("stick to non-pellet!\n"); + } + Pellet* pellet = static_cast(mStickTarget); + pellet->stickOffSlot(mPelletStickSlot); + } - .loc_0x34: - li r0, -0x1 - stw r0, 0x1A0(r31) - mr r3, r31 - bl 0x124 - li r0, 0 - stw r0, 0x188(r31) - lwz r0, 0xC8(r31) - rlwinm r0,r0,0,18,16 - stw r0, 0xC8(r31) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + mPelletStickSlot = -1; + endStick(); + mStickPart = nullptr; + resetCreatureFlag(CF_StuckToObject); } /* @@ -897,85 +596,44 @@ void Creature::endStickObject() * Address: 800908E4 * Size: 0000F8 */ -void Creature::startStick(Creature*, CollPart*) +bool Creature::startStick(Creature* stickTarget, CollPart* stickPart) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - li r31, 0 - stw r30, 0x20(r1) - addi r30, r5, 0 - stw r29, 0x1C(r1) - addi r29, r4, 0 - stw r28, 0x18(r1) - addi r28, r3, 0 - stw r31, 0x188(r3) - lwz r0, 0xC8(r3) - rlwinm r0,r0,0,18,16 - stw r0, 0xC8(r3) - lwz r0, 0x184(r3) - cmplwi r0, 0 - beq- .loc_0x50 - li r3, 0 - b .loc_0xD8 - - .loc_0x50: - mr r3, r28 - bl -0x61AC - stw r29, 0x184(r28) - lwz r0, 0x180(r29) - cmplwi r0, 0 - bne- .loc_0x78 - stw r28, 0x180(r29) - stw r31, 0x190(r28) - stw r31, 0x18C(r28) - b .loc_0xA0 + mStickPart = nullptr; + resetCreatureFlag(CF_StuckToObject); + if (mStickTarget) { + PRINT("already stick to something !\n"); + return false; + } - .loc_0x78: - mr r3, r0 - b .loc_0x84 + PRINT("piki%x :::: stick ! : standType = %s\n", _standType[getStandType()]); + + mStickTarget = stickTarget; + if (!stickTarget->mStickListHead) { + stickTarget->mStickListHead = this; + mPrevSticker = nullptr; + mNextSticker = nullptr; + } else { + Creature* prevSticker; + for (prevSticker = stickTarget->mStickListHead; prevSticker->mNextSticker; prevSticker = prevSticker->mNextSticker) { + ; + } + prevSticker->mNextSticker = this; + mPrevSticker = prevSticker; + mNextSticker = nullptr; + } - .loc_0x80: - mr r3, r0 + if (!mStickTarget) { + PRINT("error !\n"); + } + if (!mStickTarget) { + PRINT("error2 !\n"); + } - .loc_0x84: - lwz r0, 0x18C(r3) - cmplwi r0, 0 - bne+ .loc_0x80 - stw r28, 0x18C(r3) - li r0, 0 - stw r3, 0x190(r28) - stw r0, 0x18C(r28) + mStickPart = stickPart; - .loc_0xA0: - stw r30, 0x188(r28) - addi r3, r28, 0 - addi r4, r29, 0 - lwz r12, 0x0(r28) - lwz r12, 0xC4(r12) - mtlr r12 - blrl - mr r3, r29 - lwz r12, 0x0(r29) - mr r4, r28 - lwz r12, 0xBC(r12) - mtlr r12 - blrl - li r3, 0x1 - - .loc_0xD8: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - lwz r29, 0x1C(r1) - lwz r28, 0x18(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + stickToCallback(stickTarget); + stickTarget->stickCallback(this); + return true; } /* @@ -983,9 +641,13 @@ void Creature::startStick(Creature*, CollPart*) * Address: ........ * Size: 000028 */ -void Creature::isStickLeader() +bool Creature::isStickLeader() { - // UNUSED FUNCTION + if (mStickTarget && !mPrevSticker) { + return true; + } + + return false; } /* @@ -995,78 +657,37 @@ void Creature::isStickLeader() */ void Creature::endStick() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - li r31, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - stw r31, 0x284(r3) - lwz r3, 0x184(r3) - cmplwi r3, 0 - beq- .loc_0xD4 - lwz r12, 0x0(r3) - mr r4, r30 - lwz r12, 0xC0(r12) - mtlr r12 - blrl - lwz r3, 0x190(r30) - cmplwi r3, 0 - bne- .loc_0x68 - lwz r0, 0x18C(r30) - cmplwi r0, 0 - bne- .loc_0x68 - lwz r3, 0x184(r30) - stw r31, 0x180(r3) - stw r31, 0x184(r30) - b .loc_0xCC - - .loc_0x68: - cmplwi r3, 0 - bne- .loc_0x98 - lwz r4, 0x18C(r30) - li r0, 0 - lwz r3, 0x184(r30) - stw r4, 0x180(r3) - stw r0, 0x184(r30) - lwz r3, 0x18C(r30) - stw r0, 0x190(r3) - stw r0, 0x190(r30) - stw r0, 0x18C(r30) - b .loc_0xCC - - .loc_0x98: - li r0, 0 - stw r0, 0x184(r30) - lwz r0, 0x18C(r30) - lwz r3, 0x190(r30) - stw r0, 0x18C(r3) - lwz r3, 0x18C(r30) - cmplwi r3, 0 - beq- .loc_0xC0 - lwz r0, 0x190(r30) - stw r0, 0x190(r3) - - .loc_0xC0: - li r0, 0 - stw r0, 0x190(r30) - stw r0, 0x18C(r30) + mCollPlatNormal = nullptr; + if (!mStickTarget) { + return; + } - .loc_0xCC: - li r0, 0 - stw r0, 0x280(r30) + mStickTarget->offstickCallback(this); + if (!mPrevSticker && !mNextSticker) { + mStickTarget->mStickListHead = nullptr; + mStickTarget = nullptr; + PRINT("course 1 : only\n"); + + } else if (!mPrevSticker) { + mStickTarget->mStickListHead = mNextSticker; + mStickTarget = nullptr; + mNextSticker->mPrevSticker = nullptr; + mPrevSticker = nullptr; + mNextSticker = nullptr; + PRINT("course 2 : top\n"); + + } else { + mStickTarget = nullptr; + mPrevSticker->mNextSticker = mNextSticker; + if (mNextSticker) { + mNextSticker->mPrevSticker = mPrevSticker; + } + mPrevSticker = nullptr; + mNextSticker = nullptr; + PRINT("course 3 : prev and next\n"); + } - .loc_0xD4: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + mCollPlatform = nullptr; } /* @@ -1074,96 +695,38 @@ void Creature::endStick() * Address: 80090AC8 * Size: 000124 */ -void Creature::startRope(RopeCreature*, f32) +bool Creature::startRope(RopeCreature* rope, f32 ropeRatio) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x50(r1) - stfd f31, 0x48(r1) - fmr f31, f1 - stw r31, 0x44(r1) - addi r31, r4, 0 - stw r30, 0x40(r1) - addi r30, r3, 0 - addi r3, r30, 0x114 - bl -0x52D34 - lwz r0, 0x158(r30) - cmplwi r0, 0 - beq- .loc_0x40 - li r3, 0 - b .loc_0x108 + _114.makeIdentity(); + if (mRope) { + PRINT("already hold on to something !\n"); + return false; + } - .loc_0x40: - stw r31, 0x158(r30) - addi r3, r1, 0x20 - addi r4, r30, 0x94 - lwz r5, 0x2B8(r31) - lfs f1, 0x94(r31) - lfs f0, -0x74AC(r2) - stfs f1, 0x20(r1) - lfs f1, 0x98(r31) - stfs f1, 0x24(r1) - lfs f1, 0x9C(r31) - stfs f1, 0x28(r1) - lfsu f1, 0x94(r5) - stfs f1, 0x2C(r1) - lfs f1, 0x4(r5) - stfs f1, 0x30(r1) - lfs f1, 0x8(r5) - stfs f1, 0x34(r1) - stfs f0, 0x38(r1) - bl -0x9488 - stfs f1, 0x15C(r30) - addi r4, r31, 0 - addi r3, r1, 0x14 - lfs f1, 0x15C(r30) - bl 0x3E14 - lwz r3, 0x14(r1) - lwz r0, 0x18(r1) - stw r3, 0x94(r30) - stw r0, 0x98(r30) - lwz r0, 0x1C(r1) - stw r0, 0x9C(r30) - lwz r0, 0x154(r31) - cmplwi r0, 0 - bne- .loc_0xD8 - stw r30, 0x154(r31) - li r0, 0 - stw r0, 0x164(r30) - stw r0, 0x160(r30) - b .loc_0x100 + mRope = rope; - .loc_0xD8: - mr r3, r0 - b .loc_0xE4 + Cylinder cylinder(rope->mPosition, rope->_2B8->mPosition, 2.0f); + mRopeRatio = cylinder.getPosRatio(mPosition); + mPosition = rope->getRopePos(mRopeRatio); - .loc_0xE0: - mr r3, r0 + if (!rope->mRopeListHead) { + rope->mRopeListHead = this; + mPrevRopeHolder = nullptr; + mNextRopeHolder = nullptr; - .loc_0xE4: - lwz r0, 0x160(r3) - cmplwi r0, 0 - bne+ .loc_0xE0 - stw r30, 0x160(r3) - li r0, 0 - stw r3, 0x164(r30) - stw r0, 0x160(r30) - - .loc_0x100: - stfs f31, 0x15C(r30) - li r3, 0x1 - - .loc_0x108: - lwz r0, 0x54(r1) - lfd f31, 0x48(r1) - lwz r31, 0x44(r1) - lwz r30, 0x40(r1) - addi r1, r1, 0x50 - mtlr r0 - blr - */ + } else { + Creature* prevHolder = rope->mRopeListHead; + for (prevHolder; prevHolder->mNextRopeHolder; prevHolder = prevHolder->mNextRopeHolder) { + ; + } + prevHolder->mNextRopeHolder = this; + mPrevRopeHolder = prevHolder; + mNextRopeHolder = nullptr; + } + + mRopeRatio = ropeRatio; + + return true; } /* @@ -1173,53 +736,34 @@ void Creature::startRope(RopeCreature*, f32) */ void Creature::endRope() { - /* - .loc_0x0: - lwz r5, 0x158(r3) - cmplwi r5, 0 - beqlr- - lwz r4, 0x164(r3) - cmplwi r4, 0 - bne- .loc_0x34 - lwz r0, 0x160(r3) - cmplwi r0, 0 - bne- .loc_0x34 - li r0, 0 - stw r0, 0x154(r5) - stw r0, 0x158(r3) - blr + if (!mRope) { + return; + } - .loc_0x34: - cmplwi r4, 0 - bne- .loc_0x60 - lwz r4, 0x160(r3) - li r0, 0 - stw r4, 0x154(r5) - stw r0, 0x158(r3) - lwz r4, 0x160(r3) - stw r0, 0x164(r4) - stw r0, 0x164(r3) - stw r0, 0x160(r3) - blr + PRINT("endRope called ! : %x\n", this); - .loc_0x60: - li r0, 0 - stw r0, 0x158(r3) - lwz r0, 0x160(r3) - lwz r4, 0x164(r3) - stw r0, 0x160(r4) - lwz r4, 0x160(r3) - cmplwi r4, 0 - beq- .loc_0x88 - lwz r0, 0x164(r3) - stw r0, 0x164(r4) + if (!mPrevRopeHolder && !mNextRopeHolder) { + mRope->mRopeListHead = nullptr; + mRope = nullptr; + return; + } - .loc_0x88: - li r0, 0 - stw r0, 0x164(r3) - stw r0, 0x160(r3) - blr - */ + if (!mPrevRopeHolder) { + mRope->mRopeListHead = mNextRopeHolder; + mRope = nullptr; + mNextRopeHolder->mPrevRopeHolder = nullptr; + mPrevRopeHolder = nullptr; + mNextRopeHolder = nullptr; + return; + } + + mRope = nullptr; + mPrevRopeHolder->mNextRopeHolder = mNextRopeHolder; + if (mNextRopeHolder) { + mNextRopeHolder->mPrevRopeHolder = mPrevRopeHolder; + } + mPrevRopeHolder = nullptr; + mNextRopeHolder = nullptr; } /* @@ -1241,9 +785,9 @@ Stickers::Stickers(Creature* owner) void Stickers::calcNum() { mCount = 0; - Creature* stuck = mOwner->_180; + Creature* stuck = mOwner->mStickListHead; while (stuck) { - stuck = stuck->_18C; + stuck = stuck->mNextSticker; mCount++; } } @@ -1253,77 +797,22 @@ void Stickers::calcNum() * Address: 80090D0C * Size: 0000CC */ -Creature* Stickers::getCreature(int) +Creature* Stickers::getCreature(int idx) { - return nullptr; - /* - .loc_0x0: - lwz r7, 0x8(r3) - li r0, 0 - stw r0, 0x8(r3) - lwz r5, 0xC(r3) - lwz r6, 0x180(r5) - b .loc_0x28 - - .loc_0x18: - lwz r5, 0x8(r3) - lwz r6, 0x18C(r6) - addi r0, r5, 0x1 - stw r0, 0x8(r3) - - .loc_0x28: - cmplwi r6, 0 - bne+ .loc_0x18 - lwz r5, 0x8(r3) - cmpw r7, r5 - ble- .loc_0x48 - cmpw r4, r5 - blt- .loc_0x48 - subi r4, r5, 0x1 - - .loc_0x48: - lwz r3, 0xC(r3) - cmpwi r4, 0 - li r6, 0 - lwz r3, 0x180(r3) - ble- .loc_0xBC - cmpwi r4, 0x8 - subi r5, r4, 0x8 - ble- .loc_0xA4 - addi r0, r5, 0x7 - rlwinm r0,r0,29,3,31 - cmpwi r5, 0 - mtctr r0 - ble- .loc_0xA4 - - .loc_0x7C: - lwz r3, 0x18C(r3) - addi r6, r6, 0x8 - lwz r3, 0x18C(r3) - lwz r3, 0x18C(r3) - lwz r3, 0x18C(r3) - lwz r3, 0x18C(r3) - lwz r3, 0x18C(r3) - lwz r3, 0x18C(r3) - lwz r3, 0x18C(r3) - bdnz+ .loc_0x7C - - .loc_0xA4: - sub r0, r4, r6 - cmpw r6, r4 - mtctr r0 - bge- .loc_0xBC - - .loc_0xB4: - lwz r3, 0x18C(r3) - bdnz+ .loc_0xB4 + int startCount = mCount; + calcNum(); + if (startCount > mCount && idx >= mCount) { + idx = mCount - 1; + } - .loc_0xBC: - cmplwi r3, 0 - bnelr- - li r3, 0 - blr - */ + Creature* stuck = mOwner->mStickListHead; + for (int i = 0; i < idx; i++) { + stuck = stuck->mNextSticker; + } + if (stuck) { + return stuck; + } + return nullptr; } /* diff --git a/src/plugPikiKando/interactBattle.cpp b/src/plugPikiKando/interactBattle.cpp index 56664d2c..f4753758 100644 --- a/src/plugPikiKando/interactBattle.cpp +++ b/src/plugPikiKando/interactBattle.cpp @@ -160,9 +160,9 @@ bool InteractSpore::actPiki(Piki* piki) // if not a puffmin, make a puffmin if (!piki->isKinoko()) { Creature* kinoko = mOwner; - if (piki->_2AC) { + if (piki->mGrabbedCreature.mPtr) { InteractRelease release(piki, 1.0f); - piki->_2AC->stimulate(release); + piki->mGrabbedCreature.mPtr->stimulate(release); } piki->_4A8 = kinoko; @@ -505,9 +505,9 @@ bool InteractSwallow::actPiki(Piki* piki) } if (!isPiki) { - Creature* target = mOwner->_180; + Creature* target = mOwner->mStickListHead; while (target) { - target = target->_18C; + target = target->mNextSticker; } } @@ -788,7 +788,7 @@ bool InteractPress::actPiki(Piki* piki) } piki->playEventSound(mOwner, 27); if (piki->hasBomb()) { - Creature* bomb = piki->_2AC; + Creature* bomb = piki->mGrabbedCreature.mPtr; bomb->resetStateGrabbed(); if (bomb->mObjType == OBJTYPE_Bomb) { MsgUser msg(1); diff --git a/src/plugPikiKando/mapcode.cpp b/src/plugPikiKando/mapcode.cpp index bde463b2..173d31db 100644 --- a/src/plugPikiKando/mapcode.cpp +++ b/src/plugPikiKando/mapcode.cpp @@ -8,7 +8,7 @@ * Address: 80116080 * Size: 00000C */ -u32 MapCode::getAttribute(CollTriInfo* triInfo) { return triInfo->mMapCode >> 29; }; +int MapCode::getAttribute(CollTriInfo* triInfo) { return triInfo->mMapCode >> 29; }; /* * --INFO-- @@ -26,7 +26,7 @@ char* MapCode::getAttributeName(int) * Address: 8011608C * Size: 00001C */ -u32 MapCode::getSlipCode(CollTriInfo* triInfo) +int MapCode::getSlipCode(CollTriInfo* triInfo) { if (triInfo) { return triInfo->mMapCode >> 27 & 3; diff --git a/src/plugPikiKando/mizuItem.cpp b/src/plugPikiKando/mizuItem.cpp index 85b70f0a..5c7ec125 100644 --- a/src/plugPikiKando/mizuItem.cpp +++ b/src/plugPikiKando/mizuItem.cpp @@ -84,7 +84,7 @@ void MizuItem::startAI(int) */ bool MizuItem::isAlive() { - int stateID = getCurrState()->getStateID(); + int stateID = getCurrState()->getID(); if (mObjType == OBJTYPE_FallWater) { return false; } diff --git a/src/plugPikiKando/navi.cpp b/src/plugPikiKando/navi.cpp index 4c6e7ceb..35f95c43 100644 --- a/src/plugPikiKando/navi.cpp +++ b/src/plugPikiKando/navi.cpp @@ -787,7 +787,7 @@ NaviProp::NaviProp() */ bool Navi::isBuried() { - if (getCurrState()->getStateID() == NAVISTATE_Bury) { + if (getCurrState()->getID() == NAVISTATE_Bury) { return true; } return false; @@ -800,7 +800,7 @@ bool Navi::isBuried() */ bool Navi::isVisible() { - if (getCurrState()->getStateID() == NAVISTATE_Dead) { + if (getCurrState()->getID() == NAVISTATE_Dead) { return false; } return true; @@ -813,7 +813,7 @@ bool Navi::isVisible() */ bool Navi::isRopable() { - if (getCurrState()->getStateID() == NAVISTATE_RopeExit) { + if (getCurrState()->getID() == NAVISTATE_RopeExit) { return false; } return true; diff --git a/src/plugPikiKando/naviState.cpp b/src/plugPikiKando/naviState.cpp index 88db0258..6aa27d71 100644 --- a/src/plugPikiKando/naviState.cpp +++ b/src/plugPikiKando/naviState.cpp @@ -328,7 +328,7 @@ void NaviStuckState::init(Navi* navi) */ void NaviStuckState::exec(Navi* navi) { - if (!navi->_180) { + if (!navi->mStickListHead) { transit(navi, NAVISTATE_Walk); return; } diff --git a/src/plugPikiKando/pikiInf.cpp b/src/plugPikiKando/pikiInf.cpp index 320a97e9..3ee684a2 100644 --- a/src/plugPikiKando/pikiInf.cpp +++ b/src/plugPikiKando/pikiInf.cpp @@ -494,14 +494,14 @@ void CreatureInf::doStore(Creature* owner) _38 = owner->isCreatureFlag(CF_Unk16) != 0; owner->doStore(this); - if (owner->_34 > 0) { + if (owner->mRebirthDay > 0) { if (owner->isAlive()) { _38 = 1; - _34 = owner->_34; + _34 = owner->mRebirthDay; } else { _38 = 0; _30 = gameflow.mWorldClock._24; - _34 = owner->_34; + _34 = owner->mRebirthDay; } } } diff --git a/src/plugPikiKando/ropeCreature.cpp b/src/plugPikiKando/ropeCreature.cpp index 999c9c39..bd87e40d 100644 --- a/src/plugPikiKando/ropeCreature.cpp +++ b/src/plugPikiKando/ropeCreature.cpp @@ -226,7 +226,7 @@ void RopeCreature::update() * Address: 80094978 * Size: 0000B4 */ -void RopeCreature::getRopePos(f32) +Vector3f RopeCreature::getRopePos(f32) { /* .loc_0x0: diff --git a/src/plugPikiKando/updateMgr.cpp b/src/plugPikiKando/updateMgr.cpp index 95b6b190..2e8590c7 100644 --- a/src/plugPikiKando/updateMgr.cpp +++ b/src/plugPikiKando/updateMgr.cpp @@ -73,7 +73,7 @@ void UpdateContext::exit() mMgr->removeClient(this); mMgr = nullptr; } - mIsActive = false; + mIsPiki = false; } /* @@ -171,7 +171,7 @@ void UpdateMgr::addClient(UpdateContext* client) mClientSlotList[slotIdx]++; // if client is active, assign to active slot as well - if (client->mIsActive) { + if (client->mIsPiki) { mActiveClientSlotList[slotIdx]++; } @@ -191,7 +191,7 @@ void UpdateMgr::removeClient(UpdateContext* client) } mClientSlotList[client->mMgrSlotIndex]--; - if (client->isActive()) { + if (client->isPiki()) { mActiveClientSlotList[client->mMgrSlotIndex]--; } diff --git a/src/plugPikiKando/workObject.cpp b/src/plugPikiKando/workObject.cpp index 6a5fa173..3aac831c 100644 --- a/src/plugPikiKando/workObject.cpp +++ b/src/plugPikiKando/workObject.cpp @@ -2782,8 +2782,8 @@ Bridge::Bridge(Shape* shape, bool a3) _40C->mSystemFlags |= 0x10; _40C->mSystemFlags |= 0x4; - mBuildShape = new DynBuildShape(shape); - mBuildShape->_28 = this; + mBuildShape = new DynBuildShape(shape); + mBuildShape->mCreature = this; if (_3C8) { mStageCount = shape->mJointList->getChildCount() / 2; diff --git a/src/plugPikiNakata/genteki.cpp b/src/plugPikiNakata/genteki.cpp index 9da6ab2d..2f0241b7 100644 --- a/src/plugPikiNakata/genteki.cpp +++ b/src/plugPikiNakata/genteki.cpp @@ -143,6 +143,6 @@ Creature* GenObjectTeki::birth(BirthInfo& info) teki->setCreatureFlag(CF_Unk16); } - teki->_34 = info.mGenerator->_28->_18(); + teki->mRebirthDay = info.mGenerator->_28->_18(); return teki; } diff --git a/src/plugPikiNishimura/Boss.cpp b/src/plugPikiNishimura/Boss.cpp index aeb0f714..b3a0e078 100644 --- a/src/plugPikiNishimura/Boss.cpp +++ b/src/plugPikiNishimura/Boss.cpp @@ -463,7 +463,7 @@ int Boss::getStickMouthPikiCount() CI_LOOP(iter) { Creature* stuck = *iter; - if (stuck->isAlive() && stuck->isGrabbed()) { + if (stuck->isAlive() && stuck->isStickToMouth()) { count++; } } @@ -483,7 +483,7 @@ int Boss::getStickNoMouthPikiCount() CI_LOOP(iter) { Creature* stuck = *iter; - if (stuck->isAlive() && !stuck->isGrabbed()) { + if (stuck->isAlive() && !stuck->isStickToMouth()) { count++; } } diff --git a/src/plugPikiNishimura/PomAi.cpp b/src/plugPikiNishimura/PomAi.cpp index 02dcb95b..ac8ffc69 100644 --- a/src/plugPikiNishimura/PomAi.cpp +++ b/src/plugPikiNishimura/PomAi.cpp @@ -410,10 +410,10 @@ void PomAi::calcPetalStickers() CI_LOOP(iter) { Creature* stuck = *iter; - if (stuck && stuck->isAlive() && !stuck->isGrabbed()) { + if (stuck && stuck->isAlive() && !stuck->isStickToMouth()) { CollPart* childPart = slotPart->getChildAt(0); InteractSwallow swallow(mPom, childPart, 0); - bool res = stuck->stimulate(swallow); // necessary for stack + stuck->stimulate(swallow); } } } diff --git a/src/plugPikiYamashita/P2DStream.cpp b/src/plugPikiYamashita/P2DStream.cpp index c9ef2101..7097c6b8 100644 --- a/src/plugPikiYamashita/P2DStream.cpp +++ b/src/plugPikiYamashita/P2DStream.cpp @@ -68,4 +68,4 @@ void P2DStream::align(int paddingAmount) for (int i = 0; i < alignedPosition - position; i++) { mStream->readByte(); } -} \ No newline at end of file +} diff --git a/src/sysCommon/sysMath.cpp b/src/sysCommon/sysMath.cpp index bc572e78..71c6aa7c 100644 --- a/src/sysCommon/sysMath.cpp +++ b/src/sysCommon/sysMath.cpp @@ -707,7 +707,7 @@ f32 qdist2(f32 x0, f32 y0, f32 x1, f32 y1) * Address: ........ * Size: 000080 */ -void qdist3(f32, f32, f32, f32, f32, f32) +f32 qdist3(f32, f32, f32, f32, f32, f32) { // UNUSED FUNCTION }