Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -4,7 +4,7 @@
|
|||
// More your close, the more it can panic
|
||||
/*
|
||||
* AnimalHunterAI, AnimalHidingAI, AnimalDomesticAI...
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Server.Mobiles
|
||||
|
|
@ -26,7 +26,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
else if ( m_Mobile.IsHurt() || m_Mobile.Combatant != null )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am hurt or being attacked, I flee" );
|
||||
m_Mobile.DebugSay( "I am hurt or being attacked, I flee" );
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
else
|
||||
|
|
@ -66,7 +66,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile combatant = m_Mobile.Combatant;
|
||||
|
||||
if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map)
|
||||
if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map)
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is gone..");
|
||||
|
||||
|
|
@ -147,4 +147,4 @@ namespace Server.Mobiles
|
|||
return base.DoActionFlee();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool DoActionCombat()
|
||||
{
|
||||
if (m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted || !m_Mobile.Combatant.Alive ||
|
||||
if (m_Mobile.Combatant?.Deleted != false || !m_Mobile.Combatant.Alive ||
|
||||
m_Mobile.Combatant.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is deleted");
|
||||
|
|
@ -117,4 +117,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ namespace Server.Mobiles
|
|||
Skill skill = ourSkills[i];
|
||||
Skill theirSkill = theirSkills[i];
|
||||
|
||||
if (skill != null && theirSkill != null && skill.Base >= 60.0 &&
|
||||
if (skill != null && skill?.Base >= 60.0 &&
|
||||
m_Mobile.CheckTeach(skill.SkillName, e.Mobile))
|
||||
{
|
||||
double toTeach = skill.Base / 3.0;
|
||||
|
|
@ -813,7 +813,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Mobile.DebugSay("I will go to the next waypoint");
|
||||
m_Mobile.CurrentWayPoint = point.NextPoint;
|
||||
if (point.NextPoint != null && point.NextPoint.Deleted)
|
||||
if (point.NextPoint?.Deleted == true)
|
||||
m_Mobile.CurrentWayPoint = point.NextPoint = point.NextPoint.NextPoint;
|
||||
}
|
||||
}
|
||||
|
|
@ -833,7 +833,7 @@ namespace Server.Mobiles
|
|||
WalkRandomInHome(2, 2, 1);
|
||||
}
|
||||
|
||||
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive &&
|
||||
if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive &&
|
||||
!m_Mobile.Combatant.IsDeadBondedPet) m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant);
|
||||
|
||||
return true;
|
||||
|
|
@ -849,7 +849,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile c = m_Mobile.Combatant;
|
||||
|
||||
if (c == null || c.Deleted || c.Map != m_Mobile.Map || !c.Alive || c.IsDeadBondedPet)
|
||||
if (c?.Deleted != false || c.Map != m_Mobile.Map || !c.Alive || c.IsDeadBondedPet)
|
||||
Action = ActionType.Wander;
|
||||
else
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo(c);
|
||||
|
|
@ -882,7 +882,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile from = m_Mobile.FocusMob;
|
||||
|
||||
if (from == null || from.Deleted || from.Map != m_Mobile.Map)
|
||||
if (from?.Deleted != false || from.Map != m_Mobile.Map)
|
||||
{
|
||||
m_Mobile.DebugSay("I have lost him");
|
||||
Action = ActionType.Guard;
|
||||
|
|
@ -964,7 +964,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual void OnCurrentOrderChanged()
|
||||
{
|
||||
if (m_Mobile.Deleted || m_Mobile.ControlMaster == null || m_Mobile.ControlMaster.Deleted)
|
||||
if (m_Mobile.Deleted || m_Mobile.ControlMaster?.Deleted != false)
|
||||
return;
|
||||
|
||||
switch (m_Mobile.ControlOrder)
|
||||
|
|
@ -1077,7 +1077,7 @@ namespace Server.Mobiles
|
|||
|
||||
WalkRandomInHome(3, 2, 1);
|
||||
|
||||
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive &&
|
||||
if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive &&
|
||||
!m_Mobile.Combatant.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.Warmode = true;
|
||||
|
|
@ -1093,35 +1093,35 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual bool DoOrderCome()
|
||||
{
|
||||
if (m_Mobile.ControlMaster != null && !m_Mobile.ControlMaster.Deleted)
|
||||
if (m_Mobile.ControlMaster?.Deleted != false)
|
||||
return true;
|
||||
|
||||
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlMaster);
|
||||
|
||||
if (iCurrDist > m_Mobile.RangePerception)
|
||||
{
|
||||
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlMaster);
|
||||
m_Mobile.DebugSay("I have lost my master. I stay here");
|
||||
m_Mobile.ControlTarget = null;
|
||||
m_Mobile.ControlOrder = OrderType.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay("My master told me come");
|
||||
|
||||
if (iCurrDist > m_Mobile.RangePerception)
|
||||
// Not exactly OSI style, but better than nothing.
|
||||
bool bRun = iCurrDist > 5;
|
||||
|
||||
if (WalkMobileRange(m_Mobile.ControlMaster, 1, bRun, 0, 1))
|
||||
{
|
||||
m_Mobile.DebugSay("I have lost my master. I stay here");
|
||||
m_Mobile.ControlTarget = null;
|
||||
m_Mobile.ControlOrder = OrderType.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay("My master told me come");
|
||||
|
||||
// Not exactly OSI style, but better than nothing.
|
||||
bool bRun = iCurrDist > 5;
|
||||
|
||||
if (WalkMobileRange(m_Mobile.ControlMaster, 1, bRun, 0, 1))
|
||||
if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive &&
|
||||
!m_Mobile.Combatant.IsDeadBondedPet)
|
||||
{
|
||||
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive &&
|
||||
!m_Mobile.Combatant.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.Warmode = true;
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.Warmode = false;
|
||||
}
|
||||
m_Mobile.Warmode = true;
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.Warmode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1140,7 +1140,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (pack != null)
|
||||
{
|
||||
List<Item> list = pack.Items;
|
||||
List<Item> list = pack?.Items;
|
||||
|
||||
for (int i = list.Count - 1; i >= 0; --i)
|
||||
if (i < list.Count)
|
||||
|
|
@ -1196,7 +1196,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Mobile.DebugSay("Praise the shepherd!");
|
||||
}
|
||||
else if (m_Mobile.ControlTarget != null && !m_Mobile.ControlTarget.Deleted && m_Mobile.ControlTarget != m_Mobile)
|
||||
else if (m_Mobile.ControlTarget?.Deleted == false && m_Mobile.ControlTarget != m_Mobile)
|
||||
{
|
||||
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlTarget);
|
||||
|
||||
|
|
@ -1204,7 +1204,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Mobile.DebugSay("I have lost the one to follow. I stay here");
|
||||
|
||||
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive &&
|
||||
if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive &&
|
||||
!m_Mobile.Combatant.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.Warmode = true;
|
||||
|
|
@ -1224,7 +1224,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (WalkMobileRange(m_Mobile.ControlTarget, 1, bRun, 0, 1))
|
||||
{
|
||||
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive &&
|
||||
if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive &&
|
||||
!m_Mobile.Combatant.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.Warmode = true;
|
||||
|
|
@ -1254,7 +1254,7 @@ namespace Server.Mobiles
|
|||
Mobile from = m_Mobile.ControlMaster;
|
||||
Mobile to = m_Mobile.ControlTarget;
|
||||
|
||||
if (from == null || to == null || from == to || from.Deleted || to.Deleted || !to.Player)
|
||||
if (from?.Deleted != false || to?.Deleted != false || from == to || !to.Player)
|
||||
{
|
||||
m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused*
|
||||
}
|
||||
|
|
@ -1326,7 +1326,7 @@ namespace Server.Mobiles
|
|||
Mobile from = m_Mobile.ControlMaster;
|
||||
Mobile to = m_Mobile.ControlTarget;
|
||||
|
||||
if (from == null || to == null || from == to || from.Deleted || to.Deleted || !to.Player)
|
||||
if (from?.Deleted != false || to?.Deleted != false || from == to || !to.Player)
|
||||
{
|
||||
m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused*
|
||||
}
|
||||
|
|
@ -1360,7 +1360,7 @@ namespace Server.Mobiles
|
|||
|
||||
Mobile controlMaster = m_Mobile.ControlMaster;
|
||||
|
||||
if (controlMaster == null || controlMaster.Deleted)
|
||||
if (controlMaster?.Deleted != false)
|
||||
return true;
|
||||
|
||||
Mobile combatant = m_Mobile.Combatant;
|
||||
|
|
@ -1374,7 +1374,7 @@ namespace Server.Mobiles
|
|||
AggressorInfo info = aggressors[i];
|
||||
Mobile attacker = info.Attacker;
|
||||
|
||||
if (attacker != null && !attacker.Deleted &&
|
||||
if (attacker?.Deleted == false &&
|
||||
attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception)
|
||||
if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) <
|
||||
combatant.GetDistanceToSqrt(controlMaster))
|
||||
|
|
@ -1385,7 +1385,7 @@ namespace Server.Mobiles
|
|||
m_Mobile.DebugSay("Crap, my master has been attacked! I will attack one of those bastards!");
|
||||
}
|
||||
|
||||
if (combatant != null && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && !combatant.Deleted &&
|
||||
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)
|
||||
{
|
||||
|
|
@ -1420,9 +1420,8 @@ namespace Server.Mobiles
|
|||
if (m_Mobile.IsDeadPet)
|
||||
return true;
|
||||
|
||||
if (m_Mobile.ControlTarget == null || m_Mobile.ControlTarget.Deleted ||
|
||||
m_Mobile.ControlTarget.Map != m_Mobile.Map || !m_Mobile.ControlTarget.Alive ||
|
||||
m_Mobile.ControlTarget.IsDeadBondedPet)
|
||||
if (m_Mobile.ControlTarget?.Deleted != false || m_Mobile.ControlTarget.Map != m_Mobile.Map ||
|
||||
!m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet)
|
||||
{
|
||||
m_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.");
|
||||
|
|
@ -1527,7 +1526,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual bool DoOrderStop()
|
||||
{
|
||||
if (m_Mobile.ControlMaster == null || m_Mobile.ControlMaster.Deleted)
|
||||
if (m_Mobile.ControlMaster?.Deleted != false)
|
||||
return true;
|
||||
|
||||
m_Mobile.DebugSay("My master told me to stop.");
|
||||
|
|
@ -1553,7 +1552,7 @@ namespace Server.Mobiles
|
|||
Mobile from = m_Mobile.ControlMaster;
|
||||
Mobile to = m_Mobile.ControlTarget;
|
||||
|
||||
if (from != to && from != null && !from.Deleted && to != null && !to.Deleted && to.Player)
|
||||
if (from?.Deleted == false && to?.Deleted == false && from != to && to.Player)
|
||||
{
|
||||
m_Mobile.DebugSay("Begin transfer with {0}", to.Name);
|
||||
|
||||
|
|
@ -1639,10 +1638,9 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual bool DoBardProvoked()
|
||||
{
|
||||
if (DateTime.UtcNow >= m_Mobile.BardEndTime && (m_Mobile.BardMaster == null || m_Mobile.BardMaster.Deleted ||
|
||||
m_Mobile.BardMaster.Map != m_Mobile.Map ||
|
||||
m_Mobile.GetDistanceToSqrt(m_Mobile.BardMaster) >
|
||||
m_Mobile.RangePerception))
|
||||
if (DateTime.UtcNow >= m_Mobile.BardEndTime && (m_Mobile.BardMaster?.Deleted != false ||
|
||||
m_Mobile.BardMaster.Map != m_Mobile.Map || m_Mobile.GetDistanceToSqrt(m_Mobile.BardMaster) >
|
||||
m_Mobile.RangePerception))
|
||||
{
|
||||
m_Mobile.DebugSay("I have lost my provoker");
|
||||
m_Mobile.BardProvoked = false;
|
||||
|
|
@ -1654,7 +1652,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_Mobile.BardTarget == null || m_Mobile.BardTarget.Deleted || m_Mobile.BardTarget.Map != m_Mobile.Map ||
|
||||
if (m_Mobile.BardTarget?.Deleted != false || m_Mobile.BardTarget.Map != m_Mobile.Map ||
|
||||
m_Mobile.GetDistanceToSqrt(m_Mobile.BardTarget) > m_Mobile.RangePerception)
|
||||
{
|
||||
m_Mobile.DebugSay("I have lost my provoke target");
|
||||
|
|
@ -2056,7 +2054,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual bool MoveTo(Mobile m, bool run, int range)
|
||||
{
|
||||
if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == null || m.Deleted)
|
||||
if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m?.Deleted != false)
|
||||
return false;
|
||||
|
||||
if (m_Mobile.InRange(m, range))
|
||||
|
|
@ -2065,7 +2063,7 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
|
||||
if (m_Path != null && m_Path.Goal == m)
|
||||
if (m_Path?.Goal == m)
|
||||
{
|
||||
if (m_Path.Follow(run, 1))
|
||||
{
|
||||
|
|
@ -2184,7 +2182,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (m_Mobile.BardProvoked)
|
||||
{
|
||||
if (m_Mobile.BardTarget == null || m_Mobile.BardTarget.Deleted)
|
||||
if (m_Mobile.BardTarget?.Deleted != false)
|
||||
{
|
||||
m_Mobile.FocusMob = null;
|
||||
return false;
|
||||
|
|
@ -2196,7 +2194,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (m_Mobile.Controlled)
|
||||
{
|
||||
if (m_Mobile.ControlTarget == null || m_Mobile.ControlTarget.Deleted || m_Mobile.ControlTarget.Hidden ||
|
||||
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))
|
||||
{
|
||||
|
|
@ -2386,6 +2384,7 @@ namespace Server.Mobiles
|
|||
return;
|
||||
|
||||
IPooledEnumerable<Mobile> eable = m_Mobile.GetMobilesInRange(m_Mobile.RangePerception);
|
||||
|
||||
foreach (Mobile trg in eable)
|
||||
if (trg != m_Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player &&
|
||||
m_Mobile.InLOS(trg))
|
||||
|
|
@ -2599,7 +2598,7 @@ namespace Server.Mobiles
|
|||
if (!base.AllowSecureTrade(from, to, newOwner, accepted))
|
||||
return false;
|
||||
|
||||
if (Deleted || m_Creature == null || m_Creature.Deleted || m_Creature.ControlMaster != from ||
|
||||
if (Deleted || m_Creature?.Deleted != false || m_Creature.ControlMaster != from ||
|
||||
!from.CheckAlive() || !to.CheckAlive())
|
||||
return false;
|
||||
|
||||
|
|
@ -2661,7 +2660,7 @@ namespace Server.Mobiles
|
|||
|
||||
Delete();
|
||||
|
||||
if (m_Creature == null || m_Creature.Deleted || m_Creature.ControlMaster != from || !from.CheckAlive() ||
|
||||
if (m_Creature?.Deleted != false || m_Creature.ControlMaster != from || !from.CheckAlive() ||
|
||||
!to.CheckAlive())
|
||||
return;
|
||||
|
||||
|
|
@ -2795,4 +2794,4 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool DoActionCombat()
|
||||
{
|
||||
if (m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted)
|
||||
if (m_Mobile.Combatant?.Deleted != false)
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is deleted");
|
||||
Action = ActionType.Guard;
|
||||
|
|
@ -79,4 +79,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,23 +48,23 @@ namespace Server.Mobiles
|
|||
if (m_Mobile.Debug)
|
||||
m_Mobile.DebugSay("{0} needs a cure", toHelp.Name);
|
||||
|
||||
if (!new CureSpell(m_Mobile, null).Cast())
|
||||
new CureSpell(m_Mobile, null).Cast();
|
||||
if (!new CureSpell(m_Mobile).Cast())
|
||||
new CureSpell(m_Mobile).Cast();
|
||||
}
|
||||
else if (NeedGHeal(toHelp))
|
||||
{
|
||||
if (m_Mobile.Debug)
|
||||
m_Mobile.DebugSay("{0} needs a greater heal", toHelp.Name);
|
||||
|
||||
if (!new GreaterHealSpell(m_Mobile, null).Cast())
|
||||
new HealSpell(m_Mobile, null).Cast();
|
||||
if (!new GreaterHealSpell(m_Mobile).Cast())
|
||||
new HealSpell(m_Mobile).Cast();
|
||||
}
|
||||
else if (NeedLHeal(toHelp))
|
||||
{
|
||||
if (m_Mobile.Debug)
|
||||
m_Mobile.DebugSay("{0} needs a lesser heal", toHelp.Name);
|
||||
|
||||
new HealSpell(m_Mobile, null).Cast();
|
||||
new HealSpell(m_Mobile).Cast();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -151,4 +151,4 @@ namespace Server.Mobiles
|
|||
|
||||
private delegate bool NeedDelegate(Mobile m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
// If I'm poisoned, always attempt to cure.
|
||||
if (m_Mobile.Poisoned)
|
||||
return new CureSpell(m_Mobile, null);
|
||||
return new CureSpell(m_Mobile);
|
||||
|
||||
// Summoned creatures never heal themselves.
|
||||
if (m_Mobile.Summoned)
|
||||
|
|
@ -150,11 +150,11 @@ namespace Server.Mobiles
|
|||
m_Mobile.UseSkill(SkillName.SpiritSpeak);
|
||||
}
|
||||
else
|
||||
spell = new GreaterHealSpell(m_Mobile, null);
|
||||
spell = new GreaterHealSpell(m_Mobile);
|
||||
}
|
||||
else if (m_Mobile.Hits < m_Mobile.HitsMax - 10)
|
||||
{
|
||||
spell = new HealSpell(m_Mobile, null);
|
||||
spell = new HealSpell(m_Mobile);
|
||||
}
|
||||
|
||||
double delay;
|
||||
|
|
@ -213,7 +213,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Mobile.Target?.Cancel(m_Mobile, TargetCancelType.Canceled);
|
||||
|
||||
new TeleportSpell(m_Mobile, null).Cast();
|
||||
new TeleportSpell(m_Mobile).Cast();
|
||||
|
||||
m_Mobile.DebugSay("I am stuck, I'm going to try teleporting away");
|
||||
}
|
||||
|
|
@ -265,19 +265,19 @@ namespace Server.Mobiles
|
|||
{
|
||||
case 0:
|
||||
m_Mobile.DebugSay("Pain Spike");
|
||||
return new PainSpikeSpell(m_Mobile, null);
|
||||
return new PainSpikeSpell(m_Mobile);
|
||||
case 1:
|
||||
m_Mobile.DebugSay("Poison Strike");
|
||||
return new PoisonStrikeSpell(m_Mobile, null);
|
||||
return new PoisonStrikeSpell(m_Mobile);
|
||||
case 2:
|
||||
m_Mobile.DebugSay("Strangle");
|
||||
return new StrangleSpell(m_Mobile, null);
|
||||
return new StrangleSpell(m_Mobile);
|
||||
case 3:
|
||||
m_Mobile.DebugSay("Wither");
|
||||
return new WitherSpell(m_Mobile, null);
|
||||
return new WitherSpell(m_Mobile);
|
||||
default:
|
||||
m_Mobile.DebugSay("Vengeful Spirit");
|
||||
return new VengefulSpiritSpell(m_Mobile, null);
|
||||
return new VengefulSpiritSpell(m_Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,18 +293,18 @@ namespace Server.Mobiles
|
|||
switch (Utility.Random(maxCircle * 2))
|
||||
{
|
||||
case 0:
|
||||
case 1: return new MagicArrowSpell(m_Mobile, null);
|
||||
case 1: return new MagicArrowSpell(m_Mobile);
|
||||
case 2:
|
||||
case 3: return new HarmSpell(m_Mobile, null);
|
||||
case 3: return new HarmSpell(m_Mobile);
|
||||
case 4:
|
||||
case 5: return new FireballSpell(m_Mobile, null);
|
||||
case 5: return new FireballSpell(m_Mobile);
|
||||
case 6:
|
||||
case 7: return new LightningSpell(m_Mobile, null);
|
||||
case 7: return new LightningSpell(m_Mobile);
|
||||
case 8:
|
||||
case 9: return new MindBlastSpell(m_Mobile, null);
|
||||
case 10: return new EnergyBoltSpell(m_Mobile, null);
|
||||
case 11: return new ExplosionSpell(m_Mobile, null);
|
||||
default: return new FlameStrikeSpell(m_Mobile, null);
|
||||
case 9: return new MindBlastSpell(m_Mobile);
|
||||
case 10: return new EnergyBoltSpell(m_Mobile);
|
||||
case 11: return new ExplosionSpell(m_Mobile);
|
||||
default: return new FlameStrikeSpell(m_Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,38 +319,38 @@ namespace Server.Mobiles
|
|||
{
|
||||
case 0:
|
||||
m_Mobile.DebugSay("Blood Oath");
|
||||
return new BloodOathSpell(m_Mobile, null);
|
||||
return new BloodOathSpell(m_Mobile);
|
||||
case 1:
|
||||
m_Mobile.DebugSay("Corpse Skin");
|
||||
return new CorpseSkinSpell(m_Mobile, null);
|
||||
return new CorpseSkinSpell(m_Mobile);
|
||||
case 2:
|
||||
m_Mobile.DebugSay("Evil Omen");
|
||||
return new EvilOmenSpell(m_Mobile, null);
|
||||
return new EvilOmenSpell(m_Mobile);
|
||||
default:
|
||||
m_Mobile.DebugSay("Mind Rot");
|
||||
return new MindRotSpell(m_Mobile, null);
|
||||
return new MindRotSpell(m_Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Spell GetRandomCurseSpellMage()
|
||||
{
|
||||
if (m_Mobile.Skills.Magery.Value >= 40.0 && Utility.Random(4) == 0)
|
||||
return new CurseSpell(m_Mobile, null);
|
||||
return new CurseSpell(m_Mobile);
|
||||
|
||||
switch (Utility.Random(3))
|
||||
{
|
||||
case 0: return new WeakenSpell(m_Mobile, null);
|
||||
case 1: return new ClumsySpell(m_Mobile, null);
|
||||
default: return new FeeblemindSpell(m_Mobile, null);
|
||||
case 0: return new WeakenSpell(m_Mobile);
|
||||
case 1: return new ClumsySpell(m_Mobile);
|
||||
default: return new FeeblemindSpell(m_Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Spell GetRandomManaDrainSpell()
|
||||
{
|
||||
if (m_Mobile.Skills.Magery.Value >= 80.0 && Utility.RandomBool())
|
||||
return new ManaVampireSpell(m_Mobile, null);
|
||||
return new ManaVampireSpell(m_Mobile);
|
||||
|
||||
return new ManaDrainSpell(m_Mobile, null);
|
||||
return new ManaDrainSpell(m_Mobile);
|
||||
}
|
||||
|
||||
public virtual Spell DoDispel(Mobile toDispel)
|
||||
|
|
@ -358,7 +358,7 @@ namespace Server.Mobiles
|
|||
if (!SmartAI)
|
||||
{
|
||||
if (ScaleBySkill(DispelChance, SkillName.Magery) > Utility.RandomDouble())
|
||||
return new DispelSpell(m_Mobile, null);
|
||||
return new DispelSpell(m_Mobile);
|
||||
|
||||
return ChooseSpell(toDispel);
|
||||
}
|
||||
|
|
@ -368,11 +368,11 @@ namespace Server.Mobiles
|
|||
if (spell == null)
|
||||
{
|
||||
if (!m_Mobile.DisallowAllMoves && Utility.Random((int)m_Mobile.GetDistanceToSqrt(toDispel)) == 0)
|
||||
spell = new TeleportSpell(m_Mobile, null);
|
||||
spell = new TeleportSpell(m_Mobile);
|
||||
else if (Utility.Random(3) == 0 && !m_Mobile.InRange(toDispel, 3) && !toDispel.Paralyzed && !toDispel.Frozen)
|
||||
spell = new ParalyzeSpell(m_Mobile, null);
|
||||
spell = new ParalyzeSpell(m_Mobile);
|
||||
else
|
||||
spell = new DispelSpell(m_Mobile, null);
|
||||
spell = new DispelSpell(m_Mobile);
|
||||
}
|
||||
|
||||
return spell;
|
||||
|
|
@ -380,7 +380,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual Spell ChooseSpell(Mobile c)
|
||||
{
|
||||
Spell spell = null;
|
||||
Spell spell;
|
||||
|
||||
if (!SmartAI)
|
||||
{
|
||||
|
|
@ -396,7 +396,7 @@ namespace Server.Mobiles
|
|||
(c.Player ? 18 : 30);
|
||||
|
||||
if (psDamage > c.Hits)
|
||||
return new PainSpikeSpell(m_Mobile, null);
|
||||
return new PainSpikeSpell(m_Mobile);
|
||||
}
|
||||
|
||||
switch (Utility.Random(16))
|
||||
|
|
@ -409,14 +409,14 @@ namespace Server.Mobiles
|
|||
|
||||
m_Mobile.DebugSay("Attempting to poison");
|
||||
|
||||
spell = new PoisonSpell(m_Mobile, null);
|
||||
spell = new PoisonSpell(m_Mobile);
|
||||
break;
|
||||
}
|
||||
case 2: // Bless ourselves
|
||||
{
|
||||
m_Mobile.DebugSay("Blessing myself");
|
||||
|
||||
spell = new BlessSpell(m_Mobile, null);
|
||||
spell = new BlessSpell(m_Mobile);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
|
|
@ -434,7 +434,7 @@ namespace Server.Mobiles
|
|||
|
||||
m_Mobile.DebugSay("Attempting to paralyze");
|
||||
|
||||
spell = new ParalyzeSpell(m_Mobile, null);
|
||||
spell = new ParalyzeSpell(m_Mobile);
|
||||
break;
|
||||
}
|
||||
case 6: // Drain mana
|
||||
|
|
@ -451,7 +451,7 @@ namespace Server.Mobiles
|
|||
|
||||
m_Mobile.DebugSay("Attempting to invis myself");
|
||||
|
||||
spell = new InvisibilitySpell(m_Mobile, null);
|
||||
spell = new InvisibilitySpell(m_Mobile);
|
||||
break;
|
||||
}
|
||||
default: // Damage them
|
||||
|
|
@ -478,7 +478,7 @@ namespace Server.Mobiles
|
|||
if (c.Poisoned)
|
||||
goto case 1;
|
||||
|
||||
spell = new PoisonSpell(m_Mobile, null);
|
||||
spell = new PoisonSpell(m_Mobile);
|
||||
break;
|
||||
}
|
||||
case 1: // Deal some damage
|
||||
|
|
@ -499,7 +499,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
else if (!c.Poisoned)
|
||||
{
|
||||
spell = new ParalyzeSpell(m_Mobile, null);
|
||||
spell = new ParalyzeSpell(m_Mobile);
|
||||
}
|
||||
}
|
||||
else if (m_Mobile.Mana > 60)
|
||||
|
|
@ -507,12 +507,12 @@ namespace Server.Mobiles
|
|||
if (Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned)
|
||||
{
|
||||
m_Combo = 0;
|
||||
spell = new ParalyzeSpell(m_Mobile, null);
|
||||
spell = new ParalyzeSpell(m_Mobile);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Combo = 1;
|
||||
spell = new ExplosionSpell(m_Mobile, null);
|
||||
spell = new ExplosionSpell(m_Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -529,20 +529,20 @@ namespace Server.Mobiles
|
|||
|
||||
if (m_Combo == 0)
|
||||
{
|
||||
spell = new ExplosionSpell(m_Mobile, null);
|
||||
spell = new ExplosionSpell(m_Mobile);
|
||||
++m_Combo; // Move to next spell
|
||||
}
|
||||
else if (m_Combo == 1)
|
||||
{
|
||||
spell = new WeakenSpell(m_Mobile, null);
|
||||
spell = new WeakenSpell(m_Mobile);
|
||||
++m_Combo; // Move to next spell
|
||||
}
|
||||
else if (m_Combo == 2)
|
||||
{
|
||||
if (!c.Poisoned)
|
||||
spell = new PoisonSpell(m_Mobile, null);
|
||||
spell = new PoisonSpell(m_Mobile);
|
||||
else if (IsNecromancer)
|
||||
spell = new StrangleSpell(m_Mobile, null);
|
||||
spell = new StrangleSpell(m_Mobile);
|
||||
|
||||
++m_Combo; // Move to next spell
|
||||
}
|
||||
|
|
@ -554,9 +554,9 @@ namespace Server.Mobiles
|
|||
case 0:
|
||||
{
|
||||
if (c.Int < c.Dex)
|
||||
spell = new FeeblemindSpell(m_Mobile, null);
|
||||
spell = new FeeblemindSpell(m_Mobile);
|
||||
else
|
||||
spell = new ClumsySpell(m_Mobile, null);
|
||||
spell = new ClumsySpell(m_Mobile);
|
||||
|
||||
++m_Combo; // Move to next spell
|
||||
|
||||
|
|
@ -564,19 +564,19 @@ namespace Server.Mobiles
|
|||
}
|
||||
case 1:
|
||||
{
|
||||
spell = new EnergyBoltSpell(m_Mobile, null);
|
||||
spell = new EnergyBoltSpell(m_Mobile);
|
||||
m_Combo = -1; // Reset combo state
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
spell = new FlameStrikeSpell(m_Mobile, null);
|
||||
spell = new FlameStrikeSpell(m_Mobile);
|
||||
m_Combo = -1; // Reset combo state
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
spell = new PainSpikeSpell(m_Mobile, null);
|
||||
spell = new PainSpikeSpell(m_Mobile);
|
||||
m_Combo = -1; // Reset combo state
|
||||
break;
|
||||
}
|
||||
|
|
@ -584,7 +584,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
else if (m_Combo == 4 && spell == null)
|
||||
{
|
||||
spell = new MindBlastSpell(m_Mobile, null);
|
||||
spell = new MindBlastSpell(m_Mobile);
|
||||
m_Combo = -1;
|
||||
}
|
||||
|
||||
|
|
@ -607,7 +607,7 @@ namespace Server.Mobiles
|
|||
Mobile c = m_Mobile.Combatant;
|
||||
m_Mobile.Warmode = true;
|
||||
|
||||
if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) ||
|
||||
if (c?.Deleted != false || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) ||
|
||||
!m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map)
|
||||
{
|
||||
// Our combatant is deleted, dead, hidden, or we cannot hurt them
|
||||
|
|
@ -710,7 +710,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Mobile.DebugSay("I am going to cure myself");
|
||||
|
||||
spell = new CureSpell(m_Mobile, null);
|
||||
spell = new CureSpell(m_Mobile);
|
||||
}
|
||||
else if (toDispel != null) // Something dispellable is attacking us
|
||||
{
|
||||
|
|
@ -725,7 +725,7 @@ namespace Server.Mobiles
|
|||
else if (SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned
|
||||
) // They have a heal spell out
|
||||
{
|
||||
spell = new PoisonSpell(m_Mobile, null);
|
||||
spell = new PoisonSpell(m_Mobile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -764,7 +764,7 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool DoActionGuard()
|
||||
{
|
||||
if (m_LastTarget != null && m_LastTarget.Hidden)
|
||||
if (m_LastTarget?.Hidden == true)
|
||||
{
|
||||
Map map = m_Mobile.Map;
|
||||
|
||||
|
|
@ -777,7 +777,7 @@ namespace Server.Mobiles
|
|||
m_Mobile.DebugSay("I am going to reveal my last target");
|
||||
|
||||
m_RevealTarget = new LandTarget(m_LastTargetLoc, map);
|
||||
Spell spell = new RevealSpell(m_Mobile, null);
|
||||
Spell spell = new RevealSpell(m_Mobile);
|
||||
|
||||
if (spell.Cast())
|
||||
m_LastTarget = null; // only do it once
|
||||
|
|
@ -827,7 +827,7 @@ namespace Server.Mobiles
|
|||
m_Mobile.FocusMob = null;
|
||||
|
||||
if (m_Mobile.Poisoned && Utility.Random(0, 5) == 0)
|
||||
new CureSpell(m_Mobile, null).Cast();
|
||||
new CureSpell(m_Mobile).Cast();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -855,7 +855,7 @@ namespace Server.Mobiles
|
|||
|
||||
Mobile comb = m_Mobile.Combatant;
|
||||
|
||||
if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet &&
|
||||
if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet &&
|
||||
m_Mobile.InRange(comb, Core.ML ? 10 : 12) && CanDispel(comb))
|
||||
{
|
||||
active = comb;
|
||||
|
|
@ -917,7 +917,7 @@ namespace Server.Mobiles
|
|||
|
||||
Mobile comb = m_Mobile.Combatant;
|
||||
|
||||
if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb))
|
||||
if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb))
|
||||
{
|
||||
active = inactive = comb;
|
||||
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
|
||||
|
|
@ -1100,4 +1100,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile combatant = m_Mobile.Combatant;
|
||||
|
||||
if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive ||
|
||||
if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map || !combatant.Alive ||
|
||||
combatant.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is gone, so my guard is up");
|
||||
|
|
@ -174,4 +174,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* PredatorAI, its an animal that can attack
|
||||
* Dont flee but dont attack if not hurt or attacked
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Server.Mobiles
|
||||
|
|
@ -36,7 +36,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile combatant = m_Mobile.Combatant;
|
||||
|
||||
if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map)
|
||||
if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map)
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is gone, so my guard is up");
|
||||
Action = ActionType.Wander;
|
||||
|
|
@ -89,4 +89,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile combatant = m_Mobile.Combatant;
|
||||
|
||||
if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map)
|
||||
if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map)
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is gone, so my guard is up");
|
||||
|
||||
|
|
@ -50,24 +50,15 @@ namespace Server.Mobiles
|
|||
if (WalkMobileRange(combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight))
|
||||
{
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant);
|
||||
if (m_toDisarm == null)
|
||||
m_toDisarm = combatant.FindItemOnLayer(Layer.OneHanded);
|
||||
|
||||
if (m_toDisarm == null)
|
||||
m_toDisarm = combatant.FindItemOnLayer(Layer.TwoHanded);
|
||||
|
||||
if (m_toDisarm != null && m_toDisarm.IsChildOf(m_Mobile.Backpack))
|
||||
{
|
||||
m_toDisarm = combatant.FindItemOnLayer(Layer.OneHanded);
|
||||
if (m_toDisarm == null)
|
||||
m_toDisarm = combatant.FindItemOnLayer(Layer.TwoHanded);
|
||||
}
|
||||
if (m_toDisarm?.IsChildOf(m_Mobile.Backpack) != false)
|
||||
m_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)
|
||||
EventSink.InvokeDisarmRequest(new DisarmRequestEventArgs(m_Mobile));
|
||||
|
||||
if (m_toDisarm != null && m_toDisarm.IsChildOf(combatant.Backpack) &&
|
||||
if (m_toDisarm?.IsChildOf(combatant.Backpack) == true &&
|
||||
Core.TickCount - m_Mobile.NextSkillTime >= 0 && m_toDisarm.LootType != LootType.Blessed &&
|
||||
m_toDisarm.LootType != LootType.Newbied)
|
||||
{
|
||||
|
|
@ -126,31 +117,28 @@ namespace Server.Mobiles
|
|||
m_Mobile.DebugSay("I should be closer to {0}", combatant.Name);
|
||||
}
|
||||
|
||||
if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 && m_Mobile.CanFlee)
|
||||
if (m_Mobile.Hits >= m_Mobile.HitsMax * 20 / 100 || !m_Mobile.CanFlee)
|
||||
return true;
|
||||
// We are low on health, should we flee?
|
||||
|
||||
bool flee;
|
||||
|
||||
if (m_Mobile.Hits < combatant.Hits)
|
||||
{
|
||||
// We are low on health, should we flee?
|
||||
// We are more hurt than them
|
||||
int diff = combatant.Hits - m_Mobile.Hits;
|
||||
|
||||
bool flee = false;
|
||||
flee = Utility.Random(0, 100) > 10 + diff; // (10 + diff)% chance to flee
|
||||
}
|
||||
else
|
||||
{
|
||||
flee = Utility.Random(0, 100) > 10; // 10% chance to flee
|
||||
}
|
||||
|
||||
if (m_Mobile.Hits < combatant.Hits)
|
||||
{
|
||||
// We are more hurt than them
|
||||
|
||||
int diff = combatant.Hits - m_Mobile.Hits;
|
||||
|
||||
flee = Utility.Random(0, 100) > 10 + diff; // (10 + diff)% chance to flee
|
||||
}
|
||||
else
|
||||
{
|
||||
flee = Utility.Random(0, 100) > 10; // 10% chance to flee
|
||||
}
|
||||
|
||||
if (flee)
|
||||
{
|
||||
m_Mobile.DebugSay("I am going to flee from {0}", combatant.Name);
|
||||
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
if (flee)
|
||||
{
|
||||
m_Mobile.DebugSay("I am going to flee from {0}", combatant.Name);
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -189,4 +177,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
|
||||
if (customer == null || customer.Deleted || customer.Map != m_Mobile.Map)
|
||||
if (customer?.Deleted != false || customer.Map != m_Mobile.Map)
|
||||
{
|
||||
m_Mobile.DebugSay("My customer have disapeared");
|
||||
m_Mobile.FocusMob = null;
|
||||
|
|
@ -147,4 +147,4 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue