Adds OnDamage script hook.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-11-21 14:02:00 +01:00
parent 40d6e8a389
commit 0912483ba8
2 changed files with 4 additions and 1 deletions

View File

@@ -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<DamageHistory>(this, damage, source);
}
_currentHealth = newHealth;
if (battle.HasValue()) {
HOOK(OnDamage, this, this, source);
}
if (IsFainted() && damage > 0 && battle != nullptr) {
OnFaint(source);