25 lines
1006 B
C#
25 lines
1006 B
C#
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
///
|
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Cursed_Body_(Ability)">Bulbapedia - Cursed Body</see>
|
|
/// </summary>
|
|
[Script(ScriptCategory.Ability, "cursed_body")]
|
|
public class CursedBody : Script, IScriptOnIncomingHit
|
|
{
|
|
/// <inheritdoc />
|
|
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));
|
|
}
|
|
} |