From 179b94a677735e75be16ff763318a34ab89f07e9 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 12 Feb 2022 15:43:15 +0100 Subject: [PATCH] Adds hook to completely prevent stat boost change --- src/Battling/Models/Creature.cpp | 6 ++++++ src/Battling/ScriptHandling/BattleScript.hpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 2d9087a..ef3d493 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -141,6 +141,12 @@ namespace CreatureLib::Battling { } bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { + bool preventStatChange = false; + HOOK(PreventStatBoostChange, this, this, stat, diffAmount, &preventStatChange); + if (preventStatChange) { + return false; + } + HOOK(ModifyStatBoostChange, this, this, stat, &diffAmount); bool changed = false; auto oldValue = this->_statBoost.GetStat(stat); diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 67073a6..8e64d6b 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -86,6 +86,8 @@ namespace CreatureLib::Battling { virtual void OnFaintingOpponent(_par_ const ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitNumber){}; + virtual void PreventStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat, + _par_ int8_t diffAmount, _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,