Adds Script Hook to change stat boost changes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-12 15:05:42 +01:00
parent 6da591dd92
commit 34f1e43269
3 changed files with 80 additions and 81 deletions

View File

@@ -141,6 +141,7 @@ namespace CreatureLib::Battling {
}
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
HOOK(ModifyStatBoostChange, this, this, stat, &diffAmount);
bool changed = false;
auto oldValue = this->_statBoost.GetStat(stat);
if (diffAmount > 0) {
@@ -148,11 +149,14 @@ namespace CreatureLib::Battling {
} else if (diffAmount < 0) {
changed = this->_statBoost.DecreaseStatBy(stat, -diffAmount);
}
if (this->GetBattle().HasValue()) {
auto newValue = this->_statBoost.GetStat(stat);
this->GetBattle().GetValue()->TriggerEventListener<ChangeStatBoostEvent>(this, stat, oldValue, newValue);
if (changed) {
if (this->GetBattle().HasValue()) {
auto newValue = this->_statBoost.GetStat(stat);
this->GetBattle().GetValue()->TriggerEventListener<ChangeStatBoostEvent>(this, stat, oldValue,
newValue);
}
this->RecalculateBoostedStat(stat);
}
this->RecalculateBoostedStat(stat);
return changed;
}