mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Arena] self bot now leaves finished arena game reliably (may also fix issues with other bot types leaving arena or all bot types leaving BG's but I wasnt able to reproduce any 'bots stay in bg/arena' bugs except self-bots in arena)
This commit is contained in:
@@ -674,6 +674,10 @@ bool BGLeaveAction::Execute(Event event)
|
||||
|
||||
// botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT);
|
||||
|
||||
if (BGStatusAction::LeaveBG(botAI))
|
||||
return true;
|
||||
|
||||
// leave queue if not in BG
|
||||
BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(0);
|
||||
BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId);
|
||||
uint8 type = false;
|
||||
@@ -689,27 +693,6 @@ bool BGLeaveAction::Execute(Event event)
|
||||
type = arenaType;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
WorldPacket leave(CMSG_LEAVE_BATTLEFIELD);
|
||||
leave << uint8(0) << uint8(0) << uint32(0) << uint16(0);
|
||||
bot->GetSession()->HandleBattlefieldLeaveOpcode(leave);
|
||||
|
||||
if (IsRandomBot)
|
||||
botAI->SetMaster(nullptr);
|
||||
|
||||
botAI->ResetStrategies(!IsRandomBot);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg role")->Set(0);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("arena type")->Set(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 queueType = AI_VALUE(uint32, "bg type");
|
||||
if (!queueType)
|
||||
return false;
|
||||
@@ -733,6 +716,54 @@ bool BGLeaveAction::Execute(Event event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BGStatusAction::LeaveBG(PlayerbotAI* botAI)
|
||||
{
|
||||
Player* bot = botAI->GetBot();
|
||||
Battleground* bg = bot->GetBattleground();
|
||||
if (!bg)
|
||||
return false;
|
||||
bool isArena = bg->isArena();
|
||||
bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
|
||||
|
||||
if (isRandomBot)
|
||||
botAI->SetMaster(nullptr);
|
||||
|
||||
botAI->ChangeStrategy("-warsong", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-warsong", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-arathi", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-arathi", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-eye", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-eye", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-isle", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-isle", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-Battleground", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-Battleground", BOT_STATE_NON_COMBAT);
|
||||
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");
|
||||
|
||||
WorldPacket packet(CMSG_LEAVE_BATTLEFIELD);
|
||||
packet << uint8(0);
|
||||
packet << uint8(0); // BattlegroundTypeId-1 ?
|
||||
packet << uint32(0);
|
||||
packet << uint16(0);
|
||||
|
||||
bot->GetSession()->HandleBattlefieldLeaveOpcode(packet);
|
||||
|
||||
botAI->ResetStrategies(!isRandomBot);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg role")->Set(0);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("arena type")->Set(0);
|
||||
PositionMap& posMap = botAI->GetAiObjectContext()->GetValue<PositionMap&>("position")->Get();
|
||||
PositionInfo pos = botAI->GetAiObjectContext()->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
||||
pos.Reset();
|
||||
posMap["bg objective"] = pos;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BGStatusAction::isUseful() { return bot->InBattlegroundQueue(); }
|
||||
|
||||
bool BGStatusAction::Execute(Event event)
|
||||
@@ -860,47 +891,12 @@ bool BGStatusAction::Execute(Event event)
|
||||
|
||||
if (Time1 == TIME_TO_AUTOREMOVE) // Battleground is over, bot needs to leave
|
||||
{
|
||||
LOG_INFO("playerbots", "Bot {} <{}> ({} {}): Received BG status TIME_REMOVE for {} {}",
|
||||
LOG_INFO("playerbots", "Bot {} <{}> ({} {}): Received BG status TIME_TO_AUTOREMOVE for {} {}",
|
||||
bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(),
|
||||
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType);
|
||||
|
||||
// remove warsong strategy
|
||||
if (IsRandomBot)
|
||||
botAI->SetMaster(nullptr);
|
||||
|
||||
botAI->ChangeStrategy("-warsong", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-warsong", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-arathi", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-arathi", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-eye", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-eye", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-isle", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-isle", BOT_STATE_NON_COMBAT);
|
||||
botAI->ChangeStrategy("-Battleground", BOT_STATE_COMBAT);
|
||||
botAI->ChangeStrategy("-Battleground", BOT_STATE_NON_COMBAT);
|
||||
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);
|
||||
|
||||
WorldPacket packet(CMSG_LEAVE_BATTLEFIELD);
|
||||
packet << uint8(0);
|
||||
packet << uint8(0); // BattlegroundTypeId-1 ?
|
||||
packet << uint32(0);
|
||||
packet << uint16(0);
|
||||
|
||||
bot->GetSession()->HandleBattlefieldLeaveOpcode(packet);
|
||||
|
||||
botAI->ResetStrategies(!IsRandomBot);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg role")->Set(0);
|
||||
botAI->GetAiObjectContext()->GetValue<uint32>("arena type")->Set(0);
|
||||
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
||||
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
||||
pos.Reset();
|
||||
posMap["bg objective"] = pos;
|
||||
if (LeaveBG(botAI))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (statusid == STATUS_WAIT_QUEUE) // bot is in queue
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
static bool LeaveBG(PlayerbotAI* botAI);
|
||||
};
|
||||
|
||||
class BGStatusCheckAction : public Action
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "BattleGroundTactics.h"
|
||||
#include "BattleGroundJoinAction.h"
|
||||
|
||||
#include "ArenaTeam.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
@@ -2167,7 +2168,7 @@ bool BGTactics::Execute(Event event)
|
||||
}
|
||||
|
||||
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||
return false;
|
||||
return BGStatusAction::LeaveBG(botAI);
|
||||
|
||||
if (bg->isArena())
|
||||
{
|
||||
@@ -4537,20 +4538,22 @@ bool ArenaTactics::Execute(Event event)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bot->GetBattleground()->GetStatus() != STATUS_IN_PROGRESS)
|
||||
Battleground* bg = bot->GetBattleground();
|
||||
if (!bg)
|
||||
return false;
|
||||
|
||||
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||
return BGStatusAction::LeaveBG(botAI);
|
||||
|
||||
if (bg->GetStatus() != STATUS_IN_PROGRESS)
|
||||
return false;
|
||||
|
||||
if (bot->isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bot->isMoving())
|
||||
return false;
|
||||
|
||||
Battleground* bg = bot->GetBattleground();
|
||||
if (!bg)
|
||||
return false;
|
||||
|
||||
// startup phase
|
||||
if (bg->GetStartDelayTime() > 0)
|
||||
|
||||
Reference in New Issue
Block a user