From d73ebe2e383d28167e32e03f16080f6cdffb6eaf Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Sun, 10 Nov 2024 04:54:01 -0300 Subject: [PATCH] fix(Core/SAI): Don't try to reposition Rooted inhabit type creatures (#20504) --- src/server/game/AI/SmartScripts/SmartScript.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index ac6bebeca..553a5b82d 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -696,6 +696,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle()) { failedSpellCast = true; // Mark spellcast as failed so we can retry it later + + if (me->IsRooted()) // Rooted inhabit type, never move/reposition + continue; + float minDistance = std::max(meleeRange, spellMinRange) - distanceToTarget + NOMINAL_MELEE_RANGE; CAST_AI(SmartAI, me->AI())->MoveAway(std::min(minDistance, spellMaxRange)); continue; @@ -705,12 +709,20 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (distanceToTarget > spellMaxRange && isWithinLOSInMap) { failedSpellCast = true; + + if (me->IsRooted()) // Rooted inhabit type, never move/reposition + continue; + CAST_AI(SmartAI, me->AI())->SetCombatMove(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f)); continue; } else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS)) { failedSpellCast = true; + + if (me->IsRooted()) // Rooted inhabit type, never move/reposition + continue; + CAST_AI(SmartAI, me->AI())->SetCombatMove(true); continue; }