using PkmnLib.Plugin.Gen7.Scripts.Battle; using PkmnLib.Plugin.Gen7.Scripts.Side; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "future_sight")] public class FutureSight : Script, IScriptStopBeforeMove { /// public void StopBeforeMove(IExecutingMove move, ref bool prevent) { var battleData = move.User; if (battleData == null) return; var battle = battleData.Battle; var moveChoice = move.MoveChoice; prevent = true; if (IsTargetAlreadySetToBeHit(battle, moveChoice.TargetSide, moveChoice.TargetPosition)) { moveChoice.Fail(); return; } if (battle.Volatile.TryGet(out var effect)) effect.AddStrike(moveChoice); else battle.Volatile.Add(new FutureSightEffect(moveChoice)); } private static bool IsTargetAlreadySetToBeHit(IBattle battle, byte side, byte position) { if (battle.Volatile.TryGet(out var futureSight) && futureSight.HasStrikeAt(side, position)) return true; var doomDesire = battle.Sides[side].VolatileScripts.Get(); return doomDesire != null && doomDesire.HasTarget(position); } }