mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 01:49:09 +00:00
fixes for arena I've been working on with Dave (most credit belongs to him I feel)
This commit is contained in:
@@ -252,6 +252,9 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
|
||||
if (!sPlayerbotAIConfig->randomBotAutoJoinBG && !hasPlayers)
|
||||
return false;
|
||||
|
||||
if (!hasPlayers && isArena) // avoid many arena's being created when 1 player queues a skirmish
|
||||
return false;
|
||||
|
||||
if (!(hasPlayers || hasBots))
|
||||
return false;
|
||||
|
||||
@@ -471,7 +474,8 @@ 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)
|
||||
{
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
|
||||
@@ -950,7 +954,8 @@ bool BGStatusAction::Execute(Event event)
|
||||
{
|
||||
if (ginfo.IsInvitedToBGInstanceGUID && !bot->InBattleground())
|
||||
{
|
||||
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId);
|
||||
// BattlegroundMgr::GetBattleground() does not return battleground if bgTypeId==BATTLEGROUND_AA
|
||||
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId);
|
||||
if (bg)
|
||||
{
|
||||
if (isArena)
|
||||
@@ -972,6 +977,8 @@ bool BGStatusAction::Execute(Event event)
|
||||
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
|
||||
|
||||
botAI->ResetStrategies(false);
|
||||
// if this is first bot into BG they can lose bg strat
|
||||
botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT);
|
||||
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
|
||||
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
||||
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
||||
@@ -1049,7 +1056,8 @@ bool BGStatusAction::Execute(Event event)
|
||||
|
||||
if (ginfo.IsInvitedToBGInstanceGUID)
|
||||
{
|
||||
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId);
|
||||
// BattlegroundMgr::GetBattleground() does not return battleground if bgTypeId==BATTLEGROUND_AA
|
||||
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId);
|
||||
if (!bg)
|
||||
{
|
||||
LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}",
|
||||
@@ -1077,6 +1085,8 @@ bool BGStatusAction::Execute(Event event)
|
||||
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
|
||||
|
||||
botAI->ResetStrategies(false);
|
||||
// if this is first bot into BG they can lose bg strat
|
||||
botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT);
|
||||
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
|
||||
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
||||
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
||||
|
||||
@@ -2607,6 +2607,13 @@ bool BGTactics::Execute(Event event)
|
||||
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||
return false;
|
||||
|
||||
if (bg->isArena())
|
||||
{
|
||||
// can't use this in arena - it will crash server wehen vPaths/vFlagIds are used uninitialized
|
||||
botAI->ResetStrategies();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bg->GetStatus() == STATUS_IN_PROGRESS)
|
||||
botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT);
|
||||
|
||||
@@ -4866,11 +4873,12 @@ bool ArenaTactics::Execute(Event event)
|
||||
if (botAI->HasStrategy("buff", BOT_STATE_NON_COMBAT))
|
||||
botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT);
|
||||
|
||||
if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID()))
|
||||
{
|
||||
botAI->ResetStrategies(false);
|
||||
botAI->SetMaster(nullptr);
|
||||
}
|
||||
// this causes bot to reset constantly in arena
|
||||
// if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID()))
|
||||
// {
|
||||
// botAI->ResetStrategies(false);
|
||||
// botAI->SetMaster(nullptr);
|
||||
// }
|
||||
|
||||
if (!bot->IsInCombat())
|
||||
return moveToCenter(bg);
|
||||
|
||||
Reference in New Issue
Block a user