mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Begin wild double battles
This commit is contained in:
parent
b3ad32bbe6
commit
ef11706dc7
@ -37,6 +37,7 @@ extern u16 gTrainerBattleOpponent_B;
|
|||||||
extern u16 gPartnerTrainerId;
|
extern u16 gPartnerTrainerId;
|
||||||
|
|
||||||
void BattleSetup_StartWildBattle(void);
|
void BattleSetup_StartWildBattle(void);
|
||||||
|
void BattleSetup_StartDoubleWildBattle(void);
|
||||||
void BattleSetup_StartBattlePikeWildBattle(void);
|
void BattleSetup_StartBattlePikeWildBattle(void);
|
||||||
void BattleSetup_StartRoamerBattle(void);
|
void BattleSetup_StartRoamerBattle(void);
|
||||||
void StartWallyTutorialBattle(void);
|
void StartWallyTutorialBattle(void);
|
||||||
|
@ -10489,6 +10489,8 @@ static void atkEF_handleballthrow(void)
|
|||||||
|
|
||||||
gActiveBattler = gBattlerAttacker;
|
gActiveBattler = gBattlerAttacker;
|
||||||
gBattlerTarget = gBattlerAttacker ^ BIT_SIDE;
|
gBattlerTarget = gBattlerAttacker ^ BIT_SIDE;
|
||||||
|
if (!IsBattlerAlive(gBattlerTarget))
|
||||||
|
gBattlerTarget ^= BIT_FLANK;
|
||||||
|
|
||||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||||
{
|
{
|
||||||
@ -10630,18 +10632,18 @@ static void atkEF_handleballthrow(void)
|
|||||||
|
|
||||||
static void atkF0_givecaughtmon(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())
|
if (!sub_813B21C())
|
||||||
{
|
{
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
||||||
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN)));
|
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
|
else
|
||||||
{
|
{
|
||||||
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN)));
|
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()));
|
StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id()));
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
||||||
}
|
}
|
||||||
@ -10650,17 +10652,17 @@ static void atkF0_givecaughtmon(void)
|
|||||||
gBattleCommunication[MULTISTRING_CHOOSER]++;
|
gBattleCommunication[MULTISTRING_CHOOSER]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL);
|
gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL);
|
||||||
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick);
|
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick);
|
||||||
gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL);
|
gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, NULL);
|
||||||
|
|
||||||
gBattlescriptCurrInstr++;
|
gBattlescriptCurrInstr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void atkF1_trysetcaughtmondexflags(void)
|
static void atkF1_trysetcaughtmondexflags(void)
|
||||||
{
|
{
|
||||||
u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL);
|
u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL);
|
||||||
u32 personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL);
|
u32 personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_PERSONALITY, NULL);
|
||||||
|
|
||||||
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT))
|
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT))
|
||||||
{
|
{
|
||||||
@ -10675,7 +10677,7 @@ static void atkF1_trysetcaughtmondexflags(void)
|
|||||||
|
|
||||||
static void atkF2_displaydexinfo(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])
|
switch (gBattleCommunication[0])
|
||||||
{
|
{
|
||||||
@ -10840,13 +10842,13 @@ static void atkF3_trygivecaughtmonnick(void)
|
|||||||
case 2:
|
case 2:
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick);
|
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick);
|
||||||
FreeAllWindowBuffers();
|
FreeAllWindowBuffers();
|
||||||
|
|
||||||
DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gBattleStruct->caughtMonNick,
|
DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gBattleStruct->caughtMonNick,
|
||||||
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_SPECIES),
|
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES),
|
||||||
GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]),
|
GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]),
|
||||||
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_PERSONALITY, NULL),
|
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_PERSONALITY, NULL),
|
||||||
BattleMainCB2);
|
BattleMainCB2);
|
||||||
|
|
||||||
gBattleCommunication[MULTIUSE_STATE]++;
|
gBattleCommunication[MULTIUSE_STATE]++;
|
||||||
@ -10855,7 +10857,7 @@ static void atkF3_trygivecaughtmonnick(void)
|
|||||||
case 3:
|
case 3:
|
||||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active )
|
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);
|
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -80,7 +80,7 @@ extern void CopyTrainerHillTrainerText(u8 a0, u16 arg1);
|
|||||||
// this file's functions
|
// this file's functions
|
||||||
static void DoBattlePikeWildBattle(void);
|
static void DoBattlePikeWildBattle(void);
|
||||||
static void DoSafariBattle(void);
|
static void DoSafariBattle(void);
|
||||||
static void DoStandardWildBattle(void);
|
static void DoStandardWildBattle(bool32 isDouble);
|
||||||
static void CB2_EndWildBattle(void);
|
static void CB2_EndWildBattle(void);
|
||||||
static void CB2_EndScriptedWildBattle(void);
|
static void CB2_EndScriptedWildBattle(void);
|
||||||
static u8 GetWildBattleTransition(void);
|
static u8 GetWildBattleTransition(void);
|
||||||
@ -378,7 +378,12 @@ void BattleSetup_StartWildBattle(void)
|
|||||||
if (GetSafariZoneFlag())
|
if (GetSafariZoneFlag())
|
||||||
DoSafariBattle();
|
DoSafariBattle();
|
||||||
else
|
else
|
||||||
DoStandardWildBattle();
|
DoStandardWildBattle(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BattleSetup_StartDoubleWildBattle(void)
|
||||||
|
{
|
||||||
|
DoStandardWildBattle(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleSetup_StartBattlePikeWildBattle(void)
|
void BattleSetup_StartBattlePikeWildBattle(void)
|
||||||
@ -386,13 +391,15 @@ void BattleSetup_StartBattlePikeWildBattle(void)
|
|||||||
DoBattlePikeWildBattle();
|
DoBattlePikeWildBattle();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoStandardWildBattle(void)
|
static void DoStandardWildBattle(bool32 isDouble)
|
||||||
{
|
{
|
||||||
ScriptContext2_Enable();
|
ScriptContext2_Enable();
|
||||||
FreezeEventObjects();
|
FreezeEventObjects();
|
||||||
sub_808BCF4();
|
sub_808BCF4();
|
||||||
gMain.savedCallback = CB2_EndWildBattle;
|
gMain.savedCallback = CB2_EndWildBattle;
|
||||||
gBattleTypeFlags = 0;
|
gBattleTypeFlags = 0;
|
||||||
|
if (isDouble)
|
||||||
|
gBattleTypeFlags |= BATTLE_TYPE_DOUBLE;
|
||||||
if (InBattlePyramid())
|
if (InBattlePyramid())
|
||||||
{
|
{
|
||||||
VarSet(VAR_TEMP_E, 0);
|
VarSet(VAR_TEMP_E, 0);
|
||||||
|
@ -931,7 +931,17 @@ void ItemUseOutOfBattle_EvolutionStone(u8 taskId)
|
|||||||
|
|
||||||
void ItemUseInBattle_PokeBall(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);
|
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||||
if (!InBattlePyramid())
|
if (!InBattlePyramid())
|
||||||
@ -944,8 +954,10 @@ void ItemUseInBattle_PokeBall(u8 taskId)
|
|||||||
DisplayItemMessage(taskId, 1, gText_BoxFull, bag_menu_inits_lists_menu);
|
DisplayItemMessage(taskId, 1, gText_BoxFull, bag_menu_inits_lists_menu);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, sub_81C6714);
|
DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, sub_81C6714);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void sub_80FE408(u8 taskId)
|
void sub_80FE408(u8 taskId)
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "tv.h"
|
#include "tv.h"
|
||||||
#include "link.h"
|
#include "link.h"
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
#include "battle_debug.h"
|
||||||
#include "constants/items.h"
|
#include "constants/items.h"
|
||||||
#include "constants/maps.h"
|
#include "constants/maps.h"
|
||||||
|
|
||||||
@ -5145,8 +5146,18 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
|
|||||||
|
|
||||||
// try a regular wild land encounter
|
// try a regular wild land encounter
|
||||||
if (TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
|
if (TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
|
||||||
|
{
|
||||||
|
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();
|
BattleSetup_StartWildBattle();
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user