From e94dca132b4a505f3cc4583bd63879148ad51ca3 Mon Sep 17 00:00:00 2001 From: ccrs Date: Fri, 19 Jul 2019 16:07:00 +0200 Subject: [PATCH] Core/SmartAI: add missing movement generator type check on SmartAI::SetCombatMove ref #21562 (cherry picked from commit 0e3e4353a1824dd6e40ca10a01c4465aa1b1fbad) --- src/server/game/AI/SmartScripts/SmartAI.cpp | 2 +- src/server/game/AI/SmartScripts/SmartScript.cpp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index dcc6bf9d9c..3702ede142 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -797,7 +797,7 @@ void SmartAI::SetCombatMove(bool on) { if (!me->HasReactState(REACT_PASSIVE) && me->GetVictim() && !me->GetMotionMaster()->HasMovementGenerator([](MovementGenerator const* movement) -> bool { - return movement->Mode == MOTION_MODE_DEFAULT && movement->Priority == MOTION_PRIORITY_NORMAL; + return movement->GetMovementGeneratorType() == CHASE_MOTION_TYPE && movement->Mode == MOTION_MODE_DEFAULT && movement->Priority == MOTION_PRIORITY_NORMAL; })) { SetRun(_run); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 39319151a6..12c7aab0d9 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -563,9 +563,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (e.action.cast.castFlags & SMARTCAST_COMBAT_MOVE) { - // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed - // unless target is outside spell range, out of mana, or LOS. - + // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed unless target is outside spell range, out of mana, or LOS. bool allowMove = false; SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(e.action.cast.spell, me->GetMap()->GetDifficultyID()); std::vector costs = spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()); @@ -588,11 +586,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u break; } } - } - if (me->GetDistance(target) > spellInfo->GetMaxRange(true) || - me->GetDistance(target) < spellInfo->GetMinRange(true) || + if (me->GetDistance(target) > spellInfo->GetMaxRange(true) || me->GetDistance(target) < spellInfo->GetMinRange(true) || !me->IsWithinLOSInMap(target) || !hasPower || me->HasUnitFlag(UNIT_FLAG_SILENCED))