Merge branch 'master' of https://github.com/TrinityCore/TrinityCore
This commit is contained in:
@@ -12148,6 +12148,26 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
|| target->GetReactionTo(this) > REP_NEUTRAL)
|
||||
return false;
|
||||
|
||||
// Not all neutral creatures can be attacked
|
||||
if (GetReactionTo(target) == REP_NEUTRAL &&
|
||||
target->GetReactionTo(this) == REP_NEUTRAL)
|
||||
{
|
||||
if (
|
||||
!(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) &&
|
||||
!(target->GetTypeId() == TYPEID_UNIT && GetTypeId() == TYPEID_UNIT)
|
||||
)
|
||||
{
|
||||
Player const* player = target->GetTypeId() == TYPEID_PLAYER ? target->ToPlayer() : ToPlayer();
|
||||
Unit const* creature = target->GetTypeId() == TYPEID_UNIT ? target : this;
|
||||
|
||||
if (FactionTemplateEntry const* factionTemplate = creature->getFactionTemplateEntry())
|
||||
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction))
|
||||
if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
|
||||
if (repState->Flags & FACTION_FLAG_PEACE_FORCED)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Creature const* creatureAttacker = ToCreature();
|
||||
if (creatureAttacker && creatureAttacker->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK26)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user