summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjestermaniac <88903576+jestermaniac@users.noreply.github.com>2021-10-14 13:21:18 +0200
committerGitHub <noreply@github.com>2021-10-14 13:21:18 +0200
commitda69fec3453dcc1063b5338d2060417f54eb884f (patch)
tree1bafbfa8f3d530a5fe5f2e225c303939d0b2338c /src
parent37d621333f7ab33a18fefd999c50488f62c547f6 (diff)
fix(Core/Entities): contested guards attacking after bg/recent pvp (#7518)
* fix(Core/Entities): contested guards attacking after bg/recent pvp * fix(Core/Entities): contested guards attacking after bg/recent pvp * Update Unit.cpp * fix(Core/Entities): contested guards attacking after bg/recent pvp * fix(Core/Entities): contested guards attacking after bg/recent pvp * Update Unit.cpp
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp14
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.h24
2 files changed, 37 insertions, 1 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index f0bd0ba2fc..79859ab388 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -16393,9 +16393,21 @@ void Unit::SetContestedPvP(Player* attackedPlayer)
{
Player* player = GetCharmerOrOwnerPlayerOrPlayerItself();
- if (!player || (attackedPlayer && (attackedPlayer == player || (player->duel && player->duel->opponent == attackedPlayer))))
+ if (!player || ((attackedPlayer && (attackedPlayer == player || (player->duel && player->duel->opponent == attackedPlayer))) || player->InBattleground()))
return;
+ // check if there any guards that should care about the contested flag on player
+ std::list<Unit*> targets;
+ Acore::NearestVisibleDetectableContestedGuardUnitCheck u_check(this);
+ Acore::UnitListSearcher<Acore::NearestVisibleDetectableContestedGuardUnitCheck> searcher(this, targets, u_check);
+ Cell::VisitAllObjects(this, searcher, MAX_AGGRO_RADIUS);
+
+ // return if there are no contested guards found
+ if (!targets.size())
+ {
+ return;
+ }
+
player->SetContestedPvPTimer(30000);
if (!player->HasUnitState(UNIT_STATE_ATTACK_PLAYER))
{
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 44cdee243b..ebb584d902 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -1114,6 +1114,30 @@ namespace Acore
NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&);
};
+ class NearestVisibleDetectableContestedGuardUnitCheck
+ {
+ public:
+ explicit NearestVisibleDetectableContestedGuardUnitCheck(Unit const* unit) : me(unit) {}
+ bool operator()(Unit* u)
+ {
+ if (!u->CanSeeOrDetect(me, true, true, false))
+ {
+ return false;
+ }
+
+ if (!u->IsContestedGuard())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ private:
+ Unit const* me;
+ NearestVisibleDetectableContestedGuardUnitCheck(NearestVisibleDetectableContestedGuardUnitCheck const&);
+ };
+
class AnyAssistCreatureInRangeCheck
{
public: