fix: Simplifies fastwalk detection (#907)

* Uses a circular buffer for steps.
* Limits to 3 steps instead of 4.
* Gives a 5% buffer on the first step.
This commit is contained in:
Kamron Batman 2022-02-27 02:20:03 -08:00 • committed by GitHub
parent 5b7b99e0de
commit e873d2ed7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 186 additions and 78 deletions

View file

@ -9029,7 +9029,10 @@ namespace Server
public Direction GetDirectionTo(IPoint2D p, bool run = false) =>
p == null ? Direction.North | (run ? Direction.Running : 0) : GetDirectionTo(p.X, p.Y, run);
public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight = true)
public void PublicOverheadMessage(
MessageType type, int hue, bool ascii, string text, bool noLineOfSight = true,
AccessLevel accessLevel = AccessLevel.Player
)
{
if (m_Map == null)
{
@ -9042,7 +9045,11 @@ namespace Server
foreach (var state in eable)
{
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
if (
state.Mobile.AccessLevel >= accessLevel &&
state.Mobile.CanSee(this) &&
(noLineOfSight || state.Mobile.InLOS(this))
)
{
var length = OutgoingMessagePackets.CreateMessage(
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
@ -9093,7 +9100,8 @@ namespace Server
public void PublicOverheadMessage(
MessageType type, int hue, int number, AffixType affixType, string affix,
string args = "", bool noLineOfSight = false
string args = "", bool noLineOfSight = false,
AccessLevel accessLevel = AccessLevel.Player
)
{
if (m_Map == null)
@ -9107,7 +9115,11 @@ namespace Server
foreach (var state in eable)
{
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
if (
state.Mobile.AccessLevel >= accessLevel &&
state.Mobile.CanSee(this) &&
(noLineOfSight || state.Mobile.InLOS(this))
)
{
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
buffer, Serial, Body, type, hue, 3, number, Name, affixType, affix, args

View file

@ -19,16 +19,16 @@ namespace Server.Movement
{
// Movement implementation algorithm
public static IMovementImpl Impl { get; set; }
public static int WalkFootDelay { get; set; } = 440;
public static int RunFootDelay { get; set; } = 220;
public static int WalkMountDelay { get; set; } = 220;
public static int RunMountDelay { get; set; } = 110;
public static int WalkFootDelay { get; set; } = 400;
public static int RunFootDelay { get; set; } = 200;
public static int WalkMountDelay { get; set; } = 200;
public static int RunMountDelay { get; set; } = 100;
public static bool EnableFastwalkPrevention { get; set; } = true;
public static AccessLevel FastwalkExemptionLevel { get; set; } = AccessLevel.Counselor;
// If this is changed during runtime, then the steps array needs resizing.
public static int MaxSteps { get; private set; } = 4;
public static int MaxSteps { get; private set; } = 3;
public static void Configure()
{