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
This commit is contained in:
EricksOliveira
2025-04-18 18:04:35 -03:00
committed by GitHub
parent 7737f9ab72
commit 27e3b802b7

View File

@@ -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";
}