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:
parent
5b7b99e0de
commit
e873d2ed7e
4 changed files with 186 additions and 78 deletions
67
Projects/UOContent/Network/FastwalkDetection.cs
Normal file
67
Projects/UOContent/Network/FastwalkDetection.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System.Collections.Generic;
|
||||
using Server.Commands.Generic;
|
||||
|
||||
namespace Server.Network;
|
||||
|
||||
public static class FastwalkDetection
|
||||
{
|
||||
private static readonly HashSet<Mobile> _debugFastwalk = new();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
TargetCommands.Register(new DebugFastwalk());
|
||||
EventSink.FastWalk += OnFastwalk;
|
||||
}
|
||||
|
||||
private static void OnFastwalk(FastWalkEventArgs e)
|
||||
{
|
||||
var from = e.NetState.Mobile;
|
||||
if (from == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_debugFastwalk.Contains(from))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
from.PublicOverheadMessage(MessageType.Emote, from.EmoteHue, false, "Fastwalk Detected", accessLevel: AccessLevel.GameMaster);
|
||||
}
|
||||
|
||||
public class DebugFastwalk : BaseCommand
|
||||
{
|
||||
public DebugFastwalk()
|
||||
{
|
||||
AccessLevel = AccessLevel.GameMaster;
|
||||
Supports = CommandSupport.AllMobiles;
|
||||
Commands = new[] { "DebugFastwalk" };
|
||||
ObjectTypes = ObjectTypes.Mobiles;
|
||||
ListOptimized = true;
|
||||
Usage = "DebugFastwalk <on|off>";
|
||||
Description = "Enables fastwalk debug messages";
|
||||
}
|
||||
|
||||
public override void ExecuteList(CommandEventArgs e, List<object> list)
|
||||
{
|
||||
var on = e.Arguments.Length == 0 || e.GetBoolean(0);
|
||||
|
||||
foreach (var o in list)
|
||||
{
|
||||
if (o is not Mobile m)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (on)
|
||||
{
|
||||
_debugFastwalk.Add(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
_debugFastwalk.Remove(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue