mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
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:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user