More abilities, refactor IPokemon.SetStatus to pass pokemon that caused the status change
All checks were successful
Build / Build (push) Successful in 50s

This commit is contained in:
2025-06-15 12:29:13 +02:00
parent defb1349ca
commit 85d97cb9e6
37 changed files with 214 additions and 46 deletions

View File

@@ -361,7 +361,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// <summary>
/// Adds a non-volatile status to the Pokemon.
/// </summary>
bool SetStatus(StringKey status, bool selfInflicted, EventBatchId batchId = default);
bool SetStatus(StringKey status, IPokemon? originPokemon, EventBatchId batchId = default);
/// <summary>
/// Removes the current non-volatile status from the Pokemon.
@@ -1186,7 +1186,7 @@ public class PokemonImpl : ScriptSource, IPokemon
public bool HasStatus(StringKey status) => StatusScript.Script?.Name == status;
/// <inheritdoc />
public bool SetStatus(StringKey status, bool selfInflicted, EventBatchId batchId = default)
public bool SetStatus(StringKey status, IPokemon? originPokemon, EventBatchId batchId = default)
{
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
throw new KeyNotFoundException($"Status script {status} not found");
@@ -1194,6 +1194,7 @@ public class PokemonImpl : ScriptSource, IPokemon
if (!StatusScript.IsEmpty)
return false;
var oldStatus = StatusScript.Script?.Name;
var selfInflicted = originPokemon == this;
var preventStatus = false;
this.RunScriptHook(script => script.PreventStatusChange(this, status, selfInflicted, ref preventStatus));
@@ -1206,6 +1207,7 @@ public class PokemonImpl : ScriptSource, IPokemon
{
BatchId = batchId,
});
this.RunScriptHook(script => script.OnAfterStatusChange(this, status, originPokemon));
return true;
}

View File

@@ -767,6 +767,10 @@ public abstract class Script : IDeepCloneable
{
}
public virtual void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon)
{
}
/// <summary>
/// This function allows a script to prevent a Pokémon from being affected by a volatile status condition.
/// </summary>