mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
fixes for arena I've been working on with Dave (most credit belongs to him I feel)
This commit is contained in:
@@ -1808,6 +1808,16 @@ Player* PlayerbotAI::GetPlayer(ObjectGuid guid)
|
|||||||
return unit ? unit->ToPlayer() : nullptr;
|
return unit ? unit->ToPlayer() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 GetCreatureIdForCreatureTemplateId(uint32 creatureTemplateId)
|
||||||
|
{
|
||||||
|
QueryResult results = WorldDatabase.Query("SELECT guid FROM `acore_world`.`creature` WHERE id1 = {} LIMIT 1;", creatureTemplateId);
|
||||||
|
if (results) {
|
||||||
|
Field* fields = results->Fetch();
|
||||||
|
return fields[0].Get<uint32>();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Unit* PlayerbotAI::GetUnit(CreatureData const* creatureData)
|
Unit* PlayerbotAI::GetUnit(CreatureData const* creatureData)
|
||||||
{
|
{
|
||||||
if (!creatureData)
|
if (!creatureData)
|
||||||
@@ -1817,7 +1827,10 @@ Unit* PlayerbotAI::GetUnit(CreatureData const* creatureData)
|
|||||||
if (!map)
|
if (!map)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId);
|
uint32 spawnId = creatureData->spawnId;
|
||||||
|
if (!spawnId) // workaround for CreatureData with missing spawnId (this just uses first matching creatureId in DB, but thats ok this method is only used for battlemasters and theres only 1 of each type)
|
||||||
|
spawnId = GetCreatureIdForCreatureTemplateId(creatureData->id1);
|
||||||
|
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId);
|
||||||
if (creatureBounds.first == creatureBounds.second)
|
if (creatureBounds.first == creatureBounds.second)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,9 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
|
|||||||
if (!sPlayerbotAIConfig->randomBotAutoJoinBG && !hasPlayers)
|
if (!sPlayerbotAIConfig->randomBotAutoJoinBG && !hasPlayers)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!hasPlayers && isArena) // avoid many arena's being created when 1 player queues a skirmish
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!(hasPlayers || hasBots))
|
if (!(hasPlayers || hasBots))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -471,7 +474,8 @@ bool BGJoinAction::JoinQueue(uint32 type)
|
|||||||
isArena = true;
|
isArena = true;
|
||||||
|
|
||||||
// get battlemaster
|
// 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)
|
if (!unit && isArena)
|
||||||
{
|
{
|
||||||
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
|
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
|
||||||
@@ -950,7 +954,8 @@ bool BGStatusAction::Execute(Event event)
|
|||||||
{
|
{
|
||||||
if (ginfo.IsInvitedToBGInstanceGUID && !bot->InBattleground())
|
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 (bg)
|
||||||
{
|
{
|
||||||
if (isArena)
|
if (isArena)
|
||||||
@@ -972,6 +977,8 @@ bool BGStatusAction::Execute(Event event)
|
|||||||
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
|
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
|
||||||
|
|
||||||
botAI->ResetStrategies(false);
|
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));
|
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
|
||||||
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
||||||
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
||||||
@@ -1049,7 +1056,8 @@ bool BGStatusAction::Execute(Event event)
|
|||||||
|
|
||||||
if (ginfo.IsInvitedToBGInstanceGUID)
|
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)
|
if (!bg)
|
||||||
{
|
{
|
||||||
LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}",
|
LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}",
|
||||||
@@ -1077,6 +1085,8 @@ bool BGStatusAction::Execute(Event event)
|
|||||||
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
|
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
|
||||||
|
|
||||||
botAI->ResetStrategies(false);
|
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));
|
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
|
||||||
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
PositionMap& posMap = context->GetValue<PositionMap&>("position")->Get();
|
||||||
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()["bg objective"];
|
||||||
|
|||||||
@@ -2607,6 +2607,13 @@ bool BGTactics::Execute(Event event)
|
|||||||
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
|
||||||
return false;
|
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)
|
if (bg->GetStatus() == STATUS_IN_PROGRESS)
|
||||||
botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT);
|
botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT);
|
||||||
|
|
||||||
@@ -4866,11 +4873,12 @@ bool ArenaTactics::Execute(Event event)
|
|||||||
if (botAI->HasStrategy("buff", BOT_STATE_NON_COMBAT))
|
if (botAI->HasStrategy("buff", BOT_STATE_NON_COMBAT))
|
||||||
botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT);
|
botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT);
|
||||||
|
|
||||||
if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID()))
|
// this causes bot to reset constantly in arena
|
||||||
{
|
// if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID()))
|
||||||
botAI->ResetStrategies(false);
|
// {
|
||||||
botAI->SetMaster(nullptr);
|
// botAI->ResetStrategies(false);
|
||||||
}
|
// botAI->SetMaster(nullptr);
|
||||||
|
// }
|
||||||
|
|
||||||
if (!bot->IsInCombat())
|
if (!bot->IsInCombat())
|
||||||
return moveToCenter(bg);
|
return moveToCenter(bg);
|
||||||
|
|||||||
Reference in New Issue
Block a user