mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 11:14:15 +01:00
allow ai vs ai battles
This commit is contained in:
parent
fc66a8c476
commit
8d5ba6c6d1
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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:
|
||||
|
@ -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,13 +224,19 @@ static void InitSinglePlayerBtlControllers(void)
|
||||
{
|
||||
gBattleMainFunc = BeginBattleIntro;
|
||||
|
||||
gBattlerControllerFuncs[0] = SetControllerToPlayer;
|
||||
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;
|
||||
|
||||
gBattlerControllerFuncs[2] = SetControllerToPlayer;
|
||||
if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
|
||||
gBattlerControllerFuncs[2] = SetControllerToPlayerPartner;
|
||||
else
|
||||
gBattlerControllerFuncs[2] = SetControllerToPlayer;
|
||||
gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT;
|
||||
|
||||
gBattlerControllerFuncs[3] = SetControllerToOpponent;
|
||||
|
@ -565,8 +565,8 @@ static void CB2_InitBattleInternal(void)
|
||||
gBattle_BG3_X = 0;
|
||||
gBattle_BG3_Y = 0;
|
||||
|
||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||
|
||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||
|
||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||
#else
|
||||
if (!gIsDebugBattle)
|
||||
@ -594,7 +594,7 @@ static void CB2_InitBattleInternal(void)
|
||||
else
|
||||
SetMainCallback2(CB2_HandleStartBattle);
|
||||
|
||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
|
||||
{
|
||||
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
|
||||
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user