Link aiBattle.cpp

epoch you owe me $20
This commit is contained in:
HeartPiece 2023-12-28 20:22:43 +11:00
parent 4adee4f94b
commit 9cafdf6c00
7 changed files with 173 additions and 1493 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1000,7 +1000,7 @@ LIBS = [
["plugProjectKandoU/cellIterator", False],
["plugProjectKandoU/vsGS_VSGame", True],
["plugProjectKandoU/gameSoundEvent", True],
["plugProjectKandoU/aiBattle", False],
["plugProjectKandoU/aiBattle", True],
["plugProjectKandoU/gameDeathCount", True],
["plugProjectKandoU/aiBore", True],
["plugProjectKandoU/mapPartsView", True],

View File

@ -102,29 +102,29 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/naviWhistle.cpp">naviWhistle.cpp</a> | 11601 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemHole.cpp">itemHole.cpp</a> | 11707 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemHoney.cpp">itemHoney.cpp</a> | 12288 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemBigFountain.cpp">itemBigFountain.cpp</a> | 12667 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiBreakGate.cpp">aiBreakGate.cpp</a> | 13962 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/creatureLOD.cpp">creatureLOD.cpp</a> | 14138 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/texCaster.cpp">texCaster.cpp</a> | 14405 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiBattle.cpp">aiBattle.cpp</a> | 14627 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCaveInfo.cpp">gameCaveInfo.cpp</a> | 15260 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/baseGameSectionKantei.cpp">baseGameSectionKantei.cpp</a> | 15444 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemRock.cpp">itemRock.cpp</a> | 17251 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemCave.cpp">itemCave.cpp</a> | 20160 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pathfinder.cpp">pathfinder.cpp</a> | 20316 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemDownFloor.cpp">itemDownFloor.cpp</a> | 21092 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_MainResult.cpp">singleGS_MainResult.cpp</a> | 21380 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/dynCreature.cpp">dynCreature.cpp</a> | 21624 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameDynamics.cpp">gameDynamics.cpp</a> | 24672 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_CaveResult.cpp">singleGS_CaveResult.cpp</a> | 24942 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPikihead.cpp">itemPikihead.cpp</a> | 26218 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCPlate.cpp">gameCPlate.cpp</a> | 26452 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_DayEnd.cpp">singleGS_DayEnd.cpp</a> | 30300 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/vsCardMgr.cpp">vsCardMgr.cpp</a> | 30743 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemBridge.cpp">itemBridge.cpp</a> | 32134 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gamePlayDataMemCard.cpp">gamePlayDataMemCard.cpp</a> | 36009 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/piki.cpp">piki.cpp</a> | 36183 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/routeMgr.cpp">routeMgr.cpp</a> | 39098 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameGeneratorCache.cpp">gameGeneratorCache.cpp</a> | 40204 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/mapMgr.cpp">mapMgr.cpp</a> | 43345 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/collinfo.cpp">collinfo.cpp</a> | 43401 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemGate.cpp">itemGate.cpp</a> | 44298 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_MainGame.cpp">singleGS_MainGame.cpp</a> | 46509 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pikiMgr.cpp">pikiMgr.cpp</a> | 47819 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/cellPyramid.cpp">cellPyramid.cpp</a> | 51129 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiFormation.cpp">aiFormation.cpp</a> | 52263 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/navi_demoCheck.cpp">navi_demoCheck.cpp</a> | 60100 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemWeed.cpp">itemWeed.cpp</a> | 62050 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pelletState.cpp">pelletState.cpp</a> | 62916 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemUjamushi.cpp">itemUjamushi.cpp</a> | 63532 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_CaveGame.cpp">singleGS_CaveGame.cpp</a> | 64715 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/fakePiki.cpp">fakePiki.cpp</a> | 65586 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gamePlayData.cpp">gamePlayData.cpp</a> | 66859 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPlant.cpp">itemPlant.cpp</a> | 73145 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGameSection.cpp">singleGameSection.cpp</a> | 86509 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/baseGameSection.cpp">baseGameSection.cpp</a> | 92113 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemMgr.cpp">itemMgr.cpp</a> | 102130 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiPrimitives.cpp">aiPrimitives.cpp</a> | 116999 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pelletMgr.cpp">pelletMgr.cpp</a> | 142647 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pikiState.cpp">pikiState.cpp</a> | 152912 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/navi.cpp">navi.cpp</a> | 153111 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameMapParts.cpp">gameMapParts.cpp</a> | 168088 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/naviState.cpp">naviState.cpp</a> | 180513 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_Zukan.cpp">singleGS_Zukan.cpp</a> | 192293 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/texCaster.cpp">texCaster.cpp</a> | 14405 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCaveInfo.cpp">gameCaveInfo.cpp</a> | 15260 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/baseGameSectionKantei.cpp">baseGameSectionKantei.cpp</a> | 15444 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemRock.cpp">itemRock.cpp</a> | 17251 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemCave.cpp">itemCave.cpp</a> | 20160 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pathfinder.cpp">pathfinder.cpp</a> | 20316 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemDownFloor.cpp">itemDownFloor.cpp</a> | 21092 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_MainResult.cpp">singleGS_MainResult.cpp</a> | 21380 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/dynCreature.cpp">dynCreature.cpp</a> | 21624 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameDynamics.cpp">gameDynamics.cpp</a> | 24672 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_CaveResult.cpp">singleGS_CaveResult.cpp</a> | 24942 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPikihead.cpp">itemPikihead.cpp</a> | 26218 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCPlate.cpp">gameCPlate.cpp</a> | 26452 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_DayEnd.cpp">singleGS_DayEnd.cpp</a> | 30300 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/vsCardMgr.cpp">vsCardMgr.cpp</a> | 30743 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemBridge.cpp">itemBridge.cpp</a> | 32134 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gamePlayDataMemCard.cpp">gamePlayDataMemCard.cpp</a> | 36009 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/piki.cpp">piki.cpp</a> | 36183 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/routeMgr.cpp">routeMgr.cpp</a> | 39098 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameGeneratorCache.cpp">gameGeneratorCache.cpp</a> | 40204 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/mapMgr.cpp">mapMgr.cpp</a> | 43345 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/collinfo.cpp">collinfo.cpp</a> | 43401 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemGate.cpp">itemGate.cpp</a> | 44298 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_MainGame.cpp">singleGS_MainGame.cpp</a> | 46509 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pikiMgr.cpp">pikiMgr.cpp</a> | 47819 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/cellPyramid.cpp">cellPyramid.cpp</a> | 51129 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiFormation.cpp">aiFormation.cpp</a> | 52263 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/navi_demoCheck.cpp">navi_demoCheck.cpp</a> | 60100 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemWeed.cpp">itemWeed.cpp</a> | 62050 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pelletState.cpp">pelletState.cpp</a> | 62916 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemUjamushi.cpp">itemUjamushi.cpp</a> | 63532 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_CaveGame.cpp">singleGS_CaveGame.cpp</a> | 64715 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/fakePiki.cpp">fakePiki.cpp</a> | 65586 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gamePlayData.cpp">gamePlayData.cpp</a> | 66859 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPlant.cpp">itemPlant.cpp</a> | 73145 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGameSection.cpp">singleGameSection.cpp</a> | 86509 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/baseGameSection.cpp">baseGameSection.cpp</a> | 92113 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemMgr.cpp">itemMgr.cpp</a> | 102130 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiPrimitives.cpp">aiPrimitives.cpp</a> | 116999 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pelletMgr.cpp">pelletMgr.cpp</a> | 142647 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pikiState.cpp">pikiState.cpp</a> | 152912 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/navi.cpp">navi.cpp</a> | 153111 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameMapParts.cpp">gameMapParts.cpp</a> | 168088 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/naviState.cpp">naviState.cpp</a> | 180513 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_Zukan.cpp">singleGS_Zukan.cpp</a> | 192293 | | |
### <section id="plugProjectKonoU">plugProjectKonoU</section>
| File | Size (bytes) | File | Size (bytes) |

View File

@ -261,6 +261,10 @@ struct ActAttack : public Action, virtual SysShape::MotionListener {
// _38 = MotionListener
};
struct BattleMessage {
ActBattle* mBattle; // _00
};
struct ActBattleArg : public ActionArg {
virtual const char* getName() { return "ActBattleArg"; } // _08 (weak)
@ -277,13 +281,19 @@ struct ActBattleArg : public ActionArg {
bool mIsAttackStart; // _08
};
#define PIKIAI_ACTBATTLE_APPROACH (0)
#define PIKIAI_ACTBATTLE_BATTLE (1)
#define PIKIAI_ACTBATTLE_DAMAGE (2)
// Pikmin hitting eachother, like in VS mode
struct ActBattle : public Action, virtual SysShape::MotionListener {
ActBattle(Game::Piki* p);
enum StateID {
BATTLE_Approach = 0,
BATTLE_Battle = 1,
BATTLE_Damage = 2,
};
enum BattleFlags {
BATTLEFLAG_InBattle = 0x2,
};
ActBattle(Game::Piki* piki);
virtual void init(ActionArg* settings); // _08
virtual int exec(); // _0C
@ -298,14 +308,22 @@ struct ActBattle : public Action, virtual SysShape::MotionListener {
int execBattle();
int execDamage();
Action* getTekiAction();
void send(BattleMessage& msg);
void recv(BattleMessage& msg);
inline void setFlag(u32 flag) { mFlags |= flag; }
inline void resetFlag(u32 flag) { mFlags &= ~flag; }
inline bool isFlag(u32 flag) const { return mFlags & flag; }
// _00 = VTBL
// _00-_0C = Action
// _0C-_10 = MotionListener*
Game::Piki* mOther; // _10, vs battle piki attack
u8 mState; // _14
ActApproachPos* mApproachPos; // _18
s8 mFlags; // _1C
s8 mHitCount; // _1D
u8 mFlags; // _1C
u8 mHitCount; // _1D
};
struct ActBoreBase : public Action, virtual SysShape::MotionListener {

View File

@ -111,7 +111,7 @@ KANDO_FILES:=\
$(BUILD_DIR)/asm/plugProjectKandoU/cellIterator.o\
$(BUILD_DIR)/src/plugProjectKandoU/vsGS_VSGame.o\
$(BUILD_DIR)/src/plugProjectKandoU/gameSoundEvent.o\
$(BUILD_DIR)/asm/plugProjectKandoU/aiBattle.o\
$(BUILD_DIR)/src/plugProjectKandoU/aiBattle.o\
$(BUILD_DIR)/src/plugProjectKandoU/gameDeathCount.o\
$(BUILD_DIR)/src/plugProjectKandoU/aiBore.o\
$(BUILD_DIR)/src/plugProjectKandoU/mapPartsView.o\

View File

@ -1,5 +1,3 @@
#include "types.h"
#include "PikiAI.h"
#include "Game/Piki.h"
#include "efx/TPk.h"
@ -16,18 +14,20 @@
namespace PikiAI {
#ifdef MATCHING
static const char unusedAiBattleName[] = "aiBattle";
#endif
/**
* @note Address: 0x8022ECB4
* @note Size: 0xB8
*/
ActBattle::ActBattle(Game::Piki* p)
: Action(p)
ActBattle::ActBattle(Game::Piki* piki)
: Action(piki)
{
mFlags = 0;
mName = "Battle";
mApproachPos = new ActApproachPos(p);
mApproachPos = new ActApproachPos(piki);
}
/**
@ -40,6 +40,48 @@ void ActBattle::emotion_success()
mParent->mFsm->transit(mParent, Game::PIKISTATE_Emotion, &arg);
}
/**
* @note Address: N/A
* @note Size: 0x50
*/
Action* ActBattle::getTekiAction()
{
if (mOther && mOther->getCurrActionID() == PikiAI::ACT_Battle) {
return mOther->getCurrAction();
}
return nullptr;
}
/**
* @note Address: N/A
* @note Size: 0x78
*/
void ActBattle::send(BattleMessage& msg)
{
// UNUSED/INLINED
}
/**
* @note Address: N/A
* @note Size: 0x11C
*/
void ActBattle::recv(BattleMessage& msg)
{
ActBattle* battle = msg.mBattle;
if (battle && battle->mState != BATTLE_Damage) {
if (randFloat() > 0.5f) {
if (battle->mOther && randFloat() > 0.9f) {
battle->initApproach();
Game::InteractFlick flick(battle->mOther, 60.0f, 0.0f, FLICK_BACKWARD_ANGLE);
battle->mParent->stimulate(flick);
} else {
battle->initApproach();
}
}
}
}
/**
* @note Address: 0x8022EDB0
* @note Size: 0x300
@ -47,10 +89,9 @@ void ActBattle::emotion_success()
*/
void ActBattle::init(PikiAI::ActionArg* arg)
{
bool isBattleArg = false;
if (arg) {
bool strCheck = strcmp("ActTransportArg", arg->getName()) == 0;
bool strCheck = strcmp("ActBattleArg", arg->getName()) == 0;
if (strCheck) {
isBattleArg = true;
}
@ -63,38 +104,40 @@ void ActBattle::init(PikiAI::ActionArg* arg)
Game::InteractBattle battle(mParent);
mOther->stimulate(battle);
if (battleArg->mIsAttackStart) {
SET_FLAG(mFlags, 2);
setFlag(BATTLEFLAG_InBattle);
} else if (mOther == mOther->getVsBattlePiki()) {
SET_FLAG(mFlags, 2);
setFlag(BATTLEFLAG_InBattle);
} else {
RESET_FLAG(mFlags, 2);
resetFlag(BATTLEFLAG_InBattle);
}
initApproach();
mHitCount = 0;
Vector3f midPoint = (mParent->getPosition() + mOther->getPosition());
midPoint *= 0.5f;
Sys::Sphere itSphere(midPoint, 10.0f);
Game::CellIteratorArg citArg(itSphere);
citArg.mIsSphereCollisionDisabled = false;
Sys::Sphere searchSphere(midPoint, 10.0f);
Game::CellIteratorArg iterArg(searchSphere);
iterArg.mIsSphereCollisionDisabled = false;
Game::CellIterator cellIt(citArg);
CI_LOOP(cellIt)
Game::CellIterator iter(iterArg);
CI_LOOP(iter)
{
Game::Piki* c = static_cast<Game::Piki*>(*cellIt);
if (!c->isPiki() || c->getVsBattlePiki()) {
Game::Piki* piki = static_cast<Game::Piki*>(*iter);
if (!piki->isPiki() || piki->getVsBattlePiki()) {
continue;
}
// TODO: WTF?
Vector3f diff = c->getPosition() - itSphere.mPosition;
diff.y = 0.0f;
diff.normalise();
diff *= 50.0f;
diff.y = 100.0f;
Game::InteractWind wind(mParent, 0.0f, &diff);
c->stimulate(wind);
Vector3f pushDir = piki->getPosition();
pushDir = pushDir - searchSphere.mPosition;
pushDir.y = 0.0f;
pushDir.normalise();
pushDir *= 50.0f;
pushDir.y = 100.0f;
Game::InteractWind wind(mParent, 0.0f, &pushDir);
piki->stimulate(wind);
}
}
@ -105,28 +148,30 @@ void ActBattle::init(PikiAI::ActionArg* arg)
int ActBattle::exec()
{
if (!mOther || !mOther->isAlive() || mOther != mParent->getVsBattlePiki() || mParent != mOther->getVsBattlePiki()) {
return 0;
return ACTEXEC_Success;
}
if (!(mFlags & 2)) {
return 2;
if (!isFlag(BATTLEFLAG_InBattle)) {
return ACTEXEC_Fail;
}
PSMGetPikiBattleD()->mVoteState++;
switch (mState) {
case PIKIAI_ACTBATTLE_APPROACH:
case BATTLE_Approach:
execApproach();
break;
case PIKIAI_ACTBATTLE_BATTLE:
case BATTLE_Battle:
execBattle();
break;
case PIKIAI_ACTBATTLE_DAMAGE:
case BATTLE_Damage:
execDamage();
break;
}
return 1;
return ACTEXEC_Continue;
}
/**
@ -147,408 +192,75 @@ void ActBattle::collisionCallback(Game::Piki*, Game::CollEvent&) { }
*/
void ActBattle::onKeyEvent(SysShape::KeyEvent const& event)
{
if (mState == PIKIAI_ACTBATTLE_BATTLE) {
if (mState == BATTLE_Battle) {
switch (event.mType) {
case KEYEVENT_2: {
PikiAI::ActBattle* battle;
if (mOther && mOther->getCurrActionID() == PikiAI::ACT_Battle) {
battle = static_cast<ActBattle*>(mOther->getCurrAction());
} else {
battle = nullptr;
}
if (battle) {
if (battle->mState != PIKIAI_ACTBATTLE_DAMAGE) {
if (randFloat() > 0.5f) {
if (battle->mOther && randFloat() > 0.9f) {
battle->initApproach();
Game::InteractFlick flick(battle->mOther, 60.0f, 0.0f, FLICK_BACKWARD_ANGLE);
battle->mParent->stimulate(flick);
} else {
battle->initApproach();
}
}
}
}
BattleMessage msg;
msg.mBattle = static_cast<ActBattle*>(getTekiAction());
recv(msg);
if (mParent->doped()) {
efx::TPkAttackDP dp;
efx::Arg arg;
arg.mPosition = mParent->mLeafStemOffset;
dp.create(&arg);
Vector3f offset = mParent->mLeafStemOffset;
efx::Arg fxArg;
fxArg.mPosition = offset;
dp.create(&fxArg);
} else {
efx::PikiDamage pd;
efx::Arg arg;
arg.mPosition = Vector3f(mParent->mLeafStemOffset);
pd.create(&arg);
Vector3f offset = mParent->mLeafStemOffset;
efx::Arg fxArg;
fxArg.mPosition = offset;
pd.create(&fxArg);
}
mParent->startSound(mOther, PSSE_PK_SE_ATTACKHIT, true);
} break;
case KEYEVENT_END: {
initApproach();
int rngChance = randInt(2);
u8 old = ++mHitCount;
if (old >= rngChance + 6) {
if (++mHitCount >= (int)(2.2f * randFloat()) + 6) { // hit cap is either 6, 7 or 8
if (mOther && mOther->getVsBattlePiki() == mParent) {
f32 oh = 0.5f * mOther->mHappaKind + 1.0f;
f32 ph = 0.5f * mParent->mHappaKind + 1.0f;
// this whole calculation ended up being unused, other piki dies either way
f32 otherHappa = 0.5f * mOther->getHappa() + 1.0f; // 1, 1.5, 2
f32 thisHappa = 0.5f * mParent->getHappa() + 1.0f; // 1, 1.5, 2
if (mOther->doped()) {
ph = 2.5f;
otherHappa = 2.5f;
}
if (mParent->doped()) {
oh = 2.5f;
thisHappa = 2.5f;
}
if (randFloat() <= ph / (ph + oh)) {
// both result in the same outcome - would've been ~29% for leaf to kill spicy, up to ~74% for spicy to kill leaf
if (randFloat() <= thisHappa / (thisHappa + otherHappa)) {
Game::DyingStateArg arg;
arg._04 = true;
mOther->mFsm->transit(mOther, Game::PIKISTATE_Dying, &arg);
} else {
Game::DyingStateArg arg;
arg._04 = true;
mOther->mFsm->transit(mOther, Game::PIKISTATE_Dying, &arg);
}
} else {
RESET_FLAG(mFlags, 2);
resetFlag(BATTLEFLAG_InBattle);
}
return;
}
} break;
}
} else if (mState == PIKIAI_ACTBATTLE_DAMAGE) {
initApproach();
return;
}
/*
.loc_0x0:
stwu r1, -0xB0(r1)
mflr r0
stw r0, 0xB4(r1)
stfd f31, 0xA0(r1)
psq_st f31,0xA8(r1),0,0
stfd f30, 0x90(r1)
psq_st f30,0x98(r1),0,0
stw r31, 0x8C(r1)
stw r30, 0x88(r1)
mr r31, r3
lbz r0, 0x14(r3)
cmplwi r0, 0x1
bne- .loc_0x450
lwz r0, 0x1C(r4)
cmpwi r0, 0x3E8
beq- .loc_0x2A4
bge- .loc_0x45C
cmpwi r0, 0x2
beq- .loc_0x50
b .loc_0x45C
.loc_0x50:
lwz r3, 0x10(r31)
cmplwi r3, 0
beq- .loc_0x78
bl -0xE73C0
cmpwi r3, 0xD
bne- .loc_0x78
lwz r3, 0x10(r31)
bl -0xE7404
mr r30, r3
b .loc_0x7C
.loc_0x78:
li r30, 0
.loc_0x7C:
cmplwi r30, 0
beq- .loc_0x168
lbz r0, 0x14(r30)
cmplwi r0, 0x2
beq- .loc_0x168
bl -0x165C9C
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x6C(r1)
lfd f3, -0x4020(r2)
stw r0, 0x68(r1)
lfs f1, -0x4038(r2)
lfd f2, 0x68(r1)
lfs f0, -0x4034(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fcmpo cr0, f1, f0
ble- .loc_0x168
lwz r0, 0x10(r30)
cmplwi r0, 0
beq- .loc_0x160
bl -0x165CDC
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x6C(r1)
lfd f3, -0x4020(r2)
stw r0, 0x68(r1)
lfs f1, -0x4038(r2)
lfd f2, 0x68(r1)
lfs f0, -0x4030(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fcmpo cr0, f1, f0
ble- .loc_0x160
mr r3, r30
bl .loc_0x484
lwz r5, 0x10(r30)
lis r3, 0x804B
subi r4, r3, 0x5D00
lfs f2, -0x402C(r2)
lfs f1, -0x4028(r2)
lis r3, 0x804B
lfs f0, -0x4024(r2)
addi r0, r3, 0x4E04
stw r4, 0x50(r1)
addi r4, r1, 0x50
stw r5, 0x54(r1)
stw r0, 0x50(r1)
stfs f2, 0x58(r1)
stfs f1, 0x5C(r1)
stfs f0, 0x60(r1)
lwz r3, 0x4(r30)
lwz r12, 0x0(r3)
lwz r12, 0x1A4(r12)
mtctr r12
bctrl
b .loc_0x168
.loc_0x160:
mr r3, r30
bl .loc_0x484
.loc_0x168:
lwz r3, 0x4(r31)
bl -0xE5338
rlwinm. r0,r3,0,24,31
beq- .loc_0x204
lis r3, 0x804B
lis r4, 0x804E
subi r0, r3, 0x5808
lis r3, 0x804B
stw r0, 0x44(r1)
addi r4, r4, 0x6A78
li r0, 0x149
li r7, 0
stw r4, 0x44(r1)
addi r6, r3, 0x4B9C
lis r3, 0x8051
lis r4, 0x804B
sth r0, 0x48(r1)
addi r5, r3, 0x41E4
lfs f2, 0x0(r5)
subi r0, r4, 0x5814
stw r7, 0x4C(r1)
addi r3, r1, 0x44
lfs f1, 0x4(r5)
addi r4, r1, 0x34
stw r6, 0x44(r1)
lfs f0, 0x8(r5)
lwz r5, 0x4(r31)
lfs f3, 0x25C(r5)
lfs f4, 0x260(r5)
lfs f5, 0x264(r5)
stfs f2, 0x38(r1)
stfs f1, 0x3C(r1)
stfs f0, 0x40(r1)
stw r0, 0x34(r1)
stfs f3, 0x38(r1)
stfs f4, 0x3C(r1)
stfs f5, 0x40(r1)
bl 0x17FBDC
b .loc_0x28C
.loc_0x204:
lis r3, 0x804B
lis r4, 0x804E
subi r0, r3, 0x5808
lis r3, 0x804B
stw r0, 0x28(r1)
addi r4, r4, 0x6A78
li r0, 0x148
li r7, 0
stw r4, 0x28(r1)
addi r6, r3, 0x4B88
lis r3, 0x8051
lis r4, 0x804B
sth r0, 0x2C(r1)
addi r5, r3, 0x41E4
lfs f2, 0x0(r5)
subi r0, r4, 0x5814
stw r7, 0x30(r1)
addi r3, r1, 0x28
lfs f1, 0x4(r5)
addi r4, r1, 0x18
stw r6, 0x28(r1)
lfs f0, 0x8(r5)
lwz r5, 0x4(r31)
lfs f3, 0x25C(r5)
lfs f4, 0x260(r5)
lfs f5, 0x264(r5)
stfs f2, 0x1C(r1)
stfs f1, 0x20(r1)
stfs f0, 0x24(r1)
stw r0, 0x18(r1)
stfs f3, 0x1C(r1)
stfs f4, 0x20(r1)
stfs f5, 0x24(r1)
bl 0x17FB50
.loc_0x28C:
lwz r3, 0x4(r31)
li r5, 0x2808
lwz r4, 0x10(r31)
li r6, 0x1
bl -0xE6AF4
b .loc_0x45C
.loc_0x2A4:
bl .loc_0x484
bl -0x165EB4
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x6C(r1)
lbz r3, 0x1D(r31)
stw r0, 0x68(r1)
lfd f2, -0x4020(r2)
addi r0, r3, 0x1
lfd f0, 0x68(r1)
rlwinm r4,r0,0,24,31
lfs f1, -0x4038(r2)
fsubs f2, f0, f2
lfs f0, -0x4008(r2)
stb r0, 0x1D(r31)
fdivs f1, f2, f1
fmuls f0, f0, f1
fctiwz f0, f0
stfd f0, 0x70(r1)
lwz r3, 0x74(r1)
addi r0, r3, 0x6
cmpw r4, r0
blt- .loc_0x45C
lwz r3, 0x10(r31)
cmplwi r3, 0
beq- .loc_0x440
bl -0xE69D4
lwz r5, 0x4(r31)
cmplw r3, r5
bne- .loc_0x440
lwz r3, 0x10(r31)
lis r4, 0x4330
lbz r0, 0x2B9(r5)
lbz r5, 0x2B9(r3)
xoris r0, r0, 0x8000
stw r4, 0x70(r1)
xoris r5, r5, 0x8000
lfd f3, -0x4020(r2)
stw r5, 0x74(r1)
lfs f4, -0x4034(r2)
lfd f0, 0x70(r1)
stw r0, 0x6C(r1)
fsubs f2, f0, f3
lfs f1, -0x4014(r2)
stw r4, 0x68(r1)
lfd f0, 0x68(r1)
fmadds f31, f4, f2, f1
fsubs f0, f0, f3
fmadds f30, f4, f0, f1
bl -0xE5534
rlwinm. r0,r3,0,24,31
beq- .loc_0x378
lfs f31, -0x4004(r2)
.loc_0x378:
lwz r3, 0x4(r31)
bl -0xE5548
rlwinm. r0,r3,0,24,31
beq- .loc_0x38C
lfs f30, -0x4004(r2)
.loc_0x38C:
bl -0x165F98
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x7C(r1)
fadds f0, f30, f31
lfd f3, -0x4020(r2)
stw r0, 0x78(r1)
lfs f1, -0x4038(r2)
fdivs f0, f30, f0
lfd f2, 0x78(r1)
fsubs f2, f2, f3
fdivs f1, f2, f1
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x404
li r0, 0
li r3, -0x1
stb r0, 0x14(r1)
li r0, 0x1
addi r6, r1, 0x10
li r5, 0x18
stw r3, 0x10(r1)
stb r0, 0x14(r1)
lwz r4, 0x10(r31)
lwz r3, 0x28C(r4)
lwz r12, 0x0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
b .loc_0x45C
.loc_0x404:
li r0, 0
li r3, -0x1
stb r0, 0xC(r1)
li r0, 0x1
addi r6, r1, 0x8
li r5, 0x18
stw r3, 0x8(r1)
stb r0, 0xC(r1)
lwz r4, 0x10(r31)
lwz r3, 0x28C(r4)
lwz r12, 0x0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
b .loc_0x45C
.loc_0x440:
lbz r0, 0x1C(r31)
rlwinm r0,r0,0,31,29
stb r0, 0x1C(r31)
b .loc_0x45C
.loc_0x450:
cmplwi r0, 0x2
bne- .loc_0x45C
bl .loc_0x484
.loc_0x45C:
psq_l f31,0xA8(r1),0,0
lfd f31, 0xA0(r1)
psq_l f30,0x98(r1),0,0
lfd f30, 0x90(r1)
lwz r31, 0x8C(r1)
lwz r0, 0xB4(r1)
lwz r30, 0x88(r1)
mtlr r0
addi r1, r1, 0xB0
blr
.loc_0x484:
*/
if (mState == BATTLE_Damage) {
initApproach();
}
}
/**
* @note Address: 0x8022F630
* @note Size: 0xBC
* TODO: WTF is going on in approach arg?
*/
void ActBattle::initApproach()
{
@ -559,7 +271,7 @@ void ActBattle::initApproach()
PikiAI::ApproachPosActionArg arg(pos, 10.0f, -1.0f);
arg.mIsElasticSpeed = true;
mApproachPos->init(&arg);
mState = PIKIAI_ACTBATTLE_APPROACH;
mState = BATTLE_Approach;
}
}
@ -569,11 +281,11 @@ void ActBattle::initApproach()
*/
int ActBattle::execApproach()
{
if (!mApproachPos->exec()) {
if (mApproachPos->exec() == ACTEXEC_Success) {
initBattle();
}
return 1;
return ACTEXEC_Continue;
}
/**
@ -582,12 +294,12 @@ int ActBattle::execApproach()
*/
void ActBattle::initBattle()
{
mState = PIKIAI_ACTBATTLE_BATTLE;
mState = BATTLE_Battle;
if (randFloat() > 0.5f) {
mParent->startMotion(64, 64, this, nullptr);
mParent->startMotion(Game::IPikiAnims::PUNCH, Game::IPikiAnims::PUNCH, this, nullptr);
} else {
mParent->startMotion(65, 65, this, nullptr);
mParent->startMotion(Game::IPikiAnims::PUNCH2, Game::IPikiAnims::PUNCH2, this, nullptr);
}
}
@ -597,22 +309,13 @@ void ActBattle::initBattle()
*/
int ActBattle::execBattle()
{
if (!mParent->assertMotion(64) && !mParent->assertMotion(Game::IPikiAnims::PUNCH2)) {
if (mOther) {
Vector3f pos = mOther->getPosition();
// no time limit
PikiAI::ApproachPosActionArg arg(pos, 10.0f, -1.0f);
arg.mIsElasticSpeed = true;
mApproachPos->init(&arg);
mState = PIKIAI_ACTBATTLE_APPROACH;
}
if (!mParent->assertMotion(Game::IPikiAnims::PUNCH) && !mParent->assertMotion(Game::IPikiAnims::PUNCH2)) {
initApproach();
}
Game::Piki* parent = mParent;
parent->mVelocity = Vector3f(0.0f, 0.0f, 0.0f);
mParent->mVelocity = Vector3f(0.0f);
return 1;
return ACTEXEC_Continue;
}
/**
@ -621,21 +324,12 @@ int ActBattle::execBattle()
*/
int ActBattle::execDamage()
{
if (!mParent->assertMotion(4)) {
if (mOther) {
Vector3f pos = mOther->getPosition();
// no time limit
PikiAI::ApproachPosActionArg arg(pos, 10.0f, -1.0f);
arg.mIsElasticSpeed = true;
mApproachPos->init(&arg);
mState = PIKIAI_ACTBATTLE_APPROACH;
}
if (!mParent->assertMotion(Game::IPikiAnims::DAMAGE)) {
initApproach();
}
Game::Piki* parent = mParent;
parent->mVelocity = Vector3f(0.0f, 0.0f, 0.0f);
mParent->mVelocity = Vector3f(0.0f);
return 1;
return ACTEXEC_Continue;
}
} // namespace PikiAI

View File

@ -835,3 +835,5 @@ You have 3744 out of 10000 Pokos and 94 out of 201 treasures.",2023-12-23 18:07:
You have 3751 out of 10000 Pokos and 94 out of 201 treasures.",2023-12-26 09:24:38.357159
3755,1747172,0.3755459604088427,94,336283,0.4717404356560091,"
You have 3755 out of 10000 Pokos and 94 out of 201 treasures.",2023-12-26 12:52:32.588287
3762,1750572,0.3762767735545376,94,336501,0.4720462477695355,"
You have 3762 out of 10000 Pokos and 94 out of 201 treasures.",2023-12-28 20:21:48.046528

1 code_count_in_pokos code_completion_in_bytes code_completion_in_percentage data_count_in_treasures data_completion_in_bytes data_completion_in_percentage sentence created_at
835
836
837
838
839