mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-26 06:56:24 +00:00
Merge pull request #479 from fuzzdeveloper/self-bot-and-crash-fixes
Self bot and crash fixes
This commit is contained in:
@@ -578,18 +578,10 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
|||||||
if (!BgCheckTimer)
|
if (!BgCheckTimer)
|
||||||
BgCheckTimer = time(nullptr);
|
BgCheckTimer = time(nullptr);
|
||||||
|
|
||||||
uint32 count = 0;
|
if (time(nullptr) < BgCheckTimer + 30)
|
||||||
uint32 visual_count = 0;
|
|
||||||
|
|
||||||
uint32 check_time = count > 0 ? 120 : 30;
|
|
||||||
if (time(nullptr) < (BgCheckTimer + check_time))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else
|
BgCheckTimer = time(nullptr);
|
||||||
{
|
|
||||||
BgCheckTimer = time(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO("playerbots", "Checking BG Queue...");
|
LOG_INFO("playerbots", "Checking BG Queue...");
|
||||||
|
|
||||||
@@ -600,7 +592,8 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
|||||||
if (!player->InBattlegroundQueue())
|
if (!player->InBattlegroundQueue())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (player->InBattleground() && player->GetBattleground()->GetStatus() == STATUS_WAIT_LEAVE)
|
Battleground* bg = player->GetBattleground();
|
||||||
|
if (bg && bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TeamId teamId = player->GetTeamId();
|
TeamId teamId = player->GetTeamId();
|
||||||
@@ -611,7 +604,7 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
BattlegroundTypeId bgTypeId = sBattlegroundMgr->BGTemplateId(queueTypeId);
|
BattlegroundTypeId bgTypeId = sBattlegroundMgr->BGTemplateId(queueTypeId);
|
||||||
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
|
bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
|
||||||
uint32 mapId = bg->GetMapId();
|
uint32 mapId = bg->GetMapId();
|
||||||
PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, player->GetLevel());
|
PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, player->GetLevel());
|
||||||
if (!pvpDiff)
|
if (!pvpDiff)
|
||||||
@@ -690,7 +683,8 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
|||||||
if (!IsRandomBot(bot))
|
if (!IsRandomBot(bot))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (bot->InBattleground() && bot->GetBattleground()->GetStatus() == STATUS_WAIT_LEAVE)
|
Battleground* bg = bot->GetBattleground();
|
||||||
|
if (bg && bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TeamId teamId = bot->GetTeamId();
|
TeamId teamId = bot->GetTeamId();
|
||||||
@@ -702,7 +696,7 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
BattlegroundTypeId bgTypeId = sBattlegroundMgr->BGTemplateId(queueTypeId);
|
BattlegroundTypeId bgTypeId = sBattlegroundMgr->BGTemplateId(queueTypeId);
|
||||||
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
|
bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
|
||||||
uint32 mapId = bg->GetMapId();
|
uint32 mapId = bg->GetMapId();
|
||||||
PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, bot->GetLevel());
|
PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, bot->GetLevel());
|
||||||
if (!pvpDiff)
|
if (!pvpDiff)
|
||||||
|
|||||||
@@ -674,6 +674,10 @@ bool BGLeaveAction::Execute(Event event)
|
|||||||
|
|
||||||
// botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT);
|
// botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT);
|
||||||
|
|
||||||
|
if (BGStatusAction::LeaveBG(botAI))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// leave queue if not in BG
|
||||||
BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(0);
|
BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(0);
|
||||||
BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId);
|
BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId);
|
||||||
uint8 type = false;
|
uint8 type = false;
|
||||||
@@ -689,27 +693,6 @@ bool BGLeaveAction::Execute(Event event)
|
|||||||
type = arenaType;
|
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");
|
uint32 queueType = AI_VALUE(uint32, "bg type");
|
||||||
if (!queueType)
|
if (!queueType)
|
||||||
return false;
|
return false;
|
||||||
@@ -733,6 +716,54 @@ bool BGLeaveAction::Execute(Event event)
|
|||||||
return true;
|
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::isUseful() { return bot->InBattlegroundQueue(); }
|
||||||
|
|
||||||
bool BGStatusAction::Execute(Event event)
|
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
|
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->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(),
|
||||||
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType);
|
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType);
|
||||||
|
|
||||||
// remove warsong strategy
|
if (LeaveBG(botAI))
|
||||||
if (IsRandomBot)
|
return true;
|
||||||
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 (statusid == STATUS_WAIT_QUEUE) // bot is in queue
|
if (statusid == STATUS_WAIT_QUEUE) // bot is in queue
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public:
|
|||||||
|
|
||||||
bool Execute(Event event) override;
|
bool Execute(Event event) override;
|
||||||
bool isUseful() override;
|
bool isUseful() override;
|
||||||
|
static bool LeaveBG(PlayerbotAI* botAI);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BGStatusCheckAction : public Action
|
class BGStatusCheckAction : public Action
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BattleGroundTactics.h"
|
#include "BattleGroundTactics.h"
|
||||||
|
#include "BattleGroundJoinAction.h"
|
||||||
|
|
||||||
#include "ArenaTeam.h"
|
#include "ArenaTeam.h"
|
||||||
#include "ArenaTeamMgr.h"
|
#include "ArenaTeamMgr.h"
|
||||||
@@ -2167,7 +2168,7 @@ bool BGTactics::Execute(Event event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||||
return false;
|
return BGStatusAction::LeaveBG(botAI);
|
||||||
|
|
||||||
if (bg->isArena())
|
if (bg->isArena())
|
||||||
{
|
{
|
||||||
@@ -4088,13 +4089,17 @@ bool BGTactics::atFlag(std::vector<BattleBotPath*> const& vPaths, std::vector<ui
|
|||||||
{
|
{
|
||||||
for (auto& guid : closePlayers)
|
for (auto& guid : closePlayers)
|
||||||
{
|
{
|
||||||
Unit* pFriend = botAI->GetUnit(guid);
|
if (Unit* pFriend = botAI->GetUnit(guid))
|
||||||
if (pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL) &&
|
|
||||||
pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL)->m_spellInfo->Id == SPELL_CAPTURE_BANNER)
|
|
||||||
{
|
{
|
||||||
resetObjective();
|
if (Spell* spell = pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL))
|
||||||
startNewPathBegin(vPaths);
|
{
|
||||||
return false;
|
if (spell->m_spellInfo->Id == SPELL_CAPTURE_BANNER)
|
||||||
|
{
|
||||||
|
resetObjective();
|
||||||
|
startNewPathBegin(vPaths);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4537,20 +4542,22 @@ bool ArenaTactics::Execute(Event event)
|
|||||||
return false;
|
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;
|
return false;
|
||||||
|
|
||||||
if (bot->isDead())
|
if (bot->isDead())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (bot->isMoving())
|
if (bot->isMoving())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Battleground* bg = bot->GetBattleground();
|
|
||||||
if (!bg)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// startup phase
|
// startup phase
|
||||||
if (bg->GetStartDelayTime() > 0)
|
if (bg->GetStartDelayTime() > 0)
|
||||||
|
|||||||
@@ -129,11 +129,14 @@ bool CheckMountStateAction::isUseful()
|
|||||||
if (bot->isDead())
|
if (bot->isDead())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isOutdoor = bot->IsOutdoors();
|
if (bot->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
||||||
if (!isOutdoor)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bot->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
// checks both outdoors flag, and whether bot is clipping below floor slightly
|
||||||
|
// because that will cause bot to falsely indicate outdoors state and try
|
||||||
|
// mount indoors (seems to mostly be an issue in tunnels of WSG and AV)
|
||||||
|
if (!bot->IsOutdoors() || bot->GetPositionZ() < bot->GetMapWaterOrGroundLevel(
|
||||||
|
bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bot->InArena())
|
if (bot->InArena())
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ bool AutoReleaseSpiritAction::Execute(Event event)
|
|||||||
mm.Clear();
|
mm.Clear();
|
||||||
mm.MovePoint(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), true);
|
mm.MovePoint(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), true);
|
||||||
}
|
}
|
||||||
else
|
else if (!botAI->IsRealPlayer()) // below doesnt work properly on realplayer, but its also not needed
|
||||||
{
|
{
|
||||||
bg_gossip_time = time(NULL);
|
bg_gossip_time = time(NULL);
|
||||||
WorldPacket packet(CMSG_GOSSIP_HELLO);
|
WorldPacket packet(CMSG_GOSSIP_HELLO);
|
||||||
@@ -133,7 +133,7 @@ bool AutoReleaseSpiritAction::Execute(Event event)
|
|||||||
bot->GetSession()->HandleGossipHelloOpcode(packet);
|
bot->GetSession()->HandleGossipHelloOpcode(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
botAI->SetNextCheckDelay(1000);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user