Creates random element extension (#196)
This commit is contained in:
parent
0926b5abaa
commit
4403d6c1c7
84 changed files with 226 additions and 330 deletions
|
|
@ -538,11 +538,9 @@ namespace Server.Items
|
|||
|
||||
while (amount > 0 && toKill.Count > 0)
|
||||
{
|
||||
int kill = Utility.Random(toKill.Count);
|
||||
|
||||
toKill[kill].Kill();
|
||||
|
||||
toKill.RemoveAt(kill);
|
||||
var kill = toKill.RandomElement();
|
||||
kill.Kill();
|
||||
toKill.Remove(kill);
|
||||
|
||||
amount -= 1;
|
||||
LiveCreatures = Math.Max(LiveCreatures - 1, 0);
|
||||
|
|
@ -639,7 +637,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
if (Utility.RandomDouble() < 0.05)
|
||||
fish.Hue = FishHues[Utility.Random(FishHues.Length)];
|
||||
fish.Hue = FishHues.RandomElement();
|
||||
else if (Utility.RandomDouble() < 0.5)
|
||||
fish.Hue = Utility.RandomMinMax(0x100, 0x3E5);
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
if (level == 6 && Core.AOS)
|
||||
cont.DropItem((Item)ActivatorUtil.CreateInstance(Artifacts[Utility.Random(Artifacts.Length)]));
|
||||
cont.DropItem((Item)ActivatorUtil.CreateInstance(Artifacts.RandomElement()));
|
||||
}
|
||||
|
||||
public override bool CheckLocked(Mobile from)
|
||||
|
|
|
|||
|
|
@ -22,11 +22,10 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
public MahjongTileType Next()
|
||||
{
|
||||
int random = Utility.Random(LeftTileTypes.Count);
|
||||
MahjongTileType next = LeftTileTypes[random];
|
||||
LeftTileTypes.RemoveAt(random);
|
||||
MahjongTileType next = LeftTileTypes.RandomElement();
|
||||
LeftTileTypes.Remove(next);
|
||||
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,10 +163,7 @@ namespace Server.Items
|
|||
if (m_Locations == null)
|
||||
LoadLocations();
|
||||
|
||||
if (m_Locations.Length > 0)
|
||||
return m_Locations[Utility.Random(m_Locations.Length)];
|
||||
|
||||
return Point2D.Zero;
|
||||
return m_Locations?.RandomElement() ?? Point2D.Zero;
|
||||
}
|
||||
|
||||
public static Point2D GetRandomHavenLocation()
|
||||
|
|
@ -174,10 +171,7 @@ namespace Server.Items
|
|||
if (m_HavenLocations == null)
|
||||
LoadLocations();
|
||||
|
||||
if (m_HavenLocations.Length > 0)
|
||||
return m_HavenLocations[Utility.Random(m_HavenLocations.Length)];
|
||||
|
||||
return Point2D.Zero;
|
||||
return m_HavenLocations?.RandomElement() ?? Point2D.Zero;
|
||||
}
|
||||
|
||||
private static void LoadLocations()
|
||||
|
|
@ -225,8 +219,7 @@ namespace Server.Items
|
|||
|
||||
try
|
||||
{
|
||||
bc = (BaseCreature)ActivatorUtil.CreateInstance(
|
||||
m_SpawnTypes[level][Utility.Random(m_SpawnTypes[level].Length)]);
|
||||
bc = (BaseCreature)ActivatorUtil.CreateInstance(m_SpawnTypes[level].RandomElement());
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ namespace Server.Items
|
|||
{
|
||||
Map map = Map;
|
||||
BaseCreature bc =
|
||||
(BaseCreature)ActivatorUtil.CreateInstance(Creatures[Utility.Random(Creatures.Length)]);
|
||||
(BaseCreature)ActivatorUtil.CreateInstance(Creatures.RandomElement());
|
||||
|
||||
Point3D spawnLoc = GetSpawnPosition();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Server.Items
|
|||
{
|
||||
if (m_TurnedOn && IsLockedDown && (!m.Hidden || m.AccessLevel == AccessLevel.Player) &&
|
||||
Utility.InRange(m.Location, Location, 2) && !Utility.InRange(oldLocation, Location, 2))
|
||||
Effects.PlaySound(Location, Map, Sounds[Utility.Random(Sounds.Length)]);
|
||||
Effects.PlaySound(Location, Map, Sounds.RandomElement());
|
||||
|
||||
base.OnMovement(m, oldLocation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,8 +82,7 @@ namespace Server.Items
|
|||
if (list.Count == 0)
|
||||
return Point3D.Zero;
|
||||
|
||||
int idx = Utility.Random(list.Count);
|
||||
return list[idx];
|
||||
return list.RandomElement();
|
||||
}
|
||||
|
||||
private void AddOffsetLocation(Mobile from, int offsetX, int offsetY, List<Point3D> list)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ namespace Server.Items
|
|||
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
Rectangle2D reg = regions[Utility.Random(regions.Length)];
|
||||
Rectangle2D reg = regions.RandomElement();
|
||||
int x = Utility.Random(reg.X, reg.Width);
|
||||
int y = Utility.Random(reg.Y, reg.Height);
|
||||
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ namespace Server.Items
|
|||
maxIntensity = 15;
|
||||
}
|
||||
|
||||
int propertyCount = propertyCounts[Utility.Random(propertyCounts.Length)];
|
||||
int propertyCount = propertyCounts.RandomElement();
|
||||
|
||||
BaseRunicTool.ApplyAttributesTo(this, true, 0, propertyCount, minIntensity, maxIntensity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -439,8 +439,8 @@ namespace Server.Items
|
|||
if (randomizeOrder)
|
||||
for (int i = 0; i < attrs.Length; i++)
|
||||
{
|
||||
int rand = Utility.Random(attrs.Length);
|
||||
AosElementAttribute temp = attrs[i];
|
||||
int rand = Utility.Random(attrs.Length);
|
||||
|
||||
attrs[i] = attrs[rand];
|
||||
attrs[rand] = temp;
|
||||
|
|
@ -501,7 +501,7 @@ namespace Server.Items
|
|||
if (entries.Length == 0)
|
||||
return SlayerName.None;
|
||||
|
||||
entry = entries[Utility.Random(entries.Length)];
|
||||
entry = entries.RandomElement();
|
||||
}
|
||||
|
||||
return entry.Name;
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ namespace Server.Items
|
|||
_ => m_CommonTracks
|
||||
};
|
||||
|
||||
return list[Utility.Random(list.Length)];
|
||||
return list.RandomElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
[Constructible]
|
||||
public HolidayBell()
|
||||
: this(m_StaffNames[Utility.Random(m_StaffNames.Length)])
|
||||
: this(m_StaffNames.RandomElement())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
m_Maker = maker;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
Hue = m_Hues[Utility.Random(m_Hues.Length)];
|
||||
Hue = m_Hues.RandomElement();
|
||||
SoundID = 0x0F5 + Utility.Random(14);
|
||||
}
|
||||
|
||||
|
|
@ -108,4 +108,4 @@
|
|||
Utility.Intern(ref m_Maker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ namespace Server.Items
|
|||
|
||||
public override bool Eat(Mobile from)
|
||||
{
|
||||
int message = m_Messages[Utility.Random(m_Messages.Length)];
|
||||
int message = m_Messages.RandomElement();
|
||||
|
||||
if (message != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@
|
|||
0x448
|
||||
};
|
||||
|
||||
public static int RandomGiftBoxHue => m_NormalHues[Utility.Random(m_NormalHues.Length)];
|
||||
public static int RandomNeonBoxHue => m_NeonHues[Utility.Random(m_NeonHues.Length)];
|
||||
public static int RandomGiftBoxHue => m_NormalHues.RandomElement();
|
||||
public static int RandomNeonBoxHue => m_NeonHues.RandomElement();
|
||||
}
|
||||
|
||||
[Flippable(0x46A5, 0x46A6)]
|
||||
|
|
@ -205,4 +205,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,12 @@ namespace Server.Items
|
|||
|
||||
public class BadCard : Item
|
||||
{
|
||||
private static readonly int[] m_CardHues = { 0x45, 0x27, 0x3d0 };
|
||||
|
||||
[Constructible]
|
||||
public BadCard() : base(0x14ef)
|
||||
{
|
||||
int[] m_CardHues = { 0x45, 0x27, 0x3d0 };
|
||||
Hue = m_CardHues[Utility.Random(m_CardHues.Length)];
|
||||
Hue = m_CardHues.RandomElement();
|
||||
Stackable = false;
|
||||
LootType = LootType.Blessed;
|
||||
Movable = true;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
[Constructible]
|
||||
public SnowPileDeco()
|
||||
: this(m_Types[Utility.Random(m_Types.Length)])
|
||||
: this(m_Types.RandomElement())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -37,4 +37,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,71 +55,65 @@ namespace Server.Items
|
|||
return true;
|
||||
}
|
||||
|
||||
public static string GetRandomTitle()
|
||||
// All hail OSI staff
|
||||
private static readonly string[] titles =
|
||||
{
|
||||
// All hail OSI staff
|
||||
string[] titles =
|
||||
{
|
||||
/* 1 */ "Backflash",
|
||||
/* 2 */ "Carbon",
|
||||
/* 3 */ "Colbalistic",
|
||||
/* 4 */ "Comforl",
|
||||
/* 5 */ "Coppacchia",
|
||||
/* 6 */ "Cyrus",
|
||||
/* 7 */ "DannyB",
|
||||
/* 8 */ "DJSoul",
|
||||
/* 9 */ "DraconisRex",
|
||||
/* 10 */ "Earia",
|
||||
/* 11 */ "Foster",
|
||||
/* 12 */ "Gonzo",
|
||||
/* 13 */ "Haan",
|
||||
/* 14 */ "Halona",
|
||||
/* 15 */ "Hugo",
|
||||
/* 16 */ "Hyacinth",
|
||||
/* 17 */ "Imirian",
|
||||
/* 18 */ "Jinsol",
|
||||
/* 19 */ "Liciatia",
|
||||
/* 20 */ "Loewen",
|
||||
/* 21 */ "Loke",
|
||||
/* 22 */ "Magnus",
|
||||
/* 23 */ "Maleki",
|
||||
/* 24 */ "Morpheus",
|
||||
/* 25 */ "Obberron",
|
||||
/* 26 */ "Odee",
|
||||
/* 27 */ "Orbeus",
|
||||
/* 28 */ "Pax",
|
||||
/* 29 */ "Phields",
|
||||
/* 30 */ "Pigpen",
|
||||
/* 31 */ "Platinum",
|
||||
/* 32 */ "Polpol",
|
||||
/* 33 */ "Prume",
|
||||
/* 34 */ "Quinnly",
|
||||
/* 35 */ "Ragnarok",
|
||||
/* 36 */ "Rend",
|
||||
/* 37 */ "Roland",
|
||||
/* 38 */ "RyanM",
|
||||
/* 39 */ "Screach",
|
||||
/* 40 */ "Seraph",
|
||||
/* 41 */ "Silvani",
|
||||
/* 42 */ "Sherbear",
|
||||
/* 43 */ "SkyWalker",
|
||||
/* 44 */ "Snark",
|
||||
/* 45 */ "Sowl",
|
||||
/* 46 */ "Spada",
|
||||
/* 47 */ "Starblade",
|
||||
/* 48 */ "Tenacious",
|
||||
/* 49 */ "Tnez",
|
||||
/* 50 */ "Wasia",
|
||||
/* 51 */ "Zilo",
|
||||
/* 52 */ "Zippy",
|
||||
/* 53 */ "Zoer"
|
||||
};
|
||||
/* 1 */ "Backflash",
|
||||
/* 2 */ "Carbon",
|
||||
/* 3 */ "Colbalistic",
|
||||
/* 4 */ "Comforl",
|
||||
/* 5 */ "Coppacchia",
|
||||
/* 6 */ "Cyrus",
|
||||
/* 7 */ "DannyB",
|
||||
/* 8 */ "DJSoul",
|
||||
/* 9 */ "DraconisRex",
|
||||
/* 10 */ "Earia",
|
||||
/* 11 */ "Foster",
|
||||
/* 12 */ "Gonzo",
|
||||
/* 13 */ "Haan",
|
||||
/* 14 */ "Halona",
|
||||
/* 15 */ "Hugo",
|
||||
/* 16 */ "Hyacinth",
|
||||
/* 17 */ "Imirian",
|
||||
/* 18 */ "Jinsol",
|
||||
/* 19 */ "Liciatia",
|
||||
/* 20 */ "Loewen",
|
||||
/* 21 */ "Loke",
|
||||
/* 22 */ "Magnus",
|
||||
/* 23 */ "Maleki",
|
||||
/* 24 */ "Morpheus",
|
||||
/* 25 */ "Obberron",
|
||||
/* 26 */ "Odee",
|
||||
/* 27 */ "Orbeus",
|
||||
/* 28 */ "Pax",
|
||||
/* 29 */ "Phields",
|
||||
/* 30 */ "Pigpen",
|
||||
/* 31 */ "Platinum",
|
||||
/* 32 */ "Polpol",
|
||||
/* 33 */ "Prume",
|
||||
/* 34 */ "Quinnly",
|
||||
/* 35 */ "Ragnarok",
|
||||
/* 36 */ "Rend",
|
||||
/* 37 */ "Roland",
|
||||
/* 38 */ "RyanM",
|
||||
/* 39 */ "Screach",
|
||||
/* 40 */ "Seraph",
|
||||
/* 41 */ "Silvani",
|
||||
/* 42 */ "Sherbear",
|
||||
/* 43 */ "SkyWalker",
|
||||
/* 44 */ "Snark",
|
||||
/* 45 */ "Sowl",
|
||||
/* 46 */ "Spada",
|
||||
/* 47 */ "Starblade",
|
||||
/* 48 */ "Tenacious",
|
||||
/* 49 */ "Tnez",
|
||||
/* 50 */ "Wasia",
|
||||
/* 51 */ "Zilo",
|
||||
/* 52 */ "Zippy",
|
||||
/* 53 */ "Zoer"
|
||||
};
|
||||
|
||||
if (titles.Length > 0)
|
||||
return titles[Utility.Random(titles.Length)];
|
||||
|
||||
return null;
|
||||
}
|
||||
public static string GetRandomTitle() => titles.RandomElement();
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -479,9 +479,7 @@ namespace Server.Items
|
|||
|
||||
if (m_Region != null && Entries.Count != 0)
|
||||
{
|
||||
int winner = Utility.Random(Entries.Count);
|
||||
|
||||
m_Winner = Entries[winner].From;
|
||||
m_Winner = Entries.RandomElement().From;
|
||||
|
||||
if (m_Winner != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ namespace Server.Items
|
|||
int[] sounds = MonsterStatuetteInfo.GetInfo(m_Type).Sounds;
|
||||
|
||||
if (sounds.Length > 0)
|
||||
Effects.PlaySound(Location, Map, sounds[Utility.Random(sounds.Length)]);
|
||||
Effects.PlaySound(Location, Map, sounds.RandomElement());
|
||||
}
|
||||
|
||||
base.OnMovement(m, oldLocation);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Server.Items
|
|||
|
||||
organ = random switch
|
||||
{
|
||||
0 => (PlagueBeastOrgan)new PlagueBeastRockOrgan(),
|
||||
0 => new PlagueBeastRockOrgan(),
|
||||
1 => new PlagueBeastMaidenOrgan(),
|
||||
2 => new PlagueBeastRubbleOrgan(),
|
||||
_ => new PlagueBeastRockOrgan()
|
||||
|
|
@ -99,10 +99,9 @@ namespace Server.Items
|
|||
|
||||
for (int i = 0; i < m_BrainHues.Length; i++)
|
||||
{
|
||||
int random = Utility.Random(organs.Count);
|
||||
organ = organs[random];
|
||||
organ = organs.RandomElement();
|
||||
organ.BrainHue = m_BrainHues[i];
|
||||
organs.RemoveAt(random);
|
||||
organs.Remove(organ);
|
||||
}
|
||||
|
||||
organs.Clear();
|
||||
|
|
@ -174,4 +173,4 @@ namespace Server.Items
|
|||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace Server.Items
|
|||
min /= 5;
|
||||
max /= 5;
|
||||
|
||||
return new PowerScroll(Skills[Utility.Random(Skills.Count)], 100 + Utility.RandomMinMax(min, max) * 5);
|
||||
return new PowerScroll(Skills.RandomElement(), 100 + Utility.RandomMinMax(min, max) * 5);
|
||||
}
|
||||
|
||||
public static PowerScroll CreateRandomNoCraft(int min, int max)
|
||||
|
|
@ -147,7 +147,7 @@ namespace Server.Items
|
|||
|
||||
do
|
||||
{
|
||||
skillName = Skills[Utility.Random(Skills.Count)];
|
||||
skillName = Skills.RandomElement();
|
||||
} while (skillName == SkillName.Blacksmith || skillName == SkillName.Tailoring);
|
||||
|
||||
return new PowerScroll(skillName, 100 + Utility.RandomMinMax(min, max) * 5);
|
||||
|
|
|
|||
|
|
@ -30,12 +30,8 @@ namespace Server.Items
|
|||
public override string DefaultTitle =>
|
||||
$"<basefont color=#FFFFFF>Scroll of Transcendence ({Value} Skill):</basefont>";
|
||||
|
||||
public static ScrollofTranscendence CreateRandom(int min, int max)
|
||||
{
|
||||
SkillName skill = (SkillName)Utility.Random(SkillInfo.Table.Length);
|
||||
|
||||
return new ScrollofTranscendence(skill, Utility.RandomMinMax(min, max) * 0.1);
|
||||
}
|
||||
public static ScrollofTranscendence CreateRandom(int min, int max) =>
|
||||
new ScrollofTranscendence(Utility.RandomSkill(), Utility.RandomMinMax(min, max) * 0.1);
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -955,7 +955,7 @@ namespace Server.Items
|
|||
1023817 // clean bandage
|
||||
};
|
||||
|
||||
public static Type GetRandomSummonType() => m_Summons[Utility.Random(m_Summons.Length)];
|
||||
public static Type GetRandomSummonType() => m_Summons.RandomElement();
|
||||
|
||||
public static TalismanAttribute GetRandomSummoner()
|
||||
{
|
||||
|
|
@ -1049,7 +1049,7 @@ namespace Server.Items
|
|||
SkillName.Tinkering
|
||||
};
|
||||
|
||||
public static SkillName GetRandomSkill() => m_Skills[Utility.Random(m_Skills.Length)];
|
||||
public static SkillName GetRandomSkill() => m_Skills.RandomElement();
|
||||
|
||||
public static int GetRandomExceptional()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ namespace Server.Items
|
|||
{
|
||||
ItemID = 0x13B1;
|
||||
Hue = 0x48F;
|
||||
SkillBonuses.SetValues(0, m_PossibleBonusSkills[Utility.Random(m_PossibleBonusSkills.Length)],
|
||||
Utility.Random(4) == 0 ? 10.0 : 5.0);
|
||||
SkillBonuses.SetValues(0, m_PossibleBonusSkills.RandomElement(), Utility.Random(4) == 0 ? 10.0 : 5.0);
|
||||
WeaponAttributes.SelfRepair = 5;
|
||||
Attributes.WeaponSpeed = 50;
|
||||
Attributes.WeaponDamage = 35;
|
||||
|
|
@ -49,8 +48,7 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
|
||||
if (version < 1)
|
||||
SkillBonuses.SetValues(0, m_PossibleBonusSkills[Utility.Random(m_PossibleBonusSkills.Length)],
|
||||
Utility.Random(4) == 0 ? 10.0 : 5.0);
|
||||
SkillBonuses.SetValues(0, m_PossibleBonusSkills.RandomElement(), Utility.Random(4) == 0 ? 10.0 : 5.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,10 +201,7 @@ namespace Server.Items
|
|||
{
|
||||
int index = Utility.Random(1 + group.Entries.Length);
|
||||
|
||||
if (index == 0)
|
||||
return group.Super.Name;
|
||||
|
||||
return group.Entries[index - 1].Name;
|
||||
return index == 0 ? group.Super.Name : group.Entries[index - 1].Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue