mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-12-01 21:12:50 +08:00
Merge branch 'master' into rewrite-equip-score2
This commit is contained in:
@@ -2562,7 +2562,7 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8
|
|||||||
|
|
||||||
if (!itemTarget)
|
if (!itemTarget)
|
||||||
{
|
{
|
||||||
if (sqrt(bot->GetDistance(x, y, z)) > sPlayerbotAIConfig->sightDistance)
|
if (bot->GetDistance(x, y, z) > sPlayerbotAIConfig->sightDistance)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3092,21 +3092,9 @@ bool PlayerbotAI::CastVehicleSpell(uint32 spellId, Unit* target)
|
|||||||
|
|
||||||
targets.SetDst(dest);
|
targets.SetDst(dest);
|
||||||
targets.SetSpeed(30.0f);
|
targets.SetSpeed(30.0f);
|
||||||
float distanceToDest = sqrt(vehicleBase->GetPosition().GetExactDist(dest));
|
float dist = vehicleBase->GetPosition().GetExactDist(dest);
|
||||||
float elev = 0.01f;
|
// very much an approximation of the real projectile arc
|
||||||
if (distanceToDest < 25.0f)
|
float elev = dist >= 110.0f ? 1.0f : pow(((dist + 10.0f) / 120.0f), 2.0f);
|
||||||
elev = 0.04f;
|
|
||||||
else if (distanceToDest < 55.0f)
|
|
||||||
elev = 0.22f;
|
|
||||||
else if (distanceToDest < 85.0f)
|
|
||||||
elev = 0.42f;
|
|
||||||
else if (distanceToDest < 95.0f)
|
|
||||||
elev = 0.70f;
|
|
||||||
else if (distanceToDest < 110.0f)
|
|
||||||
elev = 0.88f;
|
|
||||||
else
|
|
||||||
elev = 1.0f;
|
|
||||||
|
|
||||||
targets.SetElevation(elev);
|
targets.SetElevation(elev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,15 @@ PlayerbotFactory::PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality
|
|||||||
: level(level), itemQuality(itemQuality), gearScoreLimit(gearScoreLimit), bot(bot)
|
: level(level), itemQuality(itemQuality), gearScoreLimit(gearScoreLimit), bot(bot)
|
||||||
{
|
{
|
||||||
botAI = GET_PLAYERBOT_AI(bot);
|
botAI = GET_PLAYERBOT_AI(bot);
|
||||||
|
if (!this->itemQuality)
|
||||||
|
{
|
||||||
|
uint32 gs = sPlayerbotAIConfig->randomGearScoreLimit == 0
|
||||||
|
? 0
|
||||||
|
: PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->randomGearScoreLimit,
|
||||||
|
sPlayerbotAIConfig->randomGearQualityLimit);
|
||||||
|
this->itemQuality = sPlayerbotAIConfig->randomGearQualityLimit;
|
||||||
|
this->gearScoreLimit = gs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::Init()
|
void PlayerbotFactory::Init()
|
||||||
@@ -147,16 +156,6 @@ void PlayerbotFactory::Init()
|
|||||||
|
|
||||||
void PlayerbotFactory::Prepare()
|
void PlayerbotFactory::Prepare()
|
||||||
{
|
{
|
||||||
if (!itemQuality)
|
|
||||||
{
|
|
||||||
uint32 gs = sPlayerbotAIConfig->randomGearScoreLimit == 0
|
|
||||||
? 0
|
|
||||||
: PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->randomGearScoreLimit,
|
|
||||||
sPlayerbotAIConfig->randomGearQualityLimit);
|
|
||||||
itemQuality = sPlayerbotAIConfig->randomGearQualityLimit;
|
|
||||||
gearScoreLimit = gs;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bot->isDead())
|
if (bot->isDead())
|
||||||
bot->ResurrectPlayer(1.0f, false);
|
bot->ResurrectPlayer(1.0f, false);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ bool ReachAreaTriggerAction::Execute(Event event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bot->GetMapId() != at->map || sqrt(bot->GetDistance(at->x, at->y, at->z)) > sPlayerbotAIConfig->sightDistance)
|
if (bot->GetMapId() != at->map)
|
||||||
{
|
{
|
||||||
botAI->TellError("I won't follow: too far away");
|
botAI->TellError("I won't follow: too far away");
|
||||||
return true;
|
return true;
|
||||||
@@ -42,7 +42,7 @@ bool ReachAreaTriggerAction::Execute(Event event)
|
|||||||
|
|
||||||
bot->GetMotionMaster()->MovePoint(at->map, at->x, at->y, at->z);
|
bot->GetMotionMaster()->MovePoint(at->map, at->x, at->y, at->z);
|
||||||
|
|
||||||
float distance = sqrt(bot->GetDistance(at->x, at->y, at->z));
|
float distance = bot->GetDistance(at->x, at->y, at->z);
|
||||||
float delay = 1000.0f * distance / bot->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay;
|
float delay = 1000.0f * distance / bot->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay;
|
||||||
botAI->TellError("Wait for me");
|
botAI->TellError("Wait for me");
|
||||||
botAI->SetNextCheckDelay(delay);
|
botAI->SetNextCheckDelay(delay);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -294,7 +294,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
|
|||||||
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
|
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (sqrt(bot->GetDistance(master)) > sPlayerbotAIConfig->rpgDistance * 2)
|
if (bot->GetDistance(master) > sPlayerbotAIConfig->rpgDistance * 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Formation* formation = AI_VALUE(Formation*, "formation");
|
Formation* formation = AI_VALUE(Formation*, "formation");
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "PossibleRpgTargetsValue.h"
|
#include "PossibleRpgTargetsValue.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
|
#include "PvpTriggers.h"
|
||||||
|
|
||||||
bool AttackEnemyPlayerAction::isUseful()
|
bool AttackEnemyPlayerAction::isUseful()
|
||||||
{
|
{
|
||||||
// if carry flag, do not start fight
|
if (PlayerHasFlag::IsCapturingFlag(bot))
|
||||||
if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
|
return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
|
||||||
@@ -25,7 +25,7 @@ bool AttackEnemyFlagCarrierAction::isUseful()
|
|||||||
{
|
{
|
||||||
Unit* target = context->GetValue<Unit*>("enemy flag carrier")->Get();
|
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), 75.0f) &&
|
||||||
(bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976));
|
PlayerHasFlag::IsCapturingFlag(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttackAnythingAction::isUseful()
|
bool AttackAnythingAction::isUseful()
|
||||||
@@ -124,8 +124,7 @@ bool AttackAnythingAction::isPossible() { return AttackAction::isPossible() && G
|
|||||||
|
|
||||||
bool DpsAssistAction::isUseful()
|
bool DpsAssistAction::isUseful()
|
||||||
{
|
{
|
||||||
// if carry flag, do not start fight
|
if (PlayerHasFlag::IsCapturingFlag(bot))
|
||||||
if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ void MovementAction::JumpTo(uint32 mapId, float x, float y, float z)
|
|||||||
float botZ = bot->GetPositionZ();
|
float botZ = bot->GetPositionZ();
|
||||||
float speed = bot->GetSpeed(MOVE_RUN);
|
float speed = bot->GetSpeed(MOVE_RUN);
|
||||||
MotionMaster& mm = *bot->GetMotionMaster();
|
MotionMaster& mm = *bot->GetMotionMaster();
|
||||||
botAI->SetNextCheckDelay(1000);
|
|
||||||
mm.Clear();
|
mm.Clear();
|
||||||
mm.MoveJump(x, y, z, speed, speed, 1);
|
mm.MoveJump(x, y, z, speed, speed, 1);
|
||||||
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), 1000);
|
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), 1000);
|
||||||
@@ -141,7 +140,7 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged)
|
|||||||
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||||
CreateWp(bot, point.x, point.y, point.z, 0.0, 2334);
|
CreateWp(bot, point.x, point.y, point.z, 0.0, 2334);
|
||||||
|
|
||||||
float distPoint = sqrt(target->GetDistance(point.x, point.y, point.z));
|
float distPoint = target->GetDistance(point.x, point.y, point.z);
|
||||||
if (distPoint < dist && target->IsWithinLOS(point.x, point.y, point.z + bot->GetCollisionHeight()))
|
if (distPoint < dist && target->IsWithinLOS(point.x, point.y, point.z + bot->GetCollisionHeight()))
|
||||||
{
|
{
|
||||||
dist = distPoint;
|
dist = distPoint;
|
||||||
@@ -177,6 +176,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (bot->Unit::IsFalling()) {
|
// if (bot->Unit::IsFalling()) {
|
||||||
// bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL);
|
// bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL);
|
||||||
// return false;
|
// return false;
|
||||||
@@ -190,7 +190,27 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
bool generatePath = !bot->IsFlying() && !bot->isSwimming();
|
bool generatePath = !bot->IsFlying() && !bot->isSwimming();
|
||||||
bool disableMoveSplinePath = sPlayerbotAIConfig->disableMoveSplinePath >= 2 ||
|
bool disableMoveSplinePath = sPlayerbotAIConfig->disableMoveSplinePath >= 2 ||
|
||||||
(sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground());
|
(sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground());
|
||||||
if (exact_waypoint || disableMoveSplinePath || !generatePath)
|
if (Vehicle* vehicle = bot->GetVehicle())
|
||||||
|
{
|
||||||
|
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
||||||
|
Unit* vehicleBase = vehicle->GetBase();
|
||||||
|
if (!vehicleBase || !seat || !seat->CanControl()) // is passenger and cant move anyway
|
||||||
|
return false;
|
||||||
|
|
||||||
|
float distance = vehicleBase->GetExactDist(x, y, z); // use vehicle distance, not bot
|
||||||
|
if (distance > sPlayerbotAIConfig->contactDistance)
|
||||||
|
{
|
||||||
|
MotionMaster& mm = *vehicleBase->GetMotionMaster(); // need to move vehicle, not bot
|
||||||
|
mm.Clear();
|
||||||
|
mm.MovePoint(mapId, x, y, z, generatePath);
|
||||||
|
float delay = 1000.0f * (distance / vehicleBase->GetSpeed(MOVE_RUN)) - sPlayerbotAIConfig->reactDelay;
|
||||||
|
delay = std::max(.0f, delay);
|
||||||
|
delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, delay);
|
||||||
|
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (exact_waypoint || disableMoveSplinePath || !generatePath)
|
||||||
{
|
{
|
||||||
float distance = bot->GetExactDist(x, y, z);
|
float distance = bot->GetExactDist(x, y, z);
|
||||||
if (distance > sPlayerbotAIConfig->contactDistance)
|
if (distance > sPlayerbotAIConfig->contactDistance)
|
||||||
@@ -861,7 +881,10 @@ bool MovementAction::IsMovingAllowed(Unit* target)
|
|||||||
|
|
||||||
bool MovementAction::IsMovingAllowed(uint32 mapId, float x, float y, float z)
|
bool MovementAction::IsMovingAllowed(uint32 mapId, float x, float y, float z)
|
||||||
{
|
{
|
||||||
float distance = sqrt(bot->GetDistance(x, y, z));
|
// removed sqrt as means distance limit was effectively 22500 (ReactDistance<63>)
|
||||||
|
// leaving it commented incase we find ReactDistance limit causes problems
|
||||||
|
// float distance = sqrt(bot->GetDistance(x, y, z));
|
||||||
|
float distance = bot->GetDistance(x, y, z);
|
||||||
if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance)
|
if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,11 @@ bool AutoReleaseSpiritAction::Execute(Event event)
|
|||||||
}
|
}
|
||||||
if (bot->GetDistance(unit) >= INTERACTION_DISTANCE)
|
if (bot->GetDistance(unit) >= INTERACTION_DISTANCE)
|
||||||
{
|
{
|
||||||
bot->GetMotionMaster()->MoveChase(unit);
|
// bot needs to actually click spirit-healer in BG to get res timer going
|
||||||
|
// and in IOC it's not within clicking range when they res in own base
|
||||||
|
MotionMaster& mm = *bot->GetMotionMaster();
|
||||||
|
mm.Clear();
|
||||||
|
mm.MovePoint(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,11 +5,16 @@
|
|||||||
|
|
||||||
#include "VehicleActions.h"
|
#include "VehicleActions.h"
|
||||||
|
|
||||||
|
#include "BattlegroundIC.h"
|
||||||
#include "ItemVisitors.h"
|
#include "ItemVisitors.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
|
||||||
|
// TODO methods to enter/exit vehicle should be added to BGTactics or MovementAction (so that we can better control
|
||||||
|
// whether bot is in vehicle, eg: get out of vehicle to cap flag, if we're down to final boss, etc),
|
||||||
|
// right now they will enter vehicle based only what's available here, then they're stuck in vehicle until they die
|
||||||
|
// (LeaveVehicleAction doesnt do much seeing as they, or another bot, will get in immediately after exit)
|
||||||
bool EnterVehicleAction::Execute(Event event)
|
bool EnterVehicleAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
// do not switch vehicles yet
|
// do not switch vehicles yet
|
||||||
@@ -21,21 +26,30 @@ bool EnterVehicleAction::Execute(Event event)
|
|||||||
{
|
{
|
||||||
Unit* vehicleBase = botAI->GetUnit(*i);
|
Unit* vehicleBase = botAI->GetUnit(*i);
|
||||||
if (!vehicleBase)
|
if (!vehicleBase)
|
||||||
return false;
|
continue;
|
||||||
|
|
||||||
|
// dont let them get in the cannons as they'll stay forever and do nothing useful
|
||||||
|
// dont let them in catapult they cant use them at all
|
||||||
|
if (NPC_KEEP_CANNON == vehicleBase->GetEntry() || NPC_CATAPULT == vehicleBase->GetEntry())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!vehicleBase->IsFriendlyTo(bot))
|
if (!vehicleBase->IsFriendlyTo(bot))
|
||||||
return false;
|
continue;
|
||||||
|
|
||||||
if (!vehicleBase->GetVehicleKit()->GetAvailableSeatCount())
|
if (!vehicleBase->GetVehicleKit()->GetAvailableSeatCount())
|
||||||
return false;
|
continue;
|
||||||
|
|
||||||
if (fabs(bot->GetPositionZ() - vehicleBase->GetPositionZ()) < 20.0f)
|
// this will avoid adding passengers (which dont really do much for the IOC vehicles which is the only place
|
||||||
|
// this code is used)
|
||||||
|
if (vehicleBase->GetVehicleKit()->IsVehicleInUse())
|
||||||
|
continue;
|
||||||
|
|
||||||
// if (sServerFacade->GetDistance2d(bot, vehicle) > 100.0f)
|
float dist = sServerFacade->GetDistance2d(bot, vehicleBase);
|
||||||
// continue;
|
if (dist > 40.0f)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (sServerFacade->GetDistance2d(bot, vehicleBase) > 10.0f)
|
if (dist > INTERACTION_DISTANCE)
|
||||||
return MoveTo(vehicleBase, INTERACTION_DISTANCE);
|
return MoveTo(vehicleBase);
|
||||||
|
|
||||||
bot->EnterVehicle(vehicleBase);
|
bot->EnterVehicle(vehicleBase);
|
||||||
|
|
||||||
|
|||||||
@@ -99,8 +99,9 @@ void IsleStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
|||||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("incendiary rocket", 70.0f), nullptr)));
|
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("incendiary rocket", 70.0f), nullptr)));
|
||||||
triggers.push_back(
|
triggers.push_back(
|
||||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("rocket blast", 70.0f), nullptr)));
|
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("rocket blast", 70.0f), nullptr)));
|
||||||
triggers.push_back(
|
// this is bugged: it doesn't work, and stops glaive throw working (which is needed to take down gate)
|
||||||
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("blade salvo", 71.0f), nullptr)));
|
||||||
triggers.push_back(
|
triggers.push_back(
|
||||||
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("glaive throw", 70.0f), nullptr)));
|
new TriggerNode("in vehicle", NextAction::array(0, new NextAction("glaive throw", 70.0f), nullptr)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,22 +117,53 @@ bool PlayerIsInBattlegroundWithoutFlag::IsActive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerHasFlag::IsActive()
|
bool PlayerHasFlag::IsActive()
|
||||||
|
{
|
||||||
|
return IsCapturingFlag(bot);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerHasFlag::IsCapturingFlag(Player* bot)
|
||||||
{
|
{
|
||||||
if (bot->InBattleground())
|
if (bot->InBattleground())
|
||||||
{
|
{
|
||||||
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS)
|
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS)
|
||||||
{
|
{
|
||||||
BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground();
|
BattlegroundWS* bg = (BattlegroundWS*)bot->GetBattleground();
|
||||||
if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) ||
|
// bot is horde and has ally flag
|
||||||
bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE))
|
if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE))
|
||||||
{
|
{
|
||||||
return true;
|
if (bg->GetFlagPickerGUID(TEAM_HORDE)) // enemy has flag too
|
||||||
|
{
|
||||||
|
if (GameObject* go = bg->GetBGObject(BG_WS_OBJECT_H_FLAG))
|
||||||
|
{
|
||||||
|
// only indicate capturing if signicant distance from own flag
|
||||||
|
// (otherwise allow bot to defend itself)
|
||||||
|
return bot->GetDistance(go) > 36.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true; // enemy doesnt have flag so we can cap immediately
|
||||||
|
}
|
||||||
|
// bot is ally and has horde flag
|
||||||
|
if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE))
|
||||||
|
{
|
||||||
|
if (bg->GetFlagPickerGUID(TEAM_ALLIANCE)) // enemy has flag too
|
||||||
|
{
|
||||||
|
if (GameObject* go = bg->GetBGObject(BG_WS_OBJECT_A_FLAG))
|
||||||
|
{
|
||||||
|
// only indicate capturing if signicant distance from own flag
|
||||||
|
// (otherwise allow bot to defend itself)
|
||||||
|
return bot->GetDistance(go) > 36.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true; // enemy doesnt have flag so we can cap immediately
|
||||||
|
}
|
||||||
|
return false; // bot doesn't have flag
|
||||||
|
}
|
||||||
|
|
||||||
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_EY)
|
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_EY)
|
||||||
{
|
{
|
||||||
BattlegroundEY* bg = (BattlegroundEY*)botAI->GetBot()->GetBattleground();
|
// 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();
|
||||||
return bot->GetGUID() == bg->GetFlagPickerGUID();
|
return bot->GetGUID() == bg->GetFlagPickerGUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,15 @@ public:
|
|||||||
bool IsActive() override;
|
bool IsActive() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NOTE this trigger is only active when bot is actively returning flag
|
||||||
|
// (not when hiding in base because enemy has flag too)
|
||||||
class PlayerHasFlag : public Trigger
|
class PlayerHasFlag : public Trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayerHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has flag") {}
|
PlayerHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has flag") {}
|
||||||
|
|
||||||
bool IsActive() override;
|
bool IsActive() override;
|
||||||
|
static bool IsCapturingFlag(Player* bot);
|
||||||
};
|
};
|
||||||
|
|
||||||
class EnemyFlagCarrierNear : public Trigger
|
class EnemyFlagCarrierNear : public Trigger
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
|
#include "Vehicle.h"
|
||||||
|
|
||||||
bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit)
|
bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit)
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,19 @@ bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit)
|
|||||||
|
|
||||||
Unit* EnemyPlayerValue::Calculate()
|
Unit* EnemyPlayerValue::Calculate()
|
||||||
{
|
{
|
||||||
bool inCannon = botAI->IsInVehicle(false, true);
|
bool controllingCannon = false;
|
||||||
|
bool controllingVehicle = false;
|
||||||
|
if (Vehicle* vehicle = bot->GetVehicle())
|
||||||
|
{
|
||||||
|
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
||||||
|
if (!seat || !seat->CanControl()) // not in control of vehicle so cant attack anyone
|
||||||
|
return nullptr;
|
||||||
|
VehicleEntry const* vi = vehicle->GetVehicleInfo();
|
||||||
|
if (vi && vi->m_flags & VEHICLE_FLAG_FIXED_POSITION)
|
||||||
|
controllingCannon = true;
|
||||||
|
else
|
||||||
|
controllingVehicle = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 1. Check units we are currently in combat with.
|
// 1. Check units we are currently in combat with.
|
||||||
std::vector<Unit*> targets;
|
std::vector<Unit*> targets;
|
||||||
@@ -95,12 +108,15 @@ Unit* EnemyPlayerValue::Calculate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aggro weak enemies from further away.
|
// Aggro weak enemies from further away.
|
||||||
uint32 const aggroDistance = (inCannon || bot->GetHealth() > pTarget->GetHealth()) ? maxAggroDistance : 20.0f;
|
// If controlling mobile vehicle only agro close enemies (otherwise will never reach objective)
|
||||||
|
uint32 const aggroDistance = controllingVehicle ? 5.0f
|
||||||
|
: (controllingCannon || bot->GetHealth() > pTarget->GetHealth()) ? maxAggroDistance
|
||||||
|
: 20.0f;
|
||||||
if (!bot->IsWithinDist(pTarget, aggroDistance))
|
if (!bot->IsWithinDist(pTarget, aggroDistance))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (bot->IsWithinLOSInMap(pTarget) &&
|
if (bot->IsWithinLOSInMap(pTarget) &&
|
||||||
(inCannon || (fabs(bot->GetPositionZ() - pTarget->GetPositionZ()) < 30.0f)))
|
(controllingCannon || (fabs(bot->GetPositionZ() - pTarget->GetPositionZ()) < 30.0f)))
|
||||||
return pTarget;
|
return pTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ bool NearestVehiclesValue::AcceptUnit(Unit* unit)
|
|||||||
if (!unit || !unit->IsVehicle() || !unit->IsAlive())
|
if (!unit || !unit->IsVehicle() || !unit->IsAlive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Vehicle* veh = unit->GetVehicle();
|
Vehicle* veh = unit->GetVehicleKit();
|
||||||
if (!veh || !veh->GetAvailableSeatCount())
|
if (!veh || !veh->GetAvailableSeatCount())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user