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 | |
| parent | 03234a0657eca4836b1015556973629893c76958 (diff) | |
*AI structure update.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/AggressorAI.cpp | 46 | ||||
| -rw-r--r-- | src/game/AggressorAI.h | 3 | ||||
| -rw-r--r-- | src/game/Creature.h | 2 | ||||
| -rw-r--r-- | src/game/CreatureAI.cpp | 37 | ||||
| -rw-r--r-- | src/game/CreatureAI.h | 32 | ||||
| -rw-r--r-- | src/game/GuardAI.cpp | 18 | ||||
| -rw-r--r-- | src/game/GuardAI.h | 1 | ||||
| -rw-r--r-- | src/game/NullCreatureAI.h | 3 | ||||
| -rw-r--r-- | src/game/OutdoorPvPObjectiveAI.cpp | 29 | ||||
| -rw-r--r-- | src/game/OutdoorPvPObjectiveAI.h | 12 | ||||
| -rw-r--r-- | src/game/PetAI.cpp | 14 | ||||
| -rw-r--r-- | src/game/PetAI.h | 1 | ||||
| -rw-r--r-- | src/game/PossessedAI.cpp | 6 | ||||
| -rw-r--r-- | src/game/PossessedAI.h | 3 | ||||
| -rw-r--r-- | src/game/ReactorAI.cpp | 18 | ||||
| -rw-r--r-- | src/game/ReactorAI.h | 3 | ||||
| -rw-r--r-- | src/game/TotemAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 27 | ||||
| -rw-r--r-- | src/game/Unit.h | 1 |
19 files changed, 69 insertions, 189 deletions
diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index a11584eab64..65dd1849217 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -38,29 +38,10 @@ AggressorAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -AggressorAI::AggressorAI(Creature *c) : i_creature(*c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_creature(*c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) { } -void -AggressorAI::MoveInLineOfSight(Unit *u) -{ - if(!i_creature.getVictim() && i_creature.canStartAttack(u)) - AttackStart(u); - - /* - if(!i_creature.getVictim()) - { - AttackStart(u); - } - else if(sMapStore.LookupEntry(i_creature.GetMapId())->IsDungeon()) - { - u->SetInCombatWith(&i_creature); - i_creature.AddThreat(u, 0.0f); - } - */ -} - void AggressorAI::EnterEvadeMode() { if( !i_creature.isAlive() ) @@ -118,7 +99,7 @@ void AggressorAI::UpdateAI(const uint32 /*diff*/) { // update i_victimGuid if i_creature.getVictim() !=0 and changed - if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) + if(!UpdateVictim()) return; i_victimGuid = i_creature.getVictim()->GetGUID(); @@ -132,26 +113,3 @@ AggressorAI::UpdateAI(const uint32 /*diff*/) } } } - -bool -AggressorAI::IsVisible(Unit *pl) const -{ - return i_creature.GetDistance(pl) < sWorld.getConfig(CONFIG_SIGHT_MONSTER) - && pl->isVisibleForOrDetect(&i_creature,true); -} - -void -AggressorAI::AttackStart(Unit *u) -{ - if( !u ) - return; - - if(i_creature.Attack(u,true)) - { - i_creature.AddThreat(u, 0.0f); - // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); - i_victimGuid = u->GetGUID(); - - i_creature.GetMotionMaster()->MoveChase(u); - } -} diff --git a/src/game/AggressorAI.h b/src/game/AggressorAI.h index f6e2a649c8a..e50a4c0ece3 100644 --- a/src/game/AggressorAI.h +++ b/src/game/AggressorAI.h @@ -38,10 +38,7 @@ class TRINITY_DLL_DECL AggressorAI : public CreatureAI AggressorAI(Creature *c); - void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); void EnterEvadeMode(); - bool IsVisible(Unit *) const; void UpdateAI(const uint32); static int Permissible(const Creature *); diff --git a/src/game/Creature.h b/src/game/Creature.h index f51f5f6be47..14fc77cf24a 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -632,7 +632,7 @@ class TRINITY_DLL_SPEC Creature : public Unit bool IsFormationLeader() {return (GetDBTableGUIDLow() && GetDBTableGUIDLow() == m_formationID);} uint32 GetFormationID(){return m_formationID;} - Unit *SelectHostilTarget(); + Unit *SelectVictim(); protected: bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 66c9d5af0b0..8682bf064a5 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -20,17 +20,39 @@ #include "CreatureAI.h" #include "Creature.h" +#include "Player.h" #include "Pet.h" #include "SpellAuras.h" -CreatureAI::~CreatureAI() +void UnitAI::AttackStart(Unit *victim) { + if(!victim) + return; + + if(me->Attack(victim, true)) + { + //DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", me->GetName(), victim->GetGUIDLow()); + me->GetMotionMaster()->MoveChase(victim); + } } -void CreatureAI::EnterEvadeMode() +void CreatureAI::MoveInLineOfSight(Unit *who) { - if(!me) return; + if(!me->getVictim() && me->canStartAttack(who)) + AttackStart(who); +} +bool CreatureAI::UpdateVictim() +{ + if(!me->isInCombat()) + return false; + if(Unit *victim = me->SelectVictim()) + AttackStart(victim); + return me->getVictim(); +} + +void CreatureAI::EnterEvadeMode() +{ me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(); @@ -62,12 +84,5 @@ void SimpleCharmedAI::UpdateAI(const uint32 /*diff*/) Unit *target = me->getVictim(); if(!target || !charmer->canAttack(target)) - { - target = charmer->SelectNearestTarget(); - if(!target) - return; - - me->GetMotionMaster()->MoveChase(target); - me->Attack(target, true); - } + AttackStart(charmer->SelectNearestTarget()); } diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 72e911cceaf..5a8126f24d4 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -29,6 +29,7 @@ class Unit; class Creature; +class Player; struct SpellEntry; #define TIME_INTERVAL_LOOK 5000 @@ -71,34 +72,41 @@ enum SelectAggroTarget class TRINITY_DLL_SPEC UnitAI { + protected: + Unit *me; public: UnitAI(Unit *u) : me(u) {} + virtual void AttackStart(Unit *); virtual void UpdateAI(const uint32 diff) = 0; +}; + +class TRINITY_DLL_SPEC PlayerAI : public UnitAI +{ protected: - Unit *me; + Player *me; + public: + PlayerAI(Player *p) : UnitAI((Unit*)p), me(p) {} }; -class TRINITY_DLL_SPEC SimpleCharmedAI : public UnitAI +class TRINITY_DLL_SPEC SimpleCharmedAI : public PlayerAI { public: - virtual void UpdateAI(const uint32 diff); + void UpdateAI(const uint32 diff); }; class TRINITY_DLL_SPEC CreatureAI : public UnitAI { protected: Creature *me; + + bool UpdateVictim(); public: - CreatureAI() : UnitAI(NULL), me(NULL) {} CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c) {} - virtual ~CreatureAI(); + virtual ~CreatureAI() {} // Called if IsVisible(Unit *who) is true at each *who move - virtual void MoveInLineOfSight(Unit *) = 0; - - // Called at each attack of m_creature by any victim - virtual void AttackStart(Unit *) = 0; + virtual void MoveInLineOfSight(Unit *); // Called at stopping attack by any attacker virtual void EnterEvadeMode(); @@ -106,12 +114,6 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI // Called at any Damage from any attacker (before damage apply) virtual void DamageTaken(Unit *done_by, uint32 & /*damage*/) {} - // Is unit visible for MoveInLineOfSight - virtual bool IsVisible(Unit *) const = 0; - - // Called at World update tick - virtual void UpdateAI(const uint32 diff ) = 0; - // Called when the creature is killed virtual void JustDied(Unit *) {} diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 273fa32272b..d3c3d9a7330 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -33,7 +33,7 @@ int GuardAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -GuardAI::GuardAI(Creature *c) : i_creature(*c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +GuardAI::GuardAI(Creature *c) : CreatureAI(c), i_creature(*c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) { } @@ -110,7 +110,7 @@ void GuardAI::EnterEvadeMode() void GuardAI::UpdateAI(const uint32 /*diff*/) { // update i_victimGuid if i_creature.getVictim() !=0 and changed - if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) + if(!UpdateVictim()) return; i_victimGuid = i_creature.getVictim()->GetGUID(); @@ -131,20 +131,6 @@ bool GuardAI::IsVisible(Unit *pl) const && pl->isVisibleForOrDetect(&i_creature,true); } -void GuardAI::AttackStart(Unit *u) -{ - if( !u ) - return; - - // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); - if(i_creature.Attack(u,true)) - { - i_creature.AddThreat(u, 0.0f); - i_victimGuid = u->GetGUID(); - i_creature.GetMotionMaster()->MoveChase(u); - } -} - void GuardAI::JustDied(Unit *killer) { if(Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) diff --git a/src/game/GuardAI.h b/src/game/GuardAI.h index 16e0c6e8bd6..30f76dd509a 100644 --- a/src/game/GuardAI.h +++ b/src/game/GuardAI.h @@ -39,7 +39,6 @@ class TRINITY_DLL_DECL GuardAI : public CreatureAI GuardAI(Creature *c); void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); void EnterEvadeMode(); void JustDied(Unit *); bool IsVisible(Unit *) const; diff --git a/src/game/NullCreatureAI.h b/src/game/NullCreatureAI.h index 821b42f7e76..a9814c9c5e0 100644 --- a/src/game/NullCreatureAI.h +++ b/src/game/NullCreatureAI.h @@ -32,8 +32,6 @@ class TRINITY_DLL_DECL PassiveAI : public CreatureAI void MoveInLineOfSight(Unit *) {} void AttackStart(Unit *) {} - bool IsVisible(Unit *) const { return false; } - void UpdateAI(const uint32); static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } }; @@ -43,6 +41,7 @@ class TRINITY_DLL_DECL NullCreatureAI : public PassiveAI public: NullCreatureAI(Creature *c) : PassiveAI(c) {} + void UpdateAI(const uint32) {} void EnterEvadeMode() {} }; diff --git a/src/game/OutdoorPvPObjectiveAI.cpp b/src/game/OutdoorPvPObjectiveAI.cpp index a99afbfbe5a..aa7778ef105 100644 --- a/src/game/OutdoorPvPObjectiveAI.cpp +++ b/src/game/OutdoorPvPObjectiveAI.cpp @@ -25,18 +25,18 @@ #define MAX_OUTDOOR_PVP_DISTANCE 200 // the max value in capture point type go data0 is 100 currently, so use twice that much to handle leaving as well -OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature *c) : i_creature(*c) +OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature *c) : NullCreatureAI(c) { - sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", i_creature.GetGUIDLow()); - i_creature.SetReactState(REACT_AGGRESSIVE); + sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", me->GetGUIDLow()); + me->SetReactState(REACT_AGGRESSIVE); } void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u) { // IsVisible only passes for players in range, so no need to check again // leaving/entering distance will be checked based on go range data - if((u->GetTypeId() == TYPEID_PLAYER) && i_creature.IsWithinDistInMap(u, MAX_OUTDOOR_PVP_DISTANCE)) - sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature); + if((u->GetTypeId() == TYPEID_PLAYER) && me->IsWithinDistInMap(u, MAX_OUTDOOR_PVP_DISTANCE)) + sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u), me); } int OutdoorPvPObjectiveAI::Permissible(const Creature * c) @@ -45,22 +45,3 @@ int OutdoorPvPObjectiveAI::Permissible(const Creature * c) return PERMIT_BASE_NO; } -bool OutdoorPvPObjectiveAI::IsVisible(Unit *pl) const -{ - return (pl->GetTypeId() == TYPEID_PLAYER) && (i_creature.GetDistance(pl) < MAX_OUTDOOR_PVP_DISTANCE); -} - -void OutdoorPvPObjectiveAI::AttackStart(Unit *) -{ - //EnterEvadeMode(); -} - -void OutdoorPvPObjectiveAI::EnterEvadeMode() -{ -// i_creature.DeleteThreatList(); -// i_creature.CombatStop(); -} - -void OutdoorPvPObjectiveAI::UpdateAI(const uint32 diff) -{ -} diff --git a/src/game/OutdoorPvPObjectiveAI.h b/src/game/OutdoorPvPObjectiveAI.h index 2da9086dbd3..c8e4844cd5a 100644 --- a/src/game/OutdoorPvPObjectiveAI.h +++ b/src/game/OutdoorPvPObjectiveAI.h @@ -19,25 +19,17 @@ #ifndef TRINITY_OUTDOORPVPOBJECTIVEAI_H #define TRINITY_OUTDOORPVPOBJECTIVEAI_H -#include "CreatureAI.h" +#include "NullCreatureAI.h" class Creature; -class TRINITY_DLL_DECL OutdoorPvPObjectiveAI : public CreatureAI +class TRINITY_DLL_DECL OutdoorPvPObjectiveAI : public NullCreatureAI { public: - OutdoorPvPObjectiveAI(Creature *c); void MoveInLineOfSight(Unit *); - bool IsVisible(Unit *) const; - void AttackStart(Unit *); - void EnterEvadeMode(); - void UpdateAI(const uint32 diff); static int Permissible(const Creature *); - - private: - Creature &i_creature; }; #endif diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index bce8a4d8f59..67607defba0 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -38,7 +38,7 @@ int PetAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -PetAI::PetAI(Creature *c) : i_pet(*c), i_tracker(TIME_INTERVAL_LOOK), inCombat(false) +PetAI::PetAI(Creature *c) : CreatureAI(c), i_pet(*c), i_tracker(TIME_INTERVAL_LOOK), inCombat(false) { m_AllySet.clear(); UpdateAllies(); @@ -87,11 +87,6 @@ void PetAI::EnterEvadeMode() { } -bool PetAI::IsVisible(Unit *pl) const -{ - return _isVisible(pl); -} - bool PetAI::_needToStop() const { // This is needed for charmed creatures, as once their target was reset other effects can trigger threat @@ -291,13 +286,6 @@ void PetAI::UpdateAI(const uint32 diff) } } -bool PetAI::_isVisible(Unit *u) const -{ - //return false; //( ((Creature*)&i_pet)->GetDistanceSq(u) * 1.0<= sWorld.getConfig(CONFIG_SIGHT_GUARDER) && !u->m_stealth && u->isAlive()); - return i_pet.GetDistance(u) < sWorld.getConfig(CONFIG_SIGHT_GUARDER) - && u->isVisibleForOrDetect(&i_pet,true); -} - void PetAI::UpdateAllies() { Unit* owner = i_pet.GetCharmerOrOwner(); diff --git a/src/game/PetAI.h b/src/game/PetAI.h index 8583404b669..b81bdd8e14f 100644 --- a/src/game/PetAI.h +++ b/src/game/PetAI.h @@ -36,7 +36,6 @@ class TRINITY_DLL_DECL PetAI : public CreatureAI void MoveInLineOfSight(Unit *); void AttackStart(Unit *); void EnterEvadeMode(); - bool IsVisible(Unit *) const; void JustDied(Unit* who) { _stopAttack(); } void UpdateAI(const uint32); diff --git a/src/game/PossessedAI.cpp b/src/game/PossessedAI.cpp index 4292a2bd22b..f291221216a 100644 --- a/src/game/PossessedAI.cpp +++ b/src/game/PossessedAI.cpp @@ -107,12 +107,6 @@ void PossessedAI::UpdateAI(const uint32 diff) } } -bool PossessedAI::_isVisible(Unit *u) const -{ - return i_pet.GetDistance(u) < sWorld.getConfig(CONFIG_SIGHT_MONSTER) - && u->isVisibleForOrDetect(&i_pet,true); -} - void PossessedAI::JustDied(Unit *u) { // We died while possessed, disable our loot diff --git a/src/game/PossessedAI.h b/src/game/PossessedAI.h index 16c3172b6bf..5c4a670c200 100644 --- a/src/game/PossessedAI.h +++ b/src/game/PossessedAI.h @@ -28,7 +28,7 @@ class Creature; class TRINITY_DLL_DECL PossessedAI : public CreatureAI { public: - PossessedAI(Creature *c) : i_pet(*c), i_victimGuid(0) {} + PossessedAI(Creature *c) : CreatureAI(c), i_pet(*c), i_victimGuid(0) {} // Possessed creatures shouldn't aggro by themselves void MoveInLineOfSight(Unit *) {} @@ -36,7 +36,6 @@ class TRINITY_DLL_DECL PossessedAI : public CreatureAI void EnterEvadeMode() {} void JustDied(Unit*); void KilledUnit(Unit* victim); - bool IsVisible(Unit * u) const { return _isVisible(u); } void UpdateAI(const uint32); // Never permit this to be used, it must always be initialized with Creature::InitPossessedAI() diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index 7ade73495c3..29b07f60b00 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -41,22 +41,6 @@ ReactorAI::MoveInLineOfSight(Unit *) { } -void -ReactorAI::AttackStart(Unit *p) -{ - if(!p) - return; - - if(i_creature.Attack(p,true)) - { - DEBUG_LOG("Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId()); - - i_creature.AddThreat(p, 0.0f); - i_victimGuid = p->GetGUID(); - i_creature.GetMotionMaster()->MoveChase(p); - } -} - bool ReactorAI::IsVisible(Unit *) const { @@ -67,7 +51,7 @@ void ReactorAI::UpdateAI(const uint32 /*time_diff*/) { // update i_victimGuid if i_creature.getVictim() !=0 and changed - if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) + if(!UpdateVictim()) return; i_victimGuid = i_creature.getVictim()->GetGUID(); diff --git a/src/game/ReactorAI.h b/src/game/ReactorAI.h index b2bfa3501c2..cea1e8dcdb5 100644 --- a/src/game/ReactorAI.h +++ b/src/game/ReactorAI.h @@ -29,10 +29,9 @@ class TRINITY_DLL_DECL ReactorAI : public CreatureAI { public: - ReactorAI(Creature *c) : i_creature(*c), i_victimGuid(0) {} + ReactorAI(Creature *c) : CreatureAI(c), i_creature(*c), i_victimGuid(0) {} void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); void EnterEvadeMode(); bool IsVisible(Unit *) const; diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 72a43cfc97b..4d7b45eba8e 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -40,7 +40,7 @@ TotemAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature *c) : i_totem(static_cast<Totem&>(*c)), i_victimGuid(0) +TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_totem(static_cast<Totem&>(*c)), i_victimGuid(0) { } 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) diff --git a/src/game/Unit.h b/src/game/Unit.h index 83cb1900506..69c10400a4c 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1238,7 +1238,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL); float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL); void DeleteThreatList(); - //bool SelectHostilTarget(); void TauntApply(Unit* pVictim); void TauntFadeOut(Unit *taunter); ThreatManager& getThreatManager() { return m_ThreatManager; } |
