fix: Fixes random bias & Adds back champion arties for UOML (#1235)

* Fixes RNG bias, we should never do `Utility.RandomDouble() <=`
* Adds back champion artifacts behind UOML flag.
This commit is contained in:
Kamron Batman 2022-11-09 16:33:27 -08:00 • committed by GitHub
parent 810061db8c
commit 8e01db8555
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 289 additions and 335 deletions

View file

@ -502,8 +502,10 @@ namespace Server.Engines.CannedEvil
{ {
RegisterDamageTo(Champion); RegisterDamageTo(Champion);
//if (m_Champion is BaseChampion) if (Core.ML)
// AwardArtifact(((BaseChampion)m_Champion).GetArtifact()); {
AwardArtifact((Champion as BaseChampion)?.GetArtifact());
}
DamageEntries.Clear(); DamageEntries.Clear();
@ -560,31 +562,22 @@ namespace Server.Engines.CannedEvil
{ {
if (Map == Map.Felucca) 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); GiveScrollOfTranscendenceFelTo(pm, CreateRandomFelSoT());
}
if (random <= 24) else if (random == 1)
{ {
ScrollofTranscendence SoTF = CreateRandomFelSoT(); GivePowerScrollFelTo(pm, CreateRandomFelPS());
GiveScrollOfTranscendenceFelTo (pm, SoTF);
}
else
{
PowerScroll PS = CreateRandomFelPS();
GivePowerScrollFelTo (pm, PS);
}
} }
} }
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!
{ pm.AddToBackpack(CreateRandomTramSoT());
pm.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence!
ScrollofTranscendence SoTT = CreateRandomTramSoT();
pm.AddToBackpack(SoTT);
}
} }
} }

View file

@ -115,7 +115,7 @@ namespace Server.Engines.Harvest
if (obj?.Completed == false) 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. // You pull a shellfish out of the water, and find a rainbow pearl inside of it.
player.SendLocalizedMessage(1055086, "", 0x59); player.SendLocalizedMessage(1055086, "", 0x59);

View file

@ -61,7 +61,7 @@ namespace Server.Engines.MLQuests.Items
{ {
AddBaseLoot(Loot.MLArmorTypes, Loot.JewelryTypes, m_TalismanType); AddBaseLoot(Loot.MLArmorTypes, Loot.JewelryTypes, m_TalismanType);
if (Utility.RandomDouble() < 0.50) if (Utility.RandomBool())
{ {
AddRecipe(DefTailoring.CraftSystem); AddRecipe(DefTailoring.CraftSystem);
} }
@ -94,7 +94,7 @@ namespace Server.Engines.MLQuests.Items
{ {
AddBaseLoot(Loot.MLWeaponTypes, Loot.JewelryTypes, m_TalismanType); AddBaseLoot(Loot.MLWeaponTypes, Loot.JewelryTypes, m_TalismanType);
if (Utility.RandomDouble() < 0.50) if (Utility.RandomBool())
{ {
AddRecipe(DefBlacksmithy.CraftSystem); AddRecipe(DefBlacksmithy.CraftSystem);
} }
@ -127,7 +127,7 @@ namespace Server.Engines.MLQuests.Items
{ {
AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType);
if (Utility.RandomDouble() < 0.50) if (Utility.RandomBool())
{ {
switch (Utility.Random(6)) switch (Utility.Random(6))
{ {
@ -173,7 +173,7 @@ namespace Server.Engines.MLQuests.Items
{ {
AddBaseLoot(Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); AddBaseLoot(Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType);
if (Utility.RandomDouble() < 0.50) if (Utility.RandomBool())
{ {
AddRecipe(DefBowFletching.CraftSystem); AddRecipe(DefBowFletching.CraftSystem);
} }
@ -208,7 +208,7 @@ namespace Server.Engines.MLQuests.Items
{ {
AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType);
if (Utility.RandomDouble() < 0.50) if (Utility.RandomBool())
{ {
AddRecipe(DefCarpentry.CraftSystem); AddRecipe(DefCarpentry.CraftSystem);
} }

View file

@ -185,7 +185,7 @@ namespace Server.Engines.Events
return; return;
} }
if (Utility.RandomDouble() > .10) if (Utility.RandomDouble() < 0.90)
{ {
begged.Say( begged.Say(
Utility.Random(3) switch 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); from.AddToBackpack(HolidaySettings.RandomGMBeggerItem);

View file

@ -19,7 +19,7 @@ namespace Server.Items
public HalloweenPumpkin() public HalloweenPumpkin()
{ {
Weight = Utility.RandomMinMax(3, 20); Weight = Utility.RandomMinMax(3, 20);
ItemID = Utility.RandomDouble() <= .02 ItemID = Utility.RandomDouble() < 0.02
? Utility.RandomList(0x4694, 0x4698) ? Utility.RandomList(0x4694, 0x4698)
: Utility.RandomList(0xc6a, 0xc6b, 0xc6c); : Utility.RandomList(0xc6a, 0xc6b, 0xc6c);
} }

View file

@ -656,7 +656,7 @@ namespace Server.Items
{ {
fish.Hue = FishHues.RandomElement(); fish.Hue = FishHues.RandomElement();
} }
else if (Utility.RandomDouble() < 0.5) else if (Utility.RandomBool())
{ {
fish.Hue = Utility.RandomMinMax(0x100, 0x3E5); fish.Hue = Utility.RandomMinMax(0x100, 0x3E5);
} }

View file

@ -7,7 +7,7 @@ namespace Server.Items
public partial class Futon : Item public partial class Futon : Item
{ {
[Constructible] [Constructible]
public Futon() : base(Utility.RandomDouble() > 0.5 ? 0x295C : 0x295E) public Futon() : base(Utility.RandomBool() ? 0x295C : 0x295E)
{ {
} }

View file

@ -369,7 +369,7 @@ public partial class TreasureMapChest : LockableContainer
_lifted ??= new HashSet<Item>(); _lifted ??= new HashSet<Item>();
_lifted.Add(item); _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); TreasureMap.Spawn(_level, GetWorldLocation(), Map, from, false);
} }

View file

@ -76,7 +76,7 @@ namespace Server.Items
.Random(3) .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!" ); // "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)) Core.TickCount - from.LastMoveTime < from.ComputeMovementSpeed(from.Direction))
{ {
// Didn't your parents ever tell you not to run with scissors in your hand?! // Didn't your parents ever tell you not to run with scissors in your hand?!

View file

@ -1059,7 +1059,7 @@ namespace Server.Items
public static TalismanAttribute GetRandomSummoner() public static TalismanAttribute GetRandomSummoner()
{ {
if (Utility.RandomDouble() >= 0.025) if (Utility.RandomDouble() < 0.975)
{ {
return new TalismanAttribute(); return new TalismanAttribute();
} }
@ -1141,7 +1141,7 @@ namespace Server.Items
? (TalismanSlayerName)Utility.RandomMinMax(1, 9) ? (TalismanSlayerName)Utility.RandomMinMax(1, 9)
: TalismanSlayerName.None; : 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] [Flags]
private enum SaveFlag private enum SaveFlag

View file

@ -47,7 +47,7 @@ public class Dismount : WeaponAbility
return; 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 return; // Lesser Hiryu have an 80% chance of missing this attack
} }

View file

@ -32,7 +32,7 @@ namespace Server.Items
{ {
--PoisonCharges; --PoisonCharges;
if (Utility.RandomDouble() >= 0.5) // 50% chance to poison if (Utility.RandomBool()) // 50% chance to poison
{ {
defender.ApplyPoison(attacker, Poison); defender.ApplyPoison(attacker, Poison);
} }

View file

@ -47,72 +47,85 @@ namespace Server.Items
{ {
from.SendMessage("You must be holding that weapon to use it."); 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); case Direction.North:
{
AOS.Damage(m, from, Utility.Random(5, from.Str / 10), 100, 0, 0, 0, 0); --y;
break;
m_Dagger.MoveToWorld(m.Location, m.Map); }
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) x += Utility.Random(-1, 3);
{ y += Utility.Random(-1, 3);
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); x += m.X;
y += Utility.Random(-1, 3); y += m.Y;
x += m.X; m_Dagger.MoveToWorld(new Point3D(x, y, m.Z), m.Map);
y += m.Y;
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.");
}
} }
} }
} }

View file

@ -94,7 +94,7 @@ namespace Server.Items
public override void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1) public override void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1)
{ {
if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) &&
Utility.RandomDouble() <= 0.4) Utility.RandomDouble() < 0.4)
{ {
defender.AddToBackpack(Ammo); defender.AddToBackpack(Ammo);
} }
@ -124,7 +124,7 @@ namespace Server.Items
public override void OnMiss(Mobile attacker, Mobile defender) 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) if (Core.SE)
{ {

View file

@ -37,7 +37,7 @@ namespace Server.Items
{ {
--PoisonCharges; --PoisonCharges;
if (Utility.RandomDouble() >= 0.5) // 50% chance to poison if (Utility.RandomBool()) // 50% chance to poison
{ {
defender.ApplyPoison(attacker, Poison); defender.ApplyPoison(attacker, Poison);
} }

View file

@ -29,7 +29,7 @@ namespace Server.Items
{ {
--PoisonCharges; --PoisonCharges;
if (Utility.RandomDouble() >= 0.5) // 50% chance to poison if (Utility.RandomBool()) // 50% chance to poison
{ {
defender.ApplyPoison(attacker, Poison); defender.ApplyPoison(attacker, Poison);
} }

View file

@ -159,7 +159,7 @@ namespace Server
AOS.Damage(m_Mobile, From, damage, 0, 0, 0, 100, 0); AOS.Damage(m_Mobile, From, damage, 0, 0, 0, 100, 0);
// OSI: randomly revealed between first and third damage tick, guessing 60% chance // 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(); m_Mobile.RevealingAction();
} }

View file

@ -2248,7 +2248,7 @@ public abstract class BaseAI
if (blocked) 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) for (var i = 0; i < 2; ++i)
{ {

View file

@ -8,7 +8,7 @@ namespace Server.Mobiles
Body = Utility.RandomList(0xE8, 0xE9); Body = Utility.RandomList(0xE8, 0xE9);
BaseSoundID = 0x64; BaseSoundID = 0x64;
if (Utility.RandomDouble() <= 0.5) if (Utility.RandomBool())
{ {
Hue = 0x901; Hue = 0x901;
} }

View file

@ -103,7 +103,7 @@ public class LesserHiryu : BaseMount
{ {
var tamingChance = base.GetControlChance(m, useBaseSkill); var tamingChance = base.GetControlChance(m, useBaseSkill);
if (tamingChance >= 0.95) if (tamingChance < 0.05)
{ {
return tamingChance; return tamingChance;
} }

View file

@ -52,7 +52,7 @@ namespace Server.Mobiles
public override string DefaultName => "a giant snake"; public override string DefaultName => "a giant snake";
public override Poison PoisonImmune => Poison.Greater; 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; public override bool DeathAdderCharmable => true;

View file

@ -2995,7 +2995,7 @@ namespace Server.Mobiles
{ {
PackItem(new ParagonChest(Name, treasureLevel)); 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)); PackItem(new TreasureMap(treasureLevel, Map));
} }
@ -4222,7 +4222,7 @@ namespace Server.Mobiles
{ {
for (var i = 0; i < amount; ++i) for (var i = 0; i < amount; ++i)
{ {
if (m_Loyalty < MaxLoyalty && Utility.RandomDouble() <= 0.5) if (m_Loyalty < MaxLoyalty && Utility.RandomBool())
{ {
m_Loyalty += 10; m_Loyalty += 10;
} }
@ -4799,7 +4799,7 @@ namespace Server.Mobiles
public void PackNecroScroll(int index) public void PackNecroScroll(int index)
{ {
if (!Core.AOS || Utility.RandomDouble() >= 0.05) if (!Core.AOS || Utility.RandomDouble() < 0.95)
{ {
return; return;
} }

View file

@ -37,7 +37,7 @@ namespace Server.Mobiles
public override string CorpseName => "a death adder corpse"; public override string CorpseName => "a death adder corpse";
public override string DefaultName => "a death adder"; 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) public override void Serialize(IGenericWriter writer)
{ {

View file

@ -51,7 +51,7 @@ namespace Server.Mobiles
{ {
base.OnDeath(c); base.OnDeath(c);
if (Utility.RandomDouble() < 0.5) if (Utility.RandomBool())
{ {
c.DropItem(new FragmentOfAMap()); c.DropItem(new FragmentOfAMap());
} }

View file

@ -191,18 +191,12 @@ namespace Server.Mobiles
} }
var luck = LootPack.GetLuckChanceForKiller(boss); var luck = LootPack.GetLuckChanceForKiller(boss);
int chance;
if (boss is DemonKnight) return boss switch
{ {
chance = 1500 + luck / 5; DemonKnight => 1500 + luck / 5,
} _ => 750 + luck / 10
else };
{
chance = 750 + luck / 10;
}
return chance;
} }
public static bool CheckArtifactChance(Mobile boss) => GetArtifactChance(boss) > Utility.Random(100000); public static bool CheckArtifactChance(Mobile boss) => GetArtifactChance(boss) > Utility.Random(100000);

View file

@ -53,7 +53,7 @@ namespace Server.Mobiles
public override bool Unprovokable => Core.SE; public override bool Unprovokable => Core.SE;
public override bool AreaPeaceImmune => Core.SE; public override bool AreaPeaceImmune => Core.SE;
public override Poison PoisonImmune => Poison.Lethal; 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; public override int TreasureMapLevel => 1;

View file

@ -40,7 +40,7 @@ namespace Server.Mobiles
SolenHelper.PackPicnicBasket(this); 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) if (Utility.RandomDouble() < 0.05)
{ {

View file

@ -38,7 +38,7 @@ namespace Server.Mobiles
SolenHelper.PackPicnicBasket(this); 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) public RedSolenInfiltratorQueen(Serial serial) : base(serial)

View file

@ -38,7 +38,7 @@ namespace Server.Mobiles
SolenHelper.PackPicnicBasket(this); 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) public RedSolenInfiltratorWarrior(Serial serial) : base(serial)

View file

@ -39,7 +39,7 @@ namespace Server.Mobiles
SolenHelper.PackPicnicBasket(this); 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) if (Utility.RandomDouble() < 0.05)
{ {

View file

@ -38,7 +38,7 @@ namespace Server.Mobiles
VirtualArmor = 35; VirtualArmor = 35;
SolenHelper.PackPicnicBasket(this); 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) if (Utility.RandomDouble() < 0.05)
{ {

View file

@ -105,7 +105,7 @@ namespace Server.Mobiles
m_Thrown++; 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); m_NextBomb = Core.Now + TimeSpan.FromSeconds(3.0);
} }

View file

@ -52,7 +52,7 @@ namespace Server.Mobiles
AddItem(new BoneArms()); AddItem(new BoneArms());
AddItem(new BoneLegs()); AddItem(new BoneLegs());
if (Utility.RandomDouble() < 0.5) if (Utility.RandomBool())
{ {
AddItem(new SavageMask()); AddItem(new SavageMask());
} }

View file

@ -75,7 +75,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() > 0.2) if (Utility.RandomDouble() < 0.80)
{ {
return; return;
} }

View file

@ -73,7 +73,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.1) if (Utility.RandomDouble() < 0.9)
{ {
return; return;
} }

View file

@ -94,7 +94,7 @@ namespace Server.Mobiles
public void AreaPeace() 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; return;
} }
@ -122,7 +122,7 @@ namespace Server.Mobiles
public void AreaUndress() 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; return;
} }

View file

@ -90,7 +90,7 @@ namespace Server.Mobiles
public void Peace(Mobile target) 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; return;
} }
@ -111,7 +111,7 @@ namespace Server.Mobiles
public void Suppress(Mobile target) public void Suppress(Mobile target)
{ {
if (target == null || m_Suppressed.ContainsKey(target) || Deleted || !Alive || 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; return;
} }
@ -160,7 +160,7 @@ namespace Server.Mobiles
public void Undress(Mobile target) 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; return;
} }
@ -193,7 +193,7 @@ namespace Server.Mobiles
public void Provoke(Mobile target) 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; return;
} }

View file

@ -167,7 +167,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() <= 0.2) if (Utility.RandomDouble() < 0.2)
{ {
Earthquake(); Earthquake();
} }

View file

@ -103,7 +103,7 @@ namespace Server.Mobiles
public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) public override void AlterDamageScalarFrom(Mobile caster, ref double scalar)
{ {
if (Utility.RandomDouble() <= 0.1) if (Utility.RandomDouble() < 0.1)
{ {
SpawnPixies(caster); SpawnPixies(caster);
} }
@ -122,7 +122,7 @@ namespace Server.Mobiles
{ {
base.OnGotMeleeAttack(attacker, damage); base.OnGotMeleeAttack(attacker, damage);
if (Utility.RandomDouble() <= 0.1) if (Utility.RandomDouble() < 0.1)
{ {
SpawnPixies(attacker); SpawnPixies(attacker);
} }

View file

@ -100,7 +100,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.1) if (Utility.RandomDouble() < 0.9)
{ {
return; return;
} }

View file

@ -122,16 +122,16 @@ namespace Server.Mobiles
{ {
base.OnGotMeleeAttack(attacker, damage); base.OnGotMeleeAttack(attacker, damage);
if (Hits > HitsMax / 4) if (Utility.RandomDouble() < 0.25)
{ {
if (Utility.RandomDouble() <= 0.25) if (Hits > HitsMax / 4)
{ {
SpawnBogling(attacker); SpawnBogling(attacker);
} }
} else
else if (Utility.RandomDouble() <= 0.25) {
{ EatBoglings();
EatBoglings(); }
} }
} }
} }

View file

@ -40,7 +40,7 @@ namespace Server.Mobiles
PackReg(3); PackReg(3);
PackItem(new FertileDirt(Utility.RandomMinMax(1, 10))); PackItem(new FertileDirt(Utility.RandomMinMax(1, 10)));
if (Utility.RandomDouble() <= 0.2) if (Utility.RandomDouble() < 0.2)
{ {
PackItem(new ExecutionersCap()); PackItem(new ExecutionersCap());
} }

View file

@ -56,7 +56,7 @@ namespace Server.Mobiles
public override FoodType FavoriteFood => FoodType.Meat; public override FoodType FavoriteFood => FoodType.Meat;
public override PackInstinct PackInstinct => PackInstinct.Arachnid; public override PackInstinct PackInstinct => PackInstinct.Arachnid;
public override Poison PoisonImmune => Poison.Greater; 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() public override void GenerateLoot()
{ {

View file

@ -93,7 +93,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.1) if (Utility.RandomDouble() < 0.9)
{ {
return; return;
} }

View file

@ -49,7 +49,7 @@ namespace Server.Mobiles
AddItem(new Tessen()); AddItem(new Tessen());
if (Utility.RandomDouble() <= 0.02) if (Utility.RandomDouble() < 0.02)
{ {
PackItem(new OrigamiPaper()); PackItem(new OrigamiPaper());
} }

View file

@ -77,7 +77,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.1) if (Utility.RandomDouble() < 0.9)
{ {
return; return;
} }

View file

@ -60,7 +60,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.1 || m_Table.Contains(defender)) if (Utility.RandomDouble() < 0.9 || m_Table.Contains(defender))
{ {
return; return;
} }

View file

@ -75,7 +75,7 @@ namespace Server.Mobiles
break; break;
} }
if (Utility.RandomDouble() > .2) if (Utility.RandomDouble() < 0.80)
{ {
AddItem(new NoDachi()); AddItem(new NoDachi());
} }

View file

@ -99,7 +99,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.05) if (Utility.RandomDouble() < 0.95)
{ {
return; return;
} }

View file

@ -82,7 +82,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() >= 0.1) if (Utility.RandomDouble() < 0.9)
{ {
return; return;
} }

View file

@ -185,12 +185,12 @@ namespace Server.Mobiles
return; 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); 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); SpawnRatmen(target);
} }

View file

@ -41,26 +41,14 @@ namespace Server.Mobiles
var version = reader.ReadInt(); var version = reader.ReadInt();
} }
public Item GetArtifact() public Item GetArtifact() =>
{ Utility.RandomDouble() switch
var random = Utility.RandomDouble();
if (random <= 0.05)
{ {
return CreateArtifact(UniqueList); < 0.05 => CreateArtifact(UniqueList),
} < 0.15 => CreateArtifact(SharedList),
< 0.30 => CreateArtifact(DecorativeList),
if (random <= 0.15) _ => null
{ };
return CreateArtifact(SharedList);
}
if (random <= 0.30)
{
return CreateArtifact(DecorativeList);
}
return null;
}
public Item CreateArtifact(Type[] list) public Item CreateArtifact(Type[] list)
{ {
@ -82,23 +70,14 @@ namespace Server.Mobiles
return artifact; return artifact;
} }
private PowerScroll CreateRandomPowerScroll() private static PowerScroll CreateRandomPowerScroll()
{ {
int level; var level = Utility.RandomDouble() switch
var random = Utility.RandomDouble();
if (random <= 0.05)
{ {
level = 20; < 0.05 => 20,
} < 0.4 => 15,
else if (random <= 0.4) _ => 10
{ };
level = 15;
}
else
{
level = 10;
}
return PowerScroll.CreateRandomNoCraft(level, level); return PowerScroll.CreateRandomNoCraft(level, level);
} }
@ -226,16 +205,13 @@ namespace Server.Mobiles
{ {
prot.AddToBackpack(powerScroll); prot.AddToBackpack(powerScroll);
} }
else if (prot.Corpse?.Deleted == false)
{
prot.Corpse.DropItem(powerScroll);
}
else else
{ {
if (prot.Corpse?.Deleted == false) prot.AddToBackpack(powerScroll);
{
prot.Corpse.DropItem(powerScroll);
}
else
{
prot.AddToBackpack(powerScroll);
}
} }
} }
} }
@ -342,49 +318,51 @@ namespace Server.Mobiles
g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); 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)) return;
{ }
case 0: // Fire column
{
Effects.SendLocationParticles(
EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x3709,
10,
30,
5052
);
Effects.PlaySound(g, 0x208);
break; switch (Utility.Random(3))
} {
case 1: // Explosion case 0: // Fire column
{ {
Effects.SendLocationParticles( Effects.SendLocationParticles(
EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36BD, 0x3709,
20, 10,
10, 30,
5044 5052
); );
Effects.PlaySound(g, 0x307); Effects.PlaySound(g, 0x208);
break; break;
} }
case 2: // Ball of fire case 1: // Explosion
{ {
Effects.SendLocationParticles( Effects.SendLocationParticles(
EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36FE, 0x36BD,
10, 20,
10, 10,
5052 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;
}
} }
} }
} }

View file

@ -88,9 +88,9 @@ namespace Server.Mobiles
Instances.Add(this); Instances.Add(this);
} }
public Type[] UniqueList => new[] { typeof(AcidProofRobe) }; public static Type[] UniqueList => new[] { typeof(AcidProofRobe) };
public Type[] SharedList => new[] { typeof(TheRobeOfBritanniaAri) }; public static Type[] SharedList => new[] { typeof(TheRobeOfBritanniaAri) };
public Type[] DecorativeList => new[] { typeof(EvilIdolSkull), typeof(SkullPole) }; public static Type[] DecorativeList => new[] { typeof(EvilIdolSkull), typeof(SkullPole) };
public static List<Harrower> Instances { get; } = new(); public static List<Harrower> Instances { get; } = new();
@ -269,29 +269,14 @@ namespace Server.Mobiles
for (var i = 0; i < 16; ++i) for (var i = 0; i < 16; ++i)
{ {
int level; var level = Utility.RandomDouble() switch
var random = Utility.RandomDouble();
if (random <= 0.1)
{ {
level = 25; < 0.1 => 25,
} < 0.25 => 20,
else if (random <= 0.25) < 0.45 => 15,
{ < 0.70 => 10,
level = 20; _ => 5
} };
else if (random <= 0.45)
{
level = 15;
}
else if (random <= 0.70)
{
level = 10;
}
else
{
level = 5;
}
var m = toGive[i % toGive.Count]; var m = toGive[i % toGive.Count];
@ -482,9 +467,8 @@ namespace Server.Mobiles
} }
else else
{ {
to.SendLocalizedMessage( // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
1062317 to.SendLocalizedMessage(1062317);
); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
} }
} }
@ -492,26 +476,14 @@ namespace Server.Mobiles
m.Player && m.Alive && m.InRange(Location, 32) && m.Player && m.Alive && m.InRange(Location, 32) &&
m.Backpack?.CheckHold(m, artifact, false) == true; m.Backpack?.CheckHold(m, artifact, false) == true;
public Item GetArtifact() public Item GetArtifact() =>
{ Utility.RandomDouble() switch
var random = Utility.RandomDouble();
if (random <= 0.05)
{ {
return CreateArtifact(UniqueList); < 0.05 => CreateArtifact(UniqueList),
} < 0.15 => CreateArtifact(SharedList),
< 0.30 => CreateArtifact(DecorativeList),
if (random <= 0.15) _ => null
{ };
return CreateArtifact(SharedList);
}
if (random <= 0.30)
{
return CreateArtifact(DecorativeList);
}
return null;
}
public Item CreateArtifact(Type[] list) => Loot.Construct(list.RandomElement()); public Item CreateArtifact(Type[] list) => Loot.Construct(list.RandomElement());
@ -564,7 +536,7 @@ namespace Server.Mobiles
return; return;
} }
if (Utility.RandomDouble() > 0.25) if (Utility.RandomDouble() < 0.75)
{ {
return; return;
} }
@ -678,49 +650,51 @@ namespace Server.Mobiles
g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); 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)) return;
{ }
case 0: // Fire column
{
Effects.SendLocationParticles(
EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x3709,
10,
30,
5052
);
Effects.PlaySound(g, 0x208);
break; switch (Utility.Random(3))
} {
case 1: // Explosion case 0: // Fire column
{ {
Effects.SendLocationParticles( Effects.SendLocationParticles(
EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36BD, 0x3709,
20, 10,
10, 30,
5044 5052
); );
Effects.PlaySound(g, 0x307); Effects.PlaySound(g, 0x208);
break; break;
} }
case 2: // Ball of fire case 1: // Explosion
{ {
Effects.SendLocationParticles( Effects.SendLocationParticles(
EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36FE, 0x36BD,
10, 20,
10, 10,
5052 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;
}
} }
} }
} }

View file

@ -151,7 +151,7 @@ namespace Server.Mobiles
{ {
scalar *= 0.1; scalar *= 0.1;
if (Utility.RandomDouble() <= 0.1) if (Utility.RandomDouble() < 0.1)
{ {
SpawnPixies(caster); SpawnPixies(caster);
} }
@ -173,7 +173,7 @@ namespace Server.Mobiles
CheckQueen(); CheckQueen();
if (m_Queen != null && Utility.RandomDouble() <= 0.1) if (m_Queen != null && Utility.RandomDouble() < 0.1)
{ {
SpawnPixies(attacker); SpawnPixies(attacker);
} }

View file

@ -144,7 +144,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); 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); AddUnholyBone(defender, 0.25);
} }
@ -156,7 +156,7 @@ namespace Server.Mobiles
{ {
base.OnGotMeleeAttack(attacker, damage); 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); AddUnholyBone(attacker, 0.25);
} }
@ -166,7 +166,7 @@ namespace Server.Mobiles
{ {
base.AlterDamageScalarFrom(caster, ref scalar); 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); AddUnholyBone(caster, 1.0);
} }

View file

@ -83,7 +83,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender, damage); base.OnGaveMeleeAttack(defender, damage);
if (Utility.RandomDouble() <= 0.2) if (Utility.RandomDouble() < 0.2)
{ {
Earthquake(); Earthquake();
} }

View file

@ -78,7 +78,7 @@ namespace Server.Mobiles
public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) public override void AlterDamageScalarFrom(Mobile caster, ref double scalar)
{ {
if (Utility.RandomDouble() <= 0.1) if (Utility.RandomDouble() < 0.1)
{ {
SpawnPixies(caster); SpawnPixies(caster);
} }
@ -97,7 +97,7 @@ namespace Server.Mobiles
{ {
base.OnGotMeleeAttack(attacker, damage); base.OnGotMeleeAttack(attacker, damage);
if (Utility.RandomDouble() <= 0.1) if (Utility.RandomDouble() < 0.1)
{ {
SpawnPixies(attacker); SpawnPixies(attacker);
} }

View file

@ -206,7 +206,7 @@ namespace Server.SkillHandlers
// Someone else is already taming this. // Someone else is already taming this.
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802, from.NetState); 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! // You seem to anger the beast!
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805, from.NetState); creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805, from.NetState);
@ -214,7 +214,7 @@ namespace Server.SkillHandlers
creature.PlaySound(creature.GetAngerSound()); creature.PlaySound(creature.GetAngerSound());
creature.Direction = creature.GetDirectionTo(from); 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)); Timer.StartTimer(TimeSpan.FromSeconds(2.0), () => Pacify(creature));
} }

View file

@ -161,7 +161,9 @@ namespace Server.SkillHandlers
{ {
Caster.CheckSkill(SkillName.SpiritSpeak, 0.0, 120.0); 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. Caster.SendLocalizedMessage(502443); // You fail your attempt at contacting the netherworld.
} }

View file

@ -219,7 +219,7 @@ namespace Server.Spells.Necromancy
AOS.Damage(_target, _from, (int)damage, 0, 0, 0, 100, 0); AOS.Damage(_target, _from, (int)damage, 0, 0, 0, 100, 0);
// OSI: randomly revealed between first and third damage tick, guessing 60% chance // OSI: randomly revealed between first and third damage tick, guessing 60% chance
if (Utility.RandomDouble() >= 0.60) if (Utility.RandomDouble() < 0.40)
{ {
_target.RevealingAction(); _target.RevealingAction();
} }