using PkmnLib.Static.Moves; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "present")] public class Present : Script { private bool _isHealing; private byte _basePower; /// public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex) { var battleRandom = move.User.BattleData?.Battle.Random; if (battleRandom == null) return; var percentRoll = battleRandom.GetFloat() * 100.0; if (percentRoll < 20.0) { _isHealing = true; _basePower = 0; } else { _isHealing = false; _basePower = percentRoll switch { < 30 => 120, < 60 => 80, _ => 40, }; } } /// public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category) { if (_isHealing) category = MoveCategory.Status; } /// public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) { basePower = _basePower; } /// public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) { if (!_isHealing) return; var healAmount = (ushort)(target.MaxHealth / 4); target.Heal(healAmount); } }