This commit is contained in:
27
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SubstituteMove.cs
Normal file
27
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SubstituteMove.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user