using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
///
/// Cursed Body is an ability that has a 30% chance to disable the last move used against the Pokémon.
/// When triggered, the opponent's move becomes disabled for 4 turns, preventing its use.
/// This ability can be triggered by any damaging move that hits the Pokémon.
///
/// Bulbapedia - Cursed Body
///
[Script(ScriptCategory.Ability, "cursed_body")]
public class CursedBody : Script, IScriptOnIncomingHit
{
///
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
// 30% chance to disable the move
if (move.Battle.Random.GetFloat() > 0.3f)
return;
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
target.Volatile.Add(new DisableEffect(move.ChosenMove.MoveData.Name));
}
}