2025-06-14 12:25:29 +02:00

22 lines
841 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Rattled is an ability that raises Speed when hit by a Bug-, Ghost-, or Dark-type move.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Rattled_(Ability)">Bulbapedia - Rattled</see>
/// </summary>
[Script(ScriptCategory.Ability, "rattled")]
public class Rattled : Script
{
/// <inheritdoc />
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
var type = move.GetHitData(target, hit).Type;
if (type is null)
return;
if (type.Value.Name != "bug" && type.Value.Name != "ghost" && type.Value.Name != "dark")
return;
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
target.ChangeStatBoost(Statistic.Speed, 1, true, false);
}
}