This commit is contained in:
44
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs
Normal file
44
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "spikes")]
|
||||
public class SpikesEffect : Script
|
||||
{
|
||||
private int _layers = 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Stack()
|
||||
{
|
||||
if (_layers < 3)
|
||||
_layers++;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.IsFloating)
|
||||
return;
|
||||
|
||||
var modifier = _layers switch
|
||||
{
|
||||
1 => 1 / 16f,
|
||||
2 => 3 / 16f,
|
||||
3 => 1 / 4f,
|
||||
_ => throw new ArgumentOutOfRangeException(),
|
||||
};
|
||||
var damage = (uint)(pokemon.MaxHealth * modifier);
|
||||
|
||||
EventBatchId eventBatch = new();
|
||||
pokemon.Damage(damage, DamageSource.Misc, eventBatch);
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new DialogEvent("spikes_damage", new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", pokemon },
|
||||
})
|
||||
{
|
||||
BatchId = eventBatch,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user