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

@ -56,11 +56,12 @@ namespace Server.Mobiles
Attack, // "(All/Name) kill",
// "(All/Name) attack" All or the specified pet(s) currently under your control attack the target.
Patrol, // "(Name) patrol" Roves between two or more guarded targets.
Release, // "(Name) release" Releases pet back into the wild (removes "tame" status).
Stay, // "(All/Name) stay" All or the specified pet(s) will stop and stay in current spot.
Stop, // "(All/Name) stop Cancels any current orders to attack, guard or follow.
Transfer // "(Name) transfer" Transfers complete ownership to targeted player.
Patrol, // "(Name) patrol" Roves between two or more guarded targets.
Release, // "(Name) release" Releases pet back into the wild (removes "tame" status).
Stay, // "(All/Name) stay" All or the specified pet(s) will stop and stay in current spot.
Stop, // "(All/Name) stop Cancels any current orders to attack, guard or follow.
Transfer, // "(Name) transfer" Transfers complete ownership to targeted player.
Rename // "(Name) rename" Changes the name of the pet.
}
[Flags]
@ -132,30 +133,6 @@ namespace Server.Mobiles
public int CompareTo(DamageStore ds) => (ds?.m_Damage ?? 0).CompareTo(m_Damage);
}
[AttributeUsage(AttributeTargets.Class)]
public class FriendlyNameAttribute : Attribute
{
public FriendlyNameAttribute(TextDefinition friendlyName) => FriendlyName = friendlyName;
// future use: Talisman 'Protection/Bonus vs. Specific Creature
public TextDefinition FriendlyName { get; }
public static TextDefinition GetFriendlyNameFor(Type t)
{
if (t.IsDefined(typeof(FriendlyNameAttribute), false))
{
var objs = t.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
if (objs.Length > 0)
{
return (objs[0] as FriendlyNameAttribute)?.FriendlyName ?? "";
}
}
return t.Name;
}
}
public abstract partial class BaseCreature : Mobile, IHonorTarget, IQuestGiver
{
public enum Allegiance
@ -364,7 +341,11 @@ namespace Server.Mobiles
FightMode = mode;
ResetSpeeds();
GetSpeeds(out var activeSpeed, out var passiveSpeed);
ActiveSpeed = activeSpeed;
PassiveSpeed = passiveSpeed;
CurrentSpeed = passiveSpeed;
m_Team = 0;
@ -926,8 +907,6 @@ namespace Server.Mobiles
public virtual bool ReturnsToHome =>
SeeksHome && Home != Point3D.Zero && !m_ReturnQueued && !Controlled && !Summoned;
public virtual bool ScaleSpeedByDex => NPCSpeeds.ScaleSpeedByDex && !IsMonster;
// used for deleting untamed creatures [in houses]
[CommandProperty(AccessLevel.GameMaster)]
public bool RemoveIfUntamed { get; set; }
@ -1517,15 +1496,6 @@ namespace Server.Mobiles
}
}
public override void OnRawDexChange(int oldValue)
{
// This only really happens for pets or when a GM modifies a mob.
if (oldValue != RawDex && ScaleSpeedByDex)
{
ResetSpeeds();
}
}
public override void OnBeforeSpawn(Point3D location, Map m)
{
if (Paragon.CheckConvert(this, location, m))
@ -3536,7 +3506,6 @@ namespace Server.Mobiles
}
Guild = null;
ResetSpeeds();
Delta(MobileDelta.Noto);
@ -4926,15 +4895,6 @@ namespace Server.Mobiles
NPCSpeeds.GetSpeeds(this, out activeSpeed, out passiveSpeed);
}
public void ResetSpeeds(bool currentUseActive = false)
{
GetSpeeds(out var activeSpeed, out var passiveSpeed);
ActiveSpeed = activeSpeed;
PassiveSpeed = passiveSpeed;
CurrentSpeed = currentUseActive ? activeSpeed : passiveSpeed;
}
public virtual void DropBackpack()
{
if (Backpack?.Items.Count > 0)