fix(Core/SAI): Don't try to reposition Rooted inhabit type creatures (#20504)
This commit is contained in:
@@ -696,6 +696,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle())
|
if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle())
|
||||||
{
|
{
|
||||||
failedSpellCast = true; // Mark spellcast as failed so we can retry it later
|
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;
|
float minDistance = std::max(meleeRange, spellMinRange) - distanceToTarget + NOMINAL_MELEE_RANGE;
|
||||||
CAST_AI(SmartAI, me->AI())->MoveAway(std::min(minDistance, spellMaxRange));
|
CAST_AI(SmartAI, me->AI())->MoveAway(std::min(minDistance, spellMaxRange));
|
||||||
continue;
|
continue;
|
||||||
@@ -705,12 +709,20 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (distanceToTarget > spellMaxRange && isWithinLOSInMap)
|
if (distanceToTarget > spellMaxRange && isWithinLOSInMap)
|
||||||
{
|
{
|
||||||
failedSpellCast = true;
|
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));
|
CAST_AI(SmartAI, me->AI())->SetCombatMove(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS))
|
else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS))
|
||||||
{
|
{
|
||||||
failedSpellCast = true;
|
failedSpellCast = true;
|
||||||
|
|
||||||
|
if (me->IsRooted()) // Rooted inhabit type, never move/reposition
|
||||||
|
continue;
|
||||||
|
|
||||||
CAST_AI(SmartAI, me->AI())->SetCombatMove(true);
|
CAST_AI(SmartAI, me->AI())->SetCombatMove(true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user