diff --git a/Distribution/Data/npc-speeds.json b/Distribution/Data/npc-speeds.json index 5ea8371ae..af77f1826 100644 --- a/Distribution/Data/npc-speeds.json +++ b/Distribution/Data/npc-speeds.json @@ -1,8 +1,8 @@ [ { - "name": "Slow", - "active": 0.3, - "passive": 0.6, + "level": "Slow", + "active": 0.35, + "passive": 0.5, "types": [ "AntLion", "ArcticOgreLord", "BogThing", "Bogle", "BoneKnight", "EarthElemental", @@ -19,9 +19,9 @@ ] }, { - "name": "Medium", - "active": 0.25, - "passive": 0.5, + "level": "Medium", + "active": 0.275, + "passive": 0.45, "types": [ "AcidElemental", "AgapiteElemental", "Alligator", "AncientLich", "Betrayer", "Bird", @@ -99,7 +99,7 @@ ] }, { - "name": "Fast", + "level": "Fast", "active": 0.2, "passive": 0.4, "types": [ @@ -130,9 +130,9 @@ ] }, { - "name": "Very Fast", - "active": 0.175, - "passive": 0.35, + "level": "VeryFast", + "active": 0.125, + "passive": 0.3, "types": [ "Barracoon", "Mephitis", "Neira", "Rikktor", "Semidar", "EnergyVortex", diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index c1f1b7139..cef4dbd47 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -2033,12 +2033,16 @@ public abstract class BaseAI } } - public double TransformMoveDelay(double delay) + public double TransformMoveDelay(double thinkingSpeed) { // Monster is passive - if (m_Mobile is { Controlled: false, Summoned: false } && Math.Abs(delay - m_Mobile.PassiveSpeed) < 0.0001) + if (m_Mobile is { Controlled: false, Summoned: false } && Math.Abs(thinkingSpeed - m_Mobile.PassiveSpeed) < 0.0001) { - delay *= 3; + thinkingSpeed *= 3; + } + else // Movement speed is twice as slow as "thinking" + { + thinkingSpeed *= 2; } if (!m_Mobile.IsDeadPet && (m_Mobile.ReduceSpeedWithDamage || m_Mobile.IsSubdued)) @@ -2059,11 +2063,11 @@ public abstract class BaseAI if (offset < 1.0) { - delay += m_Mobile.PassiveSpeed * (1.0 - offset); + thinkingSpeed += m_Mobile.PassiveSpeed * (1.0 - offset); } } - return delay; + return thinkingSpeed; } public virtual bool CheckMove() => Core.TickCount - NextMove >= 0; diff --git a/Projects/UOContent/Mobiles/BaseCreature.cs b/Projects/UOContent/Mobiles/BaseCreature.cs index 4ca56b3b6..853461c82 100644 --- a/Projects/UOContent/Mobiles/BaseCreature.cs +++ b/Projects/UOContent/Mobiles/BaseCreature.cs @@ -4828,7 +4828,7 @@ namespace Server.Mobiles } // If this needs to be serialized, recommend creating a hash or registry id. Don't serialize strings. - public virtual string SpeedClass => null; + public virtual SpeedLevel SpeedClass => SpeedLevel.None; public virtual void GetSpeeds(out double activeSpeed, out double passiveSpeed) { diff --git a/Projects/UOContent/Mobiles/NPCSpeeds.cs b/Projects/UOContent/Mobiles/NPCSpeeds.cs index e6317c91f..b052c7af7 100644 --- a/Projects/UOContent/Mobiles/NPCSpeeds.cs +++ b/Projects/UOContent/Mobiles/NPCSpeeds.cs @@ -6,11 +6,20 @@ using Server.Json; namespace Server.Mobiles; +public enum SpeedLevel +{ + None, + Slow, + Medium, + Fast, + VeryFast +} + public static class NPCSpeeds { private const string _tablePath = "Data/npc-speeds.json"; private static Dictionary _speedsByType = new(); - private static Dictionary _speedsByName = new(); + private static Dictionary _speedsByLevel = new(); // Enabled for pets on HS+ public static bool ScaleSpeedByDex { get; private set; } @@ -38,22 +47,19 @@ public static class NPCSpeeds return; } - if (bc.SpeedClass != null && _speedsByName.TryGetValue(bc.SpeedClass, out var sp) || - _speedsByType.TryGetValue(bc.GetType(), out sp)) + if ((bc.SpeedClass == SpeedLevel.None || !_speedsByLevel.TryGetValue(bc.SpeedClass, out var sp)) && + !_speedsByType.TryGetValue(bc.GetType(), out sp)) { - activeSpeed = sp.ActiveSpeed; - passiveSpeed = sp.PassiveSpeed; - return; + sp = _speedsByLevel[SpeedLevel.Medium]; } - // "Fast" - activeSpeed = 0.2; - passiveSpeed = 0.4; + activeSpeed = sp.ActiveSpeed; + passiveSpeed = sp.PassiveSpeed; } public static void RegisterSpeed(SpeedClassEntry entry) { - _speedsByName[entry.Name] = entry; + _speedsByLevel[entry.Level] = entry; foreach (var type in entry.Types) { @@ -87,8 +93,8 @@ public static class NPCSpeeds public record SpeedClassEntry { - [JsonPropertyName("name")] - public string Name { get; init; } + [JsonPropertyName("level")] + public SpeedLevel Level { get; init; } [JsonPropertyName("active")] public double ActiveSpeed { get; init; }