Getting started with implementing an explicit AI, based on the Essentials one.
All checks were successful
Build / Build (push) Successful in 1m2s

This commit is contained in:
2025-07-11 17:03:08 +02:00
parent 084ae84130
commit a3a4993407
56 changed files with 2687 additions and 1274 deletions

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
[Script(ScriptCategory.Weather, "hail")]
public class Hail : Script, ILimitedTurnsScript, IScriptOnEndTurn
public class Hail : Script, ILimitedTurnsScript, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
{
private int? _duration;
@@ -46,4 +46,15 @@ public class Hail : Script, ILimitedTurnsScript, IScriptOnEndTurn
battle.SetWeather(null, 0);
}
}
/// <inheritdoc />
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
{
if (pokemon.Types.Any(x => x.Name == "ice"))
return; // Ice types are immune to Hail damage.
if (_duration.HasValue)
{
damage += (int)(pokemon.MaxHealth / 16f);
}
}
}

View File

@@ -1,7 +1,8 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
[Script(ScriptCategory.Weather, "sandstorm")]
public class Sandstorm : Script, IScriptChangeBasePower, IScriptChangeDefensiveStatValue, IScriptOnEndTurn
public class Sandstorm : Script, IScriptChangeBasePower, IScriptChangeDefensiveStatValue, IScriptOnEndTurn,
IAIInfoScriptExpectedEndOfTurnDamage
{
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
@@ -39,4 +40,12 @@ public class Sandstorm : Script, IScriptChangeBasePower, IScriptChangeDefensiveS
if (move.UseMove.Name == "solar_beam")
basePower /= 2;
}
/// <inheritdoc />
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
{
if (pokemon.Types.Any(x => x.Name == "rock" || x.Name == "ground" || x.Name == "steel"))
return; // Rock, Ground, and Steel types are immune to Sandstorm damage.
damage += (int)(pokemon.MaxHealth / 16f);
}
}