Deukhoofd 7727f92f4e
All checks were successful
continuous-integration/drone/push Build is passing
Even more moves
2025-05-05 16:58:03 +02:00

26 lines
917 B
C#

using System.Collections.Generic;
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "stealth_rock")]
public class StealthRockEffect : Script
{
/// <inheritdoc />
public override void OnSwitchIn(IPokemon pokemon, byte position)
{
var typeLibrary = pokemon.Library.StaticLibrary.Types;
var effectiveness = 1.0f;
if (typeLibrary.TryGetTypeIdentifier("rock", out var rockType))
{
effectiveness = typeLibrary.GetEffectiveness(rockType, pokemon.Types);
}
var damage = (uint)(pokemon.MaxHealth / 8f * effectiveness);
EventBatchId batchId = new();
pokemon.Damage(damage, DamageSource.Misc, batchId);
pokemon.BattleData?.Battle.EventHook.Invoke(new DialogEvent("stealth_rock_damage",
new Dictionary<string, object>
{
{ "pokemon", pokemon },
}));
}
}