diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 994cf4d52..a882a0315 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2010,6 +2010,14 @@ .4byte \ptr .endm + .macro activateweatherabilities battler:req + various \battler, VARIOUS_ACTIVATE_WEATHER_ABILITIES + .endm + + .macro activateterrainabilities battler:req + various \battler, VARIOUS_ACTIVATE_TERRAIN_ABILITIES + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 01ef1fdd3..722619c3b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -410,7 +410,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectCourtChange @ EFFECT_COURT_CHANGE .4byte BattleScript_EffectSteelBeam @ EFFECT_STEEL_BEAM .4byte BattleScript_EffectExtremeEvoboost @ EFFECT_EXTREME_EVOBOOST - .4byte BattleScript_EffectTerrainHit @ EFFECT_DAMAGE_SET_TERRAIN + .4byte BattleScript_EffectHitSetRemoveTerrain @ EFFECT_HIT_SET_REMOVE_TERRAIN .4byte BattleScript_EffectDarkVoid @ EFFECT_DARK_VOID .4byte BattleScript_EffectSleepHit @ EFFECT_SLEEP_HIT .4byte BattleScript_EffectDoubleShock @ EFFECT_DOUBLE_SHOCK @@ -2456,6 +2456,7 @@ BattleScript_EffectPsychicTerrain: printfromtable gTerrainStringIds waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop jumpifabilitypresent ABILITY_MIMICRY, BattleScript_ApplyMimicry goto BattleScript_MoveEnd @@ -4975,9 +4976,20 @@ BattleScript_MoveWeatherChange:: printfromtable gMoveWeatherChangeStringIds waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges - call BattleScript_ActivateSwitchInAbilities + call BattleScript_ActivateWeatherAbilities goto BattleScript_MoveEnd +BattleScript_ActivateWeatherAbilities: + copybyte sBATTLER, gBattlerAttacker + setbyte gBattlerAttacker, 0 +BattleScript_ActivateWeatherAbilities_Loop: + activateweatherabilities BS_ATTACKER +BattleScript_ActivateWeatherAbilities_Increment: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateWeatherAbilities_Loop + copybyte gBattlerAttacker, sBATTLER + return + BattleScript_EffectSunnyDay:: attackcanceler attackstring @@ -7150,6 +7162,7 @@ BattleScript_SeedSowerActivates:: printstring STRINGID_TERRAINBECOMESGRASSY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop return @@ -8167,6 +8180,7 @@ BattleScript_DrizzleActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_AbilityRaisesDefenderStat:: @@ -8327,6 +8341,7 @@ BattleScript_SandstreamActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_SandSpitActivates:: @@ -8336,6 +8351,7 @@ BattleScript_SandSpitActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities return BattleScript_ShedSkinActivates:: @@ -8454,6 +8470,7 @@ BattleScript_DroughtActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandActivates:: @@ -8463,6 +8480,7 @@ BattleScript_DesolateLandActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandEvaporatesWaterTypeMoves:: @@ -8483,6 +8501,7 @@ BattleScript_PrimordialSeaActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: @@ -8553,6 +8572,7 @@ BattleScript_SnowWarningActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_TerrainSeedLoop: @@ -8566,7 +8586,6 @@ BattleScript_TerrainSeedLoop_NextBattler: addbyte gBattlerTarget, 0x1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TerrainSeedLoopIter restoretarget - call BattleScript_ActivateSwitchInAbilities return BattleScript_ActivateSwitchInAbilities: @@ -8580,12 +8599,24 @@ BattleScript_ActivateSwitchInAbilities_Increment: copybyte gBattlerAttacker, sBATTLER return +BattleScript_ActivateTerrainAbilities: + copybyte sBATTLER, gBattlerAttacker + setbyte gBattlerAttacker, 0 +BattleScript_ActivateTerrainAbilities_Loop: + activateterrainabilities BS_ATTACKER +BattleScript_ActivateTerrainAbilities_Increment: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateTerrainAbilities_Loop + copybyte gBattlerAttacker, sBATTLER + return + BattleScript_ElectricSurgeActivates:: pause B_WAIT_TIME_SHORT call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESELECTRIC waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -8595,6 +8626,7 @@ BattleScript_MistySurgeActivates:: printstring STRINGID_TERRAINBECOMESMISTY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -8604,6 +8636,7 @@ BattleScript_GrassySurgeActivates:: printstring STRINGID_TERRAINBECOMESGRASSY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -8613,6 +8646,7 @@ BattleScript_PsychicSurgeActivates:: printstring STRINGID_TERRAINBECOMESPSYCHIC waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -9722,6 +9756,7 @@ BattleScript_AnnounceAirLockCloudNine:: printstring STRINGID_AIRLOCKACTIVATES waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_QuickClawActivation:: @@ -9881,7 +9916,7 @@ BattleScript_ExtremeEvoboostSpDef:: BattleScript_ExtremeEvoboostEnd:: goto BattleScript_MoveEnd -BattleScript_EffectTerrainHit: +BattleScript_EffectHitSetRemoveTerrain: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring @@ -9903,6 +9938,7 @@ BattleScript_EffectTerrainHit: setterrain BattleScript_TryFaint playanimation BS_ATTACKER, B_ANIM_RESTORE_BG printfromtable gTerrainStringIds + call BattleScript_ActivateTerrainAbilities BattleScript_TryFaint: tryfaintmon BS_TARGET goto BattleScript_MoveEnd diff --git a/include/battle_util.h b/include/battle_util.h index 5f5f0b902..18af25c68 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -34,6 +34,8 @@ #define ABILITYEFFECT_MOVE_END_OTHER 12 #define ABILITYEFFECT_NEUTRALIZINGGAS 13 #define ABILITYEFFECT_FIELD_SPORT 14 // Only used if B_SPORT_TURNS < GEN_6 +#define ABILITYEFFECT_ON_WEATHER 15 +#define ABILITYEFFECT_ON_TERRAIN 16 // Special cases #define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS < GEN_6 #define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS < GEN_6 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 5af1017a9..122660c05 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -391,7 +391,7 @@ #define EFFECT_COURT_CHANGE 385 #define EFFECT_STEEL_BEAM 386 #define EFFECT_EXTREME_EVOBOOST 387 -#define EFFECT_DAMAGE_SET_TERRAIN 388 // genesis supernova +#define EFFECT_HIT_SET_REMOVE_TERRAIN 388 #define EFFECT_DARK_VOID 389 #define EFFECT_SLEEP_HIT 390 #define EFFECT_DOUBLE_SHOCK 391 diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 3aba0144d..74d7a0be2 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -248,6 +248,8 @@ #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 #define VARIOUS_SWAP_STATS 158 #define VARIOUS_TRY_WIND_RIDER_POWER 159 +#define VARIOUS_ACTIVATE_WEATHER_ABILITIES 160 +#define VARIOUS_ACTIVATE_TERRAIN_ABILITIES 161 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 807cafa28..e08a61c2f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7941,7 +7941,7 @@ static void HandleTerrainMove(u16 move) statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.terrainTimer; gBattleCommunication[MULTISTRING_CHOOSER] = 3; break; - case EFFECT_DAMAGE_SET_TERRAIN: + case EFFECT_HIT_SET_REMOVE_TERRAIN: switch (gBattleMoves[move].argument) { case 0: //genesis supernova @@ -10116,6 +10116,14 @@ static void Cmd_various(void) } } return; + case VARIOUS_ACTIVATE_WEATHER_ABILITIES: + gBattlescriptCurrInstr += 3; + AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, gActiveBattler, 0, 0, 0); + return; + case VARIOUS_ACTIVATE_TERRAIN_ABILITIES: + gBattlescriptCurrInstr += 3; + AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0); + return; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; diff --git a/src/battle_tv.c b/src/battle_tv.c index 9d2ec244e..33483da06 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -476,7 +476,7 @@ static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_COURT_CHANGE] = 0, // TODO: Assign points [EFFECT_STEEL_BEAM] = 0, // TODO: Assign points [EFFECT_EXTREME_EVOBOOST] = 0, // TODO: Assign points - [EFFECT_DAMAGE_SET_TERRAIN] = 0, // TODO: Assign points + [EFFECT_HIT_SET_REMOVE_TERRAIN] = 0, // TODO: Assign points [EFFECT_DARK_VOID] = 0, // TODO: Assign points [EFFECT_SLEEP_HIT] = 1, [EFFECT_DOUBLE_SHOCK] = 0, // TODO: Assign points diff --git a/src/battle_util.c b/src/battle_util.c index c1d112d19..c31ee5069 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6251,6 +6251,34 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; } break; + case ABILITYEFFECT_ON_WEATHER: // For ability effects that activate when the battle weather changes. + gBattleScripting.battler = gBattlerAbility = battler; + switch (GetBattlerAbility(battler)) + { + case ABILITY_PROTOSYNTHESIS: + if (IsBattlerWeatherAffected(battler, B_WEATHER_SUN)) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler)); + BattleScriptPushCursorAndCallback(BattleScript_ProtosynthesisActivates); + effect++; + } + break; + } + break; + case ABILITYEFFECT_ON_TERRAIN: // For ability effects that activate when the field terrain changes. + gBattleScripting.battler = gBattlerAbility = battler; + switch (GetBattlerAbility(battler)) + { + case ABILITY_QUARK_DRIVE: + if (IsBattlerTerrainAffected(battler, STATUS_FIELD_ELECTRIC_TERRAIN)) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler)); + BattleScriptPushCursorAndCallback(BattleScript_QuarkDriveActivates); + effect++; + } + break; + } + break; } if (effect && gLastUsedAbility != 0xFF) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index b633010e7..e5d3306ce 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -13872,7 +13872,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_ICE_SPINNER] = { - .effect = EFFECT_DAMAGE_SET_TERRAIN, + .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 80, .type = TYPE_ICE, .accuracy = 100, @@ -13884,7 +13884,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMovePower = 160, .zMoveEffect = Z_EFFECT_NONE, - .argument = 1, //remove terrain + .argument = 1, // Remove the active field terrain if there is one. }, [MOVE_GLAIVE_RUSH] = @@ -14839,7 +14839,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = }, [MOVE_GENESIS_SUPERNOVA] = { - .effect = EFFECT_DAMAGE_SET_TERRAIN, + .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 185, .type = TYPE_PSYCHIC, .accuracy = 0, @@ -14850,7 +14850,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .flags = 0, .zMovePower = 0, .split = SPLIT_SPECIAL, - .argument = 0, //psychic terrain + .argument = 0, // Set Psychic Terrain. If there's a different field terrain active, overwrite it. .zMoveEffect = 0 }, [MOVE_SINISTER_ARROW_RAID] = @@ -14900,7 +14900,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = }, [MOVE_SPLINTERED_STORMSHARDS] = { - .effect = EFFECT_DAMAGE_SET_TERRAIN, + .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 190, .type = TYPE_ROCK, .accuracy = 0, @@ -14911,7 +14911,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .flags = 0, .zMovePower = 0, .split = SPLIT_PHYSICAL, - .argument = 1, //remove terrain + .argument = 1, // Remove the active field terrain if there is one. .zMoveEffect = 0 }, [MOVE_LETS_SNUGGLE_FOREVER] =