Adds parameters to OnDamage to show the health change.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-21 14:13:31 +01:00
parent 0912483ba8
commit 9cb2a27007
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 3 additions and 4 deletions

View File

@ -210,11 +210,9 @@ namespace CreatureLib::Battling {
if (battle.HasValue()) { if (battle.HasValue()) {
battle.GetValue()->TriggerEventListener<DamageEvent>(this, source, _currentHealth, newHealth); battle.GetValue()->TriggerEventListener<DamageEvent>(this, source, _currentHealth, newHealth);
battle.GetValue()->RegisterHistoryElement<DamageHistory>(this, damage, source); battle.GetValue()->RegisterHistoryElement<DamageHistory>(this, damage, source);
HOOK(OnDamage, this, this, source, _currentHealth, newHealth);
} }
_currentHealth = newHealth; _currentHealth = newHealth;
if (battle.HasValue()) {
HOOK(OnDamage, this, this, source);
}
if (IsFainted() && damage > 0 && battle != nullptr) { if (IsFainted() && damage > 0 && battle != nullptr) {
OnFaint(source); OnFaint(source);

View File

@ -114,7 +114,8 @@ namespace CreatureLib::Battling {
[[maybe_unused]] bool* result){}; [[maybe_unused]] bool* result){};
virtual void OnEndTurn(){}; 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 OnFaint(Creature*, DamageSource){};
virtual void OnSwitchIn(Creature*){}; virtual void OnSwitchIn(Creature*){};
}; };