Skip to content

Commit

Permalink
Merge pull request liyunfan1223#171 from oiuv/player_bots
Browse files Browse the repository at this point in the history
add config for another player's character as bot
  • Loading branch information
liyunfan1223 authored Apr 2, 2024
2 parents 39eb6a0 + 308cf4f commit de26d37
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions conf/playerbots.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ AiPlayerbot.DeleteRandomBotAccounts = 0
# auto-login all player alts as bots on player login
AiPlayerbot.BotAutologin = 0

# Allow login other players' characters as bots
# Default: 0 (disabled)
AiPlayerbot.AllowPlayerBots = 0

# Guild Task system
AiPlayerbot.EnableGuildTasks = 0

Expand Down
13 changes: 7 additions & 6 deletions src/PlayerbotAIConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool PlayerbotAIConfig::Initialize()
iterationsPerTick = sConfigMgr->GetOption<int32>("AiPlayerbot.IterationsPerTick", 100);

allowGuildBots = sConfigMgr->GetOption<bool>("AiPlayerbot.AllowGuildBots", true);
allowPlayerBots = sConfigMgr->GetOption<bool>("AiPlayerbot.AllowPlayerBots", false);

randomBotMapsAsString = sConfigMgr->GetOption<std::string>("AiPlayerbot.RandomBotMaps", "0,1,530,571");
LoadList<std::vector<uint32>>(randomBotMapsAsString, randomBotMaps);
Expand All @@ -106,7 +107,7 @@ bool PlayerbotAIConfig::Initialize()
LoadList<std::vector<uint32>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.RandomBotSpellIds", "54197"), randomBotSpellIds);
LoadList<std::vector<uint32>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.PvpProhibitedZoneIds", "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395"), pvpProhibitedZoneIds);
LoadList<std::vector<uint32>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.PvpProhibitedAreaIds", "976,35"), pvpProhibitedAreaIds);

LoadList<std::vector<uint32>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.RandomBotQuestIds", "7848,3802,5505,6502,7761"), randomBotQuestIds);

botAutologin = sConfigMgr->GetOption<bool>("AiPlayerbot.BotAutologin", false);
Expand Down Expand Up @@ -171,7 +172,7 @@ bool PlayerbotAIConfig::Initialize()
}
for (uint32 spec = 0; spec < MAX_SPECNO; ++spec)
{
std::ostringstream os;
std::ostringstream os;
os << "AiPlayerbot.PremadeSpecName." << cls << "." << spec;
premadeSpecName[cls][spec] = sConfigMgr->GetOption<std::string>(os.str().c_str(), "", false);
os.str("");
Expand All @@ -193,7 +194,7 @@ bool PlayerbotAIConfig::Initialize()
}
for (uint32 spec = 0; spec < 3; ++spec)
{
std::ostringstream os;
std::ostringstream os;
os << "AiPlayerbot.RandomClassSpecProb." << cls << "." << spec;
randomClassSpecProb[cls][spec] = sConfigMgr->GetOption<uint32>(os.str().c_str(), 33);
os.str("");
Expand Down Expand Up @@ -298,7 +299,7 @@ bool PlayerbotAIConfig::Initialize()
autoUpgradeEquip = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoUpgradeEquip", false);
autoLearnTrainerSpells = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoLearnTrainerSpells", true);
autoLearnQuestSpells = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoLearnQuestSpells", false);
autoTeleportForLevel = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoTeleportForLevel", false);
autoTeleportForLevel = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoTeleportForLevel", false);
autoDoQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoDoQuests", false);
syncLevelWithPlayers = sConfigMgr->GetOption<bool>("AiPlayerbot.SyncLevelWithPlayers", false);
freeFood = sConfigMgr->GetOption<bool>("AiPlayerbot.FreeFood", true);
Expand Down Expand Up @@ -531,7 +532,7 @@ static std::vector<std::string> split(const std::string &str, const std::string

std::vector<std::vector<uint32>> PlayerbotAIConfig::ParseTempTalentsOrder(uint32 cls, std::string tab_link) {
// check bad link
uint32 classMask = 1 << (cls - 1);
uint32 classMask = 1 << (cls - 1);
std::vector<std::vector<uint32>> res;
std::vector<std::string> tab_links = split(tab_link, "-");
std::map<uint32, std::vector<TalentEntry const*>> spells;
Expand Down Expand Up @@ -575,4 +576,4 @@ std::vector<std::vector<uint32>> PlayerbotAIConfig::ParseTempTalentsOrder(uint32
res.insert(res.end(), order.begin(), order.end());
}
return res;
}
}
8 changes: 4 additions & 4 deletions src/PlayerbotAIConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PlayerbotAIConfig
bool IsInPvpProhibitedArea(uint32 id);

bool enabled;
bool allowGuildBots;
bool allowGuildBots, allowPlayerBots;
uint32 globalCoolDown, reactDelay, maxWaitForMove, expireActionTime, dispelAuraDuration, passiveDelay, repeatDelay,
errorDelay, rpgDelay, sitDelay, returnDelay, lootDelay;
float sightDistance, spellDistance, reactDistance, grindDistance, lootDistance, shootDistance,
Expand Down Expand Up @@ -103,11 +103,11 @@ class PlayerbotAIConfig
std::string randomBotCombatStrategies, randomBotNonCombatStrategies;
uint32 randomBotMinLevel, randomBotMaxLevel;
float randomChangeMultiplier;


// std::string premadeLevelSpec[MAX_CLASSES][10][91]; //lvl 10 - 100
// ClassSpecs classSpecs[MAX_CLASSES];

std::string premadeSpecName[MAX_CLASSES][MAX_SPECNO];
std::string premadeSpecGlyph[MAX_CLASSES][MAX_SPECNO];
std::vector<uint32> parsedSpecGlyph[MAX_CLASSES][MAX_SPECNO];
Expand Down
3 changes: 3 additions & 0 deletions src/PlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,9 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje
if (ObjectAccessor::FindPlayer(guid))
return "player already logged in";

if (!sPlayerbotAIConfig->allowPlayerBots && !isRandomAccount && !isMasterAccount)
return "You cannot login another player's character as bot.";

AddPlayerBot(guid, masterAccountId);
return "ok";
}
Expand Down

0 comments on commit de26d37

Please sign in to comment.