From 67fefd0261ff0f2b11f26829ecfa3622d05eabf0 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 13 Dec 2020 19:42:48 -0700 Subject: [PATCH 1/7] var terrain, surge fixes --- data/battle_anim_scripts.s | 16 ---------- data/battle_scripts_1.s | 16 +++++++--- include/battle.h | 1 + include/battle_scripts.h | 1 + include/battle_util.h | 1 + include/constants/battle.h | 25 ++++++++-------- include/constants/battle_anim.h | 12 +++----- include/constants/battle_config.h | 5 ++++ src/battle_interface.c | 5 +--- src/battle_main.c | 6 ++++ src/battle_script_commands.c | 7 +++-- src/battle_util.c | 50 +++++++++++++++++++++++++++---- 12 files changed, 94 insertions(+), 51 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index cf11f4d6ae..1cd25477fd 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -808,10 +808,6 @@ gBattleAnims_General:: .4byte General_IngrainHeal .4byte General_WishHeal .4byte General_MegaEvolution - .4byte General_TerrainMisty - .4byte General_TerrainGrassy - .4byte General_TerrainElectric - .4byte General_TerrainPsychic .4byte General_IllusionOff .4byte General_FormChange .4byte General_SlideOffScreen @@ -24319,18 +24315,6 @@ MegaEvolutionParticles: delay 3 return -General_TerrainMisty: - end - -General_TerrainGrassy: - end - -General_TerrainElectric: - end - -General_TerrainPsychic: - end - General_RestoreBg: restorebg waitbgfadein diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0ccaa7ef64..9811a2fba9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5386,6 +5386,12 @@ BattleScript_OverworldWeatherStarts:: playanimation2 BS_ATTACKER, sB_ANIM_ARG1, NULL end3 +BattleScript_OverworldTerrain:: + printfromtable gTerrainStringIds + waitmessage 0x40 + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL + end3 + BattleScript_SideStatusWoreOff:: printstring STRINGID_PKMNSXWOREOFF waitmessage 0x40 @@ -6823,7 +6829,7 @@ BattleScript_ElectricSurgeActivates:: call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESELECTRIC waitstate - playanimation BS_SCRIPTING, B_ANIM_TERRAIN_ELECTRIC, NULL + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 BattleScript_MistySurgeActivates:: @@ -6831,7 +6837,7 @@ BattleScript_MistySurgeActivates:: call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESMISTY waitstate - playanimation BS_SCRIPTING, B_ANIM_TERRAIN_MISTY, NULL + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 BattleScript_GrassySurgeActivates:: @@ -6839,7 +6845,7 @@ BattleScript_GrassySurgeActivates:: call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESGRASSY waitstate - playanimation BS_SCRIPTING, B_ANIM_TERRAIN_GRASSY, NULL + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 BattleScript_PsychicSurgeActivates:: @@ -6847,7 +6853,7 @@ BattleScript_PsychicSurgeActivates:: call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESPSYCHIC waitstate - playanimation BS_SCRIPTING, B_ANIM_TERRAIN_PSYCHIC, NULL + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 BattleScript_BadDreamsActivates:: @@ -7035,7 +7041,9 @@ BattleScript_GrassyTerrainLoopIncrement:: jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_GrassyTerrainLoop BattleScript_GrassyTerrainLoopEnd:: bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_PERMANENT, BattleScript_GrassyTerrainHealEnd jumpifbyte CMP_EQUAL, gFieldTimers + 5, 0x0, BattleScript_GrassyTerrainEnds +BattleScript_GrassyTerrainHealEnd: end2 BattleScript_AbilityNoSpecificStatLoss:: diff --git a/include/battle.h b/include/battle.h index 488e0fc51c..f43220e9b1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -503,6 +503,7 @@ struct BattleStruct u8 wishPerishSongState; u8 wishPerishSongBattlerId; bool8 overworldWeatherDone; + bool8 terrainDone; u8 atkCancellerTracker; struct BattleTvMovePoints tvMovePoints; struct BattleTv tv; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3566a1c4d2..980dde468a 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -48,6 +48,7 @@ extern const u8 BattleScript_SandStormHailEnds[]; extern const u8 BattleScript_SunlightContinues[]; extern const u8 BattleScript_SunlightFaded[]; extern const u8 BattleScript_OverworldWeatherStarts[]; +extern const u8 BattleScript_OverworldTerrain[]; extern const u8 BattleScript_SideStatusWoreOff[]; extern const u8 BattleScript_SafeguardProtected[]; extern const u8 BattleScript_SafeguardEnds[]; diff --git a/include/battle_util.h b/include/battle_util.h index f7699fceda..0637e80f77 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -23,6 +23,7 @@ #define ABILITYEFFECT_TRACE1 0xC #define ABILITYEFFECT_TRACE2 0xD #define ABILITYEFFECT_MOVE_END_OTHER 0xE +#define ABILITYEFFECT_SWITCH_IN_TERRAIN 0xFE #define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF #define ITEMEFFECT_ON_SWITCH_IN 0x0 diff --git a/include/constants/battle.h b/include/constants/battle.h index 40c604c9ed..7ea1e5e483 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -221,18 +221,19 @@ #define SIDE_STATUS_MAT_BLOCK (1 << 21) // Field affecting statuses. -#define STATUS_FIELD_MAGIC_ROOM 0x1 -#define STATUS_FIELD_TRICK_ROOM 0x2 -#define STATUS_FIELD_WONDER_ROOM 0x4 -#define STATUS_FIELD_MUDSPORT 0x8 -#define STATUS_FIELD_WATERSPORT 0x10 -#define STATUS_FIELD_GRAVITY 0x20 -#define STATUS_FIELD_GRASSY_TERRAIN 0x40 -#define STATUS_FIELD_MISTY_TERRAIN 0x80 -#define STATUS_FIELD_ELECTRIC_TERRAIN 0x100 -#define STATUS_FIELD_PSYCHIC_TERRAIN 0x200 -#define STATUS_FIELD_ION_DELUGE 0x400 -#define STATUS_FIELD_FAIRY_LOCK 0x800 +#define STATUS_FIELD_MAGIC_ROOM (1 << 0) +#define STATUS_FIELD_TRICK_ROOM (1 << 1) +#define STATUS_FIELD_WONDER_ROOM (1 << 2) +#define STATUS_FIELD_MUDSPORT (1 << 3) +#define STATUS_FIELD_WATERSPORT (1 << 4) +#define STATUS_FIELD_GRAVITY (1 << 5) +#define STATUS_FIELD_GRASSY_TERRAIN (1 << 6) +#define STATUS_FIELD_MISTY_TERRAIN (1 << 7) +#define STATUS_FIELD_ELECTRIC_TERRAIN (1 << 8) +#define STATUS_FIELD_PSYCHIC_TERRAIN (1 << 9) +#define STATUS_FIELD_ION_DELUGE (1 << 10) +#define STATUS_FIELD_FAIRY_LOCK (1 << 11) +#define STATUS_FIELD_TERRAIN_PERMANENT (1 << 12) // Overworld thunderstorm generates electric terrain #define STATUS_TERRAIN_ANY (STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN) diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 4066060505..025b9e310c 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -518,14 +518,10 @@ #define B_ANIM_INGRAIN_HEAL 0x15 #define B_ANIM_WISH_HEAL 0x16 #define B_ANIM_MEGA_EVOLUTION 0x17 -#define B_ANIM_TERRAIN_MISTY 0x18 -#define B_ANIM_TERRAIN_GRASSY 0x19 -#define B_ANIM_TERRAIN_ELECTRIC 0x1A -#define B_ANIM_TERRAIN_PSYCHIC 0x1B -#define B_ANIM_ILLUSION_OFF 0x1C -#define B_ANIM_FORM_CHANGE 0x1D -#define B_ANIM_SLIDE_OFFSCREEN 0x1E // for Emergency Exit -#define B_ANIM_RESTORE_BG 0x1F // for Terrain Endings +#define B_ANIM_ILLUSION_OFF 0x18 +#define B_ANIM_FORM_CHANGE 0x19 +#define B_ANIM_SLIDE_OFFSCREEN 0x1A // for Emergency Exit +#define B_ANIM_RESTORE_BG 0x1B // for Terrain Endings, Surge abilities // special animations table #define B_ANIM_LVL_UP 0x0 diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index be58ba7e74..df255ac59d 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -131,6 +131,10 @@ #define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. #define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles. +// Var Settings +// To use the following features in scripting, replace the 0s with the Var ID you're assigning to it. Eg: replace VAR_UNUSED_0x40F7 with VAR_TERRAIN for that feature +#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 + // Interface settings #define B_ABILITY_POP_UP TRUE // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle. #define B_FAST_INTRO TRUE // If set to TRUE, battle intro texts print at the same time as animation of a Pokémon, as opposing to waiting for the animation to end. @@ -147,6 +151,7 @@ #define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric-type Pokémon can't be paralyzed. #define B_POWDER_GRASS GEN_6 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves. #define B_STEEL_RESISTANCES GEN_6 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark and Ghost moves. +#define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/battle_interface.c b/src/battle_interface.c index 267b06ece1..9a0b98618f 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -965,10 +965,7 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 case B_ANIM_WISH_HEAL: //new case B_ANIM_MEGA_EVOLUTION: - case B_ANIM_TERRAIN_MISTY: - case B_ANIM_TERRAIN_GRASSY: - case B_ANIM_TERRAIN_ELECTRIC: - case B_ANIM_TERRAIN_PSYCHIC: + case B_ANIM_RESTORE_BG: break; } return; //all other special anims dont hide diff --git a/src/battle_main.c b/src/battle_main.c index 48129c5230..d9b3757f0e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3483,6 +3483,12 @@ static void TryDoEventsBeforeFirstTurn(void) gBattleStruct->overworldWeatherDone = TRUE; return; } + if (!gBattleStruct->terrainDone && AbilityBattleEffects(0, 0, 0, ABILITYEFFECT_SWITCH_IN_TERRAIN, 0) != 0) + { + gBattleStruct->terrainDone = TRUE; + return; + } + // Check all switch in abilities happening from the fastest mon to slowest. while (gBattleStruct->switchInAbilitiesCounter < gBattlersCount) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c1587f0940..df46f35a2d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6937,8 +6937,11 @@ static void HandleTerrainMove(u32 moveEffect) gBattleCommunication[MULTISTRING_CHOOSER] = 1; break; case EFFECT_ELECTRIC_TERRAIN: - statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.electricTerrainTimer; - gBattleCommunication[MULTISTRING_CHOOSER] = 2; + if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)) + { + statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.electricTerrainTimer; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } break; case EFFECT_PSYCHIC_TERRAIN: statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.psychicTerrainTimer; diff --git a/src/battle_util.c b/src/battle_util.c index b929b7499d..bff9c1d75d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1988,16 +1988,18 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnCountersTracker++; break; case ENDTURN_ELECTRIC_TERRAIN: - if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && --gFieldTimers.electricTerrainTimer == 0) + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN + && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0)) { - gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN); + gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT); BattleScriptExecute(BattleScript_ElectricTerrainEnds); effect++; } gBattleStruct->turnCountersTracker++; break; case ENDTURN_MISTY_TERRAIN: - if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN && --gFieldTimers.mistyTerrainTimer == 0) + if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN + && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN); BattleScriptExecute(BattleScript_MistyTerrainEnds); @@ -2008,15 +2010,18 @@ u8 DoFieldEndTurnEffects(void) case ENDTURN_GRASSY_TERRAIN: if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN) { - if (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0) + if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) + && (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0)) gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN); + BattleScriptExecute(BattleScript_GrassyTerrainHeals); effect++; } gBattleStruct->turnCountersTracker++; break; case ENDTURN_PSYCHIC_TERRAIN: - if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && --gFieldTimers.psychicTerrainTimer == 0) + if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN + && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN); BattleScriptExecute(BattleScript_PsychicTerrainEnds); @@ -3602,6 +3607,41 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattleScripting.battler = battler; switch (gLastUsedAbility) { + case ABILITYEFFECT_SWITCH_IN_TERRAIN: + if (VarGet(VAR_TERRAIN) & STATUS_TERRAIN_ANY) + { + u16 terrainFlags = VarGet(VAR_TERRAIN) & STATUS_TERRAIN_ANY; // only works for status flag (1 << 15) + gFieldStatuses = terrainFlags | STATUS_FIELD_TERRAIN_PERMANENT; // terrain is permanent + switch (VarGet(VAR_TERRAIN) & STATUS_TERRAIN_ANY) + { + case STATUS_FIELD_ELECTRIC_TERRAIN: + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + break; + case STATUS_FIELD_MISTY_TERRAIN: + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + break; + case STATUS_FIELD_GRASSY_TERRAIN: + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + break; + case STATUS_FIELD_PSYCHIC_TERRAIN: + gBattleCommunication[MULTISTRING_CHOOSER] = 3; + break; + } + + BattleScriptPushCursorAndCallback(BattleScript_OverworldTerrain); + effect++; + } + #if B_THUNDERSTORM_TERRAIN == TRUE + else if (GetCurrentWeather() == WEATHER_RAIN_THUNDERSTORM && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)) + { + // drizzle started rain, so just do electric terrain anim + gFieldStatuses = (STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT); + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + BattleScriptPushCursorAndCallback(BattleScript_OverworldTerrain); + effect++; + } + #endif + break; case ABILITYEFFECT_SWITCH_IN_WEATHER: if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) { From 9c64635ebe4c5621a5362a6672273024e7591376 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 13 Dec 2020 19:50:02 -0700 Subject: [PATCH 2/7] remove redundant permanent terrain check --- src/battle_script_commands.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index df46f35a2d..c1587f0940 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6937,11 +6937,8 @@ static void HandleTerrainMove(u32 moveEffect) gBattleCommunication[MULTISTRING_CHOOSER] = 1; break; case EFFECT_ELECTRIC_TERRAIN: - if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)) - { - statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.electricTerrainTimer; - gBattleCommunication[MULTISTRING_CHOOSER] = 2; - } + statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.electricTerrainTimer; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; break; case EFFECT_PSYCHIC_TERRAIN: statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.psychicTerrainTimer; From 09496abef0101ce2e8eaf3d1e8dfddd1969fb8eb Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 14 Dec 2020 08:59:57 -0700 Subject: [PATCH 3/7] reset VAR_TERRAIN on whiteout --- src/overworld.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/overworld.c b/src/overworld.c index 223e6e1522..2fac455a3c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -403,6 +403,9 @@ static void Overworld_ResetStateAfterWhiteOut(void) FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_USE_STRENGTH); FlagClear(FLAG_SYS_USE_FLASH); + #if VAR_TERRAIN != 0 + VarSet(VAR_TERRAIN, 0); + #endif // If you were defeated by Kyogre/Groudon and the step counter has // maxed out, end the abnormal weather. if (VarGet(VAR_SHOULD_END_ABNORMAL_WEATHER) == 1) From d26605c9fe124906baf58270a4e65401d01d71b8 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 13 Jan 2021 16:01:47 -0700 Subject: [PATCH 4/7] fix bad bg fade if no permanent terrain --- data/battle_anim_scripts.s | 8 -------- data/battle_scripts_1.s | 9 +++++---- data/event_scripts.s | 1 + include/constants/battle_anim.h | 14 +++++--------- include/constants/battle_config.h | 4 ++-- src/battle_script_commands.c | 9 +++++++++ 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 59ab539028..24f05d6e63 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -8474,8 +8474,6 @@ Move_GRASSY_TERRAIN:: delay 4 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(31, 24, 31) waitforvisualfinish - restorebg - waitbgfadein end Move_MISTY_TERRAIN:: @@ -8514,8 +8512,6 @@ Move_MISTY_TERRAIN:: delay 4 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 7, 0, RGB(31, 24, 31) waitforvisualfinish - restorebg - waitbgfadein end Move_ELECTRIFY:: @@ -9399,8 +9395,6 @@ Move_ELECTRIC_TERRAIN:: delay 2 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(28, 28, 0) waitforvisualfinish - restorebg - waitbgfadein end Move_DAZZLING_GLEAM:: @@ -11056,8 +11050,6 @@ Move_PSYCHIC_TERRAIN:: delay 4 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(27, 0, 13) waitforvisualfinish - restorebg - waitbgfadein end Move_LUNGE:: diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5a7af4fb87..28644edf7c 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1520,6 +1520,7 @@ BattleScript_EffectPsychicTerrain: waitanimation printfromtable gTerrainStringIds waitmessage 0x40 + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL goto BattleScript_MoveEnd BattleScript_EffectTopsyTurvy: @@ -6893,7 +6894,7 @@ BattleScript_ElectricSurgeActivates:: pause 0x20 call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESELECTRIC - waitstate + waitmessage 0x40 playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 @@ -6901,7 +6902,7 @@ BattleScript_MistySurgeActivates:: pause 0x20 call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESMISTY - waitstate + waitmessage 0x40 playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 @@ -6909,7 +6910,7 @@ BattleScript_GrassySurgeActivates:: pause 0x20 call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESGRASSY - waitstate + waitmessage 0x40 playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 @@ -6917,7 +6918,7 @@ BattleScript_PsychicSurgeActivates:: pause 0x20 call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESPSYCHIC - waitstate + waitmessage 0x40 playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL end3 diff --git a/data/event_scripts.s b/data/event_scripts.s index 8039be6876..f22377aa27 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -2,6 +2,7 @@ #include "constants/apprentice.h" #include "constants/battle.h" #include "constants/battle_arena.h" +#include "constants/battle_config.h" #include "constants/battle_dome.h" #include "constants/battle_factory.h" #include "constants/battle_frontier.h" diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 90766f9d59..6d32abfa8c 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -518,15 +518,11 @@ #define B_ANIM_INGRAIN_HEAL 0x15 #define B_ANIM_WISH_HEAL 0x16 #define B_ANIM_MEGA_EVOLUTION 0x17 -#define B_ANIM_TERRAIN_MISTY 0x18 -#define B_ANIM_TERRAIN_GRASSY 0x19 -#define B_ANIM_TERRAIN_ELECTRIC 0x1A -#define B_ANIM_TERRAIN_PSYCHIC 0x1B -#define B_ANIM_ILLUSION_OFF 0x1C -#define B_ANIM_FORM_CHANGE 0x1D -#define B_ANIM_SLIDE_OFFSCREEN 0x1E // for Emergency Exit -#define B_ANIM_RESTORE_BG 0x1F // for Terrain Endings -#define B_ANIM_TOTEM_FLARE 0x20 // Totem boosts aura flare +#define B_ANIM_ILLUSION_OFF 0x18 +#define B_ANIM_FORM_CHANGE 0x19 +#define B_ANIM_SLIDE_OFFSCREEN 0x1A // for Emergency Exit +#define B_ANIM_RESTORE_BG 0x1B // for Terrain Endings +#define B_ANIM_TOTEM_FLARE 0x1C // Totem boosts aura flare // special animations table #define B_ANIM_LVL_UP 0x0 diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 0c063f2fbc..5b4a895f50 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -135,7 +135,7 @@ // Var Settings // To use the following features in scripting, replace the 0s with the Var ID you're assigning to it. Eg: replace VAR_UNUSED_0x40F7 with VAR_TERRAIN for that feature -#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 VAR_TERRAIN VAR_UNUSED_0x40F7 // 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 // Interface settings #define B_ABILITY_POP_UP TRUE // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle. @@ -173,7 +173,7 @@ #define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. #define HIDE_HEALTHBOXES_DURING_ANIMS TRUE // If set to TRUE, hides healthboxes during move animations -#define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. +#define B_TERRAIN_BG_CHANGE FALSE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. #define B_ENABLE_DEBUG TRUE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6c5f37a7d4..c86691cd89 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4403,6 +4403,15 @@ static void Cmd_playanimation(void) gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); argumentPtr = T2_READ_PTR(gBattlescriptCurrInstr + 3); + + #if B_TERRAIN_BG_CHANGE == FALSE + if (gBattlescriptCurrInstr[2] == B_ANIM_RESTORE_BG) + { + // workaround for .if not working + gBattlescriptCurrInstr += 7; + return; + } + #endif if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE || gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE From d571c8b02806dcaa265e743e27e956ef02e2adaf Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 13 Jan 2021 16:02:32 -0700 Subject: [PATCH 5/7] B_TERRAIN_BG_CHANGE TRUE by default --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 5b4a895f50..42eeb592aa 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -173,7 +173,7 @@ #define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. #define HIDE_HEALTHBOXES_DURING_ANIMS TRUE // If set to TRUE, hides healthboxes during move animations -#define B_TERRAIN_BG_CHANGE FALSE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. +#define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. #define B_ENABLE_DEBUG TRUE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H From b576eb5247d84e98781da7bf463e5ed82d94ab0f Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 19 Jan 2021 13:26:36 -0700 Subject: [PATCH 6/7] fix var_terrain default, wording --- include/constants/battle_config.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 42eeb592aa..b192db7cfa 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -134,8 +134,9 @@ #define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles. // Var Settings -// To use the following features in scripting, replace the 0s with the Var ID you're assigning to it. Eg: replace VAR_UNUSED_0x40F7 with VAR_TERRAIN for that feature -#define VAR_TERRAIN VAR_UNUSED_0x40F7 // 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 +// To use the following features in scripting, replace the 0s with the var ID you're assigning it to. +// Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature. +#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 // Interface settings #define B_ABILITY_POP_UP TRUE // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle. From 9d9da6a485cf5176b920debf80046f8d73045352 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Tue, 19 Jan 2021 15:01:51 -0700 Subject: [PATCH 7/7] Update include/constants/battle_config.h Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index b192db7cfa..8d3f48080a 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -136,7 +136,7 @@ // Var Settings // To use the following features in scripting, replace the 0s with the var ID you're assigning it to. // Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature. -#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 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 // Interface settings #define B_ABILITY_POP_UP TRUE // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle.