allow ai vs ai battles

This commit is contained in:
DizzyEggg 2023-08-09 09:15:42 +02:00
parent fc66a8c476
commit 8d5ba6c6d1
5 changed files with 31 additions and 5 deletions

View File

@ -2018,3 +2018,10 @@
setvar VAR_0x8002, \tryMultiple
special TrySpecialOverworldEvo
.endm
.macro ai_vs_ai_battle trainer1:req, trainer2:req
setflag B_FLAG_AI_VS_AI_BATTLE
setvar VAR_0x8004, trainer1
callnative CreateTrainerPartyForPlayer
trainerbattle_no_intro trainer2, NULL
.endm

View File

@ -156,6 +156,7 @@
#define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon
#define B_FLAG_NO_BAG_USE 0 // If this flag is set, the ability to use the bag in battle is disabled.
#define B_FLAG_NO_CATCHING 0 // If this flag is set, the ability to catch wild Pokémon is disabled.
#define B_FLAG_AI_VS_AI_BATTLE 0 // If this flag is set, the player's mons will be controlled by the ai next battles.
// Var Settings
// To use the following features in scripting, replace the 0s with the var ID you're assigning it to.

View File

@ -8,6 +8,7 @@
#include "battle_ai_switch_items.h"
#include "battle_factory.h"
#include "battle_setup.h"
#include "event_data.h"
#include "data.h"
#include "item.h"
#include "pokemon.h"
@ -445,6 +446,8 @@ bool32 BattlerHasAi(u32 battlerId)
switch (GetBattlerPosition(battlerId))
{
case B_POSITION_PLAYER_LEFT:
if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
return TRUE;
default:
return FALSE;
case B_POSITION_OPPONENT_LEFT:

View File

@ -6,6 +6,7 @@
#include "battle_message.h"
#include "battle_setup.h"
#include "cable_club.h"
#include "event_data.h"
#include "link.h"
#include "link_rfu.h"
#include "party_menu.h"
@ -170,6 +171,8 @@ static void InitSinglePlayerBtlControllers(void)
gBattlerControllerFuncs[0] = SetControllerToSafari;
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
gBattlerControllerFuncs[0] = SetControllerToWally;
else if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
gBattlerControllerFuncs[0] = SetControllerToPlayerPartner;
else
gBattlerControllerFuncs[0] = SetControllerToPlayer;
@ -221,12 +224,18 @@ static void InitSinglePlayerBtlControllers(void)
{
gBattleMainFunc = BeginBattleIntro;
if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
gBattlerControllerFuncs[0] = SetControllerToPlayerPartner;
else
gBattlerControllerFuncs[0] = SetControllerToPlayer;
gBattlerPositions[0] = B_POSITION_PLAYER_LEFT;
gBattlerControllerFuncs[1] = SetControllerToOpponent;
gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT;
if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
gBattlerControllerFuncs[2] = SetControllerToPlayerPartner;
else
gBattlerControllerFuncs[2] = SetControllerToPlayer;
gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT;

View File

@ -2145,6 +2145,12 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
return retVal;
}
void CreateTrainerPartyForPlayer(void)
{
ZeroPlayerPartyMons();
CreateNPCTrainerPartyFromTrainer(gPlayerParty, &gTrainers[gSpecialVar_0x8004], TRUE, 0);
}
void VBlankCB_Battle(void)
{
// Change gRngSeed every vblank unless the battle could be recorded.