Formatting #2 (#59)

This commit is contained in:
Kamron Batman 2019-10-05 00:37:03 -07:00 committed by GitHub
parent 096d39609e
commit 8e9221bb5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
400 changed files with 3688 additions and 5969 deletions

View file

@ -340,7 +340,7 @@ namespace Server.Mobiles
Skill skill = ourSkills[i];
Skill theirSkill = theirSkills[i];
if (skill != 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;
@ -907,50 +907,23 @@ namespace Server.Mobiles
if (m_Mobile.Deleted)
return false;
switch (m_Mobile.ControlOrder)
return m_Mobile.ControlOrder switch
{
case OrderType.None:
return DoOrderNone();
case OrderType.Come:
return DoOrderCome();
case OrderType.Drop:
return DoOrderDrop();
case OrderType.Friend:
return DoOrderFriend();
case OrderType.Unfriend:
return DoOrderUnfriend();
case OrderType.Guard:
return DoOrderGuard();
case OrderType.Attack:
return DoOrderAttack();
case OrderType.Patrol:
return DoOrderPatrol();
case OrderType.Release:
return DoOrderRelease();
case OrderType.Stay:
return DoOrderStay();
case OrderType.Stop:
return DoOrderStop();
case OrderType.Follow:
return DoOrderFollow();
case OrderType.Transfer:
return DoOrderTransfer();
default:
return false;
}
OrderType.None => DoOrderNone(),
OrderType.Come => DoOrderCome(),
OrderType.Drop => DoOrderDrop(),
OrderType.Friend => DoOrderFriend(),
OrderType.Unfriend => DoOrderUnfriend(),
OrderType.Guard => DoOrderGuard(),
OrderType.Attack => DoOrderAttack(),
OrderType.Patrol => DoOrderPatrol(),
OrderType.Release => DoOrderRelease(),
OrderType.Stay => DoOrderStay(),
OrderType.Stop => DoOrderStop(),
OrderType.Follow => DoOrderFollow(),
OrderType.Transfer => DoOrderTransfer(),
_ => false
};
}
public virtual void OnCurrentOrderChanged()
@ -1131,7 +1104,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)
@ -1629,9 +1602,10 @@ namespace Server.Mobiles
public virtual bool DoBardProvoked()
{
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))
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;
@ -1767,7 +1741,7 @@ namespace Server.Mobiles
using (StreamWriter op = new StreamWriter("nan_transform.txt", true))
{
op.WriteLine(
$"NaN in TransformMoveDelay: {DateTime.UtcNow}, {GetType()}, {(m_Mobile == null ? "null" : m_Mobile.GetType().ToString())}, {m_Mobile.HitsMax}");
$"NaN in TransformMoveDelay: {DateTime.UtcNow}, {GetType()}, {m_Mobile?.GetType()}, {m_Mobile.HitsMax}");
}
return 1.0;
@ -1791,7 +1765,7 @@ namespace Server.Mobiles
public virtual MoveResult DoMoveImpl(Direction d)
{
if (m_Mobile.Deleted || m_Mobile.Frozen || m_Mobile.Paralyzed ||
m_Mobile.Spell != null && m_Mobile.Spell.IsCasting || m_Mobile.DisallowAllMoves)
m_Mobile.Spell?.IsCasting == true || m_Mobile.DisallowAllMoves)
return MoveResult.BadState;
if (!CheckMove())
return MoveResult.BadState;

View file

@ -13,7 +13,7 @@ namespace Server.Mobiles
if (AcquireFocusMob(m_Mobile.RangePerception, FightMode.Closest, false, true, true))
{
if (m_Mobile.Debug)
m_Mobile.DebugSay("I have detected " + m_Mobile.FocusMob.Name + " and I will attack");
m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name} and I will attack");
m_Mobile.Combatant = m_Mobile.FocusMob;
Action = ActionType.Combat;
@ -45,12 +45,12 @@ namespace Server.Mobiles
if (m_Mobile.Combatant != null)
{
if (m_Mobile.Debug)
m_Mobile.DebugSay("I am still not in range of " + m_Mobile.Combatant.Name);
m_Mobile.DebugSay($"I am still not in range of {m_Mobile.Combatant.Name}");
if ((int)m_Mobile.GetDistanceToSqrt(m_Mobile.Combatant) > m_Mobile.RangePerception + 1)
{
if (m_Mobile.Debug)
m_Mobile.DebugSay("I have lost " + m_Mobile.Combatant.Name);
m_Mobile.DebugSay($"I have lost {m_Mobile.Combatant.Name}");
Action = ActionType.Guard;
return true;

View file

@ -143,9 +143,7 @@ namespace Server.Mobiles
if (m_Mobile.Hits < m_Mobile.HitsMax - 50)
{
if (UseNecromancy())
{
m_Mobile.UseSkill(SkillName.SpiritSpeak);
}
else
spell = new GreaterHealSpell(m_Mobile);
}
@ -199,7 +197,7 @@ namespace Server.Mobiles
public void RunFrom(Mobile m)
{
Run((m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask);
Run(m_Mobile.GetDirectionTo(m) - 4 & Direction.Mask);
}
public void OnFailedMove()
@ -229,7 +227,7 @@ namespace Server.Mobiles
public void Run(Direction d)
{
if (m_Mobile.Spell != null && m_Mobile.Spell.IsCasting || m_Mobile.Paralyzed || m_Mobile.Frozen ||
if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen ||
m_Mobile.DisallowAllMoves)
return;
@ -284,22 +282,22 @@ namespace Server.Mobiles
else if (maxCircle > 8)
maxCircle = 8;
switch (Utility.Random(maxCircle * 2))
return Utility.Random(maxCircle * 2) switch
{
case 0:
case 1: return new MagicArrowSpell(m_Mobile);
case 2:
case 3: return new HarmSpell(m_Mobile);
case 4:
case 5: return new FireballSpell(m_Mobile);
case 6:
case 7: return new LightningSpell(m_Mobile);
case 8:
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);
}
0 => (Spell)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)
};
}
public virtual Spell GetRandomCurseSpell() => UseNecromancy() ? GetRandomCurseSpellNecro() : GetRandomCurseSpellMage();
@ -328,12 +326,12 @@ namespace Server.Mobiles
if (m_Mobile.Skills.Magery.Value >= 40.0 && Utility.Random(4) == 0)
return new CurseSpell(m_Mobile);
switch (Utility.Random(3))
return Utility.Random(3) switch
{
case 0: return new WeakenSpell(m_Mobile);
case 1: return new ClumsySpell(m_Mobile);
default: return new FeeblemindSpell(m_Mobile);
}
0 => (Spell)new WeakenSpell(m_Mobile),
1 => new ClumsySpell(m_Mobile),
_ => new FeeblemindSpell(m_Mobile)
};
}
public virtual Spell GetRandomManaDrainSpell()
@ -742,7 +740,7 @@ namespace Server.Mobiles
m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds;
}
else if (m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting)
else if (m_Mobile.Spell?.IsCasting != true)
{
RunTo(c);
}

View file

@ -169,8 +169,6 @@ namespace Server
if (m_Table == null)
LoadTable();
;
return m_Table.ContainsKey(obj.GetType());
}

View file

@ -115,7 +115,7 @@ namespace Server.Mobiles
if (!(attacker == this || attacker == m_Rider || willKill || DateTime.UtcNow < NextMountAbility)
&& DoMountAbility(amount, from))
NextMountAbility = DateTime.UtcNow + MountAbilityDelay;
NextMountAbility = DateTime.UtcNow + MountAbilityDelay;
}
public override bool OnBeforeDeath()

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public FrenziedOstard(string name = "a frenzied ostard") :
base(name, 0xDA, 0x3EA4, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
base(name, 0xDA, 0x3EA4, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
{
Hue = Race.Human.RandomHairHue() | 0x8000;

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public HellSteed(string name = "a hellsteed") :
base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
SetStats(this);
}

View file

@ -14,7 +14,7 @@ namespace Server.Mobiles
[Constructible]
public Horse(string name = "a horse") :
base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
int random = Utility.Random(4);

View file

@ -8,7 +8,7 @@ namespace Server.Mobiles
{
[Constructible]
public Kirin(string name = "a ki-rin") :
base(name, 132, 0x3EAD, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4)
base(name, 132, 0x3EAD, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4)
{
BaseSoundID = 0x3C5;

View file

@ -6,7 +6,7 @@ namespace Server.Mobiles
{
[Constructible]
public Nightmare(string name = "a nightmare") :
base(name, 0x74, 0x3EA7, AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4)
base(name, 0x74, 0x3EA7, AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4)
{
BaseSoundID = Core.AOS ? 0xA8 : 0x16A;

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public RidableLlama(string name = "a ridable llama") :
base(name, 0xDC, 0x3EA6, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 0xDC, 0x3EA6, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
BaseSoundID = 0x3F3;

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public Ridgeback(string name = "a ridgeback") :
base(name, 187, 0x3EBA, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 187, 0x3EBA, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
BaseSoundID = 0x3F3;

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public SavageRidgeback(string name = "a savage ridgeback") :
base(name, 188, 0x3EB8, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 188, 0x3EB8, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
BaseSoundID = 0x3F3;

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public ScaledSwampDragon(string name = "a swamp dragon") :
base(name, 0x31F, 0x3EBE, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 0x31F, 0x3EBE, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
SetStr(201, 300);
SetDex(66, 85);

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public SeaHorse(string name = "a sea horse") :
base(name, 0x90, 0x3EB3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 0x90, 0x3EB3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
InitStats(Utility.Random(50, 30), Utility.Random(50, 30), 10);
Skills.MagicResist.Base = 25.0 + Utility.RandomDouble() * 5.0;

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
[Constructible]
public SilverSteed(string name = "a silver steed") :
base(name, 0x75, 0x3EA8, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 0x75, 0x3EA8, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
InitStats(Utility.Random(50, 30), Utility.Random(50, 30), 10);
Skills.MagicResist.Base = 25.0 + Utility.RandomDouble() * 5.0;

View file

@ -12,7 +12,7 @@ namespace Server.Mobiles
[Constructible]
public SwampDragon(string name = "a swamp dragon") :
base(name, 0x31A, 0x3EBD, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
base(name, 0x31A, 0x3EBD, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
{
BaseSoundID = 0x16A;

View file

@ -8,7 +8,7 @@ namespace Server.Mobiles
{
[Constructible]
public Unicorn(string name = "a unicorn") :
base(name, 0x7A, 0x3EB4, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4)
base(name, 0x7A, 0x3EB4, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4)
{
BaseSoundID = 0x4BC;

View file

@ -9,18 +9,13 @@ namespace Server.Mobiles
{
Hue = 0x901;
switch (Utility.Random(3))
Name = Utility.Random(3) switch
{
case 0:
Name = "a crow";
break;
case 2:
Name = "a raven";
break;
case 1:
Name = "a magpie";
break;
}
0 => "a crow",
2 => "a raven",
1 => "a magpie",
_ => Name
};
}
else
{

View file

@ -832,10 +832,7 @@ namespace Server.Mobiles
public override string ApplyNameSuffix(string suffix)
{
if (IsParagon && !GivesMLMinorArtifact)
{
suffix = suffix.Length == 0 ? "(Paragon)" : $"{suffix} (Paragon)";
}
if (IsParagon && !GivesMLMinorArtifact) suffix = suffix.Length == 0 ? "(Paragon)" : $"{suffix} (Paragon)";
return base.ApplyNameSuffix(suffix);
}
@ -1120,23 +1117,14 @@ namespace Server.Mobiles
if (Core.AOS && holding is SkinningKnife)
{
Item leather = null;
switch (HideType)
var leather = HideType switch
{
case HideType.Regular:
leather = new Leather(hides);
break;
case HideType.Spined:
leather = new SpinedLeather(hides);
break;
case HideType.Horned:
leather = new HornedLeather(hides);
break;
case HideType.Barbed:
leather = new BarbedLeather(hides);
break;
}
HideType.Regular => (Item)new Leather(hides),
HideType.Spined => new SpinedLeather(hides),
HideType.Horned => new HornedLeather(hides),
HideType.Barbed => new BarbedLeather(hides),
_ => null
};
if (leather != null)
{
@ -1625,39 +1613,21 @@ namespace Server.Mobiles
return;
}
AIObject = null;
switch (NewAI)
AIObject = NewAI switch
{
case AIType.AI_Melee:
AIObject = new MeleeAI(this);
break;
case AIType.AI_Animal:
AIObject = new AnimalAI(this);
break;
case AIType.AI_Berserk:
AIObject = new BerserkAI(this);
break;
case AIType.AI_Archer:
AIObject = new ArcherAI(this);
break;
case AIType.AI_Healer:
AIObject = new HealerAI(this);
break;
case AIType.AI_Vendor:
AIObject = new VendorAI(this);
break;
case AIType.AI_Mage:
AIObject = new MageAI(this);
break;
case AIType.AI_Predator:
//m_AI = new PredatorAI(this);
AIObject = new MeleeAI(this);
break;
case AIType.AI_Thief:
AIObject = new ThiefAI(this);
break;
}
AIType.AI_Melee => (BaseAI)new MeleeAI(this),
AIType.AI_Animal => new AnimalAI(this),
AIType.AI_Berserk => new BerserkAI(this),
AIType.AI_Archer => new ArcherAI(this),
AIType.AI_Healer => new HealerAI(this),
AIType.AI_Vendor => new VendorAI(this),
AIType.AI_Mage => new MageAI(this),
AIType.AI_Predator =>
//m_AI = new PredatorAI(this);
new MeleeAI(this),
AIType.AI_Thief => new ThiefAI(this),
_ => null
};
}
public virtual void OnTeamChange()
@ -1794,17 +1764,12 @@ namespace Server.Mobiles
if (bPlayerOnly && !m.Player)
return double.MinValue;
switch (acqType)
return acqType switch
{
case FightMode.Strongest:
return m.Skills.Tactics.Value + m.Str; //returns strongest mobile
case FightMode.Weakest:
return -m.Hits; // returns weakest mobile
default:
return -GetDistanceToSqrt(m); // returns closest mobile
}
FightMode.Strongest => (m.Skills.Tactics.Value + m.Str), //returns strongest mobile
FightMode.Weakest => -m.Hits, // returns weakest mobile
_ => -GetDistanceToSqrt(m)
};
}
// Turn, - for left, + for right
@ -1813,14 +1778,14 @@ namespace Server.Mobiles
{
int v = (int)Direction;
Direction = (Direction)((((v & 0x7) + iTurnSteps) & 0x7) | (v & 0x80));
Direction = (Direction)((v & 0x7) + iTurnSteps & 0x7 | v & 0x80);
}
public virtual void TurnInternal(int iTurnSteps)
{
int v = (int)Direction;
SetDirection((Direction)((((v & 0x7) + iTurnSteps) & 0x7) | (v & 0x80)));
SetDirection((Direction)((v & 0x7) + iTurnSteps & 0x7 | v & 0x80));
}
public bool IsHurt() => Hits != HitsMax;
@ -1898,7 +1863,7 @@ namespace Server.Mobiles
if (Region.IsPartOf<SafeZone>() && m is PlayerMobile pm &&
(pm.DuelContext?.Started != true || pm.DuelContext.Finished ||
pm.DuelPlayer?.Eliminated != false))
pm.DuelPlayer?.Eliminated != false))
return true;
#endregion
@ -1970,9 +1935,9 @@ namespace Server.Mobiles
if (Controlled || Summoned)
{
if (m_ControlMaster != null && m_ControlMaster.Player)
if (m_ControlMaster?.Player == true)
m_ControlMaster.CriminalAction(false);
else if (m_SummonMaster != null && m_SummonMaster.Player)
else if (m_SummonMaster?.Player == true)
m_SummonMaster.CriminalAction(false);
}
}
@ -2002,9 +1967,9 @@ namespace Server.Mobiles
if (ai.Defender == target)
{
if (m_ControlMaster != null && m_ControlMaster.Player && m_ControlMaster.CanBeHarmful(target, false))
if (m_ControlMaster?.Player == true && m_ControlMaster.CanBeHarmful(target, false))
m_ControlMaster.DoHarmful(target, true);
else if (m_SummonMaster != null && m_SummonMaster.Player && m_SummonMaster.CanBeHarmful(target, false))
else if (m_SummonMaster?.Player == true && m_SummonMaster.CanBeHarmful(target, false))
m_SummonMaster.DoHarmful(target, true);
return;
@ -2800,7 +2765,7 @@ namespace Server.Mobiles
{
base.OnRegionChange(Old, New);
if (Controlled && Spawner is SpawnEntry se && !se.UnlinkOnTaming && (New == null || !New.AcceptsSpawnsFrom(se.Region)))
if (Controlled && Spawner is SpawnEntry se && !se.UnlinkOnTaming && New?.AcceptsSpawnsFrom(se.Region) != true)
{
Spawner.Remove(this);
Spawner = null;
@ -3390,7 +3355,7 @@ namespace Server.Mobiles
{
get
{
if (m_DeleteTimer != null && m_DeleteTimer.Running)
if (m_DeleteTimer?.Running == true)
return m_DeleteTimer.Next - DateTime.UtcNow;
return TimeSpan.Zero;
@ -4445,49 +4410,29 @@ namespace Server.Mobiles
public void SetFameLevel(int level)
{
switch (level)
Fame = level switch
{
case 1:
Fame = Utility.RandomMinMax(0, 1249);
break;
case 2:
Fame = Utility.RandomMinMax(1250, 2499);
break;
case 3:
Fame = Utility.RandomMinMax(2500, 4999);
break;
case 4:
Fame = Utility.RandomMinMax(5000, 9999);
break;
case 5:
Fame = Utility.RandomMinMax(10000, 10000);
break;
}
1 => Utility.RandomMinMax(0, 1249),
2 => Utility.RandomMinMax(1250, 2499),
3 => Utility.RandomMinMax(2500, 4999),
4 => Utility.RandomMinMax(5000, 9999),
5 => Utility.RandomMinMax(10000, 10000),
_ => Fame
};
}
public void SetKarmaLevel(int level)
{
switch (level)
Karma = level switch
{
case 0:
Karma = -Utility.RandomMinMax(0, 624);
break;
case 1:
Karma = -Utility.RandomMinMax(625, 1249);
break;
case 2:
Karma = -Utility.RandomMinMax(1250, 2499);
break;
case 3:
Karma = -Utility.RandomMinMax(2500, 4999);
break;
case 4:
Karma = -Utility.RandomMinMax(5000, 9999);
break;
case 5:
Karma = -Utility.RandomMinMax(10000, 10000);
break;
}
0 => -Utility.RandomMinMax(0, 624),
1 => -Utility.RandomMinMax(625, 1249),
2 => -Utility.RandomMinMax(1250, 2499),
3 => -Utility.RandomMinMax(2500, 4999),
4 => -Utility.RandomMinMax(5000, 9999),
5 => -Utility.RandomMinMax(10000, 10000),
_ => Karma
};
}
#endregion

View file

@ -119,7 +119,7 @@ namespace Server.Mobiles
{
m_NextResurrect = DateTime.UtcNow + ResurrectDelay;
if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
if (m.Map?.CanFit(m.Location, 16, false, false) != true)
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
else if (CheckResurrect(m)) OfferResurrection(m);
}

View file

@ -198,13 +198,13 @@ namespace Server.Mobiles
public override WeaponAbility GetWeaponAbility()
{
switch (Utility.Random(3))
return Utility.Random(3) switch
{
default:
case 0: return WeaponAbility.DoubleStrike;
case 1: return WeaponAbility.WhirlwindAttack;
case 2: return WeaponAbility.CrushingBlow;
}
0 => WeaponAbility.DoubleStrike,
1 => WeaponAbility.WhirlwindAttack,
2 => WeaponAbility.CrushingBlow,
_ => WeaponAbility.DoubleStrike
};
}
public override void OnDeath(Container c)

View file

@ -43,23 +43,13 @@ namespace Server.Mobiles
if (Core.ML && Utility.RandomDouble() < .33)
PackItem(Seed.RandomPeculiarSeed(2));
Item orepile = null; /* no trust, no love :( */
switch (Utility.Random(4))
var orepile = Utility.Random(4) switch
{
case 0:
orepile = new DullCopperOre();
break;
case 1:
orepile = new ShadowIronOre();
break;
case 2:
orepile = new CopperOre();
break;
default:
orepile = new BronzeOre();
break;
}
0 => (Item)new DullCopperOre(),
1 => new ShadowIronOre(),
2 => new CopperOre(),
_ => new BronzeOre()
};
orepile.Amount = Utility.RandomMinMax(1, 10);
orepile.ItemID = 0x19B9;

View file

@ -40,44 +40,24 @@ namespace Server.Mobiles
Fame = 5000;
Karma = -5000;
CraftResource res = CraftResource.None;
switch (Utility.Random(6))
var res = Utility.Random(6) switch
{
case 0:
res = CraftResource.BlackScales;
break;
case 1:
res = CraftResource.RedScales;
break;
case 2:
res = CraftResource.BlueScales;
break;
case 3:
res = CraftResource.YellowScales;
break;
case 4:
res = CraftResource.GreenScales;
break;
case 5:
res = CraftResource.WhiteScales;
break;
}
0 => CraftResource.BlackScales,
1 => CraftResource.RedScales,
2 => CraftResource.BlueScales,
3 => CraftResource.YellowScales,
4 => CraftResource.GreenScales,
5 => CraftResource.WhiteScales,
_ => CraftResource.None
};
BaseWeapon melee = null;
switch (Utility.Random(3))
var melee = Utility.Random(3) switch
{
case 0:
melee = new Kryss();
break;
case 1:
melee = new Broadsword();
break;
case 2:
melee = new Katana();
break;
}
0 => (BaseWeapon)new Kryss(),
1 => new Broadsword(),
2 => new Katana(),
_ => null
};
melee.Movable = false;
AddItem(melee);

View file

@ -41,44 +41,25 @@ namespace Server.Mobiles
Karma = -8000;
CraftResource res = CraftResource.None;
;
switch (Utility.Random(6))
res = Utility.Random(6) switch
{
case 0:
res = CraftResource.BlackScales;
break;
case 1:
res = CraftResource.RedScales;
break;
case 2:
res = CraftResource.BlueScales;
break;
case 3:
res = CraftResource.YellowScales;
break;
case 4:
res = CraftResource.GreenScales;
break;
case 5:
res = CraftResource.WhiteScales;
break;
}
0 => CraftResource.BlackScales,
1 => CraftResource.RedScales,
2 => CraftResource.BlueScales,
3 => CraftResource.YellowScales,
4 => CraftResource.GreenScales,
5 => CraftResource.WhiteScales,
_ => res
};
BaseWeapon melee = null;
switch (Utility.Random(3))
var melee = Utility.Random(3) switch
{
case 0:
melee = new Kryss();
break;
case 1:
melee = new Broadsword();
break;
case 2:
melee = new Katana();
break;
}
0 => (BaseWeapon)new Kryss(),
1 => new Broadsword(),
2 => new Katana(),
_ => null
};
melee.Movable = false;
AddItem(melee);
@ -139,36 +120,19 @@ namespace Server.Mobiles
break;
}
switch (Utility.Random(9))
res = Utility.Random(9) switch
{
case 0:
res = CraftResource.DullCopper;
break;
case 1:
res = CraftResource.ShadowIron;
break;
case 2:
res = CraftResource.Copper;
break;
case 3:
res = CraftResource.Bronze;
break;
case 4:
res = CraftResource.Gold;
break;
case 5:
res = CraftResource.Agapite;
break;
case 6:
res = CraftResource.Verite;
break;
case 7:
res = CraftResource.Valorite;
break;
case 8:
res = CraftResource.Iron;
break;
}
0 => CraftResource.DullCopper,
1 => CraftResource.ShadowIron,
2 => CraftResource.Copper,
3 => CraftResource.Bronze,
4 => CraftResource.Gold,
5 => CraftResource.Agapite,
6 => CraftResource.Verite,
7 => CraftResource.Valorite,
8 => CraftResource.Iron,
_ => res
};
SwampDragon mt = new SwampDragon();
mt.HasBarding = true;
@ -240,4 +204,4 @@ namespace Server.Mobiles
int version = reader.ReadInt();
}
}
}
}

View file

@ -108,25 +108,14 @@ namespace Server.Mobiles
if (!combatant.Map.CanSpawnMobile(loc))
continue;
BaseCreature rabid;
switch (i)
var rabid = i switch
{
case 0:
rabid = new EnragedRabbit(this);
break;
case 1:
rabid = new EnragedHind(this);
break;
case 2:
rabid = new EnragedHart(this);
break;
case 3:
rabid = new EnragedBlackBear(this);
break;
default:
rabid = new EnragedEagle(this);
break;
}
0 => (BaseCreature)new EnragedRabbit(this),
1 => new EnragedHind(this),
2 => new EnragedHart(this),
3 => new EnragedBlackBear(this),
_ => new EnragedEagle(this)
};
rabid.FocusMob = combatant;
rabid.MoveToWorld(loc, combatant.Map);

View file

@ -72,7 +72,7 @@ namespace Server.Mobiles
{
m_NextResurrect = DateTime.UtcNow + ResurrectDelay;
if (!from.Criminal && from.Kills < 5 && from.Karma > 0)
if (from.Map != null && from.Map.CanFit(from.Location, 16, false, false))
if (from.Map?.CanFit(from.Location, 16, false, false) == true)
{
Direction = GetDirectionTo(from);
from.PlaySound(0x1F2);
@ -123,4 +123,4 @@ namespace Server.Mobiles
int version = reader.ReadInt();
}
}
}
}

View file

@ -134,7 +134,7 @@ namespace Server.Mobiles
int amt = 0;
Mobile target = this;
int rand = Utility.Random(1, 100);
if (willKill) amt = ((rand % 5) >> 2) + 3;
if (willKill) amt = (rand % 5 >> 2) + 3;
if (Hits < 100 && rand < 21)
{
target = rand % 2 < 1 ? this : from;

View file

@ -108,7 +108,7 @@ namespace Server.Mobiles
target = m;
}
if (target == null || !target.InRange(this, 18))
if (target?.InRange(this, 18) != true)
target = attacker;
Animate(10, 4, 1, true, false, 0);

View file

@ -477,33 +477,23 @@ namespace Server.Mobiles
Direction dir = GetDirection4(oldWorldLoc, newWorldLoc);
if (itemIDs.Length == 2)
switch (dir)
item.ItemID = dir switch
{
case Direction.North:
case Direction.South:
item.ItemID = itemIDs[0];
break;
case Direction.East:
case Direction.West:
item.ItemID = itemIDs[1];
break;
}
Direction.North => itemIDs[0],
Direction.South => itemIDs[0],
Direction.East => itemIDs[1],
Direction.West => itemIDs[1],
_ => item.ItemID
};
else if (itemIDs.Length == 4)
switch (dir)
item.ItemID = dir switch
{
case Direction.South:
item.ItemID = itemIDs[0];
break;
case Direction.East:
item.ItemID = itemIDs[1];
break;
case Direction.North:
item.ItemID = itemIDs[2];
break;
case Direction.West:
item.ItemID = itemIDs[3];
break;
}
Direction.South => itemIDs[0],
Direction.East => itemIDs[1],
Direction.North => itemIDs[2],
Direction.West => itemIDs[3],
_ => item.ItemID
};
}
}
}
@ -575,8 +565,7 @@ namespace Server.Mobiles
else if (AnimalForm.UnderTransformation(this)) AnimalForm.RemoveContext(this, true);
}
if (m_MountBlock == null || !m_MountBlock.m_Timer.Running ||
m_MountBlock.m_Timer.Next < DateTime.UtcNow + duration) m_MountBlock = new MountBlock(duration, type, this);
if (m_MountBlock?.m_Timer.Running != true || m_MountBlock.m_Timer.Next < DateTime.UtcNow + duration) m_MountBlock = new MountBlock(duration, type, this);
}
public override void OnSkillInvalidated(Skill skill)
@ -1722,10 +1711,7 @@ namespace Server.Mobiles
DropHolding();
if (Core.AOS && Backpack?.Deleted == false)
{
Backpack.FindItemsByType<Item>(FindItems_Callback).ForEach(item => Backpack.AddItem(item));
}
if (Core.AOS && Backpack?.Deleted == false) Backpack.FindItemsByType<Item>(FindItems_Callback).ForEach(item => Backpack.AddItem(item));
EquipSnapshot = new List<Item>(Items);
@ -1931,8 +1917,7 @@ namespace Server.Mobiles
if (YoungDeathTeleport())
Timer.DelayCall(TimeSpan.FromSeconds(2.5), SendYoungDeathNotice);
if (DuelContext == null || !DuelContext.Registered || !DuelContext.Started || m_DuelPlayer == null ||
m_DuelPlayer.Eliminated)
if (DuelContext?.Registered != true || !DuelContext.Started || m_DuelPlayer?.Eliminated != false)
Faction.HandleDeath(this, killer);
Guilds.Guild.HandleDeath(this, killer);
@ -1988,7 +1973,7 @@ namespace Server.Mobiles
}
else if (type == MessageType.Alliance)
{
if (g.Alliance != null && g.Alliance.IsMember(g))
if (g.Alliance?.IsMember(g) == true)
{
//g.Alliance.AllianceTextMessage( hue, "[Alliance][{0}]: {1}", this.Name, text );
g.Alliance.AllianceChat(this, text);
@ -2691,28 +2676,24 @@ namespace Server.Mobiles
if (faction.Commander == this)
{
text = string.Concat(Female ? "(Commanding Lady of the " : "(Commanding Lord of the ",
faction.Definition.FriendlyName, ")");
text = $"{(Female ? "(Commanding Lady of the " : "(Commanding Lord of the ")}{faction.Definition.FriendlyName})";
}
else if (pl.Sheriff != null)
{
text = string.Concat("(The Sheriff of ", pl.Sheriff.Definition.FriendlyName, ", ",
faction.Definition.FriendlyName, ")");
text = $"(The Sheriff of {pl.Sheriff.Definition.FriendlyName}, {faction.Definition.FriendlyName})";
}
else if (pl.Finance != null)
{
text = string.Concat("(The Finance Minister of ", pl.Finance.Definition.FriendlyName, ", ",
faction.Definition.FriendlyName, ")");
text = $"(The Finance Minister of {pl.Finance.Definition.FriendlyName}, {faction.Definition.FriendlyName})";
}
else
{
ascii = true;
if (pl.MerchantTitle != MerchantTitle.None)
text = string.Concat("(", MerchantTitles.GetInfo(pl.MerchantTitle).Title.String, ", ",
faction.Definition.FriendlyName, ")");
text = $"({MerchantTitles.GetInfo(pl.MerchantTitle).Title.String}, {faction.Definition.FriendlyName})";
else
text = string.Concat("(", pl.Rank.Title.String, ", ", faction.Definition.FriendlyName, ")");
text = $"({pl.Rank.Title.String}, {faction.Definition.FriendlyName})";
}
int hue = Faction.Find(from) == faction ? 98 : 38;
@ -3284,7 +3265,7 @@ namespace Server.Mobiles
private void ToggleItemInsurance_Callback(Mobile from, Item item, bool target)
{
if (item == null || !item.IsChildOf(this))
if (item?.IsChildOf(this) != true)
{
if (target)
BeginTarget(-1, false, TargetFlags.None, ToggleItemInsurance_Callback);
@ -3766,7 +3747,7 @@ namespace Server.Mobiles
public override bool CheckPoisonImmunity(Mobile from, Poison poison)
{
if (Young && (DuelContext == null || !DuelContext.Started || DuelContext.Finished))
if (Young && (DuelContext?.Started != true || DuelContext.Finished))
return true;
return base.CheckPoisonImmunity(from, poison);
@ -3774,7 +3755,7 @@ namespace Server.Mobiles
public override void OnPoisonImmunity(Mobile from, Poison poison)
{
if (Young && (DuelContext == null || !DuelContext.Started || DuelContext.Finished))
if (Young && (DuelContext?.Started != true || DuelContext.Finished))
SendLocalizedMessage(
502808); // You would have been poisoned, were you not new to the land of Britannia. Be careful in the future.
else
@ -4107,7 +4088,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = "(Young)";
else
suffix = string.Concat(suffix, " (Young)");
suffix = $"{suffix} (Young)";
}
#region Ethics
@ -4117,7 +4098,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = EthicPlayer.Ethic.Definition.Adjunct.String;
else
suffix = string.Concat(suffix, " ", EthicPlayer.Ethic.Definition.Adjunct.String);
suffix = $"{suffix} {EthicPlayer.Ethic.Definition.Adjunct.String}";
}
#endregion
@ -4132,7 +4113,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = adjunct;
else
suffix = string.Concat(suffix, " ", adjunct);
suffix = $"{suffix} {adjunct}";
}
}
@ -4686,12 +4667,12 @@ namespace Server.Mobiles
public void RemoveBuff(BuffIcon b)
{
if (m_BuffTable == null || !m_BuffTable.ContainsKey(b))
if (m_BuffTable?.ContainsKey(b) != true)
return;
BuffInfo info = m_BuffTable[b];
if (info.Timer != null && info.Timer.Running)
if (info.Timer?.Running == true)
info.Timer.Stop();
m_BuffTable.Remove(b);

View file

@ -142,21 +142,13 @@ namespace Server.Mobiles
for (int i = 0; i < rats; ++i)
{
BaseCreature rat;
switch (Utility.Random(5))
var rat = Utility.Random(5) switch
{
default:
rat = new Ratman();
break;
case 2:
case 3:
rat = new RatmanArcher();
break;
case 4:
rat = new RatmanMage();
break;
}
2 => (BaseCreature)new RatmanArcher(),
3 => new RatmanArcher(),
4 => new RatmanMage(),
_ => new Ratman()
};
rat.Team = Team;
rat.MoveToWorld(map.GetRandomNearbyLocation(Location), map);

View file

@ -179,20 +179,13 @@ namespace Server.Mobiles
if (prot.Map != pm.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(pm, prot))
continue;
int chance = 0;
switch (VirtueHelper.GetLevel(prot, VirtueName.Justice))
var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch
{
case VirtueLevel.Seeker:
chance = 60;
break;
case VirtueLevel.Follower:
chance = 80;
break;
case VirtueLevel.Knight:
chance = 100;
break;
}
VirtueLevel.Seeker => 60,
VirtueLevel.Follower => 80,
VirtueLevel.Knight => 100,
_ => 0
};
if (chance > Utility.Random(100))
{

View file

@ -287,20 +287,13 @@ namespace Server.Mobiles
!JusticeVirtue.CheckMapRegion(pm, prot))
continue;
int chance = 0;
switch (VirtueHelper.GetLevel(prot, VirtueName.Justice))
var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch
{
case VirtueLevel.Seeker:
chance = 60;
break;
case VirtueLevel.Follower:
chance = 80;
break;
case VirtueLevel.Knight:
chance = 100;
break;
}
VirtueLevel.Seeker => 60,
VirtueLevel.Follower => 80,
VirtueLevel.Knight => 100,
_ => 0
};
if (chance > Utility.Random(100))
{

View file

@ -93,7 +93,7 @@ namespace Server.Mobiles
public static bool Withdraw(Mobile from, int amount)
{
// If for whatever reason the TOL checks fail, we should still try old methods for withdrawing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.WithdrawGold(amount)) return true;
if (AccountGold.Enabled && from.Account?.WithdrawGold(amount) == true) return true;
int balance = GetBalance(from, out Item[] gold, out Item[] checks);
@ -133,7 +133,7 @@ namespace Server.Mobiles
public static bool Deposit(Mobile from, int amount)
{
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount)) return true;
if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true) return true;
BankBox box = from.FindBankNoCreate();
@ -179,7 +179,7 @@ namespace Server.Mobiles
public static int DepositUpTo(Mobile from, int amount)
{
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount)) return amount;
if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true) return amount;
BankBox box = from.FindBankNoCreate();

View file

@ -658,10 +658,8 @@ namespace Server.Mobiles
m_Table = new Dictionary<string, EscortDestinationInfo>();
foreach (Region r in list)
{
if (r.Name != null && (r is DungeonRegion || r is TownRegion))
m_Table[r.Name] = new EscortDestinationInfo(r.Name, r);
}
}
public static EDI Find(string name)

View file

@ -22,16 +22,16 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(6))
return Utility.Random(6) switch
{
default:
case 0: return 0;
case 1: return Utility.RandomBlueHue();
case 2: return Utility.RandomGreenHue();
case 3: return Utility.RandomRedHue();
case 4: return Utility.RandomYellowHue();
case 5: return Utility.RandomNeutralHue();
}
0 => 0,
1 => Utility.RandomBlueHue(),
2 => Utility.RandomGreenHue(),
3 => Utility.RandomRedHue(),
4 => Utility.RandomYellowHue(),
5 => Utility.RandomNeutralHue(),
_ => 0
};
}
public override void InitOutfit()

View file

@ -25,15 +25,15 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(5))
return Utility.Random(5) switch
{
default:
case 0: return Utility.RandomBlueHue();
case 1: return Utility.RandomGreenHue();
case 2: return Utility.RandomRedHue();
case 3: return Utility.RandomYellowHue();
case 4: return Utility.RandomNeutralHue();
}
0 => Utility.RandomBlueHue(),
1 => Utility.RandomGreenHue(),
2 => Utility.RandomRedHue(),
3 => Utility.RandomYellowHue(),
4 => Utility.RandomNeutralHue(),
_ => Utility.RandomBlueHue()
};
}
public override void InitOutfit()

View file

@ -22,16 +22,16 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(6))
return Utility.Random(6) switch
{
default:
case 0: return 0;
case 1: return Utility.RandomBlueHue();
case 2: return Utility.RandomGreenHue();
case 3: return Utility.RandomRedHue();
case 4: return Utility.RandomYellowHue();
case 5: return Utility.RandomNeutralHue();
}
0 => 0,
1 => Utility.RandomBlueHue(),
2 => Utility.RandomGreenHue(),
3 => Utility.RandomRedHue(),
4 => Utility.RandomYellowHue(),
5 => Utility.RandomNeutralHue(),
_ => 0
};
}
public override void InitOutfit()

View file

@ -16,16 +16,16 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(6))
return Utility.Random(6) switch
{
default:
case 0: return 0;
case 1: return Utility.RandomBlueHue();
case 2: return Utility.RandomGreenHue();
case 3: return Utility.RandomRedHue();
case 4: return Utility.RandomYellowHue();
case 5: return Utility.RandomNeutralHue();
}
0 => 0,
1 => Utility.RandomBlueHue(),
2 => Utility.RandomGreenHue(),
3 => Utility.RandomRedHue(),
4 => Utility.RandomYellowHue(),
5 => Utility.RandomNeutralHue(),
_ => 0
};
}
public override void InitOutfit()

View file

@ -23,16 +23,16 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(6))
return Utility.Random(6) switch
{
default:
case 0: return 0;
case 1: return Utility.RandomBlueHue();
case 2: return Utility.RandomGreenHue();
case 3: return Utility.RandomRedHue();
case 4: return Utility.RandomYellowHue();
case 5: return Utility.RandomNeutralHue();
}
0 => 0,
1 => Utility.RandomBlueHue(),
2 => Utility.RandomGreenHue(),
3 => Utility.RandomRedHue(),
4 => Utility.RandomYellowHue(),
5 => Utility.RandomNeutralHue(),
_ => 0
};
}
public override void InitOutfit()

View file

@ -16,16 +16,16 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(6))
return Utility.Random(6) switch
{
default:
case 0: return 0;
case 1: return Utility.RandomBlueHue();
case 2: return Utility.RandomGreenHue();
case 3: return Utility.RandomRedHue();
case 4: return Utility.RandomYellowHue();
case 5: return Utility.RandomNeutralHue();
}
0 => 0,
1 => Utility.RandomBlueHue(),
2 => Utility.RandomGreenHue(),
3 => Utility.RandomRedHue(),
4 => Utility.RandomYellowHue(),
5 => Utility.RandomNeutralHue(),
_ => 0
};
}
public override void InitOutfit()

View file

@ -35,16 +35,16 @@ namespace Server.Mobiles
private static int GetRandomHue()
{
switch (Utility.Random(6))
return Utility.Random(6) switch
{
default:
case 0: return 0;
case 1: return Utility.RandomBlueHue();
case 2: return Utility.RandomGreenHue();
case 3: return Utility.RandomRedHue();
case 4: return Utility.RandomYellowHue();
case 5: return Utility.RandomNeutralHue();
}
0 => 0,
1 => Utility.RandomBlueHue(),
2 => Utility.RandomGreenHue(),
3 => Utility.RandomRedHue(),
4 => Utility.RandomYellowHue(),
5 => Utility.RandomNeutralHue(),
_ => 0
};
}
public override void InitOutfit()

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using Server.Commands;
using Server.Gumps;
using Server.Items;
using Server.Network;
@ -322,18 +321,12 @@ namespace Server.Mobiles
AddItem(new FancyShirt(Utility.RandomBlueHue()));
Item skirt;
switch (Utility.Random(2))
var skirt = Utility.Random(2) switch
{
case 0:
skirt = new Skirt();
break;
default:
case 1:
skirt = new Kilt();
break;
}
0 => (Item)new Skirt(),
1 => new Kilt(),
_ => new Kilt()
};
skirt.Hue = Utility.RandomGreenHue();
@ -341,18 +334,12 @@ namespace Server.Mobiles
AddItem(new FeatheredHat(Utility.RandomGreenHue()));
Item boots;
switch (Utility.Random(2))
var boots = Utility.Random(2) switch
{
case 0:
boots = new Boots();
break;
default:
case 1:
boots = new ThighBoots();
break;
}
0 => (Item)new Boots(),
1 => new ThighBoots(),
_ => new ThighBoots()
};
AddItem(boots);

View file

@ -252,15 +252,11 @@ namespace Server.Mobiles
{
Item buyItem;
if (amount >= item.Amount)
{
buyItem = item;
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount) ?? item;
}
if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
if (cont?.TryDropItem(buyer, buyItem, false) != true)
buyItem.MoveToWorld(buyer.Location, buyer.Map);
break;
@ -508,15 +504,15 @@ namespace Server.Mobiles
public virtual int GetRandomHue()
{
switch (Utility.Random(5))
return Utility.Random(5) switch
{
default:
case 0: return Utility.RandomBlueHue();
case 1: return Utility.RandomGreenHue();
case 2: return Utility.RandomRedHue();
case 3: return Utility.RandomYellowHue();
case 4: return Utility.RandomNeutralHue();
}
0 => Utility.RandomBlueHue(),
1 => Utility.RandomGreenHue(),
2 => Utility.RandomRedHue(),
3 => Utility.RandomYellowHue(),
4 => Utility.RandomNeutralHue(),
_ => Utility.RandomBlueHue()
};
}
public virtual int GetShoeHue() => 0.1 > Utility.RandomDouble() ? 0 : Utility.RandomNeutralHue();
@ -598,12 +594,12 @@ namespace Server.Mobiles
public virtual int GetRandomNecromancerHue()
{
switch (Utility.Random(20))
return Utility.Random(20) switch
{
case 0: return 0;
case 1: return 0x4E9;
default: return Utility.RandomList(0x485, 0x497);
}
0 => 0,
1 => 0x4E9,
_ => Utility.RandomList(0x485, 0x497)
};
}
public virtual void TurnToNecromancer()
@ -903,15 +899,13 @@ namespace Server.Mobiles
List<SellItemState> list = new List<SellItemState>();
foreach (IShopSellInfo ssi in info)
foreach (Item item in pack.FindItemsByType(ssi.Types))
{
foreach (Item item in pack.FindItemsByType(ssi.Types))
{
if (item is Container container && container.Items.Count != 0)
continue;
if (item is Container container && container.Items.Count != 0)
continue;
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item)));
}
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item)));
}
if (list.Count > 0)
@ -992,10 +986,8 @@ namespace Server.Mobiles
IBuyItemInfo[] buyInfo = GetBuyInfo();
for (int i = 0; i < buyInfo.Length; ++i)
{
if (buyInfo[i] is GenericBuyInfo gbi && gbi.GetDisplayEntity() == obj)
return gbi;
}
return null;
}
@ -1045,26 +1037,24 @@ namespace Server.Mobiles
{
item.Amount = amount;
if (cont == null || !cont.TryDropItem(buyer, item, false))
if (cont?.TryDropItem(buyer, item, false) != true)
item.MoveToWorld(buyer.Location, buyer.Map);
}
else
{
item.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, item, false))
if (cont?.TryDropItem(buyer, item, false) != true)
item.MoveToWorld(buyer.Location, buyer.Map);
for (int i = 1; i < amount; i++)
{
if (bii.GetEntity() is Item newItem)
{
newItem.Amount = 1;
if (cont == null || !cont.TryDropItem(buyer, newItem, false))
if (cont?.TryDropItem(buyer, newItem, false) != true)
newItem.MoveToWorld(buyer.Location, buyer.Map);
}
}
}
}
else if (o is Mobile m)
@ -1080,7 +1070,6 @@ namespace Server.Mobiles
}
for (int i = 1; i < amount; ++i)
{
if (bii.GetEntity() is Mobile newMobile)
{
newMobile.Direction = (Direction)Utility.Random(8);
@ -1092,7 +1081,6 @@ namespace Server.Mobiles
newBc.ControlOrder = OrderType.Stop;
}
}
}
}
}
@ -1118,29 +1106,17 @@ namespace Server.Mobiles
GenericBuyInfo gbi = buyInfo[j];
int maxAmount = gbi.MaxAmount;
int doubled = 0;
switch (maxAmount)
var doubled = maxAmount switch
{
case 40:
doubled = 1;
break;
case 80:
doubled = 2;
break;
case 160:
doubled = 3;
break;
case 320:
doubled = 4;
break;
case 640:
doubled = 5;
break;
case 999:
doubled = 6;
break;
}
40 => 1,
80 => 2,
160 => 3,
320 => 4,
640 => 5,
999 => 6,
_ => 0
};
if (doubled > 0)
{
@ -1188,29 +1164,16 @@ namespace Server.Mobiles
{
GenericBuyInfo gbi = buyInfo[buyInfoIndex];
int amount = 20;
switch (doubled)
var amount = doubled switch
{
case 1:
amount = 40;
break;
case 2:
amount = 80;
break;
case 3:
amount = 160;
break;
case 4:
amount = 320;
break;
case 5:
amount = 640;
break;
case 6:
amount = 999;
break;
}
1 => 40,
2 => 80,
3 => 160,
4 => 320,
5 => 640,
6 => 999,
_ => 20
};
gbi.Amount = gbi.MaxAmount = amount;
}

View file

@ -102,8 +102,11 @@ namespace Server.Mobiles
if (pet?.Deleted != false)
{
pet.IsStabled = false;
pet.StabledBy = null;
if (pet != null)
{
pet.IsStabled = false;
pet.StabledBy = null;
}
from.Stabled.RemoveAt(i);
--i;
continue;

View file

@ -93,7 +93,6 @@ namespace Server.Mobiles
public override bool OnGoldGiven(Mobile from, Gold dropped)
{
if (from is PlayerMobile pm && dropped.Amount == 700)
{
if (pm.NpcGuild == NpcGuild.ThievesGuild)
{
pm.AddToBackpack(new DisguiseKit());
@ -101,7 +100,6 @@ namespace Server.Mobiles
dropped.Delete();
return true;
}
}
return base.OnGoldGiven(from, dropped);
}

View file

@ -53,15 +53,12 @@ namespace Server.Mobiles
AddItem(ApplyHue(new PlateGorget(), 0x47E));
}
switch (Utility.Random(Female ? 2 : 1))
HairItemID = Utility.Random(Female ? 2 : 1) switch
{
case 0:
HairItemID = 0x203C;
break;
case 1:
HairItemID = 0x203D;
break;
}
0 => 0x203C,
1 => 0x203D,
_ => HairItemID
};
HairHue = 0x47E;

View file

@ -602,7 +602,7 @@ namespace Server.Mobiles
House.VendorInventories.Add(inventory);
}
}
else if ((toBackpack || House == null || !House.IsAosRules) && Map != Map.Internal
else if ((toBackpack || House?.IsAosRules != true) && Map != Map.Internal
) // Case 3 - Move to backpack
{
Container backpack = new Backpack();
@ -851,7 +851,7 @@ namespace Server.Mobiles
if (!string.IsNullOrEmpty(item.Name))
name = item.Name;
else
name = "#" + item.LabelNumber;
name = $"#{item.LabelNumber}";
from.SendLocalizedMessage(1043303, name); // Type in a price and description for ~1_ITEM~ (ESC=not for sale)
from.Prompt = new VendorPricePrompt(this, vi);
@ -1110,7 +1110,7 @@ namespace Server.Mobiles
{
SayTo(from, 503212); // You own this shop, just take what you want.
}
else if (House == null || !House.IsBanned(from))
else if (House?.IsBanned(from) != true)
{
from.SendLocalizedMessage(503213); // Select the item you wish to buy.
from.Target = new PVBuyTarget();

View file

@ -115,8 +115,7 @@ namespace Server.Mobiles
ComputeRentalExpireDelay(out int days, out int hours);
to.SendLocalizedMessage(1062464,
days + "\t" +
hours); // The rental contract on this vendor will expire in ~1_DAY~ day(s) and ~2_HOUR~ hour(s).
$"{days}\t{hours}"); // The rental contract on this vendor will expire in ~1_DAY~ day(s) and ~2_HOUR~ hour(s).
}
public override void OnAfterDelete()