fix: Fixes NPC slowness. (#955)

* Adds the following configurations:
  * `movement.delay.npcMinDelay` - 0.1 - Pets or Non-monster NPCs
  * `movement.delay.npcMaxDelay` - 0.4 - Pets or Non-monster NPCs
  * `movement.delay.monsterMinDelay` - 0.4 - Non-pet Monsters or NPC vs Player Combat
  * `movement.delay.monsterMaxDelay` - 0.8 - Non-pet Monsters or NPC vs Player Combat
  * `movement.delay.monsterMinDex` - 150 - Dex maximum for delay by dex
  * `movement.delay.MinDex` - 190 - Dex maximum for delay by dex
This commit is contained in:
Kamron Batman 2022-03-10 22:55:06 -08:00 • committed by GitHub
parent 44bd129734
commit bdee7bc671
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
357 changed files with 767 additions and 962 deletions

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using Server.ContextMenus;
using Server.Engines.Quests;
using Server.Engines.Quests.Necro;
@ -810,31 +809,45 @@ namespace Server.Mobiles
switch (Action)
{
case ActionType.Wander:
m_Mobile.OnActionWander();
return DoActionWander();
{
m_Mobile.OnActionWander();
return DoActionWander();
}
case ActionType.Combat:
m_Mobile.OnActionCombat();
return DoActionCombat();
{
m_Mobile.OnActionCombat();
return DoActionCombat();
}
case ActionType.Guard:
m_Mobile.OnActionGuard();
return DoActionGuard();
{
m_Mobile.OnActionGuard();
return DoActionGuard();
}
case ActionType.Flee:
m_Mobile.OnActionFlee();
return DoActionFlee();
{
m_Mobile.OnActionFlee();
return DoActionFlee();
}
case ActionType.Interact:
m_Mobile.OnActionInteract();
return DoActionInteract();
{
m_Mobile.OnActionInteract();
return DoActionInteract();
}
case ActionType.Backoff:
m_Mobile.OnActionBackoff();
return DoActionBackoff();
{
m_Mobile.OnActionBackoff();
return DoActionBackoff();
}
default:
return false;
{
return false;
}
}
}
@ -843,42 +856,54 @@ namespace Server.Mobiles
switch (Action)
{
case ActionType.Wander:
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
m_Mobile.FocusMob = null;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
break;
{
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
m_Mobile.FocusMob = null;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
break;
}
case ActionType.Combat:
m_Mobile.Warmode = true;
m_Mobile.FocusMob = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
{
m_Mobile.Warmode = true;
m_Mobile.FocusMob = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
}
case ActionType.Guard:
m_Mobile.Warmode = true;
m_Mobile.FocusMob = null;
m_Mobile.Combatant = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_NextStopGuard = Core.TickCount + (int)TimeSpan.FromSeconds(10).TotalMilliseconds;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
{
m_Mobile.Warmode = true;
m_Mobile.FocusMob = null;
m_Mobile.Combatant = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_NextStopGuard = Core.TickCount + (int)TimeSpan.FromSeconds(10).TotalMilliseconds;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
}
case ActionType.Flee:
m_Mobile.Warmode = true;
m_Mobile.FocusMob = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
{
m_Mobile.Warmode = true;
m_Mobile.FocusMob = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
}
case ActionType.Interact:
m_Mobile.Warmode = false;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
break;
{
m_Mobile.Warmode = false;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
break;
}
case ActionType.Backoff:
m_Mobile.Warmode = false;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
break;
{
m_Mobile.Warmode = false;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
break;
}
}
}
@ -1012,12 +1037,7 @@ namespace Server.Mobiles
public virtual bool Obey()
{
if (m_Mobile.Deleted)
{
return false;
}
return m_Mobile.ControlOrder switch
var shouldObey = !m_Mobile.Deleted && m_Mobile.ControlOrder switch
{
OrderType.None => DoOrderNone(),
OrderType.Come => DoOrderCome(),
@ -1034,6 +1054,15 @@ namespace Server.Mobiles
OrderType.Transfer => DoOrderTransfer(),
_ => false
};
if (shouldObey)
{
// TODO: This might cause the movement timer to reset too often if someone is spamming commands.
// Test this thoroughly.
m_Mobile.ResetSpeeds();
}
return shouldObey;
}
public virtual void OnCurrentOrderChanged()
@ -1046,104 +1075,128 @@ namespace Server.Mobiles
switch (m_Mobile.ControlOrder)
{
case OrderType.None:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.Home = m_Mobile.Location;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.Home = m_Mobile.Location;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Come:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Drop:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = true;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = true;
m_Mobile.Combatant = null;
break;
}
case OrderType.Friend:
case OrderType.Unfriend:
m_Mobile.ControlMaster.RevealingAction();
break;
{
m_Mobile.ControlMaster.RevealingAction();
break;
}
case OrderType.Guard:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = true;
m_Mobile.Combatant = null;
var petname = $"{m_Mobile.Name}";
m_Mobile.ControlMaster.SendLocalizedMessage(1049671, petname); // ~1_PETNAME~ is now guarding you.
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = true;
m_Mobile.Combatant = null;
var petname = $"{m_Mobile.Name}";
m_Mobile.ControlMaster.SendLocalizedMessage(1049671, petname); // ~1_PETNAME~ is now guarding you.
break;
}
case OrderType.Attack:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = true;
m_Mobile.Combatant = null;
break;
m_Mobile.Warmode = true;
m_Mobile.Combatant = null;
break;
}
case OrderType.Patrol:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Release:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Stay:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Stop:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.Home = m_Mobile.Location;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.Home = m_Mobile.Location;
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Follow:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
case OrderType.Transfer:
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
{
m_Mobile.ControlMaster.RevealingAction();
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
m_Mobile.PlaySound(m_Mobile.GetIdleSound());
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
m_Mobile.Warmode = false;
m_Mobile.Combatant = null;
break;
}
}
}
@ -1824,32 +1877,50 @@ namespace Server.Mobiles
switch (iRndMove)
{
case 0:
DoMove(Direction.Up);
break;
{
DoMove(Direction.Up);
break;
}
case 1:
DoMove(Direction.North);
break;
{
DoMove(Direction.North);
break;
}
case 2:
DoMove(Direction.Left);
break;
{
DoMove(Direction.Left);
break;
}
case 3:
DoMove(Direction.West);
break;
{
DoMove(Direction.West);
break;
}
case 5:
DoMove(Direction.Down);
break;
{
DoMove(Direction.Down);
break;
}
case 6:
DoMove(Direction.South);
break;
{
DoMove(Direction.South);
break;
}
case 7:
DoMove(Direction.Right);
break;
{
DoMove(Direction.Right);
break;
}
case 8:
DoMove(Direction.East);
break;
{
DoMove(Direction.East);
break;
}
default:
DoMove(m_Mobile.Direction);
break;
{
DoMove(m_Mobile.Direction);
break;
}
}
}
}
@ -1857,100 +1928,24 @@ namespace Server.Mobiles
public double TransformMoveDelay(double delay)
{
var isPassive = delay == m_Mobile.PassiveSpeed;
var isControlled = m_Mobile.Controlled || m_Mobile.Summoned;
double max = m_Mobile.IsMonster ? SpeedInfo.MaxMonsterDelay : SpeedInfo.MaxDelay;
if (delay == 0.2)
if (!m_Mobile.IsDeadPet && (m_Mobile.ReduceSpeedWithDamage || m_Mobile.IsSubdued))
{
delay = 0.3;
}
else if (delay == 0.25)
{
delay = 0.45;
}
else if (delay == 0.3)
{
delay = 0.6;
}
else if (delay == 0.4)
{
delay = 0.9;
}
else if (delay == 0.5)
{
delay = 1.05;
}
else if (delay == 0.6)
{
delay = 1.2;
}
else if (delay == 0.8)
{
delay = 1.5;
}
double offset = m_Mobile.StamMax <= 0 ? 1.0 : m_Mobile.Stam / (double)m_Mobile.StamMax;
if (isPassive)
{
delay += 0.2;
}
if (!isControlled)
{
delay += 0.1;
}
else if (m_Mobile.Controlled)
{
if (m_Mobile.ControlOrder == OrderType.Follow && m_Mobile.ControlTarget == m_Mobile.ControlMaster)
if (offset < 1.0)
{
delay *= 0.5;
delay += (max - delay) * (1.0 - offset);
}
delay -= 0.075;
}
if (m_Mobile.ReduceSpeedWithDamage || m_Mobile.IsSubdued)
{
var offset = (double)m_Mobile.Hits / m_Mobile.HitsMax;
if (offset < 0.0)
{
offset = 0.0;
}
else if (offset > 1.0)
{
offset = 1.0;
}
offset = 1.0 - offset;
delay += offset * 0.8;
}
if (delay < 0.0)
{
delay = 0.0;
}
if (double.IsNaN(delay))
{
using (var op = new StreamWriter("nan_transform.txt", true))
{
op.WriteLine(
$"NaN in TransformMoveDelay: {Core.Now}, {GetType()}, {m_Mobile?.GetType()}, {m_Mobile.HitsMax}"
);
}
return 1.0;
}
return delay;
return Math.Min(delay, max);
}
public virtual bool CheckMove() => Core.TickCount - NextMove >= 0;
public virtual bool DoMove(Direction d) => DoMove(d, false);
public virtual bool DoMove(Direction d, bool badStateOk)
public virtual bool DoMove(Direction d, bool badStateOk = false)
{
var res = DoMoveImpl(d);
@ -2712,7 +2707,7 @@ namespace Server.Mobiles
public virtual void OnCurrentSpeedChanged()
{
m_Timer.Stop();
m_Timer.Delay = TimeSpan.FromSeconds(Utility.RandomDouble());
m_Timer.Delay = TimeSpan.FromMilliseconds(Utility.Random(128) * 8);
m_Timer.Interval = TimeSpan.FromSeconds(Math.Max(0.0, m_Mobile.CurrentSpeed));
m_Timer.Start();
}
@ -2740,70 +2735,72 @@ namespace Server.Mobiles
public override void OnClick()
{
if (!m_Mobile.Deleted && m_Mobile.Controlled && m_From.CheckAlive())
if (m_Mobile.Deleted || !m_Mobile.Controlled || !m_From.CheckAlive())
{
if (m_Mobile.IsDeadPet && m_Order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop)
{
return;
}
return;
}
var isOwner = m_From == m_Mobile.ControlMaster;
var isFriend = !isOwner && m_Mobile.IsPetFriend(m_From);
if (m_Mobile.IsDeadPet && m_Order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop)
{
return;
}
if (!isOwner && !isFriend)
{
return;
}
var isOwner = m_From == m_Mobile.ControlMaster;
var isFriend = !isOwner && m_Mobile.IsPetFriend(m_From);
if (isFriend && m_Order != OrderType.Follow && m_Order != OrderType.Stay && m_Order != OrderType.Stop)
{
return;
}
if (!isOwner && !isFriend)
{
return;
}
switch (m_Order)
{
case OrderType.Follow:
case OrderType.Attack:
case OrderType.Transfer:
case OrderType.Friend:
case OrderType.Unfriend:
if (isFriend && m_Order != OrderType.Follow && m_Order != OrderType.Stay && m_Order != OrderType.Stop)
{
return;
}
switch (m_Order)
{
case OrderType.Follow:
case OrderType.Attack:
case OrderType.Transfer:
case OrderType.Friend:
case OrderType.Unfriend:
{
if (m_Order == OrderType.Transfer && m_From.HasTrade)
{
if (m_Order == OrderType.Transfer && m_From.HasTrade)
{
m_From.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending
}
else if (m_Order == OrderType.Friend && m_From.HasTrade)
{
m_From.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending
}
else
{
m_AI.BeginPickTarget(m_From, m_Order);
}
break;
m_From.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending
}
case OrderType.Release:
else if (m_Order == OrderType.Friend && m_From.HasTrade)
{
if (m_Mobile.Summoned)
{
goto default;
}
m_From.SendGump(new ConfirmReleaseGump(m_From, m_Mobile));
break;
m_From.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending
}
default:
else
{
if (m_Mobile.CheckControlChance(m_From))
{
m_Mobile.ControlOrder = m_Order;
}
break;
m_AI.BeginPickTarget(m_From, m_Order);
}
}
break;
}
case OrderType.Release:
{
if (m_Mobile.Summoned)
{
goto default;
}
m_From.SendGump(new ConfirmReleaseGump(m_From, m_Mobile));
break;
}
default:
{
if (m_Mobile.CheckControlChance(m_From))
{
m_Mobile.ControlOrder = m_Order;
}
break;
}
}
}
}
@ -2904,14 +2901,10 @@ namespace Server.Mobiles
{
var args = $"{to.Name}\t{from.Name}\t ";
from.SendLocalizedMessage(
1043248,
args
); // The pet refuses to be transferred because it will not obey ~1_NAME~.~3_BLANK~
to.SendLocalizedMessage(
1043249,
args
); // The pet will not accept you as a master because it does not trust you.~3_BLANK~
// The pet refuses to be transferred because it will not obey ~1_NAME~.~3_BLANK~
from.SendLocalizedMessage(1043248, args);
// The pet will not accept you as a master because it does not trust you.~3_BLANK~
to.SendLocalizedMessage(1043249, args);
return false;
}
@ -2919,14 +2912,10 @@ namespace Server.Mobiles
{
var args = $"{to.Name}\t{from.Name}\t ";
from.SendLocalizedMessage(
1043250,
args
); // The pet refuses to be transferred because it will not obey you sufficiently.~3_BLANK~
to.SendLocalizedMessage(
1043251,
args
); // The pet will not accept you as a master because it does not trust ~2_NAME~.~3_BLANK~
// The pet refuses to be transferred because it will not obey you sufficiently.~3_BLANK~
from.SendLocalizedMessage(1043250, args);
// The pet will not accept you as a master because it does not trust ~2_NAME~.~3_BLANK~
to.SendLocalizedMessage(1043251, args);
}
else if (accepted && to.Followers + m_Creature.ControlSlots > to.FollowersMax)
{
@ -2986,10 +2975,8 @@ namespace Server.Mobiles
var args = $"{from.Name}\t{m_Creature.Name}\t{to.Name}";
from.SendLocalizedMessage(1043253, args); // You have transferred your pet to ~3_GETTER~.
to.SendLocalizedMessage(
1043252,
args
); // ~1_NAME~ has transferred the allegiance of ~2_PET_NAME~ to you.
// ~1_NAME~ has transferred the allegiance of ~2_PET_NAME~ to you.
to.SendLocalizedMessage(1043252, args);
}
}
}
@ -3004,7 +2991,7 @@ namespace Server.Mobiles
public AITimer(BaseAI owner)
: base(
TimeSpan.FromSeconds(Utility.RandomDouble()),
TimeSpan.FromSeconds(Utility.Random(128) * 8),
TimeSpan.FromSeconds(Math.Max(0.0, owner.m_Mobile.CurrentSpeed))
)
{

View file

@ -1,228 +1,50 @@
using System;
using System.Collections.Generic;
using Server.Factions;
using Server.Mobiles;
namespace Server
namespace Server;
public static class SpeedInfo
{
public class SpeedInfo
public static double MinDelay { get; private set; }
public static double MaxDelay { get; private set; }
public static double MinMonsterDelay { get; private set; }
public static double MaxMonsterDelay { get; private set; }
// Determines the maximum dex for delay by dex
public static int MaxDex { get; private set; }
public static int MaxMonsterDex { get; private set; }
public static void Configure()
{
// Should we use the new method of speeds?
private static readonly bool Enabled = true;
// Default speed determined by dex (0 -> 190) for non-monster NPCs including pets
MinDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.npcMinDelay", 0.1);
MaxDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.npcMaxDelay", 0.5);
MaxDex = ServerConfiguration.GetOrUpdateSetting("movement.delay.maxDex", 190);
private static Dictionary<Type, SpeedInfo> m_Table;
// Default speed determined by dex (0 -> 150) for monsters
MinMonsterDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.monsterMinDelay", 0.4);
MaxMonsterDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.monsterMaxDelay", 0.8);
MaxMonsterDex = ServerConfiguration.GetOrUpdateSetting("movement.delay.monsterMaxDex", 150);
}
private static readonly SpeedInfo[] m_Speeds =
public static void GetSpeeds(BaseCreature bc, out double activeSpeed, out double passiveSpeed)
{
var isMonster = bc.IsMonster;
var monsterDelay = isMonster || bc.InActivePVPCombat();
var maxDex = isMonster ? MaxMonsterDex : MaxDex;
var dex = Math.Clamp(bc.Dex, 25, maxDex);
double min = monsterDelay ? MinMonsterDelay : MinDelay;
double max = monsterDelay ? MaxMonsterDelay : MaxDelay;
if (bc.IsParagon)
{
/* Slow */
new(
0.3,
0.6,
new[]
{
typeof(AntLion), typeof(ArcticOgreLord), typeof(BogThing),
typeof(Bogle), typeof(BoneKnight), typeof(EarthElemental),
typeof(Ettin), typeof(FrostOoze), typeof(FrostTroll),
typeof(GazerLarva), typeof(Ghoul), typeof(Golem),
typeof(HeadlessOne), typeof(Jwilson), typeof(Mummy),
typeof(Ogre), typeof(OgreLord), typeof(PlagueBeast),
typeof(Quagmire), typeof(Rat), typeof(RottingCorpse),
typeof(SewerRat), typeof(Skeleton), typeof(Slime),
typeof(Zombie), typeof(Walrus), typeof(RestlessSoul),
typeof(CrystalElemental), typeof(DarknightCreeper), typeof(MoundOfMaggots),
typeof(Juggernaut), typeof(Yamandon), typeof(Serado)
}
),
/* Fast */
new(
0.2,
0.4,
new[]
{
typeof(LordOaks), typeof(Silvani), typeof(AirElemental),
typeof(AncientWyrm), typeof(Balron), typeof(BladeSpirits),
typeof(DreadSpider), typeof(Efreet), typeof(EtherealWarrior),
typeof(Lich), typeof(Nightmare), typeof(OphidianArchmage),
typeof(OphidianMage), typeof(OphidianWarrior), typeof(OphidianMatriarch),
typeof(OphidianKnight), typeof(PoisonElemental), typeof(Revenant),
typeof(SandVortex), typeof(SavageRider), typeof(SavageShaman),
typeof(SnowElemental), typeof(WhiteWyrm), typeof(Wisp),
typeof(DemonKnight), typeof(GiantBlackWidow), typeof(SummonedAirElemental),
typeof(LesserHiryu), typeof(Hiryu), typeof(LadyOfTheSnow),
typeof(RaiJu), typeof(Ronin), typeof(RuneBeetle),
typeof(Changeling), typeof(LadyJennifyr), typeof(LadyMarai), typeof(MasterJonath),
typeof(MasterMikael), typeof(MasterTheophilus), typeof(RedDeath),
typeof(SirPatrick), typeof(Miasma), typeof(Rend),
typeof(Grobu), typeof(Gnaw), typeof(Guile),
typeof(Irk), typeof(Spite), typeof(LadyLissith),
typeof(LadySabrix), typeof(Malefic), typeof(Silk),
typeof(Virulent)
// TODO: Where to put Lurg, Putrefier, Swoop and Pyre? They seem slower.
}
),
/* Very Fast */
new(
0.175,
0.350,
new[]
{
typeof(Barracoon), typeof(Mephitis), typeof(Neira),
typeof(Rikktor), typeof(Semidar), typeof(EnergyVortex),
typeof(EliteNinja), typeof(Pixie), typeof(SilverSerpent),
typeof(VorpalBunny), typeof(FleshRenderer), typeof(KhaldunRevenant),
typeof(FactionDragoon), typeof(FactionKnight), typeof(FactionPaladin),
typeof(FactionHenchman), typeof(FactionMercenary), typeof(FactionNecromancer),
typeof(FactionSorceress), typeof(FactionWizard), typeof(FactionBerserker),
typeof(FactionPaladin), typeof(Leviathan), typeof(FireBeetle),
typeof(FanDancer), typeof(FactionDeathKnight)
}
),
/* Medium */
new(
0.25,
0.5,
new[]
{
typeof(AcidElemental), typeof(AgapiteElemental), typeof(Alligator),
typeof(AncientLich), typeof(Betrayer), typeof(Bird),
typeof(BlackBear), typeof(BlackSolenInfiltratorQueen), typeof(BlackSolenInfiltratorWarrior),
typeof(BlackSolenQueen), typeof(BlackSolenWarrior), typeof(BlackSolenWorker),
typeof(BloodElemental), typeof(Boar), typeof(Bogling),
typeof(BoneMagi), typeof(Brigand), typeof(BronzeElemental),
typeof(BrownBear), typeof(Bull), typeof(BullFrog),
typeof(Cat), typeof(Centaur), typeof(ChaosDaemon),
typeof(Chicken), typeof(GolemController), typeof(CopperElemental),
typeof(CopperElemental), typeof(Cougar), typeof(Cow),
typeof(Cyclops), typeof(Daemon), typeof(DeepSeaSerpent),
typeof(DesertOstard), typeof(DireWolf), typeof(Dog),
typeof(Dolphin), typeof(Dragon), typeof(Drake),
typeof(DullCopperElemental), typeof(Eagle), typeof(ElderGazer),
typeof(EvilMage), typeof(EvilMageLord), typeof(Executioner),
typeof(Savage), typeof(FireElemental), typeof(FireGargoyle),
typeof(FireSteed), typeof(ForestOstard), typeof(FrenziedOstard),
typeof(FrostSpider), typeof(Gargoyle), typeof(Gazer),
typeof(IceSerpent), typeof(GiantRat), typeof(GiantSerpent),
typeof(GiantSpider), typeof(GiantToad), typeof(Goat),
typeof(GoldenElemental), typeof(Gorilla), typeof(GreatHart),
typeof(GreyWolf), typeof(GrizzlyBear), typeof(Guardian),
typeof(Harpy), typeof(Harrower), typeof(HellHound),
typeof(Hind), typeof(HordeMinion), typeof(Horse),
typeof(Horse), typeof(IceElemental), typeof(IceFiend),
typeof(IceSnake), typeof(Imp), typeof(JackRabbit),
typeof(Kirin), typeof(Kraken), typeof(PredatorHellCat),
typeof(LavaLizard), typeof(LavaSerpent), typeof(LavaSnake),
typeof(Lizardman), typeof(Llama), typeof(Mongbat),
typeof(StrongMongbat), typeof(MountainGoat), typeof(Orc),
typeof(OrcBomber), typeof(OrcBrute), typeof(OrcCaptain),
typeof(OrcishLord), typeof(OrcishMage), typeof(PackHorse),
typeof(PackLlama), typeof(Panther), typeof(Pig),
typeof(PlagueSpawn), typeof(PolarBear), typeof(Rabbit),
typeof(Ratman), typeof(RatmanArcher), typeof(RatmanMage),
typeof(RedSolenInfiltratorQueen), typeof(RedSolenInfiltratorWarrior), typeof(RedSolenQueen),
typeof(RedSolenWarrior), typeof(RedSolenWorker), typeof(RidableLlama),
typeof(Ridgeback), typeof(Scorpion), typeof(SeaSerpent),
typeof(SerpentineDragon), typeof(Shade), typeof(ShadowIronElemental),
typeof(ShadowWisp), typeof(ShadowWyrm), typeof(Sheep),
typeof(SilverSteed), typeof(SkeletalDragon), typeof(SkeletalMage),
typeof(SkeletalMount), typeof(HellCat), typeof(Snake),
typeof(SnowLeopard), typeof(SpectralArmour), typeof(Spectre),
typeof(StoneGargoyle), typeof(StoneHarpy), typeof(SwampDragon),
typeof(ScaledSwampDragon), typeof(SwampTentacle), typeof(TerathanAvenger),
typeof(TerathanDrone), typeof(TerathanMatriarch), typeof(TerathanWarrior),
typeof(TimberWolf), typeof(Titan), typeof(Troll),
typeof(Unicorn), typeof(ValoriteElemental), typeof(VeriteElemental),
typeof(CoMWarHorse), typeof(MinaxWarHorse), typeof(SLWarHorse),
typeof(TBWarHorse), typeof(WaterElemental), typeof(WhippingVine),
typeof(WhiteWolf), typeof(Wraith), typeof(Wyvern),
typeof(KhaldunZealot), typeof(KhaldunSummoner), typeof(SavageRidgeback),
typeof(LichLord), typeof(SkeletalKnight), typeof(SummonedDaemon),
typeof(SummonedEarthElemental), typeof(SummonedWaterElemental), typeof(SummonedFireElemental),
typeof(MeerWarrior), typeof(MeerEternal), typeof(MeerMage),
typeof(MeerCaptain), typeof(JukaLord), typeof(JukaMage),
typeof(JukaWarrior), typeof(AbysmalHorror), typeof(BoneDemon),
typeof(Devourer), typeof(FleshGolem), typeof(Gibberling),
typeof(GoreFiend), typeof(Impaler), typeof(PatchworkSkeleton),
typeof(Ravager), typeof(ShadowKnight), typeof(SkitteringHopper),
typeof(Treefellow), typeof(VampireBat), typeof(WailingBanshee),
typeof(WandererOfTheVoid), typeof(Cursed), typeof(GrimmochDrummel),
typeof(LysanderGathenwale), typeof(MorgBergen), typeof(ShadowFiend),
typeof(SpectralArmour), typeof(TavaraSewel), typeof(ArcaneDaemon),
typeof(Doppleganger), typeof(EnslavedGargoyle), typeof(ExodusMinion),
typeof(ExodusOverseer), typeof(GargoyleDestroyer), typeof(GargoyleEnforcer),
typeof(Moloch), typeof(BakeKitsune), typeof(DeathwatchBeetleHatchling),
typeof(Kappa), typeof(KazeKemono), typeof(DeathwatchBeetle),
typeof(TsukiWolf), typeof(YomotsuElder), typeof(YomotsuPriest),
typeof(YomotsuWarrior), typeof(RevenantLion), typeof(Oni),
typeof(Gaman), typeof(Crane), typeof(Beetle)
}
)
};
public SpeedInfo(double activeSpeed, double passiveSpeed, Type[] types)
{
ActiveSpeed = activeSpeed;
PassiveSpeed = passiveSpeed;
Types = types;
min /= 2;
max = min + 0.5;
}
public double ActiveSpeed { get; set; }
public double PassiveSpeed { get; set; }
public Type[] Types { get; set; }
public static bool Contains(object obj)
{
if (!Enabled)
{
return false;
}
if (m_Table == null)
{
LoadTable();
}
return m_Table!.ContainsKey(obj.GetType());
}
public static bool GetSpeeds(object obj, ref double activeSpeed, ref double passiveSpeed)
{
if (!Enabled)
{
return false;
}
if (m_Table == null)
{
LoadTable();
}
if (!m_Table!.TryGetValue(obj.GetType(), out var sp))
{
return false;
}
activeSpeed = sp.ActiveSpeed;
passiveSpeed = sp.PassiveSpeed;
return true;
}
private static void LoadTable()
{
m_Table = new Dictionary<Type, SpeedInfo>();
for (var i = 0; i < m_Speeds.Length; ++i)
{
var info = m_Speeds[i];
var types = info.Types;
for (var j = 0; j < types.Length; ++j)
{
m_Table[types[j]] = info;
}
}
}
activeSpeed = Math.Max(max - (max - min) * ((double)dex / maxDex), min);
passiveSpeed = activeSpeed * 2;
}
}