diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Creature.h | 13 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 39 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 1 | ||||
-rw-r--r-- | src/game/ScriptedCreature.cpp | 3 |
4 files changed, 7 insertions, 49 deletions
diff --git a/src/game/Creature.h b/src/game/Creature.h index 1d0a2fd560f..e0f66eb1963 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -296,19 +296,6 @@ enum ChatType CHAT_TYPE_ZONE_YELL = 6 }; -//Selection method used by SelectTarget (CreatureEventAI) -enum AttackingTarget -{ - ATTACKING_TARGET_RANDOM = 0, //Just selects a random target - ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom - ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top - /* not implemented - ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only) - ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only) - ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only) - */ -}; - // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform #if defined( __GNUC__ ) #pragma pack() diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 133bfca1f4b..081dc776aeb 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -1121,37 +1121,6 @@ void CreatureEventAI::UpdateAI(const uint32 diff) DoMeleeAttackIfReady(); } -inline Unit* CreatureEventAI::SelectUnit(AttackingTarget target, uint32 position) -{ - //ThreatList m_threatlist; - std::list<HostileReference*>& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list<HostileReference*>::iterator i = m_threatlist.begin(); - std::list<HostileReference*>::reverse_iterator r = m_threatlist.rbegin(); - - if (position >= m_threatlist.size() || !m_threatlist.size()) - return NULL; - - switch (target) - { - case ATTACKING_TARGET_RANDOM: - { - advance ( i , position + (rand() % (m_threatlist.size() - position ) )); - return Unit::GetUnit(*m_creature,(*i)->getUnitGuid()); - } - case ATTACKING_TARGET_TOPAGGRO: - { - advance ( i , position); - return Unit::GetUnit(*m_creature,(*i)->getUnitGuid()); - } - case ATTACKING_TARGET_BOTTOMAGGRO: - { - advance ( r , position); - return Unit::GetUnit(*m_creature,(*r)->getUnitGuid()); - } - } - return NULL; -} - inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3) { switch (rnd % 3) @@ -1183,13 +1152,13 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke case TARGET_T_HOSTILE: return m_creature->getVictim(); case TARGET_T_HOSTILE_SECOND_AGGRO: - return SelectUnit(ATTACKING_TARGET_TOPAGGRO,1); + return SelectTarget(SELECT_TARGET_TOPAGGRO,1); case TARGET_T_HOSTILE_LAST_AGGRO: - return SelectUnit(ATTACKING_TARGET_BOTTOMAGGRO,0); + return SelectTarget(SELECT_TARGET_BOTTOMAGGRO,0); case TARGET_T_HOSTILE_RANDOM: - return SelectUnit(ATTACKING_TARGET_RANDOM,0); + return SelectTarget(SELECT_TARGET_RANDOM,0); case TARGET_T_HOSTILE_RANDOM_NOT_TOP: - return SelectUnit(ATTACKING_TARGET_RANDOM,1); + return SelectTarget(SELECT_TARGET_RANDOM,1); case TARGET_T_ACTION_INVOKER: return pActionInvoker; default: diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 61ceb7da21b..380947d7db7 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -610,7 +610,6 @@ class CreatureEventAI : public CreatureAI inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3); inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3); inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker); - inline Unit* SelectUnit(AttackingTarget target, uint32 position); void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target); bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered); diff --git a/src/game/ScriptedCreature.cpp b/src/game/ScriptedCreature.cpp index 19d8afa02ff..c2e817007c7 100644 --- a/src/game/ScriptedCreature.cpp +++ b/src/game/ScriptedCreature.cpp @@ -191,6 +191,9 @@ Unit* ScriptedAI::SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition) advance (ritr , uiPosition); return Unit::GetUnit((*m_creature),(*ritr)->getUnitGuid()); break; + + default: + return UnitAI::SelectTarget(pTarget, uiPosition); } return NULL; |