From 50754bede70a2dd8c356b75d784e68aa68d0c198 Mon Sep 17 00:00:00 2001 From: PSF Date: Sun, 23 Apr 2023 19:16:25 -0700 Subject: [PATCH 01/34] Original implementation from Phlayne --- data/specials.inc | 2 + include/battle_util.h | 4 ++ include/constants/flags.h | 2 +- include/constants/vars.h | 2 +- include/load_save.h | 1 + src/battle_script_commands.c | 2 +- src/battle_setup.c | 28 +++++++++++ src/battle_util.c | 95 ++++++++++++++++++++++++++++++++++++ src/field_specials.c | 40 +++++++++++++++ src/load_save.c | 14 ++++++ 10 files changed, 187 insertions(+), 3 deletions(-) diff --git a/data/specials.inc b/data/specials.inc index ded2e3f4fee7..85cdfbce0f15 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -536,3 +536,5 @@ gSpecials:: def_special TrySetBattleTowerLinkType def_special SetTotemBoost def_special TrySpecialOverworldEvo + def_special CanDoSkyBattle + def_special PrepareSkyBattle diff --git a/include/battle_util.h b/include/battle_util.h index 0661081e43b8..47bab86a28ba 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -235,4 +235,8 @@ u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc); bool32 IsMyceliumMightOnField(void); bool8 ChangeTypeBasedOnTerrain(u8 battlerId); +bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon); +bool8 IsMonBannedFromSkyBattles(u16 species); +bool8 IsMoveBannedFromSkyBattles(u16 move); + #endif // GUARD_BATTLE_UTIL_H diff --git a/include/constants/flags.h b/include/constants/flags.h index 59bde846c557..f17bc85fca70 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1217,7 +1217,7 @@ #define FLAG_ITEM_SAFARI_ZONE_NORTH_EAST_NUGGET 0x491 #define FLAG_ITEM_SAFARI_ZONE_SOUTH_EAST_BIG_PEARL 0x492 -#define FLAG_UNUSED_0x493 0x493 // Unused Flag +#define FLAG_IS_IN_SKY_BATTLE 0x493 #define FLAG_UNUSED_0x494 0x494 // Unused Flag #define FLAG_UNUSED_0x495 0x495 // Unused Flag #define FLAG_UNUSED_0x496 0x496 // Unused Flag diff --git a/include/constants/vars.h b/include/constants/vars.h index e0b08f4475b3..b9a0d968211b 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -263,7 +263,7 @@ #define VAR_ROXANNE_CALL_STEP_COUNTER 0x40F4 #define VAR_SCOTT_BF_CALL_STEP_COUNTER 0x40F5 #define VAR_RIVAL_RAYQUAZA_CALL_STEP_COUNTER 0x40F6 -#define VAR_UNUSED_0x40F7 0x40F7 // Unused Var +#define VAR_SKY_BATTLE_POKEMON_POSITIONS 0x40F7 #define VAR_UNUSED_0x40F8 0x40F8 // Unused Var #define VAR_UNUSED_0x40F9 0x40F9 // Unused Var #define VAR_UNUSED_0x40FA 0x40FA // Unused Var diff --git a/include/load_save.h b/include/load_save.h index 389bd5a2b925..1def5a79366c 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -46,6 +46,7 @@ void SetContinueGameWarpStatusToDynamicWarp(void); void ClearContinueGameWarpStatus2(void); void SavePlayerParty(void); void LoadPlayerParty(void); +void UpdatePlayerSavedPartyAfterSkyBattle(void); void SaveObjectEvents(void); void LoadObjectEvents(void); void CopyPartyAndObjectsToSave(void); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e1494ce3828..eb18406ea250 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1560,7 +1560,7 @@ static void Cmd_attackcanceler(void) } gHitMarker |= HITMARKER_OBEYS; - if (NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || ((FlagGet(FLAG_IS_IN_SKY_BATTLE) && IsMoveBannedFromSkyBattles(gCurrentMove))))) { gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; if (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) diff --git a/src/battle_setup.c b/src/battle_setup.c index 2b8e63e76683..6bb03af74810 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1,5 +1,6 @@ #include "global.h" #include "battle.h" +#include "load_save.h" #include "battle_setup.h" #include "battle_transition.h" #include "main.h" @@ -1351,10 +1352,37 @@ void BattleSetup_StartTrainerBattle(void) static void CB2_EndTrainerBattle(void) { + bool8 everyPokemonFainted; + u8 partyCount; + u8 i; + if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) { SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } + else if (FlagGet(FLAG_IS_IN_SKY_BATTLE)) + { + FlagClear(FLAG_IS_IN_SKY_BATTLE); + UpdatePlayerSavedPartyAfterSkyBattle(); // Only updates the pokemon that participated in the battle + LoadPlayerParty(); // Load the saved pokemons + if (IsPlayerDefeated(gBattleOutcome) == TRUE) { // Check if every pokemon is fainted; + everyPokemonFainted = TRUE; + partyCount = CalculatePlayerPartyCount(); + for (i = 0; i < partyCount; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) > 0) + { + everyPokemonFainted = FALSE; + break; + } + } + if (everyPokemonFainted) + SetMainCallback2(CB2_WhiteOut); + else + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); + } + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); + } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { if (InBattlePyramid() || InTrainerHillChallenge()) diff --git a/src/battle_util.c b/src/battle_util.c index ac274bf0f833..5e92f5918a1e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10858,3 +10858,98 @@ static void SetRandomMultiHitCounter() gMultiHitCounter = 5 - (Random() & 1); } } + +bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon){ + int i; + bool8 isFlyingType = FALSE; + bool8 isLevitating = GetMonData(pokemon, MON_DATA_ABILITY_NUM, NULL) == ABILITY_LEVITATE; + bool8 hasFlyMove = FALSE; + + if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG)) + { + u16 species = GetMonData(pokemon, MON_DATA_SPECIES); + isFlyingType = gSpeciesInfo[species].types[0] == TYPE_FLYING || gSpeciesInfo[species].types[1] == TYPE_FLYING; + if (isFlyingType) + { + gSpecialVar_Result = TRUE; + return; + } + } + return (isFlyingType || isLevitating) && !IsMonBannedFromSkyBattles(GetMonData(pokemon,MON_DATA_SPECIES_OR_EGG)); +} + +bool8 IsMonBannedFromSkyBattles(u16 species){ + switch (species){ + case SPECIES_EGG: + case SPECIES_SPEAROW: + case SPECIES_FARFETCHD: + case SPECIES_DODUO: + case SPECIES_DODRIO: + case SPECIES_HOOTHOOT: + case SPECIES_NATU: + case SPECIES_MURKROW: + case SPECIES_DELIBIRD: + case SPECIES_TAILLOW: + case SPECIES_STARLY: + case SPECIES_CHATOT: + case SPECIES_SHAYMIN: + case SPECIES_PIDOVE: + case SPECIES_ARCHEN: + case SPECIES_DUCKLETT: + case SPECIES_RUFFLET: + case SPECIES_VULLABY: + case SPECIES_FLETCHLING: + case SPECIES_HAWLUCHA: + case SPECIES_ROWLET: + case SPECIES_PIKIPEK: + return TRUE; + default: + return FALSE; + } +} + +bool8 IsMoveBannedFromSkyBattles(u16 move){ + switch (move) { + case MOVE_BODY_SLAM: + case MOVE_BULLDOZE: + case MOVE_DIG: + case MOVE_DIVE: + case MOVE_EARTH_POWER: + case MOVE_EARTHQUAKE: + case MOVE_ELECTRIC_TERRAIN: + case MOVE_FIRE_PLEDGE: + case MOVE_FISSURE: + case MOVE_FLYING_PRESS: + case MOVE_FRENZY_PLANT: + case MOVE_GEOMANCY: + case MOVE_GRASS_KNOT: + case MOVE_GRASS_PLEDGE: + case MOVE_GRASSY_TERRAIN: + case MOVE_GRAVITY: + case MOVE_HEAT_CRASH: + case MOVE_HEAVY_SLAM: + case MOVE_INGRAIN: + case MOVE_LANDS_WRATH: + case MOVE_MAGNITUDE: + case MOVE_MAT_BLOCK: + case MOVE_MISTY_TERRAIN: + case MOVE_MUD_SPORT: + case MOVE_MUDDY_WATER: + case MOVE_ROTOTILLER: + case MOVE_SEISMIC_TOSS: + case MOVE_SLAM: + case MOVE_SMACK_DOWN: + case MOVE_SPIKES: + case MOVE_STOMP: + case MOVE_SUBSTITUTE: + case MOVE_SURF: + case MOVE_THOUSAND_ARROWS: + case MOVE_THOUSAND_WAVES: + case MOVE_TOXIC_SPIKES: + case MOVE_WATER_PLEDGE: + case MOVE_WATER_SPORT: + return TRUE; + default: + return FALSE; + } +} diff --git a/src/field_specials.c b/src/field_specials.c index 6fdec2a5f09d..63707a868682 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -20,6 +20,7 @@ #include "international_string_util.h" #include "item_icon.h" #include "link.h" +#include "load_save.h" #include "list_menu.h" #include "main.h" #include "mystery_gift.h" @@ -45,6 +46,7 @@ #include "tv.h" #include "wallclock.h" #include "window.h" +#include "constants/abilities.h" #include "constants/battle_frontier.h" #include "constants/battle_pyramid.h" #include "constants/battle_tower.h" @@ -4207,3 +4209,41 @@ u8 Script_TryGainNewFanFromCounter(void) { return TryGainNewFanFromCounter(gSpecialVar_0x8004); } + +void CanDoSkyBattle(void) +{ + int i; + for (i = 0; i < CalculatePlayerPartyCount(); i++) + { + struct Pokemon* pokemon = &gPlayerParty[i]; + + if (CanMonParticipateInSkyBattle(pokemon) && GetMonData(pokemon, MON_DATA_HP, NULL) > 0) + { + gSpecialVar_Result = TRUE; + return; + } + } + gSpecialVar_Result = FALSE; +} + +void PrepareSkyBattle(void) +{ + int i, var; + u8 partyCount; + u16 species; + partyCount = CalculatePlayerPartyCount(); + SavePlayerParty(); + FlagSet(FLAG_IS_IN_SKY_BATTLE); + var = 0; + for (i = 0; i < partyCount; i++) + { + struct Pokemon* pokemon = &gPlayerParty[i]; + + if (CanMonParticipateInSkyBattle(pokemon)) + var += 1 << i; //This part savces the value of the Pokémon that participate or not, and this allows us to save them after the battle, instread of loading them back from befor the battle, so they lose HP, PP, etc. + else + ZeroMonData(pokemon); + } + VarSet(VAR_SKY_BATTLE_POKEMON_POSITIONS,var); + CompactPartySlots(); +} diff --git a/src/load_save.c b/src/load_save.c index 44e08b5e9c46..625078686b9a 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -13,6 +13,7 @@ #include "gba/flash_internal.h" #include "decoration_inventory.h" #include "agb_flash.h" +#include "event_data.h" static void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey); @@ -177,6 +178,19 @@ void LoadPlayerParty(void) gPlayerParty[i] = gSaveBlock1Ptr->playerParty[i]; } +void UpdatePlayerSavedPartyAfterSkyBattle(void) +{ + int i; + int c = 0; + int skyPokemonVar = VarGet(VAR_SKY_BATTLE_POKEMON_POSITIONS); + + for (i = 0; i < PARTY_SIZE; i++) + if ((skyPokemonVar >> i & 1) == 1){ + gSaveBlock1Ptr->playerParty[i] = gPlayerParty[c]; + c++; + } +} + void SaveObjectEvents(void) { int i; From 4deaf371be37dfd207070cdd9d5becf51d088096 Mon Sep 17 00:00:00 2001 From: PSF Date: Sun, 23 Apr 2023 21:56:16 -0700 Subject: [PATCH 02/34] Moved Sky Battle Flag / Var into a config --- data/scripts/debug.inc | 11 +++++++++++ include/battle_util.h | 1 - include/config/battle.h | 4 ++++ include/constants/flags.h | 2 +- include/constants/vars.h | 2 +- src/battle_script_commands.c | 2 +- src/battle_setup.c | 12 ++++++------ src/field_specials.c | 4 ++-- src/load_save.c | 2 +- 9 files changed, 27 insertions(+), 13 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 92e9062a3963..9538ed5ac9aa 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -68,12 +68,23 @@ Debug_FlagsNotSetBattleConfigMessage_Text: .string "'include/config/battle.h'!$" Debug_Script_1:: + setflag FLAG_BADGE08_GET + setflag FLAG_SYS_POKEMON_GET + givemon SPECIES_AERODACTYL, 10, 0 + givemon SPECIES_RUFFLET, 10, 0 + givemon SPECIES_BLASTOISE, 100, 0 end Debug_Script_2:: + special CanDoSkyBattle + compare VAR_RESULT, FALSE + goto_if_eq Debug_Script_3 + special PrepareSkyBattle + trainerbattle_single TRAINER_WALLACE, Route118_Text_RoseIntro, Route118_Text_RoseDefeat, Route118_EventScript_RegisterRose end Debug_Script_3:: + msgbox(Debug_FlagsNotSetBattleConfigMessage_Text) end Debug_Script_4:: diff --git a/include/battle_util.h b/include/battle_util.h index 47bab86a28ba..959cb35b5d69 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -234,7 +234,6 @@ u32 GetBattlerFriendshipScore(u8 battlerId); u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc); bool32 IsMyceliumMightOnField(void); bool8 ChangeTypeBasedOnTerrain(u8 battlerId); - bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon); bool8 IsMonBannedFromSkyBattles(u16 species); bool8 IsMoveBannedFromSkyBattles(u16 move); diff --git a/include/config/battle.h b/include/config/battle.h index 24f4ad4f1579..c32249f5e127 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -140,6 +140,10 @@ #define B_SPORT_BALL_MODIFIER GEN_LATEST // In Gen8, Sport Ball's catch multiplier was reduced from x1.5 to x1. #define B_SERENE_GRACE_BOOST GEN_LATEST // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. +// Sky Battles +#define B_FLAG_SKY_BATTLE FLAG_UNUSED_0x493 // If this flag is set, the player will be able to engage in scripted Sky Battles. +#define B_VAR_SKY_BATTLE VAR_UNUSED_0x40F7 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. + // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. diff --git a/include/constants/flags.h b/include/constants/flags.h index f17bc85fca70..59bde846c557 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1217,7 +1217,7 @@ #define FLAG_ITEM_SAFARI_ZONE_NORTH_EAST_NUGGET 0x491 #define FLAG_ITEM_SAFARI_ZONE_SOUTH_EAST_BIG_PEARL 0x492 -#define FLAG_IS_IN_SKY_BATTLE 0x493 +#define FLAG_UNUSED_0x493 0x493 // Unused Flag #define FLAG_UNUSED_0x494 0x494 // Unused Flag #define FLAG_UNUSED_0x495 0x495 // Unused Flag #define FLAG_UNUSED_0x496 0x496 // Unused Flag diff --git a/include/constants/vars.h b/include/constants/vars.h index b9a0d968211b..e0b08f4475b3 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -263,7 +263,7 @@ #define VAR_ROXANNE_CALL_STEP_COUNTER 0x40F4 #define VAR_SCOTT_BF_CALL_STEP_COUNTER 0x40F5 #define VAR_RIVAL_RAYQUAZA_CALL_STEP_COUNTER 0x40F6 -#define VAR_SKY_BATTLE_POKEMON_POSITIONS 0x40F7 +#define VAR_UNUSED_0x40F7 0x40F7 // Unused Var #define VAR_UNUSED_0x40F8 0x40F8 // Unused Var #define VAR_UNUSED_0x40F9 0x40F9 // Unused Var #define VAR_UNUSED_0x40FA 0x40FA // Unused Var diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eb18406ea250..d2bc8a75d7f4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1560,7 +1560,7 @@ static void Cmd_attackcanceler(void) } gHitMarker |= HITMARKER_OBEYS; - if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || ((FlagGet(FLAG_IS_IN_SKY_BATTLE) && IsMoveBannedFromSkyBattles(gCurrentMove))))) + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || ((FlagGet(B_FLAG_SKY_BATTLE) && IsMoveBannedFromSkyBattles(gCurrentMove)))) { gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; if (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) diff --git a/src/battle_setup.c b/src/battle_setup.c index 6bb03af74810..512698584866 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1356,13 +1356,9 @@ static void CB2_EndTrainerBattle(void) u8 partyCount; u8 i; - if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) - { - SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); - } - else if (FlagGet(FLAG_IS_IN_SKY_BATTLE)) + if (FlagGet(B_FLAG_SKY_BATTLE)) { - FlagClear(FLAG_IS_IN_SKY_BATTLE); + FlagClear(B_FLAG_SKY_BATTLE); UpdatePlayerSavedPartyAfterSkyBattle(); // Only updates the pokemon that participated in the battle LoadPlayerParty(); // Load the saved pokemons if (IsPlayerDefeated(gBattleOutcome) == TRUE) { // Check if every pokemon is fainted; @@ -1383,6 +1379,10 @@ static void CB2_EndTrainerBattle(void) } SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } + else if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) + { + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); + } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { if (InBattlePyramid() || InTrainerHillChallenge()) diff --git a/src/field_specials.c b/src/field_specials.c index 63707a868682..7cfac672f59d 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -4233,7 +4233,7 @@ void PrepareSkyBattle(void) u16 species; partyCount = CalculatePlayerPartyCount(); SavePlayerParty(); - FlagSet(FLAG_IS_IN_SKY_BATTLE); + FlagSet(B_FLAG_SKY_BATTLE); var = 0; for (i = 0; i < partyCount; i++) { @@ -4244,6 +4244,6 @@ void PrepareSkyBattle(void) else ZeroMonData(pokemon); } - VarSet(VAR_SKY_BATTLE_POKEMON_POSITIONS,var); + VarSet(B_VAR_SKY_BATTLE,var); CompactPartySlots(); } diff --git a/src/load_save.c b/src/load_save.c index 625078686b9a..e71d15e9a8e7 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -182,7 +182,7 @@ void UpdatePlayerSavedPartyAfterSkyBattle(void) { int i; int c = 0; - int skyPokemonVar = VarGet(VAR_SKY_BATTLE_POKEMON_POSITIONS); + int skyPokemonVar = VarGet(B_VAR_SKY_BATTLE); for (i = 0; i < PARTY_SIZE; i++) if ((skyPokemonVar >> i & 1) == 1){ From 8cbfca830ae974555d52ad9042cc61b2bbcc0099 Mon Sep 17 00:00:00 2001 From: PSF Date: Mon, 24 Apr 2023 18:37:55 -0700 Subject: [PATCH 03/34] Optimized existing code and fixed existing bugs Added error message for when sky battle var and flag are not set Merged CanDoSkyBattle and PrepareSkyBattle into one special --- data/scripts/debug.inc | 22 ++++++++-- data/specials.inc | 3 +- include/battle_script_commands.h | 1 + include/battle_util.h | 1 - include/debug.h | 1 + include/field_specials.h | 1 + include/load_save.h | 2 +- src/battle_script_commands.c | 59 ++++++++++++++++++++++++++- src/battle_setup.c | 50 +++++++++++------------ src/battle_util.c | 70 +++++--------------------------- src/debug.c | 1 + src/field_specials.c | 34 +++++++++++----- src/load_save.c | 16 ++++---- 13 files changed, 150 insertions(+), 111 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 9538ed5ac9aa..afdd40c13541 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -67,19 +67,33 @@ Debug_FlagsNotSetBattleConfigMessage_Text: .string "Please define a usable flag in:\l" .string "'include/config/battle.h'!$" +Debug_FlagsAndVarNotSetBattleConfigMessage:: + lockall + message Debug_FlagsAndVarNotSetBattleConfigMessage_Text + waitmessage + waitbuttonpress + releaseall + end + +Debug_FlagsAndVarNotSetBattleConfigMessage_Text: + .string "Feature unavailable! Please define a\n" + .string "usable flag and a usable var in:\l" + .string "'include/config/battle.h'!$" + + Debug_Script_1:: setflag FLAG_BADGE08_GET setflag FLAG_SYS_POKEMON_GET - givemon SPECIES_AERODACTYL, 10, 0 - givemon SPECIES_RUFFLET, 10, 0 + givemon SPECIES_PIDGEOT, 100, 0 + givemon SPECIES_RUFFLET, 100, 0 givemon SPECIES_BLASTOISE, 100, 0 + givemon SPECIES_LATIOS, 100, 0 end Debug_Script_2:: - special CanDoSkyBattle + special TrySkyBattle compare VAR_RESULT, FALSE goto_if_eq Debug_Script_3 - special PrepareSkyBattle trainerbattle_single TRAINER_WALLACE, Route118_Text_RoseIntro, Route118_Text_RoseDefeat, Route118_EventScript_RegisterRose end diff --git a/data/specials.inc b/data/specials.inc index 85cdfbce0f15..f2d87bd4ac38 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -536,5 +536,4 @@ gSpecials:: def_special TrySetBattleTowerLinkType def_special SetTotemBoost def_special TrySpecialOverworldEvo - def_special CanDoSkyBattle - def_special PrepareSkyBattle + def_special TrySkyBattle diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index dcf601e8040d..c527085b5d8e 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -45,6 +45,7 @@ void StealTargetItem(u8 battlerStealer, u8 battlerItem); u8 GetCatchingBattler(void); u32 GetHighestStatId(u32 battlerId); bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType); +bool32 DoesSkyBattleCancelMove(u32 gCurrentMove); bool32 DoSwitchInAbilitiesItems(u32 battlerId); u8 GetFirstFaintedPartyIndex(u8 battlerId); diff --git a/include/battle_util.h b/include/battle_util.h index 959cb35b5d69..afe9e3a85e50 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -236,6 +236,5 @@ bool32 IsMyceliumMightOnField(void); bool8 ChangeTypeBasedOnTerrain(u8 battlerId); bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon); bool8 IsMonBannedFromSkyBattles(u16 species); -bool8 IsMoveBannedFromSkyBattles(u16 move); #endif // GUARD_BATTLE_UTIL_H diff --git a/include/debug.h b/include/debug.h index 88f5f666205c..be71c7773ab9 100644 --- a/include/debug.h +++ b/include/debug.h @@ -2,5 +2,6 @@ #define GUARD_DEBUG_H void Debug_ShowMainMenu(void); +extern u8 Debug_FlagsAndVarNotSetBattleConfigMessage[]; #endif // GUARD_DEBUG_H diff --git a/include/field_specials.h b/include/field_specials.h index faf71e9c0877..d36f2686c286 100644 --- a/include/field_specials.h +++ b/include/field_specials.h @@ -31,5 +31,6 @@ bool8 UsedPokemonCenterWarp(void); void ResetFanClub(void); bool8 ShouldShowBoxWasFullMessage(void); void SetPCBoxToSendMon(u8 boxId); +void PreparePartyForSkyBattle(void); #endif // GUARD_FIELD_SPECIALS_H diff --git a/include/load_save.h b/include/load_save.h index 1def5a79366c..fad3e913d1f3 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -46,7 +46,7 @@ void SetContinueGameWarpStatusToDynamicWarp(void); void ClearContinueGameWarpStatus2(void); void SavePlayerParty(void); void LoadPlayerParty(void); -void UpdatePlayerSavedPartyAfterSkyBattle(void); +void SaveChangesToPlayerParty(void); void SaveObjectEvents(void); void LoadObjectEvents(void); void CopyPartyAndObjectsToSave(void); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d2bc8a75d7f4..01e57711ca77 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1458,6 +1458,62 @@ bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType) return FALSE; } +bool32 DoesSkyBattleCancelCurrentMove(u32 gCurrentMove) +{ + bool8 moveBannedFromSkyBattles = FALSE; + + switch (gCurrentMove) { + case MOVE_BODY_SLAM: + case MOVE_BULLDOZE: + case MOVE_DIG: + case MOVE_DIVE: + case MOVE_EARTH_POWER: + case MOVE_EARTHQUAKE: + case MOVE_ELECTRIC_TERRAIN: + case MOVE_FIRE_PLEDGE: + case MOVE_FISSURE: + case MOVE_FLYING_PRESS: + case MOVE_FRENZY_PLANT: + case MOVE_GEOMANCY: + case MOVE_GRASS_KNOT: + case MOVE_GRASS_PLEDGE: + case MOVE_GRASSY_TERRAIN: + case MOVE_GRAVITY: + case MOVE_HEAT_CRASH: + case MOVE_HEAVY_SLAM: + case MOVE_INGRAIN: + case MOVE_LANDS_WRATH: + case MOVE_MAGNITUDE: + case MOVE_MAT_BLOCK: + case MOVE_MISTY_TERRAIN: + case MOVE_MUD_SPORT: + case MOVE_MUDDY_WATER: + case MOVE_ROTOTILLER: + case MOVE_SEISMIC_TOSS: + case MOVE_SLAM: + case MOVE_SMACK_DOWN: + case MOVE_SPIKES: + case MOVE_STOMP: + case MOVE_SUBSTITUTE: + case MOVE_SURF: + case MOVE_THOUSAND_ARROWS: + case MOVE_THOUSAND_WAVES: + case MOVE_TOXIC_SPIKES: + case MOVE_WATER_PLEDGE: + case MOVE_WATER_SPORT: + moveBannedFromSkyBattles = TRUE; + break; + default: + moveBannedFromSkyBattles = FALSE; + } + + if (FlagGet(B_FLAG_SKY_BATTLE) && (moveBannedFromSkyBattles)){ + return TRUE; + } + + return FALSE; +} + static void Cmd_attackcanceler(void) { CMD_ARGS(); @@ -1560,7 +1616,7 @@ static void Cmd_attackcanceler(void) } gHitMarker |= HITMARKER_OBEYS; - if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || ((FlagGet(B_FLAG_SKY_BATTLE) && IsMoveBannedFromSkyBattles(gCurrentMove)))) + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || (DoesSkyBattleCancelCurrentMove(gCurrentMove))) { gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; if (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) @@ -15095,6 +15151,7 @@ u16 GetSecretPowerMoveEffect(void) return moveEffect; } + static void Cmd_pickup(void) { CMD_ARGS(); diff --git a/src/battle_setup.c b/src/battle_setup.c index 512698584866..f4c23d187814 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1350,42 +1350,42 @@ void BattleSetup_StartTrainerBattle(void) ScriptContext_Stop(); } -static void CB2_EndTrainerBattle(void) +static void HandleSpecialBattleParty(void) { - bool8 everyPokemonFainted; - u8 partyCount; - u8 i; - if (FlagGet(B_FLAG_SKY_BATTLE)) { + SaveChangesToPlayerParty(); + LoadPlayerParty(); FlagClear(B_FLAG_SKY_BATTLE); - UpdatePlayerSavedPartyAfterSkyBattle(); // Only updates the pokemon that participated in the battle - LoadPlayerParty(); // Load the saved pokemons - if (IsPlayerDefeated(gBattleOutcome) == TRUE) { // Check if every pokemon is fainted; - everyPokemonFainted = TRUE; - partyCount = CalculatePlayerPartyCount(); - for (i = 0; i < partyCount; i++) - { - if (GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) > 0) - { - everyPokemonFainted = FALSE; - break; - } - } - if (everyPokemonFainted) - SetMainCallback2(CB2_WhiteOut); - else - SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); + } +} + +static bool8 PlayerHasHealthyPokemon(void){ + u8 i; + u8 partyCount; + + partyCount = CalculatePlayerPartyCount(); + for (i = 0; i < partyCount; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) > 0) + { + return TRUE; } - SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } - else if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) + return FALSE; +} + +static void CB2_EndTrainerBattle(void) +{ + HandleSpecialBattleParty(); + + if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) { SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { - if (InBattlePyramid() || InTrainerHillChallenge()) + if (InBattlePyramid() || InTrainerHillChallenge() || PlayerHasHealthyPokemon() ) SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); else SetMainCallback2(CB2_WhiteOut); diff --git a/src/battle_util.c b/src/battle_util.c index 5e92f5918a1e..d80e47f5c3d7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10860,22 +10860,19 @@ static void SetRandomMultiHitCounter() } bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon){ - int i; - bool8 isFlyingType = FALSE; - bool8 isLevitating = GetMonData(pokemon, MON_DATA_ABILITY_NUM, NULL) == ABILITY_LEVITATE; - bool8 hasFlyMove = FALSE; + u16 species = GetMonData(pokemon, MON_DATA_SPECIES); + u8 monAbilityNum = GetMonData(pokemon, MON_DATA_ABILITY_NUM, NULL); + + bool8 hasLevitateAbility = gSpeciesInfo[species].abilities[monAbilityNum] == ABILITY_LEVITATE; + bool8 isFlyingType = gSpeciesInfo[species].types[0] == TYPE_FLYING || gSpeciesInfo[species].types[1] == TYPE_FLYING; + bool8 monIsValidAndNotEgg = GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG); - if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG)) + if (monIsValidAndNotEgg) { - u16 species = GetMonData(pokemon, MON_DATA_SPECIES); - isFlyingType = gSpeciesInfo[species].types[0] == TYPE_FLYING || gSpeciesInfo[species].types[1] == TYPE_FLYING; - if (isFlyingType) - { - gSpecialVar_Result = TRUE; - return; - } + if ((hasLevitateAbility || isFlyingType) && !IsMonBannedFromSkyBattles(species)) + return TRUE; } - return (isFlyingType || isLevitating) && !IsMonBannedFromSkyBattles(GetMonData(pokemon,MON_DATA_SPECIES_OR_EGG)); + return FALSE; } bool8 IsMonBannedFromSkyBattles(u16 species){ @@ -10903,52 +10900,7 @@ bool8 IsMonBannedFromSkyBattles(u16 species){ case SPECIES_ROWLET: case SPECIES_PIKIPEK: return TRUE; - default: - return FALSE; - } -} - -bool8 IsMoveBannedFromSkyBattles(u16 move){ - switch (move) { - case MOVE_BODY_SLAM: - case MOVE_BULLDOZE: - case MOVE_DIG: - case MOVE_DIVE: - case MOVE_EARTH_POWER: - case MOVE_EARTHQUAKE: - case MOVE_ELECTRIC_TERRAIN: - case MOVE_FIRE_PLEDGE: - case MOVE_FISSURE: - case MOVE_FLYING_PRESS: - case MOVE_FRENZY_PLANT: - case MOVE_GEOMANCY: - case MOVE_GRASS_KNOT: - case MOVE_GRASS_PLEDGE: - case MOVE_GRASSY_TERRAIN: - case MOVE_GRAVITY: - case MOVE_HEAT_CRASH: - case MOVE_HEAVY_SLAM: - case MOVE_INGRAIN: - case MOVE_LANDS_WRATH: - case MOVE_MAGNITUDE: - case MOVE_MAT_BLOCK: - case MOVE_MISTY_TERRAIN: - case MOVE_MUD_SPORT: - case MOVE_MUDDY_WATER: - case MOVE_ROTOTILLER: - case MOVE_SEISMIC_TOSS: - case MOVE_SLAM: - case MOVE_SMACK_DOWN: - case MOVE_SPIKES: - case MOVE_STOMP: - case MOVE_SUBSTITUTE: - case MOVE_SURF: - case MOVE_THOUSAND_ARROWS: - case MOVE_THOUSAND_WAVES: - case MOVE_TOXIC_SPIKES: - case MOVE_WATER_PLEDGE: - case MOVE_WATER_SPORT: - return TRUE; + break; default: return FALSE; } diff --git a/src/debug.c b/src/debug.c index 3fb79d2e8639..486625b6925e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -279,6 +279,7 @@ static void DebugAction_OpenSubMenu(u8 taskId, struct ListMenuTemplate LMtemplat extern u8 Debug_FlagsNotSetOverworldConfigMessage[]; extern u8 Debug_FlagsNotSetBattleConfigMessage[]; +extern u8 Debug_FlagsAndVarNotSetBattleConfigMessage[]; extern u8 Debug_Script_1[]; extern u8 Debug_Script_2[]; extern u8 Debug_Script_3[]; diff --git a/src/field_specials.c b/src/field_specials.c index 7cfac672f59d..5a0568896137 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1,4 +1,5 @@ #include "global.h" +#include "debug.h" #include "malloc.h" #include "battle.h" #include "battle_tower.h" @@ -4210,40 +4211,53 @@ u8 Script_TryGainNewFanFromCounter(void) return TryGainNewFanFromCounter(gSpecialVar_0x8004); } -void CanDoSkyBattle(void) +void TrySkyBattle(void) { +#if B_VAR_SKY_BATTLE == 0 || B_FLAG_SKY_BATTLE == 0 + LockPlayerFieldControls(); + ScriptContext_SetupScript(Debug_FlagsAndVarNotSetBattleConfigMessage); +#else int i; + + /* + if (B_VAR_SKY_BATTLE == 0 || B_FLAG_SKY_BATTLE == 0){ + gSpecialVar_Result = FALSE; + return; + } + */ + for (i = 0; i < CalculatePlayerPartyCount(); i++) { struct Pokemon* pokemon = &gPlayerParty[i]; if (CanMonParticipateInSkyBattle(pokemon) && GetMonData(pokemon, MON_DATA_HP, NULL) > 0) { + PreparePartyForSkyBattle(); gSpecialVar_Result = TRUE; return; } } gSpecialVar_Result = FALSE; +#endif } -void PrepareSkyBattle(void) +void PreparePartyForSkyBattle(void) { - int i, var; - u8 partyCount; - u16 species; - partyCount = CalculatePlayerPartyCount(); - SavePlayerParty(); + int i, participatingPokemonSlot = 0; + u8 partyCount = CalculatePlayerPartyCount(); + FlagSet(B_FLAG_SKY_BATTLE); - var = 0; + SavePlayerParty(); + for (i = 0; i < partyCount; i++) { struct Pokemon* pokemon = &gPlayerParty[i]; if (CanMonParticipateInSkyBattle(pokemon)) - var += 1 << i; //This part savces the value of the Pokémon that participate or not, and this allows us to save them after the battle, instread of loading them back from befor the battle, so they lose HP, PP, etc. + participatingPokemonSlot += 1 << i; else ZeroMonData(pokemon); } - VarSet(B_VAR_SKY_BATTLE,var); + VarSet(B_VAR_SKY_BATTLE,participatingPokemonSlot); CompactPartySlots(); } diff --git a/src/load_save.c b/src/load_save.c index e71d15e9a8e7..34c0918204f4 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -178,17 +178,17 @@ void LoadPlayerParty(void) gPlayerParty[i] = gSaveBlock1Ptr->playerParty[i]; } -void UpdatePlayerSavedPartyAfterSkyBattle(void) +void SaveChangesToPlayerParty(void) { - int i; - int c = 0; - int skyPokemonVar = VarGet(B_VAR_SKY_BATTLE); + u8 i = 0, j = 0; + u8 participatedPokemon = VarGet(B_VAR_SKY_BATTLE); - for (i = 0; i < PARTY_SIZE; i++) - if ((skyPokemonVar >> i & 1) == 1){ - gSaveBlock1Ptr->playerParty[i] = gPlayerParty[c]; - c++; + for (i = 0; i < PARTY_SIZE; i++){ + if ((participatedPokemon >> i & 1) == 1){ + gSaveBlock1Ptr->playerParty[i] = gPlayerParty[j]; + j++; } + } } void SaveObjectEvents(void) From a10c1bd0b4a8ee3fa292a6ff06ae9cd881f5b526 Mon Sep 17 00:00:00 2001 From: PSF Date: Mon, 24 Apr 2023 18:52:51 -0700 Subject: [PATCH 04/34] Added compatibility for Gen7+ --- include/config/battle.h | 3 +++ src/battle_script_commands.c | 12 ++++++++++++ src/battle_util.c | 2 ++ 3 files changed, 17 insertions(+) diff --git a/include/config/battle.h b/include/config/battle.h index c32249f5e127..502a655e8fe6 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -143,6 +143,9 @@ // Sky Battles #define B_FLAG_SKY_BATTLE FLAG_UNUSED_0x493 // If this flag is set, the player will be able to engage in scripted Sky Battles. #define B_VAR_SKY_BATTLE VAR_UNUSED_0x40F7 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. +#define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //When TRUE, Sky Battles will use the eligibility from Pokémon XY. When FALSE, all Flying-types or Pokémon with Levitate are allowed. + +#define B_SKY_BATTLE_STRICT_MOVES FALSE //When TRUE, Sky Battles will use the banned moves from Pokémon XY. When FALSE, more moves that debuted after Pokémon XY are added. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 01e57711ca77..269c972cad4b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1501,6 +1501,18 @@ bool32 DoesSkyBattleCancelCurrentMove(u32 gCurrentMove) case MOVE_TOXIC_SPIKES: case MOVE_WATER_PLEDGE: case MOVE_WATER_SPORT: +#if B_SKY_BATTLE_STRICT_MOVES == FALSE + case MOVE_TECTONIC_RAGE: + //case MOVE_MAX_QUAKE: + case MOVE_STOMPING_TANTRUM: + case MOVE_BODY_PRESS: + case MOVE_SNAP_TRAP: + case MOVE_GRASSY_GLIDE: + case MOVE_WAVE_CRASH: + case MOVE_SPIN_OUT: + case MOVE_ICE_SPINNER: + case MOVE_VOLT_CRASH: +#endif moveBannedFromSkyBattles = TRUE; break; default: diff --git a/src/battle_util.c b/src/battle_util.c index d80e47f5c3d7..d38dfe5dc3a8 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10878,6 +10878,7 @@ bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon){ bool8 IsMonBannedFromSkyBattles(u16 species){ switch (species){ case SPECIES_EGG: +#if B_SKY_BATTLE_STRICT_ELIGIBILITY == TRUE case SPECIES_SPEAROW: case SPECIES_FARFETCHD: case SPECIES_DODUO: @@ -10899,6 +10900,7 @@ bool8 IsMonBannedFromSkyBattles(u16 species){ case SPECIES_HAWLUCHA: case SPECIES_ROWLET: case SPECIES_PIKIPEK: +#endif return TRUE; break; default: From 1c3e61bda98544168e2b1b3ab220393802dc908c Mon Sep 17 00:00:00 2001 From: PSF Date: Mon, 24 Apr 2023 19:06:17 -0700 Subject: [PATCH 05/34] Commented out Volt Crash from banned moves --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 269c972cad4b..27f2a438bdc0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1511,7 +1511,7 @@ bool32 DoesSkyBattleCancelCurrentMove(u32 gCurrentMove) case MOVE_WAVE_CRASH: case MOVE_SPIN_OUT: case MOVE_ICE_SPINNER: - case MOVE_VOLT_CRASH: + //case MOVE_VOLT_CRASH: #endif moveBannedFromSkyBattles = TRUE; break; From 35c9e94300440c731ae8b9cd956df7593d6fe0db Mon Sep 17 00:00:00 2001 From: PSF Date: Mon, 24 Apr 2023 20:00:33 -0700 Subject: [PATCH 06/34] Cleaned up debug scripts from testing --- data/scripts/debug.inc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index afdd40c13541..9011130e61ad 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -82,23 +82,12 @@ Debug_FlagsAndVarNotSetBattleConfigMessage_Text: Debug_Script_1:: - setflag FLAG_BADGE08_GET - setflag FLAG_SYS_POKEMON_GET - givemon SPECIES_PIDGEOT, 100, 0 - givemon SPECIES_RUFFLET, 100, 0 - givemon SPECIES_BLASTOISE, 100, 0 - givemon SPECIES_LATIOS, 100, 0 end Debug_Script_2:: - special TrySkyBattle - compare VAR_RESULT, FALSE - goto_if_eq Debug_Script_3 - trainerbattle_single TRAINER_WALLACE, Route118_Text_RoseIntro, Route118_Text_RoseDefeat, Route118_EventScript_RegisterRose end Debug_Script_3:: - msgbox(Debug_FlagsNotSetBattleConfigMessage_Text) end Debug_Script_4:: From 146e8a01a4f521c3b27e6ab598ab245377c072b9 Mon Sep 17 00:00:00 2001 From: PSF Date: Mon, 24 Apr 2023 22:29:10 -0700 Subject: [PATCH 07/34] =?UTF-8?q?Fixed=20bug=20where=20player=20did=20not?= =?UTF-8?q?=20white=20out=20even=20if=20they=20had=20no=20healthy=20Pok?= =?UTF-8?q?=C3=A9mon=20and=20only=20an=20egg=20Zeroed=20out=20both=20Sky?= =?UTF-8?q?=20Battle=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/config/battle.h | 8 ++++---- src/battle_setup.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 5d4fb7d024c1..a025e5a29da2 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -142,11 +142,11 @@ #define B_SERENE_GRACE_BOOST GEN_LATEST // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. // Sky Battles -#define B_FLAG_SKY_BATTLE FLAG_UNUSED_0x493 // If this flag is set, the player will be able to engage in scripted Sky Battles. -#define B_VAR_SKY_BATTLE VAR_UNUSED_0x40F7 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. -#define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //When TRUE, Sky Battles will use the eligibility from Pokémon XY. When FALSE, all Flying-types or Pokémon with Levitate are allowed. +#define B_FLAG_SKY_BATTLE 0 // If this flag is set, the player will be able to engage in scripted Sky Battles. +#define B_VAR_SKY_BATTLE 0 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. -#define B_SKY_BATTLE_STRICT_MOVES FALSE //When TRUE, Sky Battles will use the banned moves from Pokémon XY. When FALSE, more moves that debuted after Pokémon XY are added. +#define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. +#define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. diff --git a/src/battle_setup.c b/src/battle_setup.c index f4c23d187814..2b385c91d79e 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1367,7 +1367,7 @@ static bool8 PlayerHasHealthyPokemon(void){ partyCount = CalculatePlayerPartyCount(); for (i = 0; i < partyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) > 0) + if ((GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) > 0) && (!GetMonData(&gPlayerParty[i],MON_DATA_IS_EGG,NULL))) { return TRUE; } From db39306a2deaff18da625c8580b7f1167792c29c Mon Sep 17 00:00:00 2001 From: PSF Date: Mon, 24 Apr 2023 22:42:14 -0700 Subject: [PATCH 08/34] Removed extra include from src/field_specials.c Removed extra line break in src/battle_script_commands.c --- src/battle_script_commands.c | 1 - src/field_specials.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 381ce3aa71ff..3485c0ea8624 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -15234,7 +15234,6 @@ u16 GetSecretPowerMoveEffect(void) return moveEffect; } - static void Cmd_pickup(void) { CMD_ARGS(); diff --git a/src/field_specials.c b/src/field_specials.c index 5a0568896137..cbb9591acc1d 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -47,7 +47,6 @@ #include "tv.h" #include "wallclock.h" #include "window.h" -#include "constants/abilities.h" #include "constants/battle_frontier.h" #include "constants/battle_pyramid.h" #include "constants/battle_tower.h" From f7e8a52d4544648af8946c5abbede57216853a00 Mon Sep 17 00:00:00 2001 From: PSF Date: Wed, 26 Apr 2023 22:43:28 -0700 Subject: [PATCH 09/34] Added FLAG_DISABLED_IN_SKY_BATTLE Added FLAG_DISABLED_IN_SKY_BATTLE to appropriate moves --- include/constants/pokemon.h | 1 + src/data/battle_moves.h | 136 ++++++++++++++++++++++-------------- 2 files changed, 86 insertions(+), 51 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index ddf879854ed8..78c158d7ffa7 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -244,6 +244,7 @@ #define FLAG_TWO_STRIKES (1 << 27) // A move with this flag will strike twice, and may apply its effect on each hit #define FLAG_WIND_MOVE (1 << 28) #define FLAG_SLICING_MOVE (1 << 29) +#define FLAG_DISABLED_IN_SKY_BATTLE (1 << 30) // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 4a89222a966c..f5e9a9aecacd 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -348,7 +348,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -386,7 +386,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_MINIMIZE, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_MINIMIZE | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -564,9 +564,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_BODY_SLAM] = { #if B_UPDATED_MOVE_DATA >= GEN_6 - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_MINIMIZE, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_MINIMIZE | FLAG_DISABLED_IN_SKY_BATTLE, #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DISABLED_IN_SKY_BATTLE, #endif .effect = EFFECT_PARALYZE_HIT, .power = 85, @@ -970,7 +970,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .pp = 15, .secondaryEffectChance = 0, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_UNDERWATER, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_UNDERWATER | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -1168,7 +1168,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -1514,7 +1514,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_FOES_AND_ALLY, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_UNDERGROUND, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_UNDERGROUND | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -1529,7 +1529,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_DMG_UNDERGROUND, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_DMG_UNDERGROUND | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -1548,7 +1548,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -2768,7 +2768,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_SNATCH_AFFECTED, + .flags = FLAG_SNATCH_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_RESET_STATS, }, @@ -3229,9 +3229,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_SPIKES] = { #if B_UPDATED_MOVE_DATA >= GEN_5 - .flags = FLAG_MAGIC_COAT_AFFECTED, + .flags = FLAG_MAGIC_COAT_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, #else - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, #endif .effect = EFFECT_SPIKES, .power = 0, @@ -3775,7 +3775,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_FOES_AND_ALLY, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_UNDERGROUND, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_UNDERGROUND | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -4694,7 +4694,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_SNATCH_AFFECTED, + .flags = FLAG_SNATCH_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, }, @@ -4950,7 +4950,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -5093,7 +5093,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, }, @@ -5607,7 +5607,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 30, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -5744,7 +5744,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -5884,7 +5884,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, }, @@ -6055,7 +6055,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPATK_UP_1, }, @@ -6621,9 +6621,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_TOXIC_SPIKES] = { #if B_UPDATED_MOVE_DATA >= GEN_5 - .flags = FLAG_MAGIC_COAT_AFFECTED, + .flags = FLAG_MAGIC_COAT_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, #else - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, #endif .effect = EFFECT_TOXIC_SPIKES, .power = 0, @@ -7040,7 +7040,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 10, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -7574,7 +7574,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -8099,7 +8099,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -8171,9 +8171,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_HEAVY_SLAM] = { #if B_UPDATED_MOVE_DATA >= GEN_7 - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_MINIMIZE, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_MINIMIZE | FLAG_DISABLED_IN_SKY_BATTLE, #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, #endif .effect = EFFECT_HEAT_CRASH, .power = 1, @@ -8722,7 +8722,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -8741,7 +8741,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -8760,7 +8760,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -8809,7 +8809,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_FOES_AND_ALLY, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -8990,9 +8990,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_HEAT_CRASH] = { #if B_UPDATED_MOVE_DATA >= GEN_6 - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_MINIMIZE, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_MINIMIZE | FLAG_DISABLED_IN_SKY_BATTLE, #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, #endif .effect = EFFECT_HEAT_CRASH, .power = 1, @@ -9392,7 +9392,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_MINIMIZE, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_MINIMIZE | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .argument = TYPE_FLYING, .zMoveEffect = Z_EFFECT_NONE, @@ -9408,7 +9408,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_SNATCH_AFFECTED, + .flags = FLAG_SNATCH_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .argument = TRUE, // Protects the whole side. .zMoveEffect = Z_EFFECT_DEF_UP_1, @@ -9439,7 +9439,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_ATK_UP_1, }, @@ -9716,7 +9716,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_DEF_UP_1, }, @@ -9731,7 +9731,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, }, @@ -10044,7 +10044,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_ALL_STATS_UP_1, }, @@ -10089,7 +10089,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPD_UP_1, }, @@ -10240,7 +10240,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR | FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR | FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -10255,7 +10255,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -10270,7 +10270,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -10941,6 +10941,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_STOMPING_TANTRUM] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_STOMPING_TANTRUM, .power = 75, .type = TYPE_GROUND, @@ -10949,7 +10954,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -11671,6 +11675,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_BODY_PRESS] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif + .effect = EFFECT_BODY_PRESS, .power = 80, .type = TYPE_FIGHTING, @@ -11679,7 +11689,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -11716,6 +11725,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_SNAP_TRAP] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif + .effect = EFFECT_TRAP, .power = 35, .type = TYPE_GRASS, @@ -11724,7 +11739,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -12081,6 +12095,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = #else .power = 70, #endif + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_GRASSY_GLIDE, .type = TYPE_GRASS, .accuracy = 100, @@ -12088,7 +12107,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -12570,6 +12588,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = #else .power = 75, #endif + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_RECOIL_33, .type = TYPE_WATER, .accuracy = 100, @@ -12577,7 +12600,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -12986,6 +13008,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_SPIN_OUT] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_PLACEHOLDER, // EFFECT_SPIN_OUT .power = 100, .type = TYPE_STEEL, @@ -12994,7 +13021,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE }, @@ -13017,6 +13043,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_ICE_SPINNER] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 80, .type = TYPE_ICE, @@ -13025,7 +13056,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .argument = 1, // Remove the active field terrain if there is one. @@ -13688,6 +13718,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = }, [MOVE_TECTONIC_RAGE] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = 0, + #else + .flags = FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_HIT, .power = 1, .type = TYPE_GROUND, @@ -13696,7 +13731,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = 0, .split = SPLIT_PHYSICAL, .zMoveEffect = 0 }, From 8e2888c57690d1f9a894efd7fbbd175cf6a53d7b Mon Sep 17 00:00:00 2001 From: PSF Date: Wed, 26 Apr 2023 23:04:17 -0700 Subject: [PATCH 10/34] Changed DoesSkyBattleCancelCurrentMove to look at move flags --- src/battle_script_commands.c | 59 ++---------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e13732e0b62..566150e59cb4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1498,67 +1498,12 @@ bool32 DoesSkyBattleCancelCurrentMove(u32 gCurrentMove) { bool8 moveBannedFromSkyBattles = FALSE; - switch (gCurrentMove) { - case MOVE_BODY_SLAM: - case MOVE_BULLDOZE: - case MOVE_DIG: - case MOVE_DIVE: - case MOVE_EARTH_POWER: - case MOVE_EARTHQUAKE: - case MOVE_ELECTRIC_TERRAIN: - case MOVE_FIRE_PLEDGE: - case MOVE_FISSURE: - case MOVE_FLYING_PRESS: - case MOVE_FRENZY_PLANT: - case MOVE_GEOMANCY: - case MOVE_GRASS_KNOT: - case MOVE_GRASS_PLEDGE: - case MOVE_GRASSY_TERRAIN: - case MOVE_GRAVITY: - case MOVE_HEAT_CRASH: - case MOVE_HEAVY_SLAM: - case MOVE_INGRAIN: - case MOVE_LANDS_WRATH: - case MOVE_MAGNITUDE: - case MOVE_MAT_BLOCK: - case MOVE_MISTY_TERRAIN: - case MOVE_MUD_SPORT: - case MOVE_MUDDY_WATER: - case MOVE_ROTOTILLER: - case MOVE_SEISMIC_TOSS: - case MOVE_SLAM: - case MOVE_SMACK_DOWN: - case MOVE_SPIKES: - case MOVE_STOMP: - case MOVE_SUBSTITUTE: - case MOVE_SURF: - case MOVE_THOUSAND_ARROWS: - case MOVE_THOUSAND_WAVES: - case MOVE_TOXIC_SPIKES: - case MOVE_WATER_PLEDGE: - case MOVE_WATER_SPORT: -#if B_SKY_BATTLE_STRICT_MOVES == FALSE - case MOVE_TECTONIC_RAGE: - //case MOVE_MAX_QUAKE: - case MOVE_STOMPING_TANTRUM: - case MOVE_BODY_PRESS: - case MOVE_SNAP_TRAP: - case MOVE_GRASSY_GLIDE: - case MOVE_WAVE_CRASH: - case MOVE_SPIN_OUT: - case MOVE_ICE_SPINNER: - //case MOVE_VOLT_CRASH: -#endif - moveBannedFromSkyBattles = TRUE; - break; - default: - moveBannedFromSkyBattles = FALSE; - } + if (gBattleMoves[gCurrentMove].flags & FLAG_DISABLED_IN_SKY_BATTLE) + moveBannedFromSkyBattles = TRUE; if (FlagGet(B_FLAG_SKY_BATTLE) && (moveBannedFromSkyBattles)){ return TRUE; } - return FALSE; } From 1da176590dcbee221f60f1a3bd7d2d52aa60a78b Mon Sep 17 00:00:00 2001 From: PSF Date: Wed, 26 Apr 2023 23:10:54 -0700 Subject: [PATCH 11/34] Fixed alignment and spacing in battle_moves.h --- src/data/battle_moves.h | 42 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index f5e9a9aecacd..4350aa9a741e 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -11675,12 +11675,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_BODY_PRESS] = { - #if B_SKY_BATTLE_STRICT_MOVES == TRUE - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, - #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, - #endif - + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_BODY_PRESS, .power = 80, .type = TYPE_FIGHTING, @@ -11725,12 +11724,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_SNAP_TRAP] = { - #if B_SKY_BATTLE_STRICT_MOVES == TRUE - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, - #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, - #endif - + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_TRAP, .power = 35, .type = TYPE_GRASS, @@ -13008,11 +13006,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_SPIN_OUT] = { - #if B_SKY_BATTLE_STRICT_MOVES == TRUE - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, - #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, - #endif + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_PLACEHOLDER, // EFFECT_SPIN_OUT .power = 100, .type = TYPE_STEEL, @@ -13043,11 +13041,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_ICE_SPINNER] = { - #if B_SKY_BATTLE_STRICT_MOVES == TRUE - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, - #else - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, - #endif + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 80, .type = TYPE_ICE, From 60a6a57c9fe1dd4153b63e97d128ed9ca12ecdbe Mon Sep 17 00:00:00 2001 From: PSF Date: Thu, 27 Apr 2023 10:04:44 -0700 Subject: [PATCH 12/34] Added FLAG_DISABLED_IN_SKY_BATTLE to Sticky Web --- src/data/battle_moves.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 4350aa9a741e..e072a4021b75 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9446,6 +9446,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_STICKY_WEB] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAGIC_COAT_AFFECTED, + #else + .flags = FLAG_MAGIC_COAT_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_STICKY_WEB, .power = 0, .type = TYPE_BUG, @@ -9454,7 +9459,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_OPPONENTS_FIELD, .priority = 0, - .flags = FLAG_MAGIC_COAT_AFFECTED, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPD_UP_1, }, From 4aa9156261b63fcae85c980205846223257abf3c Mon Sep 17 00:00:00 2001 From: PSF Date: Thu, 27 Apr 2023 10:31:18 -0700 Subject: [PATCH 13/34] Added FLAG_DISABLED_IN_SKY_BATTLE to Steel Roller --- src/data/battle_moves.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index e072a4021b75..391b56f1ecf9 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12017,6 +12017,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_STEEL_ROLLER] = { + #if B_SKY_BATTLE_STRICT_MOVES == TRUE + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + #else + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DISABLED_IN_SKY_BATTLE, + #endif .effect = EFFECT_REMOVE_TERRAIN, .power = 130, .type = TYPE_STEEL, @@ -12025,7 +12030,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, From d2ada7743fb4a3affffe54965bad4060cc8248b1 Mon Sep 17 00:00:00 2001 From: PSF Date: Thu, 27 Apr 2023 13:41:37 -0700 Subject: [PATCH 14/34] Disabled the ability to change Battle Terrain when Sky Battle is happening Stopped Ceaseless Edge from spawning Spikes when Sky Battle is happening Added B_SKY_BATTLE_STRICT_MECHANICS config --- include/config/battle.h | 5 +++-- src/battle_script_commands.c | 4 ++++ src/battle_util.c | 27 +++++++++++++++++---------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index a025e5a29da2..7228723efeee 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -142,11 +142,12 @@ #define B_SERENE_GRACE_BOOST GEN_LATEST // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. // Sky Battles -#define B_FLAG_SKY_BATTLE 0 // If this flag is set, the player will be able to engage in scripted Sky Battles. -#define B_VAR_SKY_BATTLE 0 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. +#define B_FLAG_SKY_BATTLE 0 // If this flag is set, the player will be able to engage in scripted Sky Battles. +#define B_VAR_SKY_BATTLE 0 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. #define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. #define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. +#define B_SKY_BATTLE_STRICT_MECHANICS FALSE //If TRUE, Sky Battles will use the exact mechanics from Pokémon XY. If FALSE, moves and Abilities that set Terrain, Toxic Spikes, or Spikes will not have those effects activate. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 566150e59cb4..cb1275dc4026 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3858,7 +3858,11 @@ void SetMoveEffect(bool32 primary, u32 certain) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SPIKESSCATTERED; BattleScriptPush(gBattlescriptCurrInstr + 1); + #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE + gBattlescriptCurrInstr++; + #else gBattlescriptCurrInstr = BattleScript_SpikesActivates; + #endif } break; } diff --git a/src/battle_util.c b/src/battle_util.c index 982c66f4251a..484e8b63945f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4098,19 +4098,23 @@ bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility) static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer) { +#if B_SKY_BATTLE_STRICT_MECHANICS == TRUE if (!(gFieldStatuses & statusFlag)) - { - gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); - gFieldStatuses |= statusFlag; +#else + if (!(gFieldStatuses & statusFlag) && !FlagGet(B_FLAG_SKY_BATTLE)) +#endif + { + gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); + gFieldStatuses |= statusFlag; - if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER) - *timer = 8; - else - *timer = 5; + if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER) + *timer = 8; + else + *timer = 5; - gBattlerAttacker = gBattleScripting.battler = battler; - return TRUE; - } + gBattlerAttacker = gBattleScripting.battler = battler; + return TRUE; + } return FALSE; } @@ -5794,6 +5798,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE + && !FlagGet(B_FLAG_SKY_BATTLE) + #endif && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && IS_MOVE_PHYSICAL(gCurrentMove) && TARGET_TURN_DAMAGED From 7a6abe2e0e502df4d63705f987ce41dbf7a969ce Mon Sep 17 00:00:00 2001 From: PSF Date: Thu, 27 Apr 2023 22:37:41 -0700 Subject: [PATCH 15/34] Fixed bug with SKY_BATTLE_STRICT_MECHANICS where conditions were not consistently being applied --- src/battle_script_commands.c | 4 ++-- src/battle_util.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cb1275dc4026..d817055dd435 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3859,9 +3859,9 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SPIKESSCATTERED; BattleScriptPush(gBattlescriptCurrInstr + 1); #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE - gBattlescriptCurrInstr++; - #else gBattlescriptCurrInstr = BattleScript_SpikesActivates; + #else + gBattlescriptCurrInstr++; #endif } break; diff --git a/src/battle_util.c b/src/battle_util.c index 484e8b63945f..ac2f790dad6b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5798,7 +5798,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE + #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE && !FlagGet(B_FLAG_SKY_BATTLE) #endif && !gProtectStructs[gBattlerAttacker].confusionSelfDmg From f3584a0ac3c24dc20694117074e6ac58e2d3665d Mon Sep 17 00:00:00 2001 From: PSF Date: Fri, 28 Apr 2023 19:04:53 -0700 Subject: [PATCH 16/34] Add rulesVariants to the BattleStruct Added skyBattle check in AllocateBattleResources --- include/battle.h | 8 ++++++++ src/battle_util2.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/battle.h b/include/battle.h index c7265ed2a0dd..64567fe25cae 100644 --- a/include/battle.h +++ b/include/battle.h @@ -523,6 +523,13 @@ struct LostItem u16 stolen:1; }; +struct BattleRulesVariant +{ + bool8 skyBattle:1; + //bool8 inverseBattle:1; +}; + + struct BattleStruct { u8 turnEffectsTracker; @@ -669,6 +676,7 @@ struct BattleStruct bool8 trainerSlideMegaEvolutionMsgDone; bool8 trainerSlideZMoveMsgDone; bool8 trainerSlideBeforeFirstTurnMsgDone; + struct BattleRulesVariant rulesVariants; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/src/battle_util2.c b/src/battle_util2.c index 0f04a6eb4eb1..f852c952514c 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -19,6 +19,10 @@ void AllocateBattleResources(void) gBattleStruct = AllocZeroed(sizeof(*gBattleStruct)); +#if B_FLAG_SKY_BATTLE + gBattleStruct->rulesVariants.skyBattle = FlagGet(B_FLAG_SKY_BATTLE); +#endif + gBattleResources = AllocZeroed(sizeof(*gBattleResources)); gBattleResources->secretBase = AllocZeroed(sizeof(*gBattleResources->secretBase)); gBattleResources->flags = AllocZeroed(sizeof(*gBattleResources->flags)); From aec9817cee9f9e87fb21a68dac2a6cce3904548e Mon Sep 17 00:00:00 2001 From: PSF Date: Fri, 28 Apr 2023 19:25:47 -0700 Subject: [PATCH 17/34] Replaced B_FLAG_SKY_BATTLE checks with rulesVariants.skyBattle checks --- data/scripts/debug.inc | 62 ++++++++++++++++++++++++++++++++++++ include/config/battle.h | 4 +-- src/battle_script_commands.c | 2 +- src/battle_setup.c | 4 +-- src/battle_util.c | 4 +-- src/field_specials.c | 7 ---- 6 files changed, 69 insertions(+), 14 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 9011130e61ad..b47a74b3f7a2 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -82,9 +82,19 @@ Debug_FlagsAndVarNotSetBattleConfigMessage_Text: Debug_Script_1:: + setflag FLAG_BADGE08_GET + setflag FLAG_SYS_POKEMON_GET + givemon SPECIES_TAPU_BULU,100,0 + givemon SPECIES_SPEAROW,50,0 + givemon SPECIES_FLYGON,50,0 + givemon SPECIES_PIDGEOT,10,0 + //givemon SPECIES_WEEDLE,10,0 + giveegg SPECIES_RAYQUAZA + goto Route123_EventScript_Alberto2 end Debug_Script_2:: +call Route123_EventScript_Alberto_StartBattle end Debug_Script_3:: @@ -104,3 +114,55 @@ Debug_Script_7:: Debug_Script_8:: end + +Route123_EventScript_Alberto2:: + lock + faceplayer + checktrainerflag TRAINER_ALBERTO + goto_if 0, Route123_EventScript_Alberto_Battle_Event_Script + msgbox Route123_Text_AlbertoPostBattle, MSGBOX_AUTOCLOSE + release + end + +Route123_EventScript_Alberto_Battle_Event_Script: + msgbox Route123_EventScript_Alberto_Text_AskSkyBattle, MSGBOX_YESNO + compare VAR_RESULT, NO + goto_if_eq Route123_EventScript_Alberto_DenySkyBattle + special TrySkyBattle + compare VAR_RESULT, TRUE + goto_if_eq Route123_EventScript_Alberto_StartBattle + msgbox Route123_EventScript_Alberto_Text_No_Flying_Pokemon + closemessage + release + end + +Route123_EventScript_Alberto_DenySkyBattle: + msgbox Route123_EventScript_Alberto_Text_DenySkyBattle + closemessage + release + end + +Route123_EventScript_Alberto_StartBattle: + msgbox Route123_EventScript_Alberto_Text_StartBattle + trainerbattle_no_intro TRAINER_ALBERTO, Route123_Text_AlbertoDefeat + release + end + + +Route123_EventScript_Alberto_Text_AskSkyBattle: + .string "Care for a Sky Battle with a Sky\n" + .string "Trainer?$" + +Route123_EventScript_Alberto_Text_DenySkyBattle: + .string "Well, this is a bit disappointing for a\n" + .string "Sky Trainer like me...$" + +Route123_EventScript_Alberto_Text_StartBattle: + .string "Woo hoo! I'm a Sky Trainer! Look at me\n" + .string "go! Wooooo!$" + +Route123_EventScript_Alberto_Text_No_Flying_Pokemon: + .string "Well, well, isn't this a shame. You don't\n" + .string "have any flying Pokemon. We Sky\l" + .string "Trainers only battle with Pokemon that\l" + .string "can fly in the sky.$" diff --git a/include/config/battle.h b/include/config/battle.h index 7228723efeee..6ca53771de76 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -142,8 +142,8 @@ #define B_SERENE_GRACE_BOOST GEN_LATEST // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. // Sky Battles -#define B_FLAG_SKY_BATTLE 0 // If this flag is set, the player will be able to engage in scripted Sky Battles. -#define B_VAR_SKY_BATTLE 0 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. +#define B_FLAG_SKY_BATTLE FLAG_UNUSED_0x264 // If this flag is set, the player will be able to engage in scripted Sky Battles. +#define B_VAR_SKY_BATTLE VAR_UNUSED_0x40F7 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. #define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. #define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d817055dd435..cef0b7263f52 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1501,7 +1501,7 @@ bool32 DoesSkyBattleCancelCurrentMove(u32 gCurrentMove) if (gBattleMoves[gCurrentMove].flags & FLAG_DISABLED_IN_SKY_BATTLE) moveBannedFromSkyBattles = TRUE; - if (FlagGet(B_FLAG_SKY_BATTLE) && (moveBannedFromSkyBattles)){ + if ((gBattleStruct->rulesVariants.skyBattle) && (moveBannedFromSkyBattles)){ return TRUE; } return FALSE; diff --git a/src/battle_setup.c b/src/battle_setup.c index 2b385c91d79e..421f6ece0a6e 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1350,7 +1350,7 @@ void BattleSetup_StartTrainerBattle(void) ScriptContext_Stop(); } -static void HandleSpecialBattleParty(void) +static void HandleBattleVariantParty(void) { if (FlagGet(B_FLAG_SKY_BATTLE)) { @@ -1377,7 +1377,7 @@ static bool8 PlayerHasHealthyPokemon(void){ static void CB2_EndTrainerBattle(void) { - HandleSpecialBattleParty(); + HandleBattleVariantParty(); if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) { diff --git a/src/battle_util.c b/src/battle_util.c index ac2f790dad6b..7a8feb19464c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4101,7 +4101,7 @@ static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer) #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE if (!(gFieldStatuses & statusFlag)) #else - if (!(gFieldStatuses & statusFlag) && !FlagGet(B_FLAG_SKY_BATTLE)) + if ((!(gFieldStatuses & statusFlag) && (!gBattleStruct->rulesVariants.skyBattle))) #endif { gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); @@ -5799,7 +5799,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE - && !FlagGet(B_FLAG_SKY_BATTLE) + && (!gBattleStruct->rulesVariants.skyBattle) #endif && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && IS_MOVE_PHYSICAL(gCurrentMove) diff --git a/src/field_specials.c b/src/field_specials.c index cbb9591acc1d..1516182c3c7b 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -4218,13 +4218,6 @@ void TrySkyBattle(void) #else int i; - /* - if (B_VAR_SKY_BATTLE == 0 || B_FLAG_SKY_BATTLE == 0){ - gSpecialVar_Result = FALSE; - return; - } - */ - for (i = 0; i < CalculatePlayerPartyCount(); i++) { struct Pokemon* pokemon = &gPlayerParty[i]; From 3b0626a71c8dfdb1df6db1d72acd3be2f8f36a0d Mon Sep 17 00:00:00 2001 From: PSF Date: Fri, 28 Apr 2023 19:28:16 -0700 Subject: [PATCH 18/34] Fixed debug script --- data/scripts/debug.inc | 62 ------------------------------------------ 1 file changed, 62 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index b47a74b3f7a2..9011130e61ad 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -82,19 +82,9 @@ Debug_FlagsAndVarNotSetBattleConfigMessage_Text: Debug_Script_1:: - setflag FLAG_BADGE08_GET - setflag FLAG_SYS_POKEMON_GET - givemon SPECIES_TAPU_BULU,100,0 - givemon SPECIES_SPEAROW,50,0 - givemon SPECIES_FLYGON,50,0 - givemon SPECIES_PIDGEOT,10,0 - //givemon SPECIES_WEEDLE,10,0 - giveegg SPECIES_RAYQUAZA - goto Route123_EventScript_Alberto2 end Debug_Script_2:: -call Route123_EventScript_Alberto_StartBattle end Debug_Script_3:: @@ -114,55 +104,3 @@ Debug_Script_7:: Debug_Script_8:: end - -Route123_EventScript_Alberto2:: - lock - faceplayer - checktrainerflag TRAINER_ALBERTO - goto_if 0, Route123_EventScript_Alberto_Battle_Event_Script - msgbox Route123_Text_AlbertoPostBattle, MSGBOX_AUTOCLOSE - release - end - -Route123_EventScript_Alberto_Battle_Event_Script: - msgbox Route123_EventScript_Alberto_Text_AskSkyBattle, MSGBOX_YESNO - compare VAR_RESULT, NO - goto_if_eq Route123_EventScript_Alberto_DenySkyBattle - special TrySkyBattle - compare VAR_RESULT, TRUE - goto_if_eq Route123_EventScript_Alberto_StartBattle - msgbox Route123_EventScript_Alberto_Text_No_Flying_Pokemon - closemessage - release - end - -Route123_EventScript_Alberto_DenySkyBattle: - msgbox Route123_EventScript_Alberto_Text_DenySkyBattle - closemessage - release - end - -Route123_EventScript_Alberto_StartBattle: - msgbox Route123_EventScript_Alberto_Text_StartBattle - trainerbattle_no_intro TRAINER_ALBERTO, Route123_Text_AlbertoDefeat - release - end - - -Route123_EventScript_Alberto_Text_AskSkyBattle: - .string "Care for a Sky Battle with a Sky\n" - .string "Trainer?$" - -Route123_EventScript_Alberto_Text_DenySkyBattle: - .string "Well, this is a bit disappointing for a\n" - .string "Sky Trainer like me...$" - -Route123_EventScript_Alberto_Text_StartBattle: - .string "Woo hoo! I'm a Sky Trainer! Look at me\n" - .string "go! Wooooo!$" - -Route123_EventScript_Alberto_Text_No_Flying_Pokemon: - .string "Well, well, isn't this a shame. You don't\n" - .string "have any flying Pokemon. We Sky\l" - .string "Trainers only battle with Pokemon that\l" - .string "can fly in the sky.$" From 95c4eaf96a03e7ad39cba51e4c3dfc5813a066d1 Mon Sep 17 00:00:00 2001 From: PSF Date: Fri, 28 Apr 2023 19:31:38 -0700 Subject: [PATCH 19/34] Reverted include/config/battle.h --- include/config/battle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 6ca53771de76..7228723efeee 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -142,8 +142,8 @@ #define B_SERENE_GRACE_BOOST GEN_LATEST // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. // Sky Battles -#define B_FLAG_SKY_BATTLE FLAG_UNUSED_0x264 // If this flag is set, the player will be able to engage in scripted Sky Battles. -#define B_VAR_SKY_BATTLE VAR_UNUSED_0x40F7 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. +#define B_FLAG_SKY_BATTLE 0 // If this flag is set, the player will be able to engage in scripted Sky Battles. +#define B_VAR_SKY_BATTLE 0 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. #define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. #define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. From 2755fb5bb26ab3950528852a6a9b2e91aab5603c Mon Sep 17 00:00:00 2001 From: PSF Date: Fri, 28 Apr 2023 20:05:24 -0700 Subject: [PATCH 20/34] Fixed spacing and placement of functions --- data/scripts/debug.inc | 14 -------------- include/battle.h | 2 -- include/config/battle.h | 16 ++++++++-------- src/battle_util.c | 20 ++++++++++---------- 4 files changed, 18 insertions(+), 34 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 9011130e61ad..92e9062a3963 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -67,20 +67,6 @@ Debug_FlagsNotSetBattleConfigMessage_Text: .string "Please define a usable flag in:\l" .string "'include/config/battle.h'!$" -Debug_FlagsAndVarNotSetBattleConfigMessage:: - lockall - message Debug_FlagsAndVarNotSetBattleConfigMessage_Text - waitmessage - waitbuttonpress - releaseall - end - -Debug_FlagsAndVarNotSetBattleConfigMessage_Text: - .string "Feature unavailable! Please define a\n" - .string "usable flag and a usable var in:\l" - .string "'include/config/battle.h'!$" - - Debug_Script_1:: end diff --git a/include/battle.h b/include/battle.h index 64567fe25cae..95df1552292e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -526,10 +526,8 @@ struct LostItem struct BattleRulesVariant { bool8 skyBattle:1; - //bool8 inverseBattle:1; }; - struct BattleStruct { u8 turnEffectsTracker; diff --git a/include/config/battle.h b/include/config/battle.h index 7228723efeee..81c4315d8d6c 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -141,14 +141,6 @@ #define B_SPORT_BALL_MODIFIER GEN_LATEST // In Gen8, Sport Ball's catch multiplier was reduced from x1.5 to x1. #define B_SERENE_GRACE_BOOST GEN_LATEST // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. -// Sky Battles -#define B_FLAG_SKY_BATTLE 0 // If this flag is set, the player will be able to engage in scripted Sky Battles. -#define B_VAR_SKY_BATTLE 0 // If this var is set, the game will remember the positions of Pokémon used in Sky Battles. - -#define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. -#define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. -#define B_SKY_BATTLE_STRICT_MECHANICS FALSE //If TRUE, Sky Battles will use the exact mechanics from Pokémon XY. If FALSE, moves and Abilities that set Terrain, Toxic Spikes, or Spikes will not have those effects activate. - // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. @@ -164,6 +156,14 @@ #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) +// Sky Battles +#define B_FLAG_SKY_BATTLE 0 // If this flag has a value, the player will be able to engage in scripted Sky Battles. +#define B_VAR_SKY_BATTLE 0 // If this var has a value, the game will remember the positions of Pokémon used in Sky Battles. + +#define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. +#define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. +#define B_SKY_BATTLE_STRICT_MECHANICS FALSE //If TRUE, Sky Battles will use the exact mechanics from Pokémon XY. If FALSE, moves and Abilities that set Terrain, Toxic Spikes, or Spikes will not have those effects activate. + // Flag and Var settings #define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If TRUE, Overworld_ResetBattleFlagsAndVars will reset battle-related Flags and Vars when the player whites out. diff --git a/src/battle_util.c b/src/battle_util.c index 7a8feb19464c..01046f54734c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4103,18 +4103,18 @@ static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer) #else if ((!(gFieldStatuses & statusFlag) && (!gBattleStruct->rulesVariants.skyBattle))) #endif - { - gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); - gFieldStatuses |= statusFlag; + { + gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); + gFieldStatuses |= statusFlag; - if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER) - *timer = 8; - else - *timer = 5; + if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER) + *timer = 8; + else + *timer = 5; - gBattlerAttacker = gBattleScripting.battler = battler; - return TRUE; - } + gBattlerAttacker = gBattleScripting.battler = battler; + return TRUE; + } return FALSE; } From 2dd238f2df79019c8e3b8b6710bc9a65be33a5b8 Mon Sep 17 00:00:00 2001 From: PSF Date: Fri, 28 Apr 2023 20:43:51 -0700 Subject: [PATCH 21/34] Fixed debug script omission Fixed bug where Spikes did not set from Ceaseless Edge and Stone Axe --- data/scripts/debug.inc | 13 +++++++++++++ src/battle_script_commands.c | 10 ++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 92e9062a3963..dfbe55aa950e 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -67,6 +67,19 @@ Debug_FlagsNotSetBattleConfigMessage_Text: .string "Please define a usable flag in:\l" .string "'include/config/battle.h'!$" +Debug_FlagsAndVarNotSetBattleConfigMessage:: + lockall + message Debug_FlagsAndVarNotSetBattleConfigMessage_Text + waitmessage + waitbuttonpress + releaseall + end + +Debug_FlagsAndVarNotSetBattleConfigMessage_Text: + .string "Feature unavailable! Please define a\n" + .string "usable flag and a usable var in:\l" + .string "'include/config/battle.h'!$" + Debug_Script_1:: end diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cef0b7263f52..63b43c5433bd 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3858,11 +3858,13 @@ void SetMoveEffect(bool32 primary, u32 certain) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SPIKESSCATTERED; BattleScriptPush(gBattlescriptCurrInstr + 1); - #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE - gBattlescriptCurrInstr = BattleScript_SpikesActivates; - #else - gBattlescriptCurrInstr++; + + #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE + if (gBattleStruct->rulesVariants.skyBattle){ + gBattlescriptCurrInstr++; + }else #endif + gBattlescriptCurrInstr = BattleScript_SpikesActivates; } break; } From cca1b41e83e199008de412c49831bed36441ae92 Mon Sep 17 00:00:00 2001 From: PSF Date: Tue, 2 May 2023 20:06:05 -0700 Subject: [PATCH 22/34] Added FLAG_DISABLED_IN_SKY_BATTLE to Psychic Terrain --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 391b56f1ecf9..ed98c9964eff 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10653,7 +10653,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_DISABLED_IN_SKY_BATTLE, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPATK_UP_1, }, From e3814e13eeb6c672184ed81c901c061101a80a03 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Fri, 30 Jun 2023 10:36:24 -0700 Subject: [PATCH 23/34] Addressed DizzyEgg PR feedback --- include/battle_script_commands.h | 1 + include/debug.h | 2 +- src/battle_script_commands.c | 12 ++++++------ src/battle_setup.c | 19 ++----------------- src/battle_util.c | 7 ++++--- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index c527085b5d8e..059277c45163 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -20,6 +20,7 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi s8 GetInverseCritChance(u8 battlerAtk, u8 battlerDef, u32 move); u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move, u32 atkAbility, u32 defAbility, u32 atkHoldEffect, u32 defHoldEffect); u8 GetBattlerTurnOrderNum(u8 battlerId); +bool32 NoAliveMonsForPlayer(void); bool32 NoAliveMonsForEitherParty(void); void SetMoveEffect(bool32 primary, u32 certain); bool32 CanBattlerSwitch(u32 battlerId); diff --git a/include/debug.h b/include/debug.h index be71c7773ab9..64e0494a501b 100644 --- a/include/debug.h +++ b/include/debug.h @@ -2,6 +2,6 @@ #define GUARD_DEBUG_H void Debug_ShowMainMenu(void); -extern u8 Debug_FlagsAndVarNotSetBattleConfigMessage[]; +extern const u8 Debug_FlagsAndVarNotSetBattleConfigMessage[]; #endif // GUARD_DEBUG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5e78113ab3a0..6dba1f527e4e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4589,7 +4589,7 @@ static bool32 NoAliveMonsForPlayerAndPartner(void) } #endif -static bool32 NoAliveMonsForPlayer(void) +bool32 NoAliveMonsForPlayer(void) { u32 i; u32 HP_count = 0; @@ -12117,15 +12117,15 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr { gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); gProtectStructs[gActiveBattler].statRaised = TRUE; - + // check mirror herb for (index = 0; index < gBattlersCount; index++) { if (GetBattlerSide(index) == GetBattlerSide(gActiveBattler)) - continue; // Only triggers on opposing side + continue; // Only triggers on opposing side if (GetBattlerHoldEffect(index, TRUE) == HOLD_EFFECT_MIRROR_HERB && gBattleMons[index].statStages[statId] < MAX_STAT_STAGE) - { + { gProtectStructs[index].eatMirrorHerb = 1; gTotemBoosts[index].stats |= (1 << (statId - 1)); // -1 to start at atk gTotemBoosts[index].statChanges[statId - 1] = statValue; @@ -16319,7 +16319,7 @@ void BS_CheckParentalBondCounter(void) void BS_GetBattlerSide(void) { NATIVE_ARGS(u8 battler); - gBattleCommunication[0] = GetBattlerSide(GetBattlerForBattleScript(cmd->battler)); + gBattleCommunication[0] = GetBattlerSide(GetBattlerForBattleScript(cmd->battler)); gBattlescriptCurrInstr = cmd->nextInstr; } @@ -16345,7 +16345,7 @@ void BS_TrySymbiosis(void) gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; return; } - + gBattlescriptCurrInstr = cmd->nextInstr; } diff --git a/src/battle_setup.c b/src/battle_setup.c index 421f6ece0a6e..e38da8480ea9 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1355,26 +1355,11 @@ static void HandleBattleVariantParty(void) if (FlagGet(B_FLAG_SKY_BATTLE)) { SaveChangesToPlayerParty(); - LoadPlayerParty(); + LoadPlayerParty(); FlagClear(B_FLAG_SKY_BATTLE); } } -static bool8 PlayerHasHealthyPokemon(void){ - u8 i; - u8 partyCount; - - partyCount = CalculatePlayerPartyCount(); - for (i = 0; i < partyCount; i++) - { - if ((GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) > 0) && (!GetMonData(&gPlayerParty[i],MON_DATA_IS_EGG,NULL))) - { - return TRUE; - } - } - return FALSE; -} - static void CB2_EndTrainerBattle(void) { HandleBattleVariantParty(); @@ -1385,7 +1370,7 @@ static void CB2_EndTrainerBattle(void) } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { - if (InBattlePyramid() || InTrainerHillChallenge() || PlayerHasHealthyPokemon() ) + if (InBattlePyramid() || InTrainerHillChallenge() || (!NoAliveMonsForPlayer())) SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); else SetMainCallback2(CB2_WhiteOut); diff --git a/src/battle_util.c b/src/battle_util.c index 4944c720f077..309c5707e166 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10950,9 +10950,10 @@ bool32 IsAlly(u32 battlerAtk, u32 battlerDef) return (GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef)); } -bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon){ +bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon) +{ u16 species = GetMonData(pokemon, MON_DATA_SPECIES); - u8 monAbilityNum = GetMonData(pokemon, MON_DATA_ABILITY_NUM, NULL); + u16 monAbilityNum = GetMonData(pokemon, MON_DATA_ABILITY_NUM, NULL); bool8 hasLevitateAbility = gSpeciesInfo[species].abilities[monAbilityNum] == ABILITY_LEVITATE; bool8 isFlyingType = gSpeciesInfo[species].types[0] == TYPE_FLYING || gSpeciesInfo[species].types[1] == TYPE_FLYING; @@ -10997,4 +10998,4 @@ bool8 IsMonBannedFromSkyBattles(u16 species){ default: return FALSE; } -} \ No newline at end of file +} From d01ead17c3536aded2387caf043481094b14c6e1 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Fri, 30 Jun 2023 11:25:13 -0700 Subject: [PATCH 24/34] Forgot a file in last commit --- src/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index 9d87593425a6..64645f7b1b9a 100644 --- a/src/debug.c +++ b/src/debug.c @@ -280,7 +280,7 @@ static void DebugAction_OpenSubMenu(u8 taskId, struct ListMenuTemplate LMtemplat extern u8 Debug_FlagsNotSetOverworldConfigMessage[]; extern u8 Debug_FlagsNotSetBattleConfigMessage[]; -extern u8 Debug_FlagsAndVarNotSetBattleConfigMessage[]; +extern const u8 Debug_FlagsAndVarNotSetBattleConfigMessage[]; extern u8 Debug_Script_1[]; extern u8 Debug_Script_2[]; extern u8 Debug_Script_3[]; From dc3a6bd405e9fd359b7341dfd6d8c2b4e328643a Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sat, 8 Jul 2023 12:39:06 -0700 Subject: [PATCH 25/34] Addressed feedback from DizzyEggg --- include/battle.h | 7 +------ include/battle_script_commands.h | 2 +- include/battle_util.h | 2 +- src/battle_script_commands.c | 17 ++++------------- src/battle_util.c | 12 ++++++------ src/battle_util2.c | 2 +- 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/include/battle.h b/include/battle.h index b398b5504788..8936dcc92df5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -520,11 +520,6 @@ struct LostItem u16 stolen:1; }; -struct BattleRulesVariant -{ - bool8 skyBattle:1; -}; - struct BattleStruct { u8 turnEffectsTracker; @@ -672,7 +667,7 @@ struct BattleStruct bool8 trainerSlideMegaEvolutionMsgDone; bool8 trainerSlideZMoveMsgDone; bool8 trainerSlideBeforeFirstTurnMsgDone; - struct BattleRulesVariant rulesVariants; + u8 isSkyBattle:1; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index 059277c45163..fbaaa5011133 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -46,7 +46,7 @@ void StealTargetItem(u8 battlerStealer, u8 battlerItem); u8 GetCatchingBattler(void); u32 GetHighestStatId(u32 battlerId); bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType); -bool32 DoesSkyBattleCancelMove(u32 gCurrentMove); +bool32 isMoveNotAllowedInSkyBattles(u32 move); bool32 DoSwitchInAbilitiesItems(u32 battlerId); u8 GetFirstFaintedPartyIndex(u8 battlerId); diff --git a/include/battle_util.h b/include/battle_util.h index 8f16a983d478..8a0241badc21 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -239,7 +239,7 @@ void RemoveConfusionStatus(u8 battlerId); u8 GetBattlerGender(u8 battlerId); bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2); u32 CalcSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance); -bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon); +bool8 CanMonParticipateInSkyBattle(struct Pokemon *mon); bool8 IsMonBannedFromSkyBattles(u16 species); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5659903e4ce7..946dc90b8562 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1267,18 +1267,9 @@ bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType) return FALSE; } -bool32 DoesSkyBattleCancelCurrentMove(u32 gCurrentMove) +bool32 isMoveNotAllowedInSkyBattles(u32 move) { - bool8 moveBannedFromSkyBattles = FALSE; - - //if (gBattleMoves[gCurrentMove].flags & FLAG_DISABLED_IN_SKY_BATTLE) - if (gBattleMoves[gCurrentMove].skybattleBanned) - moveBannedFromSkyBattles = TRUE; - - if ((gBattleStruct->rulesVariants.skyBattle) && (moveBannedFromSkyBattles)){ - return TRUE; - } - return FALSE; + return ((gBattleStruct->isSkyBattle) && (gBattleMoves[gCurrentMove].skybattleBanned)); } static void Cmd_attackcanceler(void) @@ -1383,7 +1374,7 @@ static void Cmd_attackcanceler(void) } gHitMarker |= HITMARKER_OBEYS; - if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || (DoesSkyBattleCancelCurrentMove(gCurrentMove))) + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || (isMoveNotAllowedInSkyBattles(gCurrentMove))) { gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; if (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) @@ -3645,7 +3636,7 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE - if (gBattleStruct->rulesVariants.skyBattle){ + if (gBattleStruct->isSkyBattle){ gBattlescriptCurrInstr++; }else #endif diff --git a/src/battle_util.c b/src/battle_util.c index 8b571775d771..54074966771e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4014,7 +4014,7 @@ static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer) #if B_SKY_BATTLE_STRICT_MECHANICS == TRUE if (!(gFieldStatuses & statusFlag)) #else - if ((!(gFieldStatuses & statusFlag) && (!gBattleStruct->rulesVariants.skyBattle))) + if ((!(gFieldStatuses & statusFlag) && (!gBattleStruct->isSkyBattle))) #endif { gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); @@ -5648,7 +5648,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE - && (!gBattleStruct->rulesVariants.skyBattle) + && (!gBattleStruct->isSkyBattle) #endif && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && IS_MOVE_PHYSICAL(gCurrentMove) @@ -10899,14 +10899,14 @@ bool32 IsAlly(u32 battlerAtk, u32 battlerDef) return (GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef)); } -bool8 CanMonParticipateInSkyBattle(struct Pokemon* pokemon) +bool8 CanMonParticipateInSkyBattle(struct Pokemon *mon) { - u16 species = GetMonData(pokemon, MON_DATA_SPECIES); - u16 monAbilityNum = GetMonData(pokemon, MON_DATA_ABILITY_NUM, NULL); + u16 species = GetMonData(mon, MON_DATA_SPECIES); + u16 monAbilityNum = GetMonData(mon, MON_DATA_ABILITY_NUM, NULL); bool8 hasLevitateAbility = gSpeciesInfo[species].abilities[monAbilityNum] == ABILITY_LEVITATE; bool8 isFlyingType = gSpeciesInfo[species].types[0] == TYPE_FLYING || gSpeciesInfo[species].types[1] == TYPE_FLYING; - bool8 monIsValidAndNotEgg = GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG); + bool8 monIsValidAndNotEgg = GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(mon, MON_DATA_IS_EGG); if (monIsValidAndNotEgg) { diff --git a/src/battle_util2.c b/src/battle_util2.c index f852c952514c..c84ff4eae78a 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -20,7 +20,7 @@ void AllocateBattleResources(void) gBattleStruct = AllocZeroed(sizeof(*gBattleStruct)); #if B_FLAG_SKY_BATTLE - gBattleStruct->rulesVariants.skyBattle = FlagGet(B_FLAG_SKY_BATTLE); + gBattleStruct->isSkyBattle = FlagGet(B_FLAG_SKY_BATTLE); #endif gBattleResources = AllocZeroed(sizeof(*gBattleResources)); From be205f85e6e3ad325fa9c0ca830c52244f7db19d Mon Sep 17 00:00:00 2001 From: PSF Date: Sat, 8 Jul 2023 22:04:11 -0700 Subject: [PATCH 26/34] Address Lunos' PR feedback --- data/specials.inc | 2 +- include/battle_script_commands.h | 2 +- src/battle_script_commands.c | 4 ++-- src/battle_util.c | 9 +++++---- src/load_save.c | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/data/specials.inc b/data/specials.inc index f2d87bd4ac38..d0be7592b665 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -536,4 +536,4 @@ gSpecials:: def_special TrySetBattleTowerLinkType def_special SetTotemBoost def_special TrySpecialOverworldEvo - def_special TrySkyBattle + def_special TrySkyBattle \ No newline at end of file diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index fbaaa5011133..b4377aed3716 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -46,7 +46,7 @@ void StealTargetItem(u8 battlerStealer, u8 battlerItem); u8 GetCatchingBattler(void); u32 GetHighestStatId(u32 battlerId); bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType); -bool32 isMoveNotAllowedInSkyBattles(u32 move); +bool32 IsMoveNotAllowedInSkyBattles(u32 move); bool32 DoSwitchInAbilitiesItems(u32 battlerId); u8 GetFirstFaintedPartyIndex(u8 battlerId); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 946dc90b8562..c5134bb81cc3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1267,7 +1267,7 @@ bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType) return FALSE; } -bool32 isMoveNotAllowedInSkyBattles(u32 move) +bool32 IsMoveNotAllowedInSkyBattles(u32 move) { return ((gBattleStruct->isSkyBattle) && (gBattleMoves[gCurrentMove].skybattleBanned)); } @@ -1374,7 +1374,7 @@ static void Cmd_attackcanceler(void) } gHitMarker |= HITMARKER_OBEYS; - if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || (isMoveNotAllowedInSkyBattles(gCurrentMove))) + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) || (IsMoveNotAllowedInSkyBattles(gCurrentMove))) { gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; if (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) diff --git a/src/battle_util.c b/src/battle_util.c index 54074966771e..5d3b0e8415ae 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10916,9 +10916,10 @@ bool8 CanMonParticipateInSkyBattle(struct Pokemon *mon) return FALSE; } -bool8 IsMonBannedFromSkyBattles(u16 species){ - switch (species){ - case SPECIES_EGG: +bool8 IsMonBannedFromSkyBattles(u16 species) +{ + switch (species) + { #if B_SKY_BATTLE_STRICT_ELIGIBILITY == TRUE case SPECIES_SPEAROW: case SPECIES_FARFETCHD: @@ -10942,8 +10943,8 @@ bool8 IsMonBannedFromSkyBattles(u16 species){ case SPECIES_ROWLET: case SPECIES_PIKIPEK: #endif + case SPECIES_EGG: return TRUE; - break; default: return FALSE; } diff --git a/src/load_save.c b/src/load_save.c index 34c0918204f4..5556a470f2ad 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -182,9 +182,10 @@ void SaveChangesToPlayerParty(void) { u8 i = 0, j = 0; u8 participatedPokemon = VarGet(B_VAR_SKY_BATTLE); - - for (i = 0; i < PARTY_SIZE; i++){ - if ((participatedPokemon >> i & 1) == 1){ + for (i = 0; i < PARTY_SIZE; i++) + { + if ((participatedPokemon >> i & 1) == 1) + { gSaveBlock1Ptr->playerParty[i] = gPlayerParty[j]; j++; } From f17e2d60c5ea1344063775fc6f68fb8fc9e55606 Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Sun, 9 Jul 2023 06:03:57 -0700 Subject: [PATCH 27/34] Update specials.inc Added an empty line at the end of data/specials.inc --- data/specials.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/specials.inc b/data/specials.inc index d0be7592b665..f310cc9db182 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -536,4 +536,4 @@ gSpecials:: def_special TrySetBattleTowerLinkType def_special SetTotemBoost def_special TrySpecialOverworldEvo - def_special TrySkyBattle \ No newline at end of file + def_special TrySkyBattle From eb0a03499693a797ae9f8766c290fbdf06bd0774 Mon Sep 17 00:00:00 2001 From: PSF Date: Tue, 11 Jul 2023 09:38:55 -0700 Subject: [PATCH 28/34] Fixed spacing --- data/specials.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/data/specials.inc b/data/specials.inc index f310cc9db182..e4705779904a 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -537,3 +537,4 @@ gSpecials:: def_special SetTotemBoost def_special TrySpecialOverworldEvo def_special TrySkyBattle + From 9ef212fddfad52922ea088becc85b4f3c0978701 Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Wed, 19 Jul 2023 09:36:48 -0600 Subject: [PATCH 29/34] Apply suggestions from code review Co-authored-by: Eduardo Quezada D'Ottone --- data/scripts/debug.inc | 1 - include/battle.h | 2 +- include/pokemon.h | 2 +- src/battle_setup.c | 4 +++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 7975a61f29af..4c21bea920a9 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -61,7 +61,6 @@ Debug_FlagsNotSetBattleConfigMessage_Text: .string "Feature unavailable!\n" .string "Please define a usable flag in:\l" .string "'include/config/battle.h'!$" - Debug_BoxFilledMessage:: message Debug_BoxFilledMessage_Text goto Debug_MessageEnd diff --git a/include/battle.h b/include/battle.h index 795d0f1354ff..5417d4b232d1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -667,7 +667,7 @@ struct BattleStruct bool8 trainerSlideMegaEvolutionMsgDone; bool8 trainerSlideZMoveMsgDone; bool8 trainerSlideBeforeFirstTurnMsgDone; - u8 isSkyBattle:1; + bool8 isSkyBattle:1; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/pokemon.h b/include/pokemon.h index bc386f6dec8b..b30ad6e2d244 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -384,7 +384,7 @@ struct BattleMove u32 copycatBanned:1; u32 sleepTalkBanned:1; u32 instructBanned:1; - u32 skybattleBanned:1; + u32 skyBattleBanned:1; }; #define SPINDA_SPOT_WIDTH 16 diff --git a/src/battle_setup.c b/src/battle_setup.c index 115c189a722d..ffaf9be20518 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1417,14 +1417,16 @@ void BattleSetup_StartTrainerBattle_Debug(void) ScriptContext_Stop(); } -static void HandleBattleVariantParty(void) +static void HandleBattleVariantEndParty(void) { +#if B_FLAG_SKY_BATTLE != 0 if (FlagGet(B_FLAG_SKY_BATTLE)) { SaveChangesToPlayerParty(); LoadPlayerParty(); FlagClear(B_FLAG_SKY_BATTLE); } +#endif } static void CB2_EndTrainerBattle(void) From dd2eb71e842098bd534ac5a1ee25e72e6dc7aef7 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Wed, 19 Jul 2023 08:49:59 -0700 Subject: [PATCH 30/34] Updated skyBattleBanned and HandleBattleVariantEndParty to use correct names --- src/battle_script_commands.c | 2 +- src/battle_setup.c | 2 +- src/data/battle_moves.h | 94 ++++++++++++++++++------------------ 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0d99851e38fd..5de3e35bbd81 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1269,7 +1269,7 @@ bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType) bool32 IsMoveNotAllowedInSkyBattles(u32 move) { - return ((gBattleStruct->isSkyBattle) && (gBattleMoves[gCurrentMove].skybattleBanned)); + return ((gBattleStruct->isSkyBattle) && (gBattleMoves[gCurrentMove].skyBattleBanned)); } static void Cmd_attackcanceler(void) diff --git a/src/battle_setup.c b/src/battle_setup.c index ffaf9be20518..1c2865510a69 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1431,7 +1431,7 @@ static void HandleBattleVariantEndParty(void) static void CB2_EndTrainerBattle(void) { - HandleBattleVariantParty(); + HandleBattleVariantEndParty(); if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) { diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index ab321dc13bd6..50111c74bc11 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -373,7 +373,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_VINE_WHIP] = @@ -414,7 +414,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .makesContact = TRUE, .sheerForceBoost = TRUE, .minimizeDoubleDamage = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_DOUBLE_KICK] = @@ -603,7 +603,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .makesContact = TRUE, .sheerForceBoost = TRUE, .minimizeDoubleDamage = B_UPDATED_MOVE_FLAGS >= GEN_6, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_WRAP] = @@ -999,7 +999,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, .damagesUnderwater = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_ICE_BEAM] = @@ -1209,7 +1209,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_STRENGTH] = @@ -1562,7 +1562,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .ignoresKingsRock = B_UPDATED_MOVE_FLAGS < GEN_3, .damagesUnderground = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_FISSURE] = @@ -1578,7 +1578,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .damagesUnderground = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_DIG] = @@ -1600,7 +1600,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .makesContact = TRUE, .sleepTalkBanned = TRUE, .instructBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_TOXIC] = @@ -2833,7 +2833,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_RESET_STATS, .snatchAffected = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_STRUGGLE] = @@ -3316,7 +3316,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_DEF_UP_1, .magicCoatAffected = B_UPDATED_MOVE_FLAGS >= GEN_5, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_ZAP_CANNON] = @@ -3856,7 +3856,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .damagesUnderground = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_DYNAMIC_PUNCH] = @@ -4772,7 +4772,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, .snatchAffected = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_SUPERPOWER] = @@ -5021,7 +5021,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .makesContact = TRUE, .sleepTalkBanned = TRUE, .instructBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_ARM_THRUST] = @@ -5165,7 +5165,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_ICE_BALL] = @@ -5678,7 +5678,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, .sheerForceBoost = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_BULLET_SEED] = @@ -5812,7 +5812,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_BULK_UP] = @@ -5960,7 +5960,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_CALM_MIND] = @@ -6130,7 +6130,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPATK_UP_1, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_MIRACLE_EYE] = @@ -6676,7 +6676,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_DEF_UP_1, .magicCoatAffected = B_UPDATED_MOVE_FLAGS >= GEN_5, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_HEART_SWAP] = @@ -7077,7 +7077,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, .sheerForceBoost = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_SWITCHEROO] = @@ -7606,7 +7606,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_CHATTER] = @@ -8133,7 +8133,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .damagesAirborne = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_STORM_THROW] = @@ -8214,7 +8214,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .makesContact = TRUE, .danceMove = TRUE, .minimizeDoubleDamage = B_UPDATED_MOVE_FLAGS >= GEN_7, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_SYNCHRONOISE] = @@ -8759,7 +8759,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_FIRE_PLEDGE] = @@ -8778,7 +8778,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_GRASS_PLEDGE] = @@ -8797,7 +8797,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_VOLT_SWITCH] = @@ -8846,7 +8846,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .sheerForceBoost = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_FROST_BREATH] = @@ -9454,7 +9454,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .makesContact = TRUE, .minimizeDoubleDamage = TRUE, .gravityBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_MAT_BLOCK] = @@ -9473,7 +9473,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .snatchAffected = TRUE, .metronomeBanned = TRUE, .copycatBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_BELCH] = @@ -9509,7 +9509,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_ATK_UP_1, .ignoresProtect = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_STICKY_WEB] = @@ -9525,7 +9525,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPD_UP_1, .magicCoatAffected = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_FELL_STINGER] = @@ -9784,7 +9784,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_DEF_UP_1, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_MISTY_TERRAIN] = @@ -9799,7 +9799,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPDEF_UP_1, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_ELECTRIFY] = @@ -10124,7 +10124,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_ALL_STATS_UP_1, .sleepTalkBanned = TRUE, .instructBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_MAGNETIC_FLUX] = @@ -10168,7 +10168,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPD_UP_1, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_DAZZLING_GLEAM] = @@ -10330,7 +10330,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .damagesAirborne = TRUE, .ignoreTypeIfFlyingAndUngrounded = TRUE, .metronomeBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_THOUSAND_WAVES] = @@ -10346,7 +10346,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .metronomeBanned = TRUE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_LANDS_WRATH] = @@ -10361,7 +10361,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, - .skybattleBanned = TRUE, + .skyBattleBanned = TRUE, }, [MOVE_LIGHT_OF_RUIN] = @@ -11069,7 +11069,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_SHADOW_BONE] = @@ -11815,7 +11815,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, .metronomeBanned = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_DECORATE] = @@ -11864,7 +11864,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, .metronomeBanned = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_PYRO_BALL] = @@ -12173,7 +12173,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_SCALE_SHOT] = @@ -12251,7 +12251,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_RISING_VOLTAGE] = @@ -12761,7 +12761,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_CHLOROBLAST] = @@ -13192,7 +13192,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_POPULATION_BOMB] = @@ -13226,7 +13226,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, .argument = 1, // Remove the active field terrain if there is one. - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_GLAIVE_RUSH] = @@ -13919,7 +13919,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_PHYSICAL, .zMoveEffect = 0, - .skybattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE }, [MOVE_CONTINENTAL_CRUSH] = { From 2d0aa40d4acfcca07baeaf4dd7d05c95d573f2fb Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 24 Sep 2023 14:07:24 -0700 Subject: [PATCH 31/34] Removed STRICT_MOVES and STRICT_MECHANICS --- include/config/battle.h | 2 -- src/battle_script_commands.c | 2 -- src/battle_util.c | 6 ------ src/data/battle_moves.h | 20 ++++++++++---------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 4cc688b31713..8f851beb8668 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -170,8 +170,6 @@ #define B_VAR_SKY_BATTLE 0 // If this var has a value, the game will remember the positions of Pokémon used in Sky Battles. #define B_SKY_BATTLE_STRICT_ELIGIBILITY FALSE //If TRUE, Sky Battles will use the eligibility from Pokémon XY. If FALSE, all Flying-types or Pokémon with Levitate are allowed. -#define B_SKY_BATTLE_STRICT_MOVES FALSE //If TRUE, Sky Battles will use the banned moves from Pokémon XY. If FALSE, more moves that debuted after Pokémon XY are added. -#define B_SKY_BATTLE_STRICT_MECHANICS FALSE //If TRUE, Sky Battles will use the exact mechanics from Pokémon XY. If FALSE, moves and Abilities that set Terrain, Toxic Spikes, or Spikes will not have those effects activate. // Flag and Var settings #define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If TRUE, Overworld_ResetBattleFlagsAndVars will reset battle-related Flags and Vars when the player whites out. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index dab242862fe4..c7d122127b3a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3667,11 +3667,9 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SPIKESSCATTERED; BattleScriptPush(gBattlescriptCurrInstr + 1); - #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE if (gBattleStruct->isSkyBattle){ gBattlescriptCurrInstr++; }else - #endif gBattlescriptCurrInstr = BattleScript_SpikesActivates; } break; diff --git a/src/battle_util.c b/src/battle_util.c index f6fe99e8d9b6..9868ed20f02d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4049,11 +4049,7 @@ bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility) static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer) { -#if B_SKY_BATTLE_STRICT_MECHANICS == TRUE - if (!(gFieldStatuses & statusFlag)) -#else if ((!(gFieldStatuses & statusFlag) && (!gBattleStruct->isSkyBattle))) -#endif { gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); gFieldStatuses |= statusFlag; @@ -5708,9 +5704,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - #if B_SKY_BATTLE_STRICT_MECHANICS == FALSE && (!gBattleStruct->isSkyBattle) - #endif && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && IS_MOVE_PHYSICAL(gCurrentMove) && TARGET_TURN_DAMAGED diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index d9f1dfcdfa40..ab86338d899d 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9526,7 +9526,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_STATUS, .zMoveEffect = Z_EFFECT_SPD_UP_1, .magicCoatAffected = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_FELL_STINGER] = @@ -11070,7 +11070,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_SHADOW_BONE] = @@ -11816,7 +11816,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, .metronomeBanned = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_DECORATE] = @@ -11865,7 +11865,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, .metronomeBanned = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_PYRO_BALL] = @@ -12174,7 +12174,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_SCALE_SHOT] = @@ -12253,7 +12253,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_RISING_VOLTAGE] = @@ -12764,7 +12764,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_CHLOROBLAST] = @@ -13195,7 +13195,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_POPULATION_BOMB] = @@ -13230,7 +13230,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .zMoveEffect = Z_EFFECT_NONE, .makesContact = TRUE, .argument = 1, // Remove the active field terrain if there is one. - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_GLAIVE_RUSH] = @@ -13923,7 +13923,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .priority = 0, .split = SPLIT_PHYSICAL, .zMoveEffect = 0, - .skyBattleBanned = B_SKY_BATTLE_STRICT_MOVES == FALSE + .skyBattleBanned = TRUE, }, [MOVE_CONTINENTAL_CRUSH] = { From e5e37461244836af86cca20c3acd97fe7477a508 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 24 Sep 2023 14:12:50 -0700 Subject: [PATCH 32/34] Fixed minor spacing issues with merge --- src/battle_script_commands.c | 4 ++-- src/battle_util.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c7d122127b3a..b0e307ef2ee2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1377,8 +1377,8 @@ static void Cmd_attackcanceler(void) gHitMarker |= HITMARKER_OBEYS; // Check if no available target present on the field. - if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) - && (!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) || (IsMoveNotAllowedInSkyBattles(gCurrentMove))) + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove)) + && ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) || (IsMoveNotAllowedInSkyBattles(gCurrentMove)))) { if (gBattleMoves[gCurrentMove].effect == EFFECT_FLING) // Edge case for removing a mon's item when there is no target available after using Fling. gBattlescriptCurrInstr = BattleScript_FlingFailConsumeItem; diff --git a/src/battle_util.c b/src/battle_util.c index 9868ed20f02d..8ddc602fd8ba 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -11186,6 +11186,7 @@ bool32 IsGen6ExpShareEnabled(void) #else return FlagGet(I_EXP_SHARE_FLAG); #endif +} bool8 CanMonParticipateInSkyBattle(struct Pokemon *mon) { From 5f6a1b0a61a88080b052249e484d41c62111aeff Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Thu, 23 Nov 2023 14:42:28 -0800 Subject: [PATCH 33/34] Merged in upcoming --- src/battle_script_commands.c | 9 ++++----- src/battle_util.c | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f321ff774953..6bce7cc2121c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1368,11 +1368,10 @@ static void Cmd_attackcanceler(void) } gHitMarker |= HITMARKER_OBEYS; - // Check if no available target present on the field. - if ((NoTargetPresent(gBattlerAttacker, gCurrentMove)) - && (!gBattleMoves[gCurrentMove].twoTurnMove || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) - || IsMoveNotAllowedInSkyBattles(gCurrentMove) - ) + // Check if no available target present on the field or if Sky Battles ban the move + if ((NoTargetPresent(gBattlerAttacker, gCurrentMove) + && (!gBattleMoves[gCurrentMove].twoTurnMove || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))) + || (IsMoveNotAllowedInSkyBattles(gCurrentMove))) { if (gBattleMoves[gCurrentMove].effect == EFFECT_FLING) // Edge case for removing a mon's item when there is no target available after using Fling. gBattlescriptCurrInstr = BattleScript_FlingFailConsumeItem; diff --git a/src/battle_util.c b/src/battle_util.c index 1e4c6085253a..218d6c03601a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -11312,6 +11312,7 @@ bool8 IsMonBannedFromSkyBattles(u16 species) default: return FALSE; } +} u8 GetBattlerType(u32 battler, u8 typeIndex) { From fca1d479750551aa9384927a93684fc04a40ff46 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Fri, 24 Nov 2023 09:37:36 -0800 Subject: [PATCH 34/34] Implemented feedback from Jasper https://github.com/rh-hideout/pokeemerald-expansion/pull/2950/files/5da6117d1bc725900c6386e62ab719f8e1695027 --- data/scripts/debug.inc | 1 + data/specials.inc | 2 +- include/load_save.h | 1 - src/battle_script_commands.c | 4 ++-- src/battle_setup.c | 27 ++++++++++++++++++++------- src/field_specials.c | 12 ++++++------ src/load_save.c | 14 -------------- 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 31dad79ceedb..573b60d457c2 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -87,6 +87,7 @@ Debug_FlagsNotSetBattleConfigMessage_Text: .string "Feature unavailable!\n" .string "Please define a usable flag in:\l" .string "'include/config/battle.h'!$" + Debug_BoxFilledMessage:: message Debug_BoxFilledMessage_Text goto Debug_MessageEnd diff --git a/data/specials.inc b/data/specials.inc index 434cdffb4f2a..34e86cad29f9 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -539,4 +539,4 @@ gSpecials:: def_special GetNumberSprayStrength def_special GetSprayId def_special GetLastUsedSprayType - def_special TrySkyBattle + def_special TrySkyBattle diff --git a/include/load_save.h b/include/load_save.h index fad3e913d1f3..389bd5a2b925 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -46,7 +46,6 @@ void SetContinueGameWarpStatusToDynamicWarp(void); void ClearContinueGameWarpStatus2(void); void SavePlayerParty(void); void LoadPlayerParty(void); -void SaveChangesToPlayerParty(void); void SaveObjectEvents(void); void LoadObjectEvents(void); void CopyPartyAndObjectsToSave(void); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6bce7cc2121c..d04d0ac314f0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3602,9 +3602,9 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SPIKESSCATTERED; BattleScriptPush(gBattlescriptCurrInstr + 1); - if (gBattleStruct->isSkyBattle){ + if (gBattleStruct->isSkyBattle) gBattlescriptCurrInstr++; - }else + else gBattlescriptCurrInstr = BattleScript_SpikesActivates; } break; diff --git a/src/battle_setup.c b/src/battle_setup.c index 7f0344b2a36a..72a41aca9ce2 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -82,6 +82,8 @@ static void TryUpdateGymLeaderRematchFromTrainer(void); static void CB2_GiveStarter(void); static void CB2_StartFirstBattle(void); static void CB2_EndFirstBattle(void); +static void SaveChangesToPlayerParty(void); +static void HandleBattleVariantEndParty(void); static void CB2_EndTrainerBattle(void); static bool32 IsPlayerDefeated(u32 battleOutcome); static u16 GetRematchTrainerId(u16 trainerId); @@ -1381,16 +1383,27 @@ void BattleSetup_StartTrainerBattle_Debug(void) ScriptContext_Stop(); } -static void HandleBattleVariantEndParty(void) +static void SaveChangesToPlayerParty(void) { -#if B_FLAG_SKY_BATTLE != 0 - if (FlagGet(B_FLAG_SKY_BATTLE)) + u8 i = 0, j = 0; + u8 participatedPokemon = VarGet(B_VAR_SKY_BATTLE); + for (i = 0; i < PARTY_SIZE; i++) { - SaveChangesToPlayerParty(); - LoadPlayerParty(); - FlagClear(B_FLAG_SKY_BATTLE); + if ((participatedPokemon >> i & 1) == 1) + { + gSaveBlock1Ptr->playerParty[i] = gPlayerParty[j]; + j++; + } } -#endif +} + +static void HandleBattleVariantEndParty(void) +{ + if (B_FLAG_SKY_BATTLE == 0 || !FlagGet(B_FLAG_SKY_BATTLE)) + return; + SaveChangesToPlayerParty(); + LoadPlayerParty(); + FlagClear(B_FLAG_SKY_BATTLE); } static void CB2_EndTrainerBattle(void) diff --git a/src/field_specials.c b/src/field_specials.c index 0f205712e75f..c4968a6cc827 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -4212,16 +4212,17 @@ u8 Script_TryGainNewFanFromCounter(void) void TrySkyBattle(void) { -#if B_VAR_SKY_BATTLE == 0 || B_FLAG_SKY_BATTLE == 0 - LockPlayerFieldControls(); - ScriptContext_SetupScript(Debug_FlagsAndVarNotSetBattleConfigMessage); -#else int i; + if (B_VAR_SKY_BATTLE == 0 || B_FLAG_SKY_BATTLE == 0) + { + LockPlayerFieldControls(); + ScriptContext_SetupScript(Debug_FlagsAndVarNotSetBattleConfigMessage); + return; + } for (i = 0; i < CalculatePlayerPartyCount(); i++) { struct Pokemon* pokemon = &gPlayerParty[i]; - if (CanMonParticipateInSkyBattle(pokemon) && GetMonData(pokemon, MON_DATA_HP, NULL) > 0) { PreparePartyForSkyBattle(); @@ -4230,7 +4231,6 @@ void TrySkyBattle(void) } } gSpecialVar_Result = FALSE; -#endif } void PreparePartyForSkyBattle(void) diff --git a/src/load_save.c b/src/load_save.c index 5556a470f2ad..4f706180c4e6 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -178,20 +178,6 @@ void LoadPlayerParty(void) gPlayerParty[i] = gSaveBlock1Ptr->playerParty[i]; } -void SaveChangesToPlayerParty(void) -{ - u8 i = 0, j = 0; - u8 participatedPokemon = VarGet(B_VAR_SKY_BATTLE); - for (i = 0; i < PARTY_SIZE; i++) - { - if ((participatedPokemon >> i & 1) == 1) - { - gSaveBlock1Ptr->playerParty[i] = gPlayerParty[j]; - j++; - } - } -} - void SaveObjectEvents(void) { int i;