using System.Collections.Generic; using PkmnLib.Plugin.Gen7.Scripts.Pokemon; using PkmnLib.Static.Utils; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "counter")] public class Counter : Script { /// public override void OnBeforeTurnStart(ITurnChoice choice) { choice.User.Volatile.Add(new CounterHelperEffect()); } /// public override void ChangeTargets(IMoveChoice moveChoice, ref IReadOnlyList targets) { var counterHelper = moveChoice.User.Volatile.Get(); var lastHitBy = counterHelper?.LastHitBy; if (lastHitBy == null) { moveChoice.Fail(); return; } targets = [lastHitBy]; } /// public override void ChangeDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage) { var counterHelper = move.User.Volatile.Get(); if (counterHelper == null || counterHelper.LastHitBy == null || counterHelper.LastHitBy != target) { move.GetHitData(target, hit).Fail(); return; } var lastDamage = counterHelper.LastDamage; damage = lastDamage.MultiplyOrMax(2); } }