feat: Overhauls AI (Speech/Movement) (#2232)

### Summary

* Refactors AI so it is easier to read and maintain
* Fixes NPC speed issues
* Fixes pet sector AI issue that was causing stuttering
* Fixes direction snapping for Melee/Mage AI
* Refactors pet orders
* Refactors speech commands
* Removes scale speed by dex for HS+ (it was a stupid feature anyways)
This commit is contained in:
Kamron Batman 2025-07-18 22:39:57 -07:00 committed by GitHub
parent f89150735e
commit aab731ed96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 3688 additions and 3429 deletions

View file

@ -22,32 +22,12 @@ public static class NPCSpeeds
private static readonly Dictionary<Type, SpeedClassEntry> _speedsByType = new();
private static readonly Dictionary<SpeedLevel, SpeedClassEntry> _speedsByLevel = new();
// Enabled for pets on HS+
public static bool ScaleSpeedByDex { get; private set; }
public static double MinDelay { get; private set; }
public static double MaxDelay { get; private set; }
public static int MinDex { get; private set; }
public static int MaxDex { get; private set; }
// Time period to lock NPCs into idling
public static int MinIdleSeconds { get; private set; }
public static int MaxIdleSeconds { get; private set; }
public static void GetSpeeds(BaseCreature bc, out double activeSpeed, out double passiveSpeed)
{
// Used for scaling pet's speed by dex in HS+
if (bc.ScaleSpeedByDex)
{
var maxDex = MaxDex;
double min = MinDelay;
double max = MaxDelay;
var dex = Math.Clamp(bc.Dex, MinDex, maxDex);
activeSpeed = Math.Max(max - (max - min) * ((double)dex / maxDex), min);
passiveSpeed = activeSpeed * 2;
return;
}
if ((bc.SpeedClass == SpeedLevel.None || !_speedsByLevel.TryGetValue(bc.SpeedClass, out var sp)) &&
!_speedsByType.TryGetValue(bc.GetType(), out sp))
{
@ -70,11 +50,6 @@ public static class NPCSpeeds
public static void Configure()
{
ScaleSpeedByDex = ServerConfiguration.GetSetting("movement.delay.scaleSpeedByDex", Core.HS);
MinDelay = ServerConfiguration.GetSetting("movement.delay.npcMinDelay", 0.1);
MaxDelay = ServerConfiguration.GetSetting("movement.delay.npcMaxDelay", 0.4);
MaxDex = ServerConfiguration.GetSetting("movement.delay.npcMinDex", 50);
MaxDex = ServerConfiguration.GetSetting("movement.delay.npcMaxDex", 200);
MinIdleSeconds = ServerConfiguration.GetSetting("movement.delay.npcMinIdle", 15);
MaxIdleSeconds = ServerConfiguration.GetSetting("movement.delay.npcMaxIdle", 25);