More move scripts
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heal_each_end_of_turn")]
|
||||
public class HealEachEndOfTurn : Script
|
||||
{
|
||||
private float _healPercentage;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnInitialize(IDynamicLibrary library, IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
base.OnInitialize(library, parameters);
|
||||
if (parameters == null || !parameters.TryGetValue("percent", out var healPercentageObj) ||
|
||||
healPercentageObj is not float healPercentage)
|
||||
{
|
||||
_healPercentage = 6.25f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_healPercentage = healPercentage!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var effectName = ScriptUtils.ResolveName<HealEachEndOfTurnEffect>();
|
||||
if (target.Volatile.Contains(effectName))
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
target.Volatile.Add(new HealEachEndOfTurnEffect(_healPercentage, target));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user