This commit is contained in:
@@ -274,8 +274,9 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// <param name="stat">The stat to be changed</param>
|
||||
/// <param name="change">The amount to change the stat by</param>
|
||||
/// <param name="selfInflicted">Whether the change was self-inflicted. This can be relevant in scripts.</param>
|
||||
/// <param name="force"></param>
|
||||
/// <param name="batchId">The event batch ID this change is a part of. This is relevant for visual handling</param>
|
||||
bool ChangeStatBoost(Statistic stat, sbyte change, bool selfInflicted, EventBatchId batchId = default);
|
||||
bool ChangeStatBoost(Statistic stat, sbyte change, bool selfInflicted, bool force, EventBatchId batchId = default);
|
||||
|
||||
/// <summary>
|
||||
/// Suppresses the ability of the Pokémon.
|
||||
@@ -354,7 +355,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// <summary>
|
||||
/// Adds a non-volatile status to the Pokemon.
|
||||
/// </summary>
|
||||
bool SetStatus(StringKey status, EventBatchId batchId = default);
|
||||
bool SetStatus(StringKey status, bool selfInflicted, EventBatchId batchId = default);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the current non-volatile status from the Pokemon.
|
||||
@@ -841,15 +842,20 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ChangeStatBoost(Statistic stat, sbyte change, bool selfInflicted, EventBatchId batchId = default)
|
||||
public bool ChangeStatBoost(Statistic stat, sbyte change, bool selfInflicted, bool force,
|
||||
EventBatchId batchId = default)
|
||||
{
|
||||
var prevented = false;
|
||||
this.RunScriptHook(script => script.PreventStatBoostChange(this, stat, change, selfInflicted, ref prevented));
|
||||
if (prevented)
|
||||
return false;
|
||||
this.RunScriptHook(script => script.ChangeStatBoostChange(this, stat, selfInflicted, ref change));
|
||||
if (change == 0)
|
||||
return false;
|
||||
if (!force)
|
||||
{
|
||||
var prevented = false;
|
||||
this.RunScriptHook(script =>
|
||||
script.PreventStatBoostChange(this, stat, change, selfInflicted, ref prevented));
|
||||
if (prevented)
|
||||
return false;
|
||||
this.RunScriptHook(script => script.ChangeStatBoostChange(this, stat, selfInflicted, ref change));
|
||||
if (change == 0)
|
||||
return false;
|
||||
}
|
||||
var changed = false;
|
||||
var oldBoost = StatBoost.GetStatistic(stat);
|
||||
changed = change switch
|
||||
@@ -1135,7 +1141,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
public bool HasStatus(StringKey status) => StatusScript.Script?.Name == status;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SetStatus(StringKey status, EventBatchId batchId = default)
|
||||
public bool SetStatus(StringKey status, bool selfInflicted, EventBatchId batchId = default)
|
||||
{
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
|
||||
throw new KeyNotFoundException($"Status script {status} not found");
|
||||
@@ -1145,7 +1151,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
var oldStatus = StatusScript.Script?.Name;
|
||||
|
||||
var preventStatus = false;
|
||||
this.RunScriptHook(script => script.PreventStatusChange(this, status, ref preventStatus));
|
||||
this.RunScriptHook(script => script.PreventStatusChange(this, status, selfInflicted, ref preventStatus));
|
||||
if (preventStatus)
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user