[Battlegrounds] fix for #424 - flag carrier not fighting back when enemy has flag too and bot is hiding

This commit is contained in:
Fuzz
2024-08-07 23:40:19 +10:00
parent 45ebef049f
commit 27c5d6b19c
5 changed files with 59 additions and 24 deletions

View File

@@ -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;