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

@@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Dry_Skin_(Ability)">Bulbapedia - Dry Skin</see>
/// </summary>
[Script(ScriptCategory.Ability, "dry_skin")]
public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn
public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
{
private IPokemon? _owningPokemon;
@@ -55,4 +55,13 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn
_owningPokemon.Damage(_owningPokemon.MaxHealth / 8, DamageSource.Weather);
}
}
/// <inheritdoc />
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
{
if (pokemon.BattleData?.Battle.WeatherName == ScriptUtils.ResolveName<Weather.HarshSunlight>())
{
damage += (int)(pokemon.MaxHealth / 8f);
}
}
}

View File

@@ -6,7 +6,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Solar_Power_(Ability)">Bulbapedia - Solar Power</see>
/// </summary>
[Script(ScriptCategory.Ability, "solar_power")]
public class SolarPower : Script, IScriptChangeOffensiveStatValue, IScriptOnEndTurn
public class SolarPower : Script, IScriptChangeOffensiveStatValue, IScriptOnEndTurn,
IAIInfoScriptExpectedEndOfTurnDamage
{
/// <inheritdoc />
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
@@ -29,6 +30,26 @@ public class SolarPower : Script, IScriptChangeOffensiveStatValue, IScriptOnEndT
if (!pokemon.IsUsable)
return;
var weatherName = pokemon.BattleData?.Battle.WeatherName;
if (weatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>() &&
weatherName != ScriptUtils.ResolveName<Weather.DesolateLands>())
{
return;
}
pokemon.Damage(pokemon.MaxHealth / 8, DamageSource.Weather);
}
/// <inheritdoc />
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
{
var weatherName = pokemon.BattleData?.Battle.WeatherName;
if (weatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>() &&
weatherName != ScriptUtils.ResolveName<Weather.DesolateLands>())
{
return;
}
damage += (int)(pokemon.MaxHealth / 8f);
}
}