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
This commit is contained in:
jestermaniac
2021-10-14 13:21:18 +02:00
committed by GitHub
parent 37d621333f
commit da69fec345
2 changed files with 37 additions and 1 deletions

View File

@@ -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))
{

View File

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