mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01: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:
parent
7737f9ab72
commit
27e3b802b7
@ -33,13 +33,18 @@ void TrainerAction::Learn(uint32 cost, TrainerSpell const* tSpell, std::ostrings
|
|||||||
if (spellInfo->Effects[j].Effect == SPELL_EFFECT_LEARN_SPELL)
|
if (spellInfo->Effects[j].Effect == SPELL_EFFECT_LEARN_SPELL)
|
||||||
{
|
{
|
||||||
uint32 learnedSpell = spellInfo->Effects[j].TriggerSpell;
|
uint32 learnedSpell = spellInfo->Effects[j].TriggerSpell;
|
||||||
|
if (!bot->HasSpell(learnedSpell))
|
||||||
|
{
|
||||||
bot->learnSpell(learnedSpell);
|
bot->learnSpell(learnedSpell);
|
||||||
learned = true;
|
learned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!learned)
|
if (!learned && !bot->HasSpell(tSpell->spell))
|
||||||
|
{
|
||||||
bot->learnSpell(tSpell->spell);
|
bot->learnSpell(tSpell->spell);
|
||||||
|
}
|
||||||
|
|
||||||
msg << " - learned";
|
msg << " - learned";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user