diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index fe475e08..caf594bf 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,7 @@ #include "GuildTaskMgr.h" #include "LFGMgr.h" #include "MapMgr.h" +#include "NewRpgStrategy.h" #include "PerformanceMonitor.h" #include "Player.h" #include "PlayerbotAI.h" @@ -359,6 +361,17 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) activateCheckLfgQueueThread(); } + if (time(nullptr) > (printStatsTimer + 300)) + { + if (!printStatsTimer) + { + printStatsTimer = time(nullptr); + } + else + { + activatePrintStatsThread(); + } + } uint32 updateBots = sPlayerbotAIConfig->randomBotsPerInterval * onlineBotFocus / 100; uint32 maxNewBots = onlineBotCount < maxAllowedBotCount ? maxAllowedBotCount - onlineBotCount : 0; uint32 loginBots = std::min(sPlayerbotAIConfig->randomBotsPerInterval - updateBots, maxNewBots); @@ -593,7 +606,7 @@ void RandomPlayerbotMgr::CheckBgQueue() BgCheckTimer = time(nullptr); - LOG_INFO("playerbots", "Checking BG Queue..."); + LOG_DEBUG("playerbots", "Checking BG Queue..."); BattlegroundData.clear(); @@ -900,7 +913,7 @@ void RandomPlayerbotMgr::LogBattlegroundInfo() bgInfo.bgHordePlayerCount + bgInfo.bgHordeBotCount, bgInfo.bgInstanceCount); } } - LOG_INFO("playerbots", "BG Queue check finished"); + LOG_DEBUG("playerbots", "BG Queue check finished"); } void RandomPlayerbotMgr::CheckLfgQueue() @@ -908,7 +921,7 @@ void RandomPlayerbotMgr::CheckLfgQueue() if (!LfgCheckTimer || time(nullptr) > (LfgCheckTimer + 30)) LfgCheckTimer = time(nullptr); - LOG_INFO("playerbots", "Checking LFG Queue..."); + LOG_DEBUG("playerbots", "Checking LFG Queue..."); // Clear LFG list LfgDungeons[TEAM_ALLIANCE].clear(); @@ -938,7 +951,7 @@ void RandomPlayerbotMgr::CheckLfgQueue() } } - LOG_INFO("playerbots", "LFG Queue check finished"); + LOG_DEBUG("playerbots", "LFG Queue check finished"); } void RandomPlayerbotMgr::CheckPlayers() @@ -1129,7 +1142,7 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) uint32 randomTime = urand( sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); - LOG_INFO("playerbots", "Mark bot {} as dead, will be revived in {}s.", + LOG_DEBUG("playerbots", "Mark bot {} as dead, will be revived in {}s.", player->GetName().c_str(), randomTime); SetEventValue(bot, "dead", 1, sPlayerbotAIConfig->maxRandomBotInWorldTime); SetEventValue(bot, "revive", 1, randomTime); @@ -1199,7 +1212,7 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) // if (randomiser) // { Randomize(player); - LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", + LOG_DEBUG("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->GetLevel(), player->GetName()); uint32 randomTime = urand( sPlayerbotAIConfig->minRandomBotRandomizeTime, @@ -1219,7 +1232,7 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) uint32 teleport = GetEventValue(bot, "teleport"); if (!teleport) { - LOG_INFO("playerbots", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName()); + LOG_DEBUG("playerbots", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName()); Refresh(player); RandomTeleportForLevel(player); uint32 time = urand( @@ -1364,7 +1377,7 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& } const LocaleConstant& locale = sWorld->GetDefaultDbcLocale(); - LOG_INFO("playerbots", + LOG_DEBUG("playerbots", "Random teleporting bot {} (level {}) to Map: {} ({}) Zone: {} ({}) Area: {} ({}) ZoneLevel: {} AreaLevel: {} {},{},{} ({}/{} " "locations)", bot->GetName().c_str(), bot->GetLevel(), map->GetId(), map->GetMapName(), zone->ID, @@ -1503,7 +1516,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache() continue; const AreaTableEntry* area = sAreaTableStore.LookupEntry(map->GetAreaId(1, x, y, z)); uint32 level = area->area_level; - LOG_INFO("playerbots", "Area: {} Level: {} creature_entry: {}", area->ID, level, c_entry); + // LOG_INFO("playerbots", "Area: {} Level: {} creature_entry: {}", area->ID, level, c_entry); int range = level <= 10 ? 6 : 8; for (int32 l = (int32)level; l <= (int32)level + range; l++) { @@ -2456,7 +2469,8 @@ Player* RandomPlayerbotMgr::GetRandomPlayer() void RandomPlayerbotMgr::PrintStats() { - LOG_INFO("playerbots", "{} Random Bots online", playerBots.size()); + printStatsTimer = time(nullptr); + LOG_INFO("playerbots", "Random Bots Stats: {} online", playerBots.size()); std::map alliance, horde; for (uint32 i = 0; i < 10; ++i) @@ -2498,6 +2512,7 @@ void RandomPlayerbotMgr::PrintStats() uint32 engine_dead = 0; uint32 stateCount[MAX_TRAVEL_STATE + 1] = {0}; std::vector> questCount; + std::unordered_map rpgStatusCount; for (PlayerBotMap::iterator i = playerBots.begin(); i != playerBots.end(); ++i) { Player* bot = i->second; @@ -2566,6 +2581,9 @@ void RandomPlayerbotMgr::PrintStats() else ++dps; + if (sPlayerbotAIConfig->enableNewRpgStrategy) + rpgStatusCount[botAI->rpgInfo.status]++; + if (TravelTarget* target = botAI->GetAiObjectContext()->GetValue("travel target")->Get()) { TravelState state = target->getTravelState(); @@ -2644,19 +2662,27 @@ void RandomPlayerbotMgr::PrintStats() LOG_INFO("playerbots", " In Rest: {}", rest); LOG_INFO("playerbots", " Dead: {}", dead); + LOG_INFO("playerbots", "Bots rpg status:", dead); + LOG_INFO("playerbots", " IDLE: {}", rpgStatusCount[NewRpgStatus::IDLE]); + LOG_INFO("playerbots", " REST: {}", rpgStatusCount[NewRpgStatus::REST]); + LOG_INFO("playerbots", " GO_GRIND: {}", rpgStatusCount[NewRpgStatus::GO_GRIND]); + LOG_INFO("playerbots", " GO_INNKEEPER: {}", rpgStatusCount[NewRpgStatus::GO_INNKEEPER]); + LOG_INFO("playerbots", " NEAR_RANDOM: {}", rpgStatusCount[NewRpgStatus::NEAR_RANDOM]); + LOG_INFO("playerbots", " NEAR_NPC: {}", rpgStatusCount[NewRpgStatus::NEAR_NPC]); + LOG_INFO("playerbots", "Bots engine:", dead); LOG_INFO("playerbots", " Non-combat: {}", engine_noncombat); LOG_INFO("playerbots", " Combat: {}", engine_combat); LOG_INFO("playerbots", " Dead: {}", engine_dead); - LOG_INFO("playerbots", "Bots questing:"); - LOG_INFO("playerbots", " Picking quests: {}", - stateCount[TRAVEL_STATE_TRAVEL_PICK_UP_QUEST] + stateCount[TRAVEL_STATE_WORK_PICK_UP_QUEST]); - LOG_INFO("playerbots", " Doing quests: {}", - stateCount[TRAVEL_STATE_TRAVEL_DO_QUEST] + stateCount[TRAVEL_STATE_WORK_DO_QUEST]); - LOG_INFO("playerbots", " Completing quests: {}", - stateCount[TRAVEL_STATE_TRAVEL_HAND_IN_QUEST] + stateCount[TRAVEL_STATE_WORK_HAND_IN_QUEST]); - LOG_INFO("playerbots", " Idling: {}", stateCount[TRAVEL_STATE_IDLE]); + // LOG_INFO("playerbots", "Bots questing:"); + // LOG_INFO("playerbots", " Picking quests: {}", + // stateCount[TRAVEL_STATE_TRAVEL_PICK_UP_QUEST] + stateCount[TRAVEL_STATE_WORK_PICK_UP_QUEST]); + // LOG_INFO("playerbots", " Doing quests: {}", + // stateCount[TRAVEL_STATE_TRAVEL_DO_QUEST] + stateCount[TRAVEL_STATE_WORK_DO_QUEST]); + // LOG_INFO("playerbots", " Completing quests: {}", + // stateCount[TRAVEL_STATE_TRAVEL_HAND_IN_QUEST] + stateCount[TRAVEL_STATE_WORK_HAND_IN_QUEST]); + // LOG_INFO("playerbots", " Idling: {}", stateCount[TRAVEL_STATE_IDLE]); /*sort(questCount.begin(), questCount.end(), [](std::pair i, std::pair j) {return i.second > j.second; }); diff --git a/src/RandomPlayerbotMgr.h b/src/RandomPlayerbotMgr.h index 60d8d8d0..906c1b9f 100644 --- a/src/RandomPlayerbotMgr.h +++ b/src/RandomPlayerbotMgr.h @@ -192,6 +192,7 @@ private: time_t BgCheckTimer; time_t LfgCheckTimer; time_t PlayersCheckTimer; + time_t printStatsTimer; uint32 AddRandomBots(); bool ProcessBot(uint32 bot); void ScheduleRandomize(uint32 bot, uint32 time); diff --git a/src/strategy/actions/NewRpgAction.cpp b/src/strategy/actions/NewRpgAction.cpp index a5e61dea..f637b784 100644 --- a/src/strategy/actions/NewRpgAction.cpp +++ b/src/strategy/actions/NewRpgAction.cpp @@ -173,7 +173,7 @@ WorldPosition NewRpgStatusUpdateAction::SelectRandomGrindPos() uint32 idx = urand(0, lo_prepared_locs.size() - 1); dest = lo_prepared_locs[idx]; } - LOG_INFO("playerbots", "[New Rpg] Bot {} select random grind pos Map:{} X:{} Y:{} Z:{} ({}+{} available in {})", + LOG_DEBUG("playerbots", "[New Rpg] Bot {} select random grind pos Map:{} X:{} Y:{} Z:{} ({}+{} available in {})", bot->GetName(), dest.GetMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), hi_prepared_locs.size(), lo_prepared_locs.size() - hi_prepared_locs.size(), locs.size()); return dest; @@ -202,7 +202,7 @@ WorldPosition NewRpgStatusUpdateAction::SelectRandomInnKeeperPos() uint32 idx = urand(0, prepared_locs.size() - 1); dest = prepared_locs[idx]; } - LOG_INFO("playerbots", "[New Rpg] Bot {} select random inn keeper pos Map:{} X:{} Y:{} Z:{} ({} available in {})", + LOG_DEBUG("playerbots", "[New Rpg] Bot {} select random inn keeper pos Map:{} X:{} Y:{} Z:{} ({} available in {})", bot->GetName(), dest.GetMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), prepared_locs.size(), locs.size()); return dest;