From 0e83bda84c1e35f5f7adecec76c824a4c2c3da4b Mon Sep 17 00:00:00 2001 From: David Date: Sun, 7 Apr 2024 13:18:34 +0100 Subject: [PATCH] Remove world buffs when the strategy gets removed --- playerbot/strategy/generic/NonCombatStrategy.cpp | 16 ++++++++++++++++ playerbot/strategy/generic/NonCombatStrategy.h | 1 + 2 files changed, 17 insertions(+) diff --git a/playerbot/strategy/generic/NonCombatStrategy.cpp b/playerbot/strategy/generic/NonCombatStrategy.cpp index 9801e4e2..ee54f2ed 100644 --- a/playerbot/strategy/generic/NonCombatStrategy.cpp +++ b/playerbot/strategy/generic/NonCombatStrategy.cpp @@ -62,3 +62,19 @@ void WorldBuffStrategy::InitNonCombatTriggers(std::list& triggers) "need world buff", NextAction::array(0, new NextAction("world buff", 1.0f), NULL))); } + +void WorldBuffStrategy::OnStrategyRemoved(BotState state) +{ + // Remove world buffs + Player* bot = ai->GetBot(); + if (bot) + { + for (auto& wb : sPlayerbotAIConfig.worldBuffs) + { + if (bot->HasAura(wb.spellId)) + { + bot->RemoveAurasDueToSpell(wb.spellId); + } + } + } +} diff --git a/playerbot/strategy/generic/NonCombatStrategy.h b/playerbot/strategy/generic/NonCombatStrategy.h index ef1c0760..05658fac 100644 --- a/playerbot/strategy/generic/NonCombatStrategy.h +++ b/playerbot/strategy/generic/NonCombatStrategy.h @@ -53,5 +53,6 @@ namespace ai protected: virtual void InitNonCombatTriggers(std::list& triggers) override; + void OnStrategyRemoved(BotState state) override; }; }