Begin wild double battles

This commit is contained in:
DizzyEggg 2018-10-14 22:37:07 +02:00
parent b3ad32bbe6
commit ef11706dc7
5 changed files with 52 additions and 19 deletions

View File

@ -37,6 +37,7 @@ extern u16 gTrainerBattleOpponent_B;
extern u16 gPartnerTrainerId;
void BattleSetup_StartWildBattle(void);
void BattleSetup_StartDoubleWildBattle(void);
void BattleSetup_StartBattlePikeWildBattle(void);
void BattleSetup_StartRoamerBattle(void);
void StartWallyTutorialBattle(void);

View File

@ -10489,6 +10489,8 @@ static void atkEF_handleballthrow(void)
gActiveBattler = gBattlerAttacker;
gBattlerTarget = gBattlerAttacker ^ BIT_SIDE;
if (!IsBattlerAlive(gBattlerTarget))
gBattlerTarget ^= BIT_FLANK;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
@ -10630,18 +10632,18 @@ static void atkEF_handleballthrow(void)
static void atkF0_givecaughtmon(void)
{
if (GiveMonToPlayer(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY)
if (GiveMonToPlayer(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]) != MON_GIVEN_TO_PARTY)
{
if (!sub_813B21C())
{
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN)));
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2);
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gStringVar2);
}
else
{
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN)));
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2);
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gStringVar2);
StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id()));
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
}
@ -10650,17 +10652,17 @@ static void atkF0_givecaughtmon(void)
gBattleCommunication[MULTISTRING_CHOOSER]++;
}
gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL);
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick);
gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL);
gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL);
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick);
gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, NULL);
gBattlescriptCurrInstr++;
}
static void atkF1_trysetcaughtmondexflags(void)
{
u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL);
u32 personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL);
u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL);
u32 personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_PERSONALITY, NULL);
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT))
{
@ -10675,7 +10677,7 @@ static void atkF1_trysetcaughtmondexflags(void)
static void atkF2_displaydexinfo(void)
{
u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL);
u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL);
switch (gBattleCommunication[0])
{
@ -10840,13 +10842,13 @@ static void atkF3_trygivecaughtmonnick(void)
case 2:
if (!gPaletteFade.active)
{
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick);
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick);
FreeAllWindowBuffers();
DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gBattleStruct->caughtMonNick,
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_SPECIES),
GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]),
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_PERSONALITY, NULL),
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES),
GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]),
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_PERSONALITY, NULL),
BattleMainCB2);
gBattleCommunication[MULTIUSE_STATE]++;
@ -10855,7 +10857,7 @@ static void atkF3_trygivecaughtmonnick(void)
case 3:
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active )
{
SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick);
SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick);
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
break;

View File

@ -80,7 +80,7 @@ extern void CopyTrainerHillTrainerText(u8 a0, u16 arg1);
// this file's functions
static void DoBattlePikeWildBattle(void);
static void DoSafariBattle(void);
static void DoStandardWildBattle(void);
static void DoStandardWildBattle(bool32 isDouble);
static void CB2_EndWildBattle(void);
static void CB2_EndScriptedWildBattle(void);
static u8 GetWildBattleTransition(void);
@ -378,7 +378,12 @@ void BattleSetup_StartWildBattle(void)
if (GetSafariZoneFlag())
DoSafariBattle();
else
DoStandardWildBattle();
DoStandardWildBattle(FALSE);
}
void BattleSetup_StartDoubleWildBattle(void)
{
DoStandardWildBattle(TRUE);
}
void BattleSetup_StartBattlePikeWildBattle(void)
@ -386,13 +391,15 @@ void BattleSetup_StartBattlePikeWildBattle(void)
DoBattlePikeWildBattle();
}
static void DoStandardWildBattle(void)
static void DoStandardWildBattle(bool32 isDouble)
{
ScriptContext2_Enable();
FreezeEventObjects();
sub_808BCF4();
gMain.savedCallback = CB2_EndWildBattle;
gBattleTypeFlags = 0;
if (isDouble)
gBattleTypeFlags |= BATTLE_TYPE_DOUBLE;
if (InBattlePyramid())
{
VarSet(VAR_TEMP_E, 0);

View File

@ -931,7 +931,17 @@ void ItemUseOutOfBattle_EvolutionStone(u8 taskId)
void ItemUseInBattle_PokeBall(u8 taskId)
{
if (IsPlayerPartyAndPokemonStorageFull() == FALSE) // have room for mon?
if (IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
&& IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))) // There are two present pokemon.
{
u8 textCantThrowPokeBall[] = _("Cannot throw a ball!\nThere are two pokemon out there!\p");
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, textCantThrowPokeBall, bag_menu_inits_lists_menu);
else
DisplayItemMessageInBattlePyramid(taskId, textCantThrowPokeBall, sub_81C6714);
}
else if (IsPlayerPartyAndPokemonStorageFull() == FALSE) // have room for mon?
{
RemoveBagItem(gSpecialVar_ItemId, 1);
if (!InBattlePyramid())
@ -944,7 +954,9 @@ void ItemUseInBattle_PokeBall(u8 taskId)
DisplayItemMessage(taskId, 1, gText_BoxFull, bag_menu_inits_lists_menu);
}
else
{
DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, sub_81C6714);
}
}
void sub_80FE408(u8 taskId)

View File

@ -18,6 +18,7 @@
#include "tv.h"
#include "link.h"
#include "script.h"
#include "battle_debug.h"
#include "constants/items.h"
#include "constants/maps.h"
@ -5146,7 +5147,17 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
// try a regular wild land encounter
if (TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
{
BattleSetup_StartWildBattle();
if (USE_BATTLE_DEBUG && GetMonsStateToDoubles() == PLAYER_HAS_TWO_USABLE_MONS)
{
struct Pokemon mon1 = gEnemyParty[0];
TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE);
gEnemyParty[1] = mon1;
BattleSetup_StartDoubleWildBattle();
}
else
{
BattleSetup_StartWildBattle();
}
return TRUE;
}