Check whether a battle has been set when calling Damage function.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
bb9b9609a6
commit
fc5826edb1
|
@ -101,7 +101,10 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
|
||||||
}
|
}
|
||||||
// HOOK: On Damage
|
// HOOK: On Damage
|
||||||
auto newHealth = _currentHealth - damage;
|
auto newHealth = _currentHealth - damage;
|
||||||
this->GetBattle()->TriggerEventListener(new DamageEvent(this, source, _currentHealth, newHealth));
|
auto battle = this->GetBattle();
|
||||||
|
if (battle != nullptr) {
|
||||||
|
battle->TriggerEventListener(new DamageEvent(this, source, _currentHealth, newHealth));
|
||||||
|
}
|
||||||
_currentHealth = newHealth;
|
_currentHealth = newHealth;
|
||||||
|
|
||||||
if (IsFainted() && damage > 0) {
|
if (IsFainted() && damage > 0) {
|
||||||
|
|
Loading…
Reference in New Issue