mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Battlegrounds] fix for #424 - flag carrier not fighting back when enemy has flag too and bot is hiding
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "Event.h"
|
||||
#include "Playerbots.h"
|
||||
#include "PositionValue.h"
|
||||
#include "PvpTriggers.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
@@ -1771,7 +1772,10 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session,
|
||||
Creature* wpCreature = player->SummonCreature(15631, c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 15000u);
|
||||
wpCreature->SetOwnerGUID(player->GetGUID());
|
||||
return fmt::format("Showing location of Creature {}", num);
|
||||
float distance = player->GetDistance(c);
|
||||
float exactDistance = player->GetExactDist(c);
|
||||
return fmt::format("Showing Creature {} location={:.3f},{:.3f},{:.3f} distance={} exactDistance={}",
|
||||
num, c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), distance, exactDistance);
|
||||
}
|
||||
|
||||
if (!strncmp(cmd, "showobject=", 11))
|
||||
@@ -1787,7 +1791,10 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session,
|
||||
Creature* wpCreature = player->SummonCreature(15631, o->GetPositionX(), o->GetPositionY(), o->GetPositionZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 15000u);
|
||||
wpCreature->SetOwnerGUID(player->GetGUID());
|
||||
return fmt::format("Showing location of GameObject {}", num);
|
||||
float distance = player->GetDistance(o);
|
||||
float exactDistance = player->GetExactDist(o);
|
||||
return fmt::format("Showing GameObject {} location={:.3f},{:.3f},{:.3f} distance={} exactDistance={}",
|
||||
num, o->GetPositionX(), o->GetPositionY(), o->GetPositionZ(), distance, exactDistance);
|
||||
}
|
||||
|
||||
return "usage: showpath(=[num]) / showcreature=[num] / showobject=[num]";
|
||||
@@ -2266,8 +2273,7 @@ bool BGTactics::Execute(Event event)
|
||||
|
||||
// NOTE: can't use IsInCombat() when in vehicle as player is stuck in combat forever while in vehicle (ac bug?)
|
||||
bool inCombat = bot->GetVehicle() ? (bool)AI_VALUE(Unit*, "enemy player target") : bot->IsInCombat();
|
||||
if (inCombat && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) ||
|
||||
bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)))
|
||||
if (inCombat && !PlayerHasFlag::IsCapturingFlag(bot))
|
||||
{
|
||||
// bot->GetMotionMaster()->MovementExpired();
|
||||
return false;
|
||||
@@ -3886,10 +3892,7 @@ bool BGTactics::moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 curr
|
||||
|
||||
// NOTE: can't use IsInCombat() when in vehicle as player is stuck in combat forever while in vehicle (ac bug?)
|
||||
bool inCombat = bot->GetVehicle() ? (bool)AI_VALUE(Unit*, "enemy player target") : bot->IsInCombat();
|
||||
if ((currentPoint == lastPointInPath) ||
|
||||
(inCombat && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) ||
|
||||
bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) ||
|
||||
!bot->IsAlive())
|
||||
if (currentPoint == lastPointInPath || (inCombat && !PlayerHasFlag::IsCapturingFlag(bot)) || !bot->IsAlive())
|
||||
{
|
||||
// Path is over.
|
||||
// std::ostringstream out;
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
#include "Playerbots.h"
|
||||
#include "PossibleRpgTargetsValue.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "PvpTriggers.h"
|
||||
|
||||
bool AttackEnemyPlayerAction::isUseful()
|
||||
{
|
||||
// if carry flag, do not start fight
|
||||
if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))
|
||||
if (PlayerHasFlag::IsCapturingFlag(bot))
|
||||
return false;
|
||||
|
||||
return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
|
||||
@@ -25,7 +25,7 @@ bool AttackEnemyFlagCarrierAction::isUseful()
|
||||
{
|
||||
Unit* target = context->GetValue<Unit*>("enemy flag carrier")->Get();
|
||||
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()
|
||||
@@ -124,8 +124,7 @@ bool AttackAnythingAction::isPossible() { return AttackAction::isPossible() && G
|
||||
|
||||
bool DpsAssistAction::isUseful()
|
||||
{
|
||||
// if carry flag, do not start fight
|
||||
if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))
|
||||
if (PlayerHasFlag::IsCapturingFlag(bot))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -44,13 +44,12 @@ bool EnterVehicleAction::Execute(Event event)
|
||||
if (vehicleBase->GetVehicleKit()->IsVehicleInUse())
|
||||
continue;
|
||||
|
||||
// if (fabs(bot->GetPositionZ() - vehicleBase->GetPositionZ()) < 20.0f)
|
||||
float dist = sServerFacade->GetDistance2d(bot, vehicleBase);
|
||||
if (dist > 40.0f)
|
||||
continue;
|
||||
|
||||
// if (sServerFacade->GetDistance2d(bot, vehicle) > 100.0f)
|
||||
// continue;
|
||||
|
||||
if (sServerFacade->GetDistance2d(bot, vehicleBase) > INTERACTION_DISTANCE)
|
||||
return MoveTo(vehicleBase, INTERACTION_DISTANCE - 1.0f);
|
||||
if (dist > INTERACTION_DISTANCE)
|
||||
return MoveTo(vehicleBase);
|
||||
|
||||
bot->EnterVehicle(vehicleBase);
|
||||
|
||||
|
||||
@@ -117,22 +117,53 @@ bool PlayerIsInBattlegroundWithoutFlag::IsActive()
|
||||
}
|
||||
|
||||
bool PlayerHasFlag::IsActive()
|
||||
{
|
||||
return IsCapturingFlag(bot);
|
||||
}
|
||||
|
||||
bool PlayerHasFlag::IsCapturingFlag(Player* bot)
|
||||
{
|
||||
if (bot->InBattleground())
|
||||
{
|
||||
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS)
|
||||
{
|
||||
BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground();
|
||||
if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) ||
|
||||
bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE))
|
||||
BattlegroundWS* bg = (BattlegroundWS*)bot->GetBattleground();
|
||||
// bot is horde and has ally flag
|
||||
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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,15 @@ public:
|
||||
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
|
||||
{
|
||||
public:
|
||||
PlayerHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has flag") {}
|
||||
|
||||
bool IsActive() override;
|
||||
static bool IsCapturingFlag(Player* bot);
|
||||
};
|
||||
|
||||
class EnemyFlagCarrierNear : public Trigger
|
||||
|
||||
Reference in New Issue
Block a user