28 lines
880 B
C#
28 lines
880 B
C#
using PkmnLib.Dynamic.Models;
|
|
using PkmnLib.Dynamic.ScriptHandling;
|
|
using PkmnLib.Static.Moves;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
public abstract class ProtectionEffectScript : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
|
{
|
|
if (target.BattleData == null)
|
|
return;
|
|
|
|
var originalTarget = executingMove.MoveChoice.TargetPosition;
|
|
var targetPosition = target.BattleData.Position;
|
|
|
|
// We only want to block the hit if it's explicitly targeting the Pokemon.
|
|
if (targetPosition != originalTarget)
|
|
return;
|
|
|
|
if (executingMove.UseMove.Target is MoveTarget.All or MoveTarget.SelfUse or MoveTarget.AllAlly
|
|
or MoveTarget.AllAdjacent)
|
|
return;
|
|
|
|
block = true;
|
|
}
|
|
} |