Items can be used on Pokemon outside of battle, and we want the user of the library to be able to check for what changed. This allows for example a heal event to be sent back to the user of the library after using an item.
This commit is contained in:
7 files changed
+21
-17
No files matched your search
@@ -340,7 +340,8 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// Heals the Pokemon by a specific amount. Unless allow_revive is set to true, this will not
|
||||
/// heal if the Pokemon has 0 health. If the amount healed is 0, this will return false.
|
||||
/// </summary>
|
||||
bool Heal(uint heal, bool allowRevive = false, EventBatchId batchId = default, bool forceHeal = false);
|
||||
bool Heal(uint heal, bool allowRevive = false, EventBatchId batchId = default, bool forceHeal = false,
|
||||
EventHook? customEventHook = null);
|
||||
|
||||
/// <summary>
|
||||
/// Restores all PP of the Pokemon.
|
||||
@@ -1118,7 +1119,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Heal(uint heal, bool allowRevive, EventBatchId batchId = default, bool forceHeal = false)
|
||||
public bool Heal(uint heal, bool allowRevive, EventBatchId batchId = default, bool forceHeal = false,
|
||||
EventHook? customEventHook = null)
|
||||
{
|
||||
if (IsFainted && !allowRevive)
|
||||
return false;
|
||||
@@ -1137,7 +1139,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
}
|
||||
|
||||
var newHealth = CurrentHealth + heal;
|
||||
BattleData?.Battle.EventHook.Invoke(new HealEvent(this, CurrentHealth, newHealth)
|
||||
customEventHook ??= BattleData?.Battle.EventHook;
|
||||
customEventHook?.Invoke(new HealEvent(this, CurrentHealth, newHealth)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user