Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/ProtectionEffectScript.cs

20 lines
721 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "protect")]
public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
{
/// <inheritdoc />
public virtual void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
ref bool block)
{
if (!executingMove.UseMove.HasFlag(MoveFlags.Protect))
return;
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
executingMove.User.RunScriptHook<IScriptCustomTrigger>(x =>
x.CustomTrigger(CustomTriggers.BypassProtection, args));
if (args.Bypass)
return;
block = true;
}
}