This commit is contained in:
50
Plugins/PkmnLib.Plugin.Gen7/Scripts/Weather/StrongWinds.cs
Normal file
50
Plugins/PkmnLib.Plugin.Gen7/Scripts/Weather/StrongWinds.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
|
||||
|
||||
/// <summary>
|
||||
/// StrongWinds is a weather condition that represents strong winds in battle.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Strong_winds">Bulbapedia - Strong Winds</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Weather, "strong_winds")]
|
||||
public class StrongWinds : Script
|
||||
{
|
||||
private HashSet<IPokemon> _placers = new();
|
||||
|
||||
public void MarkAsPlaced(IPokemon pokemon)
|
||||
{
|
||||
_placers.Add(pokemon);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
{
|
||||
_placers.Remove(oldPokemon);
|
||||
if (_placers.Count == 0)
|
||||
oldPokemon.BattleData?.Battle.SetWeather(null, 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventWeatherChange(StringKey? weatherName, ref bool preventWeatherChange)
|
||||
{
|
||||
if (weatherName == ScriptUtils.ResolveName<DesolateLands>() ||
|
||||
weatherName == ScriptUtils.ResolveName<PrimordialSea>())
|
||||
return;
|
||||
preventWeatherChange = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
var flyingType = types.FirstOrDefault(x => x.Name == "flying");
|
||||
if (flyingType != null)
|
||||
{
|
||||
var typeLibrary = executingMove.Battle.Library.StaticLibrary.Types;
|
||||
var hitData = executingMove.GetHitData(target, hitIndex);
|
||||
if (hitData.Type != null && typeLibrary.GetSingleEffectiveness(hitData.Type.Value, flyingType) > 1)
|
||||
{
|
||||
types.Remove(flyingType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user