Fix rotation class imbalance

This commit is contained in:
Yunfan Li
2024-01-15 13:21:49 +08:00
parent 8d4064d84c
commit dc4ec06164
2 changed files with 12 additions and 7 deletions

View File

@@ -29,6 +29,7 @@
#include "Unit.h" #include "Unit.h"
#include "World.h" #include "World.h"
#include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <iomanip> #include <iomanip>
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
@@ -347,7 +348,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
PreparedQueryResult result = CharacterDatabase.Query(stmt); PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result) if (!result)
continue; continue;
std::vector<uint32> guids;
do do
{ {
Field* fields = result->Fetch(); Field* fields = result->Fetch();
@@ -364,10 +365,15 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
if (std::find(currentBots.begin(), currentBots.end(), guid) != currentBots.end()) if (std::find(currentBots.begin(), currentBots.end(), guid) != currentBots.end())
continue; continue;
guids.push_back(guid);
} while (result->NextRow());
std::random_shuffle(guids.begin(), guids.end());
for (uint32 &guid : guids) {
uint32 add_time = sPlayerbotAIConfig->enableRotation ? uint32 add_time = sPlayerbotAIConfig->enableRotation ?
urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime) : urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime) :
sPlayerbotAIConfig->randomBotInWorldWithRotaionDisabled; sPlayerbotAIConfig->randomBotInWorldWithRotaionDisabled;
SetEventValue(guid, "add", 1, add_time); SetEventValue(guid, "add", 1, add_time);
SetEventValue(guid, "logout", 0, 0); SetEventValue(guid, "logout", 0, 0);
@@ -376,8 +382,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
maxAllowedBotCount--; maxAllowedBotCount--;
if (!maxAllowedBotCount) if (!maxAllowedBotCount)
break; break;
}
} while (result->NextRow());
if (!maxAllowedBotCount) if (!maxAllowedBotCount)
break; break;

View File

@@ -81,7 +81,7 @@ std::string ChangeTalentsAction::SpecList()
std::vector<std::vector<uint32>> parsed = sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][80]; std::vector<std::vector<uint32>> parsed = sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][80];
std::unordered_map<int, int> tabCount; std::unordered_map<int, int> tabCount;
tabCount[0] = tabCount[1] = tabCount[2] = 0; tabCount[0] = tabCount[1] = tabCount[2] = 0;
for (auto item : parsed) { for (auto &item : parsed) {
tabCount[item[0]] += item[3]; tabCount[item[0]] += item[3];
} }
out << specFound << ". " << sPlayerbotAIConfig->premadeSpecName[cls][specNo] << " ("; out << specFound << ". " << sPlayerbotAIConfig->premadeSpecName[cls][specNo] << " (";