Implements more abilities
All checks were successful
Build / Build (push) Successful in 47s

This commit is contained in:
2025-06-09 12:10:25 +02:00
parent af0126e413
commit 00005aa4bf
50 changed files with 80425 additions and 20485 deletions

View File

@@ -0,0 +1,36 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
[Script(ScriptCategory.Weather, "desolate_lands")]
public class DesolateLands : HarshSunlight
{
private readonly HashSet<IPokemon> _placers = [];
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<PrimordialSea>() ||
weatherName == ScriptUtils.ResolveName<StrongWinds>())
return;
preventWeatherChange = true;
}
/// <inheritdoc />
public override void FailMove(IExecutingMove move, ref bool fail)
{
if (move.UseMove.MoveType.Name == "water")
fail = true;
}
}

View File

@@ -1,5 +1,3 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
[Script(ScriptCategory.Weather, "hail")]
@@ -7,6 +5,9 @@ public class Hail : Script, ILimitedTurnsScript
{
private int? _duration;
/// <inheritdoc />
public int TurnsRemaining => _duration ?? 0;
/// <inheritdoc />
public void SetTurns(int turns)
{

View File

@@ -0,0 +1,59 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
/// <summary>
/// HarshSunlight is a weather condition that intensifies the effects of sunlight.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Harsh_sunlight">Bulbapedia - Harsh Sunlight</see>
/// </summary>
[Script(ScriptCategory.Weather, "harsh_sunlight")]
public class HarshSunlight : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var hitType = move.GetHitData(target, hit).Type;
if (hitType?.Name == "fire" || move.UseMove.Name == "hydro_steam")
{
// Increase Fire-type move power by 50% in harsh sunlight
basePower = (ushort)(basePower * 1.5);
}
else if (hitType?.Name == "water")
{
basePower = (ushort)(basePower * 0.5);
}
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, IDictionary<StringKey, object?>? parameters)
{
if (eventName == CustomTriggers.BypassChargeMove)
{
if (parameters == null || !parameters.TryGetValue("move", out var moveObj) ||
moveObj is not IExecutingMove move)
return;
if (move.UseMove.Name == "solar_beam" || move.UseMove.Name == "solar_blade")
{
parameters["bypassCharge"] = true;
}
}
}
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemonImpl, StringKey status, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Frozen>())
{
preventStatus = true;
}
}
/// <inheritdoc />
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
if (executingMove.UseMove.Name == "thunder" || executingMove.UseMove.Name == "hurricane")
{
modifiedAccuracy = (int)(modifiedAccuracy * 0.5);
}
}
}

View File

@@ -0,0 +1,29 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
[Script(ScriptCategory.Weather, "primordial_sea")]
public class PrimordialSea : 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<StrongWinds>())
return;
preventWeatherChange = true;
}
}

View 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);
}
}
}
}

View File

@@ -1,7 +0,0 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
[Script(ScriptCategory.Weather, "sunny")]
public class Sunny : Script
{
// TODO: Implement Sunny
}