Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/FriendGuardEffect.cs

28 lines
769 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "friend_guard")]
public class FriendGuardEffect : Script, IScriptChangeIncomingMoveDamage
{
private readonly HashSet<IBattlePokemon> _placerPokemon = [];
public void OnAdded(IBattlePokemon placer)
{
_placerPokemon.Add(placer);
}
public void OnRemoved(IBattlePokemon placer)
{
_placerPokemon.Remove(placer);
if (_placerPokemon.Count == 0)
{
RemoveSelf();
}
}
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
{
var modifier = Math.Pow(0.75f, _placerPokemon.Count);
damage = (uint)(damage * modifier);
}
}