namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// Magic Guard is an ability that prevents all damage except from direct attacks. /// /// Bulbapedia - Magic Guard /// [Script(ScriptCategory.Ability, "magic_guard")] public class MagicGuard : Script { /// public override void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage) { // Magic Guard doesn't work if the Pokémon is not in battle. if (pokemon.BattleData is null) return; if (source is DamageSource.MoveDamage or DamageSource.Struggle or DamageSource.FormChange) { // If the damage is from a move, struggle, or form change, we don't prevent it. return; } damage = 0; } }