aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/AI/CoreAI/UnitAI.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index 91de52db9f8..b6517e3396b 100755
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -42,22 +42,26 @@ void UnitAI::DoMeleeAttackIfReady()
if (me->HasUnitState(UNIT_STAT_CASTING))
return;
+ Unit *victim = me->getVictim();
+ if (!victim || !victim->IsInWorld())
+ return;
+
//Make sure our attack is ready and we aren't currently casting before checking distance
if (me->isAttackReady())
{
//If we are within range melee the target
- if (me->IsWithinMeleeRange(me->getVictim()))
+ if (me->IsWithinMeleeRange(victim))
{
- me->AttackerStateUpdate(me->getVictim());
+ me->AttackerStateUpdate(victim);
me->resetAttackTimer();
}
}
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
{
//If we are within range melee the target
- if (me->IsWithinMeleeRange(me->getVictim()))
+ if (me->IsWithinMeleeRange(victim))
{
- me->AttackerStateUpdate(me->getVictim(), OFF_ATTACK);
+ me->AttackerStateUpdate(victim, OFF_ATTACK);
me->resetAttackTimer(OFF_ATTACK);
}
}