diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 440b1335d..8def022a8 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -101,9 +101,9 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin()); m_assistants.pop_front(); - if (assistant) + if (assistant && assistant->CanAssistTo(&m_owner, victim)) { - assistant->SetNoCallAssistence(true); + assistant->SetNoCallAssistance(true); if(assistant->AI()) assistant->AI()->AttackStart(victim); } @@ -119,7 +119,7 @@ m_lootMoney(0), m_lootRecipient(0), m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), -m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), +m_AlreadyCallAssistance(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0) { m_valuesCount = UNIT_END; @@ -1684,11 +1684,11 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const return false; } -void Creature::CallAssistence() +void Creature::CallAssistance() { - if( !m_AlreadyCallAssistence && getVictim() && !isPet() && !isCharmed()) + if( !m_AlreadyCallAssistance && getVictim() && !isPet() && !isCharmed()) { - SetNoCallAssistence(true); + SetNoCallAssistance(true); float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS); if(radius > 0) @@ -1725,6 +1725,31 @@ void Creature::CallAssistence() } } +bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const +{ + // we don't need help from zombies :) + if( !isAlive() ) + return false; + + // skip fighting creature + if( isInCombat() ) + return false; + + // only from same creature faction + if(getFaction() != u->getFaction() ) + return false; + + // only free creature + if( GetCharmerOrOwnerGUID() ) + return false; + + // skip non hostile to caster enemy creatures + if( !IsHostileTo(enemy) ) + return false; + + return true; +} + void Creature::SaveRespawnTime() { if(isPet() || !m_DBTableGuid) diff --git a/src/game/Creature.h b/src/game/Creature.h index 03f317d81..98f54017e 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -547,8 +547,9 @@ class MANGOS_DLL_SPEC Creature : public Unit float GetAttackDistance(Unit const* pl) const; - void CallAssistence(); - void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } + void CallAssistance(); + void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; } + bool CanAssistTo(const Unit* u, const Unit* enemy) const; MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } @@ -633,7 +634,7 @@ class MANGOS_DLL_SPEC Creature : public Unit uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid uint32 m_equipmentId; - bool m_AlreadyCallAssistence; + bool m_AlreadyCallAssistance; bool m_regenHealth; bool m_AI_locked; bool m_isDeadByDefault; diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 862f434fb..bea2ad269 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -721,32 +721,15 @@ namespace MaNGOS if(u == i_funit) return false; - // we don't need help from zombies :) - if( !u->isAlive() ) - return false; - - // skip fighting creature - if( u->isInCombat() ) - return false; - - // only from same creature faction - if(u->getFaction() != i_funit->getFaction() ) - return false; - - // only free creature - if( u->GetCharmerOrOwnerGUID() ) + if ( !u->CanAssistTo(i_funit, i_enemy) ) return false; // too far if( !i_funit->IsWithinDistInMap(u, i_range) ) return false; - // skip non hostile to caster enemy creatures - if( !u->IsHostileTo(i_enemy) ) - return false; - // only if see assisted creature - if(!u->IsWithinLOSInMap(i_funit) ) + if( !i_funit->IsWithinLOSInMap(u) ) return false; return true; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index e81534c66..d1259d089 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -6908,7 +6908,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) data << uint32(AI_REACTION_AGGRO); // Aggro sound ((WorldObject*)this)->SendMessageToSet(&data, true); - ((Creature*)this)->CallAssistence(); + ((Creature*)this)->CallAssistance(); ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); } @@ -6942,7 +6942,7 @@ bool Unit::AttackStop() if( GetTypeId()==TYPEID_UNIT ) { // reset call assistance - ((Creature*)this)->SetNoCallAssistence(false); + ((Creature*)this)->SetNoCallAssistance(false); } SendAttackStop(victim); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b826c3e6f..bae4de095 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6845" + #define REVISION_NR "6846" #endif // __REVISION_NR_H__