Deukhoofd 7c270a6d52
All checks were successful
Build / Build (push) Successful in 1m1s
Finish script interface refactor
2025-07-06 10:27:56 +02:00

22 lines
759 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "protect")]
public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
{
/// <inheritdoc />
public virtual void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (target.BattleData == null)
return;
if (!executingMove.UseMove.HasFlag("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;
}
}