Skip to content

Commit

Permalink
Alt bots learn dropped book spells (#123)
Browse files Browse the repository at this point in the history
* Added config settings to config file.

Added config variables to PlayerbotAIConfig.cpp and PlayerbotAIConfig.h

Added the spell list to and function to AutoLearnSpellsAction.cpp and AutoLearnSpellsAction.h

* Finished AutoLearnSpellAction::LearnDroppedSpells. Just needs testing.

* Fixed bug that classes only learned spell if they were the level, not if there were greater than the level and did not have the skill.

* Update aiplayerbot.conf.dist.in

Added a more detailed explanation of what AiPlayerbot.AutoLearnDroppedSpells does.

* Review changes

Added default values to TBC and WoTLK aiplayerbot.conf files.

Added ifdef surounding call for LearnDroppedSpells if statement.
  • Loading branch information
Pip1987 authored Jan 14, 2025
1 parent 9069e42 commit 6203587
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 1 deletion.
3 changes: 2 additions & 1 deletion playerbot/PlayerbotAIConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ bool PlayerbotAIConfig::Initialize()
autoPickTalents = config.GetStringDefault("AiPlayerbot.AutoPickTalents", "no");
autoLearnTrainerSpells = config.GetBoolDefault("AiPlayerbot.AutoLearnTrainerSpells", false);
autoLearnQuestSpells = config.GetBoolDefault("AiPlayerbot.AutoLearnQuestSpells", false);
autoDoQuests = config.GetBoolDefault("AiPlayerbot.AutoDoQuests", true);
autoLearnDroppedSpells = config.GetBoolDefault("AiPlayerbot.AutoLearnDroppedSpells", false);
autoDoQuests = config.GetBoolDefault("AiPlayerbot.AutoDoQuests", false);

This comment has been minimized.

Copy link
@Exxenoz

Exxenoz Jan 14, 2025

Member

Was it intended to change the default for autoDoQuests back to false?

This comment has been minimized.

Copy link
@Pip1987

Pip1987 Jan 14, 2025

Author Contributor

No that wasn't intended, this config is older than the update. I thought I pulled the correct version before hand.

This comment has been minimized.

Copy link
@Pip1987

Pip1987 Jan 14, 2025

Author Contributor

Files updated, but need to rebase. I'll get that sorted in the next couple of hours and get a new pr.

syncLevelWithPlayers = config.GetBoolDefault("AiPlayerbot.SyncLevelWithPlayers", false);
syncLevelMaxAbove = config.GetIntDefault("AiPlayerbot.SyncLevelMaxAbove", 5);
syncLevelNoPlayer = config.GetIntDefault("AiPlayerbot.SyncLevelNoPlayer", randombotStartingLevel);
Expand Down
1 change: 1 addition & 0 deletions playerbot/PlayerbotAIConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class PlayerbotAIConfig
std::string autoPickTalents;
bool autoLearnTrainerSpells;
bool autoLearnQuestSpells;
bool autoLearnDroppedSpells;
bool autoDoQuests;
bool syncLevelWithPlayers;
uint32 syncLevelMaxAbove, syncLevelNoPlayer;
Expand Down
4 changes: 4 additions & 0 deletions playerbot/aiplayerbot.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ AiPlayerbot.AutoLearnTrainerSpells = 0
# Default: 0 (disabled)
AiPlayerbot.AutoLearnQuestSpells = 0

# Alt Bots automatically learn class spells from books dropped from dungeons and raids when leveled and they reached the required level of the book.
# Default: 0 (disabled)
AiPlayerbot.AutoLearnDroppedSpells = 0

# Random Bots will pick quests on their own and try to complete
# Default: 0 (disabled)
# AiPlayerbot.AutoDoQuests = 1
Expand Down
4 changes: 4 additions & 0 deletions playerbot/aiplayerbot.conf.dist.in.tbc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ AiPlayerbot.AutoLearnTrainerSpells = 0
# Default: 0 (disabled)
AiPlayerbot.AutoLearnQuestSpells = 0

# Alt Bots automatically learn class spells from books dropped from dungeons and raids when leveled and they reached the required level of the book. Classic Only.
# Default: 0 (disabled)
AiPlayerbot.AutoLearnDroppedSpells = 0

# Random Bots will pick quests on their own and try to complete
# Default: 0 (disabled)
# AiPlayerbot.AutoDoQuests = 1
Expand Down
4 changes: 4 additions & 0 deletions playerbot/aiplayerbot.conf.dist.in.wotlk
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ AiPlayerbot.AutoLearnTrainerSpells = 0
# Default: 0 (disabled)
AiPlayerbot.AutoLearnQuestSpells = 0

# Alt Bots automatically learn class spells from books dropped from dungeons and raids when leveled and they reached the required level of the book. Classic Only.
# Default: 0 (disabled)
AiPlayerbot.AutoLearnDroppedSpells = 0

# Random Bots will pick quests on their own and try to complete
# Default: 0 (disabled)
# AiPlayerbot.AutoDoQuests = 1
Expand Down
42 changes: 42 additions & 0 deletions playerbot/strategy/actions/AutoLearnSpellAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ void AutoLearnSpellAction::LearnSpells(std::ostringstream* out)
if (sPlayerbotAIConfig.autoLearnTrainerSpells)
LearnTrainerSpells(out);

#ifdef MANGOSBOT_ZERO
if (sPlayerbotAIConfig.autoLearnDroppedSpells)
LearnDroppedSpells(out);
#endif

if (!ai->HasActivePlayerMaster()) //Hunter spells for pets.
{
if (bot->getClass() == CLASS_HUNTER && bot->GetLevel() >= 10)
Expand Down Expand Up @@ -204,6 +209,43 @@ void AutoLearnSpellAction::LearnQuestSpells(std::ostringstream* out)
}
}
}

void AutoLearnSpellAction::LearnDroppedSpells(std::ostringstream* out)
{ // Class Level // Spells
std::map<uint8, std::map<uint8, std::vector<uint32>>> spellList;
spellList[CLASS_WARRIOR][60] = { 25289, 25288, 25286 };
spellList[CLASS_PALADIN][60] = { 25291, 25290, 25292 };
spellList[CLASS_HUNTER][60] = { 19801, 25296, 25294, 25295 };
spellList[CLASS_ROGUE][60] = { 25300, 25347, 25302, 31016 };
spellList[CLASS_PRIEST][48] = { 21562 };
// Spell 27683 Prayer of Shadow Protection https://www.wowhead.com/classic/spell=27683/prayer-of-shadow-protection book requires level 60, spell requires 56.
// Went with the book requirement.
spellList[CLASS_PRIEST][60] = { 25314, 25315, 25316,21564,27683 };
spellList[CLASS_SHAMAN][60] = { 29228, 25359, 25357, 25361 };
spellList[CLASS_MAGE][56] = { 23028 };
// Spell 25345 Arcane Missiles https://www.wowhead.com/classic/spell=25345/arcane-missiles book requires level 60, spell requires 56.
// Went with the book requirement.
spellList[CLASS_MAGE][60] = { 28612, 28609, 25345, 25306, 25304, 28271 };
spellList[CLASS_WARLOCK][50] = { 1122 };
spellList[CLASS_WARLOCK][60] = { 18540, 25311, 25309, 25307, 28610 };
spellList[CLASS_DRUID][50] = { 21849 };
spellList[CLASS_DRUID][60] = { 31018, 25297, 25299, 25298, 21850 };

for (const auto& levelSpells : spellList[bot->getClass()])
{
if (bot->GetLevel() >= levelSpells.first)
{
for (uint32 spellId : levelSpells.second)
{
if (!bot->HasSpell(spellId))
{
bot->learnSpell(spellId, false);
}
}
}
}
}

/**
* Attempts to add the quest item
* If the bot's bag is full report to player.
Expand Down
1 change: 1 addition & 0 deletions playerbot/strategy/actions/AutoLearnSpellAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace ai
void LearnSpells(std::ostringstream* out);
void LearnTrainerSpells(std::ostringstream* out);
void LearnQuestSpells(std::ostringstream* out);
void LearnDroppedSpells(std::ostringstream* out);
void GetClassQuestItem(Quest const* quest, std::ostringstream* out);
bool LearnSpell(uint32 spellId, std::ostringstream* out);
bool LearnSpellFromSpell(uint32 spellId, std::ostringstream* out);
Expand Down

0 comments on commit 6203587

Please sign in to comment.