bool RandomPlayerbotMgr::ProcessBot(uint32 bot) { uint32 isValid = GetEventValue(bot, "add"); if (!isValid) { Player* player = GetPlayerBot(bot); if (!player || !player->GetGroup()) { sLog.outDetail("Bot %d expired", bot); SetEventValue(bot, "add", 0, 0); } return true; } if (!GetPlayerBot(bot)) { sLog.outDetail("Bot %d logged in", bot); AddPlayerBot(bot, 0); if (!GetEventValue(bot, "online")) { SetEventValue(bot, "online", 1, sPlayerbotAIConfig.minRandomBotInWorldTime); } return true; } Player* player = GetPlayerBot(bot); if (!player) return false; PlayerbotAI* ai = player->GetPlayerbotAI(); if (!ai) return false; if (player->GetGroup()) { sLog.outDetail("Skipping bot %d as it is in group", bot); return false; } if (player->IsDead()) { if (!GetEventValue(bot, "dead")) { sLog.outDetail("Setting dead flag for bot %d", bot); uint32 randomTime = urand(sPlayerbotAIConfig.minRandomBotReviveTime, sPlayerbotAIConfig.maxRandomBotReviveTime); SetEventValue(bot, "dead", 1, randomTime); SetEventValue(bot, "revive", 1, randomTime - 60); return false; } if (!GetEventValue(bot, "revive")) { sLog.outDetail("Reviving dead bot %d", bot); SetEventValue(bot, "dead", 0, 0); SetEventValue(bot, "revive", 0, 0); RandomTeleport(player, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); return true; } return false; } uint32 randomize = GetEventValue(bot, "randomize"); if (!randomize) { sLog.outDetail("Randomizing bot %d", bot); Randomize(player); uint32 randomTime = urand(sPlayerbotAIConfig.minRandomBotRandomizeTime, sPlayerbotAIConfig.maxRandomBotRandomizeTime); ScheduleRandomize(bot, randomTime); return true; } uint32 logout = GetEventValue(bot, "logout"); if (!logout) { sLog.outDetail("Logging out bot %d", bot); LogoutPlayerBot(bot); SetEventValue(bot, "logout", 1, sPlayerbotAIConfig.maxRandomBotInWorldTime); return true; } uint32 teleport = GetEventValue(bot, "teleport"); if (!teleport) { sLog.outDetail("Random teleporting bot %d", bot); RandomTeleportForLevel(ai->GetBot()); SetEventValue(bot, "teleport", 1, sPlayerbotAIConfig.maxRandomBotInWorldTime); return true; } return false; }
bool RandomPlayerbotMgr::ProcessBot(uint32 bot) { uint32 isValid = GetEventValue(bot, "add"); if (!isValid) { Player* player = GetPlayerBot(bot); if (!player || !player->GetGroup()) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Bot %d expired", bot); SetEventValue(bot, "add", 0, 0); } return true; } if (!GetPlayerBot(bot)) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Bot %d logged in", bot); AddPlayerBot(bot, 0); if (!GetEventValue(bot, "online")) { SetEventValue(bot, "online", 1, sPlayerbotAIConfig.minRandomBotInWorldTime); } return true; } Player* player = GetPlayerBot(bot); if (!player) return false; PlayerbotAI* ai = player->GetPlayerbotAI(); if (!ai) return false; if (player->GetGroup()) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Skipping bot %d as it is in group", bot); return false; } if (player->isDead()) { if (!GetEventValue(bot, "dead")) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Setting dead flag for bot %d", bot); uint32 randomTime = urand(sPlayerbotAIConfig.minRandomBotReviveTime, sPlayerbotAIConfig.maxRandomBotReviveTime); SetEventValue(bot, "dead", 1, randomTime); SetEventValue(bot, "revive", 1, randomTime - 60); return false; } if (!GetEventValue(bot, "revive")) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Reviving dead bot %d", bot); SetEventValue(bot, "dead", 0, 0); SetEventValue(bot, "revive", 0, 0); RandomTeleport(player, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); return true; } return false; } if (player->GetGuild() && player->GetGuild()->GetLeaderGUID() == player->GetGUID()) { for (vector<Player*>::iterator i = players.begin(); i != players.end(); ++i) sGuildTaskMgr.Update(*i, player); } uint32 randomize = GetEventValue(bot, "randomize"); if (!randomize) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Randomizing bot %d", bot); Randomize(player); uint32 randomTime = urand(sPlayerbotAIConfig.minRandomBotRandomizeTime, sPlayerbotAIConfig.maxRandomBotRandomizeTime); ScheduleRandomize(bot, randomTime); return true; } uint32 logout = GetEventValue(bot, "logout"); if (!logout) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Logging out bot %d", bot); LogoutPlayerBot(bot); SetEventValue(bot, "logout", 1, sPlayerbotAIConfig.maxRandomBotInWorldTime); return true; } uint32 teleport = GetEventValue(bot, "teleport"); if (!teleport) { sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Random teleporting bot %d", bot); RandomTeleportForLevel(ai->GetBot()); SetEventValue(bot, "teleport", 1, sPlayerbotAIConfig.maxRandomBotInWorldTime); return true; } return false; }