EnableNewRpgStrategy switch for initialization

This commit is contained in:
Yunfan Li
2024-12-14 21:46:33 +08:00
parent 2656b2d0d9
commit a5d1d7579d
5 changed files with 107 additions and 103 deletions

View File

@@ -433,7 +433,7 @@ public:
std::vector<Player*> GetPlayersInGroup(); std::vector<Player*> GetPlayersInGroup();
const AreaTableEntry* GetCurrentArea(); const AreaTableEntry* GetCurrentArea();
const AreaTableEntry* GetCurrentZone(); const AreaTableEntry* GetCurrentZone();
std::string GetLocalizedAreaName(const AreaTableEntry* entry); static std::string GetLocalizedAreaName(const AreaTableEntry* entry);
bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);

View File

@@ -399,6 +399,7 @@ bool PlayerbotAIConfig::Initialize()
worldBuffs.clear(); worldBuffs.clear();
LOG_INFO("playerbots", "Loading Worldbuff...");
for (uint32 factionId = 0; factionId < 3; factionId++) for (uint32 factionId = 0; factionId < 3; factionId++)
{ {
for (uint32 classId = 0; classId < MAX_CLASSES; classId++) for (uint32 classId = 0; classId < MAX_CLASSES; classId++)

View File

@@ -556,7 +556,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
totalRandomBotChars += AccountMgr::GetCharactersCount(accountId); totalRandomBotChars += AccountMgr::GetCharactersCount(accountId);
} }
LOG_INFO("server.loading", "{} random bot accounts with {} characters available", LOG_INFO("server.loading", ">> {} random bot accounts with {} characters available",
sPlayerbotAIConfig->randomBotAccounts.size(), totalRandomBotChars); sPlayerbotAIConfig->randomBotAccounts.size(), totalRandomBotChars);
} }

View File

@@ -1433,6 +1433,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
"position_x, " "position_x, "
"position_y, " "position_y, "
"position_z, " "position_z, "
"t.minlevel, "
"t.maxlevel " "t.maxlevel "
"FROM " "FROM "
"(SELECT " "(SELECT "
@@ -1476,7 +1477,9 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
float x = fields[1].Get<float>(); float x = fields[1].Get<float>();
float y = fields[2].Get<float>(); float y = fields[2].Get<float>();
float z = fields[3].Get<float>(); float z = fields[3].Get<float>();
uint32 level = fields[4].Get<uint32>(); uint32 min_level = fields[4].Get<uint32>();
uint32 max_level = fields[5].Get<uint32>();
uint32 level = (min_level + max_level) / 2;
WorldLocation loc(mapId, x, y, z, 0); WorldLocation loc(mapId, x, y, z, 0);
collected_locs++; collected_locs++;
for (int32 l = (int32)level - (int32)sPlayerbotAIConfig->randomBotTeleHigherLevel; for (int32 l = (int32)level - (int32)sPlayerbotAIConfig->randomBotTeleHigherLevel;
@@ -1490,8 +1493,11 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
} }
} while (results->NextRow()); } while (results->NextRow());
} }
LOG_INFO("playerbots", "{} locations for level collected.", collected_locs); LOG_INFO("playerbots", ">> {} locations for level collected.", collected_locs);
LOG_INFO("playerbots", "Preparing innkeepers locations for level collected");
if (sPlayerbotAIConfig->enableNewRpgStrategy)
{
results = WorldDatabase.Query( results = WorldDatabase.Query(
"SELECT " "SELECT "
"map, " "map, "
@@ -1542,17 +1548,16 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
if (loc.GetMapId() != checkLoc.GetMapId()) if (loc.GetMapId() != checkLoc.GetMapId())
continue; continue;
if (loc.GetExactDist(checkLoc) > 1000.0f)
continue;
if (area->zone != if (area->zone !=
map->GetZoneId(1, checkLoc.GetPositionX(), checkLoc.GetPositionY(), checkLoc.GetPositionZ())) map->GetZoneId(1, checkLoc.GetPositionX(), checkLoc.GetPositionY(), checkLoc.GetPositionZ()))
continue; continue;
if (loc.GetExactDist(checkLoc) <= 1000.0f)
{
counter++; counter++;
levelLoc = checkLoc; levelLoc = checkLoc;
} }
}
if (counter < 15) if (counter < 15)
continue; continue;
@@ -1568,22 +1573,6 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
level, c_entry, i, counter, levelLoc.GetPositionX(), levelLoc.GetPositionY(), level, c_entry, i, counter, levelLoc.GetPositionX(), levelLoc.GetPositionY(),
levelLoc.GetPositionZ(), levelLoc.GetMapId()); levelLoc.GetPositionZ(), levelLoc.GetMapId());
} }
// int range = level <= 10 ? 6 : 8;
// for (int32 l = (int32)level; l <= (int32)level + range; l++)
// {
// if (l < 1 || l > maxLevel)
// {
// continue;
// }
// if (!(entry->hostileMask & 4))
// {
// hordeStarterPerLevelCache[(uint8)l].push_back(loc);
// }
// if (!(entry->hostileMask & 2))
// {
// allianceStarterPerLevelCache[(uint8)l].push_back(loc);
// }
// }
} while (results->NextRow()); } while (results->NextRow());
} }
// add all initial position // add all initial position
@@ -1608,7 +1597,8 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
break; break;
} }
} }
LOG_INFO("playerbots", "{} innkeepers locations for level collected.", collected_locs); LOG_INFO("playerbots", ">> {} innkeepers locations for level collected.", collected_locs);
}
results = WorldDatabase.Query( results = WorldDatabase.Query(
"SELECT " "SELECT "
@@ -1673,7 +1663,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
} }
} while (results->NextRow()); } while (results->NextRow());
} }
LOG_INFO("playerbots", "{} banker locations for level collected.", collected_locs); LOG_INFO("playerbots", ">> {} banker locations for level collected.", collected_locs);
} }
void RandomPlayerbotMgr::PrepareAddclassCache() void RandomPlayerbotMgr::PrepareAddclassCache()
@@ -1711,7 +1701,7 @@ void RandomPlayerbotMgr::PrepareAddclassCache()
} while (results->NextRow()); } while (results->NextRow());
} }
} }
LOG_INFO("playerbots", "{} characters collected for addclass command.", collected); LOG_INFO("playerbots", ">> {} characters collected for addclass command.", collected);
} }
void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot) void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
@@ -2565,6 +2555,7 @@ void RandomPlayerbotMgr::PrintStats()
uint32 stateCount[MAX_TRAVEL_STATE + 1] = {0}; uint32 stateCount[MAX_TRAVEL_STATE + 1] = {0};
std::vector<std::pair<Quest const*, int32>> questCount; std::vector<std::pair<Quest const*, int32>> questCount;
std::unordered_map<NewRpgStatus, int> rpgStatusCount; std::unordered_map<NewRpgStatus, int> rpgStatusCount;
std::unordered_map<uint32, int> zoneCount;
uint8 maxBotLevel = 0; uint8 maxBotLevel = 0;
for (PlayerBotMap::iterator i = playerBots.begin(); i != playerBots.end(); ++i) for (PlayerBotMap::iterator i = playerBots.begin(); i != playerBots.end(); ++i)
{ {
@@ -2635,6 +2626,8 @@ void RandomPlayerbotMgr::PrintStats()
else else
++dps; ++dps;
zoneCount[bot->GetZoneId()]++;
if (sPlayerbotAIConfig->enableNewRpgStrategy) if (sPlayerbotAIConfig->enableNewRpgStrategy)
rpgStatusCount[botAI->rpgInfo.status]++; rpgStatusCount[botAI->rpgInfo.status]++;
@@ -2719,6 +2712,15 @@ void RandomPlayerbotMgr::PrintStats()
LOG_INFO("playerbots", " In BG: {}", inBg); LOG_INFO("playerbots", " In BG: {}", inBg);
LOG_INFO("playerbots", " In Rest: {}", rest); LOG_INFO("playerbots", " In Rest: {}", rest);
LOG_INFO("playerbots", " Dead: {}", dead); LOG_INFO("playerbots", " Dead: {}", dead);
// LOG_INFO("playerbots", "Bots zone:");
// for (auto &[zond_id, counter] : zoneCount)
// {
// const AreaTableEntry* entry = sAreaTableStore.LookupEntry(zond_id);
// std::string name = PlayerbotAI::GetLocalizedAreaName(entry);
// LOG_INFO("playerbots", " {}: {}", name, counter);
// }
if (sPlayerbotAIConfig->enableNewRpgStrategy) if (sPlayerbotAIConfig->enableNewRpgStrategy)
{ {
LOG_INFO("playerbots", "Bots rpg status:", dead); LOG_INFO("playerbots", "Bots rpg status:", dead);

View File

@@ -33,7 +33,7 @@ bool NewRpgStatusUpdateAction::Execute(Event event)
uint32 roll = urand(1, 100); uint32 roll = urand(1, 100);
// IDLE -> NEAR_NPC // IDLE -> NEAR_NPC
// if ((!info.lastNearNpc || info.lastNearNpc + setNpcInterval < getMSTime()) && roll <= 30) // if ((!info.lastNearNpc || info.lastNearNpc + setNpcInterval < getMSTime()) && roll <= 30)
if (roll <= 40) if (roll <= 30)
{ {
info.lastNearNpc = getMSTime(); info.lastNearNpc = getMSTime();
GuidVector possibleTargets = AI_VALUE(GuidVector, "possible rpg targets"); GuidVector possibleTargets = AI_VALUE(GuidVector, "possible rpg targets");
@@ -44,7 +44,7 @@ bool NewRpgStatusUpdateAction::Execute(Event event)
} }
} }
// IDLE -> GO_INNKEEPER // IDLE -> GO_INNKEEPER
else if (bot->GetLevel() >= 6 && roll <= 55) else if (bot->GetLevel() >= 6 && roll <= 45)
{ {
WorldPosition pos = SelectRandomInnKeeperPos(); WorldPosition pos = SelectRandomInnKeeperPos();
if (pos != WorldPosition() && bot->GetExactDist(pos) > 50.0f) if (pos != WorldPosition() && bot->GetExactDist(pos) > 50.0f)
@@ -221,7 +221,8 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest)
float dis = bot->GetExactDist(dest); float dis = bot->GetExactDist(dest);
if (dis < pathFinderDis) if (dis < pathFinderDis)
{ {
return MoveTo(dest.getMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, false, false, true); return MoveTo(dest.getMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, false,
false, true);
} }
// performance optimization // performance optimization