From 27e3b802b7707d5d8d4292683536130679ef0a9c Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Fri, 18 Apr 2025 18:04:35 -0300 Subject: [PATCH] Fix: Prevents bots from learning spells twice (#1211) * Fix: Prevents bots from learning spells twice Added bot->HasSpell() check before calling bot->learnSpell() to ensure the bot does not learn spells it already has. This avoids redundant behavior, possible unnecessary logging, and inconsistencies in learning spells trained with SPELL_EFFECT_LEARN_SPELL. * Possible fix --- src/strategy/actions/TrainerAction.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/strategy/actions/TrainerAction.cpp b/src/strategy/actions/TrainerAction.cpp index e9004c36..6c38b463 100644 --- a/src/strategy/actions/TrainerAction.cpp +++ b/src/strategy/actions/TrainerAction.cpp @@ -33,13 +33,18 @@ void TrainerAction::Learn(uint32 cost, TrainerSpell const* tSpell, std::ostrings if (spellInfo->Effects[j].Effect == SPELL_EFFECT_LEARN_SPELL) { uint32 learnedSpell = spellInfo->Effects[j].TriggerSpell; - bot->learnSpell(learnedSpell); - learned = true; + if (!bot->HasSpell(learnedSpell)) + { + bot->learnSpell(learnedSpell); + learned = true; + } } } - if (!learned) + if (!learned && !bot->HasSpell(tSpell->spell)) + { bot->learnSpell(tSpell->spell); + } msg << " - learned"; }