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:
@@ -16393,9 +16393,21 @@ void Unit::SetContestedPvP(Player* attackedPlayer)
|
|||||||
{
|
{
|
||||||
Player* player = GetCharmerOrOwnerPlayerOrPlayerItself();
|
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;
|
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);
|
player->SetContestedPvPTimer(30000);
|
||||||
if (!player->HasUnitState(UNIT_STATE_ATTACK_PLAYER))
|
if (!player->HasUnitState(UNIT_STATE_ATTACK_PLAYER))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1114,6 +1114,30 @@ namespace Acore
|
|||||||
NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&);
|
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
|
class AnyAssistCreatureInRangeCheck
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user