mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 09:50:27 +00:00
**Original issue:** Bots/Characters received duplicate spells during randomization process. **Root cause:** When `PlayerbotFactory::Randomize` is processed, `InitSkills` is called AFTER `InitAvailableSpells`, which causes the duplicate spells issue because the skillline ability spell is already learned when processing spells from trainers (`InitAvailableSpells`). We simply need to change the order of the randomization process: skills should be handled first, then spells. An alternative approach would be to adjust the skillline abilities and check each spell for every skill, but that seems redundant since we already have checks for the trainer's spells. `InitSkills` -> `SetRandomSkill` -> `SetSkill` -> `learnSkillRewardedSpells` -> `learnSpell` -> duplicate error... **Steps to reproduce:** 1. create common character and login with it 2. set level for this character eq. 80 (`.set level 79`) 3. create and run macro: ``` /g .playerbots bot initself /g .saveall ``` 4. logout -> login and run macro again **Note:** Also added checks for the trainer's spells since `GetSpell` can return nullptr. Updated `LearnQuestSpells` after recent changes and used the same logic and implementation from `Player::learnQuestRewardedSpells`. Yes, we need to cast spells, or we should handle all spell effects that quests/trainers have (for ex.: `SPELL_EFFECT_SKILL_STEP`, `SPELL_EFFECT_UNLEARN_SPECIALIZATION`, `SPELL_EFFECT_BIND`).
35 lines
956 B
C++
35 lines
956 B
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
|
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
|
*/
|
|
|
|
#ifndef _PLAYERBOT_AUTOTELEPORTFORLEVELACTION_H
|
|
#define _PLAYERBOT_AUTOTELEPORTFORLEVELACTION_H
|
|
|
|
#include "Action.h"
|
|
|
|
class PlayerbotAI;
|
|
|
|
class AutoMaintenanceOnLevelupAction : public Action
|
|
{
|
|
public:
|
|
AutoMaintenanceOnLevelupAction(PlayerbotAI* botAI, std::string const name = "auto maintenance on levelup")
|
|
: Action(botAI, name)
|
|
{
|
|
}
|
|
|
|
bool Execute(Event event);
|
|
|
|
protected:
|
|
void AutoTeleportForLevel();
|
|
void AutoPickTalents();
|
|
void AutoLearnSpell();
|
|
void AutoUpgradeEquip();
|
|
void LearnSpells(std::ostringstream* out);
|
|
void LearnTrainerSpells(std::ostringstream* out);
|
|
void LearnQuestSpells(std::ostringstream* out);
|
|
std::string const FormatSpell(SpellInfo const* sInfo);
|
|
};
|
|
|
|
#endif
|