From 8f88de68a7cd84c1a9b2b383dbcc7c4c5a2dd759 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 18 Jul 2025 17:50:32 -0700 Subject: [PATCH] fix: Standardizes the variables for AI (#2234) --- .../Factions/Mobiles/Guards/GuardAI.cs | 94 +- .../Mobiles/AI/AIControlMobileTarget.cs | 14 +- Projects/UOContent/Mobiles/AI/AnimalAI.cs | 74 +- Projects/UOContent/Mobiles/AI/ArcherAI.cs | 62 +- Projects/UOContent/Mobiles/AI/BaseAI.cs | 1298 ++++++++--------- Projects/UOContent/Mobiles/AI/BerserkAI.cs | 50 +- Projects/UOContent/Mobiles/AI/HealerAI.cs | 75 +- Projects/UOContent/Mobiles/AI/MageAI.cs | 574 ++++---- Projects/UOContent/Mobiles/AI/MeleeAI.cs | 106 +- .../UOContent/Mobiles/AI/OppositionGroup.cs | 8 +- Projects/UOContent/Mobiles/AI/PredatorAI.cs | 52 +- Projects/UOContent/Mobiles/AI/ThiefAI.cs | 96 +- Projects/UOContent/Mobiles/AI/VendorAI.cs | 58 +- Projects/UOContent/Mobiles/BaseCreature.cs | 4 +- .../UOContent/Spells/Ninjitsu/MirrorImage.cs | 6 +- 15 files changed, 1284 insertions(+), 1287 deletions(-) diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs index 804ddbef7..85662a887 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -234,26 +234,26 @@ namespace Server.Factions public Mobile FindDispelTarget(bool activeOnly) { - if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel) + if (Mobile.Deleted || Mobile.Int < 95 || CanDispel(Mobile) || Mobile.AutoDispel) { return null; } if (activeOnly) { - var aggressed = m_Mobile.Aggressed; - var aggressors = m_Mobile.Aggressors; + var aggressed = Mobile.Aggressed; + var aggressors = Mobile.Aggressors; Mobile active = null; var activePrio = 0.0; - var comb = m_Mobile.Combatant; + var comb = Mobile.Combatant; - if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, 12) && + if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && Mobile.InRange(comb, 12) && CanDispel(comb)) { active = comb; - activePrio = m_Mobile.GetDistanceToSqrt(comb); + activePrio = Mobile.GetDistanceToSqrt(comb); if (activePrio <= 2) { @@ -266,9 +266,9 @@ namespace Server.Factions var info = aggressed[i]; var m = info.Defender; - if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m)) + if (m != comb && m.Combatant == Mobile && Mobile.InRange(m, 12) && CanDispel(m)) { - var prio = m_Mobile.GetDistanceToSqrt(m); + var prio = Mobile.GetDistanceToSqrt(m); if (active == null || prio < activePrio) { @@ -288,9 +288,9 @@ namespace Server.Factions var info = aggressors[i]; var m = info.Attacker; - if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m)) + if (m != comb && m.Combatant == Mobile && Mobile.InRange(m, 12) && CanDispel(m)) { - var prio = m_Mobile.GetDistanceToSqrt(m); + var prio = Mobile.GetDistanceToSqrt(m); if (active == null || prio < activePrio) { @@ -308,26 +308,26 @@ namespace Server.Factions return active; } - var map = m_Mobile.Map; + var map = Mobile.Map; if (map != null) { Mobile active = null, inactive = null; double actPrio = 0.0, inactPrio = 0.0; - var comb = m_Mobile.Combatant; + var comb = Mobile.Combatant; if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb)) { active = inactive = comb; - actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb); + actPrio = inactPrio = Mobile.GetDistanceToSqrt(comb); } - foreach (var m in m_Mobile.GetMobilesInRange(12)) + foreach (var m in Mobile.GetMobilesInRange(12)) { - if (m != m_Mobile && CanDispel(m)) + if (m != Mobile && CanDispel(m)) { - var prio = m_Mobile.GetDistanceToSqrt(m); + var prio = Mobile.GetDistanceToSqrt(m); if (inactive == null || prio < inactPrio) { @@ -335,7 +335,7 @@ namespace Server.Factions inactPrio = prio; } - if ((m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio)) + if ((Mobile.Combatant == m || m.Combatant == Mobile) && (active == null || prio < actPrio)) { active = m; actPrio = prio; @@ -350,7 +350,7 @@ namespace Server.Factions } public bool CanDispel(Mobile m) => - m is BaseCreature creature && creature.Summoned && m_Mobile.CanBeHarmful(creature, false) && + m is BaseCreature creature && creature.Summoned && Mobile.CanBeHarmful(creature, false) && !creature.IsAnimatedDead; public void RunTo(Mobile m) @@ -364,14 +364,14 @@ namespace Server.Factions } else {*/ - if (!m_Mobile.InRange(m, m_Mobile.RangeFight)) + if (!Mobile.InRange(m, Mobile.RangeFight)) { if (!MoveTo(m, true, 1)) { OnFailedMove(); } } - else if (m_Mobile.InRange(m, m_Mobile.RangeFight - 1)) + else if (Mobile.InRange(m, Mobile.RangeFight - 1)) { RunFrom(m); } @@ -381,7 +381,7 @@ namespace Server.Factions public void RunFrom(Mobile m) { - Run((m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask); + Run((Mobile.GetDirectionTo(m) - 4) & Direction.Mask); } public void OnFailedMove() @@ -396,33 +396,33 @@ namespace Server.Factions m_Mobile.DebugSay( "I am stuck, I'm going to try teleporting away" ); } else*/ - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"My move is blocked, so I am going to attack {m_Mobile.FocusMob.Name}"); + Mobile.DebugSay($"My move is blocked, so I am going to attack {Mobile.FocusMob.Name}"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } - else if (m_Mobile.Debug) + else if (Mobile.Debug) { - m_Mobile.DebugSay("I am stuck"); + Mobile.DebugSay("I am stuck"); } } public void Run(Direction d) { - if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen || - m_Mobile.DisallowAllMoves) + if (Mobile.Spell?.IsCasting == true || Mobile.Paralyzed || Mobile.Frozen || + Mobile.DisallowAllMoves) { return; } - m_Mobile.Direction = d | Direction.Running; + Mobile.Direction = d | Direction.Running; - if (!DoMove(m_Mobile.Direction, true)) + if (!DoMove(Mobile.Direction, true)) { OnFailedMove(); } @@ -430,7 +430,7 @@ namespace Server.Factions public override bool Think() { - if (m_Mobile.Deleted) + if (Mobile.Deleted) { return false; } @@ -438,32 +438,32 @@ namespace Server.Factions var combatant = m_Guard.Combatant; if (combatant?.Deleted != false || !combatant.Alive || combatant.IsDeadBondedPet || - !m_Mobile.CanSee(combatant) || !m_Mobile.CanBeHarmful(combatant, false) || combatant.Map != m_Mobile.Map) + !Mobile.CanSee(combatant) || !Mobile.CanBeHarmful(combatant, false) || combatant.Map != Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - m_Mobile.Combatant = combatant = m_Mobile.FocusMob; - m_Mobile.FocusMob = null; + Mobile.Combatant = combatant = Mobile.FocusMob; + Mobile.FocusMob = null; } else { - m_Mobile.Combatant = combatant = null; + Mobile.Combatant = combatant = null; } } - if (combatant != null && (!m_Mobile.InLOS(combatant) || !m_Mobile.InRange(combatant, 12))) + if (combatant != null && (!Mobile.InLOS(combatant) || !Mobile.InRange(combatant, 12))) { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - m_Mobile.Combatant = combatant = m_Mobile.FocusMob; - m_Mobile.FocusMob = null; + Mobile.Combatant = combatant = Mobile.FocusMob; + Mobile.FocusMob = null; } - else if (!m_Mobile.InRange(combatant, 36)) + else if (!Mobile.InRange(combatant, 36)) { - m_Mobile.Combatant = combatant = null; + Mobile.Combatant = combatant = null; } } @@ -544,7 +544,7 @@ namespace Server.Factions Action = ActionType.Combat; } - m_Mobile.SetCurrentSpeedToActive(); + Mobile.SetCurrentSpeedToActive(); m_Guard.Warmode = true; RunTo(toFollow); @@ -556,7 +556,7 @@ namespace Server.Factions Action = ActionType.Wander; } - m_Mobile.SetCurrentSpeedToPassive(); + Mobile.SetCurrentSpeedToPassive(); m_Guard.Warmode = false; WalkRandomInHome(2, 2, 1); @@ -582,9 +582,9 @@ namespace Server.Factions } } - var spell = m_Mobile.Spell as Spell; + var spell = Mobile.Spell as Spell; - if (spell == null && Core.TickCount - m_Mobile.NextSpellTime >= 0) + if (spell == null && Core.TickCount - Mobile.NextSpellTime >= 0) { var toRelease = DateTime.MinValue; diff --git a/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs b/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs index 063fc5221..6e12837e4 100644 --- a/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs +++ b/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs @@ -6,7 +6,7 @@ namespace Server.Targets; public class AIControlMobileTarget : Target { - private readonly List m_List; + private readonly List _list; public AIControlMobileTarget(BaseAI ai, OrderType order) : base( -1, @@ -14,7 +14,7 @@ public class AIControlMobileTarget : Target order == OrderType.Attack ? TargetFlags.Harmful : TargetFlags.None ) { - m_List = new List(); + _list = new List(); Order = order; AddAI(ai); @@ -24,9 +24,9 @@ public class AIControlMobileTarget : Target public void AddAI(BaseAI ai) { - if (!m_List.Contains(ai)) + if (!_list.Contains(ai)) { - m_List.Add(ai); + _list.Add(ai); } } @@ -34,10 +34,10 @@ public class AIControlMobileTarget : Target { if (o is Mobile m) { - for (var i = 0; i < m_List.Count; ++i) + for (var i = 0; i < _list.Count; ++i) { - m_List[i].EndPickTarget(from, m, Order); + _list[i].EndPickTarget(from, m, Order); } } } -} \ No newline at end of file +} diff --git a/Projects/UOContent/Mobiles/AI/AnimalAI.cs b/Projects/UOContent/Mobiles/AI/AnimalAI.cs index 8e3da75df..481b22747 100644 --- a/Projects/UOContent/Mobiles/AI/AnimalAI.cs +++ b/Projects/UOContent/Mobiles/AI/AnimalAI.cs @@ -19,25 +19,25 @@ public class AnimalAI : BaseAI { // New, only flee @ 10% - var hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax; + var hitPercent = (double)Mobile.Hits / Mobile.HitsMax; - if (!m_Mobile.Summoned && !m_Mobile.Controlled && hitPercent < 0.1 && m_Mobile.CanFlee) // Less than 10% health + if (!Mobile.Summoned && !Mobile.Controlled && hitPercent < 0.1 && Mobile.CanFlee) // Less than 10% health { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am low on health!"); + Mobile.DebugSay("I am low on health!"); } Action = ActionType.Flee; } - else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + else if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else @@ -50,52 +50,52 @@ public class AnimalAI : BaseAI public override bool DoActionCombat() { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone!"); + Mobile.DebugSay("My combatant is gone!"); } Action = ActionType.Wander; return true; } - if (!WalkMobileRange(combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight)) + if (!WalkMobileRange(combatant, 1, true, Mobile.RangeFight, Mobile.RangeFight)) { - if (m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) + if (Mobile.GetDistanceToSqrt(combatant) > Mobile.RangePerception + 1) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I cannot find {combatant.Name}"); + Mobile.DebugSay($"I cannot find {combatant.Name}"); } Action = ActionType.Wander; return true; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I should be closer to {combatant.Name}"); + Mobile.DebugSay($"I should be closer to {combatant.Name}"); } } - else if (Core.TickCount - m_Mobile.LastMoveTime > 400) + else if (Core.TickCount - Mobile.LastMoveTime > 400) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); + Mobile.Direction = Mobile.GetDirectionTo(combatant); } - if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee) + if (!Mobile.Controlled && !Mobile.Summoned && Mobile.CanFlee) { - var hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax; + var hitPercent = (double)Mobile.Hits / Mobile.HitsMax; if (hitPercent <= 0.1) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am low on health!"); + Mobile.DebugSay("I am low on health!"); } Action = ActionType.Flee; @@ -103,11 +103,11 @@ public class AnimalAI : BaseAI } } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); } } @@ -116,19 +116,19 @@ public class AnimalAI : BaseAI public override bool DoActionBackoff() { - var hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax; + var hitPercent = (double)Mobile.Hits / Mobile.HitsMax; - if (!m_Mobile.Summoned && !m_Mobile.Controlled && hitPercent < 0.1 && m_Mobile.CanFlee) // Less than 10% health + if (!Mobile.Summoned && !Mobile.Controlled && hitPercent < 0.1 && Mobile.CanFlee) // Less than 10% health { Action = ActionType.Flee; } - else if (AcquireFocusMob(m_Mobile.RangePerception * 2, FightMode.Closest, true, false, true)) + else if (AcquireFocusMob(Mobile.RangePerception * 2, FightMode.Closest, true, false, true)) { - if (WalkMobileRange(m_Mobile.FocusMob, 1, false, m_Mobile.RangePerception, m_Mobile.RangePerception * 2)) + if (WalkMobileRange(Mobile.FocusMob, 1, false, Mobile.RangePerception, Mobile.RangePerception * 2)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Well, here I am safe"); + Mobile.DebugSay("Well, here I am safe"); } Action = ActionType.Wander; @@ -136,9 +136,9 @@ public class AnimalAI : BaseAI } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost my focus, lets relax"); + Mobile.DebugSay("I have lost my focus, lets relax"); } Action = ActionType.Wander; @@ -149,9 +149,9 @@ public class AnimalAI : BaseAI public override bool DoActionFlee() { - AcquireFocusMob(m_Mobile.RangePerception * 2, m_Mobile.FightMode, true, false, true); + AcquireFocusMob(Mobile.RangePerception * 2, Mobile.FightMode, true, false, true); - m_Mobile.FocusMob ??= m_Mobile.Combatant; + Mobile.FocusMob ??= Mobile.Combatant; return base.DoActionFlee(); } diff --git a/Projects/UOContent/Mobiles/AI/ArcherAI.cs b/Projects/UOContent/Mobiles/AI/ArcherAI.cs index ad6788952..660ca702f 100644 --- a/Projects/UOContent/Mobiles/AI/ArcherAI.cs +++ b/Projects/UOContent/Mobiles/AI/ArcherAI.cs @@ -11,19 +11,19 @@ public class ArcherAI : BaseAI public override bool DoActionWander() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have no combatant"); + Mobile.DebugSay("I have no combatant"); } - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name} and I will attack"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name} and I will attack"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else @@ -36,62 +36,62 @@ public class ArcherAI : BaseAI public override bool DoActionCombat() { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone, so my guard is up"); + Mobile.DebugSay("My combatant is gone, so my guard is up"); } Action = ActionType.Guard; return true; } - if (Core.TickCount - m_Mobile.LastMoveTime > 1000 && !WalkMobileRange( + if (Core.TickCount - Mobile.LastMoveTime > 1000 && !WalkMobileRange( combatant, 1, true, - m_Mobile.RangeFight, - m_Mobile.Weapon.MaxRange + Mobile.RangeFight, + Mobile.Weapon.MaxRange )) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am still not in range of {combatant.Name}"); + Mobile.DebugSay($"I am still not in range of {combatant.Name}"); } - if ((int)m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) + if ((int)Mobile.GetDistanceToSqrt(combatant) > Mobile.RangePerception + 1) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have lost {combatant.Name}"); + Mobile.DebugSay($"I have lost {combatant.Name}"); } - m_Mobile.Combatant = null; + Mobile.Combatant = null; Action = ActionType.Guard; return true; } } - else if (Core.TickCount - m_Mobile.LastMoveTime > 400) + else if (Core.TickCount - Mobile.LastMoveTime > 400) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); + Mobile.Direction = Mobile.GetDirectionTo(combatant); } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); } return true; } // When we have no ammo, we flee - var pack = m_Mobile.Backpack; + var pack = Mobile.Backpack; if (pack?.FindItemByType() == null) { @@ -100,10 +100,10 @@ public class ArcherAI : BaseAI } // At 20% we should check if we must leave - if (m_Mobile.Combatant != null && m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 && m_Mobile.CanFlee) + if (Mobile.Combatant != null && Mobile.Hits < Mobile.HitsMax * 20 / 100 && Mobile.CanFlee) { // 10% to flee + the diff of hits - var fleeChance = 10 + Math.Max(0, m_Mobile.Combatant.Hits - m_Mobile.Hits); + var fleeChance = 10 + Math.Max(0, Mobile.Combatant.Hits - Mobile.Hits); if (Utility.Random(0, 100) > fleeChance) { @@ -116,14 +116,14 @@ public class ArcherAI : BaseAI public override bool DoActionGuard() { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index a77e36d8f..8ddf00d32 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -44,7 +44,7 @@ public abstract class BaseAI { // How many milliseconds until our next move can we consider it ok to move without deferring/blocking. private const int FuzzyTimeUntilNextMove = 24; - private static readonly SkillName[] m_KeywordTable = + private static readonly SkillName[] _keywordTable = { SkillName.Parry, SkillName.Healing, @@ -96,21 +96,21 @@ public abstract class BaseAI SkillName.Meditation }; - protected ActionType m_Action; + protected ActionType _action; - public readonly BaseCreature m_Mobile; + public BaseCreature Mobile { get; } - private long m_NextDetectHidden; - private long m_NextStopGuard; + private long _nextDetectHidden; + private long _nextStopGuard; - protected PathFollower m_Path; - public Timer m_Timer; + protected PathFollower _path; + public Timer _timer; public BaseAI(BaseCreature m) { - m_Mobile = m; + Mobile = m; - m_Timer = new AITimer(this); + _timer = new AITimer(this); bool activate; @@ -133,7 +133,7 @@ public abstract class BaseAI if (activate) { - m_Timer.Start(); + _timer.Start(); } Action = ActionType.Wander; @@ -141,40 +141,40 @@ public abstract class BaseAI public ActionType Action { - get => m_Action; + get => _action; set { - m_Action = value; + _action = value; OnActionChanged(); } } public long NextMove { get; set; } - public virtual bool CanDetectHidden => m_Mobile.Skills.DetectHidden.Value > 0; + public virtual bool CanDetectHidden => Mobile.Skills.DetectHidden.Value > 0; public virtual bool WasNamed(string speech) { - var name = m_Mobile.Name; + var name = Mobile.Name; return name != null && speech.InsensitiveStartsWith(name); } public virtual void GetContextMenuEntries(Mobile from, ref PooledRefList list) { - if (!from.Alive || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14)) + if (!from.Alive || !Mobile.Controlled || !from.InRange(Mobile, 14)) { return; } - var isDeadPet = m_Mobile.IsDeadPet; + var isDeadPet = Mobile.IsDeadPet; - if (from == m_Mobile.ControlMaster) + if (from == Mobile.ControlMaster) { list.Add(new InternalEntry(6107, 14, OrderType.Guard, !isDeadPet)); // Command: Guard list.Add(new InternalEntry(6108, 14, OrderType.Follow, true)); // Command: Follow - if (m_Mobile.CanDrop) + if (Mobile.CanDrop) { list.Add(new InternalEntry(6109, 14, OrderType.Drop, !isDeadPet)); // Command: Drop } @@ -184,7 +184,7 @@ public abstract class BaseAI list.Add(new InternalEntry(6112, 14, OrderType.Stop, true)); // Command: Stop list.Add(new InternalEntry(6114, 14, OrderType.Stay, true)); // Command: Stay - if (!m_Mobile.Summoned && m_Mobile is not GrizzledMare) + if (!Mobile.Summoned && Mobile is not GrizzledMare) { list.Add(new InternalEntry(6110, 14, OrderType.Friend, true)); // Add Friend list.Add(new InternalEntry(6099, 14, OrderType.Unfriend, true)); // Remove Friend @@ -193,7 +193,7 @@ public abstract class BaseAI list.Add(new InternalEntry(6118, 14, OrderType.Release, true)); // Release } - else if (m_Mobile.IsPetFriend(from)) + else if (Mobile.IsPetFriend(from)) { list.Add(new InternalEntry(6108, 14, OrderType.Follow, true)); // Command: Follow list.Add(new InternalEntry(6112, 14, OrderType.Stop, !isDeadPet)); // Command: Stop @@ -203,13 +203,13 @@ public abstract class BaseAI public virtual void BeginPickTarget(Mobile from, OrderType order) { - if (m_Mobile.Deleted || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map) + if (Mobile.Deleted || !Mobile.Controlled || !from.InRange(Mobile, 14) || from.Map != Mobile.Map) { return; } - var isOwner = from == m_Mobile.ControlMaster; - var isFriend = !isOwner && m_Mobile.IsPetFriend(from); + var isOwner = from == Mobile.ControlMaster; + var isFriend = !isOwner && Mobile.IsPetFriend(from); if (!isOwner && !isFriend) { @@ -249,25 +249,25 @@ public abstract class BaseAI public virtual void OnAggressiveAction(Mobile aggressor) { - var currentCombat = m_Mobile.Combatant; + var currentCombat = Mobile.Combatant; if (currentCombat != null && !aggressor.Hidden && currentCombat != aggressor && - m_Mobile.GetDistanceToSqrt(currentCombat) > m_Mobile.GetDistanceToSqrt(aggressor)) + Mobile.GetDistanceToSqrt(currentCombat) > Mobile.GetDistanceToSqrt(aggressor)) { - m_Mobile.Combatant = aggressor; + Mobile.Combatant = aggressor; } } public virtual void EndPickTarget(Mobile from, Mobile target, OrderType order) { - if (m_Mobile.Deleted || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map || + if (Mobile.Deleted || !Mobile.Controlled || !from.InRange(Mobile, 14) || from.Map != Mobile.Map || !from.CheckAlive()) { return; } - var isOwner = from == m_Mobile.ControlMaster; - var isFriend = !isOwner && m_Mobile.IsPetFriend(from); + var isOwner = from == Mobile.ControlMaster; + var isFriend = !isOwner && Mobile.IsPetFriend(from); if (!isOwner && !isFriend) { @@ -281,9 +281,9 @@ public abstract class BaseAI if (order == OrderType.Attack) { - if (target is BaseCreature creature && creature.IsScaryToPets && m_Mobile.IsScaredOfScaryThings) + if (target is BaseCreature creature && creature.IsScaryToPets && Mobile.IsScaredOfScaryThings) { - m_Mobile.SayTo(from, "Your pet refuses to attack this creature!"); + Mobile.SayTo(from, "Your pet refuses to attack this creature!"); return; } @@ -298,15 +298,15 @@ public abstract class BaseAI if (target is BaseFactionGuard) { - m_Mobile.SayTo(from, "Your pet refuses to attack the guard."); + Mobile.SayTo(from, "Your pet refuses to attack the guard."); return; } } - if (m_Mobile.CheckControlChance(from)) + if (Mobile.CheckControlChance(from)) { - m_Mobile.ControlTarget = target; - m_Mobile.ControlOrder = order; + Mobile.ControlTarget = target; + Mobile.ControlOrder = order; } } @@ -317,59 +317,59 @@ public abstract class BaseAI return true; } - if (from.Alive && m_Mobile.Controlled && m_Mobile.Commandable && - (from == m_Mobile.ControlMaster || m_Mobile.IsPetFriend(from))) + if (from.Alive && Mobile.Controlled && Mobile.Commandable && + (from == Mobile.ControlMaster || Mobile.IsPetFriend(from))) { return true; } - return from.Alive && from.InRange(m_Mobile.Location, 3) && m_Mobile.IsHumanInTown(); + return from.Alive && from.InRange(Mobile.Location, 3) && Mobile.IsHumanInTown(); } public virtual void OnSpeech(SpeechEventArgs e) { - if (e.Mobile.Alive && e.Mobile.InRange(m_Mobile.Location, 3) && m_Mobile.IsHumanInTown()) + if (e.Mobile.Alive && e.Mobile.InRange(Mobile.Location, 3) && Mobile.IsHumanInTown()) { if (e.HasKeyword(0x9D) && WasNamed(e.Speech)) // *move* { - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { // I am too busy fighting to deal with thee! - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); } else { // Excuse me? - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501516); + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501516); WalkRandomInHome(2, 2, 1); } } else if (e.HasKeyword(0x9E) && WasNamed(e.Speech)) // *time* { - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { // I am too busy fighting to deal with thee! - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); } else { - Clock.GetTime(m_Mobile, out var generalNumber, out _); + Clock.GetTime(Mobile, out var generalNumber, out _); - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, generalNumber); + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, generalNumber); } } else if (e.HasKeyword(0x6C) && WasNamed(e.Speech)) // *train { - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { // I am too busy fighting to deal with thee! - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); } else { var foundSomething = false; - var ourSkills = m_Mobile.Skills; + var ourSkills = Mobile.Skills; var theirSkills = e.Mobile.Skills; for (var i = 0; i < ourSkills.Length && i < theirSkills.Length; ++i) @@ -377,7 +377,7 @@ public abstract class BaseAI var skill = ourSkills[i]; var theirSkill = theirSkills[i]; - if (skill?.Base >= 60.0 && m_Mobile.CheckTeach(skill.SkillName, e.Mobile)) + if (skill?.Base >= 60.0 && Mobile.CheckTeach(skill.SkillName, e.Mobile)) { var toTeach = skill.Base / 3.0; @@ -397,10 +397,10 @@ public abstract class BaseAI if (!foundSomething) { - m_Mobile.Say(1043058); // I can train the following: + Mobile.Say(1043058); // I can train the following: } - m_Mobile.Say(number); + Mobile.Say(number); foundSomething = true; } @@ -409,7 +409,7 @@ public abstract class BaseAI if (!foundSomething) { - m_Mobile.Say(501505); // Alas, I cannot teach thee anything. + Mobile.Say(501505); // Alas, I cannot teach thee anything. } } } @@ -429,53 +429,53 @@ public abstract class BaseAI { var index = keyword - 0x6D; - if (index >= 0 && index < m_KeywordTable.Length) + if (index >= 0 && index < _keywordTable.Length) { - toTrain = m_KeywordTable[index]; + toTrain = _keywordTable[index]; } } } if (toTrain != (SkillName)(-1) && WasNamed(e.Speech)) { - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { // I am too busy fighting to deal with thee! - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 501482); } else { - var skills = m_Mobile.Skills; + var skills = Mobile.Skills; var skill = skills[toTrain]; - if (skill == null || skill.Base < 60.0 || !m_Mobile.CheckTeach(toTrain, e.Mobile)) + if (skill == null || skill.Base < 60.0 || !Mobile.CheckTeach(toTrain, e.Mobile)) { - m_Mobile.Say(501507); // 'Tis not something I can teach thee of. + Mobile.Say(501507); // 'Tis not something I can teach thee of. } else { - m_Mobile.Teach(toTrain, e.Mobile, 0, false); + Mobile.Teach(toTrain, e.Mobile, 0, false); } } } } } - if (m_Mobile.Controlled && m_Mobile.Commandable) + if (Mobile.Controlled && Mobile.Commandable) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Listening..."); + Mobile.DebugSay("Listening..."); } - var isOwner = e.Mobile == m_Mobile.ControlMaster; - var isFriend = !isOwner && m_Mobile.IsPetFriend(e.Mobile); + var isOwner = e.Mobile == Mobile.ControlMaster; + var isFriend = !isOwner && Mobile.IsPetFriend(e.Mobile); if (e.Mobile.Alive && (isOwner || isFriend)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("It's from my master"); + Mobile.DebugSay("It's from my master"); } var keywords = e.Keywords; @@ -495,10 +495,10 @@ public abstract class BaseAI break; } - if (m_Mobile.CheckControlChance(e.Mobile)) + if (Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Come; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Come; } return; @@ -516,20 +516,20 @@ public abstract class BaseAI break; } - if (m_Mobile.CheckControlChance(e.Mobile)) + if (Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Guard; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Guard; } return; } case 0x167: // all stop { - if (m_Mobile.CheckControlChance(e.Mobile)) + if (Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stop; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Stop; } return; @@ -547,20 +547,20 @@ public abstract class BaseAI } case 0x16C: // all follow me { - if (m_Mobile.CheckControlChance(e.Mobile)) + if (Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = e.Mobile; - m_Mobile.ControlOrder = OrderType.Follow; + Mobile.ControlTarget = e.Mobile; + Mobile.ControlOrder = OrderType.Follow; } return; } case 0x170: // all stay { - if (m_Mobile.CheckControlChance(e.Mobile)) + if (Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stay; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Stay; } return; @@ -582,10 +582,10 @@ public abstract class BaseAI break; } - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Come; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Come; } return; @@ -597,18 +597,18 @@ public abstract class BaseAI break; } - if (!m_Mobile.IsDeadPet && !m_Mobile.Summoned && WasNamed(speech) && - m_Mobile.CheckControlChance(e.Mobile)) + if (!Mobile.IsDeadPet && !Mobile.Summoned && WasNamed(speech) && + Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Drop; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Drop; } return; } case 0x15A: // *follow { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { BeginPickTarget(e.Mobile, OrderType.Follow); } @@ -622,9 +622,9 @@ public abstract class BaseAI break; } - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - if (m_Mobile.Summoned || m_Mobile is GrizzledMare) + if (Mobile.Summoned || Mobile is GrizzledMare) { // Summoned creatures are loyal only to their summoners. e.Mobile.SendLocalizedMessage(1005481); @@ -649,10 +649,10 @@ public abstract class BaseAI break; } - if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (!Mobile.IsDeadPet && WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Guard; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Guard; } return; @@ -665,7 +665,7 @@ public abstract class BaseAI break; } - if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (!Mobile.IsDeadPet && WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { BeginPickTarget(e.Mobile, OrderType.Attack); } @@ -679,30 +679,30 @@ public abstract class BaseAI break; } - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Patrol; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Patrol; } return; } case 0x161: // *stop { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stop; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Stop; } return; } case 0x163: // *follow me { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = e.Mobile; - m_Mobile.ControlOrder = OrderType.Follow; + Mobile.ControlTarget = e.Mobile; + Mobile.ControlOrder = OrderType.Follow; } return; @@ -714,16 +714,16 @@ public abstract class BaseAI break; } - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - if (!m_Mobile.Summoned) + if (!Mobile.Summoned) { - e.Mobile.SendGump(new ConfirmReleaseGump(e.Mobile, m_Mobile)); + e.Mobile.SendGump(new ConfirmReleaseGump(e.Mobile, Mobile)); } else { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Release; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Release; } } @@ -736,9 +736,9 @@ public abstract class BaseAI break; } - if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (!Mobile.IsDeadPet && WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - if (m_Mobile.Summoned || m_Mobile is GrizzledMare) + if (Mobile.Summoned || Mobile is GrizzledMare) { // You cannot transfer ownership of a summoned creature. e.Mobile.SendLocalizedMessage(1005487); @@ -758,10 +758,10 @@ public abstract class BaseAI } case 0x16F: // *stay { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + if (WasNamed(speech) && Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stay; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Stay; } return; @@ -774,12 +774,12 @@ public abstract class BaseAI { if (e.Mobile.AccessLevel >= AccessLevel.GameMaster) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("It's from a GM"); + Mobile.DebugSay("It's from a GM"); } - if (m_Mobile.FindMyName(e.Speech, true)) + if (Mobile.FindMyName(e.Speech, true)) { var str = e.Speech.Split(' '); int i; @@ -790,11 +790,11 @@ public abstract class BaseAI if (word.InsensitiveEquals("obey")) { - m_Mobile.SetControlMaster(e.Mobile); + Mobile.SetControlMaster(e.Mobile); - if (m_Mobile.Summoned) + if (Mobile.Summoned) { - m_Mobile.SummonMaster = e.Mobile; + Mobile.SummonMaster = e.Mobile; } return; @@ -807,7 +807,7 @@ public abstract class BaseAI public virtual bool Think() { - if (m_Mobile.Deleted) + if (Mobile.Deleted) { return false; } @@ -821,37 +821,37 @@ public abstract class BaseAI { case ActionType.Wander: { - m_Mobile.OnActionWander(); + Mobile.OnActionWander(); return DoActionWander(); } case ActionType.Combat: { - m_Mobile.OnActionCombat(); + Mobile.OnActionCombat(); return DoActionCombat(); } case ActionType.Guard: { - m_Mobile.OnActionGuard(); + Mobile.OnActionGuard(); return DoActionGuard(); } case ActionType.Flee: { - m_Mobile.OnActionFlee(); + Mobile.OnActionFlee(); return DoActionFlee(); } case ActionType.Interact: { - m_Mobile.OnActionInteract(); + Mobile.OnActionInteract(); return DoActionInteract(); } case ActionType.Backoff: { - m_Mobile.OnActionBackoff(); + Mobile.OnActionBackoff(); return DoActionBackoff(); } @@ -868,50 +868,50 @@ public abstract class BaseAI { case ActionType.Wander: { - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; - m_Mobile.FocusMob = null; - m_Mobile.SetCurrentSpeedToPassive(); + Mobile.Warmode = false; + Mobile.Combatant = null; + Mobile.FocusMob = null; + Mobile.SetCurrentSpeedToPassive(); break; } case ActionType.Combat: { - m_Mobile.Warmode = true; - m_Mobile.FocusMob = null; - m_Mobile.SetCurrentSpeedToActive(); + Mobile.Warmode = true; + Mobile.FocusMob = null; + Mobile.SetCurrentSpeedToActive(); break; } case ActionType.Guard: { - m_Mobile.Warmode = true; - m_Mobile.FocusMob = null; - m_Mobile.Combatant = null; - m_NextStopGuard = Core.TickCount + (int)TimeSpan.FromSeconds(10).TotalMilliseconds; - m_Mobile.SetCurrentSpeedToActive(); + Mobile.Warmode = true; + Mobile.FocusMob = null; + Mobile.Combatant = null; + _nextStopGuard = Core.TickCount + (int)TimeSpan.FromSeconds(10).TotalMilliseconds; + Mobile.SetCurrentSpeedToActive(); break; } case ActionType.Flee: { - m_Mobile.Warmode = true; - m_Mobile.FocusMob = null; - m_Mobile.SetCurrentSpeedToActive(); + Mobile.Warmode = true; + Mobile.FocusMob = null; + Mobile.SetCurrentSpeedToActive(); break; } case ActionType.Interact: { - m_Mobile.Warmode = false; - m_Mobile.SetCurrentSpeedToPassive(); + Mobile.Warmode = false; + Mobile.SetCurrentSpeedToPassive(); break; } case ActionType.Backoff: { - m_Mobile.Warmode = false; - m_Mobile.SetCurrentSpeedToPassive(); + Mobile.Warmode = false; + Mobile.SetCurrentSpeedToPassive(); break; } } @@ -923,44 +923,44 @@ public abstract class BaseAI { if (CheckHerding()) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Praise the shepherd!"); + Mobile.DebugSay("Praise the shepherd!"); } } - else if (m_Mobile.CurrentWayPoint != null) + else if (Mobile.CurrentWayPoint != null) { - var point = m_Mobile.CurrentWayPoint; - if ((point.X != m_Mobile.Location.X || point.Y != m_Mobile.Location.Y) && point.Map == m_Mobile.Map && + var point = Mobile.CurrentWayPoint; + if ((point.X != Mobile.Location.X || point.Y != Mobile.Location.Y) && point.Map == Mobile.Map && point.Parent == null && !point.Deleted) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I will move towards my waypoint."); + Mobile.DebugSay("I will move towards my waypoint."); } - DoMove(m_Mobile.GetDirectionTo(m_Mobile.CurrentWayPoint)); + DoMove(Mobile.GetDirectionTo(Mobile.CurrentWayPoint)); } else if (OnAtWayPoint()) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I will go to the next waypoint"); + Mobile.DebugSay("I will go to the next waypoint"); } - m_Mobile.CurrentWayPoint = point.NextPoint; + Mobile.CurrentWayPoint = point.NextPoint; if (point.NextPoint?.Deleted == true) { - m_Mobile.CurrentWayPoint = point.NextPoint = point.NextPoint.NextPoint; + Mobile.CurrentWayPoint = point.NextPoint = point.NextPoint.NextPoint; } } } - else if (m_Mobile.IsAnimatedDead) + else if (Mobile.IsAnimatedDead) { // animated dead follow their master - var master = m_Mobile.SummonMaster; + var master = Mobile.SummonMaster; - if (master != null && master.Map == m_Mobile.Map && master.InRange(m_Mobile, m_Mobile.RangePerception)) + if (master != null && master.Map == Mobile.Map && master.InRange(Mobile, Mobile.RangePerception)) { MoveTo(master, false, 1); } @@ -969,15 +969,15 @@ public abstract class BaseAI WalkRandomInHome(2, 2, 1); } } - else if (CheckMove() && CanMoveNow(out _) && !m_Mobile.CheckIdle()) + else if (CheckMove() && CanMoveNow(out _) && !Mobile.CheckIdle()) { WalkRandomInHome(2, 2, 1); } - if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) + if (Mobile.Combatant?.Deleted == false && Mobile.Combatant.Alive && + !Mobile.Combatant.IsDeadBondedPet) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); + Mobile.Direction = Mobile.GetDirectionTo(Mobile.Combatant); } return true; @@ -987,34 +987,34 @@ public abstract class BaseAI { if (Core.AOS && CheckHerding()) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Praise the shepherd!"); + Mobile.DebugSay("Praise the shepherd!"); } return true; } - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone!"); + Mobile.DebugSay("My combatant is gone!"); } Action = ActionType.Wander; return true; } - m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) + Mobile.Direction = Mobile.GetDirectionTo(combatant); + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); } } @@ -1025,24 +1025,24 @@ public abstract class BaseAI { if (Core.AOS && CheckHerding()) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Praise the shepherd!"); + Mobile.DebugSay("Praise the shepherd!"); } } - else if (Core.TickCount - m_NextStopGuard < 0) + else if (Core.TickCount - _nextStopGuard < 0) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am on guard"); + Mobile.DebugSay("I am on guard"); } // m_Mobile.Turn( Utility.Random(0, 2) - 1 ); } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I stopped being on guard"); + Mobile.DebugSay("I stopped being on guard"); } Action = ActionType.Wander; @@ -1053,33 +1053,33 @@ public abstract class BaseAI public virtual bool DoActionFlee() { - var from = m_Mobile.FocusMob; + var from = Mobile.FocusMob; - if (from?.Deleted != false || from.Map != m_Mobile.Map) + if (from?.Deleted != false || from.Map != Mobile.Map) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost him"); + Mobile.DebugSay("I have lost him"); } Action = ActionType.Guard; return true; } - if (WalkMobileRange(from, 1, true, m_Mobile.RangePerception * 2, m_Mobile.RangePerception * 3)) + if (WalkMobileRange(from, 1, true, Mobile.RangePerception * 2, Mobile.RangePerception * 3)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have fled"); + Mobile.DebugSay("I have fled"); } Action = ActionType.Guard; return true; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am fleeing!"); + Mobile.DebugSay("I am fleeing!"); } return true; @@ -1090,7 +1090,7 @@ public abstract class BaseAI public virtual bool DoActionBackoff() => true; public virtual bool Obey() => - !m_Mobile.Deleted && m_Mobile.ControlOrder switch + !Mobile.Deleted && Mobile.ControlOrder switch { OrderType.None => DoOrderNone(), OrderType.Come => DoOrderCome(), @@ -1110,133 +1110,133 @@ public abstract class BaseAI public virtual void OnCurrentOrderChanged() { - if (m_Mobile.Deleted || m_Mobile.ControlMaster?.Deleted != false) + if (Mobile.Deleted || Mobile.ControlMaster?.Deleted != false) { return; } - switch (m_Mobile.ControlOrder) + switch (Mobile.ControlOrder) { case OrderType.None: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.Home = m_Mobile.Location; - m_Mobile.SetCurrentSpeedToPassive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.Home = Mobile.Location; + Mobile.SetCurrentSpeedToPassive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Come: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToActive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToActive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Drop: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToPassive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToPassive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Friend: case OrderType.Unfriend: { - m_Mobile.ControlMaster.RevealingAction(); + Mobile.ControlMaster.RevealingAction(); break; } case OrderType.Guard: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToActive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = true; - m_Mobile.Combatant = null; - m_Mobile.ControlMaster.SendLocalizedMessage(1049671, m_Mobile.Name); // ~1_PETNAME~ is now guarding you. + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToActive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = true; + Mobile.Combatant = null; + Mobile.ControlMaster.SendLocalizedMessage(1049671, Mobile.Name); // ~1_PETNAME~ is now guarding you. break; } case OrderType.Attack: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToActive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToActive(); + Mobile.PlaySound(Mobile.GetIdleSound()); - m_Mobile.Warmode = true; - m_Mobile.Combatant = null; + Mobile.Warmode = true; + Mobile.Combatant = null; break; } case OrderType.Patrol: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToActive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToActive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Release: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToPassive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToPassive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Stay: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToPassive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToPassive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Stop: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.Home = m_Mobile.Location; - m_Mobile.SetCurrentSpeedToPassive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.ControlMaster.RevealingAction(); + Mobile.Home = Mobile.Location; + Mobile.SetCurrentSpeedToPassive(); + Mobile.PlaySound(Mobile.GetIdleSound()); + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Follow: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToActive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToActive(); + Mobile.PlaySound(Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.Warmode = false; + Mobile.Combatant = null; break; } case OrderType.Transfer: { - m_Mobile.ControlMaster.RevealingAction(); - m_Mobile.SetCurrentSpeedToPassive(); - m_Mobile.PlaySound(m_Mobile.GetIdleSound()); + Mobile.ControlMaster.RevealingAction(); + Mobile.SetCurrentSpeedToPassive(); + Mobile.PlaySound(Mobile.GetIdleSound()); - m_Mobile.Warmode = false; - m_Mobile.Combatant = null; + Mobile.Warmode = false; + Mobile.Combatant = null; break; } } @@ -1244,22 +1244,22 @@ public abstract class BaseAI public virtual bool DoOrderNone() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have no order"); + Mobile.DebugSay("I have no order"); } WalkRandomInHome(3, 2, 1); - if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) + if (Mobile.Combatant?.Deleted == false && Mobile.Combatant.Alive && + !Mobile.Combatant.IsDeadBondedPet) { - m_Mobile.Warmode = true; - m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); + Mobile.Warmode = true; + Mobile.Direction = Mobile.GetDirectionTo(Mobile.Combatant); } else { - m_Mobile.Warmode = false; + Mobile.Warmode = false; } return true; @@ -1267,44 +1267,44 @@ public abstract class BaseAI public virtual bool DoOrderCome() { - if (m_Mobile.ControlMaster?.Deleted != false) + if (Mobile.ControlMaster?.Deleted != false) { return true; } - var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlMaster); + var iCurrDist = (int)Mobile.GetDistanceToSqrt(Mobile.ControlMaster); - if (iCurrDist > m_Mobile.RangePerception) + if (iCurrDist > Mobile.RangePerception) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost my master. I stay here"); + Mobile.DebugSay("I have lost my master. I stay here"); } - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.None; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.None; } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My master told me come"); + Mobile.DebugSay("My master told me come"); } // Not exactly OSI style, but better than nothing. var bRun = iCurrDist > 5; - if (WalkMobileRange(m_Mobile.ControlMaster, 1, bRun, 0, 1)) + if (WalkMobileRange(Mobile.ControlMaster, 1, bRun, 0, 1)) { - if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) + if (Mobile.Combatant?.Deleted == false && Mobile.Combatant.Alive && + !Mobile.Combatant.IsDeadBondedPet) { - m_Mobile.Warmode = true; + Mobile.Warmode = true; // m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant, bRun); } else { - m_Mobile.Warmode = false; + Mobile.Warmode = false; } } } @@ -1314,17 +1314,17 @@ public abstract class BaseAI public virtual bool DoOrderDrop() { - if (m_Mobile.IsDeadPet || !m_Mobile.CanDrop) + if (Mobile.IsDeadPet || !Mobile.CanDrop) { return true; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I drop my stuff for my master"); + Mobile.DebugSay("I drop my stuff for my master"); } - var pack = m_Mobile.Backpack; + var pack = Mobile.Backpack; if (pack != null) { @@ -1334,37 +1334,37 @@ public abstract class BaseAI { if (i < list.Count) { - list[i].MoveToWorld(m_Mobile.Location, m_Mobile.Map); + list[i].MoveToWorld(Mobile.Location, Mobile.Map); } } } - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.None; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.None; return true; } public virtual bool CheckHerding() { - var target = m_Mobile.TargetLocation; + var target = Mobile.TargetLocation; if (target == null) { return false; // Creature is not being herded } - var distance = m_Mobile.GetDistanceToSqrt(target); + var distance = Mobile.GetDistanceToSqrt(target); if (distance is not (< 1 or > 15)) { - DoMove(m_Mobile.GetDirectionTo(target)); + DoMove(Mobile.GetDirectionTo(target)); return true; } - if (distance < 1 && target.X == 1076 && target.Y == 450 && m_Mobile is HordeMinionFamiliar) + if (distance < 1 && target.X == 1076 && target.Y == 450 && Mobile is HordeMinionFamiliar) { - if (m_Mobile.ControlMaster is PlayerMobile pm) + if (Mobile.ControlMaster is PlayerMobile pm) { var qs = pm.Quest; @@ -1374,14 +1374,14 @@ public abstract class BaseAI if (obj?.Completed == false) { - m_Mobile.AddToBackpack(new ScrollOfAbraxus()); + Mobile.AddToBackpack(new ScrollOfAbraxus()); obj.Complete(); } } } } - m_Mobile.TargetLocation = null; + Mobile.TargetLocation = null; return false; // At the target or too far away } @@ -1389,57 +1389,57 @@ public abstract class BaseAI { if (CheckHerding()) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Praise the shepherd!"); + Mobile.DebugSay("Praise the shepherd!"); } } - else if (m_Mobile.ControlTarget?.Deleted == false && m_Mobile.ControlTarget != m_Mobile) + else if (Mobile.ControlTarget?.Deleted == false && Mobile.ControlTarget != Mobile) { - var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlTarget); + var iCurrDist = (int)Mobile.GetDistanceToSqrt(Mobile.ControlTarget); - if (iCurrDist > m_Mobile.RangePerception) + if (iCurrDist > Mobile.RangePerception) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost the one to follow. I stay here"); + Mobile.DebugSay("I have lost the one to follow. I stay here"); } - if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) + if (Mobile.Combatant?.Deleted == false && Mobile.Combatant.Alive && + !Mobile.Combatant.IsDeadBondedPet) { - m_Mobile.Warmode = true; - m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); + Mobile.Warmode = true; + Mobile.Direction = Mobile.GetDirectionTo(Mobile.Combatant); } else { - m_Mobile.Warmode = false; + Mobile.Warmode = false; } } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"My master told me to follow: {m_Mobile.ControlTarget.Name}"); + Mobile.DebugSay($"My master told me to follow: {Mobile.ControlTarget.Name}"); } // Not exactly OSI style, but better than nothing. var bRun = iCurrDist > 5; - if (WalkMobileRange(m_Mobile.ControlTarget, 1, bRun, 0, 1)) + if (WalkMobileRange(Mobile.ControlTarget, 1, bRun, 0, 1)) { - if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) + if (Mobile.Combatant?.Deleted == false && Mobile.Combatant.Alive && + !Mobile.Combatant.IsDeadBondedPet) { - m_Mobile.Warmode = true; + Mobile.Warmode = true; // m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant, bRun); } else { - m_Mobile.Warmode = false; + Mobile.Warmode = false; if (Core.AOS) { - m_Mobile.CurrentSpeed = 0.1; + Mobile.CurrentSpeed = 0.1; } } } @@ -1447,13 +1447,13 @@ public abstract class BaseAI } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have nobody to follow"); + Mobile.DebugSay("I have nobody to follow"); } - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.None; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.None; } return true; @@ -1461,12 +1461,12 @@ public abstract class BaseAI public virtual bool DoOrderFriend() { - var from = m_Mobile.ControlMaster; - var to = m_Mobile.ControlTarget; + var from = Mobile.ControlMaster; + var to = Mobile.ControlTarget; if (from?.Deleted != false || to?.Deleted != false || from == to || !to.Player) { - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused* + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused* } else { @@ -1495,11 +1495,11 @@ public abstract class BaseAI { to.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending } - else if (m_Mobile.IsPetFriend(to)) + else if (Mobile.IsPetFriend(to)) { from.SendLocalizedMessage(1049691); // That person is already a friend. } - else if (!m_Mobile.AllowNewPetFriend) + else if (!Mobile.AllowNewPetFriend) { from.SendLocalizedMessage( 1005482 @@ -1508,17 +1508,17 @@ public abstract class BaseAI else { // ~1_NAME~ will now accept movement commands from ~2_NAME~. - from.SendLocalizedMessage(1049676, $"{m_Mobile.Name}\t{to.Name}"); + from.SendLocalizedMessage(1049676, $"{Mobile.Name}\t{to.Name}"); /* ~1_NAME~ has granted you the ability to give orders to their pet ~2_PET_NAME~. * This creature will now consider you as a friend. */ - to.SendLocalizedMessage(1043246, $"{from.Name}\t{m_Mobile.Name}"); + to.SendLocalizedMessage(1043246, $"{from.Name}\t{Mobile.Name}"); - m_Mobile.AddPetFriend(to); + Mobile.AddPetFriend(to); - m_Mobile.ControlTarget = to; - m_Mobile.ControlOrder = OrderType.Follow; + Mobile.ControlTarget = to; + Mobile.ControlOrder = OrderType.Follow; return true; } @@ -1526,59 +1526,59 @@ public abstract class BaseAI } } - m_Mobile.ControlTarget = from; - m_Mobile.ControlOrder = OrderType.Follow; + Mobile.ControlTarget = from; + Mobile.ControlOrder = OrderType.Follow; return true; } public virtual bool DoOrderUnfriend() { - var from = m_Mobile.ControlMaster; - var to = m_Mobile.ControlTarget; + var from = Mobile.ControlMaster; + var to = Mobile.ControlTarget; if (from?.Deleted != false || to?.Deleted != false || from == to || !to.Player) { - m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused* + Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused* } - else if (!m_Mobile.IsPetFriend(to)) + else if (!Mobile.IsPetFriend(to)) { from.SendLocalizedMessage(1070953); // That person is not a friend. } else { // ~1_NAME~ will no longer accept movement commands from ~2_NAME~. - from.SendLocalizedMessage(1070951, $"{m_Mobile.Name}\t{to.Name}"); + from.SendLocalizedMessage(1070951, $"{Mobile.Name}\t{to.Name}"); /* ~1_NAME~ has no longer granted you the ability to give orders to their pet ~2_PET_NAME~. * This creature will no longer consider you as a friend. */ - to.SendLocalizedMessage(1070952, $"{from.Name}\t{m_Mobile.Name}"); + to.SendLocalizedMessage(1070952, $"{from.Name}\t{Mobile.Name}"); - m_Mobile.RemovePetFriend(to); + Mobile.RemovePetFriend(to); } - m_Mobile.ControlTarget = from; - m_Mobile.ControlOrder = OrderType.Follow; + Mobile.ControlTarget = from; + Mobile.ControlOrder = OrderType.Follow; return true; } public virtual bool DoOrderGuard() { - if (m_Mobile.IsDeadPet) + if (Mobile.IsDeadPet) { return true; } - var controlMaster = m_Mobile.ControlMaster; + var controlMaster = Mobile.ControlMaster; if (controlMaster?.Deleted != false) { return true; } - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; var aggressors = controlMaster.Aggressors; @@ -1590,7 +1590,7 @@ public abstract class BaseAI var attacker = info.Attacker; if (attacker?.Deleted == false && - attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception) + attacker.GetDistanceToSqrt(Mobile) <= Mobile.RangePerception) { if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) < combatant.GetDistanceToSqrt(controlMaster)) @@ -1600,23 +1600,23 @@ public abstract class BaseAI } } - if (combatant != null && m_Mobile.Debug) + if (combatant != null && Mobile.Debug) { - m_Mobile.DebugSay("Crap, my master has been attacked! I will attack one of those bastards!"); + Mobile.DebugSay("Crap, my master has been attacked! I will attack one of those bastards!"); } } - if (combatant?.Deleted == false && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && - combatant.Alive && !combatant.IsDeadBondedPet && m_Mobile.CanSee(combatant) && - m_Mobile.CanBeHarmful(combatant, false) && combatant.Map == m_Mobile.Map) + if (combatant?.Deleted == false && combatant != Mobile && combatant != Mobile.ControlMaster && + combatant.Alive && !combatant.IsDeadBondedPet && Mobile.CanSee(combatant) && + Mobile.CanBeHarmful(combatant, false) && combatant.Map == Mobile.Map) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Guarding from target..."); + Mobile.DebugSay("Guarding from target..."); } - m_Mobile.Combatant = combatant; - m_Mobile.FocusMob = combatant; + Mobile.Combatant = combatant; + Mobile.FocusMob = combatant; Action = ActionType.Combat; /* @@ -1627,15 +1627,15 @@ public abstract class BaseAI } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Nothing to guard from"); + Mobile.DebugSay("Nothing to guard from"); } - m_Mobile.Warmode = false; + Mobile.Warmode = false; if (Core.AOS) { - m_Mobile.CurrentSpeed = 0.1; + Mobile.CurrentSpeed = 0.1; } WalkMobileRange(controlMaster, 1, false, 0, 1); @@ -1646,40 +1646,40 @@ public abstract class BaseAI public virtual bool DoOrderAttack() { - if (m_Mobile.IsDeadPet) + if (Mobile.IsDeadPet) { return true; } - if (m_Mobile.ControlTarget?.Deleted != false || m_Mobile.ControlTarget.Map != m_Mobile.Map || - !m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet) + if (Mobile.ControlTarget?.Deleted != false || Mobile.ControlTarget.Map != Mobile.Map || + !Mobile.ControlTarget.Alive || Mobile.ControlTarget.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay( + Mobile.DebugSay( "I think he might be dead. He's not anywhere around here at least. That's cool. I'm glad he's dead." ); } if (Core.AOS) { - m_Mobile.ControlTarget = m_Mobile.ControlMaster; - m_Mobile.ControlOrder = OrderType.Follow; + Mobile.ControlTarget = Mobile.ControlMaster; + Mobile.ControlOrder = OrderType.Follow; } else { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.None; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.None; } - if (m_Mobile.FightMode is FightMode.Closest or FightMode.Aggressor) + if (Mobile.FightMode is FightMode.Closest or FightMode.Aggressor) { Mobile newCombatant = null; var newScore = 0.0; - foreach (var aggr in m_Mobile.GetMobilesInRange(m_Mobile.RangePerception)) + foreach (var aggr in Mobile.GetMobilesInRange(Mobile.RangePerception)) { - if (!m_Mobile.CanSee(aggr) || aggr.Combatant != m_Mobile) + if (!Mobile.CanSee(aggr) || aggr.Combatant != Mobile) { continue; } @@ -1689,9 +1689,9 @@ public abstract class BaseAI continue; } - var aggrScore = m_Mobile.GetFightModeRanking(aggr, FightMode.Closest, false); + var aggrScore = Mobile.GetFightModeRanking(aggr, FightMode.Closest, false); - if ((newCombatant == null || aggrScore > newScore) && m_Mobile.InLOS(aggr)) + if ((newCombatant == null || aggrScore > newScore) && Mobile.InLOS(aggr)) { newCombatant = aggr; newScore = aggrScore; @@ -1700,12 +1700,12 @@ public abstract class BaseAI if (newCombatant != null) { - m_Mobile.ControlTarget = newCombatant; - m_Mobile.ControlOrder = OrderType.Attack; - m_Mobile.Combatant = newCombatant; - if (m_Mobile.Debug) + Mobile.ControlTarget = newCombatant; + Mobile.ControlOrder = OrderType.Attack; + Mobile.Combatant = newCombatant; + if (Mobile.Debug) { - m_Mobile.DebugSay("But -that- is not dead. Here we go again..."); + Mobile.DebugSay("But -that- is not dead. Here we go again..."); } Think(); @@ -1714,9 +1714,9 @@ public abstract class BaseAI } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Attacking target..."); + Mobile.DebugSay("Attacking target..."); } Think(); @@ -1727,9 +1727,9 @@ public abstract class BaseAI public virtual bool DoOrderPatrol() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("This order is not yet coded"); + Mobile.DebugSay("This order is not yet coded"); } return true; @@ -1737,38 +1737,38 @@ public abstract class BaseAI public virtual bool DoOrderRelease() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have been released"); + Mobile.DebugSay("I have been released"); } - m_Mobile.PlaySound(m_Mobile.GetAngerSound()); + Mobile.PlaySound(Mobile.GetAngerSound()); - m_Mobile.SetControlMaster(null); - m_Mobile.SummonMaster = null; + Mobile.SetControlMaster(null); + Mobile.SummonMaster = null; - m_Mobile.BondingBegin = DateTime.MinValue; - m_Mobile.OwnerAbandonTime = DateTime.MinValue; - m_Mobile.IsBonded = false; + Mobile.BondingBegin = DateTime.MinValue; + Mobile.OwnerAbandonTime = DateTime.MinValue; + Mobile.IsBonded = false; - var spawner = m_Mobile.Spawner; + var spawner = Mobile.Spawner; if (spawner != null && spawner.HomeLocation != Point3D.Zero) { - m_Mobile.Home = spawner.HomeLocation; - m_Mobile.RangeHome = spawner.HomeRange; + Mobile.Home = spawner.HomeLocation; + Mobile.RangeHome = spawner.HomeRange; } - if (m_Mobile.DeleteOnRelease || m_Mobile.IsDeadPet) + if (Mobile.DeleteOnRelease || Mobile.IsDeadPet) { - m_Mobile.Delete(); + Mobile.Delete(); } - m_Mobile.BeginDeleteTimer(); + Mobile.BeginDeleteTimer(); - if (m_Mobile.CanDrop) + if (Mobile.CanDrop) { - m_Mobile.DropBackpack(); + Mobile.DropBackpack(); } return true; @@ -1776,15 +1776,15 @@ public abstract class BaseAI public virtual bool DoOrderStay() { - if (m_Mobile.Debug) + if (Mobile.Debug) { if (CheckHerding()) { - m_Mobile.DebugSay("Praise the shepherd!"); + Mobile.DebugSay("Praise the shepherd!"); } else { - m_Mobile.DebugSay("My master told me to stay"); + Mobile.DebugSay("My master told me to stay"); } } @@ -1793,20 +1793,20 @@ public abstract class BaseAI public virtual bool DoOrderStop() { - if (m_Mobile.ControlMaster?.Deleted != false) + if (Mobile.ControlMaster?.Deleted != false) { return true; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My master told me to stop."); + Mobile.DebugSay("My master told me to stop."); } - m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.ControlMaster); - m_Mobile.Home = m_Mobile.Location; + Mobile.Direction = Mobile.GetDirectionTo(Mobile.ControlMaster); + Mobile.Home = Mobile.Location; - m_Mobile.ControlTarget = null; + Mobile.ControlTarget = null; if (Core.ML) { @@ -1814,7 +1814,7 @@ public abstract class BaseAI } else { - m_Mobile.ControlOrder = OrderType.None; + Mobile.ControlOrder = OrderType.None; } return true; @@ -1822,19 +1822,19 @@ public abstract class BaseAI public virtual bool DoOrderTransfer() { - if (m_Mobile.IsDeadPet) + if (Mobile.IsDeadPet) { return true; } - var from = m_Mobile.ControlMaster; - var to = m_Mobile.ControlTarget; + var from = Mobile.ControlMaster; + var to = Mobile.ControlTarget; if (from?.Deleted == false && to?.Deleted == false && from != to && to.Player) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"Begin transfer with {to.Name}"); + Mobile.DebugSay($"Begin transfer with {to.Name}"); } var youngFrom = from is PlayerMobile mobile && mobile.Young; @@ -1848,7 +1848,7 @@ public abstract class BaseAI { from.SendLocalizedMessage(502052); // As an older player, you may not transfer pets to young players. } - else if (!m_Mobile.CanBeControlledBy(to)) + else if (!Mobile.CanBeControlledBy(to)) { var args = $"{to.Name}\t{from.Name}\t "; @@ -1861,7 +1861,7 @@ public abstract class BaseAI args ); // The pet will not accept you as a master because it does not trust you.~3_BLANK~ } - else if (!m_Mobile.CanBeControlledBy(from)) + else if (!Mobile.CanBeControlledBy(from)) { var args = $"{to.Name}\t{from.Name}\t "; @@ -1874,7 +1874,7 @@ public abstract class BaseAI args ); // The pet will not accept you as a master because it does not trust ~2_NAME~.~3_BLANK~ } - else if (TransferItem.IsInCombat(m_Mobile)) + else if (TransferItem.IsInCombat(Mobile)) { from.SendMessage("You may not transfer a pet that has recently been in combat."); to.SendMessage("The pet may not be transferred to you because it has recently been in combat."); @@ -1895,38 +1895,38 @@ public abstract class BaseAI } else { - fromState.AddTrade(toState).DropItem(new TransferItem(m_Mobile)); + fromState.AddTrade(toState).DropItem(new TransferItem(Mobile)); } } } } - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stay; + Mobile.ControlTarget = null; + Mobile.ControlOrder = OrderType.Stay; return true; } public virtual bool DoBardPacified() { - if (Core.Now < m_Mobile.BardEndTime) + if (Core.Now < Mobile.BardEndTime) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am pacified, I wait"); + Mobile.DebugSay("I am pacified, I wait"); } - m_Mobile.Combatant = null; - m_Mobile.Warmode = false; + Mobile.Combatant = null; + Mobile.Warmode = false; } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I'm not pacified any longer"); + Mobile.DebugSay("I'm not pacified any longer"); } - m_Mobile.BardPacified = false; + Mobile.BardPacified = false; } return true; @@ -1934,44 +1934,44 @@ public abstract class BaseAI public virtual bool DoBardProvoked() { - if (Core.Now >= m_Mobile.BardEndTime && - (m_Mobile.BardMaster?.Deleted != false || - m_Mobile.BardMaster.Map != m_Mobile.Map || m_Mobile.GetDistanceToSqrt(m_Mobile.BardMaster) > - m_Mobile.RangePerception)) + if (Core.Now >= Mobile.BardEndTime && + (Mobile.BardMaster?.Deleted != false || + Mobile.BardMaster.Map != Mobile.Map || Mobile.GetDistanceToSqrt(Mobile.BardMaster) > + Mobile.RangePerception)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost my provoker"); + Mobile.DebugSay("I have lost my provoker"); } - m_Mobile.BardProvoked = false; - m_Mobile.BardMaster = null; - m_Mobile.BardTarget = null; + Mobile.BardProvoked = false; + Mobile.BardMaster = null; + Mobile.BardTarget = null; - m_Mobile.Combatant = null; - m_Mobile.Warmode = false; + Mobile.Combatant = null; + Mobile.Warmode = false; } - else if (m_Mobile.BardTarget?.Deleted != false || m_Mobile.BardTarget.Map != m_Mobile.Map || - m_Mobile.GetDistanceToSqrt(m_Mobile.BardTarget) > m_Mobile.RangePerception) + else if (Mobile.BardTarget?.Deleted != false || Mobile.BardTarget.Map != Mobile.Map || + Mobile.GetDistanceToSqrt(Mobile.BardTarget) > Mobile.RangePerception) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost my provoke target"); + Mobile.DebugSay("I have lost my provoke target"); } - m_Mobile.BardProvoked = false; - m_Mobile.BardMaster = null; - m_Mobile.BardTarget = null; + Mobile.BardProvoked = false; + Mobile.BardMaster = null; + Mobile.BardTarget = null; - m_Mobile.Combatant = null; - m_Mobile.Warmode = false; + Mobile.Combatant = null; + Mobile.Warmode = false; } else { - m_Mobile.Combatant = m_Mobile.BardTarget; - m_Action = ActionType.Combat; + Mobile.Combatant = Mobile.BardTarget; + _action = ActionType.Combat; - m_Mobile.OnThink(); + Mobile.OnThink(); Think(); } @@ -1980,7 +1980,7 @@ public abstract class BaseAI public virtual void WalkRandom(int iChanceToNotMove, int iChanceToDir, int iSteps) { - if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) + if (Mobile.Deleted || Mobile.DisallowAllMoves) { return; } @@ -1997,7 +1997,7 @@ public abstract class BaseAI // iChanceToDir = 2, total weight is 18 // 7/26 chance of other direction var iRndMove = Utility.Random(8 * (iChanceToDir + 1)); - Direction direction = iRndMove < 8 ? (Direction)iRndMove : m_Mobile.Direction; + Direction direction = iRndMove < 8 ? (Direction)iRndMove : Mobile.Direction; DoMove(direction); } } @@ -2101,8 +2101,8 @@ public abstract class BaseAI public virtual MoveResult DoMoveImpl(Direction d, bool badStateOk) { - if (m_Mobile == null || m_Mobile.Deleted || m_Mobile.Frozen || m_Mobile.Paralyzed || - m_Mobile.Spell?.IsCasting == true || m_Mobile.DisallowAllMoves) + if (Mobile == null || Mobile.Deleted || Mobile.Frozen || Mobile.Paralyzed || + Mobile.Spell?.IsCasting == true || Mobile.DisallowAllMoves) { return MoveResult.BadState; } @@ -2112,7 +2112,7 @@ public abstract class BaseAI return MoveResult.BadState; } - var delay = (int)(TransformMoveDelay(m_Mobile) * 1000); + var delay = (int)(TransformMoveDelay(Mobile) * 1000); if (!CanMoveNow(out var timeUntilMove)) { @@ -2127,7 +2127,7 @@ public abstract class BaseAI // This makes them always move one step, never any direction changes // TODO: This is firing off deltas which aren't needed. Look into replacing/removing this - m_Mobile.Direction = d; + Mobile.Direction = d; NextMove += delay; if (Core.TickCount - NextMove > 0) @@ -2135,24 +2135,24 @@ public abstract class BaseAI NextMove = Core.TickCount; } - m_Mobile.Pushing = false; - var mobDirection = m_Mobile.Direction; + Mobile.Pushing = false; + var mobDirection = Mobile.Direction; // Do the actual move - MoveImpl.IgnoreMovableImpassables = m_Mobile.CanMoveOverObstacles && !m_Mobile.CanDestroyObstacles; - var moveResult = m_Mobile.Move(d); + MoveImpl.IgnoreMovableImpassables = Mobile.CanMoveOverObstacles && !Mobile.CanDestroyObstacles; + var moveResult = Mobile.Move(d); MoveImpl.IgnoreMovableImpassables = false; if (moveResult) { // If we don't delay combat, then a direction change will happen and cause a glitchy sliding effect. - if (m_Mobile.Warmode && m_Mobile.Combatant != null) + if (Mobile.Warmode && Mobile.Combatant != null) { - var remaining = m_Mobile.NextCombatTime - Core.TickCount; + var remaining = Mobile.NextCombatTime - Core.TickCount; var maxWait = Math.Min(delay, 400); if (remaining < maxWait) { - m_Mobile.NextCombatTime = Core.TickCount + maxWait; + Mobile.NextCombatTime = Core.TickCount + maxWait; } } return MoveResult.Success; @@ -2163,34 +2163,34 @@ public abstract class BaseAI return MoveResult.Blocked; } - var wasPushing = m_Mobile.Pushing; + var wasPushing = Mobile.Pushing; var blocked = true; - var canOpenDoors = m_Mobile.CanOpenDoors; - var canDestroyObstacles = m_Mobile.CanDestroyObstacles; + var canOpenDoors = Mobile.CanOpenDoors; + var canDestroyObstacles = Mobile.CanDestroyObstacles; if (canOpenDoors || canDestroyObstacles) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My movement was blocked, I will try to clear some obstacles."); + Mobile.DebugSay("My movement was blocked, I will try to clear some obstacles."); } - var map = m_Mobile.Map; + var map = Mobile.Map; if (map != null) { - var x = m_Mobile.X; - var y = m_Mobile.Y; + var x = Mobile.X; + var y = Mobile.Y; Movement.Movement.Offset(d, ref x, ref y); using var queue = PooledRefQueue.Create(); var destroyables = 0; foreach (var item in map.GetItemsInRange(new Point2D(x, y), 1)) { - if (canOpenDoors && item is BaseDoor door && door.Z + door.ItemData.Height > m_Mobile.Z && - m_Mobile.Z + 16 > door.Z) + if (canOpenDoors && item is BaseDoor door && door.Z + door.ItemData.Height > Mobile.Z && + Mobile.Z + 16 > door.Z) { if (door.X != x || door.Y != y) { @@ -2208,9 +2208,9 @@ public abstract class BaseAI } } else if (canDestroyObstacles && item.Movable && item.ItemData.Impassable && - item.Z + item.ItemData.Height > m_Mobile.Z && m_Mobile.Z + 16 > item.Z) + item.Z + item.ItemData.Height > Mobile.Z && Mobile.Z + 16 > item.Z) { - if (!m_Mobile.InRange(item.GetWorldLocation(), 1)) + if (!Mobile.InRange(item.GetWorldLocation(), 1)) { continue; } @@ -2222,7 +2222,7 @@ public abstract class BaseAI if (destroyables > 0) { - Effects.PlaySound(new Point3D(x, y, m_Mobile.Z), m_Mobile.Map, 0x3B3); + Effects.PlaySound(new Point3D(x, y, Mobile.Z), Mobile.Map, 0x3B3); } if (queue.Count > 0) @@ -2236,25 +2236,25 @@ public abstract class BaseAI if (item is BaseDoor door) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay( + Mobile.DebugSay( "Little do they expect, I've learned how to open doors. Didn't they read the script??" ); } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("*twist*"); + Mobile.DebugSay("*twist*"); } - door.Use(m_Mobile); + door.Use(Mobile); } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay( + Mobile.DebugSay( $"Ugabooga. I'm so big and tough I can destroy it: {item.GetType().Name}" ); } @@ -2266,7 +2266,7 @@ public abstract class BaseAI var check = cont.Items[i]; if (check.Movable && check.ItemData.Impassable && - cont.Z + check.ItemData.Height > m_Mobile.Z) + cont.Z + check.ItemData.Height > Mobile.Z) { queue.Enqueue(check); } @@ -2283,7 +2283,7 @@ public abstract class BaseAI if (!blocked) { - blocked = !m_Mobile.Move(d); + blocked = !Mobile.Move(d); } } } @@ -2294,9 +2294,9 @@ public abstract class BaseAI for (var i = 0; i < 2; ++i) { - m_Mobile.TurnInternal(offset); + Mobile.TurnInternal(offset); - if (m_Mobile.Move(m_Mobile.Direction)) + if (Mobile.Move(Mobile.Direction)) { return MoveResult.SuccessAutoTurn; } @@ -2310,28 +2310,28 @@ public abstract class BaseAI public virtual void WalkRandomInHome(int iChanceToNotMove, int iChanceToDir, int iSteps) { - if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) + if (Mobile.Deleted || Mobile.DisallowAllMoves) { return; } - if (m_Mobile.Home == Point3D.Zero) + if (Mobile.Home == Point3D.Zero) { - if (m_Mobile.Spawner is RegionSpawner rs) + if (Mobile.Spawner is RegionSpawner rs) { Region region = rs.SpawnRegion; - if (m_Mobile.Region.AcceptsSpawnsFrom(region)) + if (Mobile.Region.AcceptsSpawnsFrom(region)) { - m_Mobile.WalkRegion = region; + Mobile.WalkRegion = region; WalkRandom(iChanceToNotMove, iChanceToDir, iSteps); - m_Mobile.WalkRegion = null; + Mobile.WalkRegion = null; } else { if (region.GoLocation != Point3D.Zero && Utility.RandomBool()) { - DoMove(m_Mobile.GetDirectionTo(region.GoLocation)); + DoMove(Mobile.GetDirectionTo(region.GoLocation)); } else { @@ -2348,21 +2348,21 @@ public abstract class BaseAI { for (var i = 0; i < iSteps; i++) { - if (m_Mobile.RangeHome != 0) + if (Mobile.RangeHome != 0) { - var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.Home); + var iCurrDist = (int)Mobile.GetDistanceToSqrt(Mobile.Home); - if (iCurrDist < m_Mobile.RangeHome * 2 / 3) + if (iCurrDist < Mobile.RangeHome * 2 / 3) { WalkRandom(iChanceToNotMove, iChanceToDir, 1); } - else if (iCurrDist > m_Mobile.RangeHome) + else if (iCurrDist > Mobile.RangeHome) { - DoMove(m_Mobile.GetDirectionTo(m_Mobile.Home)); + DoMove(Mobile.GetDirectionTo(Mobile.Home)); } else if (Utility.Random(10) > 5) { - DoMove(m_Mobile.GetDirectionTo(m_Mobile.Home)); + DoMove(Mobile.GetDirectionTo(Mobile.Home)); } else { @@ -2371,9 +2371,9 @@ public abstract class BaseAI } else { - if (m_Mobile.Location != m_Mobile.Home) + if (Mobile.Location != Mobile.Home) { - DoMove(m_Mobile.GetDirectionTo(m_Mobile.Home)); + DoMove(Mobile.GetDirectionTo(Mobile.Home)); } } } @@ -2382,9 +2382,9 @@ public abstract class BaseAI public virtual bool CheckFlee() { - if (m_Mobile.CheckFlee()) + if (Mobile.CheckFlee()) { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; if (combatant == null) { @@ -2392,12 +2392,12 @@ public abstract class BaseAI } else { - var d = combatant.GetDirectionTo(m_Mobile); + var d = combatant.GetDirectionTo(Mobile); d = (Direction)((int)d + Utility.RandomMinMax(-1, +1)); - m_Mobile.Direction = d; - m_Mobile.Move(d); + Mobile.Direction = d; + Mobile.Move(d); } return true; @@ -2408,51 +2408,51 @@ public abstract class BaseAI public virtual void OnTeleported() { - if (m_Path != null) + if (_path != null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Teleported; repathing"); + Mobile.DebugSay("Teleported; repathing"); } - m_Path.ForceRepath(); + _path.ForceRepath(); } } public virtual bool MoveTo(Mobile m, bool run, int range) { - if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m?.Deleted != false) + if (Mobile.Deleted || Mobile.DisallowAllMoves || m?.Deleted != false) { return false; } - if (m_Mobile.InRange(m, range)) + if (Mobile.InRange(m, range)) { - m_Path = null; + _path = null; return true; } - if (m_Path?.Goal == m) + if (_path?.Goal == m) { - if (m_Path.Follow(run, 1)) + if (_path.Follow(run, 1)) { - m_Path = null; + _path = null; return true; } } - else if (!DoMove(m_Mobile.GetDirectionTo(m), true)) + else if (!DoMove(Mobile.GetDirectionTo(m), true)) { - m_Path = new PathFollower(m_Mobile, m) { Mover = DoMoveImpl }; + _path = new PathFollower(Mobile, m) { Mover = DoMoveImpl }; - if (m_Path.Follow(run, 1)) + if (_path.Follow(run, 1)) { - m_Path = null; + _path = null; return true; } } else { - m_Path = null; + _path = null; return true; } @@ -2470,7 +2470,7 @@ public abstract class BaseAI */ public virtual bool WalkMobileRange(Mobile m, int iSteps, bool run, int iWantDistMin, int iWantDistMax) { - if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) + if (Mobile.Deleted || Mobile.DisallowAllMoves) { return false; } @@ -2483,36 +2483,36 @@ public abstract class BaseAI for (var i = 0; i < iSteps; i++) { // Get the current distance - var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m); + var iCurrDist = (int)Mobile.GetDistanceToSqrt(m); if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax) { var needCloser = iCurrDist > iWantDistMax; - if (needCloser && m_Path != null && m_Path.Goal == m) + if (needCloser && _path != null && _path.Goal == m) { - if (m_Path.Follow(run, 1)) + if (_path.Follow(run, 1)) { - m_Path = null; + _path = null; } } else { var dirTo = iCurrDist > iWantDistMax ? - m_Mobile.GetDirectionTo(m, run) : m.GetDirectionTo(m_Mobile, run); + Mobile.GetDirectionTo(m, run) : m.GetDirectionTo(Mobile, run); if (!DoMove(dirTo, true) && needCloser) { - m_Path = new PathFollower(m_Mobile, m) { Mover = DoMoveImpl }; + _path = new PathFollower(Mobile, m) { Mover = DoMoveImpl }; - if (m_Path.Follow(run, 1)) + if (_path.Follow(run, 1)) { - m_Path = null; + _path = null; } } else { - m_Path = null; + _path = null; } } } @@ -2523,7 +2523,7 @@ public abstract class BaseAI } // Get the current distance - var iNewDist = (int)m_Mobile.GetDistanceToSqrt(m); + var iNewDist = (int)Mobile.GetDistanceToSqrt(m); return iNewDist >= iWantDistMin && iNewDist <= iWantDistMax; } @@ -2540,85 +2540,85 @@ public abstract class BaseAI */ public virtual bool AcquireFocusMob(int iRange, FightMode acqType, bool bPlayerOnly, bool bFacFriend, bool bFacFoe) { - if (m_Mobile.Deleted) + if (Mobile.Deleted) { return false; } - if (m_Mobile.BardProvoked) + if (Mobile.BardProvoked) { - if (m_Mobile.BardTarget?.Deleted != false) + if (Mobile.BardTarget?.Deleted != false) { - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; return false; } - m_Mobile.FocusMob = m_Mobile.BardTarget; - return m_Mobile.FocusMob != null; + Mobile.FocusMob = Mobile.BardTarget; + return Mobile.FocusMob != null; } - if (m_Mobile.Controlled) + if (Mobile.Controlled) { - if (m_Mobile.ControlTarget?.Deleted != false || m_Mobile.ControlTarget.Hidden || - !m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet || - !m_Mobile.InRange(m_Mobile.ControlTarget, m_Mobile.RangePerception * 2)) + if (Mobile.ControlTarget?.Deleted != false || Mobile.ControlTarget.Hidden || + !Mobile.ControlTarget.Alive || Mobile.ControlTarget.IsDeadBondedPet || + !Mobile.InRange(Mobile.ControlTarget, Mobile.RangePerception * 2)) { - if (m_Mobile.ControlTarget != null && m_Mobile.ControlTarget != m_Mobile.ControlMaster) + if (Mobile.ControlTarget != null && Mobile.ControlTarget != Mobile.ControlMaster) { - m_Mobile.ControlTarget = null; + Mobile.ControlTarget = null; } - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; return false; } - m_Mobile.FocusMob = m_Mobile.ControlTarget; - return m_Mobile.FocusMob != null; + Mobile.FocusMob = Mobile.ControlTarget; + return Mobile.FocusMob != null; } - if (m_Mobile.ConstantFocus != null) + if (Mobile.ConstantFocus != null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Acquired my constant focus"); + Mobile.DebugSay("Acquired my constant focus"); } - m_Mobile.FocusMob = m_Mobile.ConstantFocus; + Mobile.FocusMob = Mobile.ConstantFocus; return true; } if (acqType == FightMode.None) { - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; return false; } - if (acqType == FightMode.Aggressor && m_Mobile.Aggressors.Count == 0 && m_Mobile.Aggressed.Count == 0 && - m_Mobile.FactionAllegiance == null && m_Mobile.EthicAllegiance == null) + if (acqType == FightMode.Aggressor && Mobile.Aggressors.Count == 0 && Mobile.Aggressed.Count == 0 && + Mobile.FactionAllegiance == null && Mobile.EthicAllegiance == null) { - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; return false; } - if (Core.TickCount - m_Mobile.NextReacquireTime < 0) + if (Core.TickCount - Mobile.NextReacquireTime < 0) { - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; return false; } - m_Mobile.NextReacquireTime = Core.TickCount + (int)m_Mobile.ReacquireDelay.TotalMilliseconds; + Mobile.NextReacquireTime = Core.TickCount + (int)Mobile.ReacquireDelay.TotalMilliseconds; - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Acquiring..."); + Mobile.DebugSay("Acquiring..."); } - var map = m_Mobile.Map; + var map = Mobile.Map; if (map == null) { // TODO: Is this correct? Maybe it should return false? - return m_Mobile.FocusMob != null; + return Mobile.FocusMob != null; } Mobile newFocusMob = null; @@ -2626,7 +2626,7 @@ public abstract class BaseAI Mobile enemySummonMob = null; var enemySummonVal = double.MinValue; - foreach (var m in map.GetMobilesInRange(m_Mobile.Location, iRange)) + foreach (var m in map.GetMobilesInRange(Mobile.Location, iRange)) { if (m.Deleted || m.Blessed) { @@ -2634,7 +2634,7 @@ public abstract class BaseAI } // Let's not target ourselves... - if (m == m_Mobile || m is BaseFamiliar) + if (m == Mobile || m is BaseFamiliar) { continue; } @@ -2658,7 +2658,7 @@ public abstract class BaseAI } // Can't acquire a target we can't see. - if (!m_Mobile.CanSee(m)) + if (!Mobile.CanSee(m)) { continue; } @@ -2667,34 +2667,34 @@ public abstract class BaseAI var pm = m as PlayerMobile; // Monster don't attack it's own summon or the summon of another monster - if (Core.AOS && bc != null && bc.Summoned && (bc.SummonMaster == m_Mobile || !bc.SummonMaster.Player && IsHostile(bc.SummonMaster))) + if (Core.AOS && bc != null && bc.Summoned && (bc.SummonMaster == Mobile || !bc.SummonMaster.Player && IsHostile(bc.SummonMaster))) { continue; } - if (m_Mobile.Summoned && m_Mobile.SummonMaster != null) + if (Mobile.Summoned && Mobile.SummonMaster != null) { // Animated creatures cannot attack players directly. - if (pm != null && m_Mobile.IsAnimatedDead) + if (pm != null && Mobile.IsAnimatedDead) { continue; } // Animated creatures cannot attack other animated creatures or pets of other players - if (m_Mobile.IsAnimatedDead && bc != null && (bc.IsAnimatedDead || bc.Controlled)) + if (Mobile.IsAnimatedDead && bc != null && (bc.IsAnimatedDead || bc.Controlled)) { continue; } // If this is a summon, it can't target its controller or invalid targets. - if (m_Mobile.FollowsAcquireRules && (m == m_Mobile.SummonMaster || !SpellHelper.ValidIndirectTarget(m_Mobile, m))) + if (Mobile.FollowsAcquireRules && (m == Mobile.SummonMaster || !SpellHelper.ValidIndirectTarget(Mobile, m))) { continue; } } // If we only want faction friends, make sure it's one. - if (bFacFriend && !m_Mobile.IsFriend(m)) + if (bFacFriend && !Mobile.IsFriend(m)) { continue; } @@ -2706,7 +2706,7 @@ public abstract class BaseAI } // Ignore players with activated honor - if (m_Mobile.Combatant != m && VirtueSystem.GetVirtues(pm)?.HonorActive == true) + if (Mobile.Combatant != m && VirtueSystem.GetVirtues(pm)?.HonorActive == true) { continue; } @@ -2717,8 +2717,8 @@ public abstract class BaseAI if (!bValid) { - bValid = m_Mobile.GetFactionAllegiance(m) == BaseCreature.Allegiance.Enemy || - m_Mobile.GetEthicAllegiance(m) == BaseCreature.Allegiance.Enemy; + bValid = Mobile.GetFactionAllegiance(m) == BaseCreature.Allegiance.Enemy || + Mobile.GetEthicAllegiance(m) == BaseCreature.Allegiance.Enemy; } if (acqType == FightMode.Evil && !bValid) @@ -2741,56 +2741,56 @@ public abstract class BaseAI else { // Same goes for faction enemies. - if (bFacFoe && !m_Mobile.IsEnemy(m)) + if (bFacFoe && !Mobile.IsEnemy(m)) { continue; } // If it's an enemy factioned mobile, make sure we can be harmful to it. - if (bFacFoe && !bFacFriend && !m_Mobile.CanBeHarmful(m, false)) + if (bFacFoe && !bFacFriend && !Mobile.CanBeHarmful(m, false)) { continue; } } - var theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly); + var theirVal = Mobile.GetFightModeRanking(m, acqType, bPlayerOnly); // Always prefer someone else over the summon master (EV/BS) - if ((theirVal > val || newFocusMob == m_Mobile.SummonMaster) && m_Mobile.InLOS(m)) + if ((theirVal > val || newFocusMob == Mobile.SummonMaster) && Mobile.InLOS(m)) { newFocusMob = m; val = theirVal; } // The summon is targeted when nothing else around. Otherwise this monster enters idle mode. // Do a check for this edge case so players cannot abuse by casting EVs offscreen to kill an idle monster. - else if (Core.AOS && theirVal > enemySummonVal && m_Mobile.InLOS(m) && bc?.Summoned == true && bc?.Controlled != true) + else if (Core.AOS && theirVal > enemySummonVal && Mobile.InLOS(m) && bc?.Summoned == true && bc?.Controlled != true) { enemySummonMob = m; enemySummonVal = theirVal; } } - m_Mobile.FocusMob = newFocusMob ?? enemySummonMob; - return m_Mobile.FocusMob != null; + Mobile.FocusMob = newFocusMob ?? enemySummonMob; + return Mobile.FocusMob != null; } private bool IsHostile(Mobile from) { - if (m_Mobile.Combatant == from || from.Combatant == m_Mobile) + if (Mobile.Combatant == from || from.Combatant == Mobile) { return true; } - var count = Math.Max(m_Mobile.Aggressors.Count, m_Mobile.Aggressed.Count); + var count = Math.Max(Mobile.Aggressors.Count, Mobile.Aggressed.Count); for (var a = 0; a < count; ++a) { - if (a < m_Mobile.Aggressed.Count && m_Mobile.Aggressed[a].Attacker == from) + if (a < Mobile.Aggressed.Count && Mobile.Aggressed[a].Attacker == from) { return true; } - if (a < m_Mobile.Aggressors.Count && m_Mobile.Aggressors[a].Defender == from) + if (a < Mobile.Aggressors.Count && Mobile.Aggressors[a].Defender == from) { return true; } @@ -2801,31 +2801,31 @@ public abstract class BaseAI public virtual void DetectHidden() { - if (m_Mobile.Deleted || m_Mobile.Map == null) + if (Mobile.Deleted || Mobile.Map == null) { return; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Checking for hidden players"); + Mobile.DebugSay("Checking for hidden players"); } - var srcSkill = m_Mobile.Skills.DetectHidden.Value; + var srcSkill = Mobile.Skills.DetectHidden.Value; if (srcSkill <= 0) { return; } - foreach (var trg in m_Mobile.GetMobilesInRange(m_Mobile.RangePerception)) + foreach (var trg in Mobile.GetMobilesInRange(Mobile.RangePerception)) { - if (trg != m_Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player && - m_Mobile.InLOS(trg)) + if (trg != Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player && + Mobile.InLOS(trg)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"Trying to detect {trg.Name}"); + Mobile.DebugSay($"Trying to detect {trg.Name}"); } var trgHiding = trg.Skills.Hiding.Value / 2.9; @@ -2851,15 +2851,15 @@ public abstract class BaseAI public virtual void Deactivate() { - if (m_Mobile.PlayerRangeSensitive) + if (Mobile.PlayerRangeSensitive) { - m_Timer.Stop(); + _timer.Stop(); - var spawner = m_Mobile.Spawner; + var spawner = Mobile.Spawner; - if (spawner?.ReturnOnDeactivate == true && !m_Mobile.Controlled && ( - spawner.HomeLocation == Point3D.Zero && !m_Mobile.Region.AcceptsSpawnsFrom(spawner.Region) || - !m_Mobile.InRange(spawner.HomeLocation, spawner.HomeRange) + if (spawner?.ReturnOnDeactivate == true && !Mobile.Controlled && ( + spawner.HomeLocation == Point3D.Zero && !Mobile.Region.AcceptsSpawnsFrom(spawner.Region) || + !Mobile.InRange(spawner.HomeLocation, spawner.HomeRange) )) { Timer.StartTimer(ReturnToHome); @@ -2869,32 +2869,32 @@ public abstract class BaseAI private void ReturnToHome() { - if (m_Mobile.Spawner != null) + if (Mobile.Spawner != null) { - var loc = m_Mobile.Spawner.GetSpawnPosition(m_Mobile, m_Mobile.Spawner.Map); + var loc = Mobile.Spawner.GetSpawnPosition(Mobile, Mobile.Spawner.Map); if (loc != Point3D.Zero) { - m_Mobile.MoveToWorld(loc, m_Mobile.Spawner.Map); + Mobile.MoveToWorld(loc, Mobile.Spawner.Map); } } } public virtual void Activate() { - if (!m_Timer.Running) + if (!_timer.Running) { // We want to randomize the time at which the AI activates. // This triggers when a mob is first created since it moves from the internal map to it's added location // If we spawn lots of mobs, we don't want their AI synchronized exactly. - m_Timer.Delay = TimeSpan.FromMilliseconds(Utility.Random(48) * 8); - m_Timer.Start(); + _timer.Delay = TimeSpan.FromMilliseconds(Utility.Random(48) * 8); + _timer.Start(); } } public virtual void OnCurrentSpeedChanged() { - m_Timer.Interval = TimeSpan.FromSeconds(Math.Max(0.008, m_Mobile.CurrentSpeed)); + _timer.Interval = TimeSpan.FromSeconds(Math.Max(0.008, Mobile.CurrentSpeed)); } private class InternalEntry : ContextMenuEntry @@ -2983,12 +2983,12 @@ public abstract class BaseAI private class TransferItem : Item { - private readonly BaseCreature m_Creature; + private readonly BaseCreature _creature; public TransferItem(BaseCreature creature) : base(ShrinkTable.Lookup(creature)) { - m_Creature = creature; + _creature = creature; Movable = false; @@ -3036,11 +3036,11 @@ public abstract class BaseAI base.GetProperties(list); list.Add(1041603); // This item represents a pet currently in consideration for trade - list.Add(1041601, m_Creature.Name); // Pet Name: ~1_val~ + list.Add(1041601, _creature.Name); // Pet Name: ~1_val~ - if (m_Creature.ControlMaster != null) + if (_creature.ControlMaster != null) { - list.Add(1041602, m_Creature.ControlMaster.Name); // Owner: ~1_val~ + list.Add(1041602, _creature.ControlMaster.Name); // Owner: ~1_val~ } } @@ -3051,13 +3051,13 @@ public abstract class BaseAI return false; } - if (Deleted || m_Creature?.Deleted != false || m_Creature.ControlMaster != from || + if (Deleted || _creature?.Deleted != false || _creature.ControlMaster != from || !from.CheckAlive() || !to.CheckAlive()) { return false; } - if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14)) + if (from.Map != _creature.Map || !from.InRange(_creature, 14)) { return false; } @@ -3073,7 +3073,7 @@ public abstract class BaseAI { from.SendLocalizedMessage(502052); // As an older player, you may not transfer pets to young players. } - else if (accepted && !m_Creature.CanBeControlledBy(to)) + else if (accepted && !_creature.CanBeControlledBy(to)) { var args = $"{to.Name}\t{from.Name}\t "; @@ -3084,7 +3084,7 @@ public abstract class BaseAI return false; } - else if (accepted && !m_Creature.CanBeControlledBy(from)) + else if (accepted && !_creature.CanBeControlledBy(from)) { var args = $"{to.Name}\t{from.Name}\t "; @@ -3093,13 +3093,13 @@ public abstract class BaseAI // 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) + else if (accepted && to.Followers + _creature.ControlSlots > to.FollowersMax) { to.SendLocalizedMessage(1049607); // You have too many followers to control that creature. return false; } - else if (accepted && IsInCombat(m_Creature)) + else if (accepted && IsInCombat(_creature)) { from.SendMessage("You may not transfer a pet that has recently been in combat."); to.SendMessage("The pet may not be transferred to you because it has recently been in combat."); @@ -3119,34 +3119,34 @@ public abstract class BaseAI Delete(); - if (m_Creature?.Deleted != false || m_Creature.ControlMaster != from || !from.CheckAlive() || + if (_creature?.Deleted != false || _creature.ControlMaster != from || !from.CheckAlive() || !to.CheckAlive()) { return; } - if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14)) + if (from.Map != _creature.Map || !from.InRange(_creature, 14)) { return; } - if (accepted && m_Creature.SetControlMaster(to)) + if (accepted && _creature.SetControlMaster(to)) { - if (m_Creature.Summoned) + if (_creature.Summoned) { - m_Creature.SummonMaster = to; + _creature.SummonMaster = to; } - m_Creature.ControlTarget = to; - m_Creature.ControlOrder = OrderType.Follow; + _creature.ControlTarget = to; + _creature.ControlOrder = OrderType.Follow; - m_Creature.BondingBegin = DateTime.MinValue; - m_Creature.OwnerAbandonTime = DateTime.MinValue; - m_Creature.IsBonded = false; + _creature.BondingBegin = DateTime.MinValue; + _creature.OwnerAbandonTime = DateTime.MinValue; + _creature.IsBonded = false; - m_Creature.PlaySound(m_Creature.GetIdleSound()); + _creature.PlaySound(_creature.GetIdleSound()); - var args = $"{from.Name}\t{m_Creature.Name}\t{to.Name}"; + var args = $"{from.Name}\t{_creature.Name}\t{to.Name}"; from.SendLocalizedMessage(1043253, args); // You have transferred your pet to ~3_GETTER~. // ~1_NAME~ has transferred the allegiance of ~2_PET_NAME~ to you. @@ -3160,88 +3160,88 @@ public abstract class BaseAI */ private class AITimer : Timer { - private readonly BaseAI m_Owner; + private readonly BaseAI _owner; public AITimer(BaseAI owner) : base( TimeSpan.FromMilliseconds(Utility.Random(96) * 8), - TimeSpan.FromSeconds(Math.Max(0.0, owner.m_Mobile.CurrentSpeed)) + TimeSpan.FromSeconds(Math.Max(0.0, owner.Mobile.CurrentSpeed)) ) { - m_Owner = owner; - m_Owner.m_NextDetectHidden = Core.TickCount; + _owner = owner; + _owner._nextDetectHidden = Core.TickCount; } protected override void OnTick() { - if (m_Owner.m_Mobile.Deleted) + if (_owner.Mobile.Deleted) { Stop(); return; } - if (m_Owner.m_Mobile.Map == null || m_Owner.m_Mobile.Map == Map.Internal) + if (_owner.Mobile.Map == null || _owner.Mobile.Map == Map.Internal) { - m_Owner.Deactivate(); + _owner.Deactivate(); return; } - if (m_Owner.m_Mobile.PlayerRangeSensitive) // have to check this in the timer.... + if (_owner.Mobile.PlayerRangeSensitive) // have to check this in the timer.... { - var sect = m_Owner.m_Mobile.Map.GetSector(m_Owner.m_Mobile.Location); + var sect = _owner.Mobile.Map.GetSector(_owner.Mobile.Location); if (!sect.Active) { - m_Owner.Deactivate(); + _owner.Deactivate(); return; } } - m_Owner.m_Mobile.OnThink(); + _owner.Mobile.OnThink(); - if (m_Owner.m_Mobile.Deleted) + if (_owner.Mobile.Deleted) { Stop(); return; } - if (m_Owner.m_Mobile.Map == null || m_Owner.m_Mobile.Map == Map.Internal) + if (_owner.Mobile.Map == null || _owner.Mobile.Map == Map.Internal) { - m_Owner.Deactivate(); + _owner.Deactivate(); return; } - if (m_Owner.m_Mobile.BardPacified) + if (_owner.Mobile.BardPacified) { - m_Owner.DoBardPacified(); + _owner.DoBardPacified(); } - else if (m_Owner.m_Mobile.BardProvoked) + else if (_owner.Mobile.BardProvoked) { - m_Owner.DoBardProvoked(); + _owner.DoBardProvoked(); } - else if (!m_Owner.m_Mobile.Controlled) + else if (!_owner.Mobile.Controlled) { - if (!m_Owner.Think()) + if (!_owner.Think()) { Stop(); return; } } - else if (!m_Owner.Obey()) + else if (!_owner.Obey()) { Stop(); return; } - if (m_Owner.CanDetectHidden && Core.TickCount - m_Owner.m_NextDetectHidden >= 0) + if (_owner.CanDetectHidden && Core.TickCount - _owner._nextDetectHidden >= 0) { - m_Owner.DetectHidden(); + _owner.DetectHidden(); // Not exactly OSI style, approximation. - var delay = Math.Min(15000 / m_Owner.m_Mobile.Int, 60); + var delay = Math.Min(15000 / _owner.Mobile.Int, 60); var min = delay * 900; // 13s at 1000 int, 33s at 400 int, 54s at <250 int var max = delay * 1100; // 16s at 1000 int, 41s at 400 int, 66s at <250 int - m_Owner.m_NextDetectHidden = Core.TickCount + Utility.RandomMinMax(min, max); + _owner._nextDetectHidden = Core.TickCount + Utility.RandomMinMax(min, max); } } } diff --git a/Projects/UOContent/Mobiles/AI/BerserkAI.cs b/Projects/UOContent/Mobiles/AI/BerserkAI.cs index db7a994ba..207d1f727 100644 --- a/Projects/UOContent/Mobiles/AI/BerserkAI.cs +++ b/Projects/UOContent/Mobiles/AI/BerserkAI.cs @@ -8,19 +8,19 @@ public class BerserkAI : BaseAI public override bool DoActionWander() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have no combatant"); + Mobile.DebugSay("I have no combatant"); } - if (AcquireFocusMob(m_Mobile.RangePerception, FightMode.Closest, false, true, true)) + if (AcquireFocusMob(Mobile.RangePerception, FightMode.Closest, false, true, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name} and I will attack"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name} and I will attack"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else @@ -33,48 +33,48 @@ public class BerserkAI : BaseAI public override bool DoActionCombat() { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone, so my guard is up"); + Mobile.DebugSay("My combatant is gone, so my guard is up"); } Action = ActionType.Guard; return true; } - if (!WalkMobileRange(combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight)) + if (!WalkMobileRange(combatant, 1, true, Mobile.RangeFight, Mobile.RangeFight)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am still not in range of {combatant.Name}"); + Mobile.DebugSay($"I am still not in range of {combatant.Name}"); } - if ((int)m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) + if ((int)Mobile.GetDistanceToSqrt(combatant) > Mobile.RangePerception + 1) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have lost {combatant.Name}"); + Mobile.DebugSay($"I have lost {combatant.Name}"); } Action = ActionType.Guard; return true; } } - else if (Core.TickCount - m_Mobile.LastMoveTime > 400) + else if (Core.TickCount - Mobile.LastMoveTime > 400) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); + Mobile.Direction = Mobile.GetDirectionTo(combatant); } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); } } @@ -83,14 +83,14 @@ public class BerserkAI : BaseAI public override bool DoActionGuard() { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, true, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, true, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else diff --git a/Projects/UOContent/Mobiles/AI/HealerAI.cs b/Projects/UOContent/Mobiles/AI/HealerAI.cs index 4afa17e3b..6b4dfa2ed 100644 --- a/Projects/UOContent/Mobiles/AI/HealerAI.cs +++ b/Projects/UOContent/Mobiles/AI/HealerAI.cs @@ -9,13 +9,10 @@ namespace Server.Mobiles; public class HealerAI : BaseAI { - private static readonly NeedDelegate m_Cure = NeedCure; - private static readonly NeedDelegate m_GHeal = NeedGHeal; - private static readonly NeedDelegate m_LHeal = NeedLHeal; - private static readonly NeedDelegate[] m_ACure = { m_Cure }; - private static readonly NeedDelegate[] m_AGHeal = { m_GHeal }; - private static readonly NeedDelegate[] m_ALHeal = { m_LHeal }; - private static readonly NeedDelegate[] m_All = { m_Cure, m_GHeal, m_LHeal }; + private static readonly NeedDelegate[] Cure = [NeedCure]; + private static readonly NeedDelegate[] GHeal = [NeedGHeal]; + private static readonly NeedDelegate[] LHeal = [NeedLHeal]; + private static readonly NeedDelegate[] AllHeal = [NeedCure, NeedGHeal, NeedLHeal]; public HealerAI(BaseCreature m) : base(m) { @@ -23,12 +20,12 @@ public class HealerAI : BaseAI public override bool Think() { - if (m_Mobile.Deleted) + if (Mobile.Deleted) { return false; } - var targ = m_Mobile.Target; + var targ = Mobile.Target; if (targ != null) { @@ -36,79 +33,79 @@ public class HealerAI : BaseAI if (spellTarg?.Spell is CureSpell) { - ProcessTarget(targ, m_ACure); + ProcessTarget(targ, Cure); } else if (spellTarg?.Spell is GreaterHealSpell) { - ProcessTarget(targ, m_AGHeal); + ProcessTarget(targ, GHeal); } else if (spellTarg?.Spell is HealSpell) { - ProcessTarget(targ, m_ALHeal); + ProcessTarget(targ, LHeal); } else { - targ.Cancel(m_Mobile, TargetCancelType.Canceled); + targ.Cancel(Mobile, TargetCancelType.Canceled); } return true; } - var toHelp = Find(m_All); + var toHelp = Find(AllHeal); if (toHelp != null) { if (NeedCure(toHelp)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{toHelp.Name} needs a cure"); + Mobile.DebugSay($"{toHelp.Name} needs a cure"); } - if (!new CureSpell(m_Mobile).Cast()) + if (!new CureSpell(Mobile).Cast()) { - new CureSpell(m_Mobile).Cast(); + new CureSpell(Mobile).Cast(); } } else if (NeedGHeal(toHelp)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{toHelp.Name} needs a greater heal"); + Mobile.DebugSay($"{toHelp.Name} needs a greater heal"); } - if (!new GreaterHealSpell(m_Mobile).Cast()) + if (!new GreaterHealSpell(Mobile).Cast()) { - new HealSpell(m_Mobile).Cast(); + new HealSpell(Mobile).Cast(); } } else if (NeedLHeal(toHelp)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{toHelp.Name} needs a lesser heal"); + Mobile.DebugSay($"{toHelp.Name} needs a lesser heal"); } - new HealSpell(m_Mobile).Cast(); + new HealSpell(Mobile).Cast(); } return true; } - if (!AcquireFocusMob(m_Mobile.RangePerception, FightMode.Weakest, false, true, false)) + if (!AcquireFocusMob(Mobile.RangePerception, FightMode.Weakest, false, true, false)) { WalkRandomInHome(3, 2, 1); return true; } - WalkMobileRange(m_Mobile.FocusMob, 1, false, 4, 7); + WalkMobileRange(Mobile.FocusMob, 1, false, 4, 7); // TODO: Should it be able to do this? - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, m_Mobile.Combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, Mobile.Combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {m_Mobile.Combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {Mobile.Combatant.Name}!"); } } @@ -121,26 +118,26 @@ public class HealerAI : BaseAI if (toHelp == null) { - targ.Cancel(m_Mobile, TargetCancelType.Canceled); + targ.Cancel(Mobile, TargetCancelType.Canceled); } - else if (targ.Range != -1 && !m_Mobile.InRange(toHelp, targ.Range)) + else if (targ.Range != -1 && !Mobile.InRange(toHelp, targ.Range)) { - DoMove(m_Mobile.GetDirectionTo(toHelp) | Direction.Running); + DoMove(Mobile.GetDirectionTo(toHelp) | Direction.Running); } else { - targ.Invoke(m_Mobile, toHelp); + targ.Invoke(Mobile, toHelp); } } private Mobile Find(params ReadOnlySpan funcs) { - if (m_Mobile.Deleted) + if (Mobile.Deleted) { return null; } - var map = m_Mobile.Map; + var map = Mobile.Map; if (map == null) { @@ -150,9 +147,9 @@ public class HealerAI : BaseAI var prio = 0.0; Mobile found = null; - foreach (var m in m_Mobile.GetMobilesInRange(m_Mobile.RangePerception)) + foreach (var m in Mobile.GetMobilesInRange(Mobile.RangePerception)) { - if (!m_Mobile.CanSee(m) || m is not BaseCreature bc || bc.Team != m_Mobile.Team) + if (!Mobile.CanSee(m) || m is not BaseCreature bc || bc.Team != Mobile.Team) { continue; } @@ -161,7 +158,7 @@ public class HealerAI : BaseAI { if (funcs[i](bc)) { - var val = -m_Mobile.GetDistanceToSqrt(bc); + var val = -Mobile.GetDistanceToSqrt(bc); if (found == null || val > prio) { diff --git a/Projects/UOContent/Mobiles/AI/MageAI.cs b/Projects/UOContent/Mobiles/AI/MageAI.cs index 9a323f812..d86aa67ad 100644 --- a/Projects/UOContent/Mobiles/AI/MageAI.cs +++ b/Projects/UOContent/Mobiles/AI/MageAI.cs @@ -20,7 +20,7 @@ public class MageAI : BaseAI private const double DispelChance = 0.75; // 75% chance to dispel at gm magery private const double InvisChance = 0.50; // 50% chance to invis at gm magery - private static readonly int[] m_Offsets = + private static readonly int[] _offsets = { -1, -1, -1, 0, @@ -49,27 +49,27 @@ public class MageAI : BaseAI 2, 2 }; - protected int m_Combo = -1; + protected int _combo = -1; - private Mobile m_LastTarget; - private Point3D m_LastTargetLoc; - private long m_NextCastTime; - private long m_NextHealTime; + private Mobile _lastTarget; + private Point3D _lastTargetLoc; + private long _nextCastTime; + private long _nextHealTime; - private LandTarget m_RevealTarget; + private LandTarget _revealTarget; public MageAI(BaseCreature m) : base(m) { } - public virtual bool SmartAI => m_Mobile is BaseVendor or BaseEscortable or Changeling; + public virtual bool SmartAI => Mobile is BaseVendor or BaseEscortable or Changeling; - public virtual bool IsNecromancer => Core.AOS && m_Mobile.Skills.Necromancy.Value > 50; + public virtual bool IsNecromancer => Core.AOS && Mobile.Skills.Necromancy.Value > 50; public override bool Think() { - if (m_Mobile.Deleted) + if (Mobile.Deleted) { return false; } @@ -77,38 +77,38 @@ public class MageAI : BaseAI return ProcessTarget() || base.Think(); } - public virtual double ScaleBySkill(double v, SkillName skill) => v * m_Mobile.Skills[skill].Value / 100; + public virtual double ScaleBySkill(double v, SkillName skill) => v * Mobile.Skills[skill].Value / 100; public override bool DoActionWander() { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to attack {m_Mobile.FocusMob.Name}"); + Mobile.DebugSay($"I am going to attack {Mobile.FocusMob.Name}"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; - m_NextCastTime = Core.TickCount; + _nextCastTime = Core.TickCount; } - else if (SmartAI && m_Mobile.Mana < m_Mobile.ManaMax && !m_Mobile.Meditating) + else if (SmartAI && Mobile.Mana < Mobile.ManaMax && !Mobile.Meditating) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am going to meditate"); + Mobile.DebugSay("I am going to meditate"); } - m_Mobile.UseSkill(SkillName.Meditation); + Mobile.UseSkill(SkillName.Meditation); } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am wandering"); + Mobile.DebugSay("I am wandering"); } - m_Mobile.Warmode = false; + Mobile.Warmode = false; base.DoActionWander(); @@ -126,13 +126,13 @@ public class MageAI : BaseAI private Spell CheckCastHealingSpell() { // If I'm poisoned, always attempt to cure. - if (m_Mobile.Poisoned) + if (Mobile.Poisoned) { - return new CureSpell(m_Mobile); + return new CureSpell(Mobile); } // Summoned creatures never heal themselves. - if (m_Mobile.Summoned || m_Mobile.Controlled && Core.TickCount - m_NextHealTime < 0) + if (Mobile.Summoned || Mobile.Controlled && Core.TickCount - _nextHealTime < 0) { return null; } @@ -144,32 +144,32 @@ public class MageAI : BaseAI return null; } } - else if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : m_Mobile.HitsMax / m_Mobile.Hits)) < 3) + else if (Utility.Random(0, 4 + (Mobile.Hits == 0 ? Mobile.HitsMax : Mobile.HitsMax / Mobile.Hits)) < 3) { return null; } Spell spell = null; - if (m_Mobile.Hits < m_Mobile.HitsMax - 50) + if (Mobile.Hits < Mobile.HitsMax - 50) { if (UseNecromancy()) { - m_Mobile.UseSkill(SkillName.SpiritSpeak); + Mobile.UseSkill(SkillName.SpiritSpeak); } else { - spell = new GreaterHealSpell(m_Mobile); + spell = new GreaterHealSpell(Mobile); } } - else if (m_Mobile.Hits < m_Mobile.HitsMax - 10) + else if (Mobile.Hits < Mobile.HitsMax - 10) { - spell = new HealSpell(m_Mobile); + spell = new HealSpell(Mobile); } - var delay = m_Mobile.Int >= 500 ? Utility.RandomMinMax(7, 10) : Math.Sqrt(600 - m_Mobile.Int); + var delay = Mobile.Int >= 500 ? Utility.RandomMinMax(7, 10) : Math.Sqrt(600 - Mobile.Int); - m_NextHealTime = Core.TickCount + (int)TimeSpan.FromSeconds(delay).TotalMilliseconds; + _nextHealTime = Core.TickCount + (int)TimeSpan.FromSeconds(delay).TotalMilliseconds; return spell; } @@ -178,7 +178,7 @@ public class MageAI : BaseAI { if (!SmartAI) { - if (!MoveTo(m, true, m_Mobile.RangeFight)) + if (!MoveTo(m, true, Mobile.RangeFight)) { OnFailedMove(); } @@ -188,23 +188,23 @@ public class MageAI : BaseAI if (m.Paralyzed || m.Frozen) { - if (m_Mobile.InRange(m, 1)) + if (Mobile.InRange(m, 1)) { RunFrom(m); } - else if (!m_Mobile.InRange(m, Math.Max(m_Mobile.RangeFight, 2)) && !MoveTo(m, true, 1)) + else if (!Mobile.InRange(m, Math.Max(Mobile.RangeFight, 2)) && !MoveTo(m, true, 1)) { OnFailedMove(); } } - else if (!m_Mobile.InRange(m, m_Mobile.RangeFight)) + else if (!Mobile.InRange(m, Mobile.RangeFight)) { if (!MoveTo(m, true, 1)) { OnFailedMove(); } } - else if (m_Mobile.InRange(m, m_Mobile.RangeFight - 1)) + else if (Mobile.InRange(m, Mobile.RangeFight - 1)) { RunFrom(m); } @@ -212,51 +212,51 @@ public class MageAI : BaseAI public void RunFrom(Mobile m) { - Run((m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask); + Run((Mobile.GetDirectionTo(m) - 4) & Direction.Mask); } public void OnFailedMove() { - if (!m_Mobile.DisallowAllMoves && (SmartAI + if (!Mobile.DisallowAllMoves && (SmartAI ? Utility.Random(4) == 0 : TeleportChance > 0 && ScaleBySkill(TeleportChance, SkillName.Magery) > Utility.RandomDouble())) { - m_Mobile.Target?.Cancel(m_Mobile, TargetCancelType.Canceled); + Mobile.Target?.Cancel(Mobile, TargetCancelType.Canceled); - new TeleportSpell(m_Mobile).Cast(); + new TeleportSpell(Mobile).Cast(); - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am stuck, I'm going to try teleporting away"); + Mobile.DebugSay("I am stuck, I'm going to try teleporting away"); } } - else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + else if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"My move is blocked, so I am going to attack {m_Mobile.FocusMob.Name}"); + Mobile.DebugSay($"My move is blocked, so I am going to attack {Mobile.FocusMob.Name}"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } - else if (m_Mobile.Debug) + else if (Mobile.Debug) { - m_Mobile.DebugSay("I am stuck"); + Mobile.DebugSay("I am stuck"); } } public void Run(Direction d) { - if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen || - m_Mobile.DisallowAllMoves) + if (Mobile.Spell?.IsCasting == true || Mobile.Paralyzed || Mobile.Frozen || + Mobile.DisallowAllMoves) { return; } - m_Mobile.Direction = d | Direction.Running; + Mobile.Direction = d | Direction.Running; - if (!DoMove(m_Mobile.Direction, true)) + if (!DoMove(Mobile.Direction, true)) { OnFailedMove(); } @@ -264,8 +264,8 @@ public class MageAI : BaseAI public virtual bool UseNecromancy() { - var magery = m_Mobile.Skills.Magery.BaseFixedPoint; - var necro = m_Mobile.Skills.Necromancy.BaseFixedPoint; + var magery = Mobile.Skills.Magery.BaseFixedPoint; + var necro = Mobile.Skills.Necromancy.BaseFixedPoint; return IsNecromancer && Utility.Random(magery + necro) >= magery; } @@ -274,37 +274,37 @@ public class MageAI : BaseAI public virtual Spell GetRandomDamageSpellNecro() { - var bound = m_Mobile.Skills.Necromancy.Value >= 100 ? 5 : 3; + var bound = Mobile.Skills.Necromancy.Value >= 100 ? 5 : 3; return Utility.Random(bound) switch { - 0 => new PainSpikeSpell(m_Mobile), - 1 => new PoisonStrikeSpell(m_Mobile), - 2 => new StrangleSpell(m_Mobile), - 3 => new WitherSpell(m_Mobile), - _ => new VengefulSpiritSpell(m_Mobile) + 0 => new PainSpikeSpell(Mobile), + 1 => new PoisonStrikeSpell(Mobile), + 2 => new StrangleSpell(Mobile), + 3 => new WitherSpell(Mobile), + _ => new VengefulSpiritSpell(Mobile) }; } public virtual Spell GetRandomDamageSpellMage() { - var maxCircle = Math.Clamp((int)((m_Mobile.Skills.Magery.Value + 20.0) / (100.0 / 7.0)), 1, 8); + var maxCircle = Math.Clamp((int)((Mobile.Skills.Magery.Value + 20.0) / (100.0 / 7.0)), 1, 8); return Utility.Random(maxCircle * 2) switch { - 0 => new MagicArrowSpell(m_Mobile), - 1 => new MagicArrowSpell(m_Mobile), - 2 => new HarmSpell(m_Mobile), - 3 => new HarmSpell(m_Mobile), - 4 => new FireballSpell(m_Mobile), - 5 => new FireballSpell(m_Mobile), - 6 => new LightningSpell(m_Mobile), - 7 => new LightningSpell(m_Mobile), - 8 => new MindBlastSpell(m_Mobile), - 9 => new MindBlastSpell(m_Mobile), - 10 => new EnergyBoltSpell(m_Mobile), - 11 => new ExplosionSpell(m_Mobile), - _ => new FlameStrikeSpell(m_Mobile) + 0 => new MagicArrowSpell(Mobile), + 1 => new MagicArrowSpell(Mobile), + 2 => new HarmSpell(Mobile), + 3 => new HarmSpell(Mobile), + 4 => new FireballSpell(Mobile), + 5 => new FireballSpell(Mobile), + 6 => new LightningSpell(Mobile), + 7 => new LightningSpell(Mobile), + 8 => new MindBlastSpell(Mobile), + 9 => new MindBlastSpell(Mobile), + 10 => new EnergyBoltSpell(Mobile), + 11 => new ExplosionSpell(Mobile), + _ => new FlameStrikeSpell(Mobile) }; } @@ -315,36 +315,36 @@ public class MageAI : BaseAI { return Utility.Random(4) switch { - 0 => new BloodOathSpell(m_Mobile), - 1 => new CorpseSkinSpell(m_Mobile), - 2 => new EvilOmenSpell(m_Mobile), - _ => new MindRotSpell(m_Mobile) + 0 => new BloodOathSpell(Mobile), + 1 => new CorpseSkinSpell(Mobile), + 2 => new EvilOmenSpell(Mobile), + _ => new MindRotSpell(Mobile) }; } public virtual Spell GetRandomCurseSpellMage() { - if (m_Mobile.Skills.Magery.Value >= 40.0 && Utility.Random(4) == 0) + if (Mobile.Skills.Magery.Value >= 40.0 && Utility.Random(4) == 0) { - return new CurseSpell(m_Mobile); + return new CurseSpell(Mobile); } return Utility.Random(3) switch { - 0 => new WeakenSpell(m_Mobile), - 1 => new ClumsySpell(m_Mobile), - _ => new FeeblemindSpell(m_Mobile) + 0 => new WeakenSpell(Mobile), + 1 => new ClumsySpell(Mobile), + _ => new FeeblemindSpell(Mobile) }; } public virtual Spell GetRandomManaDrainSpell() { - if (m_Mobile.Skills.Magery.Value >= 80.0 && Utility.RandomBool()) + if (Mobile.Skills.Magery.Value >= 80.0 && Utility.RandomBool()) { - return new ManaVampireSpell(m_Mobile); + return new ManaVampireSpell(Mobile); } - return new ManaDrainSpell(m_Mobile); + return new ManaDrainSpell(Mobile); } public virtual Spell DoDispel(Mobile toDispel) @@ -353,7 +353,7 @@ public class MageAI : BaseAI { if (DispelChance > 0 && ScaleBySkill(DispelChance, SkillName.Magery) > Utility.RandomDouble()) { - return new DispelSpell(m_Mobile); + return new DispelSpell(Mobile); } return null; @@ -366,18 +366,18 @@ public class MageAI : BaseAI return spell; } - var distance = (int)m_Mobile.GetDistanceToSqrt(toDispel); - if (!m_Mobile.DisallowAllMoves && distance > 0 && Utility.Random(distance) == 0) + var distance = (int)Mobile.GetDistanceToSqrt(toDispel); + if (!Mobile.DisallowAllMoves && distance > 0 && Utility.Random(distance) == 0) { - return new TeleportSpell(m_Mobile); + return new TeleportSpell(Mobile); } - if (Utility.Random(3) == 0 && !m_Mobile.InRange(toDispel, 3) && !toDispel.Paralyzed && !toDispel.Frozen) + if (Utility.Random(3) == 0 && !Mobile.InRange(toDispel, 3) && !toDispel.Paralyzed && !toDispel.Frozen) { - return new ParalyzeSpell(m_Mobile); + return new ParalyzeSpell(Mobile); } - return new DispelSpell(m_Mobile); + return new DispelSpell(Mobile); } public virtual Spell ChooseSpell(Mobile c) @@ -396,12 +396,12 @@ public class MageAI : BaseAI if (IsNecromancer) { var psDamage = - (m_Mobile.Skills.SpiritSpeak.Value - c.Skills.MagicResist.Value) / 10 + + (Mobile.Skills.SpiritSpeak.Value - c.Skills.MagicResist.Value) / 10 + (c.Player ? 18 : 30); if (psDamage > c.Hits) { - return new PainSpikeSpell(m_Mobile); + return new PainSpikeSpell(Mobile); } } @@ -415,30 +415,30 @@ public class MageAI : BaseAI goto default; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Attempting to poison"); + Mobile.DebugSay("Attempting to poison"); } - spell = new PoisonSpell(m_Mobile); + spell = new PoisonSpell(Mobile); break; } case 2: // Bless ourselves { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Blessing myself"); + Mobile.DebugSay("Blessing myself"); } - spell = new BlessSpell(m_Mobile); + spell = new BlessSpell(Mobile); break; } case 3: case 4: // Curse them { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Attempting to curse"); + Mobile.DebugSay("Attempting to curse"); } spell = GetRandomCurseSpell(); @@ -446,24 +446,24 @@ public class MageAI : BaseAI } case 5: // Paralyze them { - if (c.Paralyzed || m_Mobile.Skills.Magery.Value <= 50.0) + if (c.Paralyzed || Mobile.Skills.Magery.Value <= 50.0) { goto default; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Attempting to paralyze"); + Mobile.DebugSay("Attempting to paralyze"); } - spell = new ParalyzeSpell(m_Mobile); + spell = new ParalyzeSpell(Mobile); break; } case 6: // Drain mana { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Attempting to drain mana"); + Mobile.DebugSay("Attempting to drain mana"); } spell = GetRandomManaDrainSpell(); @@ -476,19 +476,19 @@ public class MageAI : BaseAI goto default; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Attempting to invis myself"); + Mobile.DebugSay("Attempting to invis myself"); } - spell = new InvisibilitySpell(m_Mobile); + spell = new InvisibilitySpell(Mobile); break; } default: // Damage them { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Just doing damage"); + Mobile.DebugSay("Just doing damage"); } spell = GetRandomDamageSpell(); @@ -511,7 +511,7 @@ public class MageAI : BaseAI goto case 1; } - spell = new PoisonSpell(m_Mobile); + spell = new PoisonSpell(Mobile); break; } case 1: // Deal some damage @@ -521,33 +521,33 @@ public class MageAI : BaseAI } default: // Set up a combo { - if (m_Mobile.Mana is > 15 and < 40) + if (Mobile.Mana is > 15 and < 40) { - if (c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating) + if (c.Paralyzed && !c.Poisoned && !Mobile.Meditating) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am going to meditate"); + Mobile.DebugSay("I am going to meditate"); } - m_Mobile.UseSkill(SkillName.Meditation); + Mobile.UseSkill(SkillName.Meditation); } else if (!c.Poisoned) { - spell = new ParalyzeSpell(m_Mobile); + spell = new ParalyzeSpell(Mobile); } } - else if (m_Mobile.Mana > 60) + else if (Mobile.Mana > 60) { if (Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned) { - m_Combo = 0; - spell = new ParalyzeSpell(m_Mobile); + _combo = 0; + spell = new ParalyzeSpell(Mobile); } else { - m_Combo = 1; - spell = new ExplosionSpell(m_Mobile); + _combo = 1; + spell = new ExplosionSpell(Mobile); } } @@ -557,15 +557,15 @@ public class MageAI : BaseAI } } - if (m_Mobile.Debug) + if (Mobile.Debug) { if (spell != null) { - m_Mobile.DebugSay($"Casting {spell.Name}"); + Mobile.DebugSay($"Casting {spell.Name}"); } else { - m_Mobile.DebugSay("I don't have a spell to use!"); + Mobile.DebugSay("I don't have a spell to use!"); } } @@ -576,31 +576,31 @@ public class MageAI : BaseAI { Spell spell = null; - if (m_Combo == 0) + if (_combo == 0) { - spell = new ExplosionSpell(m_Mobile); - ++m_Combo; // Move to next spell + spell = new ExplosionSpell(Mobile); + ++_combo; // Move to next spell } - else if (m_Combo == 1) + else if (_combo == 1) { - spell = new WeakenSpell(m_Mobile); - ++m_Combo; // Move to next spell + spell = new WeakenSpell(Mobile); + ++_combo; // Move to next spell } - else if (m_Combo == 2) + else if (_combo == 2) { if (!c.Poisoned) { - spell = new PoisonSpell(m_Mobile); + spell = new PoisonSpell(Mobile); } else if (IsNecromancer) { - spell = new StrangleSpell(m_Mobile); + spell = new StrangleSpell(Mobile); } - ++m_Combo; // Move to next spell + ++_combo; // Move to next spell } - if (m_Combo == 3 && spell == null) + if (_combo == 3 && spell == null) { switch (Utility.Random(IsNecromancer ? 4 : 3)) { @@ -608,41 +608,41 @@ public class MageAI : BaseAI { if (c.Int < c.Dex) { - spell = new FeeblemindSpell(m_Mobile); + spell = new FeeblemindSpell(Mobile); } else { - spell = new ClumsySpell(m_Mobile); + spell = new ClumsySpell(Mobile); } - ++m_Combo; // Move to next spell + ++_combo; // Move to next spell break; } case 1: { - spell = new EnergyBoltSpell(m_Mobile); - m_Combo = -1; // Reset combo state + spell = new EnergyBoltSpell(Mobile); + _combo = -1; // Reset combo state break; } case 2: { - spell = new FlameStrikeSpell(m_Mobile); - m_Combo = -1; // Reset combo state + spell = new FlameStrikeSpell(Mobile); + _combo = -1; // Reset combo state break; } default: { - spell = new PainSpikeSpell(m_Mobile); - m_Combo = -1; // Reset combo state + spell = new PainSpikeSpell(Mobile); + _combo = -1; // Reset combo state break; } } } - else if (m_Combo == 4 && spell == null) + else if (_combo == 4 && spell == null) { - spell = new MindBlastSpell(m_Mobile); - m_Combo = -1; + spell = new MindBlastSpell(Mobile); + _combo = -1; } return spell; @@ -652,7 +652,7 @@ public class MageAI : BaseAI { if (SmartAI || spell is DispelSpell) { - return TimeSpan.FromSeconds(m_Mobile.ActiveSpeed); + return TimeSpan.FromSeconds(Mobile.ActiveSpeed); } var del = ScaleBySkill(3.0, SkillName.Magery); @@ -664,33 +664,33 @@ public class MageAI : BaseAI public override bool DoActionCombat() { - var c = m_Mobile.Combatant; - m_Mobile.Warmode = true; + var c = Mobile.Combatant; + Mobile.Warmode = true; - if (c?.Deleted != false || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || - !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map) + if (c?.Deleted != false || !c.Alive || c.IsDeadBondedPet || !Mobile.CanSee(c) || + !Mobile.CanBeHarmful(c, false) || c.Map != Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - m_Mobile.Combatant = c = m_Mobile.FocusMob!; + Mobile.Combatant = c = Mobile.FocusMob!; - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay( + Mobile.DebugSay( $"Something happened to my combatant, so I am going to fight {c.Name}" ); } - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); + Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); } Action = ActionType.Guard; @@ -698,53 +698,53 @@ public class MageAI : BaseAI } } - if (!m_Mobile.InLOS(c)) + if (!Mobile.InLOS(c)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I can't see my target"); + Mobile.DebugSay("I can't see my target"); } - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - m_Mobile.Combatant = c = m_Mobile.FocusMob!; + Mobile.Combatant = c = Mobile.FocusMob!; - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I will switch to {c.Name}"); + Mobile.DebugSay($"I will switch to {c.Name}"); } - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; } } - if (!Core.AOS && SmartAI && !m_Mobile.StunReady && m_Mobile.Skills.Wrestling.Value >= 80.0 && - m_Mobile.Skills.Anatomy.Value >= 80.0) + if (!Core.AOS && SmartAI && !Mobile.StunReady && Mobile.Skills.Wrestling.Value >= 80.0 && + Mobile.Skills.Anatomy.Value >= 80.0) { - Fists.StunRequest(m_Mobile); + Fists.StunRequest(Mobile); } - if (!m_Mobile.InRange(c, m_Mobile.RangePerception)) + if (!Mobile.InRange(c, Mobile.RangePerception)) { // They are somewhat far away, can we find something else? - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - m_Mobile.Combatant = m_Mobile.FocusMob; - m_Mobile.FocusMob = null; + Mobile.Combatant = Mobile.FocusMob; + Mobile.FocusMob = null; } - else if (!m_Mobile.InRange(c, m_Mobile.RangePerception * 3)) + else if (!Mobile.InRange(c, Mobile.RangePerception * 3)) { - m_Mobile.Combatant = null; + Mobile.Combatant = null; } - c = m_Mobile.Combatant; + c = Mobile.Combatant; if (c == null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant has fled, so I am on guard"); + Mobile.DebugSay("My combatant has fled, so I am on guard"); } Action = ActionType.Guard; @@ -752,17 +752,17 @@ public class MageAI : BaseAI } } - if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee && m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100) + if (!Mobile.Controlled && !Mobile.Summoned && Mobile.CanFlee && Mobile.Hits < Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? // (10 + diff)% chance to flee - var fleeChance = 10 + Math.Max(0, c.Hits - m_Mobile.Hits); + var fleeChance = 10 + Math.Max(0, c.Hits - Mobile.Hits); if (Utility.Random(0, 100) > fleeChance) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to flee from {c.Name}"); + Mobile.DebugSay($"I am going to flee from {c.Name}"); } Action = ActionType.Flee; @@ -770,33 +770,33 @@ public class MageAI : BaseAI } } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, c)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, c)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I used my abilities!"); + Mobile.DebugSay("I used my abilities!"); } } - else if (m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0) + else if (Mobile.Spell == null && Core.TickCount - _nextCastTime >= 0) { // We are ready to cast a spell Spell spell; var toDispel = FindDispelTarget(true); - if (m_Mobile.Poisoned) // Top cast priority is cure + if (Mobile.Poisoned) // Top cast priority is cure { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am going to cure myself"); + Mobile.DebugSay("I am going to cure myself"); } - spell = new CureSpell(m_Mobile); + spell = new CureSpell(Mobile); } else if (toDispel != null) // Something dispellable is attacking us { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to dispel {toDispel}"); + Mobile.DebugSay($"I am going to dispel {toDispel}"); } spell = DoDispel(toDispel); // May return null if dumb AI and doesn't have enough skill @@ -809,96 +809,96 @@ public class MageAI : BaseAI spell ??= SmartAI switch { // We are doing a spell combo - true when m_Combo != -1 => DoCombo(c), + true when _combo != -1 => DoCombo(c), // They have a heal spell out - true when !c.Poisoned && c.Spell is HealSpell or GreaterHealSpell => new PoisonSpell(m_Mobile), + true when !c.Poisoned && c.Spell is HealSpell or GreaterHealSpell => new PoisonSpell(Mobile), _ => ChooseSpell(c) }; // Now we have a spell picked - var range = (spell as IRangedSpell)?.TargetRange ?? m_Mobile.RangePerception; + var range = (spell as IRangedSpell)?.TargetRange ?? Mobile.RangePerception; // Move first before casting if (!SmartAI || toDispel == null) { RunTo(c); } - else if (m_Mobile.InRange(toDispel, Math.Min(10, range))) + else if (Mobile.InRange(toDispel, Math.Min(10, range))) { RunFrom(toDispel); } - else if (!m_Mobile.InRange(toDispel, range)) + else if (!Mobile.InRange(toDispel, range)) { RunTo(toDispel); } // After running, make sure we are still in range - if (spell == null || m_Mobile.InRange(c, range)) + if (spell == null || Mobile.InRange(c, range)) { spell?.Cast(); // Even if we don't have a spell, delay the next potential cast - m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds; + _nextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds; } } - else if (m_Mobile.Spell?.IsCasting != true) + else if (Mobile.Spell?.IsCasting != true) { RunTo(c); } - if (m_Mobile.Spell != null || !m_Mobile.InRange(c, 1) || Core.TickCount - m_Mobile.LastMoveTime > 800) + if (Mobile.Spell != null || !Mobile.InRange(c, 1) || Core.TickCount - Mobile.LastMoveTime > 800) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(c); + Mobile.Direction = Mobile.GetDirectionTo(c); } - m_LastTarget = c; - m_LastTargetLoc = c.Location; + _lastTarget = c; + _lastTargetLoc = c.Location; return true; } public override bool DoActionGuard() { - if (m_LastTarget?.Hidden == true) + if (_lastTarget?.Hidden == true) { - var map = m_Mobile.Map; + var map = Mobile.Map; - if (map == null || !m_Mobile.InRange(m_LastTargetLoc, m_Mobile.RangePerception)) + if (map == null || !Mobile.InRange(_lastTargetLoc, Mobile.RangePerception)) { - m_LastTarget = null; + _lastTarget = null; } - else if (m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0) + else if (Mobile.Spell == null && Core.TickCount - _nextCastTime >= 0) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am going to reveal my last target"); + Mobile.DebugSay("I am going to reveal my last target"); } - m_RevealTarget = new LandTarget(m_LastTargetLoc, map); - Spell spell = new RevealSpell(m_Mobile); + _revealTarget = new LandTarget(_lastTargetLoc, map); + Spell spell = new RevealSpell(Mobile); if (spell.Cast()) { - m_LastTarget = null; // only do it once + _lastTarget = null; // only do it once } - m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds; + _nextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds; } } - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to attack {m_Mobile.FocusMob.Name}"); + Mobile.DebugSay($"I am going to attack {Mobile.FocusMob.Name}"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else { - if (!m_Mobile.Controlled) + if (!Mobile.Controlled) { ProcessTarget(); @@ -917,39 +917,39 @@ public class MageAI : BaseAI { // Mobile c = m_Mobile.Combatant; - if ((m_Mobile.Mana > 20 || m_Mobile.Mana == m_Mobile.ManaMax) && m_Mobile.Hits > m_Mobile.HitsMax / 2) + if ((Mobile.Mana > 20 || Mobile.Mana == Mobile.ManaMax) && Mobile.Hits > Mobile.HitsMax / 2) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am stronger now, my guard is up"); + Mobile.DebugSay("I am stronger now, my guard is up"); } Action = ActionType.Guard; } - else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + else if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am scared of {m_Mobile.FocusMob.Name}"); + Mobile.DebugSay($"I am scared of {Mobile.FocusMob.Name}"); } - RunFrom(m_Mobile.FocusMob); - m_Mobile.FocusMob = null; + RunFrom(Mobile.FocusMob); + Mobile.FocusMob = null; - if (m_Mobile.Poisoned && Utility.Random(0, 5) == 0) + if (Mobile.Poisoned && Utility.Random(0, 5) == 0) { - new CureSpell(m_Mobile).Cast(); + new CureSpell(Mobile).Cast(); } } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Area seems clear, but my guard is up"); + Mobile.DebugSay("Area seems clear, but my guard is up"); } Action = ActionType.Guard; - m_Mobile.Warmode = true; + Mobile.Warmode = true; } return true; @@ -957,26 +957,26 @@ public class MageAI : BaseAI public Mobile FindDispelTarget(bool activeOnly) { - if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel) + if (Mobile.Deleted || Mobile.Int < 95 || CanDispel(Mobile) || Mobile.AutoDispel) { return null; } if (activeOnly) { - var aggressed = m_Mobile.Aggressed; - var aggressors = m_Mobile.Aggressors; + var aggressed = Mobile.Aggressed; + var aggressors = Mobile.Aggressors; Mobile active = null; var activePrio = 0.0; - var comb = m_Mobile.Combatant; + var comb = Mobile.Combatant; if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && - m_Mobile.InRange(comb, m_Mobile.RangePerception) && CanDispel(comb)) + Mobile.InRange(comb, Mobile.RangePerception) && CanDispel(comb)) { active = comb; - activePrio = m_Mobile.GetDistanceToSqrt(comb); + activePrio = Mobile.GetDistanceToSqrt(comb); if (activePrio <= 2) { @@ -989,9 +989,9 @@ public class MageAI : BaseAI var info = aggressed[i]; var m = info.Defender; - if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, m_Mobile.RangePerception) && CanDispel(m)) + if (m != comb && m.Combatant == Mobile && Mobile.InRange(m, Mobile.RangePerception) && CanDispel(m)) { - var prio = m_Mobile.GetDistanceToSqrt(m); + var prio = Mobile.GetDistanceToSqrt(m); if (active == null || prio < activePrio) { @@ -1011,9 +1011,9 @@ public class MageAI : BaseAI var info = aggressors[i]; var m = info.Attacker; - if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, m_Mobile.RangePerception) && CanDispel(m)) + if (m != comb && m.Combatant == Mobile && Mobile.InRange(m, Mobile.RangePerception) && CanDispel(m)) { - var prio = m_Mobile.GetDistanceToSqrt(m); + var prio = Mobile.GetDistanceToSqrt(m); if (active == null || prio < activePrio) { @@ -1031,26 +1031,26 @@ public class MageAI : BaseAI return active; } - var map = m_Mobile.Map; + var map = Mobile.Map; if (map != null) { Mobile active = null, inactive = null; double actPrio = 0.0, inactPrio = 0.0; - var comb = m_Mobile.Combatant; + var comb = Mobile.Combatant; if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb)) { active = inactive = comb; - actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb); + actPrio = inactPrio = Mobile.GetDistanceToSqrt(comb); } - foreach (var m in m_Mobile.GetMobilesInRange(m_Mobile.RangePerception)) + foreach (var m in Mobile.GetMobilesInRange(Mobile.RangePerception)) { - if (m != m_Mobile && CanDispel(m)) + if (m != Mobile && CanDispel(m)) { - var prio = m_Mobile.GetDistanceToSqrt(m); + var prio = Mobile.GetDistanceToSqrt(m); if (inactive == null || prio < inactPrio) { @@ -1058,7 +1058,7 @@ public class MageAI : BaseAI inactPrio = prio; } - if ((m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio)) + if ((Mobile.Combatant == m || m.Combatant == Mobile) && (active == null || prio < actPrio)) { active = m; actPrio = prio; @@ -1073,12 +1073,12 @@ public class MageAI : BaseAI } public bool CanDispel(Mobile m) => - m is BaseCreature creature && creature.Summoned && creature.SummonMaster != m_Mobile && - m_Mobile.CanBeHarmful(creature, false) && !creature.IsAnimatedDead; + m is BaseCreature creature && creature.Summoned && creature.SummonMaster != Mobile && + Mobile.CanBeHarmful(creature, false) && !creature.IsAnimatedDead; private bool ProcessTarget() { - var targ = m_Mobile.Target; + var targ = Mobile.Target; if (targ == null) { @@ -1098,7 +1098,7 @@ public class MageAI : BaseAI if (isInvisible) { - toTarget = m_Mobile; + toTarget = Mobile; } else if (isDispel) { @@ -1108,7 +1108,7 @@ public class MageAI : BaseAI { RunTo(toTarget); } - else if (toTarget != null && m_Mobile.InRange(toTarget, 10)) + else if (toTarget != null && Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); } @@ -1119,14 +1119,14 @@ public class MageAI : BaseAI if (toTarget == null) { - toTarget = m_Mobile.Combatant; + toTarget = Mobile.Combatant; if (toTarget != null) { RunTo(toTarget); } } - else if (m_Mobile.InRange(toTarget, 10)) + else if (Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); teleportAway = true; @@ -1138,7 +1138,7 @@ public class MageAI : BaseAI } else { - toTarget = m_Mobile.Combatant; + toTarget = Mobile.Combatant; if (toTarget != null) { @@ -1148,27 +1148,27 @@ public class MageAI : BaseAI if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { - if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && - m_Mobile.InLOS(toTarget)) + if ((targ.Range == -1 || Mobile.InRange(toTarget, targ.Range)) && Mobile.CanSee(toTarget) && + Mobile.InLOS(toTarget)) { - targ.Invoke(m_Mobile, toTarget); + targ.Invoke(Mobile, toTarget); } else if (isDispel) { - targ.Cancel(m_Mobile, TargetCancelType.Canceled); + targ.Cancel(Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { - targ.Invoke(m_Mobile, m_Mobile); + targ.Invoke(Mobile, Mobile); } - else if (isReveal && m_RevealTarget != null) + else if (isReveal && _revealTarget != null) { - targ.Invoke(m_Mobile, m_RevealTarget); + targ.Invoke(Mobile, _revealTarget); } else { - var map = m_Mobile.Map; + var map = Mobile.Map; if (map != null && isTeleport && toTarget != null) { @@ -1179,10 +1179,10 @@ public class MageAI : BaseAI if (teleportAway) { - var rx = m_Mobile.X - toTarget.X; - var ry = m_Mobile.Y - toTarget.Y; + var rx = Mobile.X - toTarget.X; + var ry = Mobile.Y - toTarget.Y; - var d = m_Mobile.GetDistanceToSqrt(toTarget); + var d = Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); @@ -1193,18 +1193,18 @@ public class MageAI : BaseAI py = toTarget.Y; } - for (var i = 0; i < m_Offsets.Length; i += 2) + for (var i = 0; i < _offsets.Length; i += 2) { - int x = m_Offsets[i], y = m_Offsets[i + 1]; + int x = _offsets[i], y = _offsets[i + 1]; var p = new Point3D(px + x, py + y, 0); var lt = new LandTarget(p, map); - if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && + if ((targ.Range == -1 || Mobile.InRange(p, targ.Range)) && Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { - targ.Invoke(m_Mobile, lt); + targ.Invoke(Mobile, lt); return true; } } @@ -1212,23 +1212,23 @@ public class MageAI : BaseAI for (var i = 0; i < 10; ++i) { var randomPoint = new Point3D( - m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), - m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), + Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), + Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0 ); var lt = new LandTarget(randomPoint, map); - if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && + if (Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { - targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); + targ.Invoke(Mobile, new LandTarget(randomPoint, map)); return true; } } } - targ.Cancel(m_Mobile, TargetCancelType.Canceled); + targ.Cancel(Mobile, TargetCancelType.Canceled); } return true; diff --git a/Projects/UOContent/Mobiles/AI/MeleeAI.cs b/Projects/UOContent/Mobiles/AI/MeleeAI.cs index f431b1d23..075b4f06c 100644 --- a/Projects/UOContent/Mobiles/AI/MeleeAI.cs +++ b/Projects/UOContent/Mobiles/AI/MeleeAI.cs @@ -10,24 +10,24 @@ public class MeleeAI : BaseAI public override bool DoActionWander() { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am wandering"); + Mobile.DebugSay("I am wandering"); } - m_Mobile.Warmode = false; + Mobile.Warmode = false; base.DoActionWander(); } @@ -37,41 +37,41 @@ public class MeleeAI : BaseAI public override bool DoActionCombat() { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone, so my guard is up"); + Mobile.DebugSay("My combatant is gone, so my guard is up"); } Action = ActionType.Guard; return true; } - if (!m_Mobile.InRange(combatant, m_Mobile.RangePerception)) + if (!Mobile.InRange(combatant, Mobile.RangePerception)) { // They are somewhat far away, can we find something else? - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - m_Mobile.Combatant = m_Mobile.FocusMob; - m_Mobile.FocusMob = null; + Mobile.Combatant = Mobile.FocusMob; + Mobile.FocusMob = null; } - else if (!m_Mobile.InRange(combatant, m_Mobile.RangePerception * 3)) + else if (!Mobile.InRange(combatant, Mobile.RangePerception * 3)) { - m_Mobile.Combatant = null; + Mobile.Combatant = null; } - combatant = m_Mobile.Combatant; + combatant = Mobile.Combatant; if (combatant == null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant has fled, so I am on guard"); + Mobile.DebugSay("My combatant has fled, so I am on guard"); } Action = ActionType.Guard; @@ -79,58 +79,58 @@ public class MeleeAI : BaseAI } } - if (!MoveTo(combatant, true, m_Mobile.RangeFight)) + if (!MoveTo(combatant, true, Mobile.RangeFight)) { - if (m_Mobile.InRange(combatant, 1)) + if (Mobile.InRange(combatant, 1)) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); + Mobile.Direction = Mobile.GetDirectionTo(combatant); } - - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"My move is blocked, so I am going to attack {m_Mobile.FocusMob!.Name}"); + Mobile.DebugSay($"My move is blocked, so I am going to attack {Mobile.FocusMob!.Name}"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; return true; } - if (m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) + if (Mobile.GetDistanceToSqrt(combatant) > Mobile.RangePerception + 1) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I cannot find {combatant.Name}, so my guard is up"); + Mobile.DebugSay($"I cannot find {combatant.Name}, so my guard is up"); } Action = ActionType.Guard; return true; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I cannot find {combatant.Name}, so my guard is up"); + Mobile.DebugSay($"I cannot find {combatant.Name}, so my guard is up"); } } - else if (Core.TickCount - m_Mobile.LastMoveTime > 400) + else if (Core.TickCount - Mobile.LastMoveTime > 400) { - m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); + Mobile.Direction = Mobile.GetDirectionTo(combatant); } - if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee) + if (!Mobile.Controlled && !Mobile.Summoned && Mobile.CanFlee) { - if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100) + if (Mobile.Hits < Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? - var fleeChance = 10 + Math.Max(0, combatant.Hits - m_Mobile.Hits); // (10 + diff)% chance to flee; + var fleeChance = 10 + Math.Max(0, combatant.Hits - Mobile.Hits); // (10 + diff)% chance to flee; if (Utility.Random(0, 100) < fleeChance) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to flee from {combatant.Name}"); + Mobile.DebugSay($"I am going to flee from {combatant.Name}"); } Action = ActionType.Flee; @@ -139,11 +139,11 @@ public class MeleeAI : BaseAI } } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I used my abilities!"); + Mobile.DebugSay("I used my abilities!"); } } @@ -152,14 +152,14 @@ public class MeleeAI : BaseAI public override bool DoActionGuard() { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else @@ -172,20 +172,20 @@ public class MeleeAI : BaseAI public override bool DoActionFlee() { - if (m_Mobile.Hits > m_Mobile.HitsMax / 2) + if (Mobile.Hits > Mobile.HitsMax / 2) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am stronger now, so I will continue fighting"); + Mobile.DebugSay("I am stronger now, so I will continue fighting"); } - m_Mobile.PlaySound(m_Mobile.GetAttackSound()); - m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed; + Mobile.PlaySound(Mobile.GetAttackSound()); + Mobile.CurrentSpeed = Mobile.ActiveSpeed; Action = ActionType.Combat; } else { - m_Mobile.FocusMob = m_Mobile.Combatant; + Mobile.FocusMob = Mobile.Combatant; base.DoActionFlee(); } diff --git a/Projects/UOContent/Mobiles/AI/OppositionGroup.cs b/Projects/UOContent/Mobiles/AI/OppositionGroup.cs index 9c7dafb97..c087112db 100644 --- a/Projects/UOContent/Mobiles/AI/OppositionGroup.cs +++ b/Projects/UOContent/Mobiles/AI/OppositionGroup.cs @@ -5,9 +5,9 @@ namespace Server { public class OppositionGroup { - private readonly Type[][] m_Types; + private readonly Type[][] _types; - public OppositionGroup(Type[][] types) => m_Types = types; + public OppositionGroup(Type[][] types) => _types = types; public static OppositionGroup TerathansAndOphidians { get; } = new( new[] @@ -112,9 +112,9 @@ namespace Server var type = obj.GetType(); - for (var i = 0; i < m_Types.Length; ++i) + for (var i = 0; i < _types.Length; ++i) { - var group = m_Types[i]; + var group = _types[i]; var contains = false; diff --git a/Projects/UOContent/Mobiles/AI/PredatorAI.cs b/Projects/UOContent/Mobiles/AI/PredatorAI.cs index 7532595df..31a683ca5 100644 --- a/Projects/UOContent/Mobiles/AI/PredatorAI.cs +++ b/Projects/UOContent/Mobiles/AI/PredatorAI.cs @@ -8,20 +8,20 @@ public class PredatorAI : BaseAI public override bool DoActionWander() { - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am hurt or being attacked, I kill him"); + Mobile.DebugSay("I am hurt or being attacked, I kill him"); } Action = ActionType.Combat; } - else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, true, false, true)) + else if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, true, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("There is something near, I go away"); + Mobile.DebugSay("There is something near, I go away"); } Action = ActionType.Backoff; @@ -36,44 +36,44 @@ public class PredatorAI : BaseAI public override bool DoActionCombat() { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone, so my guard is up"); + Mobile.DebugSay("My combatant is gone, so my guard is up"); } Action = ActionType.Guard; return true; } - if (!WalkMobileRange(combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight)) + if (!WalkMobileRange(combatant, 1, true, Mobile.RangeFight, Mobile.RangeFight)) { - if (m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) + if (Mobile.GetDistanceToSqrt(combatant) > Mobile.RangePerception + 1) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I cannot find {combatant.Name}"); + Mobile.DebugSay($"I cannot find {combatant.Name}"); } Action = ActionType.Wander; return true; } - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I should be closer to {combatant.Name}"); + Mobile.DebugSay($"I should be closer to {combatant.Name}"); } } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {combatant.Name}!"); } } @@ -82,17 +82,17 @@ public class PredatorAI : BaseAI public override bool DoActionBackoff() { - if (m_Mobile.IsHurt() || m_Mobile.Combatant != null) + if (Mobile.IsHurt() || Mobile.Combatant != null) { Action = ActionType.Combat; } - else if (AcquireFocusMob(m_Mobile.RangePerception * 2, FightMode.Closest, true, false, true)) + else if (AcquireFocusMob(Mobile.RangePerception * 2, FightMode.Closest, true, false, true)) { - if (WalkMobileRange(m_Mobile.FocusMob, 1, false, m_Mobile.RangePerception, m_Mobile.RangePerception * 2)) + if (WalkMobileRange(Mobile.FocusMob, 1, false, Mobile.RangePerception, Mobile.RangePerception * 2)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Well, here I am safe"); + Mobile.DebugSay("Well, here I am safe"); } Action = ActionType.Wander; @@ -100,9 +100,9 @@ public class PredatorAI : BaseAI } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have lost my focus, lets relax"); + Mobile.DebugSay("I have lost my focus, lets relax"); } Action = ActionType.Wander; diff --git a/Projects/UOContent/Mobiles/AI/ThiefAI.cs b/Projects/UOContent/Mobiles/AI/ThiefAI.cs index c81e5be6e..30adec3cf 100644 --- a/Projects/UOContent/Mobiles/AI/ThiefAI.cs +++ b/Projects/UOContent/Mobiles/AI/ThiefAI.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles; public class ThiefAI : BaseAI { - private Item m_toDisarm; + private Item _toDisarm; public ThiefAI(BaseCreature m) : base(m) { @@ -13,19 +13,19 @@ public class ThiefAI : BaseAI public override bool DoActionWander() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I have no combatant"); + Mobile.DebugSay("I have no combatant"); } - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else @@ -38,57 +38,57 @@ public class ThiefAI : BaseAI public override bool DoActionCombat() { - var combatant = m_Mobile.Combatant; + var combatant = Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My combatant is gone, so my guard is up"); + Mobile.DebugSay("My combatant is gone, so my guard is up"); } Action = ActionType.Guard; return true; } - if (!WalkMobileRange(combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight)) + if (!WalkMobileRange(combatant, 1, true, Mobile.RangeFight, Mobile.RangeFight)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I should be closer to {combatant.Name}"); + Mobile.DebugSay($"I should be closer to {combatant.Name}"); } } else { - if (m_toDisarm?.IsChildOf(m_Mobile.Backpack) != false) + if (_toDisarm?.IsChildOf(Mobile.Backpack) != false) { - m_toDisarm = combatant.FindItemOnLayer(Layer.OneHanded) ?? combatant.FindItemOnLayer(Layer.TwoHanded); + _toDisarm = combatant.FindItemOnLayer(Layer.OneHanded) ?? combatant.FindItemOnLayer(Layer.TwoHanded); } - if (!Core.AOS && !m_Mobile.DisarmReady && m_Mobile.Skills.Wrestling.Value >= 80.0 && - m_Mobile.Skills.ArmsLore.Value >= 80.0 && m_toDisarm != null) + if (!Core.AOS && !Mobile.DisarmReady && Mobile.Skills.Wrestling.Value >= 80.0 && + Mobile.Skills.ArmsLore.Value >= 80.0 && _toDisarm != null) { - Fists.DisarmRequest(m_Mobile); + Fists.DisarmRequest(Mobile); } - if (m_toDisarm?.IsChildOf(combatant.Backpack) == true && - Core.TickCount - m_Mobile.NextSkillTime >= 0 && m_toDisarm.LootType != LootType.Blessed && - m_toDisarm.LootType != LootType.Newbied) + if (_toDisarm?.IsChildOf(combatant.Backpack) == true && + Core.TickCount - Mobile.NextSkillTime >= 0 && _toDisarm.LootType != LootType.Blessed && + _toDisarm.LootType != LootType.Newbied) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("Trying to steal from combatant."); + Mobile.DebugSay("Trying to steal from combatant."); } - m_Mobile.UseSkill(SkillName.Stealing); - m_Mobile.Target?.Invoke(m_Mobile, m_toDisarm); + Mobile.UseSkill(SkillName.Stealing); + Mobile.Target?.Invoke(Mobile, _toDisarm); } - else if (m_toDisarm == null && Core.TickCount - m_Mobile.NextSkillTime >= 0) + else if (_toDisarm == null && Core.TickCount - Mobile.NextSkillTime >= 0) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"Trying to steal from {combatant.Name}."); + Mobile.DebugSay($"Trying to steal from {combatant.Name}."); } bool didSteal = TryStealFrom(combatant); @@ -98,9 +98,9 @@ public class ThiefAI : BaseAI if (!didSteal) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to flee from {combatant.Name}"); + Mobile.DebugSay($"I am going to flee from {combatant.Name}"); } Action = ActionType.Flee; @@ -111,15 +111,15 @@ public class ThiefAI : BaseAI // We are low on health, should we flee? // (10 + diff)% chance to flee - if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 && m_Mobile.CanFlee) + if (Mobile.Hits < Mobile.HitsMax * 20 / 100 && Mobile.CanFlee) { - var fleeChance = 10 + Math.Max(0, combatant.Hits - m_Mobile.Hits); + var fleeChance = 10 + Math.Max(0, combatant.Hits - Mobile.Hits); if (Utility.Random(0, 100) > fleeChance) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am going to flee from {combatant.Name}"); + Mobile.DebugSay($"I am going to flee from {combatant.Name}"); } Action = ActionType.Flee; @@ -128,11 +128,11 @@ public class ThiefAI : BaseAI return true; } - if (m_Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, m_Mobile.Combatant)) + if (Mobile.TriggerAbility(MonsterAbilityTrigger.CombatAction, Mobile.Combatant)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I used my abilities on {m_Mobile.Combatant.Name}!"); + Mobile.DebugSay($"I used my abilities on {Mobile.Combatant.Name}!"); } } return true; @@ -143,8 +143,8 @@ public class ThiefAI : BaseAI Item steal = combatant.Backpack?.FindItemByType(); if (steal != null) { - m_Mobile.UseSkill(SkillName.Stealing); - m_Mobile.Target?.Invoke(m_Mobile, steal); + Mobile.UseSkill(SkillName.Stealing); + Mobile.Target?.Invoke(Mobile, steal); return true; } @@ -153,14 +153,14 @@ public class ThiefAI : BaseAI public override bool DoActionGuard() { - if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) + if (AcquireFocusMob(Mobile.RangePerception, Mobile.FightMode, false, false, true)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name}, attacking"); + Mobile.DebugSay($"I have detected {Mobile.FocusMob.Name}, attacking"); } - m_Mobile.Combatant = m_Mobile.FocusMob; + Mobile.Combatant = Mobile.FocusMob; Action = ActionType.Combat; } else @@ -173,18 +173,18 @@ public class ThiefAI : BaseAI public override bool DoActionFlee() { - if (m_Mobile.Hits > m_Mobile.HitsMax / 2) + if (Mobile.Hits > Mobile.HitsMax / 2) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I am stronger now, so I will continue fighting"); + Mobile.DebugSay("I am stronger now, so I will continue fighting"); } Action = ActionType.Combat; } else { - m_Mobile.FocusMob = m_Mobile.Combatant; + Mobile.FocusMob = Mobile.Combatant; base.DoActionFlee(); } diff --git a/Projects/UOContent/Mobiles/AI/VendorAI.cs b/Projects/UOContent/Mobiles/AI/VendorAI.cs index 3540655b6..7b2e7950a 100644 --- a/Projects/UOContent/Mobiles/AI/VendorAI.cs +++ b/Projects/UOContent/Mobiles/AI/VendorAI.cs @@ -15,35 +15,35 @@ public class VendorAI : BaseAI public override bool DoActionWander() { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("I'm fine"); + Mobile.DebugSay("I'm fine"); } - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{m_Mobile.Combatant.Name} is attacking me"); + Mobile.DebugSay($"{Mobile.Combatant.Name} is attacking me"); } - m_Mobile.Say(GetRandomGuardMessage()); + Mobile.Say(GetRandomGuardMessage()); Action = ActionType.Flee; } else { - if (m_Mobile.FocusMob != null) + if (Mobile.FocusMob != null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{m_Mobile.FocusMob.Name} has talked to me"); + Mobile.DebugSay($"{Mobile.FocusMob.Name} has talked to me"); } Action = ActionType.Interact; } else { - m_Mobile.Warmode = false; + Mobile.Warmode = false; base.DoActionWander(); } @@ -54,50 +54,50 @@ public class VendorAI : BaseAI public override bool DoActionInteract() { - var customer = m_Mobile.FocusMob; + var customer = Mobile.FocusMob; - if (m_Mobile.Combatant != null) + if (Mobile.Combatant != null) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{m_Mobile.Combatant.Name} is attacking me"); + Mobile.DebugSay($"{Mobile.Combatant.Name} is attacking me"); } - m_Mobile.Say(GetRandomGuardMessage()); + Mobile.Say(GetRandomGuardMessage()); Action = ActionType.Flee; return true; } - if (customer?.Deleted != false || customer.Map != m_Mobile.Map) + if (customer?.Deleted != false || customer.Map != Mobile.Map) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay("My customer have disapeared"); + Mobile.DebugSay("My customer have disapeared"); } - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; Action = ActionType.Wander; } - else if (customer.InRange(m_Mobile, m_Mobile.RangeFight)) + else if (customer.InRange(Mobile, Mobile.RangeFight)) { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"I am with {customer.Name}"); + Mobile.DebugSay($"I am with {customer.Name}"); } - m_Mobile.Direction = m_Mobile.GetDirectionTo(customer); + Mobile.Direction = Mobile.GetDirectionTo(customer); } else { - if (m_Mobile.Debug) + if (Mobile.Debug) { - m_Mobile.DebugSay($"{customer.Name} is gone"); + Mobile.DebugSay($"{customer.Name} is gone"); } - m_Mobile.FocusMob = null; + Mobile.FocusMob = null; Action = ActionType.Wander; } @@ -106,13 +106,13 @@ public class VendorAI : BaseAI public override bool DoActionGuard() { - m_Mobile.FocusMob = m_Mobile.Combatant; + Mobile.FocusMob = Mobile.Combatant; return base.DoActionGuard(); } public override bool HandlesOnSpeech(Mobile from) { - if (from.InRange(m_Mobile, 4)) + if (from.InRange(Mobile, 4)) { return true; } @@ -127,7 +127,7 @@ public class VendorAI : BaseAI var from = e.Mobile; - if (m_Mobile is BaseVendor vendor && from.InRange(m_Mobile, Core.AOS ? 1 : 4) && !e.Handled) + if (Mobile is BaseVendor vendor && from.InRange(Mobile, Core.AOS ? 1 : 4) && !e.Handled) { if (e.HasKeyword(0x14D)) // *vendor sell* { diff --git a/Projects/UOContent/Mobiles/BaseCreature.cs b/Projects/UOContent/Mobiles/BaseCreature.cs index 0957a8c22..d15bf8ef8 100644 --- a/Projects/UOContent/Mobiles/BaseCreature.cs +++ b/Projects/UOContent/Mobiles/BaseCreature.cs @@ -2258,7 +2258,7 @@ namespace Server.Mobiles public void ChangeAIType(AIType newAI) { - AIObject?.m_Timer.Stop(); + AIObject?._timer.Stop(); if (ForcedAI != null) { @@ -2381,7 +2381,7 @@ namespace Server.Mobiles { if (AIObject != null) { - AIObject.m_Timer?.Stop(); + AIObject._timer?.Stop(); AIObject = null; } diff --git a/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs b/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs index d5a088123..6d85b9d73 100644 --- a/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs +++ b/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs @@ -234,11 +234,11 @@ namespace Server.Mobiles public override bool Think() { // Clones only follow their owners - var master = m_Mobile.SummonMaster; + var master = Mobile.SummonMaster; - if (master?.Map == m_Mobile.Map && master?.InRange(m_Mobile, m_Mobile.RangePerception) == true) + if (master?.Map == Mobile.Map && master?.InRange(Mobile, Mobile.RangePerception) == true) { - var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(master); + var iCurrDist = (int)Mobile.GetDistanceToSqrt(master); var bRun = iCurrDist > 5; WalkMobileRange(master, 2, bRun, 0, 1);