fix: Finishes code gen for misc items (#1248)

This commit is contained in:
Kamron Batman 2022-11-13 23:10:13 -08:00 committed by GitHub
parent 6d00b2caa9
commit 5660f4636e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 2797 additions and 3156 deletions

View file

@ -155,5 +155,22 @@ public static class TextDefinitionExtensions
}
}
public static void PublicOverheadMessage(this TextDefinition def, Item item, MessageType messageType, int hue)
{
if (def == null)
{
return;
}
if (def.Number > 0)
{
item.PublicOverheadMessage(messageType, hue, def.Number);
}
else if (def.String != null)
{
item.PublicOverheadMessage(messageType, hue, false, def.String);
}
}
public static bool IsNullOrEmpty(this TextDefinition def) => def?.IsEmpty != false;
}

View file

@ -261,8 +261,8 @@ namespace Server.Commands
var hi = new HintItem(m_ItemID, range, messageNumber, hintNumber);
hi.WarningString = messageString;
hi.HintString = hintString;
hi.WarningMessage = messageString;
hi.HintMessage = hintString;
hi.ResetDelay = resetDelay;
item = hi;
@ -316,7 +316,7 @@ namespace Server.Commands
var wi = new WarningItem(m_ItemID, range, messageNumber);
wi.WarningString = messageString;
wi.WarningMessage = messageString;
wi.ResetDelay = resetDelay;
item = wi;
@ -687,7 +687,7 @@ namespace Server.Commands
if (indexOf >= 0)
{
st.MessageString = m_Params[i][++indexOf..];
st.Message = m_Params[i][++indexOf..];
}
}
else if (m_Params[i].StartsWithOrdinal("MessageNumber"))
@ -696,7 +696,7 @@ namespace Server.Commands
if (indexOf >= 0)
{
st.MessageNumber = Utility.ToInt32(m_Params[i].AsSpan()[++indexOf..]);
st.Message = Utility.ToInt32(m_Params[i].AsSpan()[++indexOf..]);
}
}
else if (m_Params[i].StartsWithOrdinal("PointDest"))

View file

@ -257,8 +257,8 @@ namespace Server.Commands
var hi = new HintItem(m_ItemID, range, messageNumber, hintNumber);
hi.WarningString = messageString;
hi.HintString = hintString;
hi.WarningMessage = messageString;
hi.HintMessage = hintString;
hi.ResetDelay = resetDelay;
item = hi;
@ -312,7 +312,7 @@ namespace Server.Commands
var wi = new WarningItem(m_ItemID, range, messageNumber);
wi.WarningString = messageString;
wi.WarningMessage = messageString;
wi.ResetDelay = resetDelay;
item = wi;
@ -683,7 +683,7 @@ namespace Server.Commands
if (indexOf >= 0)
{
st.MessageString = m_Params[i][++indexOf..];
st.Message = m_Params[i][++indexOf..];
}
}
else if (m_Params[i].StartsWithOrdinal("MessageNumber"))
@ -692,7 +692,7 @@ namespace Server.Commands
if (indexOf >= 0)
{
st.MessageNumber = Utility.ToInt32(m_Params[i].AsSpan()[++indexOf..]);
st.Message = Utility.ToInt32(m_Params[i].AsSpan()[++indexOf..]);
}
}
else if (m_Params[i].StartsWithOrdinal("PointDest"))

File diff suppressed because it is too large Load diff

View file

@ -1,86 +1,63 @@
using ModernUO.Serialization;
using Server.Targeting;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class Scales : Item
{
public class Scales : Item
[Constructible]
public Scales() : base(0x1852) => Weight = 4.0;
public override void OnDoubleClick(Mobile from)
{
[Constructible]
public Scales() : base(0x1852) => Weight = 4.0;
from.SendLocalizedMessage(502431); // What would you like to weigh?
from.Target = new InternalTarget(this);
}
public Scales(Serial serial) : base(serial)
private class InternalTarget : Target
{
private Scales _scales;
public InternalTarget(Scales item) : base(1, false, TargetFlags.None) => _scales = item;
protected override void OnTarget(Mobile from, object targeted)
{
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
public override void OnDoubleClick(Mobile from)
{
from.SendLocalizedMessage(502431); // What would you like to weigh?
from.Target = new InternalTarget(this);
}
private class InternalTarget : Target
{
private readonly Scales m_Item;
public InternalTarget(Scales item) : base(1, false, TargetFlags.None) => m_Item = item;
protected override void OnTarget(Mobile from, object targeted)
if (targeted == _scales)
{
string message;
from.SendMessage("It cannot weigh itself.");
return;
}
if (targeted == m_Item)
{
message = "It cannot weight itself.";
}
else if (targeted is Item item)
{
var root = item.RootParent;
if (targeted is Mobile m)
{
from.SendLocalizedMessage(502432); // That is too heavy for these scales!
}
if (root != null && root != from || item.Parent == from)
{
message = "You decide that item's current location is too awkward to get an accurate result.";
}
else if (item.Movable)
{
message = item.Amount > 1
? "You place one item on the scale. "
: "You place that item on the scale. ";
if (targeted is not Item { Movable: true } item)
{
from.SendMessage("You cannot weigh that.");
return;
}
var weight = item.Weight;
var root = item.RootParent;
if (weight <= 0.0)
{
message += "It is lighter than a feather.";
}
else
{
message += $"It weighs {weight} stones.";
}
}
else
{
message = "You cannot weigh that object.";
}
}
else
{
message = "You cannot weigh that object.";
}
if (root != null && root != from || item.Parent == from)
{
from.SendMessage("You decide that item's current location is too awkward to get an accurate result.");
return;
}
from.SendMessage(message);
var amount = item.Amount > 1 ? "one" : "that";
var weight = item.Weight;
if (weight <= 0.0)
{
from.SendMessage($"You place {amount} item on the scale. It is lighter than a feather.");
}
else
{
from.SendMessage($"You place {amount} item on the scale. It weighs {weight} stones.");
}
}
}

View file

@ -1,107 +1,81 @@
using ModernUO.Serialization;
using Server.Multis;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0)]
public partial class SerpentPillar : Item
{
public class SerpentPillar : Item
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _active;
[SerializableField(1)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private string _word;
[SerializableField(2)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private Rectangle2D _destination;
[Constructible]
public SerpentPillar() : this(null, new Rectangle2D(), false)
{
[Constructible]
public SerpentPillar() : this(null, new Rectangle2D(), false)
}
public SerpentPillar(string word, Rectangle2D destination, bool active = true) : base(0x233F)
{
Movable = false;
_active = active;
_word = word;
_destination = destination;
}
public override bool HandlesOnSpeech => true;
public override void OnSpeech(SpeechEventArgs e)
{
var from = e.Mobile;
if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == Word)
{
}
var boat = BaseBoat.FindBoatAt(from.Location, from.Map);
public SerpentPillar(string word, Rectangle2D destination, bool active = true) : base(0x233F)
{
Movable = false;
Active = active;
Word = word;
Destination = destination;
}
public SerpentPillar(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public bool Active { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string Word { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Rectangle2D Destination { get; set; }
public override bool HandlesOnSpeech => true;
public override void OnSpeech(SpeechEventArgs e)
{
var from = e.Mobile;
if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == Word)
if (boat == null)
{
var boat = BaseBoat.FindBoatAt(from.Location, from.Map);
if (boat == null)
{
return;
}
if (!Active)
{
boat.TillerMan
?.Say(
502507
); // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
return;
}
var map = from.Map;
for (var i = 0; i < 5; i++) // Try 5 times
{
var x = Utility.Random(Destination.X, Destination.Width);
var y = Utility.Random(Destination.Y, Destination.Height);
var z = map.GetAverageZ(x, y);
var dest = new Point3D(x, y, z);
if (boat.CanFit(dest, map, boat.ItemID))
{
var xOffset = x - boat.X;
var yOffset = y - boat.Y;
var zOffset = z - boat.Z;
boat.Teleport(xOffset, yOffset, zOffset);
return;
}
}
boat.TillerMan?.Say(502508); // Ar, I refuse to take that matey through here!
return;
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
if (!Active)
{
// Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
boat.TillerMan?.Say(502507);
return;
}
writer.WriteEncodedInt(0); // version
var map = from.Map;
writer.Write(Active);
writer.Write(Word);
writer.Write(Destination);
}
for (var i = 0; i < 5; i++) // Try 5 times
{
var x = Utility.Random(Destination.X, Destination.Width);
var y = Utility.Random(Destination.Y, Destination.Height);
var z = map.GetAverageZ(x, y);
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var dest = new Point3D(x, y, z);
var version = reader.ReadEncodedInt();
if (boat.CanFit(dest, map, boat.ItemID))
{
var xOffset = x - boat.X;
var yOffset = y - boat.Y;
var zOffset = z - boat.Z;
Active = reader.ReadBool();
Word = reader.ReadString();
Destination = reader.ReadRect2D();
boat.Teleport(xOffset, yOffset, zOffset);
return;
}
}
boat.TillerMan?.Say(502508); // Ar, I refuse to take that matey through here!
}
}
}

View file

@ -1,164 +1,146 @@
using System;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class SpecialBeardDye : Item
{
public class SpecialBeardDye : Item
[Constructible]
public SpecialBeardDye() : base(0xE26)
{
[Constructible]
public SpecialBeardDye() : base(0xE26)
{
Weight = 1.0;
LootType = LootType.Newbied;
}
public SpecialBeardDye(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1041087; // Special Beard Dye
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
public override void OnDoubleClick(Mobile from)
{
if (from.InRange(GetWorldLocation(), 1))
{
from.CloseGump<SpecialBeardDyeGump>();
from.SendGump(new SpecialBeardDyeGump(this));
}
else
{
from.LocalOverheadMessage(MessageType.Regular, 906, 1019045); // I can't reach that.
}
}
Weight = 1.0;
LootType = LootType.Newbied;
}
public class SpecialBeardDyeGump : Gump
public override int LabelNumber => 1041087; // Special Beard Dye
public override void OnDoubleClick(Mobile from)
{
private static readonly SpecialBeardDyeEntry[] m_Entries =
if (from.InRange(GetWorldLocation(), 1))
{
new("*****", 12, 10),
new("*****", 32, 5),
new("*****", 38, 8),
new("*****", 54, 3),
new("*****", 62, 10),
new("*****", 81, 2),
new("*****", 89, 2),
new("*****", 1153, 2)
};
private readonly SpecialBeardDye m_SpecialBeardDye;
public SpecialBeardDyeGump(SpecialBeardDye dye) : base(0, 0)
{
m_SpecialBeardDye = dye;
AddPage(0);
AddBackground(150, 60, 350, 358, 2600);
AddBackground(170, 104, 110, 270, 5100);
AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1013007); // Dye my beard this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR
for (var i = 0; i < m_Entries.Length; ++i)
{
AddLabel(180, 109 + i * 22, m_Entries[i].HueStart - 1, m_Entries[i].Name);
AddButton(257, 110 + i * 22, 5224, 5224, 0, GumpButtonType.Page, i + 1);
}
for (var i = 0; i < m_Entries.Length; ++i)
{
var e = m_Entries[i];
AddPage(i + 1);
for (var j = 0; j < e.HueCount; ++j)
{
AddLabel(328 + j / 16 * 80, 102 + j % 16 * 17, e.HueStart + j - 1, "*****");
AddRadio(310 + j / 16 * 80, 102 + j % 16 * 17, 210, 211, false, i * 100 + j);
}
}
from.CloseGump<SpecialBeardDyeGump>();
from.SendGump(new SpecialBeardDyeGump(this));
}
public override void OnResponse(NetState from, RelayInfo info)
else
{
if (m_SpecialBeardDye.Deleted)
{
return;
}
var m = from.Mobile;
var switches = info.Switches;
if (!m_SpecialBeardDye.IsChildOf(m.Backpack))
{
m.SendLocalizedMessage(1042010); // You must have the objectin your backpack to use it.
return;
}
if (info.ButtonID != 0 && switches.Length > 0)
{
if (m.FacialHairItemID == 0)
{
m.SendLocalizedMessage(502623); // You have no hair to dye and cannot use this
}
else
{
// To prevent this from being exploited, the hue is abstracted into an internal list
var entryIndex = switches[0] / 100;
var hueOffset = switches[0] % 100;
if (entryIndex >= 0 && entryIndex < m_Entries.Length)
{
var e = m_Entries[entryIndex];
if (hueOffset >= 0 && hueOffset < e.HueCount)
{
var hue = e.HueStart + hueOffset;
m.FacialHairHue = hue;
m.SendLocalizedMessage(501199); // You dye your hair
m_SpecialBeardDye.Delete();
m.PlaySound(0x4E);
}
}
}
}
else
{
m.SendLocalizedMessage(501200); // You decide not to dye your hair
}
}
private class SpecialBeardDyeEntry
{
public SpecialBeardDyeEntry(string name, int hueStart, int hueCount)
{
Name = name;
HueStart = hueStart;
HueCount = hueCount;
}
public string Name { get; }
public int HueStart { get; }
public int HueCount { get; }
from.LocalOverheadMessage(MessageType.Regular, 906, 1019045); // I can't reach that.
}
}
}
public class SpecialBeardDyeGump : Gump
{
private static SpecialBeardDyeEntry[] _entries =
{
new("*****", 12, 10),
new("*****", 32, 5),
new("*****", 38, 8),
new("*****", 54, 3),
new("*****", 62, 10),
new("*****", 81, 2),
new("*****", 89, 2),
new("*****", 1153, 2)
};
private SpecialBeardDye _specialBeardDye;
public SpecialBeardDyeGump(SpecialBeardDye dye) : base(0, 0)
{
_specialBeardDye = dye;
AddPage(0);
AddBackground(150, 60, 350, 358, 2600);
AddBackground(170, 104, 110, 270, 5100);
AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1013007); // Dye my beard this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR
for (var i = 0; i < _entries.Length; ++i)
{
AddLabel(180, 109 + i * 22, _entries[i].HueStart - 1, _entries[i].Name);
AddButton(257, 110 + i * 22, 5224, 5224, 0, GumpButtonType.Page, i + 1);
}
for (var i = 0; i < _entries.Length; ++i)
{
var e = _entries[i];
AddPage(i + 1);
for (var j = 0; j < e.HueCount; ++j)
{
AddLabel(328 + j / 16 * 80, 102 + j % 16 * 17, e.HueStart + j - 1, "*****");
AddRadio(310 + j / 16 * 80, 102 + j % 16 * 17, 210, 211, false, i * 100 + j);
}
}
}
public override void OnResponse(NetState from, RelayInfo info)
{
if (_specialBeardDye.Deleted)
{
return;
}
var m = from.Mobile;
var switches = info.Switches;
if (!_specialBeardDye.IsChildOf(m.Backpack))
{
m.SendLocalizedMessage(1042010); // You must have the object in your backpack to use it.
return;
}
if (info.ButtonID != 0 && switches.Length > 0)
{
if (m.FacialHairItemID == 0)
{
m.SendLocalizedMessage(502623); // You have no hair to dye and cannot use this
}
else
{
// To prevent this from being exploited, the hue is abstracted into an internal list
var entryIndex = Math.DivRem(switches[0], 100, out var hueOffset);
if (entryIndex >= 0 && entryIndex < _entries.Length)
{
var e = _entries[entryIndex];
if (hueOffset >= 0 && hueOffset < e.HueCount)
{
var hue = e.HueStart + hueOffset;
m.FacialHairHue = hue;
m.SendLocalizedMessage(501199); // You dye your hair
_specialBeardDye.Delete();
m.PlaySound(0x4E);
}
}
}
}
else
{
m.SendLocalizedMessage(501200); // You decide not to dye your hair
}
}
private class SpecialBeardDyeEntry
{
public SpecialBeardDyeEntry(string name, int hueStart, int hueCount)
{
Name = name;
HueStart = hueStart;
HueCount = hueCount;
}
public string Name { get; }
public int HueStart { get; }
public int HueCount { get; }
}
}

View file

@ -1,165 +1,147 @@
using System;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class SpecialHairDye : Item
{
public class SpecialHairDye : Item
[Constructible]
public SpecialHairDye() : base(0xE26)
{
[Constructible]
public SpecialHairDye() : base(0xE26)
{
Weight = 1.0;
LootType = LootType.Newbied;
}
public SpecialHairDye(Serial serial) : base(serial)
{
}
public override string DefaultName => "Special Hair Dye";
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
public override void OnDoubleClick(Mobile from)
{
if (from.InRange(GetWorldLocation(), 1))
{
from.CloseGump<SpecialHairDyeGump>();
from.SendGump(new SpecialHairDyeGump(this));
}
else
{
from.LocalOverheadMessage(MessageType.Regular, 906, 1019045); // I can't reach that.
}
}
Weight = 1.0;
LootType = LootType.Newbied;
}
public class SpecialHairDyeGump : Gump
public override int LabelNumber => 1074402;
public override void OnDoubleClick(Mobile from)
{
private static readonly SpecialHairDyeEntry[] m_Entries =
if (from.InRange(GetWorldLocation(), 1))
{
new("*****", 12, 10),
new("*****", 32, 5),
new("*****", 38, 8),
new("*****", 54, 3),
new("*****", 62, 10),
new("*****", 81, 2),
new("*****", 89, 2),
new("*****", 1153, 2)
};
private readonly SpecialHairDye m_SpecialHairDye;
public SpecialHairDyeGump(SpecialHairDye dye) : base(0, 0)
{
m_SpecialHairDye = dye;
AddPage(0);
AddBackground(150, 60, 350, 358, 2600);
AddBackground(170, 104, 110, 270, 5100);
AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1011014); // Dye my hair this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR
for (var i = 0; i < m_Entries.Length; ++i)
{
AddLabel(180, 109 + i * 22, m_Entries[i].HueStart - 1, m_Entries[i].Name);
AddButton(257, 110 + i * 22, 5224, 5224, 0, GumpButtonType.Page, i + 1);
}
for (var i = 0; i < m_Entries.Length; ++i)
{
var e = m_Entries[i];
AddPage(i + 1);
for (var j = 0; j < e.HueCount; ++j)
{
AddLabel(328 + j / 16 * 80, 102 + j % 16 * 17, e.HueStart + j - 1, "*****");
AddRadio(310 + j / 16 * 80, 102 + j % 16 * 17, 210, 211, false, i * 100 + j);
}
}
from.CloseGump<SpecialHairDyeGump>();
from.SendGump(new SpecialHairDyeGump(this));
}
public override void OnResponse(NetState from, RelayInfo info)
else
{
if (m_SpecialHairDye.Deleted)
{
return;
}
var m = from.Mobile;
var switches = info.Switches;
if (!m_SpecialHairDye.IsChildOf(m.Backpack))
{
m.SendLocalizedMessage(1042010); // You must have the objectin your backpack to use it.
return;
}
if (info.ButtonID != 0 && switches.Length > 0)
{
if (m.HairItemID == 0)
{
m.SendLocalizedMessage(502623); // You have no hair to dye and cannot use this
}
else
{
// To prevent this from being exploited, the hue is abstracted into an internal list
var entryIndex = switches[0] / 100;
var hueOffset = switches[0] % 100;
if (entryIndex >= 0 && entryIndex < m_Entries.Length)
{
var e = m_Entries[entryIndex];
if (hueOffset >= 0 && hueOffset < e.HueCount)
{
m_SpecialHairDye.Delete();
var hue = e.HueStart + hueOffset;
m.HairHue = hue;
m.SendLocalizedMessage(501199); // You dye your hair
m.PlaySound(0x4E);
}
}
}
}
else
{
m.SendLocalizedMessage(501200); // You decide not to dye your hair
}
}
private class SpecialHairDyeEntry
{
public SpecialHairDyeEntry(string name, int hueStart, int hueCount)
{
Name = name;
HueStart = hueStart;
HueCount = hueCount;
}
public string Name { get; }
public int HueStart { get; }
public int HueCount { get; }
from.LocalOverheadMessage(MessageType.Regular, 906, 1019045); // I can't reach that.
}
}
}
public class SpecialHairDyeGump : Gump
{
private static readonly SpecialHairDyeEntry[] _entries =
{
new("*****", 12, 10),
new("*****", 32, 5),
new("*****", 38, 8),
new("*****", 54, 3),
new("*****", 62, 10),
new("*****", 81, 2),
new("*****", 89, 2),
new("*****", 1153, 2)
};
private SpecialHairDye _specialHairDye;
public SpecialHairDyeGump(SpecialHairDye dye) : base(0, 0)
{
_specialHairDye = dye;
AddPage(0);
AddBackground(150, 60, 350, 358, 2600);
AddBackground(170, 104, 110, 270, 5100);
AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu
AddHtmlLocalized(235, 380, 300, 20, 1011014); // Dye my hair this color!
AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR
for (var i = 0; i < _entries.Length; ++i)
{
AddLabel(180, 109 + i * 22, _entries[i].HueStart - 1, _entries[i].Name);
AddButton(257, 110 + i * 22, 5224, 5224, 0, GumpButtonType.Page, i + 1);
}
for (var i = 0; i < _entries.Length; ++i)
{
var e = _entries[i];
AddPage(i + 1);
for (var j = 0; j < e.HueCount; ++j)
{
AddLabel(328 + j / 16 * 80, 102 + j % 16 * 17, e.HueStart + j - 1, "*****");
AddRadio(310 + j / 16 * 80, 102 + j % 16 * 17, 210, 211, false, i * 100 + j);
}
}
}
public override void OnResponse(NetState from, RelayInfo info)
{
if (_specialHairDye.Deleted)
{
return;
}
var m = from.Mobile;
var switches = info.Switches;
if (!_specialHairDye.IsChildOf(m.Backpack))
{
m.SendLocalizedMessage(1042010); // You must have the objecti n your backpack to use it.
return;
}
if (info.ButtonID != 0 && switches.Length > 0)
{
if (m.HairItemID == 0)
{
m.SendLocalizedMessage(502623); // You have no hair to dye and cannot use this
}
else
{
// To prevent this from being exploited, the hue is abstracted into an internal list
var entryIndex = Math.DivRem(switches[0], 100, out var hueOffset);
if (entryIndex >= 0 && entryIndex < _entries.Length)
{
var e = _entries[entryIndex];
if (hueOffset >= 0 && hueOffset < e.HueCount)
{
_specialHairDye.Delete();
var hue = e.HueStart + hueOffset;
m.HairHue = hue;
m.SendLocalizedMessage(501199); // You dye your hair
m.PlaySound(0x4E);
}
}
}
}
else
{
m.SendLocalizedMessage(501200); // You decide not to dye your hair
}
}
private class SpecialHairDyeEntry
{
public SpecialHairDyeEntry(string name, int hueStart, int hueCount)
{
Name = name;
HueStart = hueStart;
HueCount = hueCount;
}
public string Name { get; }
public int HueStart { get; }
public int HueCount { get; }
}
}

View file

@ -1,92 +1,37 @@
namespace Server.Items
using ModernUO.Serialization;
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class Static : Item
{
public class Static : Item
public Static() : base(0x80) => Movable = false;
[Constructible]
public Static(int itemID) : base(itemID) => Movable = false;
[Constructible]
public Static(int itemID, int count) : this(Utility.Random(itemID, count))
{
public Static() : base(0x80) => Movable = false;
[Constructible]
public Static(int itemID) : base(itemID) => Movable = false;
[Constructible]
public Static(int itemID, int count) : this(Utility.Random(itemID, count))
{
}
public Static(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version == 0 && Weight == 0)
{
Weight = -1;
}
}
}
public class LocalizedStatic : Static
{
private int m_LabelNumber;
[Constructible]
public LocalizedStatic(int itemID) : this(itemID, itemID < 0x4000 ? 1020000 + itemID : 1078872 + itemID)
{
}
[Constructible]
public LocalizedStatic(int itemID, int labelNumber) : base(itemID) => m_LabelNumber = labelNumber;
public LocalizedStatic(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public int Number
{
get => m_LabelNumber;
set
{
m_LabelNumber = value;
InvalidateProperties();
}
}
public override int LabelNumber => m_LabelNumber;
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write((byte)0); // version
writer.WriteEncodedInt(m_LabelNumber);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadByte();
switch (version)
{
case 0:
{
m_LabelNumber = reader.ReadEncodedInt();
break;
}
}
}
}
}
[SerializationGenerator(0)]
public partial class LocalizedStatic : Static
{
[EncodedInt]
[InvalidateProperties]
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private int _number;
[Constructible]
public LocalizedStatic(int itemID) : this(itemID, itemID < 0x4000 ? 1020000 + itemID : 1078872 + itemID)
{
}
[Constructible]
public LocalizedStatic(int itemID, int number) : base(itemID) => _number = number;
public override int LabelNumber => _number;
}

View file

@ -1,32 +1,16 @@
namespace Server.Items
using ModernUO.Serialization;
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class SwarmOfFlies : Item
{
public class SwarmOfFlies : Item
[Constructible]
public SwarmOfFlies() : base(0x91B)
{
[Constructible]
public SwarmOfFlies() : base(0x91B)
{
Hue = 1;
Movable = false;
}
public SwarmOfFlies(Serial serial) : base(serial)
{
}
public override string DefaultName => "a swarm of flies";
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
Hue = 1;
Movable = false;
}
public override string DefaultName => "a swarm of flies";
}

File diff suppressed because it is too large Load diff

View file

@ -1,156 +1,127 @@
using System;
using ModernUO.Serialization;
using Server.Multis;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class TrashBarrel : Container, IChoppable
{
public class TrashBarrel : Container, IChoppable
private Timer m_Timer;
[Constructible]
public TrashBarrel() : base(0xE77)
{
private Timer m_Timer;
Hue = 0x3B2;
Movable = false;
}
[Constructible]
public TrashBarrel() : base(0xE77)
public override int LabelNumber => 1041064; // a trash barrel
public override int DefaultMaxWeight => 0; // A value of 0 signals unlimited weight
public override bool IsDecoContainer => false;
public void OnChop(Mobile from)
{
var house = BaseHouse.FindHouseAt(from);
if (house?.IsCoOwner(from) == true)
{
Hue = 0x3B2;
Movable = false;
Effects.PlaySound(Location, Map, 0x3B3);
from.SendLocalizedMessage(500461); // You destroy the item.
Destroy();
}
}
public TrashBarrel(Serial serial) : base(serial)
[AfterDeserialization]
private void AfterDeserialization()
{
if (Items.Count > 0)
{
m_Timer = new EmptyTimer(this);
m_Timer.Start();
}
}
public override int LabelNumber => 1041064; // a trash barrel
public override int DefaultMaxWeight => 0; // A value of 0 signals unlimited weight
public override bool IsDecoContainer => false;
public void OnChop(Mobile from)
private void InvalidateContents(Mobile from)
{
if (TotalItems >= 50)
{
var house = BaseHouse.FindHouseAt(from);
Empty(501478); // The trash is full! Emptying!
}
else
{
SendLocalizedMessageTo(from, 1010442); // The item will be deleted in three minutes
if (house?.IsCoOwner(from) == true)
if (m_Timer != null)
{
Effects.PlaySound(Location, Map, 0x3B3);
from.SendLocalizedMessage(500461); // You destroy the item.
Destroy();
m_Timer.Stop();
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (Items.Count > 0)
else
{
m_Timer = new EmptyTimer(this);
m_Timer.Start();
}
m_Timer.Start();
}
}
public override bool OnDragDrop(Mobile from, Item dropped)
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (base.OnDragDrop(from, dropped))
{
if (!base.OnDragDrop(from, dropped))
{
return false;
}
if (TotalItems >= 50)
{
Empty(501478); // The trash is full! Emptying!
}
else
{
SendLocalizedMessageTo(from, 1010442); // The item will be deleted in three minutes
if (m_Timer != null)
{
m_Timer.Stop();
}
else
{
m_Timer = new EmptyTimer(this);
}
m_Timer.Start();
}
InvalidateContents(from);
return true;
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
return false;
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if (base.OnDragDropInto(from, item, p))
{
if (!base.OnDragDropInto(from, item, p))
{
return false;
}
if (TotalItems >= 50)
{
Empty(501478); // The trash is full! Emptying!
}
else
{
SendLocalizedMessageTo(from, 1010442); // The item will be deleted in three minutes
if (m_Timer != null)
{
m_Timer.Stop();
}
else
{
m_Timer = new EmptyTimer(this);
}
m_Timer.Start();
}
InvalidateContents(from);
return true;
}
public void Empty(int message)
return false;
}
public void Empty(int message)
{
var items = Items;
if (items.Count > 0)
{
var items = Items;
PublicOverheadMessage(MessageType.Regular, 0x3B2, message);
if (items.Count > 0)
for (var i = items.Count - 1; i >= 0; --i)
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, message);
for (var i = items.Count - 1; i >= 0; --i)
if (i >= items.Count)
{
if (i >= items.Count)
{
continue;
}
items[i].Delete();
continue;
}
items[i].Delete();
}
m_Timer?.Stop();
m_Timer = null;
}
private class EmptyTimer : Timer
m_Timer?.Stop();
m_Timer = null;
}
private class EmptyTimer : Timer
{
private TrashBarrel _barrel;
public EmptyTimer(TrashBarrel barrel) : base(TimeSpan.FromMinutes(3.0)) => _barrel = barrel;
protected override void OnTick()
{
private readonly TrashBarrel m_Barrel;
public EmptyTimer(TrashBarrel barrel) : base(TimeSpan.FromMinutes(3.0)) => m_Barrel = barrel;
protected override void OnTick()
{
m_Barrel.Empty(501479); // Emptying the trashcan!
}
_barrel.Empty(501479); // Emptying the trashcan!
}
}
}

View file

@ -1,59 +1,40 @@
using ModernUO.Serialization;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[Flippable(0xE41, 0xE40)]
[SerializationGenerator(0, false)]
public partial class TrashChest : Container
{
[Flippable(0xE41, 0xE40)]
public class TrashChest : Container
[Constructible]
public TrashChest() : base(0xE41) => Movable = false;
public override int DefaultMaxWeight => 0; // A value of 0 signals unlimited weight
public override bool IsDecoContainer => false;
public override bool OnDragDrop(Mobile from, Item dropped)
{
[Constructible]
public TrashChest() : base(0xE41) => Movable = false;
public TrashChest(Serial serial) : base(serial)
if (base.OnDragDrop(from, dropped))
{
}
public override int DefaultMaxWeight => 0; // A value of 0 signals unlimited weight
public override bool IsDecoContainer => false;
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (!base.OnDragDrop(from, dropped))
{
return false;
}
PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1042891, 8));
dropped.Delete();
return true;
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if (!base.OnDragDropInto(from, item, p))
{
return false;
}
return false;
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if (base.OnDragDropInto(from, item, p))
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1042891, 8));
item.Delete();
return true;
}
return false;
}
}

View file

@ -1,39 +1,18 @@
namespace Server.Items
using ModernUO.Serialization;
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class TribalBerry : Item
{
public class TribalBerry : Item
[Constructible]
public TribalBerry(int amount = 1) : base(0x9D0)
{
[Constructible]
public TribalBerry(int amount = 1) : base(0x9D0)
{
Weight = 1.0;
Stackable = true;
Amount = amount;
Hue = 6;
}
public TribalBerry(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1040001; // tribal berry
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (Hue == 4)
{
Hue = 6;
}
}
Weight = 1.0;
Stackable = true;
Amount = amount;
Hue = 6;
}
public override int LabelNumber => 1040001; // tribal berry
}

View file

@ -1,4 +1,5 @@
using System;
using ModernUO.Serialization;
using Server.Factions;
using Server.Mobiles;
using Server.Spells;
@ -6,87 +7,67 @@ using Server.Spells.Fifth;
using Server.Spells.Ninjitsu;
using Server.Spells.Seventh;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class TribalPaint : Item
{
public class TribalPaint : Item
[Constructible]
public TribalPaint() : base(0x9EC)
{
[Constructible]
public TribalPaint() : base(0x9EC)
Hue = 2101;
Weight = 2.0;
Stackable = Core.ML;
}
public override int LabelNumber => 1040000; // savage kin paint
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
Hue = 2101;
Weight = 2.0;
Stackable = Core.ML;
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
return;
}
public TribalPaint(Serial serial) : base(serial)
if (Sigil.ExistsOn(from))
{
from.SendLocalizedMessage(1010465); // You cannot disguise yourself while holding a sigil.
}
public override int LabelNumber => 1040000; // savage kin paint
public override void OnDoubleClick(Mobile from)
else if (!from.CanBeginAction<IncognitoSpell>())
{
if (IsChildOf(from.Backpack))
from.SendLocalizedMessage(501698); // You cannot disguise yourself while incognitoed.
}
else if (!from.CanBeginAction<PolymorphSpell>())
{
from.SendLocalizedMessage(501699); // You cannot disguise yourself while polymorphed.
}
else if (TransformationSpellHelper.UnderTransformation(from))
{
from.SendLocalizedMessage(501699); // You cannot disguise yourself while polymorphed.
}
else if (AnimalForm.UnderTransformation(from))
{
from.SendLocalizedMessage(1061634); // You cannot disguise yourself while in that form.
}
else if (from.IsBodyMod || from.FindItemOnLayer(Layer.Helm) is OrcishKinMask)
{
from.SendLocalizedMessage(501605); // You are already disguised.
}
else
{
from.BodyMod = from.Female ? 184 : 183;
from.HueMod = 0;
if (from is PlayerMobile mobile)
{
if (Sigil.ExistsOn(from))
{
from.SendLocalizedMessage(1010465); // You cannot disguise yourself while holding a sigil.
}
else if (!from.CanBeginAction<IncognitoSpell>())
{
from.SendLocalizedMessage(501698); // You cannot disguise yourself while incognitoed.
}
else if (!from.CanBeginAction<PolymorphSpell>())
{
from.SendLocalizedMessage(501699); // You cannot disguise yourself while polymorphed.
}
else if (TransformationSpellHelper.UnderTransformation(from))
{
from.SendLocalizedMessage(501699); // You cannot disguise yourself while polymorphed.
}
else if (AnimalForm.UnderTransformation(from))
{
from.SendLocalizedMessage(1061634); // You cannot disguise yourself while in that form.
}
else if (from.IsBodyMod || from.FindItemOnLayer(Layer.Helm) is OrcishKinMask)
{
from.SendLocalizedMessage(501605); // You are already disguised.
}
else
{
from.BodyMod = from.Female ? 184 : 183;
from.HueMod = 0;
if (from is PlayerMobile mobile)
{
mobile.SavagePaintExpiration = TimeSpan.FromDays(7.0);
}
from.SendLocalizedMessage(
1042537
); // You now bear the markings of the savage tribe. Your body paint will last about a week or you can remove it with an oil cloth.
Consume();
}
mobile.SavagePaintExpiration = TimeSpan.FromDays(7.0);
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
// You now bear the markings of the savage tribe. Your body paint will last about a week or you can remove it with an oil cloth.
from.SendLocalizedMessage(1042537);
writer.Write(0);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
Consume();
}
}
}

View file

@ -1,116 +1,100 @@
using System;
using ModernUO.Serialization;
using Server.Mobiles;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class UnholyBone : Item, ICarvable
{
public class UnholyBone : Item, ICarvable
private SpawnTimer m_Timer;
[Constructible]
public UnholyBone() : base(0xF7E)
{
private SpawnTimer m_Timer;
Movable = false;
Hue = 0x497;
[Constructible]
public UnholyBone() : base(0xF7E)
m_Timer = new SpawnTimer(this);
m_Timer.Start();
}
public override string DefaultName => "unholy bone";
public void Carve(Mobile from, Item item)
{
Effects.PlaySound(GetWorldLocation(), Map, 0x48F);
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10);
if (Utility.RandomDouble() < 0.3)
{
Movable = false;
Hue = 0x497;
m_Timer = new SpawnTimer(this);
m_Timer.Start();
}
public UnholyBone(Serial serial) : base(serial)
{
}
public override string DefaultName => "unholy bone";
public void Carve(Mobile from, Item item)
{
Effects.PlaySound(GetWorldLocation(), Map, 0x48F);
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10);
if (Utility.RandomDouble() < 0.3)
if (ItemID == 0xF7E)
{
if (ItemID == 0xF7E)
{
from.SendMessage("You destroy the bone.");
}
else
{
from.SendMessage("You destroy the bone pile.");
}
var gold = new Gold(25, 100);
gold.MoveToWorld(GetWorldLocation(), Map);
Delete();
m_Timer.Stop();
from.SendMessage("You destroy the bone.");
}
else
{
if (ItemID == 0xF7E)
{
from.SendMessage("You damage the bone.");
}
else
{
from.SendMessage("You damage the bone pile.");
}
from.SendMessage("You destroy the bone pile.");
}
var gold = new Gold(25, 100);
gold.MoveToWorld(GetWorldLocation(), Map);
Delete();
m_Timer.Stop();
}
public override void Serialize(IGenericWriter writer)
else if (ItemID == 0xF7E)
{
base.Serialize(writer);
writer.Write(0); // version
from.SendMessage("You damage the bone.");
}
public override void Deserialize(IGenericReader reader)
else
{
base.Deserialize(reader);
var version = reader.ReadInt();
m_Timer = new SpawnTimer(this);
m_Timer.Start();
from.SendMessage("You damage the bone pile.");
}
}
private class SpawnTimer : Timer
[AfterDeserialization]
private void AfterDeserialize()
{
m_Timer = new SpawnTimer(this);
m_Timer.Start();
}
private class SpawnTimer : Timer
{
private Item m_Item;
public SpawnTimer(Item item) : base(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10))) => m_Item = item;
protected override void OnTick()
{
private readonly Item m_Item;
public SpawnTimer(Item item) : base(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10))) => m_Item = item;
protected override void OnTick()
if (m_Item?.Deleted != false)
{
if (m_Item.Deleted)
{
return;
}
var spawn = Utility.Random(12) switch
{
0 => (Mobile)new Skeleton(),
1 => new Zombie(),
2 => new Wraith(),
3 => new Spectre(),
4 => new Ghoul(),
5 => new Mummy(),
6 => new Bogle(),
7 => new RottingCorpse(),
8 => new BoneKnight(),
9 => new SkeletalKnight(),
10 => new Lich(),
11 => new LichLord(),
_ => new Skeleton()
};
spawn.MoveToWorld(m_Item.Location, m_Item.Map);
m_Item.Delete();
return;
}
Mobile spawn = Utility.Random(12) switch
{
0 => new Skeleton(),
1 => new Zombie(),
2 => new Wraith(),
3 => new Spectre(),
4 => new Ghoul(),
5 => new Mummy(),
6 => new Bogle(),
7 => new RottingCorpse(),
8 => new BoneKnight(),
9 => new SkeletalKnight(),
10 => new Lich(),
11 => new LichLord(),
_ => new Skeleton()
};
spawn.MoveToWorld(m_Item.Location, m_Item.Map);
m_Item.Delete();
}
}
}

View file

@ -1,237 +1,162 @@
using System;
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(1, false)]
public partial class WarningItem : Item
{
public class WarningItem : Item
private bool m_Broadcasting;
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private TextDefinition _warningMessage;
// Field 1
private int _range;
[SerializableField(2)]
private TimeSpan _resetDelay;
private DateTime m_LastBroadcast;
[Constructible]
public WarningItem(int itemID, int range, int warning) : base(itemID)
{
private bool m_Broadcasting;
Movable = false;
private DateTime m_LastBroadcast;
private int m_Range;
_warningMessage = warning;
_range = Math.Min(range, 18);
}
[Constructible]
public WarningItem(int itemID, int range, int warning) : base(itemID)
[Constructible]
public WarningItem(int itemID, int range, string warning) : base(itemID)
{
Movable = false;
_warningMessage = warning;
_range = Math.Min(range, 18);
}
[CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(1, useField: nameof(_range))]
public int Range
{
get => _range;
set
{
if (range > 18)
{
range = 18;
}
Movable = false;
WarningNumber = warning;
m_Range = range;
}
[Constructible]
public WarningItem(int itemID, int range, string warning) : base(itemID)
{
if (range > 18)
{
range = 18;
}
Movable = false;
WarningString = warning;
m_Range = range;
}
public WarningItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public string WarningString { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int WarningNumber { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Range
{
get => m_Range;
set
{
if (value > 18)
{
value = 18;
}
m_Range = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan ResetDelay { get; set; }
public virtual bool OnlyToTriggerer => false;
public virtual int NeighborRange => 5;
public override bool HandlesOnMovement => true;
public virtual void SendMessage(Mobile triggerer, bool onlyToTriggerer, string messageString, int messageNumber)
{
if (onlyToTriggerer)
{
if (messageString != null)
{
triggerer.SendMessage(messageString);
}
else
{
triggerer.SendLocalizedMessage(messageNumber);
}
}
else
{
if (messageString != null)
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, false, messageString);
}
else
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, messageNumber);
}
}
}
public virtual void Broadcast(Mobile triggerer)
{
if (m_Broadcasting || Core.Now < m_LastBroadcast + ResetDelay)
{
return;
}
m_LastBroadcast = Core.Now;
m_Broadcasting = true;
SendMessage(triggerer, OnlyToTriggerer, WarningString, WarningNumber);
if (NeighborRange >= 0)
{
var list = new List<WarningItem>();
foreach (var item in GetItemsInRange(NeighborRange))
{
if (item != this && item is WarningItem warningItem)
{
list.Add(warningItem);
}
}
for (var i = 0; i < list.Count; i++)
{
list[i].Broadcast(triggerer);
}
}
Timer.StartTimer(StopBroadcasting);
}
private void StopBroadcasting()
{
m_Broadcasting = false;
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m.Player && Utility.InRange(m.Location, Location, m_Range) &&
!Utility.InRange(oldLocation, Location, m_Range))
{
Broadcast(m);
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(WarningString);
writer.Write(WarningNumber);
writer.Write(m_Range);
writer.Write(ResetDelay);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
WarningString = reader.ReadString();
WarningNumber = reader.ReadInt();
m_Range = reader.ReadInt();
ResetDelay = reader.ReadTimeSpan();
break;
}
}
_range = Math.Min(value, 18);
this.MarkDirty();
}
}
public class HintItem : WarningItem
public virtual bool OnlyToTriggerer => false;
public virtual int NeighborRange => 5;
public override bool HandlesOnMovement => true;
public virtual void SendMessage(Mobile triggerer, bool onlyToTriggerer, TextDefinition warningMessage)
{
[Constructible]
public HintItem(int itemID, int range, int warning, int hint) : base(itemID, range, warning) => HintNumber = hint;
[Constructible]
public HintItem(int itemID, int range, string warning, string hint) : base(itemID, range, warning) =>
HintString = hint;
public HintItem(Serial serial) : base(serial)
if (onlyToTriggerer)
{
warningMessage.SendMessageTo(triggerer);
}
else
{
warningMessage.PublicOverheadMessage(this, MessageType.Regular, 0x3B2);
}
}
public virtual void Broadcast(Mobile triggerer)
{
if (m_Broadcasting || Core.Now < m_LastBroadcast + ResetDelay)
{
return;
}
[CommandProperty(AccessLevel.GameMaster)]
public string HintString { get; set; }
m_LastBroadcast = Core.Now;
[CommandProperty(AccessLevel.GameMaster)]
public int HintNumber { get; set; }
m_Broadcasting = true;
public override bool OnlyToTriggerer => true;
SendMessage(triggerer, OnlyToTriggerer, _warningMessage);
public override void OnDoubleClick(Mobile from)
if (NeighborRange >= 0)
{
SendMessage(from, true, HintString, HintNumber);
}
var list = new List<WarningItem>();
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(HintString);
writer.Write(HintNumber);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
foreach (var item in GetItemsInRange(NeighborRange))
{
case 0:
{
HintString = reader.ReadString();
HintNumber = reader.ReadInt();
if (item != this && item is WarningItem warningItem)
{
list.Add(warningItem);
}
}
break;
}
for (var i = 0; i < list.Count; i++)
{
list[i].Broadcast(triggerer);
}
}
Timer.StartTimer(StopBroadcasting);
}
private void StopBroadcasting()
{
m_Broadcasting = false;
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m.Player && Utility.InRange(m.Location, Location, _range) &&
!Utility.InRange(oldLocation, Location, _range))
{
Broadcast(m);
}
}
public void Deserialize(IGenericReader reader, int version)
{
var warningMessageString = reader.ReadString();
var warningMessageInt = reader.ReadInt();
_range = reader.ReadInt();
ResetDelay = reader.ReadTimeSpan();
_warningMessage = warningMessageInt > 0 ? warningMessageInt : warningMessageString;
}
}
[SerializationGenerator(1, false)]
public partial class HintItem : WarningItem
{
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private TextDefinition _hintMessage;
[Constructible]
public HintItem(int itemID, int range, int warning, int hint) : base(itemID, range, warning) =>
_hintMessage = hint;
[Constructible]
public HintItem(int itemID, int range, string warning, string hint) : base(itemID, range, warning) =>
_hintMessage = hint;
public override bool OnlyToTriggerer => true;
public override void OnDoubleClick(Mobile from)
{
SendMessage(from, true, _hintMessage);
}
private void Deserialize(IGenericReader reader, int version)
{
var hintMessageString = reader.ReadString();
var hintMessageInt = reader.ReadInt();
_hintMessage = hintMessageInt > 0 ? hintMessageInt : hintMessageString;
}
}

View file

@ -1,155 +1,116 @@
using ModernUO.Serialization;
using Server.Targeting;
namespace Server.Items
namespace Server.Items;
[Flippable(0x1f14, 0x1f15, 0x1f16, 0x1f17)]
[SerializationGenerator(0, false)]
public partial class WayPoint : Item
{
[Flippable(0x1f14, 0x1f15, 0x1f16, 0x1f17)]
public class WayPoint : Item
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private WayPoint _nextPoint;
[Constructible]
public WayPoint(WayPoint prev = null) : base(0x1f14)
{
private WayPoint m_Next;
Hue = 0x498;
Visible = false;
// this.Movable = false;
[Constructible]
public WayPoint(WayPoint prev = null) : base(0x1f14)
if (prev != null)
{
Hue = 0x498;
Visible = false;
// this.Movable = false;
if (prev != null)
{
prev.NextPoint = this;
}
}
public WayPoint(Serial serial) : base(serial)
{
}
public override string DefaultName => "AI Way Point";
[CommandProperty(AccessLevel.GameMaster)]
public WayPoint NextPoint
{
get => m_Next;
set
{
if (m_Next != this)
{
m_Next = value;
}
}
}
public static void Initialize()
{
CommandSystem.Register("WayPointSeq", AccessLevel.GameMaster, WayPointSeq_OnCommand);
}
public static void WayPointSeq_OnCommand(CommandEventArgs arg)
{
arg.Mobile.SendMessage("Target the position of the first way point.");
arg.Mobile.Target = new WayPointSeqTarget(null);
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendMessage("Target the next way point in the sequence.");
from.Target = new NextPointTarget(this);
}
}
public override void OnSingleClick(Mobile from)
{
base.OnSingleClick(from);
if (m_Next == null)
{
LabelTo(from, "(Unlinked)");
}
else
{
LabelTo(from, "(Linked: {0})", m_Next.Location);
}
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
m_Next = reader.ReadEntity<WayPoint>();
break;
}
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(m_Next);
prev.NextPoint = this;
}
}
public class NextPointTarget : Target
public override string DefaultName => "AI Way Point";
public static void Initialize()
{
private readonly WayPoint m_Point;
CommandSystem.Register("WayPointSeq", AccessLevel.GameMaster, WayPointSeq_OnCommand);
}
public NextPointTarget(WayPoint pt) : base(-1, false, TargetFlags.None) => m_Point = pt;
public static void WayPointSeq_OnCommand(CommandEventArgs arg)
{
arg.Mobile.SendMessage("Target the position of the first way point.");
arg.Mobile.Target = new WayPointSeqTarget(null);
}
protected override void OnTarget(Mobile from, object target)
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
{
if (target is WayPoint point && m_Point != null)
{
m_Point.NextPoint = point;
}
else
{
from.SendMessage("Target a way point.");
}
from.SendMessage("Target the next way point in the sequence.");
from.Target = new NextPointTarget(this);
}
}
public class WayPointSeqTarget : Target
public override void OnSingleClick(Mobile from)
{
private readonly WayPoint m_Last;
base.OnSingleClick(from);
public WayPointSeqTarget(WayPoint last) : base(-1, true, TargetFlags.None) => m_Last = last;
protected override void OnTarget(Mobile from, object targeted)
if (_nextPoint == null)
{
if (targeted is WayPoint wayPoint)
{
if (m_Last != null)
{
m_Last.NextPoint = wayPoint;
}
}
else if (targeted is IPoint3D d)
{
var p = new Point3D(d);
var point = new WayPoint(m_Last);
point.MoveToWorld(p, from.Map);
from.Target = new WayPointSeqTarget(point);
from.SendMessage(
"Target the position of the next way point in the sequence, or target a way point link the newest way point to."
);
}
else
{
from.SendMessage("Target a position, or another way point.");
}
LabelTo(from, "(Unlinked)");
}
else
{
LabelTo(from, "(Linked: {0})", _nextPoint.Location);
}
}
}
public class NextPointTarget : Target
{
private WayPoint _point;
public NextPointTarget(WayPoint pt) : base(-1, false, TargetFlags.None) => _point = pt;
protected override void OnTarget(Mobile from, object target)
{
if (target is WayPoint point && _point != null)
{
_point.NextPoint = point;
}
else
{
from.SendMessage("Target a way point.");
}
}
}
public class WayPointSeqTarget : Target
{
private WayPoint _last;
public WayPointSeqTarget(WayPoint last) : base(-1, true, TargetFlags.None) => _last = last;
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is WayPoint wayPoint)
{
if (_last != null)
{
_last.NextPoint = wayPoint;
}
}
else if (targeted is IPoint3D d)
{
var p = new Point3D(d);
var point = new WayPoint(_last);
point.MoveToWorld(p, from.Map);
from.Target = new WayPointSeqTarget(point);
from.SendMessage(
"Target the position of the next way point in the sequence, or target a way point link the newest way point to."
);
}
else
{
from.SendMessage("Target a position, or another way point.");
}
}
}

View file

@ -1,188 +1,120 @@
using ModernUO.Serialization;
using Server.Gumps;
using Server.Multis;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public abstract partial class BaseWindChimes : Item
{
public abstract class BaseWindChimes : Item
[InvalidateProperties]
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _turnedOn;
public BaseWindChimes(int itemID) : base(itemID)
{
private bool m_TurnedOn;
}
public BaseWindChimes(int itemID) : base(itemID)
public static int[] Sounds { get; } = { 0x505, 0x506, 0x507 };
public override bool HandlesOnMovement => _turnedOn && IsLockedDown;
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (_turnedOn && IsLockedDown && (!m.Hidden || m.AccessLevel == AccessLevel.Player) &&
Utility.InRange(m.Location, Location, 2) && !Utility.InRange(oldLocation, Location, 2))
{
Effects.PlaySound(Location, Map, Sounds.RandomElement());
}
public BaseWindChimes(Serial serial) : base(serial)
base.OnMovement(m, oldLocation);
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
if (_turnedOn)
{
list.Add(502695); // turned on
}
[CommandProperty(AccessLevel.GameMaster)]
public bool TurnedOn
else
{
get => m_TurnedOn;
set
{
m_TurnedOn = value;
InvalidateProperties();
}
}
public static int[] Sounds { get; } = { 0x505, 0x506, 0x507 };
public override bool HandlesOnMovement => m_TurnedOn && IsLockedDown;
public override void OnMovement(Mobile m, Point3D oldLocation)
{
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.RandomElement());
}
base.OnMovement(m, oldLocation);
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
if (m_TurnedOn)
{
list.Add(502695); // turned on
}
else
{
list.Add(502696); // turned off
}
}
public bool IsOwner(Mobile mob) => BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
public override void OnDoubleClick(Mobile from)
{
if (IsOwner(from))
{
from.SendGump(new OnOffGump(this));
}
else
{
from.SendLocalizedMessage(502691); // You must be the owner to use this.
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(m_TurnedOn);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
m_TurnedOn = reader.ReadBool();
break;
}
}
}
private class OnOffGump : Gump
{
private readonly BaseWindChimes m_Chimes;
public OnOffGump(BaseWindChimes chimes) : base(150, 200)
{
m_Chimes = chimes;
AddBackground(0, 0, 300, 150, 0xA28);
AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034); // [De]Activate this item
AddButton(40, 53, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY
AddButton(150, 53, 0xFA5, 0xFA7, 0);
AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState sender, RelayInfo info)
{
var from = sender.Mobile;
if (info.ButtonID == 1)
{
var newValue = !m_Chimes.TurnedOn;
m_Chimes.TurnedOn = newValue;
if (newValue && !m_Chimes.IsLockedDown)
{
from.SendLocalizedMessage(502693); // Remember, this only works when locked down.
}
}
else
{
from.SendLocalizedMessage(502694); // Cancelled action.
}
}
list.Add(502696); // turned off
}
}
public class WindChimes : BaseWindChimes
public bool IsOwner(Mobile mob) => BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
public override void OnDoubleClick(Mobile from)
{
[Constructible]
public WindChimes() : base(0x2832)
if (IsOwner(from))
{
from.SendGump(new OnOffGump(this));
}
public WindChimes(Serial serial) : base(serial)
else
{
}
public override int LabelNumber => 1030290;
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
from.SendLocalizedMessage(502691); // You must be the owner to use this.
}
}
public class FancyWindChimes : BaseWindChimes
private class OnOffGump : Gump
{
[Constructible]
public FancyWindChimes() : base(0x2833)
private readonly BaseWindChimes m_Chimes;
public OnOffGump(BaseWindChimes chimes) : base(150, 200)
{
m_Chimes = chimes;
AddBackground(0, 0, 300, 150, 0xA28);
AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034); // [De]Activate this item
AddButton(40, 53, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY
AddButton(150, 53, 0xFA5, 0xFA7, 0);
AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL
}
public FancyWindChimes(Serial serial) : base(serial)
public override void OnResponse(NetState sender, RelayInfo info)
{
}
var from = sender.Mobile;
public override int LabelNumber => 1030291;
if (info.ButtonID == 1)
{
var newValue = !m_Chimes.TurnedOn;
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
m_Chimes.TurnedOn = newValue;
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (newValue && !m_Chimes.IsLockedDown)
{
from.SendLocalizedMessage(502693); // Remember, this only works when locked down.
}
}
else
{
from.SendLocalizedMessage(502694); // Cancelled action.
}
}
}
}
[SerializationGenerator(0, false)]
public partial class WindChimes : BaseWindChimes
{
[Constructible]
public WindChimes() : base(0x2832)
{
}
}
[SerializationGenerator(0, false)]
public partial class FancyWindChimes : BaseWindChimes
{
[Constructible]
public FancyWindChimes() : base(0x2833)
{
}
public override int LabelNumber => 1030291;
}

View file

@ -0,0 +1,14 @@
{
"version": 0,
"type": "Server.Items.BaseWindChimes",
"properties": [
{
"name": "TurnedOn",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
}
]
}

View file

@ -0,0 +1,24 @@
{
"version": 1,
"type": "Server.Items.ControlPanel",
"properties": [
{
"name": "SideLength",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Path",
"type": "Server.Point2D[]",
"rule": "ArrayMigrationRule",
"ruleArguments": [
"Server.Point2D",
"PrimitiveUOTypeMigrationRule",
"Point2D"
]
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.FancyWindChimes"
}

View file

@ -0,0 +1,14 @@
{
"version": 1,
"type": "Server.Items.HintItem",
"properties": [
{
"name": "HintMessage",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"TextDefinition"
]
}
]
}

View file

@ -0,0 +1,30 @@
{
"version": 0,
"type": "Server.Items.KeywordTeleporter",
"properties": [
{
"name": "Substring",
"type": "string",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Keyword",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Range",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
}
]
}

View file

@ -0,0 +1,14 @@
{
"version": 0,
"type": "Server.Items.LocalizedStatic",
"properties": [
{
"name": "Number",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
"EncodedInt"
]
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.PowerGenerator"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.Scales"
}

View file

@ -0,0 +1,30 @@
{
"version": 0,
"type": "Server.Items.SerpentPillar",
"properties": [
{
"name": "Active",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Word",
"type": "string",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Destination",
"type": "Server.Rectangle2D",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Rect2D"
]
}
]
}

View file

@ -0,0 +1,28 @@
{
"version": 1,
"type": "Server.Items.SkillTeleporter",
"properties": [
{
"name": "Skill",
"type": "Server.SkillName",
"rule": "EnumMigrationRule"
},
{
"name": "Required",
"type": "double",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Message",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"@CanBeNull",
"TextDefinition"
]
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SpecialBeardDye"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SpecialHairDye"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.Static"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SwarmOfFlies"
}

View file

@ -0,0 +1,40 @@
{
"version": 5,
"type": "Server.Items.Teleporter",
"properties": [
{
"name": "Flags",
"type": "Server.Items.TeleporterFlags",
"rule": "EnumMigrationRule"
},
{
"name": "Delay",
"type": "System.TimeSpan",
"rule": "PrimitiveTypeMigrationRule"
},
{
"name": "SoundID",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
"EncodedInt"
]
},
{
"name": "PointDest",
"type": "Server.Point3D",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Point3D"
]
},
{
"name": "MapDest",
"type": "Server.Map",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Map"
]
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.TrashBarrel"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.TrashChest"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.TribalBerry"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.TribalPaint"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.UnholyBone"
}

View file

@ -0,0 +1,32 @@
{
"version": 1,
"type": "Server.Items.WaitTeleporter",
"properties": [
{
"name": "StartMessage",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"@CanBeNull",
"TextDefinition"
]
},
{
"name": "ProgressMessage",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"@CanBeNull",
"TextDefinition"
]
},
{
"name": "ShowTimeRemaining",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
}
]
}

View file

@ -0,0 +1,27 @@
{
"version": 1,
"type": "Server.Items.WarningItem",
"properties": [
{
"name": "WarningMessage",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"TextDefinition"
]
},
{
"name": "Range",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "ResetDelay",
"type": "System.TimeSpan",
"rule": "PrimitiveTypeMigrationRule"
}
]
}

View file

@ -0,0 +1,11 @@
{
"version": 0,
"type": "Server.Items.WayPoint",
"properties": [
{
"name": "NextPoint",
"type": "Server.Items.WayPoint",
"rule": "SerializableInterfaceMigrationRule"
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.WindChimes"
}