More move scripts

This commit is contained in:
2025-05-03 16:51:44 +02:00
parent f8c43b6ba0
commit 1973ff50fa
52 changed files with 704 additions and 78 deletions

View File

@@ -487,6 +487,7 @@ public class PokemonImpl : ScriptSource, IPokemon
WeightInKg = form.Weight;
HeightInMeters = form.Height;
Happiness = species.BaseHappiness;
Volatile = new ScriptSet(this);
if (!library.StaticLibrary.Natures.TryGet(natureName, out var nature))
throw new KeyNotFoundException($"Nature {natureName} not found.");
Nature = nature;
@@ -532,6 +533,7 @@ public class PokemonImpl : ScriptSource, IPokemon
AbilityIndex = form.FindAbilityIndex(ability) ??
throw new KeyNotFoundException(
$"Ability {ability.Name} not found on species {species.Name} form {form.Name}.");
Volatile = new ScriptSet(this);
_learnedMoves = serializedPokemon.Moves.Select(move =>
{
if (move == null)
@@ -736,7 +738,7 @@ public class PokemonImpl : ScriptSource, IPokemon
public ScriptContainer StatusScript { get; } = new();
/// <inheritdoc />
public IScriptSet Volatile { get; } = new ScriptSet();
public IScriptSet Volatile { get; }
/// <inheritdoc />
public bool HasHeldItem(StringKey itemName) => HeldItem?.Name == itemName;
@@ -1097,6 +1099,11 @@ public class PokemonImpl : ScriptSource, IPokemon
{
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
throw new KeyNotFoundException($"Status script {status} not found");
var preventStatus = false;
this.RunScriptHook(script => script.PreventStatusChange(this, status, ref preventStatus));
if (preventStatus)
return false;
StatusScript.Set(statusScript);
return true;
}