aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/AI/CoreAI/UnitAI.cpp9
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp9
2 files changed, 10 insertions, 8 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index 9abdf9e8cfc..1b6cdee737c 100644
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -28,6 +28,7 @@
void UnitAI::AttackStart(Unit* victim)
{
+
if (victim && me->Attack(victim, true))
me->GetMotionMaster()->MoveChase(victim);
}
@@ -44,14 +45,18 @@ void UnitAI::DoMeleeAttackIfReady()
return;
Unit* victim = me->GetVictim();
+
+ if (!me->IsWithinMeleeRange(victim))
+ return;
+
//Make sure our attack is ready and we aren't currently casting before checking distance
- if (me->isAttackReady() && me->IsWithinMeleeRange(victim))
+ if (me->isAttackReady())
{
me->AttackerStateUpdate(victim);
me->resetAttackTimer();
}
- if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK) && me->IsWithinMeleeRange(victim))
+ if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
{
me->AttackerStateUpdate(victim, OFF_ATTACK);
me->resetAttackTimer(OFF_ATTACK);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index ef82c5022fe..296090a4378 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -597,6 +597,9 @@ void SmartAI::EnterCombat(Unit* enemy)
me->InterruptNonMeleeSpells(false); // must be before ProcessEvents
GetScript()->ProcessEventsFor(SMART_EVENT_AGGRO, enemy);
me->GetPosition(&mLastOOCPos);
+ SetRun(mRun);
+ if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == POINT_MOTION_TYPE)
+ me->GetMotionMaster()->MovementExpired();
}
void SmartAI::JustDied(Unit* killer)
@@ -620,14 +623,8 @@ void SmartAI::AttackStart(Unit* who)
{
if (who && me->Attack(who, me->IsWithinMeleeRange(who)))
{
- SetRun(mRun);
- if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == POINT_MOTION_TYPE)
- me->GetMotionMaster()->MovementExpired();
-
if (mCanCombatMove)
me->GetMotionMaster()->MoveChase(who);
-
- me->GetPosition(&mLastOOCPos);
}
}