From 57ff488d51e05f909d85b3327fc1772acd299cf6 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 2 Mar 2023 10:58:17 -0800 Subject: [PATCH] fix: Removes run flag from NPC movement (#1357) --- Projects/Server/Mobiles/Mobile.cs | 4 ++++ Projects/UOContent/Engines/Pathing/PathFollower.cs | 10 +++++----- Projects/UOContent/Mobiles/AI/BaseAI.cs | 12 +++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index 74484a327..98c325e72 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -8881,9 +8881,13 @@ public class Mobile : IHued, IComparable, ISpawnable, IObjectPropertyLis return ret | (run ? Direction.Running : 0); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public Direction GetDirectionTo(Point2D p, bool run = false) => GetDirectionTo(p.m_X, p.m_Y, run); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public Direction GetDirectionTo(Point3D p, bool run = false) => GetDirectionTo(p.m_X, p.m_Y, run); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public Direction GetDirectionTo(IPoint2D p, bool run = false) => p == null ? Direction.North | (run ? Direction.Running : 0) : GetDirectionTo(p.X, p.Y, run); diff --git a/Projects/UOContent/Engines/Pathing/PathFollower.cs b/Projects/UOContent/Engines/Pathing/PathFollower.cs index 2596f1dad..20a285a2e 100644 --- a/Projects/UOContent/Engines/Pathing/PathFollower.cs +++ b/Projects/UOContent/Engines/Pathing/PathFollower.cs @@ -102,14 +102,14 @@ namespace Server if (!(Enabled && m_Path.Success)) { - d = m_From.GetDirectionTo(goal, run); + d = m_From.GetDirectionTo(goal); m_From.SetDirection(d); Move(d); return Check(m_From.Location, goal, range); } - d = m_From.GetDirectionTo(m_Next, run); + d = m_From.GetDirectionTo(m_Next); m_From.SetDirection(d); var res = Move(d); @@ -123,16 +123,16 @@ namespace Server m_Path = null; CheckPath(); - if (!m_Path.Success) + if (!m_Path!.Success) { - d = m_From.GetDirectionTo(goal, run); + d = m_From.GetDirectionTo(goal); m_From.SetDirection(d); Move(d); return Check(m_From.Location, goal, range); } - d = m_From.GetDirectionTo(m_Next, run); + d = m_From.GetDirectionTo(m_Next); m_From.SetDirection(d); if (Move(d) == MoveResult.Blocked) diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index b6c7068b4..c8b61fb73 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -2041,14 +2041,16 @@ public abstract class BaseAI public double TransformMoveDelay(double thinkingSpeed) { + var isControlled = m_Mobile.Controlled || m_Mobile.Summoned; + // Monster is passive - if (m_Mobile is { Controlled: false, Summoned: false } && Math.Abs(thinkingSpeed - m_Mobile.PassiveSpeed) < 0.0001) + if (!isControlled && Math.Abs(thinkingSpeed - m_Mobile.PassiveSpeed) < 0.0001) { - thinkingSpeed *= 3; + thinkingSpeed *= 3; // Monster passive is 3x slower than thinking } - else // Movement speed is twice as slow as "thinking" + else if (!isControlled || m_Mobile.ControlOrder != OrderType.Follow || m_Mobile.ControlTarget != m_Mobile.ControlMaster) { - thinkingSpeed *= 2; + thinkingSpeed *= 2; // Monster active speed is 2x slower than thinking } if (!m_Mobile.IsDeadPet && (m_Mobile.ReduceSpeedWithDamage || m_Mobile.IsSubdued)) @@ -2414,7 +2416,7 @@ public abstract class BaseAI return true; } } - else if (!DoMove(m_Mobile.GetDirectionTo(m, run), true)) + else if (!DoMove(m_Mobile.GetDirectionTo(m), true)) { m_Path = new PathFollower(m_Mobile, m) { Mover = DoMoveImpl };