diff options
-rw-r--r-- | src/bindings/scripts/include/sc_creature.cpp | 3 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/creature/mob_event_ai.cpp | 1 | ||||
-rw-r--r-- | src/game/CreatureGroups.h | 4 | ||||
-rw-r--r-- | src/game/PetAI.cpp | 1 | ||||
-rw-r--r-- | src/game/Unit.cpp | 25 |
5 files changed, 14 insertions, 20 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index 12992eedc52..0caa102d56d 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -86,7 +86,6 @@ void ScriptedAI::AttackStart(Unit* who, bool melee) { m_creature->AddThreat(who, 0.0f); m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { @@ -110,7 +109,6 @@ void ScriptedAI::AttackStart(Unit* who) { m_creature->AddThreat(who, 0.0f); m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { @@ -823,7 +821,6 @@ void Scripted_NoMovementAI::AttackStart(Unit* who) { m_creature->AddThreat(who, 0.0f); m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 456a88ab3bb..eee4269e12c 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -1152,7 +1152,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI //Begin melee attack if we are within range m_creature->AddThreat(who, 0.0f); m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { diff --git a/src/game/CreatureGroups.h b/src/game/CreatureGroups.h index 0f4474106de..dd7da865955 100644 --- a/src/game/CreatureGroups.h +++ b/src/game/CreatureGroups.h @@ -58,7 +58,9 @@ class CreatureGroup bool isEmpty() {return CreatureGroupMembers.empty();} }; -extern UNORDERED_MAP<uint32, CreatureGroup*> CreatureGroupHolder; +typedef UNORDERED_MAP<uint32, CreatureGroup*> CreatureGroupHolderType; + +extern CreatureGroupHolderType CreatureGroupHolder; extern UNORDERED_MAP<uint32, FormationMember*> CreatureGroupMap; #define formation_mgr Trinity::Singleton<CreatureGroupManager>::Instance() diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 82259cbba4d..abb62ade7da 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -74,7 +74,6 @@ void PetAI::AttackStart(Unit *u) if(i_pet.Attack(u,true)) { i_pet.SetInCombatWith(u); - u->SetInCombatWith(&i_pet); i_pet.clearUnitState(UNIT_STAT_FOLLOW); // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 900c7526fad..734182fa4cf 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9697,23 +9697,12 @@ void Unit::CombatStart(Unit* target) if(!target->IsStandState()/* && !target->hasUnitState(UNIT_STAT_STUNNED)*/) target->SetStandState(PLAYER_STATE_NONE); - //Call creature group update - if(GetTypeId()==TYPEID_UNIT && ((Creature *)this)->GetFormationID() && - CreatureGroupHolder.find(((Creature *)this)->GetFormationID()) != CreatureGroupHolder.end()) - CreatureGroupHolder[((Creature *)this)->GetFormationID()]->MemberHasAttacked(((Creature *)this)); - if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->AI()) - { - SetInCombatWith(target); - target->SetInCombatWith(this); ((Creature*)target)->AI()->AttackStart(this); - } - else - { - SetInCombatWith(target); - target->SetInCombatWith(this); - } + + SetInCombatWith(target); + target->SetInCombatWith(this); Unit *who = target->GetCharmerOrOwnerOrSelf(); if(who->GetTypeId() == TYPEID_PLAYER) @@ -9727,6 +9716,14 @@ void Unit::CombatStart(Unit* target) me->UpdatePvP(true); me->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); } + + //Call creature group update + if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->GetFormationID()) + { + CreatureGroupHolderType::iterator itr = CreatureGroupHolder.find(((Creature*)this)->GetFormationID()); + if(itr != CreatureGroupHolder.end()) + itr->second->MemberHasAttacked(((Creature*)this)); + } } void Unit::SetInCombatState(bool PvP) |