mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Merge remote-tracking branch 'upstream/upcoming' into overworldsnow
This commit is contained in:
commit
9fcb1a8687
6
Makefile
6
Makefile
@ -42,6 +42,7 @@ MAKER_CODE := 01
|
||||
REVISION := 0
|
||||
MODERN ?= 0
|
||||
TEST ?= 0
|
||||
ANALYZE ?= 0
|
||||
|
||||
ifeq (modern,$(MAKECMDGOALS))
|
||||
MODERN := 1
|
||||
@ -118,7 +119,10 @@ LIBPATH := -L ../../tools/agbcc/lib
|
||||
LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
|
||||
else
|
||||
CC1 = $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -std=gnu17 -fanalyzer
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -std=gnu17
|
||||
ifeq ($(ANALYZE),1)
|
||||
override CFLAGS += -fanalyzer
|
||||
endif
|
||||
ROM := $(MODERN_ROM_NAME)
|
||||
OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
|
||||
LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))"
|
||||
|
@ -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
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
bool32 AI_RandLessThan(u8 val);
|
||||
void RecordLastUsedMoveByTarget(void);
|
||||
bool32 IsAiVsAiBattle(void);
|
||||
bool32 BattlerHasAi(u32 battlerId);
|
||||
bool32 IsAiBattlerAware(u32 battlerId);
|
||||
void ClearBattlerMoveHistory(u8 battlerId);
|
||||
|
@ -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.
|
||||
|
@ -1030,6 +1030,9 @@ static bool8 ShouldUseItem(void)
|
||||
u8 validMons = 0;
|
||||
bool8 shouldUse = FALSE;
|
||||
|
||||
if (IsAiVsAiBattle())
|
||||
return FALSE;
|
||||
|
||||
// If teaming up with player and Pokemon is on the right, or Pokemon is currently held by Sky Drop
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT)
|
||||
|| gStatuses3[gActiveBattler] & STATUS3_SKY_DROPPED)
|
||||
|
@ -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"
|
||||
@ -440,17 +441,27 @@ void RecordLastUsedMoveByTarget(void)
|
||||
RecordKnownMove(gBattlerTarget, gLastMoves[gBattlerTarget]);
|
||||
}
|
||||
|
||||
bool32 IsAiVsAiBattle(void)
|
||||
{
|
||||
return (B_FLAG_AI_VS_AI_BATTLE && FlagGet(B_FLAG_AI_VS_AI_BATTLE));
|
||||
}
|
||||
|
||||
bool32 BattlerHasAi(u32 battlerId)
|
||||
{
|
||||
switch (GetBattlerPosition(battlerId))
|
||||
{
|
||||
case B_POSITION_PLAYER_LEFT:
|
||||
if (IsAiVsAiBattle())
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
case B_POSITION_OPPONENT_LEFT:
|
||||
return TRUE;
|
||||
case B_POSITION_PLAYER_RIGHT:
|
||||
return ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) != 0);
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || IsAiVsAiBattle())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
case B_POSITION_OPPONENT_RIGHT:
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -307,6 +307,12 @@ static void PlayerPartnerHandleDrawTrainerPic(u32 battler)
|
||||
xPos = 90;
|
||||
yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80;
|
||||
}
|
||||
else if (IsAiVsAiBattle())
|
||||
{
|
||||
trainerPicId = gTrainers[gPartnerTrainerId].trainerPic;
|
||||
xPos = 60;
|
||||
yPos = (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 80;
|
||||
}
|
||||
else
|
||||
{
|
||||
trainerPicId = GetFrontierTrainerFrontSpriteId(gPartnerTrainerId);
|
||||
@ -434,6 +440,8 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(u32 battler)
|
||||
trainerPal = gTrainerBackPicPaletteTable[TRAINER_STEVEN_PARTNER].data;
|
||||
else if (gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER) // Custom multi battle.
|
||||
trainerPal = gTrainerBackPicPaletteTable[gPartnerSpriteId].data;
|
||||
else if (IsAiVsAiBattle())
|
||||
trainerPal = gTrainerFrontPicPaletteTable[gTrainers[gPartnerTrainerId].trainerPic].data;
|
||||
else
|
||||
trainerPal = gTrainerFrontPicPaletteTable[GetFrontierTrainerFrontSpriteId(gPartnerTrainerId)].data; // 2 vs 2 multi battle in Battle Frontier, load front sprite and pal.
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "battle.h"
|
||||
#include "battle_ai_main.h"
|
||||
#include "battle_arena.h"
|
||||
#include "battle_ai_util.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_arena.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "battle_gfx_sfx_util.h"
|
||||
#include "battle_interface.h"
|
||||
@ -185,6 +186,8 @@ static void InitSinglePlayerBtlControllers(void)
|
||||
gBattlerControllerFuncs[0] = SetControllerToSafari;
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
|
||||
gBattlerControllerFuncs[0] = SetControllerToWally;
|
||||
else if (IsAiVsAiBattle())
|
||||
gBattlerControllerFuncs[0] = SetControllerToPlayerPartner;
|
||||
else
|
||||
gBattlerControllerFuncs[0] = SetControllerToPlayer;
|
||||
|
||||
@ -236,13 +239,19 @@ static void InitSinglePlayerBtlControllers(void)
|
||||
{
|
||||
gBattleMainFunc = BeginBattleIntro;
|
||||
|
||||
gBattlerControllerFuncs[0] = SetControllerToPlayer;
|
||||
if (IsAiVsAiBattle())
|
||||
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 (IsAiVsAiBattle())
|
||||
gBattlerControllerFuncs[2] = SetControllerToPlayerPartner;
|
||||
else
|
||||
gBattlerControllerFuncs[2] = SetControllerToPlayer;
|
||||
gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT;
|
||||
|
||||
gBattlerControllerFuncs[3] = SetControllerToOpponent;
|
||||
|
@ -565,13 +565,12 @@ static void CB2_InitBattleInternal(void)
|
||||
gBattle_BG3_X = 0;
|
||||
gBattle_BG3_Y = 0;
|
||||
|
||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||
|
||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||
#else
|
||||
#if DEBUG_OVERWORLD_MENU == TRUE
|
||||
if (!gIsDebugBattle)
|
||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||
#endif
|
||||
{
|
||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||
}
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
|
||||
gBattleTerrain = BATTLE_TERRAIN_BUILDING;
|
||||
|
||||
@ -594,27 +593,19 @@ static void CB2_InitBattleInternal(void)
|
||||
else
|
||||
SetMainCallback2(CB2_HandleStartBattle);
|
||||
|
||||
#if DEBUG_OVERWORLD_MENU == FALSE
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
|
||||
{
|
||||
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && !BATTLE_TWO_VS_ONE_OPPONENT)
|
||||
CreateNPCTrainerParty(&gEnemyParty[PARTY_SIZE / 2], gTrainerBattleOpponent_B, FALSE);
|
||||
SetWildMonHeldItem();
|
||||
CalculateEnemyPartyCount();
|
||||
}
|
||||
#else
|
||||
#if DEBUG_OVERWORLD_MENU == TRUE
|
||||
if (!gIsDebugBattle)
|
||||
#endif
|
||||
{
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
|
||||
{
|
||||
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && !BATTLE_TWO_VS_ONE_OPPONENT)
|
||||
CreateNPCTrainerParty(&gEnemyParty[PARTY_SIZE / 2], gTrainerBattleOpponent_B, FALSE);
|
||||
SetWildMonHeldItem();
|
||||
CalculateEnemyPartyCount();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gMain.inBattle = TRUE;
|
||||
gSaveBlock2Ptr->frontier.disableRecordBattle = FALSE;
|
||||
@ -2071,6 +2062,13 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void CreateTrainerPartyForPlayer(void)
|
||||
{
|
||||
ZeroPlayerPartyMons();
|
||||
gPartnerTrainerId = gSpecialVar_0x8004;
|
||||
CreateNPCTrainerPartyFromTrainer(gPlayerParty, &gTrainers[gSpecialVar_0x8004], TRUE, BATTLE_TYPE_TRAINER);
|
||||
}
|
||||
|
||||
void VBlankCB_Battle(void)
|
||||
{
|
||||
// Change gRngSeed every vblank unless the battle could be recorded.
|
||||
|
@ -4068,7 +4068,9 @@ static void Cmd_getexp(void)
|
||||
switch (gBattleScripting.getexpState)
|
||||
{
|
||||
case 0: // check if should receive exp at all
|
||||
if (GetBattlerSide(gBattlerFainted) != B_SIDE_OPPONENT || (gBattleTypeFlags &
|
||||
if (GetBattlerSide(gBattlerFainted) != B_SIDE_OPPONENT
|
||||
|| IsAiVsAiBattle()
|
||||
|| (gBattleTypeFlags &
|
||||
(BATTLE_TYPE_LINK
|
||||
| BATTLE_TYPE_RECORDED_LINK
|
||||
| BATTLE_TYPE_TRAINER_HILL
|
||||
|
@ -7985,7 +7985,7 @@ u8 IsMonDisobedient(void)
|
||||
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
|
||||
return 0;
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)
|
||||
if (BattlerHasAi(gBattlerAttacker))
|
||||
return 0;
|
||||
|
||||
if (IsBattlerModernFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys
|
||||
|
Loading…
Reference in New Issue
Block a user