fix: Reverts to RunUO speeds, fixes direction glitching, adds movement speed interpolation (#1695)
> [!IMPORTANT] > Please read through these changes, as they changed certain expectations for how the internal AI thinking/movement work. > Note that some mobs still don't have smooth movement on ClassicUO due to how the client handles animations/movement. ### Summary - **Important Change**: Mobs will now move at a more regular pace. If the OnThink results in a move, but the cooldown would otherwise prevent the move, then the movement is scheduled on another timer. - Added a 400ms delay to mobs turning to face a player to attack in order to avoid glitching between moving and turning. - Reverted AI thinking speeds back to RunUO specific speeds. - Reverted the AI thinking to moving conversion delays back to RunUO. - For thinking speeds that are not exactly the predefined speeds from RunUO, there is a new calculation to determine the correct conversion to movement speed. This stops speeds like `0.35` from being faster than `0.3` > [!NOTE] > **Developer Note** > BaseAI.CheckMove() no longer contains the check for whether or not a mob is on movement cooldown. This function can now be overwritten without causing issues to figuring out that cooldown.
This commit is contained in:
parent
9e37879f19
commit
3332fabc39
20 changed files with 354 additions and 223 deletions
|
|
@ -261,7 +261,14 @@ namespace Server.Mobiles
|
|||
|
||||
private AIType m_CurrentAI; // The current AI
|
||||
|
||||
private double m_CurrentSpeed; // The current speed, lets say it could be changed by something;
|
||||
private double _activeSpeed;
|
||||
private double _passiveSpeed;
|
||||
private double _currentSpeed;
|
||||
|
||||
// Herding - Overrides the AI to force the mob to move to a specific location
|
||||
// Thinking: 0.3s, Movement: 0.6s.
|
||||
private IPoint2D _targetLocation;
|
||||
|
||||
private int m_DamageMax = -1;
|
||||
|
||||
private int m_DamageMin = -1;
|
||||
|
|
@ -541,9 +548,6 @@ namespace Server.Mobiles
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public WayPoint CurrentWayPoint { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public IPoint2D TargetLocation { get; set; }
|
||||
|
||||
public virtual Mobile ConstantFocus => null;
|
||||
|
||||
public virtual bool DisallowAllMoves => false;
|
||||
|
|
@ -660,32 +664,60 @@ namespace Server.Mobiles
|
|||
public int RangeHome { get; set; } = 10;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double ActiveSpeed { get; set; }
|
||||
public virtual double ActiveSpeed
|
||||
{
|
||||
get => _activeSpeed;
|
||||
set
|
||||
{
|
||||
if (Math.Abs(_activeSpeed - value) > .0001)
|
||||
{
|
||||
_activeSpeed = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double PassiveSpeed { get; set; }
|
||||
public virtual double PassiveSpeed
|
||||
{
|
||||
get => _passiveSpeed;
|
||||
set
|
||||
{
|
||||
_passiveSpeed = value;
|
||||
if (Math.Abs(_passiveSpeed - value) > .0001)
|
||||
{
|
||||
_passiveSpeed = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double SpeedMod { get; set; }
|
||||
public IPoint2D TargetLocation
|
||||
{
|
||||
get => _targetLocation;
|
||||
set
|
||||
{
|
||||
_targetLocation = value;
|
||||
AIObject?.OnCurrentSpeedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double CurrentSpeed
|
||||
{
|
||||
get => TargetLocation != null ? 0.3 : SpeedMod <= 0 ? m_CurrentSpeed : SpeedMod;
|
||||
get => _targetLocation != null ? 0.3 : _currentSpeed;
|
||||
set
|
||||
{
|
||||
if (m_CurrentSpeed != value)
|
||||
if (Math.Abs(_currentSpeed - value) > 0.0001)
|
||||
{
|
||||
m_CurrentSpeed = value;
|
||||
|
||||
if (SpeedMod <= 0)
|
||||
{
|
||||
AIObject?.OnCurrentSpeedChanged();
|
||||
}
|
||||
_currentSpeed = value;
|
||||
AIObject?.OnCurrentSpeedChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double MoveSpeedMod { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Point3D Home
|
||||
{
|
||||
|
|
@ -1795,9 +1827,9 @@ namespace Server.Mobiles
|
|||
|
||||
writer.Write(m_Team);
|
||||
|
||||
writer.Write(ActiveSpeed);
|
||||
writer.Write(PassiveSpeed);
|
||||
writer.Write(m_CurrentSpeed);
|
||||
writer.Write(_activeSpeed);
|
||||
writer.Write(_passiveSpeed);
|
||||
writer.Write(_currentSpeed);
|
||||
|
||||
writer.Write(m_Home.X);
|
||||
writer.Write(m_Home.Y);
|
||||
|
|
@ -1921,9 +1953,9 @@ namespace Server.Mobiles
|
|||
|
||||
m_Team = reader.ReadInt();
|
||||
|
||||
ActiveSpeed = reader.ReadDouble();
|
||||
PassiveSpeed = reader.ReadDouble();
|
||||
m_CurrentSpeed = reader.ReadDouble();
|
||||
_activeSpeed = reader.ReadDouble();
|
||||
_passiveSpeed = reader.ReadDouble();
|
||||
_currentSpeed = reader.ReadDouble();
|
||||
|
||||
if (RangePerception == OldRangePerception)
|
||||
{
|
||||
|
|
@ -4478,13 +4510,19 @@ namespace Server.Mobiles
|
|||
return false;
|
||||
}
|
||||
|
||||
public void SetSpeed(double active, double passive)
|
||||
public void SetSpeed(double active, double passive, bool isPassive = true)
|
||||
{
|
||||
ActiveSpeed = active;
|
||||
PassiveSpeed = passive;
|
||||
CurrentSpeed = PassiveSpeed;
|
||||
CurrentSpeed = isPassive ? PassiveSpeed : ActiveSpeed;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetCurrentSpeedToActive() => CurrentSpeed = ActiveSpeed;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetCurrentSpeedToPassive() => CurrentSpeed = PassiveSpeed;
|
||||
|
||||
public void SetDamage(int val)
|
||||
{
|
||||
m_DamageMin = val;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue