Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Curse.cs

30 lines
1.1 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "curse")]
public class Curse : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User;
if (battleData == null)
return;
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;
if (!typeLibrary.TryGetTypeIdentifier(TypeNames.Ghost, out var ghostType))
return;
if (move.User.Types.Contains(ghostType))
{
move.User.Damage(move.User.MaxHealth / 2, DamageSource.Misc, forceDamage: true);
target.Volatile.Add(new GhostCurseEffect(target));
}
else
{
EventBatchId batchId = new();
move.User.ChangeStatBoost(Statistic.Speed, -1, true, false, batchId);
move.User.ChangeStatBoost(Statistic.Defense, 1, true, false, batchId);
move.User.ChangeStatBoost(Statistic.Attack, 1, true, false, batchId);
}
}
}