diff options
Diffstat (limited to 'src/game/Creature.cpp')
-rw-r--r-- | src/game/Creature.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 17828752aac..007e224b1e7 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -111,8 +111,7 @@ uint32 CreatureInfo::GetFirstValidModelId() const bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Unit* victim = Unit::GetUnit(m_owner, m_victim); - if (victim) + if(Unit* victim = Unit::GetUnit(m_owner, m_victim)) { while (!m_assistants.empty()) { @@ -2003,30 +2002,38 @@ void Creature::CallAssistance(float radius) } } -bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const +bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const { // is it true? if(!HasReactState(REACT_AGGRESSIVE)) return false; // we don't need help from zombies :) - if( !isAlive() ) + if (!isAlive()) return false; // skip fighting creature - if( isInCombat() ) - return false; - - // only from same creature faction - if(getFaction() != u->getFaction() ) + if (isInCombat()) return false; // only free creature - if( GetCharmerOrOwnerGUID() ) + if (GetCharmerOrOwnerGUID()) return false; + // only from same creature faction + if (checkfaction) + { + if (getFaction() != u->getFaction()) + return false; + } + else + { + if (!IsFriendlyTo(u)) + return false; + } + // skip non hostile to caster enemy creatures - if( !IsHostileTo(enemy) ) + if (!IsHostileTo(enemy)) return false; return true; |