improved check to avoid unresponsive BG/arena bot, and removed possibility of battleground strat crashing server when in wrong BG

This commit is contained in:
Fuzz
2024-07-04 18:09:47 +10:00
parent 08cbe2f4ec
commit 718f90c4e9
2 changed files with 12 additions and 5 deletions

View File

@@ -977,8 +977,10 @@ 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 if (!bot->GetBattleground()) {
botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT); // 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)); 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"];
@@ -1085,8 +1087,10 @@ 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 if (!bot->GetBattleground()) {
botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT); // 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)); 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"];

View File

@@ -2609,7 +2609,7 @@ bool BGTactics::Execute(Event event)
if (bg->isArena()) if (bg->isArena())
{ {
// can't use this in arena - it will crash server wehen vPaths/vFlagIds are used uninitialized // can't use this in arena - no vPaths/vFlagIds (will crash server)
botAI->ResetStrategies(); botAI->ResetStrategies();
return false; return false;
} }
@@ -2656,6 +2656,9 @@ bool BGTactics::Execute(Event event)
break; break;
} }
default: default:
// can't use this in this BG - no vPaths/vFlagIds (will crash server)
botAI->ResetStrategies();
return false;
break; break;
} }