using PkmnLib.Plugin.Gen7.Scripts.Pokemon; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "flower_shield")] public class FlowerShield : Script, IScriptOnSecondaryEffect { /// public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit) { var battleData = target; if (battleData == null) return; if (!battleData.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Grass, out var grassType)) return; var batchId = new EventBatchId(); var sides = battleData.Battle.Sides; var anyFound = false; foreach (var side in sides) { foreach (var pokemon in side.Pokemon) { if (pokemon == null || pokemon.IsFainted) continue; if (!pokemon.Types.Contains(grassType)) continue; if (pokemon.Volatile.Any(x => x.Script?.IsSemiInvulnerableTurn == true)) continue; pokemon.ChangeStatBoost(Statistic.Defense, 1, pokemon == move.User, false, batchId); anyFound = true; } } if (!anyFound) move.GetHitData(target, hit).Fail(); } }