mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-31 01:13:48 +00:00
teleport optimizations
This commit is contained in:
@@ -1097,8 +1097,9 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
|||||||
player->GetLevel(), player->GetName().c_str());
|
player->GetLevel(), player->GetName().c_str());
|
||||||
LogoutPlayerBot(botGUID);
|
LogoutPlayerBot(botGUID);
|
||||||
currentBots.remove(bot);
|
currentBots.remove(bot);
|
||||||
SetEventValue(bot, "logout", 1,
|
SetEventValue(bot, "logout", 1, urand(
|
||||||
urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime));
|
sPlayerbotAIConfig->minRandomBotInWorldTime,
|
||||||
|
sPlayerbotAIConfig->maxRandomBotInWorldTime));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1115,16 +1116,16 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player)
|
|||||||
if (player->InBattlegroundQueue())
|
if (player->InBattlegroundQueue())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// if (player->isDead())
|
// if death revive
|
||||||
// return false;
|
|
||||||
if (player->isDead())
|
if (player->isDead())
|
||||||
{
|
{
|
||||||
if (!GetEventValue(bot, "dead"))
|
if (!GetEventValue(bot, "dead"))
|
||||||
{
|
{
|
||||||
uint32 randomTime =
|
uint32 randomTime = urand(
|
||||||
urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime);
|
sPlayerbotAIConfig->minRandomBotReviveTime,
|
||||||
// LOG_INFO("playerbots", "Mark bot {} as dead, will be revived in {}s.", player->GetName().c_str(),
|
sPlayerbotAIConfig->maxRandomBotReviveTime);
|
||||||
// randomTime);
|
LOG_INFO("playerbots", "Mark bot {} as dead, will be revived in {}s.",
|
||||||
|
player->GetName().c_str(), randomTime);
|
||||||
SetEventValue(bot, "dead", 1, sPlayerbotAIConfig->maxRandomBotInWorldTime);
|
SetEventValue(bot, "dead", 1, sPlayerbotAIConfig->maxRandomBotInWorldTime);
|
||||||
SetEventValue(bot, "revive", 1, randomTime);
|
SetEventValue(bot, "revive", 1, randomTime);
|
||||||
return false;
|
return false;
|
||||||
@@ -1139,69 +1140,90 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// leave group if leader is rndbot
|
||||||
Group* group = player->GetGroup();
|
Group* group = player->GetGroup();
|
||||||
if (group && !group->isLFGGroup() && IsRandomBot(group->GetLeader()))
|
if (group && !group->isLFGGroup() && IsRandomBot(group->GetLeader()))
|
||||||
{
|
{
|
||||||
player->RemoveFromGroup();
|
player->RemoveFromGroup();
|
||||||
LOG_INFO("playerbots", "Bot {} remove from group since leader is random bot.", player->GetName().c_str());
|
LOG_INFO("playerbots", "Bot {} remove from group since leader is random bot.", player->GetName().c_str());
|
||||||
}
|
}
|
||||||
// GET_PLAYERBOT_AI(player)->GetAiObjectContext()->GetValue<bool>("random bot update")->Set(false);
|
|
||||||
|
|
||||||
// bool randomiser = true;
|
|
||||||
// if (player->GetGuildId())
|
|
||||||
// {
|
|
||||||
// if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
|
|
||||||
// {
|
|
||||||
// if (guild->GetLeaderGUID() == player->GetGUID())
|
|
||||||
// {
|
|
||||||
// for (std::vector<Player*>::iterator i = players.begin(); i != players.end(); ++i)
|
|
||||||
// sGuildTaskMgr->Update(*i, player);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guild->GetLeaderGUID());
|
// only randomize and teleport idle bots
|
||||||
// if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId))
|
bool idleBot = false;
|
||||||
// {
|
PlayerbotAI* botAI = GET_PLAYERBOT_AI(player);
|
||||||
// uint8 rank = player->GetRank();
|
if (botAI)
|
||||||
// randomiser = rank < 4 ? false : true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
uint32 randomize = GetEventValue(bot, "randomize");
|
|
||||||
if (!randomize)
|
|
||||||
{
|
{
|
||||||
Randomize(player);
|
if (TravelTarget* target = botAI->GetAiObjectContext()->GetValue<TravelTarget*>("travel target")->Get())
|
||||||
LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H",
|
{
|
||||||
player->GetLevel(), player->GetName());
|
if (target->getTravelState() == TravelState::TRAVEL_STATE_IDLE)
|
||||||
uint32 randomTime =
|
{
|
||||||
urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime);
|
idleBot = true;
|
||||||
ScheduleRandomize(bot, randomTime);
|
}
|
||||||
return true;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idleBot = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (idleBot)
|
||||||
// enable random teleport logic if no auto traveling enabled
|
|
||||||
// if (!sPlayerbotAIConfig->autoDoQuests)
|
|
||||||
// {
|
|
||||||
uint32 teleport = GetEventValue(bot, "teleport");
|
|
||||||
if (!teleport)
|
|
||||||
{
|
{
|
||||||
LOG_INFO("playerbots", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName());
|
// randomize
|
||||||
Refresh(player);
|
uint32 randomize = GetEventValue(bot, "randomize");
|
||||||
RandomTeleportForLevel(player);
|
if (!randomize)
|
||||||
uint32 time =
|
{
|
||||||
urand(sPlayerbotAIConfig->minRandomBotTeleportInterval, sPlayerbotAIConfig->maxRandomBotTeleportInterval);
|
// bool randomiser = true;
|
||||||
ScheduleTeleport(bot, time);
|
// if (player->GetGuildId())
|
||||||
return true;
|
// {
|
||||||
}
|
// if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
|
||||||
// }
|
// {
|
||||||
|
// if (guild->GetLeaderGUID() == player->GetGUID())
|
||||||
|
// {
|
||||||
|
// for (std::vector<Player*>::iterator i = players.begin(); i != players.end(); ++i)
|
||||||
|
// sGuildTaskMgr->Update(*i, player);
|
||||||
|
// }
|
||||||
|
|
||||||
// uint32 changeStrategy = GetEventValue(bot, "change_strategy");
|
// uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guild->GetLeaderGUID());
|
||||||
// if (!changeStrategy)
|
// if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId))
|
||||||
// {
|
// {
|
||||||
// LOG_INFO("playerbots", "Changing strategy for bot #{} <{}>", bot, player->GetName().c_str());
|
// uint8 rank = player->GetRank();
|
||||||
// ChangeStrategy(player);
|
// randomiser = rank < 4 ? false : true;
|
||||||
// return true;
|
// }
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
|
// if (randomiser)
|
||||||
|
// {
|
||||||
|
Randomize(player);
|
||||||
|
LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized",
|
||||||
|
bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->GetLevel(), player->GetName());
|
||||||
|
uint32 randomTime = urand(
|
||||||
|
sPlayerbotAIConfig->minRandomBotRandomizeTime,
|
||||||
|
sPlayerbotAIConfig->maxRandomBotRandomizeTime);
|
||||||
|
ScheduleRandomize(bot, randomTime);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// uint32 changeStrategy = GetEventValue(bot, "change_strategy");
|
||||||
|
// if (!changeStrategy)
|
||||||
|
// {
|
||||||
|
// LOG_INFO("playerbots", "Changing strategy for bot #{} <{}>", bot, player->GetName().c_str());
|
||||||
|
// ChangeStrategy(player);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
uint32 teleport = GetEventValue(bot, "teleport");
|
||||||
|
if (!teleport)
|
||||||
|
{
|
||||||
|
LOG_INFO("playerbots", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName());
|
||||||
|
Refresh(player);
|
||||||
|
RandomTeleportForLevel(player);
|
||||||
|
uint32 time = urand(
|
||||||
|
sPlayerbotAIConfig->minRandomBotTeleportInterval,
|
||||||
|
sPlayerbotAIConfig->maxRandomBotTeleportInterval);
|
||||||
|
ScheduleTeleport(bot, time);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1220,14 +1242,31 @@ void RandomPlayerbotMgr::Revive(Player* player)
|
|||||||
|
|
||||||
void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>& locs, bool hearth)
|
void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>& locs, bool hearth)
|
||||||
{
|
{
|
||||||
if (bot->InBattleground())
|
// ignore when alrdy teleported or not in the world yet.
|
||||||
return;
|
if (bot->IsBeingTeleported() || !bot->IsInWorld())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// ignore when in queue for battle grounds.
|
||||||
if (bot->InBattlegroundQueue())
|
if (bot->InBattlegroundQueue())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if (bot->GetLevel() < 5)
|
// ignore when in battle grounds or arena.
|
||||||
// return;
|
if (bot->InBattleground() || bot->InArena())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// ignore when in group (e.g. world, dungeons, raids) and leader is not a player.
|
||||||
|
if (bot->GetGroup() && !bot->GetGroup()->IsLeader(bot->GetGUID()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
|
||||||
|
if (botAI)
|
||||||
|
{
|
||||||
|
// ignore when in when taxi with boat/zeppelin and has players nearby
|
||||||
|
if (bot->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
|
||||||
|
bot->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) &&
|
||||||
|
botAI->HasPlayerNearby())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if (sPlayerbotAIConfig->randomBotRpgChance < 0)
|
// if (sPlayerbotAIConfig->randomBotRpgChance < 0)
|
||||||
// return;
|
// return;
|
||||||
|
|||||||
Reference in New Issue
Block a user