Run clang-format

This commit is contained in:
Yunfan Li
2024-08-04 10:23:36 +08:00
parent 44da167492
commit 53611c9040
835 changed files with 35085 additions and 31861 deletions

View File

@@ -1,8 +1,10 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
* and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "BattleGroundJoinAction.h"
#include "ArenaTeam.h"
#include "ArenaTeamMgr.h"
#include "BattlegroundMgr.h"
@@ -16,7 +18,7 @@
bool BGJoinAction::Execute(Event event)
{
uint32 queueType = AI_VALUE(uint32, "bg type");
if (!queueType) // force join to fill bg
if (!queueType) // force join to fill bg
{
if (bgList.empty())
return false;
@@ -53,7 +55,7 @@ bool BGJoinAction::Execute(Event event)
}
// set bg type and bm guid
//botAI->GetAiObjectContext()->GetValue<ObjectGuid>("bg master")->Set(bmGUID);
// botAI->GetAiObjectContext()->GetValue<ObjectGuid>("bg master")->Set(bmGUID);
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(queueTypeId);
queueType = queueTypeId;
}
@@ -63,19 +65,19 @@ bool BGJoinAction::Execute(Event event)
bool BGJoinAction::gatherArenaTeam(ArenaType type)
{
ArenaTeam* arenateam = sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type);
if (!arenateam)
return false;
if (arenateam->GetMembersSize() < ((uint32) arenateam->GetType()))
if (arenateam->GetMembersSize() < ((uint32)arenateam->GetType()))
return false;
GuidVector members;
// search for arena team members and make them online
for (ArenaTeam::MemberList::iterator itr = arenateam->GetMembers().begin(); itr != arenateam->GetMembers().end(); ++itr)
for (ArenaTeam::MemberList::iterator itr = arenateam->GetMembers().begin(); itr != arenateam->GetMembers().end();
++itr)
{
bool offline = false;
Player* member = ObjectAccessor::FindConnectedPlayer(itr->Guid);
@@ -83,8 +85,8 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
{
offline = true;
}
//if (!member && !sObjectMgr->GetPlayerAccountIdByGUID(itr->guid))
// continue;
// if (!member && !sObjectMgr->GetPlayerAccountIdByGUID(itr->guid))
// continue;
if (offline)
sRandomPlayerbotMgr->AddPlayerBot(itr->Guid, 0);
@@ -107,10 +109,10 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
if (member->GetGUID() == bot->GetGUID())
continue;
if(member->InBattleground())
if (member->InBattleground())
continue;
if(member->InBattlegroundQueue())
if (member->InBattlegroundQueue())
continue;
if (member->GetGroup())
@@ -125,7 +127,8 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
if (!members.size() || (int)members.size() < (int)(arenateam->GetType() - 1))
{
LOG_INFO("playerbots", "Team #{} <{}> has not enough members for match", arenateam->GetId(), arenateam->GetName().c_str());
LOG_INFO("playerbots", "Team #{} <{}> has not enough members for match", arenateam->GetId(),
arenateam->GetName().c_str());
return false;
}
@@ -137,24 +140,25 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
if (!group->Create(bot))
{
LOG_INFO("playerbots", "Team #{} <{}>: Can't create group for arena queue", arenateam->GetId(), arenateam->GetName());
LOG_INFO("playerbots", "Team #{} <{}>: Can't create group for arena queue", arenateam->GetId(),
arenateam->GetName());
return false;
}
else
sGroupMgr->AddGroup(group);
LOG_INFO("playerbots", "Bot {} <{}>: Leader of <{}>", bot->GetGUID().ToString().c_str(), bot->GetName(), arenateam->GetName());
LOG_INFO("playerbots", "Bot {} <{}>: Leader of <{}>", bot->GetGUID().ToString().c_str(), bot->GetName(),
arenateam->GetName());
for (auto i = begin(members); i != end(members); ++i)
{
if (*i == bot->GetGUID())
continue;
//if (count >= (int)arenateam->GetType())
//break;
// if (count >= (int)arenateam->GetType())
// break;
if (group->GetMembersCount() >= (uint32) arenateam->GetType())
if (group->GetMembersCount() >= (uint32)arenateam->GetType())
break;
Player* member = ObjectAccessor::FindConnectedPlayer(*i);
@@ -174,19 +178,20 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
memberBotAI->Reset();
member->TeleportTo(bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), 0);
LOG_INFO("playerbots", "Bot {} <{}>: Member of <{}>", member->GetGUID().ToString().c_str(), member->GetName().c_str(), arenateam->GetName().c_str());
LOG_INFO("playerbots", "Bot {} <{}>: Member of <{}>", member->GetGUID().ToString().c_str(),
member->GetName().c_str(), arenateam->GetName().c_str());
}
if (group && group->GetMembersCount() >= (uint32)arenateam->GetType())
{
LOG_INFO("playerbots", "Team #{} <{}> Group is ready for match", arenateam->GetId(), arenateam->GetName().c_str());
LOG_INFO("playerbots", "Team #{} <{}> Group is ready for match", arenateam->GetId(),
arenateam->GetName().c_str());
return true;
}
else
{
LOG_INFO("playerbots", "Team #{} <{}> Group is not ready for match (not enough members)", arenateam->GetId(), arenateam->GetName().c_str());
LOG_INFO("playerbots", "Team #{} <{}> Group is not ready for match (not enough members)", arenateam->GetId(),
arenateam->GetName().c_str());
group->Disband();
}
@@ -229,7 +234,10 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
return false;
TeamId teamId = bot->GetTeamId();
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer) * 1.1;
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty()
? sPlayerbotAIConfig->diffEmpty
: sPlayerbotAIConfig->diffWithPlayer) *
1.1;
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
@@ -251,11 +259,15 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
// Check if bots should join Rated Arena (Only captains can queue)
uint32 ratedArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount;
uint32 ratedArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
uint32 ratedArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) <
(BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
if (isRated)
{
@@ -269,10 +281,14 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
// Check if bots should join Skirmish Arena
// We have extra bots queue because same faction can vs each other but can't be in the same group.
uint32 skirmishArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 skirmishArenaBotCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount);
if (maxRequiredSkirmishBots != 0)
maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize;
@@ -293,14 +309,14 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
if(teamId == TEAM_ALLIANCE)
if (teamId == TEAM_ALLIANCE)
{
if((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
if ((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
return true;
}
else
{
if((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
if ((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
return true;
}
@@ -351,9 +367,9 @@ bool BGJoinAction::isUseful()
return false;
// do not try if in dungeon
//Map* map = bot->GetMap();
//if (map && map->Instanceable())
// return false;
// Map* map = bot->GetMap();
// if (map && map->Instanceable())
// return false;
bgList.clear();
ratedList.clear();
@@ -415,8 +431,8 @@ bool BGJoinAction::JoinQueue(uint32 type)
// get BG MapId
uint32 bgTypeId_ = bgTypeId;
uint32 instanceId = 0; // 0 = First Available
uint32 instanceId = 0; // 0 = First Available
bool isPremade = false;
bool isArena = false;
bool isRated = false;
@@ -431,7 +447,7 @@ bool BGJoinAction::JoinQueue(uint32 type)
isArena = true;
// get battlemaster
//Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId));
// Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId));
Unit* unit = botAI->GetUnit(sRandomPlayerbotMgr->GetBattleMasterGUID(bot, bgTypeId));
if (!unit && isArena)
{
@@ -442,10 +458,10 @@ bool BGJoinAction::JoinQueue(uint32 type)
// This breaks groups as refresh includes a remove from group function call.
// refresh food/regs
//sRandomPlayerbotMgr->Refresh(bot);
// sRandomPlayerbotMgr->Refresh(bot);
bool joinAsGroup = bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() == bot->GetGUID();
// in wotlk only arena requires battlemaster guid
ObjectGuid guid = isArena ? unit->GetGUID() : bot->GetGUID();
@@ -459,7 +475,7 @@ bool BGJoinAction::JoinQueue(uint32 type)
break;
case BATTLEGROUND_AB:
_bgType = "AB";
break;
break;
case BATTLEGROUND_EY:
_bgType = "EotS";
break;
@@ -505,10 +521,11 @@ bool BGJoinAction::JoinQueue(uint32 type)
}
}
LOG_INFO("playerbots", "Bot {} {}:{} <{}> queued {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), _bgType.c_str(),
isRated ? "Rated Arena" : isArena ? "Arena" : "");
LOG_INFO("playerbots", "Bot {} {}:{} <{}> queued {} {}", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), _bgType.c_str(),
isRated ? "Rated Arena"
: isArena ? "Arena"
: "");
if (isArena)
{
@@ -519,17 +536,19 @@ bool BGJoinAction::JoinQueue(uint32 type)
}
else if (!joinAsGroup)
{
if(teamId == TEAM_ALLIANCE)
if (teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount++;
else
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++;
}
else
{
if(teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount += bot->GetGroup()->GetMembersCount();
if (teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount +=
bot->GetGroup()->GetMembersCount();
else
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount += bot->GetGroup()->GetMembersCount();
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount +=
bot->GetGroup()->GetMembersCount();
}
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
@@ -559,7 +578,10 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
return false;
TeamId teamId = bot->GetTeamId();
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer) * 1.1;
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty()
? sPlayerbotAIConfig->diffEmpty
: sPlayerbotAIConfig->diffWithPlayer) *
1.1;
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
@@ -581,11 +603,15 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
// Check if bots should join Rated Arena (Only captains can queue)
uint32 ratedArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount;
uint32 ratedArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
uint32 ratedArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) <
(BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
if (isRated)
{
@@ -599,10 +625,14 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
// Check if bots should join Skirmish Arena
// We have extra bots queue because same faction can vs each other but can't be in the same group.
uint32 skirmishArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 skirmishArenaBotCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount);
if (maxRequiredSkirmishBots != 0)
maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize;
@@ -623,14 +653,14 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
if(teamId == TEAM_ALLIANCE)
if (teamId == TEAM_ALLIANCE)
{
if((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
if ((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
return true;
}
else
{
if((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
if ((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount))
return true;
}
@@ -642,7 +672,7 @@ bool BGLeaveAction::Execute(Event event)
if (!(bot->InBattlegroundQueue() || bot->InBattleground()))
return false;
//botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT);
// botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT);
BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(0);
BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId);
@@ -661,8 +691,9 @@ bool BGLeaveAction::Execute(Event event)
if (bot->InBattleground())
{
LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG");
LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {}", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(),
isArena ? "Arena" : "BG");
WorldPacket leave(CMSG_LEAVE_BATTLEFIELD);
leave << uint8(0) << uint8(0) << uint32(0) << uint16(0);
@@ -683,8 +714,9 @@ bool BGLeaveAction::Execute(Event event)
if (!queueType)
return false;
LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} queue",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), isArena ? "Arena" : "BG");
LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} queue", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(),
isArena ? "Arena" : "BG");
WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20);
packet << type << unk2 << (uint32)_bgTypeId << unk << uint8(0);
@@ -701,10 +733,7 @@ bool BGLeaveAction::Execute(Event event)
return true;
}
bool BGStatusAction::isUseful()
{
return bot->InBattlegroundQueue();
}
bool BGStatusAction::isUseful() { return bot->InBattlegroundQueue(); }
bool BGStatusAction::Execute(Event event)
{
@@ -725,7 +754,7 @@ bool BGStatusAction::Execute(Event event)
WorldPacket p(event.getPacket());
statusid = 0;
p >> QueueSlot; // queue id (0...2) - player can be in 3 queues in time
p >> QueueSlot; // queue id (0...2) - player can be in 3 queues in time
p >> arenaByte;
if (arenaByte == 0)
return false;
@@ -738,20 +767,20 @@ bool BGStatusAction::Execute(Event event)
// check status
switch (statusid)
{
case STATUS_WAIT_QUEUE: // status_in_queue
p >> Time1; // average wait time, milliseconds
p >> Time2; // time in queue, updated every minute!, milliseconds
case STATUS_WAIT_QUEUE: // status_in_queue
p >> Time1; // average wait time, milliseconds
p >> Time2; // time in queue, updated every minute!, milliseconds
break;
case STATUS_WAIT_JOIN: // status_invite
p >> mapId; // map id
case STATUS_WAIT_JOIN: // status_invite
p >> mapId; // map id
p >> unk0;
p >> Time1; // time to remove from queue, milliseconds
p >> Time1; // time to remove from queue, milliseconds
break;
case STATUS_IN_PROGRESS: // status_in_progress
p >> mapId; // map id
case STATUS_IN_PROGRESS: // status_in_progress
p >> mapId; // map id
p >> unk0;
p >> Time1; // time to bg auto leave, 0 at bg start, 120000 after bg end, milliseconds
p >> Time2; // time from bg start, milliseconds
p >> Time1; // time to bg auto leave, 0 at bg start, 120000 after bg end, milliseconds
p >> Time2; // time from bg start, milliseconds
p >> arenaTeam;
break;
default:
@@ -773,7 +802,7 @@ bool BGStatusAction::Execute(Event event)
bracketId = pvpDiff->GetBracketId();
bool isArena = false;
uint8 type = false; // arenatype if arena
uint8 type = false; // arenatype if arena
uint16 unk = 0x1F90;
uint8 unk2 = 0x0;
uint8 action = 0x1;
@@ -829,10 +858,11 @@ bool BGStatusAction::Execute(Event event)
TeamId teamId = bot->GetTeamId();
if (Time1 == TIME_TO_AUTOREMOVE) //Battleground is over, bot needs to leave
if (Time1 == TIME_TO_AUTOREMOVE) // Battleground is over, bot needs to leave
{
LOG_INFO("playerbots", "Bot {} <{}> ({} {}): Received BG status TIME_REMOVE for {} {}",
bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType);
// remove warsong strategy
if (IsRandomBot)
@@ -851,12 +881,13 @@ bool BGStatusAction::Execute(Event event)
botAI->ChangeStrategy("-arena", BOT_STATE_COMBAT);
botAI->ChangeStrategy("-arena", BOT_STATE_NON_COMBAT);
LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} - {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} - {}", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(),
isArena ? "Arena" : "BG", _bgType);
WorldPacket packet(CMSG_LEAVE_BATTLEFIELD);
packet << uint8(0);
packet << uint8(0); // BattlegroundTypeId-1 ?
packet << uint8(0); // BattlegroundTypeId-1 ?
packet << uint32(0);
packet << uint16(0);
@@ -872,12 +903,13 @@ bool BGStatusAction::Execute(Event event)
posMap["bg objective"] = pos;
}
if (statusid == STATUS_WAIT_QUEUE) // bot is in queue
if (statusid == STATUS_WAIT_QUEUE) // bot is in queue
{
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Received BG status WAIT_QUEUE (wait time: {}) for {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), Time2, isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
bot->GetName(), Time2, isArena ? "Arena" : "BG", _bgType);
// temp fix for crash
//return true;
// return true;
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(queueTypeId);
GroupQueueInfo ginfo;
@@ -886,7 +918,8 @@ bool BGStatusAction::Execute(Event event)
if (ginfo.IsInvitedToBGInstanceGUID && !bot->InBattleground())
{
// BattlegroundMgr::GetBattleground() does not return battleground if bgTypeId==BATTLEGROUND_AA
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId);
Battleground* bg = sBattlegroundMgr->GetBattleground(
ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId);
if (bg)
{
if (isArena)
@@ -894,8 +927,9 @@ bool BGStatusAction::Execute(Event event)
_bgTypeId = bg->GetBgTypeID();
}
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Force join {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Force join {} {}", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(),
isArena ? "Arena" : "BG", _bgType);
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
action = 0x1;
@@ -905,8 +939,10 @@ bool BGStatusAction::Execute(Event event)
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
botAI->ResetStrategies(false);
if (!bot->GetBattleground()) {
// first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up properly, set bg for "bg strategy check" to fix that
if (!bot->GetBattleground())
{
// first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up
// properly, set bg for "bg strategy check" to fix that
botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT);
}
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
@@ -931,23 +967,26 @@ bool BGStatusAction::Execute(Event event)
else
timer = TIME_TO_AUTOREMOVE + 1000 * (bg->GetMaxPlayersPerTeam() * 8);
if (Time2 > timer && isArena) // disabled for BG
if (Time2 > timer && isArena) // disabled for BG
leaveQ = true;
if (leaveQ && ((bot->GetGroup() && bot->GetGroup()->IsLeader(bot->GetGUID())) || !(bot->GetGroup() || botAI->GetMaster())))
if (leaveQ && ((bot->GetGroup() && bot->GetGroup()->IsLeader(bot->GetGUID())) ||
!(bot->GetGroup() || botAI->GetMaster())))
{
TeamId teamId = bot->GetTeamId();
bool realPlayers = false;
if (isRated)
realPlayers = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount > 0;
else
realPlayers = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0;
realPlayers =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0;
if (realPlayers)
return false;
LOG_INFO("playerbots", "Bot {} {}:{} <{}> waited too long and leaves queue ({} {}).",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
bot->GetName(), isArena ? "Arena" : "BG", _bgType);
WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20);
action = 0;
@@ -963,17 +1002,19 @@ bool BGStatusAction::Execute(Event event)
}
}
if (statusid == STATUS_IN_PROGRESS) // placeholder for Leave BG if it takes too long
if (statusid == STATUS_IN_PROGRESS) // placeholder for Leave BG if it takes too long
{
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Received BG status IN_PROGRESS for {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
bot->GetName(), isArena ? "Arena" : "BG", _bgType);
return false;
}
if (statusid == STATUS_WAIT_JOIN) //bot may join
if (statusid == STATUS_WAIT_JOIN) // bot may join
{
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Received BG status WAIT_JOIN for {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
bot->GetName(), isArena ? "Arena" : "BG", _bgType);
if (isArena)
{
@@ -984,18 +1025,21 @@ bool BGStatusAction::Execute(Event event)
if (!bgQueue.GetPlayerGroupInfoData(bot->GetGUID(), &ginfo))
{
LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H",
bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
return false;
}
if (ginfo.IsInvitedToBGInstanceGUID)
{
// BattlegroundMgr::GetBattleground() does not return battleground if bgTypeId==BATTLEGROUND_AA
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId);
Battleground* bg = sBattlegroundMgr->GetBattleground(
ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId);
if (!bg)
{
LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H",
bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
return false;
}
@@ -1003,8 +1047,9 @@ bool BGStatusAction::Execute(Event event)
}
}
LOG_INFO("playerbots", "Bot {} {}:{} <{}> joined {} - {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType);
LOG_INFO("playerbots", "Bot {} {}:{} <{}> joined {} - {}", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(),
isArena ? "Arena" : "BG", _bgType);
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
@@ -1016,8 +1061,10 @@ bool BGStatusAction::Execute(Event event)
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
botAI->ResetStrategies(false);
if (!bot->GetBattleground()) {
// first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up properly, set bg for "bg strategy check" to fix that
if (!bot->GetBattleground())
{
// first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up properly,
// set bg for "bg strategy check" to fix that
botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT);
}
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
@@ -1043,25 +1090,25 @@ bool BGStatusCheckAction::Execute(Event event)
WorldPacket packet(CMSG_BATTLEFIELD_STATUS);
bot->GetSession()->HandleBattlefieldStatusOpcode(packet);
LOG_INFO("playerbots", "Bot {} <{}> ({} {}) : Checking BG invite status",
bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H");
LOG_INFO("playerbots", "Bot {} <{}> ({} {}) : Checking BG invite status", bot->GetGUID().ToString().c_str(),
bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H");
return true;
}
bool BGStatusCheckAction::isUseful()
{
return bot->InBattlegroundQueue();
}
bool BGStatusCheckAction::isUseful() { return bot->InBattlegroundQueue(); }
bool BGStrategyCheckAction::Execute(Event event)
{
bool inside_bg = bot->InBattleground() && bot->GetBattleground();;
if (!inside_bg && botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) {
bool inside_bg = bot->InBattleground() && bot->GetBattleground();
;
if (!inside_bg && botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT))
{
botAI->ResetStrategies();
return true;
}
if (inside_bg && !botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) {
if (inside_bg && !botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT))
{
botAI->ResetStrategies();
return false;
}