From e63909316c3b24542db91585e0051f6448f1e562 Mon Sep 17 00:00:00 2001 From: intns <84647527+intns@users.noreply.github.com> Date: Tue, 12 Jul 2022 14:31:29 +0100 Subject: [PATCH] Finish AIFree aiBridge work match aiBridge --- .gitignore | 1 + README.MD | 1 - include/Game/GameStats.h | 19 ++ include/Game/InteractFarmHaero.h | 4 +- include/Game/InteractFarmKarero.h | 4 +- include/Game/Interaction.h | 51 ++--- include/Game/Navi.h | 2 +- include/PSM/Piki.h | 1 + include/PikiAI.h | 96 +++++++--- obj_files.mk | 2 +- src/plugProjectKandoU/aiBridge.cpp | 148 ++++++-------- src/plugProjectKandoU/aiFree.cpp | 180 ++++++++---------- .../enemyInteractActions.cpp | 1 - 13 files changed, 260 insertions(+), 250 deletions(-) create mode 100644 include/Game/GameStats.h diff --git a/.gitignore b/.gitignore index fba5f1697..bfd4592f9 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ Debug/ .vs/ ctx.c +pikmin2.code-workspace diff --git a/README.MD b/README.MD index 3d6049273..9f0b880a1 100644 --- a/README.MD +++ b/README.MD @@ -141,7 +141,6 @@ pikmin2.usa.dol: `sha1: 90d328bf8f190c90472e8c19e7e53c6ad0fe0d1a` - plugProjectNishimuraU/KumaKochappyAnimator.cpp - plugProjectNishimuraU/KurageAnimator.cpp - plugProjectNishimuraU/MapCreator.cpp - - plugProjectNishimuraU/MapUnit.cpp - plugProjectNishimuraU/MarAnimator.cpp - plugProjectNishimuraU/MiniHoudaiAnimator.cpp - plugProjectNishimuraU/ObjectLayout.cpp diff --git a/include/Game/GameStats.h b/include/Game/GameStats.h new file mode 100644 index 000000000..494471aa6 --- /dev/null +++ b/include/Game/GameStats.h @@ -0,0 +1,19 @@ +#ifndef _GAME_GAMESTATS_H +#define _GAME_GAMESTATS_H + +namespace Game { +struct Piki; + +namespace GameStat { +struct PikiNaviCounter { + void clear(); + void inc(Game::Piki*); + void dec(Game::Piki*); +}; + +extern PikiNaviCounter* workPikis; + +} // namespace GameStat +} // namespace Game + +#endif diff --git a/include/Game/InteractFarmHaero.h b/include/Game/InteractFarmHaero.h index cfe11d40d..abc2c8df1 100644 --- a/include/Game/InteractFarmHaero.h +++ b/include/Game/InteractFarmHaero.h @@ -5,17 +5,15 @@ #include "Game/Interaction.h" namespace Game { +// TODO: MATCHING VTABLE WILL ERROR!! (vtable previously defined) struct InteractFarmHaero : public Interaction { virtual bool actCommon(Creature*); // _00 virtual bool actPiki(Piki*); // _04 virtual bool actNavi(Navi*); // _08 virtual bool actEnemy(EnemyBase*); // _0C - virtual bool actPellet(Pellet*); // _10 - virtual bool actOnyon(Onyon*); // _14 virtual bool actItem(BaseItem*); // _18 // _00 VTBL - Creature* m_creature; // _04 s32 _08; }; } // namespace Game diff --git a/include/Game/InteractFarmKarero.h b/include/Game/InteractFarmKarero.h index 5e7ab73e7..b5ac2c375 100644 --- a/include/Game/InteractFarmKarero.h +++ b/include/Game/InteractFarmKarero.h @@ -5,17 +5,15 @@ #include "Game/Interaction.h" namespace Game { +// TODO: MATCHING VTABLE WILL ERROR!! (vtable previously defined) struct InteractFarmKarero : public Interaction { virtual bool actCommon(Creature*); // _00 virtual bool actPiki(Piki*); // _04 virtual bool actNavi(Navi*); // _08 virtual bool actEnemy(EnemyBase*); // _0C - virtual bool actPellet(Pellet*); // _10 - virtual bool actOnyon(Onyon*); // _14 virtual bool actItem(BaseItem*); // _18 // _00 VTBL - Creature* m_creature; // _04 s32 _08; }; } // namespace Game diff --git a/include/Game/Interaction.h b/include/Game/Interaction.h index 37ef43f3a..0d2373f02 100644 --- a/include/Game/Interaction.h +++ b/include/Game/Interaction.h @@ -5,7 +5,14 @@ #include "types.h" namespace Game { +struct Creature; + struct Interaction { + Interaction(Creature* creature) + : m_creature(creature) + { + } + virtual bool actCommon(struct Creature*); // _00 virtual bool actPiki(struct Piki*); // _04 virtual bool actNavi(struct Navi*); // _08 @@ -15,6 +22,7 @@ struct Interaction { virtual bool actItem(struct BaseItem*); // _18 // _00 VTBL + Creature* m_creature; // _04 }; struct InteractFlick : public Interaction { @@ -22,16 +30,13 @@ struct InteractFlick : public Interaction { virtual bool actPiki(Piki*); virtual bool actNavi(Navi*); - Creature* m_creature; // _04 - f32 m_knockback; // _08 - f32 m_damage; // _0C - f32 _10; // _10 + f32 m_knockback; // _08 + f32 m_damage; // _0C + f32 _10; // _10 }; struct InteractAbsorb : public Interaction { virtual bool actItem(BaseItem*); // _18 - - Piki* m_piki; // _04 }; struct InteractAttack : public Interaction { @@ -40,7 +45,6 @@ struct InteractAttack : public Interaction { virtual bool actEnemy(EnemyBase*); virtual bool actItem(BaseItem*); - Creature* m_creature; // _04 f32 _08; // _08 struct CollPart* m_collPart; // _0C }; @@ -48,7 +52,6 @@ struct InteractAttack : public Interaction { struct InteractBreakBridge : public Interaction { virtual bool actItem(BaseItem*); // _18 - u8 _04[4]; // _04 float _08; // _08 }; @@ -56,42 +59,46 @@ struct InteractDope : public Interaction { virtual bool actPiki(Piki*); // _04 virtual bool actEnemy(EnemyBase*); // _0C - Creature* m_creature; // _04 - s32 m_sprayType; // _08 + s32 m_sprayType; // _08 }; struct InteractEat : public Interaction { virtual bool actPellet(Pellet*); // _10 virtual bool actItem(BaseItem*); // _18 - Creature* m_creature; // _04 - int _08; // _08 + int _08; // _08 }; struct InteractFlockAttack : public Interaction { virtual bool actItem(BaseItem*); // _18 - Creature* m_creature; // _04 - int _08; // _08 - float _0C; // _0C - u8 _10; // _10 - Vector3f _14; // _14 + int _08; // _08 + float _0C; // _0C + u8 _10; // _10 + Vector3f _14; // _14 }; struct InteractFue : public Interaction { + InteractFue(Creature* parent, u8 a, u8 b) + : Interaction(parent) + { + _08 = a; + _09 = b; + } + virtual bool actPiki(Piki*); // _04 virtual bool actNavi(Navi*); // _08 virtual bool actItem(BaseItem*); // _18 - Navi* m_navi; // _04 - u8 _08; // _08 - u8 _09; // _09 + // _00 VTBL + u8 _08; // _08 + u8 _09; // _09 }; struct InteractGotKey : public Interaction { virtual bool actItem(BaseItem*); // _18 - Onyon* m_onyon; // _04 + // _04 should be casted to Onyon }; struct InteractSwallow : public InteractAttack { @@ -104,8 +111,6 @@ struct InteractSwallow : public InteractAttack { struct InteractKill : public Interaction { virtual bool actCommon(Creature*); virtual bool actPiki(Piki*); - - Creature* m_creature; // _04 }; } // namespace Game diff --git a/include/Game/Navi.h b/include/Game/Navi.h index d9484ba03..1dd738158 100644 --- a/include/Game/Navi.h +++ b/include/Game/Navi.h @@ -222,7 +222,7 @@ struct Navi : public FakePiki, virtual public PelletView { void disableController(); void enterAllPikis(); void findNextThrowPiki(); - void formationable(); + bool formationable(); void fountainonAllPikis(Vector3f&); int getDopeCount(int); void getLifeRatio(); diff --git a/include/PSM/Piki.h b/include/PSM/Piki.h index 7ba7025d8..aae190ce0 100644 --- a/include/PSM/Piki.h +++ b/include/PSM/Piki.h @@ -4,6 +4,7 @@ namespace PSM { struct Piki { void becomeFree(); + void becomeNotFree(); }; } // namespace PSM diff --git a/include/PikiAI.h b/include/PikiAI.h index 68a9022be..70e3e55ca 100644 --- a/include/PikiAI.h +++ b/include/PikiAI.h @@ -161,21 +161,46 @@ struct ActBreakRock { void platCallback(Game::Piki*, Game::PlatEvent&); }; -struct ActBridgeArg { - void getName(); +struct ActBridgeArg : ActionArg { + virtual char* getName(); + + u32* _04; // _04 }; -struct ActBridge { +#define PIKIAI_BRIDGE_DEFAULT 0 +#define PIKIAI_BRIDGE_ +#define PIKIAI_BRIDGE_STICKATTACK 2 + +struct ActStickAttack; +struct ActGotoPos; +struct ActFollowVectorField; + +struct ActBridge : public Action, virtual SysShape::MotionListener { ActBridge(Game::Piki*); - void bounceCallback(Game::Piki*, Sys::Triangle*); - void cleanup(); - void collisionCallback(Game::Piki*, Game::CollEvent&); - void exec(); - void init(PikiAI::ActionArg*); + virtual void init(PikiAI::ActionArg*); + virtual s32 exec(); + virtual void cleanup(); + virtual void bounceCallback(Game::Piki*, Sys::Triangle*); + virtual void collisionCallback(Game::Piki*, Game::CollEvent&); + virtual void platCallback(Game::Piki*, Game::PlatEvent&); + virtual void onKeyEvent(const SysShape::KeyEvent&); + void initFollow(); - void onKeyEvent(const SysShape::KeyEvent&); - void platCallback(Game::Piki*, Game::PlatEvent&); + inline void initGoto(); + inline void initStickAttack(); + inline void calcAttackPos(); + + // _00 => _0C Action + MotionListener + u32* _10; // _10 + u16 m_state; // _14 + ActStickAttack* m_stickAttack; // _18 + ActGotoPos* m_gotoPos; // _1C + ActFollowVectorField* m_followField; // _20 + u32 _24; // _24 + u32 _28; // _28 + u32 _2C; // _2C + u8 _30; // _30 }; struct ActClimb { @@ -241,12 +266,15 @@ struct FollowVectorFieldActionArg { void getName(); }; -struct ActFollowVectorField { +struct ActFollowVectorField : public Action { ActFollowVectorField(Game::Piki*); - void cleanup(); - void exec(); - void init(PikiAI::ActionArg*); + virtual void init(PikiAI::ActionArg*); + virtual s32 exec(); + virtual void cleanup(); + + // _08 + u32 _0C; // _0C }; struct ActFormation { @@ -278,9 +306,9 @@ struct ActFreeArg : ActionArg { struct ActGather; -#define PIKI_ACT_FREE_DEFAULT 0 -#define PIKI_ACT_FREE_GATHER 1 -#define PIKI_ACT_FREE_BORE 2 +#define PIKIAI_FREE_DEFAULT 0 +#define PIKIAI_FREE_GATHER 1 +#define PIKIAI_FREE_BORE 2 struct ActFree : public Action, virtual SysShape::MotionListener { ActFree(Game::Piki*); @@ -292,7 +320,7 @@ struct ActFree : public Action, virtual SysShape::MotionListener { virtual void collisionCallback(Game::Piki*, Game::CollEvent&); virtual void onKeyEvent(const SysShape::KeyEvent&); - u16 m_currentAction; // _10 + u16 m_state; // _10 ActGather* m_actGather; // _14 ActBore* m_actBore; // _18 u16 m_delayTimer; // _1C @@ -334,12 +362,18 @@ struct GotoPosActionArg { void getName(); }; -struct ActGotoPos { +struct ActGotoPos : public Action { ActGotoPos(Game::Piki*); - void cleanup(); - void exec(); - void init(PikiAI::ActionArg*); + virtual void init(PikiAI::ActionArg*); + virtual s32 exec(); + virtual void cleanup(); + + // _08 + u32 _0C; + u32 _10; + u32 _14; + u32 _18; }; struct GotoSlotArg { @@ -427,14 +461,22 @@ struct StickAttackActionArg { void getName(); }; -struct ActStickAttack { +struct ActStickAttack : public Action, virtual SysShape::MotionListener { ActStickAttack(Game::Piki*); - void cleanup(); + virtual void init(PikiAI::ActionArg*); + virtual void cleanup(); + virtual s32 exec(); + virtual void onKeyEvent(const SysShape::KeyEvent&); + void createEfx(); - void exec(); - void init(PikiAI::ActionArg*); - void onKeyEvent(const SysShape::KeyEvent&); + + // _0C + u32 _10; // _10 + u32 _14; // _14 + u32 _18; // _18 + u32 _1C; // _1C + u32 _20; // _1C }; struct ActTeki { diff --git a/obj_files.mk b/obj_files.mk index e868c5b08..368340247 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -629,7 +629,7 @@ NISHIMURA:=\ $(BUILD_DIR)/asm/plugProjectNishimuraU/ShadowCylinder.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/playCamera.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/shadowMgr.o\ - $(BUILD_DIR)/src/plugProjectNishimuraU/MapUnit.o\ + $(BUILD_DIR)/asm/plugProjectNishimuraU/MapUnit.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/MapNode.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/EnemyUnit.o\ $(BUILD_DIR)/asm/plugProjectNishimuraU/RandMapMgr.o\ diff --git a/src/plugProjectKandoU/aiBridge.cpp b/src/plugProjectKandoU/aiBridge.cpp index 7a1bdbccb..3663faa0a 100644 --- a/src/plugProjectKandoU/aiBridge.cpp +++ b/src/plugProjectKandoU/aiBridge.cpp @@ -76,86 +76,36 @@ .4byte 0x00000000 */ +#include "Dolphin/rand.h" +#include "Dolphin/string.h" + +#include "JSystem/JUT/JUTException.h" + +#include "Game/Navi.h" +#include "Game/Piki.h" +#include "Game/rumble.h" +#include "Game/CollEvent.h" +#include "Game/Interaction.h" +#include "Game/GameStats.h" + +#include "PikiAI.h" + +namespace PikiAI { /* * --INFO-- * Address: 80212288 * Size: 0000FC */ -PikiAI::ActBridge::ActBridge(Game::Piki*) +ActBridge::ActBridge(Game::Piki* parent) + : Action(parent) { - /* - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - extsh. r0, r4 - stw r31, 0xc(r1) - mr r31, r5 - stw r30, 8(r1) - mr r30, r3 - beq lbl_802122C0 - addi r0, r30, 0x34 - lis r3, __vt__Q28SysShape14MotionListener@ha - stw r0, 0xc(r30) - addi r0, r3, __vt__Q28SysShape14MotionListener@l - stw r0, 0x34(r30) + _30 = 0; -lbl_802122C0: - mr r3, r30 - mr r4, r31 - bl __ct__Q26PikiAI6ActionFPQ24Game4Piki - lis r3, __vt__Q26PikiAI9ActBridge@ha - addi r4, r30, 0x34 - addi r3, r3, __vt__Q26PikiAI9ActBridge@l - li r0, 0 - stw r3, 0(r30) - addi r6, r3, 0x40 - li r3, 0x2c - lwz r5, 0xc(r30) - stw r6, 0(r5) - lwz r5, 0xc(r30) - subf r4, r5, r4 - stw r4, 4(r5) - stb r0, 0x30(r30) - bl __nw__FUl - or. r0, r3, r3 - beq lbl_8021231C - mr r5, r31 - li r4, 1 - bl __ct__Q26PikiAI14ActStickAttackFPQ24Game4Piki - mr r0, r3 + m_stickAttack = new ActStickAttack(parent); + m_gotoPos = new ActGotoPos(parent); + m_followField = new ActFollowVectorField(parent); -lbl_8021231C: - stw r0, 0x18(r30) - li r3, 0x1c - bl __nw__FUl - or. r0, r3, r3 - beq lbl_8021233C - mr r4, r31 - bl __ct__Q26PikiAI10ActGotoPosFPQ24Game4Piki - mr r0, r3 - -lbl_8021233C: - stw r0, 0x1c(r30) - li r3, 0x10 - bl __nw__FUl - or. r0, r3, r3 - beq lbl_8021235C - mr r4, r31 - bl __ct__Q26PikiAI20ActFollowVectorFieldFPQ24Game4Piki - mr r0, r3 - -lbl_8021235C: - stw r0, 0x20(r30) - addi r0, r2, lbl_80519F58@sda21 - mr r3, r30 - stw r0, 8(r30) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + m_info = "Bridge"; } /* @@ -163,8 +113,18 @@ lbl_8021235C: * Address: 80212384 * Size: 0000C8 */ -void PikiAI::ActBridge::init(PikiAI::ActionArg*) +void ActBridge::init(PikiAI::ActionArg* actionArg) { + ActBridgeArg* arg = (ActBridgeArg*)actionArg; + P2ASSERTLINE(62, (arg) && strcmp("ActBridgeArg", arg->getName())); + + Game::GameStat::workPikis->inc(m_parent); + + _10 = arg->_04; + _30 = 0; + + initFollow(); + /* stwu r1, -0x20(r1) mflr r0 @@ -228,7 +188,7 @@ lbl_80212404: * Address: 8021244C * Size: 000068 */ -void PikiAI::ActBridge::initFollow(void) +void ActBridge::initFollow(void) { /* stwu r1, -0x20(r1) @@ -265,7 +225,7 @@ void PikiAI::ActBridge::initFollow(void) * Address: ........ * Size: 00009C */ -void PikiAI::ActBridge::initGoto(void) +void ActBridge::initGoto(void) { // UNUSED FUNCTION } @@ -275,7 +235,7 @@ void PikiAI::ActBridge::initGoto(void) * Address: ........ * Size: 0000BC */ -void PikiAI::ActBridge::initStickAttack(void) +void ActBridge::initStickAttack(void) { // UNUSED FUNCTION } @@ -285,7 +245,7 @@ void PikiAI::ActBridge::initStickAttack(void) * Address: ........ * Size: 000058 */ -void PikiAI::ActBridge::calcAttackPos(void) +void ActBridge::calcAttackPos(void) { // UNUSED FUNCTION } @@ -295,8 +255,9 @@ void PikiAI::ActBridge::calcAttackPos(void) * Address: 802124B4 * Size: 00031C */ -void PikiAI::ActBridge::exec(void) +s32 ActBridge::exec(void) { + return 0; /* stwu r1, -0x50(r1) mflr r0 @@ -541,7 +502,7 @@ lbl_802127BC: * Address: 802127D0 * Size: 00005C */ -void PikiAI::ActBridge::cleanup(void) +void ActBridge::cleanup(void) { /* stwu r1, -0x10(r1) @@ -579,7 +540,7 @@ lbl_80212818: * Address: 8021282C * Size: 000110 */ -void PikiAI::ActBridge::platCallback(Game::Piki*, Game::PlatEvent&) +void ActBridge::platCallback(Game::Piki*, Game::PlatEvent&) { /* stwu r1, -0x30(r1) @@ -668,34 +629,35 @@ lbl_80212928: * Address: 8021293C * Size: 000004 */ -void PikiAI::ActBridge::collisionCallback(Game::Piki*, Game::CollEvent&) { } +void ActBridge::collisionCallback(Game::Piki*, Game::CollEvent&) { } /* * --INFO-- * Address: 80212940 * Size: 000004 */ -void PikiAI::ActBridge::bounceCallback(Game::Piki*, Sys::Triangle*) { } +void ActBridge::bounceCallback(Game::Piki*, Sys::Triangle*) { } /* * --INFO-- * Address: 80212944 * Size: 000004 */ -void PikiAI::ActBridge::onKeyEvent(SysShape::KeyEvent const&) { } +void ActBridge::onKeyEvent(SysShape::KeyEvent const&) { } /* * --INFO-- * Address: 80212948 * Size: 000014 */ -void @52 @4 @PikiAI::ActBridge::onKeyEvent(SysShape::KeyEvent const&) -{ - /* - li r11, 4 - lwzx r11, r3, r11 - add r3, r3, r11 - addi r3, r3, -52 - b onKeyEvent__Q26PikiAI9ActBridgeFRCQ28SysShape8KeyEvent - */ -} +// void @52 @4 @PikiAI::ActBridge::onKeyEvent(SysShape::KeyEvent const&) +// { +// /* +// li r11, 4 +// lwzx r11, r3, r11 +// add r3, r3, r11 +// addi r3, r3, -52 +// b onKeyEvent__Q26PikiAI9ActBridgeFRCQ28SysShape8KeyEvent +// */ +// } +} // namespace PikiAI diff --git a/src/plugProjectKandoU/aiFree.cpp b/src/plugProjectKandoU/aiFree.cpp index e19d88be7..8ae79e756 100644 --- a/src/plugProjectKandoU/aiFree.cpp +++ b/src/plugProjectKandoU/aiFree.cpp @@ -1,11 +1,55 @@ -#include "Dolphin/string.h" #include "Dolphin/rand.h" +#include "Dolphin/string.h" #include "JSystem/JUT/JUTException.h" +#include "Game/Navi.h" #include "Game/Piki.h" +#include "Game/rumble.h" +#include "Game/CollEvent.h" +#include "Game/Interaction.h" + #include "PikiAI.h" +/* + Generated from dpostproc + .section .rodata # 0x804732E0 - 0x8049E220 + .global lbl_8047F260 + lbl_8047F260: + .asciz "ActFreeArg" + .skip 1 + .asciz "aiFree.cpp" + .skip 1 + .asciz "P2Assert" + .skip 3 + .asciz "ActionArg" + .skip 2 + .global lbl_8047F290 + lbl_8047F290: + .asciz "GatherActionArg" + .section .sdata2, "a" # 0x80516360 - 0x80520E40 + .global lbl_80519058 + lbl_80519058: + .asciz "Free" + .skip 3 + .global lbl_80519060 + lbl_80519060: + .float 0.0 + .global lbl_80519064 + lbl_80519064: + .float 32768.0 + .global lbl_80519068 + lbl_80519068: + .float 30.0 + .global lbl_8051906C + lbl_8051906C: + .float 0.5 + .global lbl_80519070 + lbl_80519070: + .4byte 0x43300000 + .4byte 0x80000000 +*/ + /* * --INFO-- * Address: 8019FF38 @@ -31,7 +75,7 @@ void PikiAI::ActFree::init(PikiAI::ActionArg* arg) PikiAI::ActFreeArg* freeArg = (PikiAI::ActFreeArg*)arg; - m_currentAction = PIKI_ACT_FREE_DEFAULT; + m_state = PIKIAI_FREE_DEFAULT; if (freeArg) { char* name = arg->getName(); bool isFreeArg = strcmp("ActFreeArg", name) == 0; @@ -39,12 +83,12 @@ void PikiAI::ActFree::init(PikiAI::ActionArg* arg) freeArg = (PikiAI::ActFreeArg*)arg; if (freeArg->_04) { - m_currentAction = PIKI_ACT_FREE_GATHER; + m_state = PIKIAI_FREE_GATHER; } } - switch (m_currentAction) { - case PIKI_ACT_FREE_GATHER: + switch (m_state) { + case PIKIAI_FREE_GATHER: GatherActionArg gatherArg(freeArg); m_actGather->init(&gatherArg); break; @@ -68,11 +112,11 @@ void PikiAI::ActFree::init(PikiAI::ActionArg* arg) */ s32 PikiAI::ActFree::exec(void) { - switch (m_currentAction) { - case PIKI_ACT_FREE_GATHER: { + switch (m_state) { + case PIKIAI_FREE_GATHER: { // If we finished the gather state if (m_actGather->exec() == 0) { - m_currentAction = PIKI_ACT_FREE_DEFAULT; + m_state = PIKIAI_FREE_DEFAULT; // Wait for a bit of time to cool off u16 frameDelay = 30 * randFloat(); @@ -81,7 +125,7 @@ s32 PikiAI::ActFree::exec(void) break; } - case PIKI_ACT_FREE_BORE: { + case PIKIAI_FREE_BORE: { s32 status = m_actBore->exec(); // Let's try invoke the AI, and finish the boredom if we succeed @@ -93,8 +137,8 @@ s32 PikiAI::ActFree::exec(void) // Assuming we finished or failed being bored, we'll be free again if (status == 0 || status == 2) { - m_currentAction = PIKI_ACT_FREE_DEFAULT; - m_delayTimer = 90; + m_state = PIKIAI_FREE_DEFAULT; + m_delayTimer = 90; } break; } @@ -113,7 +157,7 @@ s32 PikiAI::ActFree::exec(void) m_delayTimer--; } else if (randFloat() > 0.5f) { m_actBore->init(nullptr); - m_currentAction = PIKI_ACT_FREE_BORE; + m_state = PIKIAI_FREE_BORE; } break; @@ -130,27 +174,9 @@ s32 PikiAI::ActFree::exec(void) */ void PikiAI::ActFree::cleanup(void) { - /* - stwu r1, -0x10(r1) - mflr r0 - li r4, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lwz r3, 4(r3) - bl setFreeLightEffect__Q24Game4PikiFb - lwz r3, 4(r31) - li r4, 0 - bl attachRadar__Q24Game4PikiFb - lwz r3, 4(r31) - lwz r3, 0x250(r3) - bl becomeNotFree__Q23PSM4PikiFv - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr - */ + m_parent->setFreeLightEffect(false); + m_parent->attachRadar(false); + m_parent->m_soundObj->becomeNotFree(); } /* @@ -165,71 +191,31 @@ void PikiAI::ActFree::onKeyEvent(SysShape::KeyEvent const&) { } * Address: 801A03B8 * Size: 0000EC */ -void PikiAI::ActFree::collisionCallback(Game::Piki*, Game::CollEvent&) +void PikiAI::ActFree::collisionCallback(Game::Piki* piki, Game::CollEvent& event) { - /* - stwu r1, -0x30(r1) - mflr r0 - stw r0, 0x34(r1) - stw r31, 0x2c(r1) - stw r30, 0x28(r1) - mr r30, r5 - stw r29, 0x24(r1) - mr r29, r4 - lwz r3, 0(r5) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_801A0488 - lwz r31, 0(r30) - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 0xa8(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x18 - beq lbl_801A0488 - lwz r0, 0x278(r31) - cmplwi r0, 0 - beq lbl_801A0488 - mr r3, r31 - bl formationable__Q24Game4NaviFv - clrlwi. r0, r3, 0x18 - beq lbl_801A0488 - lwz r3, rumbleMgr__4Game@sda21(r13) - li r4, 2 - lhz r5, 0x2dc(r31) - bl startRumble__Q24Game9RumbleMgrFii - lwz r4, 0(r30) - lis r3, __vt__Q24Game11Interaction@ha - addi r0, r3, __vt__Q24Game11Interaction@l - lis r3, __vt__Q24Game11InteractFue@ha - stw r0, 8(r1) - addi r6, r3, __vt__Q24Game11InteractFue@l - li r5, 0 - li r0, 1 - stw r4, 0xc(r1) - mr r3, r29 - addi r4, r1, 8 - stw r6, 8(r1) - stb r5, 0x10(r1) - stb r0, 0x11(r1) - lwz r12, 0(r29) - lwz r12, 0x1a4(r12) - mtctr r12 - bctrl + if (!event.m_collidingCreature->isNavi()) { + return; + } -lbl_801A0488: - lwz r0, 0x34(r1) - lwz r31, 0x2c(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - mtlr r0 - addi r1, r1, 0x30 - blr - */ + Game::Navi* navi = (Game::Navi*)event.m_collidingCreature; + if (!navi->isAlive()) { + return; + } + + // If the Navi who touched us isn't being used right now (by controller) + if (!navi->m_padinput) { + return; + } + + // If the Navi can't call us into formation + if (!navi->formationable()) { + return; + } + + // Assuming the Navi touched us, rumble and call to squad (eventually) + Game::rumbleMgr->startRumble(2, navi->m_naviIndex.m_shortView); + Game::InteractFue fue(event.m_collidingCreature, 0, 1); + piki->stimulate(fue); } /* @@ -244,7 +230,7 @@ char* PikiAI::GatherActionArg::getName() { return "GatherActionArg"; } * Address: 801A04B0 * Size: 000008 */ -u32 PikiAI::ActFree::getNextAIType() { return 2; } +u32 PikiAI::ActFree::getNextAIType() { return PIKIAI_FREE_BORE; } /* * --INFO-- diff --git a/src/plugProjectYamashitaU/enemyInteractActions.cpp b/src/plugProjectYamashitaU/enemyInteractActions.cpp index f4c29b957..ed127e4a5 100644 --- a/src/plugProjectYamashitaU/enemyInteractActions.cpp +++ b/src/plugProjectYamashitaU/enemyInteractActions.cpp @@ -1,6 +1,5 @@ #include "Game/InteractFarmKarero.h" #include "Game/InteractFarmHaero.h" -#include "Game/Interaction.h" #include "Game/EnemyBase.h" namespace Game {