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 "Event.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "PositionValue.h"
|
#include "PositionValue.h"
|
||||||
|
#include "PvpTriggers.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
#include "Vehicle.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,
|
Creature* wpCreature = player->SummonCreature(15631, c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), 0,
|
||||||
TEMPSUMMON_TIMED_DESPAWN, 15000u);
|
TEMPSUMMON_TIMED_DESPAWN, 15000u);
|
||||||
wpCreature->SetOwnerGUID(player->GetGUID());
|
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))
|
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,
|
Creature* wpCreature = player->SummonCreature(15631, o->GetPositionX(), o->GetPositionY(), o->GetPositionZ(), 0,
|
||||||
TEMPSUMMON_TIMED_DESPAWN, 15000u);
|
TEMPSUMMON_TIMED_DESPAWN, 15000u);
|
||||||
wpCreature->SetOwnerGUID(player->GetGUID());
|
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]";
|
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?)
|
// 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();
|
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) ||
|
if (inCombat && !PlayerHasFlag::IsCapturingFlag(bot))
|
||||||
bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)))
|
|
||||||
{
|
{
|
||||||
// bot->GetMotionMaster()->MovementExpired();
|
// bot->GetMotionMaster()->MovementExpired();
|
||||||
return false;
|
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?)
|
// 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();
|
bool inCombat = bot->GetVehicle() ? (bool)AI_VALUE(Unit*, "enemy player target") : bot->IsInCombat();
|
||||||
if ((currentPoint == lastPointInPath) ||
|
if (currentPoint == lastPointInPath || (inCombat && !PlayerHasFlag::IsCapturingFlag(bot)) || !bot->IsAlive())
|
||||||
(inCombat && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) ||
|
|
||||||
bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) ||
|
|
||||||
!bot->IsAlive())
|
|
||||||
{
|
{
|
||||||
// Path is over.
|
// Path is over.
|
||||||
// std::ostringstream out;
|
// std::ostringstream out;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -44,13 +44,12 @@ bool EnterVehicleAction::Execute(Event event)
|
|||||||
if (vehicleBase->GetVehicleKit()->IsVehicleInUse())
|
if (vehicleBase->GetVehicleKit()->IsVehicleInUse())
|
||||||
continue;
|
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)
|
if (dist > INTERACTION_DISTANCE)
|
||||||
// continue;
|
return MoveTo(vehicleBase);
|
||||||
|
|
||||||
if (sServerFacade->GetDistance2d(bot, vehicleBase) > INTERACTION_DISTANCE)
|
|
||||||
return MoveTo(vehicleBase, INTERACTION_DISTANCE - 1.0f);
|
|
||||||
|
|
||||||
bot->EnterVehicle(vehicleBase);
|
bot->EnterVehicle(vehicleBase);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user