Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,225 @@
using System;
using Server.Items;
namespace Server.Commands
{
public class GenKhaldun
{
private static int m_Count;
public static void Initialize()
{
CommandSystem.Register("GenKhaldun", AccessLevel.Administrator, new CommandEventHandler(GenKhaldun_OnCommand));
CommandSystem.Register("DeleteKhaldun", AccessLevel.Administrator, new CommandEventHandler(DeleteKhaldun_OnCommand));
}
public static bool FindMorphItem(int x, int y, int z, int inactiveItemID, int activeItemID)
{
IPooledEnumerable eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0);
foreach (Item item in eable)
{
if (item is MorphItem && item.Z == z && ((MorphItem)item).InactiveItemID == inactiveItemID && ((MorphItem)item).ActiveItemID == activeItemID)
{
eable.Free();
return true;
}
}
eable.Free();
return false;
}
public static bool FindEffectController(int x, int y, int z)
{
IPooledEnumerable eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0);
foreach (Item item in eable)
{
if (item is EffectController && item.Z == z)
{
eable.Free();
return true;
}
}
eable.Free();
return false;
}
public static Item TryCreateItem(int x, int y, int z, Item srcItem)
{
IPooledEnumerable eable = Map.Felucca.GetItemsInBounds(new Rectangle2D(x, y, 1, 1));
foreach (Item item in eable)
{
if (item.GetType() == srcItem.GetType())
{
eable.Free();
srcItem.Delete();
return item;
}
}
eable.Free();
srcItem.MoveToWorld(new Point3D(x, y, z), Map.Felucca);
m_Count++;
return srcItem;
}
public static void CreateMorphItem(int x, int y, int z, int inactiveItemID, int activeItemID, int range)
{
if (FindMorphItem(x, y, z, inactiveItemID, activeItemID))
return;
MorphItem item = new MorphItem(inactiveItemID, activeItemID, range, 3);
WeakEntityCollection.Add("khaldun", item);
item.MoveToWorld(new Point3D(x, y, z), Map.Felucca);
m_Count++;
}
public static void CreateApproachLight(int x, int y, int z, int off, int on, LightType light)
{
if (FindMorphItem(x, y, z, off, on))
return;
MorphItem item = new MorphItem(off, on, 2, 3);
WeakEntityCollection.Add("khaldun", item);
item.Light = light;
item.MoveToWorld(new Point3D(x, y, z), Map.Felucca);
m_Count++;
}
public static void CreateSoundEffect(int x, int y, int z, int sound, int range)
{
if (FindEffectController(x, y, z))
return;
EffectController item = new EffectController();
WeakEntityCollection.Add("khaldun", item);
item.SoundID = sound;
item.TriggerType = EffectTriggerType.InRange;
item.TriggerRange = range;
item.MoveToWorld(new Point3D(x, y, z), Map.Felucca);
m_Count++;
}
public static void CreateBigTeleporterItem(int x, int y, bool reverse)
{
if (FindMorphItem(x, y, 0, reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC))
return;
MorphItem item = new MorphItem(reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC, 1, 3);
WeakEntityCollection.Add("khaldun", item);
item.MoveToWorld(new Point3D(x, y, 0), Map.Felucca);
m_Count++;
}
public static void DeleteKhaldun_OnCommand(CommandEventArgs e)
{
WeakEntityCollection.Delete("khaldun");
}
public static void GenKhaldun_OnCommand(CommandEventArgs e)
{
m_Count = 0;
// Generate Morph Items
CreateMorphItem(5459, 1416, 0, 0x1D0, 0x1, 1);
CreateMorphItem(5460, 1416, 0, 0x1D0, 0x1, 1);
CreateMorphItem(5459, 1416, 0, 0x1, 0x53D, 1);
CreateMorphItem(5460, 1416, 0, 0x1, 0x53B, 1);
CreateMorphItem(5459, 1425, 0, 0x1, 0x53B, 2);
CreateMorphItem(5459, 1426, 0, 0x1, 0x53B, 2);
CreateMorphItem(5459, 1427, 0, 0x1, 0x53B, 2);
CreateMorphItem(5460, 1425, 0, 0x1, 0x53B, 2);
CreateMorphItem(5460, 1426, 0, 0x1, 0x53B, 2);
CreateMorphItem(5460, 1427, 0, 0x1, 0x53B, 2);
CreateMorphItem(5461, 1427, 0, 0x1, 0x53B, 2);
CreateMorphItem(5460, 1422, 0, 0x1, 0x544, 2);
CreateMorphItem(5460, 1419, 0, 0x1, 0x545, 2);
CreateMorphItem(5460, 1420, 0, 0x1, 0x545, 2);
CreateMorphItem(5460, 1423, 0, 0x1, 0x545, 2);
CreateMorphItem(5460, 1424, 0, 0x1, 0x545, 2);
CreateMorphItem(5461, 1426, 0, 0x1, 0x545, 2);
CreateMorphItem(5460, 1417, 0, 0x1, 0x546, 1);
CreateMorphItem(5460, 1418, 0, 0x1, 0x546, 2);
CreateMorphItem(5460, 1421, 0, 0x1, 0x546, 2);
CreateMorphItem(5461, 1425, 0, 0x1, 0x548, 2);
CreateMorphItem(5459, 1420, 0, 0x1, 0x54A, 2);
CreateMorphItem(5459, 1421, 0, 0x1, 0x54A, 2);
CreateMorphItem(5459, 1423, 0, 0x1, 0x54A, 2);
CreateMorphItem(5459, 1418, 0, 0x1, 0x54B, 2);
CreateMorphItem(5459, 1422, 0, 0x1, 0x54B, 2);
CreateMorphItem(5459, 1417, 0, 0x1, 0x54C, 1);
CreateMorphItem(5459, 1419, 0, 0x1, 0x54C, 2);
CreateMorphItem(5459, 1424, 0, 0x1, 0x54C, 2);
CreateMorphItem(5458, 1426, 0, 0x1, 0x1D1, 2);
CreateMorphItem(5459, 1427, 0, 0x1, 0x1E3, 2);
CreateMorphItem(5458, 1425, 3, 0x1, 0x1E4, 2);
CreateMorphItem(5458, 1427, 6, 0x1, 0x1E5, 2);
CreateMorphItem(5461, 1427, 0, 0x1, 0x1E8, 2);
CreateMorphItem(5460, 1427, 0, 0x1, 0x1E9, 2);
CreateMorphItem(5458, 1425, 0, 0x1, 0x1EA, 2);
CreateMorphItem(5458, 1427, 0, 0x1, 0x1EA, 2);
CreateMorphItem(5458, 1427, 3, 0x1, 0x1EA, 2);
// Generate Approach Lights
CreateApproachLight(5393, 1417, 0, 0x1857, 0x1858, LightType.Circle150);
CreateApproachLight(5393, 1420, 0, 0x1857, 0x1858, LightType.Circle150);
CreateApproachLight(5395, 1421, 0, 0x1857, 0x1858, LightType.Circle150);
CreateApproachLight(5396, 1417, 0, 0x1857, 0x1858, LightType.Circle150);
CreateApproachLight(5397, 1419, 0, 0x1857, 0x1858, LightType.Circle150);
CreateApproachLight(5441, 1393, 5, 0x1F2B, 0x19BB, LightType.Circle225);
CreateApproachLight(5446, 1393, 5, 0x1F2B, 0x19BB, LightType.Circle225);
// Generate Sound Effects
CreateSoundEffect(5425, 1489, 5, 0x102, 1);
CreateSoundEffect(5425, 1491, 5, 0x102, 1);
CreateSoundEffect(5449, 1499, 10, 0xF5, 1);
CreateSoundEffect(5451, 1499, 10, 0xF5, 1);
CreateSoundEffect(5453, 1499, 10, 0xF5, 1);
CreateSoundEffect(5524, 1367, 0, 0x102, 1);
CreateSoundEffect(5450, 1370, 0, 0x220, 2);
CreateSoundEffect(5450, 1372, 0, 0x220, 2);
CreateSoundEffect(5460, 1416, 0, 0x244, 2);
CreateSoundEffect(5483, 1439, 5, 0x14, 3);
// Generate Big Teleporter
CreateBigTeleporterItem(5387, 1325, true);
CreateBigTeleporterItem(5388, 1326, true);
CreateBigTeleporterItem(5388, 1325, false);
CreateBigTeleporterItem(5387, 1326, false);
// Generate Central Khaldun entrance
DisappearingRaiseSwitch sw = TryCreateItem(5459, 1426, 10, new DisappearingRaiseSwitch()) as DisappearingRaiseSwitch;
RaiseSwitch lv = TryCreateItem(5403, 1359, 0, new RaiseSwitch()) as RaiseSwitch;
RaisableItem stone = TryCreateItem(5403, 1360, 0, new RaisableItem(0x788, 10, 0x477, 0x475, TimeSpan.FromMinutes(1.5))) as RaisableItem;
RaisableItem door = TryCreateItem(5524, 1367, 0, new RaisableItem(0x1D0, 20, 0x477, 0x475, TimeSpan.FromMinutes(5.0))) as RaisableItem;
WeakEntityCollection.Add("khaldun", sw);
WeakEntityCollection.Add("khaldun", lv);
WeakEntityCollection.Add("khaldun", stone);
WeakEntityCollection.Add("khaldun", door);
sw.RaisableItem = stone;
lv.RaisableItem = door;
e.Mobile.SendMessage(String.Format("{0} dynamic Khaldun item{1} generated.", m_Count, m_Count == 1 ? "" : "s"));
}
}
}

View File

@@ -0,0 +1,130 @@
using System;
namespace Server.Items
{
public class KhaldunPitTeleporter : Item
{
private bool m_Active;
private Point3D m_PointDest;
private Map m_MapDest;
[Constructable]
public KhaldunPitTeleporter()
: this(new Point3D(5451, 1374, 0), Map.Felucca)
{
}
[Constructable]
public KhaldunPitTeleporter(Point3D pointDest, Map mapDest)
: base(0x053B)
{
this.Movable = false;
this.Hue = 1;
this.m_Active = true;
this.m_PointDest = pointDest;
this.m_MapDest = mapDest;
}
public KhaldunPitTeleporter(Serial serial)
: base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public bool Active
{
get
{
return this.m_Active;
}
set
{
this.m_Active = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public Point3D PointDest
{
get
{
return this.m_PointDest;
}
set
{
this.m_PointDest = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public Map MapDest
{
get
{
return this.m_MapDest;
}
set
{
this.m_MapDest = value;
}
}
public override int LabelNumber
{
get
{
return 1016511;
}
}// the floor of the cavern seems to have collapsed here - a faint light is visible at the bottom of the pit
public override void OnDoubleClick(Mobile m)
{
if (!this.m_Active)
return;
Map map = this.m_MapDest;
if (map == null || map == Map.Internal)
map = m.Map;
Point3D p = this.m_PointDest;
if (p == Point3D.Zero)
p = m.Location;
if (m.InRange(this, 3))
{
Server.Mobiles.BaseCreature.TeleportPets(m, this.m_PointDest, this.m_MapDest);
m.MoveToWorld(this.m_PointDest, this.m_MapDest);
}
else
{
m.SendLocalizedMessage(1019045); // I can't reach that.
}
}
public override void OnDoubleClickDead(Mobile m)
{
this.OnDoubleClick(m);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
writer.Write(this.m_Active);
writer.Write(this.m_PointDest);
writer.Write(this.m_MapDest);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
this.m_Active = reader.ReadBool();
this.m_PointDest = reader.ReadPoint3D();
this.m_MapDest = reader.ReadMap();
}
}
}

View File

@@ -0,0 +1,933 @@
using System;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
namespace Server.Items
{
public enum PuzzleChestCylinder
{
None = 0xE73,
LightBlue = 0x186F,
Blue = 0x186A,
Green = 0x186B,
Orange = 0x186C,
Purple = 0x186D,
Red = 0x186E,
DarkBlue = 0x1869,
Yellow = 0x1870
}
public class PuzzleChestSolution
{
public const int Length = 5;
private readonly PuzzleChestCylinder[] m_Cylinders = new PuzzleChestCylinder[Length];
public PuzzleChestSolution()
{
for (int i = 0; i < m_Cylinders.Length; i++)
{
m_Cylinders[i] = RandomCylinder();
}
}
public PuzzleChestSolution(PuzzleChestCylinder first, PuzzleChestCylinder second, PuzzleChestCylinder third, PuzzleChestCylinder fourth, PuzzleChestCylinder fifth)
{
First = first;
Second = second;
Third = third;
Fourth = fourth;
Fifth = fifth;
}
public PuzzleChestSolution(PuzzleChestSolution solution)
{
for (int i = 0; i < m_Cylinders.Length; i++)
{
m_Cylinders[i] = solution.m_Cylinders[i];
}
}
public PuzzleChestSolution(GenericReader reader)
{
int version = reader.ReadEncodedInt();
int length = reader.ReadEncodedInt();
for (int i = 0;; i++)
{
if (i < length)
{
PuzzleChestCylinder cylinder = (PuzzleChestCylinder)reader.ReadInt();
if (i < m_Cylinders.Length)
m_Cylinders[i] = cylinder;
}
else if (i < m_Cylinders.Length)
{
m_Cylinders[i] = RandomCylinder();
}
else
{
break;
}
}
}
public PuzzleChestCylinder[] Cylinders
{
get
{
return m_Cylinders;
}
}
public PuzzleChestCylinder First
{
get
{
return m_Cylinders[0];
}
set
{
m_Cylinders[0] = value;
}
}
public PuzzleChestCylinder Second
{
get
{
return m_Cylinders[1];
}
set
{
m_Cylinders[1] = value;
}
}
public PuzzleChestCylinder Third
{
get
{
return m_Cylinders[2];
}
set
{
m_Cylinders[2] = value;
}
}
public PuzzleChestCylinder Fourth
{
get
{
return m_Cylinders[3];
}
set
{
m_Cylinders[3] = value;
}
}
public PuzzleChestCylinder Fifth
{
get
{
return m_Cylinders[4];
}
set
{
m_Cylinders[4] = value;
}
}
public static PuzzleChestCylinder RandomCylinder()
{
switch ( Utility.Random(8) )
{
case 0:
return PuzzleChestCylinder.LightBlue;
case 1:
return PuzzleChestCylinder.Blue;
case 2:
return PuzzleChestCylinder.Green;
case 3:
return PuzzleChestCylinder.Orange;
case 4:
return PuzzleChestCylinder.Purple;
case 5:
return PuzzleChestCylinder.Red;
case 6:
return PuzzleChestCylinder.DarkBlue;
default:
return PuzzleChestCylinder.Yellow;
}
}
public bool Matches(PuzzleChestSolution solution, out int cylinders, out int colors)
{
cylinders = 0;
colors = 0;
bool[] matchesSrc = new bool[solution.m_Cylinders.Length];
bool[] matchesDst = new bool[solution.m_Cylinders.Length];
for (int i = 0; i < m_Cylinders.Length; i++)
{
if (m_Cylinders[i] == solution.m_Cylinders[i])
{
cylinders++;
matchesSrc[i] = true;
matchesDst[i] = true;
}
}
for (int i = 0; i < m_Cylinders.Length; i++)
{
if (!matchesSrc[i])
{
for (int j = 0; j < solution.m_Cylinders.Length; j++)
{
if (m_Cylinders[i] == solution.m_Cylinders[j] && !matchesDst[j])
{
colors++;
matchesDst[j] = true;
}
}
}
}
return cylinders == m_Cylinders.Length;
}
public virtual void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt((int)0); // version
writer.WriteEncodedInt((int)m_Cylinders.Length);
for (int i = 0; i < m_Cylinders.Length; i++)
{
writer.Write((int)m_Cylinders[i]);
}
}
}
public class PuzzleChestSolutionAndTime : PuzzleChestSolution
{
private readonly DateTime m_When;
public PuzzleChestSolutionAndTime(DateTime when, PuzzleChestSolution solution)
: base(solution)
{
m_When = when;
}
public PuzzleChestSolutionAndTime(GenericReader reader)
: base(reader)
{
int version = reader.ReadEncodedInt();
m_When = reader.ReadDeltaTime();
}
public DateTime When
{
get
{
return m_When;
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
writer.WriteDeltaTime(m_When);
}
}
public abstract class PuzzleChest : BaseTreasureChest
{
public const int HintsCount = 3;
public readonly TimeSpan CleanupTime = TimeSpan.FromHours(1.0);
private readonly Dictionary<Mobile, PuzzleChestSolutionAndTime> m_Guesses = new Dictionary<Mobile, PuzzleChestSolutionAndTime>();
private PuzzleChestSolution m_Solution;
private PuzzleChestCylinder[] m_Hints = new PuzzleChestCylinder[HintsCount];
public virtual int Label { get { return 1018309; } } // A Puzzle Lock
public PuzzleChest(int itemID)
: base(itemID)
{
}
public PuzzleChest(Serial serial)
: base(serial)
{
}
public PuzzleChestSolution Solution
{
get
{
return m_Solution;
}
set
{
m_Solution = value;
InitHints();
}
}
public PuzzleChestCylinder[] Hints
{
get
{
return m_Hints;
}
}
public PuzzleChestCylinder FirstHint
{
get
{
return m_Hints[0];
}
set
{
m_Hints[0] = value;
}
}
public PuzzleChestCylinder SecondHint
{
get
{
return m_Hints[1];
}
set
{
m_Hints[1] = value;
}
}
public PuzzleChestCylinder ThirdHint
{
get
{
return m_Hints[2];
}
set
{
m_Hints[2] = value;
}
}
public override string DefaultName
{
get
{
return null;
}
}
public override bool CheckLocked(Mobile from)
{
if (Locked)
{
PuzzleChestSolution solution = GetLastGuess(from);
if (solution != null)
solution = new PuzzleChestSolution(solution);
else
solution = new PuzzleChestSolution(PuzzleChestCylinder.None, PuzzleChestCylinder.None, PuzzleChestCylinder.None, PuzzleChestCylinder.None, PuzzleChestCylinder.None);
from.CloseGump(typeof(PuzzleGump));
from.CloseGump(typeof(StatusGump));
from.SendGump(new PuzzleGump(from, this, solution, 0));
return true;
}
else
{
return false;
}
}
public PuzzleChestSolutionAndTime GetLastGuess(Mobile m)
{
PuzzleChestSolutionAndTime pcst = null;
m_Guesses.TryGetValue(m, out pcst);
return pcst;
}
public void SubmitSolution(Mobile m, PuzzleChestSolution solution)
{
int correctCylinders, correctColors;
if (solution.Matches(Solution, out correctCylinders, out correctColors))
{
LockPick(m);
DisplayTo(m);
}
else
{
m_Guesses[m] = new PuzzleChestSolutionAndTime(DateTime.UtcNow, solution);
m.SendGump(new StatusGump(correctCylinders, correctColors));
DoDamage(m);
}
}
public virtual void DoDamage(Mobile to)
{
switch ( Utility.Random(4) )
{
case 0:
{
Effects.SendLocationEffect(to, to.Map, 0x113A, 20, 10);
to.PlaySound(0x231);
to.LocalOverheadMessage(MessageType.Regular, 0x44, 1010523); // A toxic vapor envelops thee.
to.ApplyPoison(to, Poison.Regular);
break;
}
case 1:
{
Effects.SendLocationEffect(to, to.Map, 0x3709, 30);
to.PlaySound(0x54);
to.LocalOverheadMessage(MessageType.Regular, 0xEE, 1010524); // Searing heat scorches thy skin.
AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 0, 100, 0, 0, 0);
break;
}
case 2:
{
to.PlaySound(0x223);
to.LocalOverheadMessage(MessageType.Regular, 0x62, 1010525); // Pain lances through thee from a sharp metal blade.
AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 100, 0, 0, 0, 0);
break;
}
default:
{
to.BoltEffect(0);
to.LocalOverheadMessage(MessageType.Regular, 0xDA, 1010526); // Lightning arcs through thy body.
AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 0, 0, 0, 0, 100);
break;
}
}
}
public override void LockPick(Mobile from)
{
base.LockPick(from);
m_Guesses.Clear();
}
public void CleanupGuesses()
{
List<Mobile> toDelete = new List<Mobile>();
foreach (KeyValuePair<Mobile, PuzzleChestSolutionAndTime> kvp in m_Guesses)
{
if (DateTime.UtcNow - kvp.Value.When > CleanupTime)
toDelete.Add(kvp.Key);
}
foreach (Mobile m in toDelete)
m_Guesses.Remove(m);
}
public override void Serialize(GenericWriter writer)
{
CleanupGuesses();
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
m_Solution.Serialize(writer);
writer.WriteEncodedInt((int)m_Hints.Length);
for (int i = 0; i < m_Hints.Length; i++)
{
writer.Write((int)m_Hints[i]);
}
writer.WriteEncodedInt((int)m_Guesses.Count);
foreach (KeyValuePair<Mobile, PuzzleChestSolutionAndTime> kvp in m_Guesses)
{
writer.Write(kvp.Key);
kvp.Value.Serialize(writer);
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
m_Solution = new PuzzleChestSolution(reader);
int length = reader.ReadEncodedInt();
for (int i = 0; i < length; i++)
{
PuzzleChestCylinder cylinder = (PuzzleChestCylinder)reader.ReadInt();
if (length == m_Hints.Length)
m_Hints[i] = cylinder;
}
if (length != m_Hints.Length)
InitHints();
int guesses = reader.ReadEncodedInt();
for (int i = 0; i < guesses; i++)
{
Mobile m = reader.ReadMobile();
PuzzleChestSolutionAndTime sol = new PuzzleChestSolutionAndTime(reader);
m_Guesses[m] = sol;
}
}
protected override void SetLockLevel()
{
LockLevel = 0; // Can't be unlocked
}
protected override void GenerateTreasure()
{
DropItem(new Gold(600, 900));
List<Item> gems = new List<Item>();
for (int i = 0; i < 9; i++)
{
Item gem = Loot.RandomGem();
Type gemType = gem.GetType();
foreach (Item listGem in gems)
{
if (listGem.GetType() == gemType)
{
listGem.Amount++;
gem.Delete();
break;
}
}
if (!gem.Deleted)
gems.Add(gem);
}
foreach (Item gem in gems)
DropItem(gem);
if (0.2 > Utility.RandomDouble())
DropItem(new BagOfReagents(50));
for (int i = 0; i < 2; i++)
{
Item item;
if (Core.AOS)
item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
else
item = Loot.RandomArmorOrShieldOrWeapon();
if (item is BaseWeapon)
{
BaseWeapon weapon = (BaseWeapon)item;
if (Core.AOS)
{
int attributeCount;
int min, max;
GetRandomAOSStats(out attributeCount, out min, out max);
BaseRunicTool.ApplyAttributesTo(weapon, attributeCount, min, max);
}
else
{
weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(6);
weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(6);
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(6);
}
DropItem(item);
}
else if (item is BaseArmor)
{
BaseArmor armor = (BaseArmor)item;
if (Core.AOS)
{
int attributeCount;
int min, max;
GetRandomAOSStats(out attributeCount, out min, out max);
BaseRunicTool.ApplyAttributesTo(armor, attributeCount, min, max);
}
else
{
armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(6);
armor.Durability = (ArmorDurabilityLevel)Utility.Random(6);
}
DropItem(item);
}
else if (item is BaseHat)
{
BaseHat hat = (BaseHat)item;
if (Core.AOS)
{
int attributeCount;
int min, max;
GetRandomAOSStats(out attributeCount, out min, out max);
BaseRunicTool.ApplyAttributesTo(hat, attributeCount, min, max);
}
DropItem(item);
}
else if (item is BaseJewel)
{
int attributeCount;
int min, max;
GetRandomAOSStats(out attributeCount, out min, out max);
BaseRunicTool.ApplyAttributesTo((BaseJewel)item, attributeCount, min, max);
DropItem(item);
}
}
Solution = new PuzzleChestSolution();
}
private static void GetRandomAOSStats(out int attributeCount, out int min, out int max)
{
int rnd = Utility.Random(15);
if (rnd < 1)
{
attributeCount = Utility.RandomMinMax(2, 6);
min = 20;
max = 70;
}
else if (rnd < 3)
{
attributeCount = Utility.RandomMinMax(2, 4);
min = 20;
max = 50;
}
else if (rnd < 6)
{
attributeCount = Utility.RandomMinMax(2, 3);
min = 20;
max = 40;
}
else if (rnd < 10)
{
attributeCount = Utility.RandomMinMax(1, 2);
min = 10;
max = 30;
}
else
{
attributeCount = 1;
min = 10;
max = 20;
}
}
private void InitHints()
{
List<PuzzleChestCylinder> list = new List<PuzzleChestCylinder>(Solution.Cylinders.Length - 1);
for (int i = 1; i < Solution.Cylinders.Length; i++)
list.Add(Solution.Cylinders[i]);
m_Hints = new PuzzleChestCylinder[HintsCount];
for (int i = 0; i < m_Hints.Length; i++)
{
int pos = Utility.Random(list.Count);
m_Hints[i] = list[pos];
list.RemoveAt(pos);
}
}
public class PuzzleGump : Gump
{
private readonly Mobile m_From;
private readonly PuzzleChest m_Chest;
private readonly PuzzleChestSolution m_Solution;
public PuzzleGump(Mobile from, PuzzleChest chest, PuzzleChestSolution solution, int check)
: base(50, 50)
{
m_From = from;
m_Chest = chest;
m_Solution = solution;
Dragable = false;
AddBackground(25, 0, 500, 410, 0x53);
AddImage(62, 20, 0x67);
AddHtmlLocalized(80, 36, 110, 70, 1018309, true, false); // A Puzzle Lock
/* Correctly choose the sequence of cylinders needed to open the latch. Each cylinder
* may potentially be used more than once. Beware! A false attempt could be deadly!
*/
AddHtmlLocalized(214, 26, 270, 90, 1018310, true, true);
AddLeftCylinderButton(62, 130, PuzzleChestCylinder.LightBlue, 10);
AddLeftCylinderButton(62, 180, PuzzleChestCylinder.Blue, 11);
AddLeftCylinderButton(62, 230, PuzzleChestCylinder.Green, 12);
AddLeftCylinderButton(62, 280, PuzzleChestCylinder.Orange, 13);
AddRightCylinderButton(451, 130, PuzzleChestCylinder.Purple, 14);
AddRightCylinderButton(451, 180, PuzzleChestCylinder.Red, 15);
AddRightCylinderButton(451, 230, PuzzleChestCylinder.DarkBlue, 16);
AddRightCylinderButton(451, 280, PuzzleChestCylinder.Yellow, 17);
double lockpicking = from.Skills.Lockpicking.Base;
if (lockpicking >= 60.0)
{
AddHtmlLocalized(160, 125, 230, 24, 1018308, false, false); // Lockpicking hint:
AddBackground(159, 150, 230, 95, 0x13EC);
if (lockpicking >= 80.0)
{
AddHtmlLocalized(165, 157, 200, 40, 1018312, false, false); // In the first slot:
AddCylinder(350, 165, chest.Solution.First);
AddHtmlLocalized(165, 197, 200, 40, 1018313, false, false); // Used in unknown slot:
AddCylinder(350, 200, chest.FirstHint);
if (lockpicking >= 90.0)
AddCylinder(350, 212, chest.SecondHint);
if (lockpicking >= 100.0)
AddCylinder(350, 224, chest.ThirdHint);
}
else
{
AddHtmlLocalized(165, 157, 200, 40, 1018313, false, false); // Used in unknown slot:
AddCylinder(350, 160, chest.FirstHint);
if (lockpicking >= 70.0)
AddCylinder(350, 172, chest.SecondHint);
}
}
PuzzleChestSolution lastGuess = chest.GetLastGuess(from);
if (lastGuess != null)
{
AddHtmlLocalized(127, 249, 170, 20, 1018311, false, false); // Thy previous guess:
AddBackground(290, 247, 115, 25, 0x13EC);
AddCylinder(281, 254, lastGuess.First);
AddCylinder(303, 254, lastGuess.Second);
AddCylinder(325, 254, lastGuess.Third);
AddCylinder(347, 254, lastGuess.Fourth);
AddCylinder(369, 254, lastGuess.Fifth);
}
AddPedestal(140, 270, solution.First, 0, check == 0);
AddPedestal(195, 270, solution.Second, 1, check == 1);
AddPedestal(250, 270, solution.Third, 2, check == 2);
AddPedestal(305, 270, solution.Fourth, 3, check == 3);
AddPedestal(360, 270, solution.Fifth, 4, check == 4);
AddButton(258, 370, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Chest.Deleted || info.ButtonID == 0 || !m_From.CheckAlive())
return;
if (m_From.IsPlayer() && (m_From.Map != m_Chest.Map || !m_From.InRange(m_Chest.GetWorldLocation(), 2)))
{
m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500446); // That is too far away.
return;
}
if (info.ButtonID == 1)
{
m_Chest.SubmitSolution(m_From, m_Solution);
}
else
{
if (info.Switches.Length == 0)
return;
int pedestal = info.Switches[0];
if (pedestal < 0 || pedestal >= m_Solution.Cylinders.Length)
return;
PuzzleChestCylinder cylinder;
switch ( info.ButtonID )
{
case 10:
cylinder = PuzzleChestCylinder.LightBlue;
break;
case 11:
cylinder = PuzzleChestCylinder.Blue;
break;
case 12:
cylinder = PuzzleChestCylinder.Green;
break;
case 13:
cylinder = PuzzleChestCylinder.Orange;
break;
case 14:
cylinder = PuzzleChestCylinder.Purple;
break;
case 15:
cylinder = PuzzleChestCylinder.Red;
break;
case 16:
cylinder = PuzzleChestCylinder.DarkBlue;
break;
case 17:
cylinder = PuzzleChestCylinder.Yellow;
break;
default:
return;
}
m_Solution.Cylinders[pedestal] = cylinder;
m_From.SendGump(new PuzzleGump(m_From, m_Chest, m_Solution, pedestal));
}
}
private void AddLeftCylinderButton(int x, int y, PuzzleChestCylinder cylinder, int buttonID)
{
AddBackground(x, y, 30, 30, 0x13EC);
AddCylinder(x - 7, y + 10, cylinder);
AddButton(x + 38, y + 9, 0x13A8, 0x4B9, buttonID, GumpButtonType.Reply, 0);
}
private void AddRightCylinderButton(int x, int y, PuzzleChestCylinder cylinder, int buttonID)
{
AddBackground(x, y, 30, 30, 0x13EC);
AddCylinder(x - 7, y + 10, cylinder);
AddButton(x - 26, y + 9, 0x13A8, 0x4B9, buttonID, GumpButtonType.Reply, 0);
}
private void AddPedestal(int x, int y, PuzzleChestCylinder cylinder, int switchID, bool initialState)
{
AddItem(x, y, 0xB10);
AddItem(x - 23, y + 12, 0xB12);
AddItem(x + 23, y + 12, 0xB13);
AddItem(x, y + 23, 0xB11);
if (cylinder != PuzzleChestCylinder.None)
{
AddItem(x, y + 2, 0x51A);
AddCylinder(x - 1, y + 19, cylinder);
}
else
{
AddItem(x, y + 2, 0x521);
}
AddRadio(x + 7, y + 65, 0x867, 0x86A, initialState, switchID);
}
private void AddCylinder(int x, int y, PuzzleChestCylinder cylinder)
{
if (cylinder != PuzzleChestCylinder.None)
AddItem(x, y, (int)cylinder);
else
AddItem(x + 9, y, (int)cylinder);
}
}
public class StatusGump : Gump
{
public StatusGump(int correctCylinders, int correctColors)
: base(50, 50)
{
AddBackground(15, 250, 305, 163, 0x53);
AddBackground(28, 265, 280, 133, 0xBB8);
AddHtmlLocalized(35, 271, 270, 24, 1018314, false, false); // Thou hast failed to solve the puzzle!
AddHtmlLocalized(35, 297, 250, 24, 1018315, false, false); // Correctly placed colors:
AddLabel(285, 297, 0x44, correctCylinders.ToString());
AddHtmlLocalized(35, 323, 250, 24, 1018316, false, false); // Used colors in wrong slots:
AddLabel(285, 323, 0x44, correctColors.ToString());
AddButton(152, 369, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
}
}
}
[FlipableAttribute(0xE41, 0xE40)]
public class MetalGoldenPuzzleChest : PuzzleChest
{
[Constructable]
public MetalGoldenPuzzleChest()
: base(0xE41)
{
}
public MetalGoldenPuzzleChest(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
[FlipableAttribute(0xE80, 0x9A8)]
public class StrongBoxPuzzle : PuzzleChest
{
[Constructable]
public StrongBoxPuzzle()
: base(0xE80)
{
}
public StrongBoxPuzzle(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
}

View File

@@ -0,0 +1,209 @@
using System;
namespace Server.Items
{
public class RaisableItem : Item
{
private int m_MaxElevation;
private int m_MoveSound;
private int m_StopSound;
private TimeSpan m_CloseDelay;
private int m_Elevation;
private RaiseTimer m_RaiseTimer;
[Constructable]
public RaisableItem(int itemID)
: this(itemID, 20, -1, -1, TimeSpan.FromMinutes(1.0))
{
}
[Constructable]
public RaisableItem(int itemID, int maxElevation, TimeSpan closeDelay)
: this(itemID, maxElevation, -1, -1, closeDelay)
{
}
[Constructable]
public RaisableItem(int itemID, int maxElevation, int moveSound, int stopSound, TimeSpan closeDelay)
: base(itemID)
{
this.Movable = false;
this.m_MaxElevation = maxElevation;
this.m_MoveSound = moveSound;
this.m_StopSound = stopSound;
this.m_CloseDelay = closeDelay;
}
public RaisableItem(Serial serial)
: base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public int MaxElevation
{
get
{
return this.m_MaxElevation;
}
set
{
if (value <= 0)
this.m_MaxElevation = 0;
else if (value >= 60)
this.m_MaxElevation = 60;
else
this.m_MaxElevation = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int MoveSound
{
get
{
return this.m_MoveSound;
}
set
{
this.m_MoveSound = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int StopSound
{
get
{
return this.m_StopSound;
}
set
{
this.m_StopSound = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan CloseDelay
{
get
{
return this.m_CloseDelay;
}
set
{
this.m_CloseDelay = value;
}
}
public bool IsRaisable
{
get
{
return this.m_RaiseTimer == null;
}
}
public void Raise()
{
if (!this.IsRaisable)
return;
this.m_RaiseTimer = new RaiseTimer(this);
this.m_RaiseTimer.Start();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
writer.WriteEncodedInt((int)this.m_MaxElevation);
writer.WriteEncodedInt((int)this.m_MoveSound);
writer.WriteEncodedInt((int)this.m_StopSound);
writer.Write((TimeSpan)this.m_CloseDelay);
writer.WriteEncodedInt((int)this.m_Elevation);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
this.m_MaxElevation = reader.ReadEncodedInt();
this.m_MoveSound = reader.ReadEncodedInt();
this.m_StopSound = reader.ReadEncodedInt();
this.m_CloseDelay = reader.ReadTimeSpan();
int elevation = reader.ReadEncodedInt();
this.Z -= elevation;
}
private class RaiseTimer : Timer
{
private readonly RaisableItem m_Item;
private readonly DateTime m_CloseTime;
private bool m_Up;
private int m_Step;
public RaiseTimer(RaisableItem item)
: base(TimeSpan.Zero, TimeSpan.FromSeconds(0.5))
{
this.m_Item = item;
this.m_CloseTime = DateTime.UtcNow + item.CloseDelay;
this.m_Up = true;
this.Priority = TimerPriority.TenMS;
}
protected override void OnTick()
{
if (this.m_Item.Deleted)
{
this.Stop();
return;
}
if (this.m_Step++ % 3 == 0)
{
if (this.m_Up)
{
this.m_Item.Z++;
if (++this.m_Item.m_Elevation >= this.m_Item.MaxElevation)
{
this.Stop();
if (this.m_Item.StopSound >= 0)
Effects.PlaySound(this.m_Item.Location, this.m_Item.Map, this.m_Item.StopSound);
this.m_Up = false;
this.m_Step = 0;
TimeSpan delay = this.m_CloseTime - DateTime.UtcNow;
Timer.DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, new TimerCallback(Start));
return;
}
}
else
{
this.m_Item.Z--;
if (--this.m_Item.m_Elevation <= 0)
{
this.Stop();
if (this.m_Item.StopSound >= 0)
Effects.PlaySound(this.m_Item.Location, this.m_Item.Map, this.m_Item.StopSound);
this.m_Item.m_RaiseTimer = null;
return;
}
}
}
if (this.m_Item.MoveSound >= 0)
Effects.PlaySound(this.m_Item.Location, this.m_Item.Map, this.m_Item.MoveSound);
}
}
}
}

View File

@@ -0,0 +1,242 @@
using System;
using Server.Network;
namespace Server.Items
{
public class RaiseSwitch : Item
{
private RaisableItem m_RaisableItem;
private ResetTimer m_ResetTimer;
[Constructable]
public RaiseSwitch()
: this(0x1093)
{
}
public RaiseSwitch(Serial serial)
: base(serial)
{
}
protected RaiseSwitch(int itemID)
: base(itemID)
{
this.Movable = false;
}
[CommandProperty(AccessLevel.GameMaster)]
public RaisableItem RaisableItem
{
get
{
return this.m_RaisableItem;
}
set
{
this.m_RaisableItem = value;
}
}
public override void OnDoubleClick(Mobile m)
{
if (!m.InRange(this, 2))
{
m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
return;
}
if (this.RaisableItem != null && this.RaisableItem.Deleted)
this.RaisableItem = null;
this.Flip();
if (this.RaisableItem != null)
{
if (this.RaisableItem.IsRaisable)
{
this.RaisableItem.Raise();
m.LocalOverheadMessage(MessageType.Regular, 0x5A, true, "You hear a grinding noise echoing in the distance.");
}
else
{
m.LocalOverheadMessage(MessageType.Regular, 0x5A, true, "You flip the switch again, but nothing happens.");
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
writer.Write((Item)this.m_RaisableItem);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
this.m_RaisableItem = (RaisableItem)reader.ReadItem();
this.Reset();
}
protected virtual void Flip()
{
if (this.ItemID != 0x1093)
{
this.ItemID = 0x1093;
this.StopResetTimer();
}
else
{
this.ItemID = 0x1095;
if (this.RaisableItem != null && this.RaisableItem.CloseDelay >= TimeSpan.Zero)
this.StartResetTimer(this.RaisableItem.CloseDelay);
else
this.StartResetTimer(TimeSpan.FromMinutes(2.0));
}
Effects.PlaySound(this.Location, this.Map, 0x3E8);
}
protected void StartResetTimer(TimeSpan delay)
{
this.StopResetTimer();
this.m_ResetTimer = new ResetTimer(this, delay);
this.m_ResetTimer.Start();
}
protected void StopResetTimer()
{
if (this.m_ResetTimer != null)
{
this.m_ResetTimer.Stop();
this.m_ResetTimer = null;
}
}
protected virtual void Reset()
{
if (this.ItemID != 0x1093)
this.Flip();
}
private class ResetTimer : Timer
{
private readonly RaiseSwitch m_RaiseSwitch;
public ResetTimer(RaiseSwitch raiseSwitch, TimeSpan delay)
: base(delay)
{
this.m_RaiseSwitch = raiseSwitch;
this.Priority = ComputePriority(delay);
}
protected override void OnTick()
{
if (this.m_RaiseSwitch.Deleted)
return;
this.m_RaiseSwitch.m_ResetTimer = null;
this.m_RaiseSwitch.Reset();
}
}
}
public class DisappearingRaiseSwitch : RaiseSwitch
{
[Constructable]
public DisappearingRaiseSwitch()
: base(0x108F)
{
}
public DisappearingRaiseSwitch(Serial serial)
: base(serial)
{
}
public int CurrentRange
{
get
{
return this.Visible ? 3 : 2;
}
}
public override bool HandlesOnMovement
{
get
{
return true;
}
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (Utility.InRange(m.Location, this.Location, this.CurrentRange) || Utility.InRange(oldLocation, this.Location, this.CurrentRange))
this.Refresh();
}
public override void OnMapChange()
{
if (!this.Deleted)
this.Refresh();
}
public override void OnLocationChange(Point3D oldLoc)
{
if (!this.Deleted)
this.Refresh();
}
public void Refresh()
{
bool found = false;
IPooledEnumerable eable = GetMobilesInRange(CurrentRange);
foreach (Mobile mob in eable)
{
if (mob.Hidden && mob.IsStaff())
continue;
found = true;
break;
}
eable.Free();
this.Visible = found;
}
public override void Serialize(GenericWriter writer)
{
if (this.RaisableItem != null && this.RaisableItem.Deleted)
this.RaisableItem = null;
base.Serialize(writer);
writer.WriteEncodedInt((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
Timer.DelayCall(TimeSpan.Zero, new TimerCallback(Refresh));
}
protected override void Flip()
{
}
protected override void Reset()
{
}
}
}