*AI structure update.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-30 18:10:05 -06:00
parent 03234a0657
commit 8fee06f041
266 changed files with 460 additions and 598 deletions
+8 -19
View File
@@ -8208,6 +8208,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
SetInCombatWith(victim);
if(victim->GetTypeId() == TYPEID_PLAYER)
victim->SetInCombatWith(this);
AddThreat(victim, 0.0f);
}
// delay offhand weapon attack to next attack time
@@ -10408,7 +10409,7 @@ void Unit::TauntFadeOut(Unit *taunter)
//======================================================================
Unit* Creature::SelectHostilTarget()
Unit* Creature::SelectVictim()
{
//function provides main threat functionality
//next-victim-selection algorithm and evade mode are called
@@ -10420,10 +10421,6 @@ Unit* Creature::SelectHostilTarget()
Unit* target = NULL;
//This function only useful once AI has been initialized
if (!AI())
return NULL;
if(!m_ThreatManager.isThreatListEmpty())
{
if(!HasAuraType(SPELL_AURA_MOD_TAUNT))
@@ -10438,18 +10435,15 @@ Unit* Creature::SelectHostilTarget()
{
if(!hasUnitState(UNIT_STAT_STUNNED))
SetInFront(target);
AI()->AttackStart(target);
return getVictim();
return target;
}
// no target but something prevent go to evade mode
if( !isInCombat() /*|| HasAuraType(SPELL_AURA_MOD_TAUNT)*/ )
return NULL;
// last case when creature don't must go to evade mode:
// it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list
// for example at owner command to pet attack some far away creature
// Note: creature not have targeted movement generator but have attacker in this case
if(m_attackers.size())
return NULL;
/*if( GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE )
{
for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr)
@@ -10462,14 +10456,9 @@ Unit* Creature::SelectHostilTarget()
// search nearby enemy before enter evade mode
if(HasReactState(REACT_AGGRESSIVE))
{
if(target = SelectNearestTarget())
{
if(!IsOutOfThreatArea(target))
{
AI()->AttackStart(target);
return getVictim();
}
}
target = SelectNearestTarget();
if(target && !IsOutOfThreatArea(target))
return target;
}
if(m_invisibilityMask)