From a015a3fc62aa3e88bbd2e54ddd172c394fac0fcc Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 12 Mar 2022 11:34:00 +0100 Subject: [PATCH] Adds parameter to change stat boost to determine whether its selfinflicted --- src/Battling/Models/Creature.cpp | 4 ++-- src/Battling/Models/Creature.hpp | 2 +- src/Battling/ScriptHandling/BattleScript.hpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 8ca3944..ffda923 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -145,9 +145,9 @@ namespace CreatureLib::Battling { } } - bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { + bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount, bool selfInflicted) { bool preventStatChange = false; - HOOK(PreventStatBoostChange, this, this, stat, diffAmount, &preventStatChange); + HOOK(PreventStatBoostChange, this, this, stat, diffAmount, selfInflicted, &preventStatChange); if (preventStatChange) { return false; } diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index e0960c2..4df8559 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -219,7 +219,7 @@ namespace CreatureLib::Battling { // region Stat APIs - bool ChangeStatBoost(Library::Statistic stat, int8_t diffAmount); + bool ChangeStatBoost(Library::Statistic stat, int8_t diffAmount, bool selfInflicted = false); [[nodiscard]] inline uint32_t GetFlatStat(Library::Statistic stat) const { return _flatStats.GetStat(stat); } [[nodiscard]] inline uint32_t GetBoostedStat(Library::Statistic stat) const { return _boostedStats.GetStat(stat); diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 30f8e0c..4280b2e 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -91,7 +91,7 @@ namespace CreatureLib::Battling { _par_ u8 hitNumber){}; virtual void PreventStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat, - _par_ int8_t diffAmount, _par_ bool* prevent){}; + _par_ int8_t diffAmount, _par_ bool selfInflicted, _par_ bool* prevent){}; virtual void ModifyStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat, _par_ int8_t* diffAmount){}; virtual void PreventSecondaryEffects(_par_ const ExecutingAttack* attack, _par_ Creature* target,