More abilities, refactor custom triggers to be typed.
All checks were successful
Build / Build (push) Successful in 48s
All checks were successful
Build / Build (push) Successful in 48s
This commit is contained in:
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/MagicGuard.cs
Normal file
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/MagicGuard.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Magic Guard is an ability that prevents all damage except from direct attacks.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Magic_Guard_(Ability)">Bulbapedia - Magic Guard</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "magic_guard")]
|
||||
public class MagicGuard : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user