2024-12-22 10:24:01 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using PkmnLib.Dynamic.Models;
|
|
|
|
using PkmnLib.Dynamic.ScriptHandling;
|
|
|
|
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
|
|
|
using PkmnLib.Static.Utils;
|
|
|
|
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
|
|
|
|
[Script(ScriptCategory.Move, "drain")]
|
|
|
|
public class Drain : Script
|
|
|
|
{
|
|
|
|
public float DrainModifier { get; set; } = 0.5f;
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2025-01-10 10:11:50 +00:00
|
|
|
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
2024-12-22 10:24:01 +00:00
|
|
|
{
|
2025-01-10 10:11:50 +00:00
|
|
|
base.OnInitialize(parameters);
|
2024-12-22 10:24:01 +00:00
|
|
|
if (parameters == null)
|
|
|
|
return;
|
|
|
|
DrainModifier = parameters.GetValueOrDefault("drain_modifier") as float? ?? DrainModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
|
|
{
|
|
|
|
var user = move.User;
|
|
|
|
var damage = move.GetHitData(target, hit).Damage;
|
|
|
|
var healed = (uint)(damage * DrainModifier);
|
|
|
|
if (move.User.HasHeldItem("big_root"))
|
|
|
|
healed = (uint)(healed * 1.3f);
|
|
|
|
user.Heal(healed, false);
|
|
|
|
}
|
|
|
|
}
|