Adds Script Hook to change stat boost changes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user