From 51e163951347f2d3c7935ad8cfdae56d0b897816 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Apr 2020 15:49:40 +0200 Subject: [PATCH] Magic Guard protects from stuff --- data/battle_scripts_1.s | 6 ++++-- src/battle_script_commands.c | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4e91dd84e6..50198442aa 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2709,6 +2709,7 @@ BattleScript_EffectRecoilIfMiss:: accuracycheck BattleScript_MoveMissedDoDamage, ACC_CURR_MOVE goto BattleScript_HitFromAtkString BattleScript_MoveMissedDoDamage:: + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_PrintMoveMissed attackstring ppreduce pause 0x40 @@ -5969,13 +5970,13 @@ BattleScript_PoisonTurnDmg:: waitmessage 0x40 BattleScript_DoStatusTurnDmg:: statusanimation BS_ATTACKER -BattleScript_DoTurnDmg:: +BattleScript_DoTurnDmg: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL atk24 BattleScript_DoTurnDmgEnd -BattleScript_DoTurnDmgEnd:: +BattleScript_DoTurnDmgEnd: end2 BattleScript_PoisonHealActivates:: @@ -6120,6 +6121,7 @@ BattleScript_PrintPayDayMoneyString:: return BattleScript_WrapTurnDmg:: + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_DoTurnDmgEnd playanimation BS_ATTACKER, B_ANIM_TURN_TRAP, sB_ANIM_ARG1 printstring STRINGID_PKMNHURTBY waitmessage 0x40 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b4876cb50a..df3a48c56c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5518,6 +5518,7 @@ static void Cmd_switchineffects(void) if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED) && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES) + && GetBattlerAbility(gActiveBattler) != ABILITY_MAGIC_GUARD && IsBattlerGrounded(gActiveBattler)) { u8 spikesDmg = (5 - gSideTimers[GetBattlerSide(gActiveBattler)].spikesAmount) * 2; @@ -5529,7 +5530,8 @@ static void Cmd_switchineffects(void) SetDmgHazardsBattlescript(gActiveBattler, 0); } else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STEALTH_ROCK_DAMAGED) - && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STEALTH_ROCK)) + && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STEALTH_ROCK) + && GetBattlerAbility(gActiveBattler) != ABILITY_MAGIC_GUARD) { gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_STEALTH_ROCK_DAMAGED; gBattleMoveDamage = GetStealthHazardDamage(gBattleMoves[MOVE_STEALTH_ROCK].type, gActiveBattler); @@ -8991,10 +8993,11 @@ static void Cmd_setsandstorm(void) static void Cmd_weatherdamage(void) { + u32 ability = GetBattlerAbility(gBattlerAttacker); + gBattleMoveDamage = 0; - if (IsBattlerAlive(gBattlerAttacker) && WEATHER_HAS_EFFECT) + if (IsBattlerAlive(gBattlerAttacker) && WEATHER_HAS_EFFECT && ability != ABILITY_MAGIC_GUARD) { - u32 ability = GetBattlerAbility(gBattlerAttacker); if (gBattleWeather & WEATHER_SANDSTORM_ANY) { if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ROCK)