27 lines
888 B
C#
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"));
|
|
}
|
|
}
|
|
} |