namespace PkmnLib.Plugin.Gen7.Scripts.Side; [Script(ScriptCategory.Side, "stealth_rock")] public class StealthRockEffect : Script, IScriptOnSwitchIn, IAIInfoScriptExpectedEntryDamage { /// public void OnSwitchIn(IBattlePokemon pokemon, byte position) { var damage = CalculateStealthRockDamage(pokemon); EventBatchId batchId = new(); pokemon.Damage(damage, DamageSource.Misc, batchId); pokemon.Battle.EventHook.Invoke(new DialogEvent("stealth_rock_damage", new Dictionary { { "pokemon", pokemon }, })); } private static uint CalculateStealthRockDamage(IBattlePokemon pokemon) { var typeLibrary = pokemon.Library.StaticLibrary.Types; var effectiveness = 1.0f; if (typeLibrary.TryGetTypeIdentifier(TypeNames.Rock, out var rockType)) { effectiveness = typeLibrary.GetEffectiveness(rockType, pokemon.Types); } return (uint)(pokemon.MaxHealth / 8f * effectiveness); } /// public void ExpectedEntryDamage(IBattlePokemon pokemon, ref uint damage) { damage += CalculateStealthRockDamage(pokemon); } }