From 917e55c92a78b02a138ce4d40e1a6c21af1813b1 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 27 Oct 2023 21:54:35 +0800 Subject: [PATCH] rndbot teleport to city --- conf/playerbots.conf.dist | 283 +------------------------------------ src/PlayerbotAIConfig.cpp | 95 +++++++------ src/PlayerbotAIConfig.h | 1 + src/RandomPlayerbotMgr.cpp | 90 +++++++++--- src/RandomPlayerbotMgr.h | 3 + 5 files changed, 127 insertions(+), 345 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 13535388..cd3e47fc 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -201,285 +201,6 @@ AiPlayerbot.AutoUpgradeEquip = 1 # Default: 1 (enabled) AiPlayerbot.AutoDoQuests = 1 -################################################################################## -# # -# All other parameters are optional but can be changed by uncommenting them here # -# # -################################################################################## - -################################################################################## -# # -# Premade builds # -# # -################################################################################## -# -# AiPlayerbot.PremadeSpecName.. = #Name of the talent specialisation -# AiPlayerbot.PremadeSpecProb.. = #Probability Randombots will pick this spec. (default 100) -# AiPlayerbot.PremadeSpecLink... = #Wowhead style link the bot should work towards at given level. - -# Preset talents supplied by Lidocain. Do you have more/improved specs? Let us know! -# Warrior -AiPlayerbot.PremadeSpecName.1.0 = pve arms -AiPlayerbot.PremadeSpecLink.1.0.80 = 3022032123335100202012013031251-32505010002 -AiPlayerbot.PremadeSpecName.1.1 = pve fury -AiPlayerbot.PremadeSpecLink.1.1.80 = 30202300233-305053000500310153120511351 -AiPlayerbot.PremadeSpecName.1.2 = pve prot -AiPlayerbot.PremadeSpecLink.1.2.80 = 05-3025-053351225000210521030113321 - -AiPlayerbot.PremadeSpecName.1.3 = pvp arms -AiPlayerbot.PremadeSpecLink.1.3.80 = 3020232023335100222212013221251-32500013 -AiPlayerbot.PremadeSpecName.1.4 = pvp fury -AiPlayerbot.PremadeSpecLink.1.4.80 = 32003200233-325000131504012050122511351 -AiPlayerbot.PremadeSpecName.1.5 = pvp prot -AiPlayerbot.PremadeSpecLink.1.5.80 = 32003200233-325000131504012050122511351 - - -# Paladin -AiPlayerbot.PremadeSpecName.2.1 = Ret Pvp -AiPlayerbot.PremadeSpecProb.2.1 = 100 -AiPlayerbot.PremadeSpecLink.2.1.80 = 05002-053201-05222150203331322133201331 - -AiPlayerbot.PremadeSpecName.2.2 = Prot Pvp -AiPlayerbot.PremadeSpecProb.2.2 = 100 -AiPlayerbot.PremadeSpecLink.2.2.80 = -15320130223122321333312321052300500002 - -AiPlayerbot.PremadeSpecName.2.3 = Holy Pvp -AiPlayerbot.PremadeSpecProb.2.3 = 100 -AiPlayerbot.PremadeSpecLink.2.3.80 = 503521503000131501034142215032013122 - -AiPlayerbot.PremadeSpecName.2.4 = Ret Pve -AiPlayerbot.PremadeSpecProb.2.4 = 100 -AiPlayerbot.PremadeSpecLink.2.4.80 = 050501-05-05232051203331302133231331 - -AiPlayerbot.PremadeSpecName.2.5 = Prot Pve -AiPlayerbot.PremadeSpecProb.2.5 = 100 -AiPlayerbot.PremadeSpecLink.2.5.80 = -050051352031323113333123215023005 - -AiPlayerbot.PremadeSpecName.2.6 = Holy Pve -AiPlayerbot.PremadeSpecProb.2.6 = 100 -AiPlayerbot.PremadeSpecLink.2.6.80 = 503501510200130531005152215-503205 - - -# Hunter -AiPlayerbot.PremadeSpecName.3.1 = BM Pvp -AiPlayerbot.PremadeSpecProb.3.1 = 100 -AiPlayerbot.PremadeSpecLink.3.1.80 = 05203001505212233100531351005305131 - -AiPlayerbot.PremadeSpecName.3.2 = MM Pvp -AiPlayerbot.PremadeSpecProb.3.2 = 100 -AiPlayerbot.PremadeSpecLink.3.2.80 = 052-025305101030213233115031051530020201 - -AiPlayerbot.PremadeSpecName.3.3 = Surv Pvp -AiPlayerbot.PremadeSpecProb.3.3 = 100 -AiPlayerbot.PremadeSpecLink.3.3.80 = -005305101-3300132510233330532135001031 - -AiPlayerbot.PremadeSpecName.3.4 = BM Pve -AiPlayerbot.PremadeSpecProb.3.4 = 100 -AiPlayerbot.PremadeSpecLink.3.4.80 = 51200201505112253100531351-015305021 - -AiPlayerbot.PremadeSpecName.3.5 = MM Pve -AiPlayerbot.PremadeSpecProb.3.5 = 100 -AiPlayerbot.PremadeSpecLink.3.5.80 = 502-035305101230013233135031351-5000002 - -AiPlayerbot.PremadeSpecName.3.6 = Surv Pve -AiPlayerbot.PremadeSpecProb.3.6 = 100 -AiPlayerbot.PremadeSpecLink.3.6.80 = -0053041-5000032500033330523134321331 - - -# Rogue -AiPlayerbot.PremadeSpecName.4.1 = Assassination Pvp -AiPlayerbot.PremadeSpecProb.4.1 = 100 -AiPlayerbot.PremadeSpecLink.4.1.80 = 005303103342102522103031000004-532023203000012 - -AiPlayerbot.PremadeSpecName.4.2 = Combat Pvp -AiPlayerbot.PremadeSpecProb.4.2 = 100 -AiPlayerbot.PremadeSpecLink.4.2.80 = 005-3250302102205015023122021251230023013 - -AiPlayerbot.PremadeSpecName.4.3 = Subtlety Pvp -AiPlayerbot.PremadeSpecProb.4.3 = 100 -AiPlayerbot.PremadeSpecLink.4.3.80 = 0053031-1-5020232033322121350105131251 - -AiPlayerbot.PremadeSpecName.4.4 = Assassination Pve -AiPlayerbot.PremadeSpecProb.4.4 = 100 -AiPlayerbot.PremadeSpecLink.4.4.80 = 005323005350100520103331051-005005003-502 - -AiPlayerbot.PremadeSpecName.4.5 = Combat Pve -AiPlayerbot.PremadeSpecProb.4.5 = 100 -AiPlayerbot.PremadeSpecLink.4.5.80 = 30530000522-0252051000035015223100501251 - -AiPlayerbot.PremadeSpecName.4.6 = Subtlety Pve -AiPlayerbot.PremadeSpecProb.4.6 = 100 -AiPlayerbot.PremadeSpecLink.4.6.80 = 0053231-2-5120222030321121050135231251 - - -# Priest -AiPlayerbot.PremadeSpecName.5.1 = Shadow PvE -AiPlayerbot.PremadeSpecProb.5.1 = 100 -AiPlayerbot.PremadeSpecLink.5.1.80 = 0503203--325023051223010323152301351 - -AiPlayerbot.PremadeSpecName.5.2 = Shadow PvP -AiPlayerbot.PremadeSpecProb.5.2 = 100 -AiPlayerbot.PremadeSpecLink.5.2.80 = 502320013--005023251023112123152311351 - -AiPlayerbot.PremadeSpecName.5.3 = Disc PvE -AiPlayerbot.PremadeSpecProb.5.3 = 100 -AiPlayerbot.PremadeSpecLink.5.3.80 = 050320313030051233132323125100550103 - -AiPlayerbot.PremadeSpecName.5.4 = Disc PvE renew build -AiPlayerbot.PremadeSpecProb.5.4 = 100 -AiPlayerbot.PremadeSpecLink.5.4.80 = 0503203130300512331323231251-03530003 - -AiPlayerbot.PremadeSpecName.5.5 = Holy PvE -AiPlayerbot.PremadeSpecProb.5.5 = 100 -AiPlayerbot.PremadeSpecLink.5.5.80 = 05032031-235050032302152530000331351 - -AiPlayerbot.PremadeSpecName.5.6 = Holy PvP -AiPlayerbot.PremadeSpecProb.5.6 = 100 -AiPlayerbot.PremadeSpecLink.5.6.80 = 500320313030251233102323115120350123 - - -# Death Knight -AiPlayerbot.PremadeSpecName.6.1 = Blood Pvp -AiPlayerbot.PremadeSpecProb.6.1 = 100 -AiPlayerbot.PremadeSpecLink.6.1.80 = 20450215333033132002231313513232 - -AiPlayerbot.PremadeSpecName.6.2 = Unholy Pvp -AiPlayerbot.PremadeSpecProb.6.2 = 100 -AiPlayerbot.PremadeSpecLink.6.2.80 = -320050410002-2301323301002152233101203103151 - -AiPlayerbot.PremadeSpecName.6.3 = Frost Pvp -AiPlayerbot.PremadeSpecProb.6.3 = 100 -AiPlayerbot.PremadeSpecLink.6.3.80 = 0325101303-32025351052203012001033101341 - -AiPlayerbot.PremadeSpecName.6.4 = Blood Pve -AiPlayerbot.PremadeSpecProb.6.4 = 100 -AiPlayerbot.PremadeSpecLink.6.4.80 = 0355220530003313221020131351305-0052 - -AiPlayerbot.PremadeSpecName.6.5 = Unholy Pve -AiPlayerbot.PremadeSpecProb.6.5 = 100 -AiPlayerbot.PremadeSpecLink.6.5.80 = 23050202--2302003350032152003150003133151 - -AiPlayerbot.PremadeSpecName.6.6 = Frost Pve -AiPlayerbot.PremadeSpecProb.6.6 = 100 -AiPlayerbot.PremadeSpecLink.6.6.80 = 03-32002350352203012300033101351230200305 - - -# Shaman -AiPlayerbot.PremadeSpecName.7.1 = Enh Pvp -AiPlayerbot.PremadeSpecProb.7.1 = 100 -AiPlayerbot.PremadeSpecLink.7.1.80 = 05032005-02305233105001333201131231251 - -AiPlayerbot.PremadeSpecName.7.2 = Ele Pvp -AiPlayerbot.PremadeSpecProb.7.2 = 100 -AiPlayerbot.PremadeSpecLink.7.2.80 = 0533001503213051322331351-024252001 - -AiPlayerbot.PremadeSpecName.7.3 = Resto Pvp -AiPlayerbot.PremadeSpecProb.7.3 = 100 -AiPlayerbot.PremadeSpecLink.7.3.80 = -023202301-50032331330313551120321251 - -AiPlayerbot.PremadeSpecName.7.4 = Enh Pve -AiPlayerbot.PremadeSpecProb.7.4 = 100 -AiPlayerbot.PremadeSpecLink.7.4.80 = 053030052-30205033005021333031131131051 - -AiPlayerbot.PremadeSpecName.7.5 = Ele Pve -AiPlayerbot.PremadeSpecProb.7.5 = 100 -AiPlayerbot.PremadeSpecLink.7.5.80 = 3530001523213351322301351005050031 - -AiPlayerbot.PremadeSpecName.7.6 = Resto Pve -AiPlayerbot.PremadeSpecProb.7.6 = 100 -AiPlayerbot.PremadeSpecLink.7.6.80 = -00505031-50005331335310501022331251 - - -# Mage -AiPlayerbot.PremadeSpecName.8.1 = Arcane Pvp -AiPlayerbot.PremadeSpecProb.8.1 = 100 -AiPlayerbot.PremadeSpecLink.8.1.80 = 205025220122032103323102515321--203023001 - -AiPlayerbot.PremadeSpecName.8.2 = Fire Pvp -AiPlayerbot.PremadeSpecProb.8.2 = 100 -AiPlayerbot.PremadeSpecLink.8.2.80 = 230320220122-2305022310220031243122201351 - -AiPlayerbot.PremadeSpecName.8.3 = Frost Pvp -AiPlayerbot.PremadeSpecProb.8.3 = 100 -AiPlayerbot.PremadeSpecLink.8.3.80 = 23002322010203--3533103310203100232102231151 - -AiPlayerbot.PremadeSpecName.8.4 = Arcane Pve -AiPlayerbot.PremadeSpecProb.8.4 = 100 -AiPlayerbot.PremadeSpecLink.8.4.80 = 23500503010023015032310250532103-203023001 - -AiPlayerbot.PremadeSpecName.8.5 = Fire Pve -AiPlayerbot.PremadeSpecProb.8.5 = 100 -AiPlayerbot.PremadeSpecLink.8.5.80 = 23000503310003-0055030012303330053120300351 - -AiPlayerbot.PremadeSpecName.8.6 = Frost Arcane Pve -AiPlayerbot.PremadeSpecProb.8.6 = 100 -AiPlayerbot.PremadeSpecLink.8.6.80 = 23500503110023015032310250532003-203023001 - - -# Warlock -AiPlayerbot.PremadeSpecName.9.1 = Affli CoE Pvp -AiPlayerbot.PremadeSpecProb.9.1 = 100 -AiPlayerbot.PremadeSpecLink.9.1.80 = 03500022312233110535023011510032203011302 - -AiPlayerbot.PremadeSpecName.9.2 = Affli CoA Pvp -AiPlayerbot.PremadeSpecProb.9.2 = 100 -AiPlayerbot.PremadeSpecLink.9.2.80 = 23500022312231110535023011510032203011302 - -AiPlayerbot.PremadeSpecName.9.3 = Destro Pvp -AiPlayerbot.PremadeSpecProb.9.3 = 100 -AiPlayerbot.PremadeSpecLink.9.3.80 = 03-0032203011302-05230015220331351005031051 - -AiPlayerbot.PremadeSpecName.9.4 = Demo Pve -AiPlayerbot.PremadeSpecProb.9.4 = 100 -AiPlayerbot.PremadeSpecLink.9.4.80 = -00320330113520253013523134155000005 - -AiPlayerbot.PremadeSpecName.9.5 = Affli Pve -AiPlayerbot.PremadeSpecProb.9.5 = 100 -AiPlayerbot.PremadeSpecLink.9.5.80 = 2350002030023510253500331151--550000051 - -AiPlayerbot.PremadeSpecName.9.6 = Destro Pve -AiPlayerbot.PremadeSpecProb.9.6 = 100 -AiPlayerbot.PremadeSpecLink.9.6.80 = -03310030003-05203205210331051335230351 - -AiPlayerbot.PremadeSpecName.9.7 = Demo Pve -AiPlayerbot.PremadeSpecProb.9.7 = 100 -AiPlayerbot.PremadeSpecLink.9.7.80 = -00320330113520253013523134155-5 - - -# Druid -AiPlayerbot.PremadeSpecName.11.1 = Feral shred Pvp -AiPlayerbot.PremadeSpecProb.11.1 = 100 -AiPlayerbot.PremadeSpecLink.11.1.80 = -55020213232021205312301331051100550101 - -AiPlayerbot.PremadeSpecName.11.2 = Feral 1v1 Pvp -AiPlayerbot.PremadeSpecProb.11.2 = 100 -AiPlayerbot.PremadeSpecLink.11.2.80 = -53020213032021205312303331351100550001 - -AiPlayerbot.PremadeSpecName.11.3 = Balance Pvp -AiPlayerbot.PremadeSpecProb.11.3 = 100 -AiPlayerbot.PremadeSpecLink.11.3.80 = 5022203125331003213035311231--230033012 - -AiPlayerbot.PremadeSpecName.11.4 = Resto Pvp -AiPlayerbot.PremadeSpecProb.11.4 = 100 -AiPlayerbot.PremadeSpecLink.11.4.80 = 5532000120321--230033312031502221350013200 - -AiPlayerbot.PremadeSpecName.11.5 = Feral dps Pve -AiPlayerbot.PremadeSpecProb.11.5 = 100 -AiPlayerbot.PremadeSpecLink.11.5.80 = -550202132322010053120030312511005503012 - -AiPlayerbot.PremadeSpecName.11.6 = Feral Tank Pve -AiPlayerbot.PremadeSpecProb.11.6 = 100 -AiPlayerbot.PremadeSpecLink.11.6.80 = -50123213032211035312030331351120350001 - -AiPlayerbot.PremadeSpecName.11.7 = Balance Pve -AiPlayerbot.PremadeSpecProb.11.7 = 100 -AiPlayerbot.PremadeSpecLink.11.7.80 = 5012203125331103213305301231--205003212 - -AiPlayerbot.PremadeSpecName.11.8 = Restro Pve -AiPlayerbot.PremadeSpecProb.11.8 = 100 -AiPlayerbot.PremadeSpecLink.11.8.80 = 05320001--230033312031512531153313051 - - # Prefix for bot chat commands (e.g. follow, stay) AiPlayerbot.CommandPrefix = "" @@ -582,6 +303,10 @@ AiPlayerbot.TargetPosRecalcDistance = 0.1 # Maps where bots can be teleported to AiPlayerbot.RandomBotMaps = 0,1,530,571 +# Probabilty bots teleport to banker (city) +# default: 0.25 +AiPlayerbot.ProbTeleToBankers = 0.25 + # Quest items to leave (do not destroy) AiPlayerbot.RandomBotQuestItems = "6948,5175,5176,5177,5178,16309,12382,13704,11000" diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 16b7fe7a..58b515ff 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -99,6 +99,7 @@ bool PlayerbotAIConfig::Initialize() randomBotMapsAsString = sConfigMgr->GetOption("AiPlayerbot.RandomBotMaps", "0,1,530,571"); LoadList>(randomBotMapsAsString, randomBotMaps); + probTeleToBankers = sConfigMgr->GetOption("AiPlayerbot.ProbTeleToBankers", 0.25f); LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestItems", "6948,5175,5176,5177,5178,16309,12382,13704,11000"), randomBotQuestItems); LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotSpellIds", "54197"), randomBotSpellIds); LoadList>(sConfigMgr->GetOption("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); @@ -190,65 +191,65 @@ bool PlayerbotAIConfig::Initialize() } } - for (uint32 cls = 1; cls < MAX_CLASSES; ++cls) - { - classSpecs[cls] = ClassSpecs(1 << (cls - 1)); + // for (uint32 cls = 1; cls < MAX_CLASSES; ++cls) + // { + // classSpecs[cls] = ClassSpecs(1 << (cls - 1)); - for (uint32 spec = 0; spec < MAX_LEVEL; ++spec) - { - std::ostringstream os; - os << "AiPlayerbot.PremadeSpecName." << cls << "." << spec; + // for (uint32 spec = 0; spec < MAX_LEVEL; ++spec) + // { + // std::ostringstream os; + // os << "AiPlayerbot.PremadeSpecName." << cls << "." << spec; - std::string const specName = sConfigMgr->GetOption(os.str().c_str(), "", false); - if (!specName.empty()) - { - std::ostringstream os; - os << "AiPlayerbot.PremadeSpecProb." << cls << "." << spec; - uint32 probability = sConfigMgr->GetOption(os.str().c_str(), 100, false); + // std::string const specName = sConfigMgr->GetOption(os.str().c_str(), "", false); + // if (!specName.empty()) + // { + // std::ostringstream os; + // os << "AiPlayerbot.PremadeSpecProb." << cls << "." << spec; + // uint32 probability = sConfigMgr->GetOption(os.str().c_str(), 100, false); - TalentPath talentPath(spec, specName, probability); + // TalentPath talentPath(spec, specName, probability); - for (uint32 level = 10; level <= 80; level++) - { - std::ostringstream os; - os << "AiPlayerbot.PremadeSpecLink." << cls << "." << spec << "." << level; + // for (uint32 level = 10; level <= 80; level++) + // { + // std::ostringstream os; + // os << "AiPlayerbot.PremadeSpecLink." << cls << "." << spec << "." << level; - std::string specLink = sConfigMgr->GetOption(os.str().c_str(), "", false); - specLink = specLink.substr(0, specLink.find("#", 0));; - specLink = specLink.substr(0, specLink.find(" ", 0));; + // std::string specLink = sConfigMgr->GetOption(os.str().c_str(), "", false); + // specLink = specLink.substr(0, specLink.find("#", 0));; + // specLink = specLink.substr(0, specLink.find(" ", 0));; - if (!specLink.empty()) - { - std::ostringstream out; + // if (!specLink.empty()) + // { + // std::ostringstream out; - // Ignore bad specs. - if (!classSpecs[cls].baseSpec.CheckTalentLink(specLink, &out)) - { - LOG_ERROR("playerbots", "Error with premade spec link: {}", specLink.c_str()); - LOG_ERROR("playerbots", "{}", out.str().c_str()); - continue; - } + // // Ignore bad specs. + // if (!classSpecs[cls].baseSpec.CheckTalentLink(specLink, &out)) + // { + // LOG_ERROR("playerbots", "Error with premade spec link: {}", specLink.c_str()); + // LOG_ERROR("playerbots", "{}", out.str().c_str()); + // continue; + // } - TalentSpec linkSpec(&classSpecs[cls].baseSpec, specLink); + // TalentSpec linkSpec(&classSpecs[cls].baseSpec, specLink); - if (!linkSpec.CheckTalents(level, &out)) - { - LOG_ERROR("playerbots", "Error with premade spec: {}", specLink.c_str()); - LOG_ERROR("playerbots", "{}", out.str().c_str()); - continue; - } + // if (!linkSpec.CheckTalents(level, &out)) + // { + // LOG_ERROR("playerbots", "Error with premade spec: {}", specLink.c_str()); + // LOG_ERROR("playerbots", "{}", out.str().c_str()); + // continue; + // } - talentPath.talentSpec.push_back(linkSpec); - } - } + // talentPath.talentSpec.push_back(linkSpec); + // } + // } - // Only add paths that have atleast 1 spec. - if (talentPath.talentSpec.size() > 0) - classSpecs[cls].talentPath.push_back(talentPath); - } - } - } + // // Only add paths that have atleast 1 spec. + // if (talentPath.talentSpec.size() > 0) + // classSpecs[cls].talentPath.push_back(talentPath); + // } + // } + // } botCheats.clear(); LoadListString>(sConfigMgr->GetOption("AiPlayerbot.BotCheats", "taxi"), botCheats); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 7e2236fa..68482c57 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -51,6 +51,7 @@ class PlayerbotAIConfig bool randomBotAutologin; bool botAutologin; std::string randomBotMapsAsString; + float probTeleToBankers; std::vector randomBotMaps; std::vector randomBotQuestItems; std::vector randomBotAccounts; diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 440d9ed6..388f33da 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -968,7 +968,7 @@ void RandomPlayerbotMgr::Revive(Player* player) SetEventValue(bot, "revive", 0, 0); - RandomTeleportForLevel(player); + RandomTeleportGrindForLevel(player); Refresh(player); } @@ -1004,30 +1004,12 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& std::vector::iterator i = find(sPlayerbotAIConfig->randomBotMaps.begin(), sPlayerbotAIConfig->randomBotMaps.end(), l.getMapId()); return i == sPlayerbotAIConfig->randomBotMaps.end(); }), tlocs.end()); - // LOG_INFO("playerbots", "Locs {} after disabled in config.", tlocs.size()); - // Check locs again in case all possible locations were removed if (tlocs.empty()) { LOG_DEBUG("playerbots", "Cannot teleport bot {} - all locations removed by filter", bot->GetName().c_str()); return; } - //Random shuffle based on distance. Closer distances are more likely (but not exclusivly) to be at the begin of the list. - // tlocs = sTravelMgr->getNextPoint(WorldPosition(bot), tlocs, 0); - // LOG_INFO("playerbots", "Locs {} after shuffled.", tlocs.size()); - // 5% + 0.1% per level chance node on different map in selection. - // tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l) - // { - // return l.GetMapId() != bot->GetMapId() && urand(1, 100) > 5 + 0.1 * bot->getLevel(); - // }), tlocs.end()); - // LOG_INFO("playerbots", "Locs {} after remove different maps.", tlocs.size()); - // Continent is about 20.000 large - // Bot will travel 0-5000 units + 75-150 units per level. - // tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l) - // { - // return sServerFacade->GetDistance2d(bot, l.GetPositionX(), l.GetPositionY()) > urand(0, 5000) + bot->getLevel() * 15 * urand(5, 10); - // }), tlocs.end()); - // LOG_INFO("playerbots", "Locs {} after remove too far away.", tlocs.size()); if (tlocs.empty()) { LOG_DEBUG("playerbots", "Cannot teleport bot {} - no locations available", bot->GetName().c_str()); @@ -1166,6 +1148,60 @@ void RandomPlayerbotMgr::PrepareTeleportCache() } LOG_INFO("playerbots", "{} locations for level collected.", collected_locs); + results = WorldDatabase.Query( + "SELECT " + "map, " + "position_x, " + "position_y, " + "position_z, " + "orientation, " + "t.minlevel " + "FROM " + "creature c " + "INNER JOIN creature_template t on c.id1 = t.entry " + "WHERE " + "t.npcflag & 131072 " + "AND t.npcflag != 135298 " + "AND t.minlevel != 55 " + "AND t.minlevel != 65 " + "AND t.faction != 35 " + "AND t.faction != 474 " + "AND map IN ({}) " + "ORDER BY " + "t.minlevel;", sPlayerbotAIConfig->randomBotMapsAsString.c_str()); + collected_locs = 0; + if (results) + { + do + { + Field* fields = results->Fetch(); + uint16 mapId = fields[0].Get(); + float x = fields[1].Get(); + float y = fields[2].Get(); + float z = fields[3].Get(); + float orient = fields[4].Get(); + uint32 level = fields[5].Get(); + WorldLocation loc(mapId, x + cos(orient) * 10.0f, y + sin(orient) * 10.0f, z, orient + M_PI); + collected_locs++; + for (int32 l = 1; l <= maxLevel; l++) { + if (l <= 60 && level >= 60) { + continue; + } + if (l <= 70 && level >= 70) { + continue; + } + if (l >= 70 && level >= 60 && level <= 70) { + continue; + } + if (l >= 30 && level <= 30) { + continue; + } + bankerLocsPerLevelCache[(uint8)l].push_back(loc); + } + } while (results->NextRow()); + } + LOG_INFO("playerbots", "{} banker locations for level collected.", collected_locs); + // temporary only use locsPerLevelCache, so disable rpgLocsCacheLevel cache // LOG_INFO("playerbots", "Preparing RPG teleport caches for {} factions...", sFactionTemplateStore.GetNumRows()); @@ -1208,6 +1244,22 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot) uint32 level = bot->getLevel(); uint8 race = bot->getRace(); LOG_INFO("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), bot->GetLevel(), locsPerLevelCache[level].size()); + if (urand(0, 100) < sPlayerbotAIConfig->probTeleToBankers * 100) { + RandomTeleport(bot, bankerLocsPerLevelCache[level], true); + } else { + RandomTeleport(bot, locsPerLevelCache[level]); + } +} + +void RandomPlayerbotMgr::RandomTeleportGrindForLevel(Player* bot) +{ + if (bot->InBattleground()) + return; + + uint32 level = bot->getLevel(); + uint8 race = bot->getRace(); + LOG_INFO("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), bot->GetLevel(), locsPerLevelCache[level].size()); + RandomTeleport(bot, locsPerLevelCache[level]); } diff --git a/src/RandomPlayerbotMgr.h b/src/RandomPlayerbotMgr.h index 03319d10..dc6a362b 100644 --- a/src/RandomPlayerbotMgr.h +++ b/src/RandomPlayerbotMgr.h @@ -69,6 +69,7 @@ class RandomPlayerbotMgr : public PlayerbotHolder uint32 GetTradeDiscount(Player* bot, Player* master); void Refresh(Player* bot); void RandomTeleportForLevel(Player* bot); + void RandomTeleportGrindForLevel(Player* bot); void RandomTeleportForRpg(Player* bot); uint32 GetMaxAllowedBotCount(); bool ProcessBot(Player* player); @@ -122,6 +123,8 @@ class RandomPlayerbotMgr : public PlayerbotHolder std::vector players; uint32 processTicks; std::map> locsPerLevelCache; + std::map> bankerLocsPerLevelCache; + // std::map> rpgLocsCache; std::map>> rpgLocsCacheLevel; std::map>> BattleMastersCache;