mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34: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
|
setvar VAR_0x8002, \tryMultiple
|
||||||
special TrySpecialOverworldEvo
|
special TrySpecialOverworldEvo
|
||||||
.endm
|
.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_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_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_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
|
// Var Settings
|
||||||
// To use the following features in scripting, replace the 0s with the var ID you're assigning it to.
|
// 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_ai_switch_items.h"
|
||||||
#include "battle_factory.h"
|
#include "battle_factory.h"
|
||||||
#include "battle_setup.h"
|
#include "battle_setup.h"
|
||||||
|
#include "event_data.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "pokemon.h"
|
#include "pokemon.h"
|
||||||
@ -445,6 +446,8 @@ bool32 BattlerHasAi(u32 battlerId)
|
|||||||
switch (GetBattlerPosition(battlerId))
|
switch (GetBattlerPosition(battlerId))
|
||||||
{
|
{
|
||||||
case B_POSITION_PLAYER_LEFT:
|
case B_POSITION_PLAYER_LEFT:
|
||||||
|
if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
|
||||||
|
return TRUE;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case B_POSITION_OPPONENT_LEFT:
|
case B_POSITION_OPPONENT_LEFT:
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "battle_message.h"
|
#include "battle_message.h"
|
||||||
#include "battle_setup.h"
|
#include "battle_setup.h"
|
||||||
#include "cable_club.h"
|
#include "cable_club.h"
|
||||||
|
#include "event_data.h"
|
||||||
#include "link.h"
|
#include "link.h"
|
||||||
#include "link_rfu.h"
|
#include "link_rfu.h"
|
||||||
#include "party_menu.h"
|
#include "party_menu.h"
|
||||||
@ -170,6 +171,8 @@ static void InitSinglePlayerBtlControllers(void)
|
|||||||
gBattlerControllerFuncs[0] = SetControllerToSafari;
|
gBattlerControllerFuncs[0] = SetControllerToSafari;
|
||||||
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
|
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
|
||||||
gBattlerControllerFuncs[0] = SetControllerToWally;
|
gBattlerControllerFuncs[0] = SetControllerToWally;
|
||||||
|
else if (FlagGet(B_FLAG_AI_VS_AI_BATTLE))
|
||||||
|
gBattlerControllerFuncs[0] = SetControllerToPlayerPartner;
|
||||||
else
|
else
|
||||||
gBattlerControllerFuncs[0] = SetControllerToPlayer;
|
gBattlerControllerFuncs[0] = SetControllerToPlayer;
|
||||||
|
|
||||||
@ -221,13 +224,19 @@ static void InitSinglePlayerBtlControllers(void)
|
|||||||
{
|
{
|
||||||
gBattleMainFunc = BeginBattleIntro;
|
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;
|
gBattlerPositions[0] = B_POSITION_PLAYER_LEFT;
|
||||||
|
|
||||||
gBattlerControllerFuncs[1] = SetControllerToOpponent;
|
gBattlerControllerFuncs[1] = SetControllerToOpponent;
|
||||||
gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT;
|
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;
|
gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT;
|
||||||
|
|
||||||
gBattlerControllerFuncs[3] = SetControllerToOpponent;
|
gBattlerControllerFuncs[3] = SetControllerToOpponent;
|
||||||
|
@ -565,8 +565,8 @@ static void CB2_InitBattleInternal(void)
|
|||||||
gBattle_BG3_X = 0;
|
gBattle_BG3_X = 0;
|
||||||
gBattle_BG3_Y = 0;
|
gBattle_BG3_Y = 0;
|
||||||
|
|
||||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||||
|
|
||||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||||
#else
|
#else
|
||||||
if (!gIsDebugBattle)
|
if (!gIsDebugBattle)
|
||||||
@ -594,7 +594,7 @@ static void CB2_InitBattleInternal(void)
|
|||||||
else
|
else
|
||||||
SetMainCallback2(CB2_HandleStartBattle);
|
SetMainCallback2(CB2_HandleStartBattle);
|
||||||
|
|
||||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
|
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
|
||||||
{
|
{
|
||||||
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
|
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
|
||||||
@ -2145,6 +2145,12 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateTrainerPartyForPlayer(void)
|
||||||
|
{
|
||||||
|
ZeroPlayerPartyMons();
|
||||||
|
CreateNPCTrainerPartyFromTrainer(gPlayerParty, &gTrainers[gSpecialVar_0x8004], TRUE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void VBlankCB_Battle(void)
|
void VBlankCB_Battle(void)
|
||||||
{
|
{
|
||||||
// Change gRngSeed every vblank unless the battle could be recorded.
|
// Change gRngSeed every vblank unless the battle could be recorded.
|
||||||
|
Loading…
Reference in New Issue
Block a user