Skip to content

Commit

Permalink
Replaced B_FLAG_SKY_BATTLE checks with rulesVariants.skyBattle checks
Browse files Browse the repository at this point in the history
  • Loading branch information
pkmnsnfrn committed Apr 29, 2023
1 parent f3584a0 commit aec9817
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 14 deletions.
62 changes: 62 additions & 0 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -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.$"
4 changes: 2 additions & 2 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/battle_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ void BattleSetup_StartTrainerBattle(void)
ScriptContext_Stop();
}

static void HandleSpecialBattleParty(void)
static void HandleBattleVariantParty(void)
{
if (FlagGet(B_FLAG_SKY_BATTLE))
{
Expand All @@ -1377,7 +1377,7 @@ static bool8 PlayerHasHealthyPokemon(void){

static void CB2_EndTrainerBattle(void)
{
HandleSpecialBattleParty();
HandleBattleVariantParty();

if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
{
Expand Down
4 changes: 2 additions & 2 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions src/field_specials.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit aec9817

Please sign in to comment.