diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index a5b8804..266b344 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -205,7 +205,6 @@ namespace CreatureLib::Battling { } if (damage == 0) return; - // HOOK: On Damage auto newHealth = _currentHealth - damage; auto battle = this->GetBattle(); if (battle.HasValue()) { @@ -213,6 +212,9 @@ namespace CreatureLib::Battling { battle.GetValue()->RegisterHistoryElement(this, damage, source); } _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 becd6de..d24349f 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -114,6 +114,7 @@ namespace CreatureLib::Battling { [[maybe_unused]] bool* result){}; virtual void OnEndTurn(){}; + virtual void OnDamage(Creature*, DamageSource){}; virtual void OnFaint(Creature*, DamageSource){}; virtual void OnSwitchIn(Creature*){}; };