fix(Core/Unit): fix AoE aggro and contested guard attack logic (#23935)
This commit is contained in:
@@ -14085,7 +14085,22 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
|||||||
|
|
||||||
if (repThisToTarget > REP_NEUTRAL
|
if (repThisToTarget > REP_NEUTRAL
|
||||||
|| (repTargetToThis = target->GetReactionTo(this)) > REP_NEUTRAL)
|
|| (repTargetToThis = target->GetReactionTo(this)) > REP_NEUTRAL)
|
||||||
return false;
|
{
|
||||||
|
// contested guards can attack contested PvP players even though players may be friendly
|
||||||
|
if (!target->IsControlledByPlayer())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool isContestedGuard = false;
|
||||||
|
if (FactionTemplateEntry const* entry = GetFactionTemplateEntry())
|
||||||
|
isContestedGuard = entry->factionFlags & FACTION_TEMPLATE_FLAG_ATTACK_PVP_ACTIVE_PLAYERS;
|
||||||
|
|
||||||
|
bool isContestedPvp = false;
|
||||||
|
if (Player const* player = target->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||||
|
isContestedPvp = player->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP);
|
||||||
|
|
||||||
|
if (!isContestedGuard && !isContestedPvp)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
|
// Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
|
||||||
if (repThisToTarget == REP_NEUTRAL &&
|
if (repThisToTarget == REP_NEUTRAL &&
|
||||||
|
|||||||
@@ -5283,14 +5283,6 @@ void SpellMgr::LoadSpellInfoCorrections()
|
|||||||
factionTemplateEntry = const_cast<FactionTemplateEntry*>(sFactionTemplateStore.LookupEntry(1921)); // The Taunka
|
factionTemplateEntry = const_cast<FactionTemplateEntry*>(sFactionTemplateStore.LookupEntry(1921)); // The Taunka
|
||||||
factionTemplateEntry->hostileMask |= 8;
|
factionTemplateEntry->hostileMask |= 8;
|
||||||
|
|
||||||
// Remove 1 from guards friendly mask, making able to attack players
|
|
||||||
factionTemplateEntry = const_cast<FactionTemplateEntry*>(sFactionTemplateStore.LookupEntry(1857)); // Area 52 Bruiser
|
|
||||||
factionTemplateEntry->friendlyMask &= ~1;
|
|
||||||
factionTemplateEntry = const_cast<FactionTemplateEntry*>(sFactionTemplateStore.LookupEntry(1806)); // Netherstorm Agent
|
|
||||||
factionTemplateEntry->friendlyMask &= ~1;
|
|
||||||
factionTemplateEntry = const_cast<FactionTemplateEntry*>(sFactionTemplateStore.LookupEntry(1812)); // K3 Bruiser
|
|
||||||
factionTemplateEntry->friendlyMask &= ~1;
|
|
||||||
|
|
||||||
// Remove vehicles attr, making accessories selectable
|
// Remove vehicles attr, making accessories selectable
|
||||||
VehicleSeatEntry* vse = const_cast<VehicleSeatEntry*>(sVehicleSeatStore.LookupEntry(4689)); // Siege Engine, Accessory
|
VehicleSeatEntry* vse = const_cast<VehicleSeatEntry*>(sVehicleSeatStore.LookupEntry(4689)); // Siege Engine, Accessory
|
||||||
vse->m_flags &= ~VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE;
|
vse->m_flags &= ~VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE;
|
||||||
|
|||||||
@@ -563,10 +563,6 @@ public:
|
|||||||
if (!SpawnAssoc)
|
if (!SpawnAssoc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// check if they're hostile
|
|
||||||
if (!(me->IsHostileTo(who) || who->IsHostileTo(me)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (me->IsValidAttackTarget(who))
|
if (me->IsValidAttackTarget(who))
|
||||||
{
|
{
|
||||||
Player* playerTarget = who->ToPlayer();
|
Player* playerTarget = who->ToPlayer();
|
||||||
|
|||||||
Reference in New Issue
Block a user