23 lines
913 B
C#

using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "whirlpool")]
public class Whirlpool : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var userVolatile = move.User.Volatile.Add(new WhirlpoolEffect());
if (userVolatile?.Script is WhirlpoolEffect whirlpoolEffect)
{
var turns = move.Battle.Random.GetInt(4, 6);
var damagePercent = 0.125f;
var args = new CustomTriggers.WhirlpoolArgs(move, target, hit, turns, damagePercent);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Whirlpool, args));
turns = args.Turns;
damagePercent = args.DamagePercent;
whirlpoolEffect.AddTargetedPokemon(target, turns, damagePercent);
}
}
}