fix: Removes run flag from NPC movement (#1357)

This commit is contained in:
Kamron Batman 2023-03-02 10:58:17 -08:00 committed by GitHub
parent 0150e1a994
commit 57ff488d51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View file

@ -8881,9 +8881,13 @@ public class Mobile : IHued, IComparable<Mobile>, 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);

View file

@ -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)

View file

@ -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 };