Adds several new scripts
This commit is contained in:
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Drain.cs
Normal file
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Drain.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
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 />
|
||||
public override void OnInitialize(IDynamicLibrary library, IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
base.OnInitialize(library, parameters);
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user