aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManuel Carrasco <manue.l@live.com.ar>2012-02-14 17:51:28 -0300
committerManuel Carrasco <manue.l@live.com.ar>2012-02-14 17:51:28 -0300
commit60adf066d90b9bc9696bce8f750f9abc79a61f8e (patch)
tree889742c5f965e23cd498602e96c8d0600c234d1f /src
parent7d30b061f0bb4b7227b16c9fd97ddd5483d2357a (diff)
Core/Unit: Solved issues with neutral creatures that were being attacked when they should not be.
Thanks to Subv for the tweaks!
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 29484f2695a..04eab0b7d56 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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;