diff options
author | megamage <none@none> | 2009-01-30 18:10:05 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-01-30 18:10:05 -0600 |
commit | 8fee06f041fbfbc7e22eccc03a8f12bd7a649999 (patch) | |
tree | 9512260148dabb87926131a225831e72980a250d /src/game/Unit.cpp | |
parent | 03234a0657eca4836b1015556973629893c76958 (diff) |
*AI structure update.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index a2b4aba30fd..ec8daf1482c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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) |