Deukhoofd 9ff4745c0a
All checks were successful
Build / Build (push) Successful in 49s
Finishes the last few moves
2025-05-18 12:20:21 +02:00

28 lines
1.1 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "whirlpool")]
public class Whirlpool : Script
{
/// <inheritdoc />
public override 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 parameters = new Dictionary<StringKey, object?>
{
{ "number_of_turns", turns },
{ "damage_percent", damagePercent },
};
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Whirlpool, parameters));
turns = parameters.GetValueOrDefault("number_of_turns", turns) as int? ?? turns;
damagePercent = parameters.GetValueOrDefault("damage_percent", damagePercent) as float? ?? damagePercent;
whirlpoolEffect.AddTargetedPokemon(target, turns, damagePercent);
}
}
}