Updates rest of the random list (#197)
This commit is contained in:
parent
4403d6c1c7
commit
8caf5a422f
18 changed files with 116 additions and 79 deletions
|
|
@ -346,34 +346,26 @@ namespace Server.Engines.Doom
|
|||
ResetLevers();
|
||||
}
|
||||
|
||||
public virtual void GenKey() /* Shuffle & build key */
|
||||
public virtual void GenKey()
|
||||
{
|
||||
ushort[] CA = { 1, 2, 4, 8 };
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int n = (n = Utility.Random(0, 3)) == i ? n & ~i : n;
|
||||
ushort tmp = CA[i];
|
||||
CA[i] = CA[n];
|
||||
CA[n] = tmp;
|
||||
}
|
||||
Span<ushort> ca = stackalloc ushort[]{ 1, 2, 4, 8 };
|
||||
ca.Shuffle();
|
||||
|
||||
for (int i = 0; i < 4; MyKey = (ushort)(CA[i++] | (MyKey <<= 4)))
|
||||
{
|
||||
}
|
||||
for (int i = 0; i < 4; i++) MyKey = (ushort)(ca[i] | (MyKey <<= 4));
|
||||
}
|
||||
|
||||
private static bool IsValidDamagable(Mobile m) =>
|
||||
m?.Deleted == false &&
|
||||
((m.Player && m.Alive) ||
|
||||
(m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet));
|
||||
(m.Player && m.Alive ||
|
||||
m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet);
|
||||
|
||||
public static void MoveMobileOut(Mobile m)
|
||||
{
|
||||
if (m != null)
|
||||
{
|
||||
if (m is PlayerMobile && !m.Alive)
|
||||
if (m.Corpse?.Deleted == false)
|
||||
m.Corpse.MoveToWorld(lr_Exit, Map.Malas);
|
||||
if (m is PlayerMobile && !m.Alive && m.Corpse?.Deleted == false)
|
||||
m.Corpse.MoveToWorld(lr_Exit, Map.Malas);
|
||||
|
||||
BaseCreature.TeleportPets(m, lr_Exit, Map.Malas);
|
||||
m.Location = lr_Exit;
|
||||
m.ProcessDelta();
|
||||
|
|
|
|||
|
|
@ -335,8 +335,7 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public virtual void DoHarvestingSound(Mobile from, Item tool, HarvestDefinition def, object toHarvest)
|
||||
{
|
||||
if (def.EffectSounds.Length > 0)
|
||||
from.PlaySound(Utility.RandomList(def.EffectSounds));
|
||||
from.PlaySound(def.EffectSounds.RandomElement(-1));
|
||||
}
|
||||
|
||||
public virtual void DoHarvestingEffect(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc)
|
||||
|
|
@ -344,7 +343,7 @@ namespace Server.Engines.Harvest
|
|||
from.Direction = from.GetDirectionTo(loc);
|
||||
|
||||
if (!from.Mounted)
|
||||
from.Animate(Utility.RandomList(def.EffectActions), 5, 1, true, false, 0);
|
||||
from.Animate(def.EffectActions.RandomElement(), 5, 1, true, false, 0);
|
||||
}
|
||||
|
||||
public virtual HarvestDefinition GetDefinition() => Definitions.First();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Server.Engines.Harvest
|
|||
m_Definition = def;
|
||||
m_ToHarvest = toHarvest;
|
||||
m_Locked = locked;
|
||||
m_Count = Utility.RandomList(def.EffectCounts);
|
||||
m_Count = def.EffectCounts.RandomElement();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
|
|
@ -31,4 +31,4 @@ namespace Server.Engines.Harvest
|
|||
Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ namespace Server.Engines.Harvest
|
|||
0x1CE2, 0x1CEC // leg
|
||||
};
|
||||
|
||||
preLoot = new ShipwreckedItem(Utility.RandomList(list));
|
||||
preLoot = new ShipwreckedItem(list.RandomElement());
|
||||
break;
|
||||
}
|
||||
case 1: // Bone parts
|
||||
|
|
@ -217,7 +217,7 @@ namespace Server.Engines.Harvest
|
|||
0x1B15, 0x1B16 // pelvis bones
|
||||
};
|
||||
|
||||
preLoot = new ShipwreckedItem(Utility.RandomList(list));
|
||||
preLoot = new ShipwreckedItem(list.RandomElement());
|
||||
break;
|
||||
}
|
||||
case 2: // Paintings and portraits
|
||||
|
|
@ -258,7 +258,7 @@ namespace Server.Engines.Harvest
|
|||
if (Utility.Random(list.Length + 1) == 0)
|
||||
preLoot = new Candelabra();
|
||||
else
|
||||
preLoot = new ShipwreckedItem(Utility.RandomList(list));
|
||||
preLoot = new ShipwreckedItem(list.RandomElement());
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Quests.Collector
|
||||
|
|
@ -56,8 +55,6 @@ namespace Server.Engines.Quests.Collector
|
|||
new ImageTypeInfo(9746, typeof(Juggernaut), 55, 38)
|
||||
};
|
||||
|
||||
private static ImageType[] m_ImageTypeList;
|
||||
|
||||
public ImageTypeInfo(int figurine, Type type, int x, int y)
|
||||
{
|
||||
Figurine = figurine;
|
||||
|
|
@ -66,6 +63,8 @@ namespace Server.Engines.Quests.Collector
|
|||
Y = y;
|
||||
}
|
||||
|
||||
public ImageType Image { get; }
|
||||
|
||||
public int Figurine { get; }
|
||||
|
||||
public Type Type { get; }
|
||||
|
|
@ -82,16 +81,21 @@ namespace Server.Engines.Quests.Collector
|
|||
|
||||
public static ImageType[] RandomList(int count)
|
||||
{
|
||||
if (m_ImageTypeList == null)
|
||||
{
|
||||
m_ImageTypeList = new ImageType[m_Table.Length];
|
||||
for (int i = 0; i < m_Table.Length; i++)
|
||||
m_ImageTypeList[i] = (ImageType)i;
|
||||
}
|
||||
if (count <= 0) return Array.Empty<ImageType>();
|
||||
|
||||
ImageType[] array = m_ImageTypeList.ToArray();
|
||||
Utility.Shuffle(array);
|
||||
return array.Take(count).ToArray();
|
||||
var length = m_Table.Length;
|
||||
Span<bool> list = stackalloc bool[length];
|
||||
var imageTypes = new ImageType[count];
|
||||
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
var rand = Utility.Random(length);
|
||||
if (!(list[rand] && (list[rand] = true)))
|
||||
imageTypes[i++] = (ImageType)rand;
|
||||
} while (i < count);
|
||||
|
||||
return imageTypes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Engines.Quests.Ninja
|
|||
};
|
||||
|
||||
[Constructible]
|
||||
public HiddenFigure() => Message = Utility.RandomList(Messages);
|
||||
public HiddenFigure() => Message = Messages.RandomElement();
|
||||
|
||||
public HiddenFigure(Serial serial) : base(serial)
|
||||
{
|
||||
|
|
@ -83,4 +83,4 @@ namespace Server.Engines.Quests.Ninja
|
|||
Message = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue