*Do not let target get in combat until hit by attacker.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-16 19:34:49 -06:00
parent ba4338783a
commit 0f150881a1
5 changed files with 14 additions and 20 deletions
@@ -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)
{
@@ -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)
{
+3 -1
View File
@@ -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()
-1
View File
@@ -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
+11 -14
View File
@@ -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)