mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge pull request #1418 from Boxhead78/bg-tactics-rewrite
Bots Bg Tactics rewrite (WSG, AB, AV, EYE)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "cs_playerbots.h"
|
||||
#include "cmath"
|
||||
#include "BattleGroundTactics.h"
|
||||
|
||||
class PlayerbotsDatabaseScript : public DatabaseScript
|
||||
{
|
||||
@@ -389,6 +390,43 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class PlayerBotsBGScript : public BGScript
|
||||
{
|
||||
public:
|
||||
PlayerBotsBGScript() : BGScript("PlayerBotsBGScript") {}
|
||||
|
||||
void OnBattlegroundStart(Battleground* bg) override
|
||||
{
|
||||
BGStrategyData data;
|
||||
|
||||
switch (bg->GetBgTypeID())
|
||||
{
|
||||
case BATTLEGROUND_WS:
|
||||
data.allianceStrategy = urand(0, WS_STRATEGY_MAX - 1);
|
||||
data.hordeStrategy = urand(0, WS_STRATEGY_MAX - 1);
|
||||
break;
|
||||
case BATTLEGROUND_AB:
|
||||
data.allianceStrategy = urand(0, AB_STRATEGY_MAX - 1);
|
||||
data.hordeStrategy = urand(0, AB_STRATEGY_MAX - 1);
|
||||
break;
|
||||
case BATTLEGROUND_AV:
|
||||
data.allianceStrategy = urand(0, AV_STRATEGY_MAX - 1);
|
||||
data.hordeStrategy = urand(0, AV_STRATEGY_MAX - 1);
|
||||
break;
|
||||
case BATTLEGROUND_EY:
|
||||
data.allianceStrategy = urand(0, EY_STRATEGY_MAX - 1);
|
||||
data.hordeStrategy = urand(0, EY_STRATEGY_MAX - 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bgStrategies[bg->GetInstanceID()] = data;
|
||||
}
|
||||
|
||||
void OnBattlegroundEnd(Battleground* bg, TeamId /*winnerTeam*/) override { bgStrategies.erase(bg->GetInstanceID()); }
|
||||
};
|
||||
|
||||
void AddPlayerbotsScripts()
|
||||
{
|
||||
new PlayerbotsDatabaseScript();
|
||||
@@ -397,6 +435,7 @@ void AddPlayerbotsScripts()
|
||||
new PlayerbotsServerScript();
|
||||
new PlayerbotsWorldScript();
|
||||
new PlayerbotsScript();
|
||||
new PlayerBotsBGScript();
|
||||
|
||||
AddSC_playerbots_commandscript();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ enum StrategyType : uint32
|
||||
// };
|
||||
|
||||
static float ACTION_IDLE = 0.0f;
|
||||
static float ACTION_BG = 1.0f;
|
||||
static float ACTION_DEFAULT = 5.0f;
|
||||
static float ACTION_NORMAL = 10.0f;
|
||||
static float ACTION_HIGH = 20.0f;
|
||||
|
||||
@@ -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
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,106 +10,82 @@
|
||||
void BGStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg join", relevance), nullptr)));
|
||||
triggers.push_back(new TriggerNode("bg invite active",
|
||||
NextAction::array(0, new NextAction("bg status check", relevance), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("timer", NextAction::array(0, new NextAction("bg strategy check", relevance), nullptr)));
|
||||
triggers.push_back(new TriggerNode("bg invite active", NextAction::array(0, new NextAction("bg status check", relevance), nullptr)));
|
||||
triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("bg strategy check", relevance), nullptr)));
|
||||
}
|
||||
|
||||
BGStrategy::BGStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) {}
|
||||
|
||||
void WarsongStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(
|
||||
new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode(
|
||||
"enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", 80.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode(
|
||||
"team has flag", NextAction::array(0, new NextAction("bg protect fc", 75.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("player has flag",
|
||||
NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr)));
|
||||
}
|
||||
|
||||
void AlteracStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{ /* placeholder */
|
||||
}
|
||||
|
||||
void ArathiStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(
|
||||
new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr)));
|
||||
}
|
||||
|
||||
void BattlegroundStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(
|
||||
new TriggerNode("bg waiting", NextAction::array(0, new NextAction("bg move to start", 1.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("bg active", NextAction::array(0, new NextAction("bg move to objective", 1.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("often", NextAction::array(0, new NextAction("bg check objective", 10.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("bg waiting", NextAction::array(0, new NextAction("bg move to start", ACTION_BG), nullptr)));
|
||||
triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg move to objective", ACTION_BG), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg check objective", ACTION_BG + 1), nullptr)));
|
||||
triggers.push_back(new TriggerNode("dead", NextAction::array(0, new NextAction("bg reset objective force", ACTION_EMERGENCY), nullptr)));
|
||||
// triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy
|
||||
// flag carrier", 80.0f), nullptr))); triggers.push_back(new TriggerNode("team flagcarrier near",
|
||||
// NextAction::array(0, new NextAction("bg protect fc", 40.0f), nullptr))); triggers.push_back(new
|
||||
// TriggerNode("player has flag", NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr)));
|
||||
}
|
||||
|
||||
void EyeStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
void WarsongStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(
|
||||
new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", ACTION_MOVE + 7.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode(
|
||||
"enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", ACTION_MOVE + 8.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("player has flag",
|
||||
NextAction::array(0, new NextAction("bg move to objective", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", ACTION_EMERGENCY ), nullptr)));
|
||||
triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", ACTION_RAID + 1.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("team flagcarrier near", NextAction::array(0, new NextAction("bg protect fc", ACTION_RAID), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", ACTION_BG), nullptr)));
|
||||
triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("bg move to objective", ACTION_EMERGENCY), nullptr)));
|
||||
triggers.push_back(new TriggerNode("timer bg", NextAction::array(0, new NextAction("bg reset objective force", ACTION_EMERGENCY), nullptr)));
|
||||
}
|
||||
|
||||
void AlteracStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(new TriggerNode("alliance no snowfall gy", NextAction::array(0, new NextAction("bg move to objective", ACTION_EMERGENCY), nullptr)));
|
||||
triggers.push_back(new TriggerNode("timer bg", NextAction::array(0, new NextAction("bg reset objective force", ACTION_EMERGENCY), nullptr)));
|
||||
}
|
||||
|
||||
void ArathiStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", ACTION_EMERGENCY), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", ACTION_BG), nullptr)));
|
||||
triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
}
|
||||
|
||||
void EyeStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", ACTION_EMERGENCY), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", ACTION_BG), nullptr)));
|
||||
triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", ACTION_RAID), nullptr)));
|
||||
triggers.push_back(new TriggerNode("player has flag",NextAction::array(0, new NextAction("bg move to objective", ACTION_EMERGENCY), nullptr)));
|
||||
}
|
||||
|
||||
//TODO: Do Priorities
|
||||
void IsleStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(
|
||||
new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("enter vehicle", 85.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("random", NextAction::array(0, new NextAction("leave vehicle", 80.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("hurl boulder", 70.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("fire cannon", 70.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("napalm", 70.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("enemy is close", NextAction::array(0, new NextAction("steam blast", 80.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("ram", 70.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("ram", 79.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("steam rush", 81.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("incendiary rocket", 70.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("rocket blast", 70.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", ACTION_MOVE), nullptr)));
|
||||
triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("enter vehicle", ACTION_MOVE + 8.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("leave vehicle", ACTION_MOVE + 7.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("hurl boulder", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("fire cannon", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("napalm", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("steam blast", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("ram", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("ram", ACTION_MOVE + 9.1f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("steam rush", ACTION_MOVE + 9.2f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("incendiary rocket", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("rocket blast", ACTION_MOVE + 9.0f), nullptr)));
|
||||
// this is bugged: it doesn't work, and stops glaive throw working (which is needed to take down gate)
|
||||
// triggers.push_back(
|
||||
// new TriggerNode("in vehicle", NextAction::array(0, new NextAction("blade salvo", 71.0f), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("glaive throw", 70.0f), nullptr)));
|
||||
// triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("blade salvo", ACTION_MOVE + 9.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("glaive throw", ACTION_MOVE + 9.0f), nullptr)));
|
||||
}
|
||||
|
||||
void ArenaStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(
|
||||
new TriggerNode("no possible targets", NextAction::array(0, new NextAction("arena tactics", 1.0f), nullptr)));
|
||||
new TriggerNode("no possible targets", NextAction::array(0, new NextAction("arena tactics", ACTION_BG), nullptr)));
|
||||
}
|
||||
|
||||
@@ -482,6 +482,19 @@ bool TimerTrigger::IsActive()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TimerBGTrigger::IsActive()
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
|
||||
if (now - lastCheck >= 60)
|
||||
{
|
||||
lastCheck = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasNoAuraTrigger::IsActive() { return !botAI->HasAura(getName(), GetTarget()); }
|
||||
|
||||
bool TankAssistTrigger::IsActive()
|
||||
|
||||
@@ -655,6 +655,17 @@ private:
|
||||
time_t lastCheck;
|
||||
};
|
||||
|
||||
class TimerBGTrigger : public Trigger
|
||||
{
|
||||
public:
|
||||
TimerBGTrigger(PlayerbotAI* botAI) : Trigger(botAI, "timer bg"), lastCheck(0) {}
|
||||
|
||||
bool IsActive() override;
|
||||
|
||||
private:
|
||||
time_t lastCheck;
|
||||
};
|
||||
|
||||
class TankAssistTrigger : public NoAttackersTrigger
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
|
||||
#include "PvpTriggers.h"
|
||||
|
||||
#include "BattleGroundTactics.h"
|
||||
#include "BattlegroundEY.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "BattlegroundWS.h"
|
||||
#include "Playerbots.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "BattlegroundAV.h"
|
||||
#include "BattlegroundEY.h"
|
||||
|
||||
bool EnemyPlayerNear::IsActive() { return AI_VALUE(Unit*, "enemy player target"); }
|
||||
|
||||
@@ -161,11 +164,27 @@ bool PlayerHasFlag::IsCapturingFlag(Player* bot)
|
||||
|
||||
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_EY)
|
||||
{
|
||||
// TODO we should probably add similiar logic as WSG to allow combat
|
||||
// when bot has flag but no bases are available to take it to
|
||||
BattlegroundEY* bg = (BattlegroundEY*)bot->GetBattleground();
|
||||
|
||||
// Check if bot has the flag
|
||||
if (bot->GetGUID() == bg->GetFlagPickerGUID())
|
||||
{
|
||||
// Count how many bases the bot's team owns
|
||||
uint32 controlledBases = 0;
|
||||
for (uint8 point = 0; point < EY_POINTS_MAX; ++point)
|
||||
{
|
||||
if (bg->GetCapturePointInfo(point)._ownerTeamId == bot->GetTeamId())
|
||||
controlledBases++;
|
||||
}
|
||||
|
||||
// If no bases are controlled, bot should go aggressive
|
||||
if (controlledBases == 0)
|
||||
return false; // bot has flag but no place to take it
|
||||
|
||||
// Otherwise, return false and stay defensive / move to base
|
||||
return bot->GetGUID() == bg->GetFlagPickerGUID();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -175,27 +194,29 @@ bool PlayerHasFlag::IsCapturingFlag(Player* bot)
|
||||
|
||||
bool TeamHasFlag::IsActive()
|
||||
{
|
||||
if (botAI->GetBot()->InBattleground())
|
||||
{
|
||||
if (botAI->GetBot()->GetBattlegroundTypeId() == BattlegroundTypeId::BATTLEGROUND_WS)
|
||||
{
|
||||
if (!botAI->GetBot()->InBattleground())
|
||||
return false;
|
||||
|
||||
if (botAI->GetBot()->GetBattlegroundTypeId() != BattlegroundTypeId::BATTLEGROUND_WS)
|
||||
return false;
|
||||
|
||||
BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground();
|
||||
|
||||
if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) ||
|
||||
bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE))
|
||||
{
|
||||
ObjectGuid botGuid = bot->GetGUID();
|
||||
TeamId teamId = bot->GetTeamId();
|
||||
TeamId enemyTeamId = bg->GetOtherTeamId(teamId);
|
||||
|
||||
// If the bot is carrying any flag, don't activate
|
||||
if (botGuid == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || botGuid == bg->GetFlagPickerGUID(TEAM_HORDE))
|
||||
return false;
|
||||
|
||||
// Check: Own team has enemy flag, enemy team does NOT have your flag
|
||||
bool ownTeamHasFlag = bg->GetFlagState(enemyTeamId) == BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
bool enemyTeamHasFlag = bg->GetFlagState(teamId) == BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
|
||||
return ownTeamHasFlag && !enemyTeamHasFlag;
|
||||
}
|
||||
|
||||
if (bg->GetFlagState(bg->GetOtherTeamId(bot->GetTeamId())) == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EnemyTeamHasFlag::IsActive()
|
||||
{
|
||||
@@ -226,11 +247,42 @@ bool EnemyTeamHasFlag::IsActive()
|
||||
bool EnemyFlagCarrierNear::IsActive()
|
||||
{
|
||||
Unit* carrier = AI_VALUE(Unit*, "enemy flag carrier");
|
||||
return carrier && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, carrier), 200.f);
|
||||
|
||||
if (!carrier || !sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, carrier), 100.f))
|
||||
return false;
|
||||
|
||||
// Check if there is another enemy player target closer than the FC
|
||||
Unit* nearbyEnemy = AI_VALUE(Unit*, "enemy player target");
|
||||
|
||||
if (nearbyEnemy)
|
||||
{
|
||||
float distToFC = sServerFacade->GetDistance2d(bot, carrier);
|
||||
float distToEnemy = sServerFacade->GetDistance2d(bot, nearbyEnemy);
|
||||
|
||||
// If the other enemy is significantly closer, don't pursue FC
|
||||
if (distToEnemy + 15.0f < distToFC) // Add small buffer
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TeamFlagCarrierNear::IsActive()
|
||||
{
|
||||
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS)
|
||||
{
|
||||
BattlegroundWS* bg = dynamic_cast<BattlegroundWS*>(bot->GetBattleground());
|
||||
if (bg)
|
||||
{
|
||||
bool bothFlagsNotAtBase =
|
||||
bg->GetFlagState(TEAM_ALLIANCE) != BG_WS_FLAG_STATE_ON_BASE &&
|
||||
bg->GetFlagState(TEAM_HORDE) != BG_WS_FLAG_STATE_ON_BASE;
|
||||
|
||||
if (bothFlagsNotAtBase)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Unit* carrier = AI_VALUE(Unit*, "team flag carrier");
|
||||
return carrier && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, carrier), 200.f);
|
||||
}
|
||||
@@ -259,3 +311,28 @@ bool VehicleNearTrigger::IsActive()
|
||||
}
|
||||
|
||||
bool InVehicleTrigger::IsActive() { return botAI->IsInVehicle(); }
|
||||
|
||||
bool AllianceNoSnowfallGY::IsActive()
|
||||
{
|
||||
if (!bot || bot->GetTeamId() != TEAM_ALLIANCE)
|
||||
return false;
|
||||
|
||||
Battleground* bg = bot->GetBattleground();
|
||||
if (bg && BGTactics::GetBotStrategyForTeam(bg, TEAM_ALLIANCE) != AV_STRATEGY_BALANCED)
|
||||
return false;
|
||||
|
||||
float botX = bot->GetPositionX();
|
||||
if (botX <= -562.0f)
|
||||
return false;
|
||||
|
||||
if (bot->GetBattlegroundTypeId() != BATTLEGROUND_AV)
|
||||
return false;
|
||||
|
||||
if (BattlegroundAV* av = dynamic_cast<BattlegroundAV*>(bg))
|
||||
{
|
||||
const BG_AV_NodeInfo& snowfall = av->GetAVNodeInfo(BG_AV_NODES_SNOWFALL_GRAVE);
|
||||
return snowfall.OwnerId != TEAM_ALLIANCE; // Active if the Snowfall Graveyard is NOT fully controlled by the Alliance
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -140,4 +140,12 @@ public:
|
||||
bool IsActive() override;
|
||||
};
|
||||
|
||||
class AllianceNoSnowfallGY : public Trigger
|
||||
{
|
||||
public:
|
||||
AllianceNoSnowfallGY(PlayerbotAI* botAI) : Trigger(botAI, "alliance no snowfall gy") {}
|
||||
|
||||
bool IsActive() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
creators["collision"] = &TriggerContext::collision;
|
||||
|
||||
creators["timer"] = &TriggerContext::Timer;
|
||||
creators["timer bg"] = &TriggerContext::TimerBG;
|
||||
creators["random"] = &TriggerContext::Random;
|
||||
creators["seldom"] = &TriggerContext::seldom;
|
||||
creators["often"] = &TriggerContext::often;
|
||||
@@ -177,6 +178,7 @@ public:
|
||||
creators["in Battleground"] = &TriggerContext::player_is_in_BATTLEGROUND;
|
||||
creators["in Battleground without flag"] = &TriggerContext::player_is_in_BATTLEGROUND_no_flag;
|
||||
creators["wants in bg"] = &TriggerContext::player_wants_in_bg;
|
||||
creators["alliance no snowfall gy"] = &TriggerContext::alliance_no_snowfall_gy;
|
||||
|
||||
creators["mounted"] = &TriggerContext::mounted;
|
||||
|
||||
@@ -307,6 +309,7 @@ private:
|
||||
static Trigger* NoAttackers(PlayerbotAI* botAI) { return new NoAttackersTrigger(botAI); }
|
||||
static Trigger* TankAssist(PlayerbotAI* botAI) { return new TankAssistTrigger(botAI); }
|
||||
static Trigger* Timer(PlayerbotAI* botAI) { return new TimerTrigger(botAI); }
|
||||
static Trigger* TimerBG(PlayerbotAI* botAI) { return new TimerBGTrigger(botAI); }
|
||||
static Trigger* NoTarget(PlayerbotAI* botAI) { return new NoTargetTrigger(botAI); }
|
||||
static Trigger* TargetInSight(PlayerbotAI* botAI) { return new TargetInSightTrigger(botAI); }
|
||||
static Trigger* not_dps_target_active(PlayerbotAI* botAI) { return new NotDpsTargetActiveTrigger(botAI); }
|
||||
@@ -377,10 +380,8 @@ private:
|
||||
static Trigger* enemy_team_has_flag(PlayerbotAI* botAI) { return new EnemyTeamHasFlag(botAI); }
|
||||
static Trigger* enemy_flagcarrier_near(PlayerbotAI* botAI) { return new EnemyFlagCarrierNear(botAI); }
|
||||
static Trigger* player_is_in_BATTLEGROUND(PlayerbotAI* botAI) { return new PlayerIsInBattleground(botAI); }
|
||||
static Trigger* player_is_in_BATTLEGROUND_no_flag(PlayerbotAI* botAI)
|
||||
{
|
||||
return new PlayerIsInBattlegroundWithoutFlag(botAI);
|
||||
}
|
||||
static Trigger* player_is_in_BATTLEGROUND_no_flag(PlayerbotAI* botAI) { return new PlayerIsInBattlegroundWithoutFlag(botAI); }
|
||||
static Trigger* alliance_no_snowfall_gy(PlayerbotAI* botAI) { return new AllianceNoSnowfallGY(botAI); }
|
||||
static Trigger* mounted(PlayerbotAI* botAI) { return new IsMountedTrigger(botAI); }
|
||||
static Trigger* at_dark_portal_outland(PlayerbotAI* botAI) { return new AtDarkPortalOutlandTrigger(botAI); }
|
||||
static Trigger* at_dark_portal_azeroth(PlayerbotAI* botAI) { return new AtDarkPortalAzerothTrigger(botAI); }
|
||||
|
||||
Reference in New Issue
Block a user