Adds OnDamage script hook.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
40d6e8a389
commit
0912483ba8
|
@ -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);
|
||||
|
|
|
@ -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*){};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue