namespace PkmnLib.Plugin.Gen7.Scripts.Moves; /// /// Named 'SubstituteMove' to avoid namespace conflicts with NSubstitute. /// [Script(ScriptCategory.Move, "substitute")] public class SubstituteMove : Script { /// public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) { var hp = move.User.MaxHealth / 4; if (move.User.CurrentHealth > hp) { move.User.Damage(hp, DamageSource.Misc, forceDamage: true); move.User.Volatile.Add(new Pokemon.SubstituteEffect(hp)); move.Battle.EventHook.Invoke(new DialogEvent("substitute", new Dictionary { { "user", move.User }, })); } else { move.Battle.EventHook.Invoke(new DialogEvent("substitute_fail")); } } }