Deukhoofd a17cb92c5a
Some checks failed
continuous-integration/drone/push Build is failing
Implements a bunch more moves
2025-05-17 17:44:15 +02:00

27 lines
888 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <remarks>
/// Named 'SubstituteMove' to avoid namespace conflicts with NSubstitute.
/// </remarks>
[Script(ScriptCategory.Move, "substitute")]
public class SubstituteMove : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var hp = move.User.MaxHealth / 4;
if (move.User.CurrentHealth > hp)
{
move.User.Damage(hp, DamageSource.Misc, forceDamage: true);
move.User.Volatile.Add(new Pokemon.SubstituteEffect(hp));
move.Battle.EventHook.Invoke(new DialogEvent("substitute", new Dictionary<string, object>
{
{ "user", move.User },
}));
}
else
{
move.Battle.EventHook.Invoke(new DialogEvent("substitute_fail"));
}
}
}