Creates random element extension (#196)
This commit is contained in:
parent
0926b5abaa
commit
4403d6c1c7
84 changed files with 226 additions and 330 deletions
|
|
@ -1102,7 +1102,7 @@ namespace Server.Misc
|
|||
int[] hues = { 0x1A8, 0xEC, 0x99, 0x90, 0xB5, 0x336, 0x89 };
|
||||
// TODO: Verify that's ALL the hues for that above.
|
||||
|
||||
EquipItem(new TattsukeHakama(hues[Utility.Random(hues.Length)]));
|
||||
EquipItem(new TattsukeHakama(hues.RandomElement()));
|
||||
|
||||
EquipItem(new HakamaShita(0x2C3));
|
||||
EquipItem(new NinjaTabi(0x2C3));
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Server.Items
|
|||
[Constructible]
|
||||
public LightOfTheWinterSolstice(string dipper = null) : base(0x236E)
|
||||
{
|
||||
Dipper = dipper ?? m_StaffNames[Utility.Random(m_StaffNames.Length)];
|
||||
Dipper = dipper ?? m_StaffNames.RandomElement();
|
||||
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
|
|
@ -81,7 +81,7 @@ namespace Server.Items
|
|||
}
|
||||
case 0:
|
||||
{
|
||||
Dipper = m_StaffNames[Utility.Random(m_StaffNames.Length)];
|
||||
Dipper = m_StaffNames.RandomElement();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ namespace Server.Guilds
|
|||
|
||||
public void CalculateAllianceLeader()
|
||||
{
|
||||
m_Leader = m_Members.Count >= 2 ? m_Members[Utility.Random(m_Members.Count)] : null;
|
||||
m_Leader = m_Members.Count >= 2 ? m_Members.RandomElement() : null;
|
||||
}
|
||||
|
||||
public void CheckLeader()
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ namespace Server.Misc
|
|||
|
||||
public IHSFlags Flags { get; set; }
|
||||
|
||||
public string GetRandomSyllable() => Syllables[Utility.Random(Syllables.Length)];
|
||||
public string GetRandomSyllable() => Syllables.RandomElement();
|
||||
|
||||
public string ConstructWord(int syllableCount)
|
||||
{
|
||||
|
|
@ -367,17 +367,14 @@ namespace Server.Misc
|
|||
public void SayRandomTranslate(Mobile mob, params string[] sentancesInEnglish)
|
||||
{
|
||||
SaySentance(mob, Utility.RandomMinMax(2, 3));
|
||||
mob.Say(sentancesInEnglish[Utility.Random(sentancesInEnglish.Length)]);
|
||||
mob.Say(sentancesInEnglish.RandomElement());
|
||||
}
|
||||
|
||||
private string GetRandomResponseWord(List<string> keywordsFound)
|
||||
{
|
||||
int random = Utility.Random(keywordsFound.Count + Responses.Length);
|
||||
|
||||
if (random < keywordsFound.Count)
|
||||
return keywordsFound[random];
|
||||
|
||||
return Responses[random - keywordsFound.Count];
|
||||
return random < keywordsFound.Count ? keywordsFound[random] : Responses[random - keywordsFound.Count];
|
||||
}
|
||||
|
||||
public bool OnSpeech(Mobile mob, Mobile speaker, string text)
|
||||
|
|
@ -411,7 +408,7 @@ namespace Server.Misc
|
|||
if (Utility.RandomBool())
|
||||
responseWord = GetRandomResponseWord(keywordsFound);
|
||||
else
|
||||
responseWord = keywordsFound[Utility.Random(keywordsFound.Count)];
|
||||
responseWord = keywordsFound.RandomElement();
|
||||
|
||||
string secondResponseWord = GetRandomResponseWord(keywordsFound);
|
||||
|
||||
|
|
|
|||
|
|
@ -539,13 +539,7 @@ namespace Server
|
|||
|
||||
public static Item RandomNecromancyReagent() => Construct(NecroRegTypes);
|
||||
|
||||
public static Item RandomPossibleReagent()
|
||||
{
|
||||
if (Core.AOS)
|
||||
return Construct(RegTypes, NecroRegTypes);
|
||||
|
||||
return Construct(RegTypes);
|
||||
}
|
||||
public static Item RandomPossibleReagent() => Core.AOS ? Construct(RegTypes, NecroRegTypes) : Construct(RegTypes);
|
||||
|
||||
public static Item RandomPotion() => Construct(PotionTypes);
|
||||
|
||||
|
|
@ -621,6 +615,8 @@ namespace Server
|
|||
|
||||
public static Item Construct(Type type)
|
||||
{
|
||||
if (type == null) return null;
|
||||
|
||||
try
|
||||
{
|
||||
return ActivatorUtil.CreateInstance(type) as Item;
|
||||
|
|
@ -631,13 +627,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public static Item Construct(Type[] types)
|
||||
{
|
||||
if (types.Length > 0)
|
||||
return Construct(types, Utility.Random(types.Length));
|
||||
|
||||
return null;
|
||||
}
|
||||
public static Item Construct(Type[] types) => Construct(types.RandomElement());
|
||||
|
||||
public static Item Construct(Type[] types, int index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Server
|
|||
|
||||
public static void GiveArtifactTo(Mobile m)
|
||||
{
|
||||
if (!(ActivatorUtil.CreateInstance(Artifacts[Utility.Random(Artifacts.Length)]) is Item item))
|
||||
if (!(ActivatorUtil.CreateInstance(Artifacts.RandomElement()) is Item item))
|
||||
return;
|
||||
|
||||
if (m.AddToBackpack(item))
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Server
|
|||
return false;
|
||||
}
|
||||
|
||||
public string GetRandomName() => List.Length > 0 ? List[Utility.Random(List.Length)] : "";
|
||||
public string GetRandomName() => List.RandomElement() ?? "";
|
||||
|
||||
public static NameList GetNameList(string type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ namespace Server.Misc
|
|||
return m_SkinHues[0];
|
||||
}
|
||||
|
||||
public override int RandomSkinHue() => m_SkinHues[Utility.Random(m_SkinHues.Length)] | 0x8000;
|
||||
public override int RandomSkinHue() => m_SkinHues.RandomElement() | 0x8000;
|
||||
|
||||
public override int ClipHairHue(int hue)
|
||||
{
|
||||
|
|
@ -195,7 +195,7 @@ namespace Server.Misc
|
|||
return m_HairHues[0];
|
||||
}
|
||||
|
||||
public override int RandomHairHue() => m_HairHues[Utility.Random(m_HairHues.Length)];
|
||||
public override int RandomHairHue() => m_HairHues.RandomElement();
|
||||
}
|
||||
|
||||
private class Gargoyle : Race
|
||||
|
|
@ -258,7 +258,7 @@ namespace Server.Misc
|
|||
|
||||
public override int ClipSkinHue(int hue) => hue;
|
||||
|
||||
public override int RandomSkinHue() => m_BodyHues[Utility.Random(m_BodyHues.Length)] | 0x8000;
|
||||
public override int RandomSkinHue() => m_BodyHues.RandomElement() | 0x8000;
|
||||
|
||||
public override int ClipHairHue(int hue)
|
||||
{
|
||||
|
|
@ -269,7 +269,7 @@ namespace Server.Misc
|
|||
return m_HornHues[0];
|
||||
}
|
||||
|
||||
public override int RandomHairHue() => m_HornHues[Utility.Random(m_HornHues.Length)];
|
||||
public override int RandomHairHue() => m_HornHues.RandomElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue