Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Defeatist.cs

20 lines
775 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Defeatist is an ability that halves the Pokémon's Attack and Special Attack when its HP drops below 50%.
/// This reduction applies to all moves used by the Pokémon, making it significantly weaker when damaged.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Defeatist_(Ability)">Bulbapedia - Defeatist</see>
/// </summary>
[Script(ScriptCategory.Ability, "defeatist")]
public class Defeatist : Script, IScriptChangeDamageModifier
{
/// <inheritdoc />
public void ChangeDamageModifier(IExecutingMove move, IBattlePokemon target, byte hit, ref float modifier)
{
if (move.User.CurrentHealth < move.User.MaxHealth / 2)
{
modifier *= 0.5f;
}
}
}