From 9cb2a2700768c4db7ce6e90d7aef6b85dae2be50 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 21 Nov 2021 14:13:31 +0100 Subject: [PATCH] Adds parameters to OnDamage to show the health change. --- src/Battling/Models/Creature.cpp | 4 +--- src/Battling/ScriptHandling/BattleScript.hpp | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 266b344..5f2e05f 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -210,11 +210,9 @@ namespace CreatureLib::Battling { if (battle.HasValue()) { battle.GetValue()->TriggerEventListener(this, source, _currentHealth, newHealth); battle.GetValue()->RegisterHistoryElement(this, damage, source); + HOOK(OnDamage, this, this, source, _currentHealth, newHealth); } _currentHealth = newHealth; - if (battle.HasValue()) { - HOOK(OnDamage, this, this, source); - } if (IsFainted() && damage > 0 && battle != nullptr) { OnFaint(source); diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index d24349f..8ab21dc 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -114,7 +114,8 @@ namespace CreatureLib::Battling { [[maybe_unused]] bool* result){}; virtual void OnEndTurn(){}; - virtual void OnDamage(Creature*, DamageSource){}; + virtual void OnDamage(Creature*, DamageSource, [[maybe_unused]] u32 oldHealth, + [[maybe_unused]] u32 newHealth){}; virtual void OnFaint(Creature*, DamageSource){}; virtual void OnSwitchIn(Creature*){}; };