aboutsummaryrefslogtreecommitdiff
path: root/src/game/CreatureAI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/CreatureAI.cpp')
-rw-r--r--src/game/CreatureAI.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 67458f5a157..350e9d7ee13 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -51,7 +51,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
{
- if(Unit *target = creature->SelectNearestTarget())
+ if(Unit *target = creature->SelectNearestTarget(50))
creature->AI()->AttackStart(target);
else if(creature->isSummon())
{
@@ -97,6 +97,26 @@ void CreatureAI::MoveInLineOfSight(Unit *who)
AttackStart(who->getVictim());
}
+bool CreatureAI::UpdateVictimByReact()
+{
+ if(!me->isInCombat())
+ return false;
+
+ if(me->HasReactState(REACT_AGGRESSIVE))
+ {
+ if(Unit *victim = me->SelectVictim())
+ AttackStart(victim);
+ return me->getVictim();
+ }
+ else if(me->getThreatManager().isThreatListEmpty())
+ {
+ EnterEvadeMode();
+ return false;
+ }
+
+ return true;
+}
+
bool CreatureAI::UpdateVictim()
{
if(!me->isInCombat())