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)
|
if (damage == 0)
|
||||||
return;
|
return;
|
||||||
// HOOK: On Damage
|
|
||||||
auto newHealth = _currentHealth - damage;
|
auto newHealth = _currentHealth - damage;
|
||||||
auto battle = this->GetBattle();
|
auto battle = this->GetBattle();
|
||||||
if (battle.HasValue()) {
|
if (battle.HasValue()) {
|
||||||
|
@ -213,6 +212,9 @@ namespace CreatureLib::Battling {
|
||||||
battle.GetValue()->RegisterHistoryElement<DamageHistory>(this, damage, source);
|
battle.GetValue()->RegisterHistoryElement<DamageHistory>(this, damage, source);
|
||||||
}
|
}
|
||||||
_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);
|
||||||
|
|
|
@ -114,6 +114,7 @@ namespace CreatureLib::Battling {
|
||||||
[[maybe_unused]] bool* result){};
|
[[maybe_unused]] bool* result){};
|
||||||
|
|
||||||
virtual void OnEndTurn(){};
|
virtual void OnEndTurn(){};
|
||||||
|
virtual void OnDamage(Creature*, DamageSource){};
|
||||||
virtual void OnFaint(Creature*, DamageSource){};
|
virtual void OnFaint(Creature*, DamageSource){};
|
||||||
virtual void OnSwitchIn(Creature*){};
|
virtual void OnSwitchIn(Creature*){};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue