Merge pull request #1418 from Boxhead78/bg-tactics-rewrite

Bots Bg Tactics rewrite (WSG, AB, AV, EYE)
This commit is contained in:
kadeshar
2025-07-07 21:45:35 +02:00
committed by GitHub
13 changed files with 1692 additions and 2016 deletions

View File

@@ -193,6 +193,7 @@ public:
// BG Tactics
creators["bg tactics"] = &ActionContext::bg_tactics;
creators["bg move to start"] = &ActionContext::bg_move_to_start;
creators["bg reset objective force"] = &ActionContext::bg_reset_objective_force;
creators["bg move to objective"] = &ActionContext::bg_move_to_objective;
creators["bg select objective"] = &ActionContext::bg_select_objective;
creators["bg check objective"] = &ActionContext::bg_check_objective;
@@ -376,6 +377,7 @@ private:
// BG Tactics
static Action* bg_tactics(PlayerbotAI* botAI) { return new BGTactics(botAI); }
static Action* bg_move_to_start(PlayerbotAI* botAI) { return new BGTactics(botAI, "move to start"); }
static Action* bg_reset_objective_force(PlayerbotAI* botAI) { return new BGTactics(botAI, "reset objective force"); }
static Action* bg_move_to_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "move to objective"); }
static Action* bg_select_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "select objective"); }
static Action* bg_check_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "check objective"); }

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,7 @@
#ifndef _PLAYERBOT_BATTLEGROUNDTACTICSACTION_H
#define _PLAYERBOT_BATTLEGROUNDTACTICSACTION_H
#include "BattlegroundAV.h"
#include "MovementActions.h"
class ChatHandler;
@@ -15,8 +16,49 @@ struct Position;
#define SPELL_CAPTURE_BANNER 21651
enum WSBotStrategy : uint8
{
WS_STRATEGY_BALANCED = 0,
WS_STRATEGY_OFFENSIVE = 1,
WS_STRATEGY_DEFENSIVE = 2,
WS_STRATEGY_MAX = 3,
};
enum ABBotStrategy : uint8
{
AB_STRATEGY_BALANCED = 0,
AB_STRATEGY_OFFENSIVE = 1,
AB_STRATEGY_DEFENSIVE = 2,
AB_STRATEGY_MAX = 3,
};
enum AVBotStrategy : uint8
{
AV_STRATEGY_BALANCED = 0,
AV_STRATEGY_OFFENSIVE = 1,
AV_STRATEGY_DEFENSIVE = 2,
AV_STRATEGY_MAX = 3,
};
enum EYBotStrategy : uint8
{
EY_STRATEGY_BALANCED = 0,
EY_STRATEGY_FRONT_FOCUS = 1,
EY_STRATEGY_BACK_FOCUS = 2,
EY_STRATEGY_FLAG_FOCUS = 3,
EY_STRATEGY_MAX = 4
};
typedef void (*BattleBotWaypointFunc)();
struct BGStrategyData
{
uint8 allianceStrategy = 0;
uint8 hordeStrategy = 0;
};
extern std::unordered_map<uint32, BGStrategyData> bgStrategies;
struct BattleBotWaypoint
{
BattleBotWaypoint(float x_, float y_, float z_, BattleBotWaypointFunc func) : x(x_), y(y_), z(z_), pFunc(func){};
@@ -27,6 +69,31 @@ struct BattleBotWaypoint
BattleBotWaypointFunc pFunc = nullptr;
};
struct AVNodePositionData
{
Position pos;
float maxRadius;
};
// Added to fix bot stuck at objectives
static std::unordered_map<uint8, AVNodePositionData> AVNodeMovementTargets = {
{BG_AV_NODES_FIRSTAID_STATION, {Position(640.364f, -36.535f, 45.625f), 15.0f}},
{BG_AV_NODES_STORMPIKE_GRAVE, {Position(665.598f, -292.976f, 30.291f), 15.0f}},
{BG_AV_NODES_STONEHEART_GRAVE, {Position(76.108f, -399.602f, 45.730f), 15.0f}},
{BG_AV_NODES_SNOWFALL_GRAVE, {Position(-201.298f, -119.661f, 78.291f), 15.0f}},
{BG_AV_NODES_ICEBLOOD_GRAVE, {Position(-617.858f, -400.654f, 59.692f), 15.0f}},
{BG_AV_NODES_FROSTWOLF_GRAVE, {Position(-1083.803f, -341.520f, 55.304f), 15.0f}},
{BG_AV_NODES_FROSTWOLF_HUT, {Position(-1405.678f, -309.108f, 89.377f, 0.392f), 10.0f}},
{BG_AV_NODES_DUNBALDAR_SOUTH, {Position(556.551f, -77.240f, 51.931f), 0.0f}},
{BG_AV_NODES_DUNBALDAR_NORTH, {Position(670.664f, -142.031f, 63.666f), 0.0f}},
{BG_AV_NODES_ICEWING_BUNKER, {Position(200.310f, -361.232f, 56.387f), 0.0f}},
{BG_AV_NODES_STONEHEART_BUNKER, {Position(-156.302f, -440.032f, 40.403f), 0.0f}},
{BG_AV_NODES_ICEBLOOD_TOWER, {Position(-569.702f, -265.362f, 75.009f), 0.0f}},
{BG_AV_NODES_TOWER_POINT, {Position(-767.439f, -360.200f, 90.895f), 0.0f}},
{BG_AV_NODES_FROSTWOLF_ETOWER, {Position(-1303.737f, -314.070f, 113.868f), 0.0f}},
{BG_AV_NODES_FROSTWOLF_WTOWER, {Position(-1300.648f, -267.356f, 114.151f), 0.0f}},
};
typedef std::vector<BattleBotWaypoint> BattleBotPath;
extern std::vector<BattleBotPath*> const vPaths_WS;
@@ -39,6 +106,7 @@ class BGTactics : public MovementAction
{
public:
static bool HandleConsoleCommand(ChatHandler* handler, char const* args);
uint8 static GetBotStrategyForTeam(Battleground* bg, TeamId teamId);
BGTactics(PlayerbotAI* botAI, std::string const name = "bg tactics") : MovementAction(botAI, name) {}
@@ -48,13 +116,13 @@ private:
static std::string const HandleConsoleCommandPrivate(WorldSession* session, char const* args);
bool moveToStart(bool force = false);
bool selectObjective(bool reset = false);
bool moveToObjective();
bool moveToObjective(bool ignoreDist);
bool selectObjectiveWp(std::vector<BattleBotPath*> const& vPaths);
bool moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 currentPoint, bool reverse = false);
bool startNewPathBegin(std::vector<BattleBotPath*> const& vPaths);
bool startNewPathFree(std::vector<BattleBotPath*> const& vPaths);
bool resetObjective();
bool wsgPaths();
bool wsJumpDown();
bool eyJumpDown();
bool atFlag(std::vector<BattleBotPath*> const& vPaths, std::vector<uint32> const& vFlagIds);
bool flagTaken();

View File

@@ -4,6 +4,8 @@
*/
#include "CheckMountStateAction.h"
#include "BattleGroundTactics.h"
#include "BattlegroundEY.h"
#include "BattlegroundWS.h"
#include "Event.h"
#include "PlayerbotAI.h"
@@ -98,7 +100,7 @@ bool CheckMountStateAction::isUseful()
if (bot->InBattleground())
{
// Do not use when carrying BG Flags
if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))
if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))
return false;
// Only mount if BG starts in less than 30 sec

View File

@@ -25,7 +25,7 @@ bool AttackEnemyPlayerAction::isUseful()
bool AttackEnemyFlagCarrierAction::isUseful()
{
Unit* target = context->GetValue<Unit*>("enemy flag carrier")->Get();
return target && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), 75.0f) &&
return target && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), 100.0f) &&
PlayerHasFlag::IsCapturingFlag(bot);
}