diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs index c57471a79..6e0755423 100755 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs @@ -502,8 +502,10 @@ namespace Server.Engines.CannedEvil { RegisterDamageTo(Champion); - //if (m_Champion is BaseChampion) - // AwardArtifact(((BaseChampion)m_Champion).GetArtifact()); + if (Core.ML) + { + AwardArtifact((Champion as BaseChampion)?.GetArtifact()); + } DamageEntries.Clear(); @@ -560,31 +562,22 @@ namespace Server.Engines.CannedEvil { if (Map == Map.Felucca) { - if (Utility.RandomDouble() < 0.001) + // 1 in 1000 you get either a scroll of transcendence or a powerscroll + var random = Utility.Random(2000); + if (random == 0) { - double random = Utility.Random (49); - - if (random <= 24) - { - ScrollofTranscendence SoTF = CreateRandomFelSoT(); - GiveScrollOfTranscendenceFelTo (pm, SoTF); - } - else - { - PowerScroll PS = CreateRandomFelPS(); - GivePowerScrollFelTo (pm, PS); - } + GiveScrollOfTranscendenceFelTo(pm, CreateRandomFelSoT()); + } + else if (random == 1) + { + GivePowerScrollFelTo(pm, CreateRandomFelPS()); } } - if (Map == Map.Ilshenar || Map == Map.Tokuno) + if ((Map == Map.Ilshenar || Map == Map.Tokuno) && Utility.Random(10000) < 15) { - if (Utility.RandomDouble() < 0.0015) - { - pm.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence! - ScrollofTranscendence SoTT = CreateRandomTramSoT(); - pm.AddToBackpack(SoTT); - } + pm.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence! + pm.AddToBackpack(CreateRandomTramSoT()); } } diff --git a/Projects/UOContent/Engines/Harvest/Fishing.cs b/Projects/UOContent/Engines/Harvest/Fishing.cs index 7e8cb9009..27025d612 100644 --- a/Projects/UOContent/Engines/Harvest/Fishing.cs +++ b/Projects/UOContent/Engines/Harvest/Fishing.cs @@ -115,7 +115,7 @@ namespace Server.Engines.Harvest if (obj?.Completed == false) { - if (Utility.RandomDouble() < 0.5) + if (Utility.RandomBool()) { // You pull a shellfish out of the water, and find a rainbow pearl inside of it. player.SendLocalizedMessage(1055086, "", 0x59); diff --git a/Projects/UOContent/Engines/ML Quests/Items/CraftmansSatchel.cs b/Projects/UOContent/Engines/ML Quests/Items/CraftmansSatchel.cs index a88fe40e4..c525fcd25 100644 --- a/Projects/UOContent/Engines/ML Quests/Items/CraftmansSatchel.cs +++ b/Projects/UOContent/Engines/ML Quests/Items/CraftmansSatchel.cs @@ -61,7 +61,7 @@ namespace Server.Engines.MLQuests.Items { AddBaseLoot(Loot.MLArmorTypes, Loot.JewelryTypes, m_TalismanType); - if (Utility.RandomDouble() < 0.50) + if (Utility.RandomBool()) { AddRecipe(DefTailoring.CraftSystem); } @@ -94,7 +94,7 @@ namespace Server.Engines.MLQuests.Items { AddBaseLoot(Loot.MLWeaponTypes, Loot.JewelryTypes, m_TalismanType); - if (Utility.RandomDouble() < 0.50) + if (Utility.RandomBool()) { AddRecipe(DefBlacksmithy.CraftSystem); } @@ -127,7 +127,7 @@ namespace Server.Engines.MLQuests.Items { AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); - if (Utility.RandomDouble() < 0.50) + if (Utility.RandomBool()) { switch (Utility.Random(6)) { @@ -173,7 +173,7 @@ namespace Server.Engines.MLQuests.Items { AddBaseLoot(Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); - if (Utility.RandomDouble() < 0.50) + if (Utility.RandomBool()) { AddRecipe(DefBowFletching.CraftSystem); } @@ -208,7 +208,7 @@ namespace Server.Engines.MLQuests.Items { AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); - if (Utility.RandomDouble() < 0.50) + if (Utility.RandomBool()) { AddRecipe(DefCarpentry.CraftSystem); } diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index 992214b14..7976ad583 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -185,7 +185,7 @@ namespace Server.Engines.Events return; } - if (Utility.RandomDouble() > .10) + if (Utility.RandomDouble() < 0.90) { begged.Say( Utility.Random(3) switch @@ -196,7 +196,7 @@ namespace Server.Engines.Events } ); - if (Utility.RandomDouble() <= .01 && from.Skills.Begging.Value >= 100) + if (Utility.RandomDouble() < 0.01 && from.Skills.Begging.Value >= 100) { from.AddToBackpack(HolidaySettings.RandomGMBeggerItem); diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs index 896af55d9..ebeb8ead6 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs @@ -19,7 +19,7 @@ namespace Server.Items public HalloweenPumpkin() { Weight = Utility.RandomMinMax(3, 20); - ItemID = Utility.RandomDouble() <= .02 + ItemID = Utility.RandomDouble() < 0.02 ? Utility.RandomList(0x4694, 0x4698) : Utility.RandomList(0xc6a, 0xc6b, 0xc6c); } diff --git a/Projects/UOContent/Items/Aquarium/Aquarium.cs b/Projects/UOContent/Items/Aquarium/Aquarium.cs index 165811484..e86aac949 100644 --- a/Projects/UOContent/Items/Aquarium/Aquarium.cs +++ b/Projects/UOContent/Items/Aquarium/Aquarium.cs @@ -656,7 +656,7 @@ namespace Server.Items { fish.Hue = FishHues.RandomElement(); } - else if (Utility.RandomDouble() < 0.5) + else if (Utility.RandomBool()) { fish.Hue = Utility.RandomMinMax(0x100, 0x3E5); } diff --git a/Projects/UOContent/Items/Champion Artifacts/Decorative/Futon.cs b/Projects/UOContent/Items/Champion Artifacts/Decorative/Futon.cs index 78e53af72..f3f24c91f 100644 --- a/Projects/UOContent/Items/Champion Artifacts/Decorative/Futon.cs +++ b/Projects/UOContent/Items/Champion Artifacts/Decorative/Futon.cs @@ -7,7 +7,7 @@ namespace Server.Items public partial class Futon : Item { [Constructible] - public Futon() : base(Utility.RandomDouble() > 0.5 ? 0x295C : 0x295E) + public Futon() : base(Utility.RandomBool() ? 0x295C : 0x295E) { } diff --git a/Projects/UOContent/Items/Containers/TreasureMapChest.cs b/Projects/UOContent/Items/Containers/TreasureMapChest.cs index 5b3153892..a584a0579 100644 --- a/Projects/UOContent/Items/Containers/TreasureMapChest.cs +++ b/Projects/UOContent/Items/Containers/TreasureMapChest.cs @@ -361,7 +361,7 @@ public partial class TreasureMapChest : LockableContainer public override void OnItemLifted(Mobile from, Item item) { - var notYetLifted = _lifted?.Contains(item) != true; + var notYetLifted = _lifted?.Contains(item) != true; from.RevealingAction(); if (notYetLifted) @@ -369,7 +369,7 @@ public partial class TreasureMapChest : LockableContainer _lifted ??= new HashSet(); _lifted.Add(item); - if (Utility.RandomDouble() <= 0.1) // 10% chance to spawn a new monster + if (Utility.RandomDouble() < 0.1) // 10% chance to spawn a new monster { TreasureMap.Spawn(_level, GetWorldLocation(), Map, from, false); } diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs index 756505c08..044d2b9a2 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs @@ -76,7 +76,7 @@ namespace Server.Items .Random(3) ); // "That doesn't seem like the smartest thing to do." / "That was an encounter you don't wish to repeat." / "Ha! You missed!" } - else if (Core.SE && Utility.RandomDouble() > .20 && (from.Direction & Direction.Running) != 0 && + else if (Core.SE && Utility.RandomDouble() < 0.80 && (from.Direction & Direction.Running) != 0 && Core.TickCount - from.LastMoveTime < from.ComputeMovementSpeed(from.Direction)) { // Didn't your parents ever tell you not to run with scissors in your hand?! diff --git a/Projects/UOContent/Items/Talismans/BaseTalisman.cs b/Projects/UOContent/Items/Talismans/BaseTalisman.cs index c3873c56d..1fbb11af1 100644 --- a/Projects/UOContent/Items/Talismans/BaseTalisman.cs +++ b/Projects/UOContent/Items/Talismans/BaseTalisman.cs @@ -1059,7 +1059,7 @@ namespace Server.Items public static TalismanAttribute GetRandomSummoner() { - if (Utility.RandomDouble() >= 0.025) + if (Utility.RandomDouble() < 0.975) { return new TalismanAttribute(); } @@ -1141,7 +1141,7 @@ namespace Server.Items ? (TalismanSlayerName)Utility.RandomMinMax(1, 9) : TalismanSlayerName.None; - public static int GetRandomCharges() => Utility.RandomDouble() < 0.5 ? Utility.RandomMinMax(10, 50) : 0; + public static int GetRandomCharges() => Utility.RandomBool() ? Utility.RandomMinMax(10, 50) : 0; [Flags] private enum SaveFlag diff --git a/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs b/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs index a53945086..7a46d1196 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs @@ -47,7 +47,7 @@ public class Dismount : WeaponAbility return; } - if (Core.ML && attacker is LesserHiryu && Utility.RandomDouble() <= 0.8) + if (Core.ML && attacker is LesserHiryu && Utility.RandomDouble() < 0.8) { return; // Lesser Hiryu have an 80% chance of missing this attack } diff --git a/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs b/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs index febf56b00..b676ed0a3 100644 --- a/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs +++ b/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs @@ -32,7 +32,7 @@ namespace Server.Items { --PoisonCharges; - if (Utility.RandomDouble() >= 0.5) // 50% chance to poison + if (Utility.RandomBool()) // 50% chance to poison { defender.ApplyPoison(attacker, Poison); } diff --git a/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs b/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs index 92ba5842c..c4ccc45f0 100644 --- a/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs +++ b/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs @@ -47,72 +47,85 @@ namespace Server.Items { from.SendMessage("You must be holding that weapon to use it."); } - else if (targeted is Mobile m) + else if (targeted is Mobile m && m != from && from.HarmfulCheck(m)) { - if (m != from && from.HarmfulCheck(m)) + var to = from.GetDirectionTo(m); + + from.Direction = to; + + from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0); + + if (Utility.RandomDouble() >= Math.Sqrt(m.Dex / 100.0) * 0.8) { - var to = from.GetDirectionTo(m); + from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0); - from.Direction = to; + AOS.Damage(m, from, Utility.Random(5, from.Str / 10), 100, 0, 0, 0, 0); - from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0); + m_Dagger.MoveToWorld(m.Location, m.Map); + } + else + { + int x = 0, y = 0; - if (Utility.RandomDouble() >= Math.Sqrt(m.Dex / 100.0) * 0.8) + switch (to & Direction.Mask) { - from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0); - - AOS.Damage(m, from, Utility.Random(5, from.Str / 10), 100, 0, 0, 0, 0); - - m_Dagger.MoveToWorld(m.Location, m.Map); + case Direction.North: + { + --y; + break; + } + case Direction.South: + { + ++y; + break; + } + case Direction.West: + { + --x; + break; + } + case Direction.East: + { + ++x; + break; + } + case Direction.Up: + { + --x; + --y; + break; + } + case Direction.Down: + { + ++x; + ++y; + break; + } + case Direction.Left: + { + --x; + ++y; + break; + } + case Direction.Right: + { + ++x; + --y; + break; + } } - else - { - int x = 0, y = 0; - switch (to & Direction.Mask) - { - case Direction.North: - --y; - break; - case Direction.South: - ++y; - break; - case Direction.West: - --x; - break; - case Direction.East: - ++x; - break; - case Direction.Up: - --x; - --y; - break; - case Direction.Down: - ++x; - ++y; - break; - case Direction.Left: - --x; - ++y; - break; - case Direction.Right: - ++x; - --y; - break; - } + x += Utility.Random(-1, 3); + y += Utility.Random(-1, 3); - x += Utility.Random(-1, 3); - y += Utility.Random(-1, 3); + x += m.X; + y += m.Y; - x += m.X; - y += m.Y; + m_Dagger.MoveToWorld(new Point3D(x, y, m.Z), m.Map); - m_Dagger.MoveToWorld(new Point3D(x, y, m.Z), m.Map); + from.MovingEffect(m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0); - from.MovingEffect(m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0); - - from.SendMessage("You miss."); - } + from.SendMessage("You miss."); } } } diff --git a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs index 4d9d3ce7f..b17429a7a 100644 --- a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs +++ b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs @@ -94,7 +94,7 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1) { if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && - Utility.RandomDouble() <= 0.4) + Utility.RandomDouble() < 0.4) { defender.AddToBackpack(Ammo); } @@ -124,7 +124,7 @@ namespace Server.Items public override void OnMiss(Mobile attacker, Mobile defender) { - if (attacker.Player && Utility.RandomDouble() <= 0.4) + if (attacker.Player && Utility.RandomDouble() < 0.4) { if (Core.SE) { diff --git a/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs b/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs index 574e2749d..612ce7033 100644 --- a/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs +++ b/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs @@ -37,7 +37,7 @@ namespace Server.Items { --PoisonCharges; - if (Utility.RandomDouble() >= 0.5) // 50% chance to poison + if (Utility.RandomBool()) // 50% chance to poison { defender.ApplyPoison(attacker, Poison); } diff --git a/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs b/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs index ffe129d16..270c39a22 100644 --- a/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs +++ b/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs @@ -29,7 +29,7 @@ namespace Server.Items { --PoisonCharges; - if (Utility.RandomDouble() >= 0.5) // 50% chance to poison + if (Utility.RandomBool()) // 50% chance to poison { defender.ApplyPoison(attacker, Poison); } diff --git a/Projects/UOContent/Misc/Poison.cs b/Projects/UOContent/Misc/Poison.cs index e0ce1542b..1e322db22 100644 --- a/Projects/UOContent/Misc/Poison.cs +++ b/Projects/UOContent/Misc/Poison.cs @@ -159,7 +159,7 @@ namespace Server AOS.Damage(m_Mobile, From, damage, 0, 0, 0, 100, 0); // OSI: randomly revealed between first and third damage tick, guessing 60% chance - if (Utility.RandomDouble() >= 0.60) + if (Utility.RandomDouble() < 0.40) { m_Mobile.RevealingAction(); } diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index c886b2ae2..c1f1b7139 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -2248,7 +2248,7 @@ public abstract class BaseAI if (blocked) { - var offset = Utility.RandomDouble() >= 0.6 ? 1 : -1; + var offset = Utility.RandomDouble() < 0.4 ? 1 : -1; for (var i = 0; i < 2; ++i) { diff --git a/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs b/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs index 2430532a0..a1d0bf124 100644 --- a/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs +++ b/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs @@ -8,7 +8,7 @@ namespace Server.Mobiles Body = Utility.RandomList(0xE8, 0xE9); BaseSoundID = 0x64; - if (Utility.RandomDouble() <= 0.5) + if (Utility.RandomBool()) { Hue = 0x901; } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs b/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs index 5f44ad263..a172e5f35 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs @@ -103,7 +103,7 @@ public class LesserHiryu : BaseMount { var tamingChance = base.GetControlChance(m, useBaseSkill); - if (tamingChance >= 0.95) + if (tamingChance < 0.05) { return tamingChance; } diff --git a/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs b/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs index 8f23649a2..c201ae850 100644 --- a/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs +++ b/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs @@ -52,7 +52,7 @@ namespace Server.Mobiles public override string DefaultName => "a giant snake"; public override Poison PoisonImmune => Poison.Greater; - public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() < 0.8 ? Poison.Greater : Poison.Deadly; public override bool DeathAdderCharmable => true; diff --git a/Projects/UOContent/Mobiles/BaseCreature.cs b/Projects/UOContent/Mobiles/BaseCreature.cs index dee356a22..4ca56b3b6 100644 --- a/Projects/UOContent/Mobiles/BaseCreature.cs +++ b/Projects/UOContent/Mobiles/BaseCreature.cs @@ -2995,7 +2995,7 @@ namespace Server.Mobiles { PackItem(new ParagonChest(Name, treasureLevel)); } - else if ((Map == Map.Felucca || Map == Map.Trammel) && Utility.RandomDouble() <= TreasureMap.LootChance) + else if ((Map == Map.Felucca || Map == Map.Trammel) && Utility.RandomDouble() < TreasureMap.LootChance) { PackItem(new TreasureMap(treasureLevel, Map)); } @@ -4222,7 +4222,7 @@ namespace Server.Mobiles { for (var i = 0; i < amount; ++i) { - if (m_Loyalty < MaxLoyalty && Utility.RandomDouble() <= 0.5) + if (m_Loyalty < MaxLoyalty && Utility.RandomBool()) { m_Loyalty += 10; } @@ -4799,7 +4799,7 @@ namespace Server.Mobiles public void PackNecroScroll(int index) { - if (!Core.AOS || Utility.RandomDouble() >= 0.05) + if (!Core.AOS || Utility.RandomDouble() < 0.95) { return; } diff --git a/Projects/UOContent/Mobiles/Familiars/DeathAdder.cs b/Projects/UOContent/Mobiles/Familiars/DeathAdder.cs index c42811e4a..e6f189a77 100644 --- a/Projects/UOContent/Mobiles/Familiars/DeathAdder.cs +++ b/Projects/UOContent/Mobiles/Familiars/DeathAdder.cs @@ -37,7 +37,7 @@ namespace Server.Mobiles public override string CorpseName => "a death adder corpse"; public override string DefaultName => "a death adder"; - public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() < 0.8 ? Poison.Greater : Poison.Deadly; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs b/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs index ff5a4454b..10ea0634f 100644 --- a/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs @@ -51,7 +51,7 @@ namespace Server.Mobiles { base.OnDeath(c); - if (Utility.RandomDouble() < 0.5) + if (Utility.RandomBool()) { c.DropItem(new FragmentOfAMap()); } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs b/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs index ef61460ef..1f1f37b8c 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs @@ -191,18 +191,12 @@ namespace Server.Mobiles } var luck = LootPack.GetLuckChanceForKiller(boss); - int chance; - if (boss is DemonKnight) + return boss switch { - chance = 1500 + luck / 5; - } - else - { - chance = 750 + luck / 10; - } - - return chance; + DemonKnight => 1500 + luck / 5, + _ => 750 + luck / 10 + }; } public static bool CheckArtifactChance(Mobile boss) => GetArtifactChance(boss) > Utility.Random(100000); diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs b/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs index 15272279a..f4eb46b21 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs @@ -53,7 +53,7 @@ namespace Server.Mobiles public override bool Unprovokable => Core.SE; public override bool AreaPeaceImmune => Core.SE; public override Poison PoisonImmune => Poison.Lethal; - public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() < 0.8 ? Poison.Greater : Poison.Deadly; public override int TreasureMapLevel => 1; diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs index 527b4b4ca..d0458d803 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 5 : 25)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.95 ? 5 : 25)); if (Utility.RandomDouble() < 0.05) { diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs index 997f65955..6d9dc70ff 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 4 : 16)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.95 ? 4 : 16)); } public RedSolenInfiltratorQueen(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs index afd41fd2a..acb004dc0 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 3 : 13)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.95 ? 3 : 13)); } public RedSolenInfiltratorWarrior(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs index 4e491e070..18649d8c4 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs @@ -39,7 +39,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 5 : 25)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.95 ? 5 : 25)); if (Utility.RandomDouble() < 0.05) { diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs index 0f3ce8f46..172f585d3 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles VirtualArmor = 35; SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 3 : 13)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.95 ? 3 : 13)); if (Utility.RandomDouble() < 0.05) { diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs index d869bd846..c7d7f8ed9 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs @@ -105,7 +105,7 @@ namespace Server.Mobiles m_Thrown++; - if (Utility.RandomDouble() <= 0.75 && m_Thrown % 2 == 1) // 75% chance to quickly throw another bomb + if (m_Thrown % 2 == 1 && Utility.RandomDouble() < 0.75) // 75% chance to quickly throw another bomb { m_NextBomb = Core.Now + TimeSpan.FromSeconds(3.0); } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs index 2b8a53ebb..5dafa5f8a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs @@ -52,7 +52,7 @@ namespace Server.Mobiles AddItem(new BoneArms()); AddItem(new BoneLegs()); - if (Utility.RandomDouble() < 0.5) + if (Utility.RandomBool()) { AddItem(new SavageMask()); } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs index 9585a617a..419a121f3 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs @@ -75,7 +75,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() > 0.2) + if (Utility.RandomDouble() < 0.80) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs index 5ea92aa3e..807411c82 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs @@ -73,7 +73,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.1) + if (Utility.RandomDouble() < 0.9) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs index e5175f0b7..9ce4f0cf3 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs @@ -94,7 +94,7 @@ namespace Server.Mobiles public void AreaPeace() { - if (Combatant == null || Deleted || !Alive || m_NextPeace > Core.Now || Utility.RandomDouble() > 0.1) + if (Combatant == null || Deleted || !Alive || m_NextPeace > Core.Now || Utility.RandomDouble() < 0.9) { return; } @@ -122,7 +122,7 @@ namespace Server.Mobiles public void AreaUndress() { - if (Combatant == null || Deleted || !Alive || m_NextUndress > Core.Now || Utility.RandomDouble() > 0.005) + if (Combatant == null || Deleted || !Alive || m_NextUndress > Core.Now || Utility.RandomDouble() >= 0.005) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs index 98f2b9bf1..7d9afe271 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs @@ -90,7 +90,7 @@ namespace Server.Mobiles public void Peace(Mobile target) { - if (target == null || Deleted || !Alive || m_NextPeace > Core.Now || Utility.RandomDouble() > 0.1) + if (target == null || Deleted || !Alive || m_NextPeace > Core.Now || Utility.RandomDouble() < 0.9) { return; } @@ -111,7 +111,7 @@ namespace Server.Mobiles public void Suppress(Mobile target) { if (target == null || m_Suppressed.ContainsKey(target) || Deleted || !Alive || - m_NextSuppress > Core.Now || Utility.RandomDouble() > 0.1) + m_NextSuppress > Core.Now || Utility.RandomDouble() < 0.9) { return; } @@ -160,7 +160,7 @@ namespace Server.Mobiles public void Undress(Mobile target) { - if (target == null || Deleted || !Alive || m_NextUndress > Core.Now || Utility.RandomDouble() > 0.005) + if (target == null || Deleted || !Alive || m_NextUndress > Core.Now || Utility.RandomDouble() >= 0.005) { return; } @@ -193,7 +193,7 @@ namespace Server.Mobiles public void Provoke(Mobile target) { - if (target == null || Deleted || !Alive || m_NextProvoke > Core.Now || Utility.RandomDouble() > 0.05) + if (target == null || Deleted || !Alive || m_NextProvoke > Core.Now || Utility.RandomDouble() < 0.95) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs b/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs index 81caffce0..de684909d 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs @@ -167,7 +167,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() <= 0.2) + if (Utility.RandomDouble() < 0.2) { Earthquake(); } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs b/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs index a3588f794..0ce251ed7 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs @@ -103,7 +103,7 @@ namespace Server.Mobiles public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { - if (Utility.RandomDouble() <= 0.1) + if (Utility.RandomDouble() < 0.1) { SpawnPixies(caster); } @@ -122,7 +122,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker, damage); - if (Utility.RandomDouble() <= 0.1) + if (Utility.RandomDouble() < 0.1) { SpawnPixies(attacker); } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs index 67ec9b586..84a52ce22 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs @@ -100,7 +100,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.1) + if (Utility.RandomDouble() < 0.9) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs index 4cf5179f6..64b54c05f 100644 --- a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs +++ b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs @@ -122,16 +122,16 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker, damage); - if (Hits > HitsMax / 4) + if (Utility.RandomDouble() < 0.25) { - if (Utility.RandomDouble() <= 0.25) + if (Hits > HitsMax / 4) { SpawnBogling(attacker); } - } - else if (Utility.RandomDouble() <= 0.25) - { - EatBoglings(); + else + { + EatBoglings(); + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs index 8fdf40f0d..3faed66a5 100644 --- a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs +++ b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles PackReg(3); PackItem(new FertileDirt(Utility.RandomMinMax(1, 10))); - if (Utility.RandomDouble() <= 0.2) + if (Utility.RandomDouble() < 0.2) { PackItem(new ExecutionersCap()); } diff --git a/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Scorpion.cs b/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Scorpion.cs index c3d172d7b..a8e3f52b5 100644 --- a/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Scorpion.cs +++ b/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Scorpion.cs @@ -56,7 +56,7 @@ namespace Server.Mobiles public override FoodType FavoriteFood => FoodType.Meat; public override PackInstinct PackInstinct => PackInstinct.Arachnid; public override Poison PoisonImmune => Poison.Greater; - public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() < 0.8 ? Poison.Greater : Poison.Deadly; public override void GenerateLoot() { diff --git a/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs b/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs index 4da10e301..4a1b5b94b 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs @@ -93,7 +93,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.1) + if (Utility.RandomDouble() < 0.9) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs b/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs index e272fac06..99887f0f3 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs @@ -49,7 +49,7 @@ namespace Server.Mobiles AddItem(new Tessen()); - if (Utility.RandomDouble() <= 0.02) + if (Utility.RandomDouble() < 0.02) { PackItem(new OrigamiPaper()); } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs b/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs index c6f9976f6..b476dc2d0 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs @@ -77,7 +77,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.1) + if (Utility.RandomDouble() < 0.9) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs b/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs index 9aad525db..543000d95 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs @@ -60,7 +60,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.1 || m_Table.Contains(defender)) + if (Utility.RandomDouble() < 0.9 || m_Table.Contains(defender)) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs b/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs index 91ca622e6..9d0825afb 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs @@ -75,7 +75,7 @@ namespace Server.Mobiles break; } - if (Utility.RandomDouble() > .2) + if (Utility.RandomDouble() < 0.80) { AddItem(new NoDachi()); } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs b/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs index cc130977f..04bed601c 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs @@ -99,7 +99,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.05) + if (Utility.RandomDouble() < 0.95) { return; } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs b/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs index 62efb2d0a..535976364 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs @@ -82,7 +82,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() >= 0.1) + if (Utility.RandomDouble() < 0.9) { return; } diff --git a/Projects/UOContent/Mobiles/Special/Barracoon.cs b/Projects/UOContent/Mobiles/Special/Barracoon.cs index 4b10286aa..422b5fe94 100644 --- a/Projects/UOContent/Mobiles/Special/Barracoon.cs +++ b/Projects/UOContent/Mobiles/Special/Barracoon.cs @@ -185,12 +185,12 @@ namespace Server.Mobiles return; } - if (Utility.RandomDouble() <= 0.6) // 60% chance to polymorph attacker into a ratman + if (Utility.RandomDouble() < 0.6) // 60% chance to polymorph attacker into a ratman { Polymorph(target); } - if (Utility.RandomDouble() <= 0.2) // 20% chance to more ratmen + if (Utility.RandomDouble() < 0.2) // 20% chance to spawn more ratmen { SpawnRatmen(target); } diff --git a/Projects/UOContent/Mobiles/Special/BaseChampion.cs b/Projects/UOContent/Mobiles/Special/BaseChampion.cs index 0085781a7..ac1b1bb33 100644 --- a/Projects/UOContent/Mobiles/Special/BaseChampion.cs +++ b/Projects/UOContent/Mobiles/Special/BaseChampion.cs @@ -41,26 +41,14 @@ namespace Server.Mobiles var version = reader.ReadInt(); } - public Item GetArtifact() - { - var random = Utility.RandomDouble(); - if (random <= 0.05) + public Item GetArtifact() => + Utility.RandomDouble() switch { - return CreateArtifact(UniqueList); - } - - if (random <= 0.15) - { - return CreateArtifact(SharedList); - } - - if (random <= 0.30) - { - return CreateArtifact(DecorativeList); - } - - return null; - } + < 0.05 => CreateArtifact(UniqueList), + < 0.15 => CreateArtifact(SharedList), + < 0.30 => CreateArtifact(DecorativeList), + _ => null + }; public Item CreateArtifact(Type[] list) { @@ -82,23 +70,14 @@ namespace Server.Mobiles return artifact; } - private PowerScroll CreateRandomPowerScroll() + private static PowerScroll CreateRandomPowerScroll() { - int level; - var random = Utility.RandomDouble(); - - if (random <= 0.05) + var level = Utility.RandomDouble() switch { - level = 20; - } - else if (random <= 0.4) - { - level = 15; - } - else - { - level = 10; - } + < 0.05 => 20, + < 0.4 => 15, + _ => 10 + }; return PowerScroll.CreateRandomNoCraft(level, level); } @@ -226,16 +205,13 @@ namespace Server.Mobiles { prot.AddToBackpack(powerScroll); } + else if (prot.Corpse?.Deleted == false) + { + prot.Corpse.DropItem(powerScroll); + } else { - if (prot.Corpse?.Deleted == false) - { - prot.Corpse.DropItem(powerScroll); - } - else - { - prot.AddToBackpack(powerScroll); - } + prot.AddToBackpack(powerScroll); } } } @@ -342,49 +318,51 @@ namespace Server.Mobiles g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); - if (Utility.RandomDouble() <= 0.5) + if (Utility.RandomDouble() < 0.95) { - switch (Utility.Random(3)) - { - case 0: // Fire column - { - Effects.SendLocationParticles( - EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x3709, - 10, - 30, - 5052 - ); - Effects.PlaySound(g, 0x208); + return; + } - break; - } - case 1: // Explosion - { - Effects.SendLocationParticles( - EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36BD, - 20, - 10, - 5044 - ); - Effects.PlaySound(g, 0x307); + switch (Utility.Random(3)) + { + case 0: // Fire column + { + Effects.SendLocationParticles( + EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x3709, + 10, + 30, + 5052 + ); + Effects.PlaySound(g, 0x208); - break; - } - case 2: // Ball of fire - { - Effects.SendLocationParticles( - EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36FE, - 10, - 10, - 5052 - ); + break; + } + case 1: // Explosion + { + Effects.SendLocationParticles( + EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36BD, + 20, + 10, + 5044 + ); + Effects.PlaySound(g, 0x307); - break; - } - } + break; + } + case 2: // Ball of fire + { + Effects.SendLocationParticles( + EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36FE, + 10, + 10, + 5052 + ); + + break; + } } } } diff --git a/Projects/UOContent/Mobiles/Special/Harrower.cs b/Projects/UOContent/Mobiles/Special/Harrower.cs index ad0779270..ef065d74a 100644 --- a/Projects/UOContent/Mobiles/Special/Harrower.cs +++ b/Projects/UOContent/Mobiles/Special/Harrower.cs @@ -88,9 +88,9 @@ namespace Server.Mobiles Instances.Add(this); } - public Type[] UniqueList => new[] { typeof(AcidProofRobe) }; - public Type[] SharedList => new[] { typeof(TheRobeOfBritanniaAri) }; - public Type[] DecorativeList => new[] { typeof(EvilIdolSkull), typeof(SkullPole) }; + public static Type[] UniqueList => new[] { typeof(AcidProofRobe) }; + public static Type[] SharedList => new[] { typeof(TheRobeOfBritanniaAri) }; + public static Type[] DecorativeList => new[] { typeof(EvilIdolSkull), typeof(SkullPole) }; public static List Instances { get; } = new(); @@ -269,29 +269,14 @@ namespace Server.Mobiles for (var i = 0; i < 16; ++i) { - int level; - var random = Utility.RandomDouble(); - - if (random <= 0.1) + var level = Utility.RandomDouble() switch { - level = 25; - } - else if (random <= 0.25) - { - level = 20; - } - else if (random <= 0.45) - { - level = 15; - } - else if (random <= 0.70) - { - level = 10; - } - else - { - level = 5; - } + < 0.1 => 25, + < 0.25 => 20, + < 0.45 => 15, + < 0.70 => 10, + _ => 5 + }; var m = toGive[i % toGive.Count]; @@ -482,9 +467,8 @@ namespace Server.Mobiles } else { - to.SendLocalizedMessage( - 1062317 - ); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. + // For your valor in combating the fallen beast, a special artifact has been bestowed on you. + to.SendLocalizedMessage(1062317); } } @@ -492,26 +476,14 @@ namespace Server.Mobiles m.Player && m.Alive && m.InRange(Location, 32) && m.Backpack?.CheckHold(m, artifact, false) == true; - public Item GetArtifact() - { - var random = Utility.RandomDouble(); - if (random <= 0.05) + public Item GetArtifact() => + Utility.RandomDouble() switch { - return CreateArtifact(UniqueList); - } - - if (random <= 0.15) - { - return CreateArtifact(SharedList); - } - - if (random <= 0.30) - { - return CreateArtifact(DecorativeList); - } - - return null; - } + < 0.05 => CreateArtifact(UniqueList), + < 0.15 => CreateArtifact(SharedList), + < 0.30 => CreateArtifact(DecorativeList), + _ => null + }; public Item CreateArtifact(Type[] list) => Loot.Construct(list.RandomElement()); @@ -564,7 +536,7 @@ namespace Server.Mobiles return; } - if (Utility.RandomDouble() > 0.25) + if (Utility.RandomDouble() < 0.75) { return; } @@ -678,49 +650,51 @@ namespace Server.Mobiles g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); - if (Utility.RandomDouble() <= 0.5) + if (Utility.RandomDouble() < 0.95) { - switch (Utility.Random(3)) - { - case 0: // Fire column - { - Effects.SendLocationParticles( - EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x3709, - 10, - 30, - 5052 - ); - Effects.PlaySound(g, 0x208); + return; + } - break; - } - case 1: // Explosion - { - Effects.SendLocationParticles( - EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36BD, - 20, - 10, - 5044 - ); - Effects.PlaySound(g, 0x307); + switch (Utility.Random(3)) + { + case 0: // Fire column + { + Effects.SendLocationParticles( + EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x3709, + 10, + 30, + 5052 + ); + Effects.PlaySound(g, 0x208); - break; - } - case 2: // Ball of fire - { - Effects.SendLocationParticles( - EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36FE, - 10, - 10, - 5052 - ); + break; + } + case 1: // Explosion + { + Effects.SendLocationParticles( + EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36BD, + 20, + 10, + 5044 + ); + Effects.PlaySound(g, 0x307); - break; - } - } + break; + } + case 2: // Ball of fire + { + Effects.SendLocationParticles( + EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36FE, + 10, + 10, + 5052 + ); + + break; + } } } } diff --git a/Projects/UOContent/Mobiles/Special/LordOaks.cs b/Projects/UOContent/Mobiles/Special/LordOaks.cs index 031b73fef..654f7bda5 100644 --- a/Projects/UOContent/Mobiles/Special/LordOaks.cs +++ b/Projects/UOContent/Mobiles/Special/LordOaks.cs @@ -151,7 +151,7 @@ namespace Server.Mobiles { scalar *= 0.1; - if (Utility.RandomDouble() <= 0.1) + if (Utility.RandomDouble() < 0.1) { SpawnPixies(caster); } @@ -173,7 +173,7 @@ namespace Server.Mobiles CheckQueen(); - if (m_Queen != null && Utility.RandomDouble() <= 0.1) + if (m_Queen != null && Utility.RandomDouble() < 0.1) { SpawnPixies(attacker); } diff --git a/Projects/UOContent/Mobiles/Special/Neira.cs b/Projects/UOContent/Mobiles/Special/Neira.cs index 0707588e9..e3404ea9b 100644 --- a/Projects/UOContent/Mobiles/Special/Neira.cs +++ b/Projects/UOContent/Mobiles/Special/Neira.cs @@ -144,7 +144,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone + if (Utility.RandomDouble() < 0.1) // 10% chance to drop or throw an unholy bone { AddUnholyBone(defender, 0.25); } @@ -156,7 +156,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker, damage); - if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone + if (Utility.RandomDouble() < 0.1) // 10% chance to drop or throw an unholy bone { AddUnholyBone(attacker, 0.25); } @@ -166,7 +166,7 @@ namespace Server.Mobiles { base.AlterDamageScalarFrom(caster, ref scalar); - if (Utility.RandomDouble() <= 0.1) // 10% chance to throw an unholy bone + if (Utility.RandomDouble() < 0.1) // 10% chance to throw an unholy bone { AddUnholyBone(caster, 1.0); } diff --git a/Projects/UOContent/Mobiles/Special/Rikktor.cs b/Projects/UOContent/Mobiles/Special/Rikktor.cs index d242fba93..540cd2536 100644 --- a/Projects/UOContent/Mobiles/Special/Rikktor.cs +++ b/Projects/UOContent/Mobiles/Special/Rikktor.cs @@ -83,7 +83,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender, damage); - if (Utility.RandomDouble() <= 0.2) + if (Utility.RandomDouble() < 0.2) { Earthquake(); } diff --git a/Projects/UOContent/Mobiles/Special/Silvani.cs b/Projects/UOContent/Mobiles/Special/Silvani.cs index 8aae6dbcf..7fa1deab8 100644 --- a/Projects/UOContent/Mobiles/Special/Silvani.cs +++ b/Projects/UOContent/Mobiles/Special/Silvani.cs @@ -78,7 +78,7 @@ namespace Server.Mobiles public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { - if (Utility.RandomDouble() <= 0.1) + if (Utility.RandomDouble() < 0.1) { SpawnPixies(caster); } @@ -97,7 +97,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker, damage); - if (Utility.RandomDouble() <= 0.1) + if (Utility.RandomDouble() < 0.1) { SpawnPixies(attacker); } diff --git a/Projects/UOContent/Skills/AnimalTaming.cs b/Projects/UOContent/Skills/AnimalTaming.cs index 1ebd2812e..59eaf9232 100644 --- a/Projects/UOContent/Skills/AnimalTaming.cs +++ b/Projects/UOContent/Skills/AnimalTaming.cs @@ -206,7 +206,7 @@ namespace Server.SkillHandlers // Someone else is already taming this. creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802, from.NetState); } - else if (creature.CanAngerOnTame && Utility.RandomDouble() <= 0.95) + else if (creature.CanAngerOnTame && Utility.RandomDouble() < 0.95) { // You seem to anger the beast! creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805, from.NetState); @@ -214,7 +214,7 @@ namespace Server.SkillHandlers creature.PlaySound(creature.GetAngerSound()); creature.Direction = creature.GetDirectionTo(from); - if (creature.BardPacified && Utility.RandomDouble() > .24) + if (creature.BardPacified && Utility.RandomDouble() < 0.75) { Timer.StartTimer(TimeSpan.FromSeconds(2.0), () => Pacify(creature)); } diff --git a/Projects/UOContent/Skills/SpiritSpeak.cs b/Projects/UOContent/Skills/SpiritSpeak.cs index 40932abf2..42a5eac60 100644 --- a/Projects/UOContent/Skills/SpiritSpeak.cs +++ b/Projects/UOContent/Skills/SpiritSpeak.cs @@ -161,7 +161,9 @@ namespace Server.SkillHandlers { Caster.CheckSkill(SkillName.SpiritSpeak, 0.0, 120.0); - if (Utility.RandomDouble() > Caster.Skills.SpiritSpeak.Value / 100.0) + var skill = Caster.Skills.SpiritSpeak.Value; + + if (skill < 100.0 && Utility.RandomDouble() >= skill / 100.0) { Caster.SendLocalizedMessage(502443); // You fail your attempt at contacting the netherworld. } diff --git a/Projects/UOContent/Spells/Necromancy/Strangle.cs b/Projects/UOContent/Spells/Necromancy/Strangle.cs index 8c1fff766..289726e5e 100644 --- a/Projects/UOContent/Spells/Necromancy/Strangle.cs +++ b/Projects/UOContent/Spells/Necromancy/Strangle.cs @@ -219,7 +219,7 @@ namespace Server.Spells.Necromancy AOS.Damage(_target, _from, (int)damage, 0, 0, 0, 100, 0); // OSI: randomly revealed between first and third damage tick, guessing 60% chance - if (Utility.RandomDouble() >= 0.60) + if (Utility.RandomDouble() < 0.40) { _target.RevealingAction(); }