namespace PkmnLib.Plugin.Gen7.Scripts.Status; [Script(ScriptCategory.Status, "frozen")] public class Frozen : Script, IScriptPreventMove { private IPokemon? _pokemon; /// public override void OnAddedToParent(IScriptSource source) { _pokemon = source as IPokemon; if (_pokemon == null) { throw new InvalidOperationException("Frozen script can only be added to a Pokemon."); } } /// public void PreventMove(IExecutingMove move, ref bool prevent) { if (move.UseMove.MoveType.Name == "fire" || move.UseMove.HasFlag("defrost")) { _pokemon?.ClearStatus(); return; } prevent = true; } /// public override void OnEndTurn(IScriptSource owner, IBattle battle) { if (_pokemon == null) return; if (battle.Random.GetInt(0, 100) >= 20) return; _pokemon.ClearStatus(); } /// public override void OnRemove() { _pokemon?.BattleData?.Battle.EventHook.Invoke(new DialogEvent("pokemon_thawed_out", new Dictionary { { "pokemon", _pokemon }, })); } }