namespace PkmnLib.Plugin.Gen7.Scripts.Weather; [Script(ScriptCategory.Weather, "rain")] public class Rain : Script, ILimitedTurnsScript, IScriptChangeBasePower, IScriptOnEndTurn, IScriptChangeAccuracy { private int? _duration; /// public int TurnsRemaining => _duration ?? 0; /// public void SetTurns(int turns) { _duration = turns; } /// public virtual void OnEndTurn(IScriptSource owner, IBattle battle) { _duration--; if (_duration <= 0) { battle.SetWeather(null, 0); } } /// public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) { var hitType = move.GetHitData(target, hit).Type; if (hitType?.Name == TypeNames.Water) { // Increase Water-type move power by 50% in rain basePower = (ushort)(basePower * 1.5); } else if (hitType?.Name == TypeNames.Fire) { // Decrease Fire-type move power by 50% in rain basePower = (ushort)(basePower * 0.5); } } // These moves are not part of the gen 7 data files, so no generated constants exist for them. private static readonly StringKey BleakwindStormName = "bleakwind_storm"; private static readonly StringKey WindboltStormName = "windbolt_storm"; private static readonly StringKey SandsearStormName = "sandsear_storm"; /// public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy) { var moveName = executingMove.UseMove.Name; if (moveName == MoveNames.Thunder || moveName == MoveNames.Hurricane || moveName == BleakwindStormName || moveName == WindboltStormName || moveName == SandsearStormName) { modifiedAccuracy = 1000; } } }