diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs index 2a948b96d..565fec925 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs @@ -1,273 +1,229 @@ using System; using System.Collections.Generic; +using ModernUO.Serialization; using Server.ContextMenus; using Server.Engines.Craft; using Server.Engines.Harvest; using Server.Mobiles; using Server.Network; -namespace Server.Items +namespace Server.Items; + +public interface IUsesRemaining { - public interface IUsesRemaining + int UsesRemaining { get; set; } + bool ShowUsesRemaining { get; set; } +} + +[SerializationGenerator(2, false)] +public abstract partial class BaseHarvestTool : Item, IUsesRemaining, ICraftable +{ + [InvalidateProperties] + [SerializableField(0)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private string _crafter; + + [InvalidateProperties] + [SerializableField(2)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _usesRemaining; + + public BaseHarvestTool(int itemID, int usesRemaining = 50) : base(itemID) { - int UsesRemaining { get; set; } - bool ShowUsesRemaining { get; set; } + _usesRemaining = usesRemaining; + _quality = ToolQuality.Regular; } - public abstract class BaseHarvestTool : Item, IUsesRemaining, ICraftable + [SerializableProperty(1)] + [CommandProperty(AccessLevel.GameMaster)] + public ToolQuality Quality { - private Mobile m_Crafter; - private ToolQuality m_Quality; - private int m_UsesRemaining; - - public BaseHarvestTool(int itemID, int usesRemaining = 50) : base(itemID) + get => _quality; + set { - m_UsesRemaining = usesRemaining; - m_Quality = ToolQuality.Regular; - } - - public BaseHarvestTool(Serial serial) : base(serial) - { - } - - [CommandProperty(AccessLevel.GameMaster)] - public Mobile Crafter - { - get => m_Crafter; - set - { - m_Crafter = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public ToolQuality Quality - { - get => m_Quality; - set - { - UnscaleUses(); - m_Quality = value; - InvalidateProperties(); - ScaleUses(); - } - } - - public abstract HarvestSystem HarvestSystem { get; } - - public int OnCraft( - int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, - CraftItem craftItem, int resHue - ) - { - Quality = (ToolQuality)quality; - - if (makersMark) - { - Crafter = from; - } - - return quality; - } - - [CommandProperty(AccessLevel.GameMaster)] - public int UsesRemaining - { - get => m_UsesRemaining; - set - { - m_UsesRemaining = value; - InvalidateProperties(); - } - } - - bool IUsesRemaining.ShowUsesRemaining - { - get => true; - set { } - } - - public void ScaleUses() - { - m_UsesRemaining = m_UsesRemaining * GetUsesScalar() / 100; + UnscaleUses(); + _quality = value; InvalidateProperties(); + ScaleUses(); + this.MarkDirty(); + } + } + + public abstract HarvestSystem HarvestSystem { get; } + + public int OnCraft( + int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, + CraftItem craftItem, int resHue + ) + { + Quality = (ToolQuality)quality; + + if (makersMark) + { + Crafter = from?.RawName; } - public void UnscaleUses() + return quality; + } + + bool IUsesRemaining.ShowUsesRemaining + { + get => true; + set { } + } + + public void ScaleUses() + { + _usesRemaining = _usesRemaining * GetUsesScalar() / 100; + InvalidateProperties(); + } + + public void UnscaleUses() + { + _usesRemaining = _usesRemaining * 100 / GetUsesScalar(); + } + + public int GetUsesScalar() => _quality == ToolQuality.Exceptional ? 200 : 100; + + public override void GetProperties(IPropertyList list) + { + base.GetProperties(list); + + // Makers mark not displayed on OSI + // if (m_Crafter != null) + // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ + + if (_quality == ToolQuality.Exceptional) { - m_UsesRemaining = m_UsesRemaining * 100 / GetUsesScalar(); + list.Add(1060636); // exceptional } - public int GetUsesScalar() - { - if (m_Quality == ToolQuality.Exceptional) - { - return 200; - } + list.Add(1060584, _usesRemaining); // uses remaining: ~1_val~ + } - return 100; + public virtual void DisplayDurabilityTo(Mobile m) + { + LabelToAffix(m, 1017323, AffixType.Append, $": {_usesRemaining}"); // Durability + } + + public override void OnSingleClick(Mobile from) + { + DisplayDurabilityTo(from); + + base.OnSingleClick(from); + } + + public override void OnDoubleClick(Mobile from) + { + if (IsChildOf(from.Backpack) || Parent == from) + { + HarvestSystem.BeginHarvesting(from, this); + } + else + { + from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } + } + + public override void GetContextMenuEntries(Mobile from, List list) + { + base.GetContextMenuEntries(from, list); + + AddContextMenuEntries(from, this, list, HarvestSystem); + } + + public static void AddContextMenuEntries(Mobile from, Item item, List list, HarvestSystem system) + { + if (system != Mining.System) + { + return; } - public override void GetProperties(IPropertyList list) + if (!item.IsChildOf(from.Backpack) && item.Parent != from) { - base.GetProperties(list); - - // Makers mark not displayed on OSI - // if (m_Crafter != null) - // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ - - if (m_Quality == ToolQuality.Exceptional) - { - list.Add(1060636); // exceptional - } - - list.Add(1060584, m_UsesRemaining); // uses remaining: ~1_val~ + return; } - public virtual void DisplayDurabilityTo(Mobile m) + if (from is not PlayerMobile pm) { - LabelToAffix(m, 1017323, AffixType.Append, $": {m_UsesRemaining}"); // Durability + return; } - public override void OnSingleClick(Mobile from) + var miningEntry = new ContextMenuEntry(pm.ToggleMiningStone ? 6179 : 6178); + miningEntry.Color = 0x421F; + list.Add(miningEntry); + + list.Add(new ToggleMiningStoneEntry(pm, false, 6176)); + list.Add(new ToggleMiningStoneEntry(pm, true, 6177)); + } + + private void Deserialize(IGenericReader reader, int version) + { + var crafter = reader.ReadEntity(); + _quality = (ToolQuality)reader.ReadInt(); + _usesRemaining = reader.ReadInt(); + + if (crafter != null) { - DisplayDurabilityTo(from); - - base.OnSingleClick(from); - } - - public override void OnDoubleClick(Mobile from) - { - if (IsChildOf(from.Backpack) || Parent == from) - { - HarvestSystem.BeginHarvesting(from, this); - } - else - { - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. - } - } - - public override void GetContextMenuEntries(Mobile from, List list) - { - base.GetContextMenuEntries(from, list); - - AddContextMenuEntries(from, this, list, HarvestSystem); - } - - public static void AddContextMenuEntries(Mobile from, Item item, List list, HarvestSystem system) - { - if (system != Mining.System) - { - return; - } - - if (!item.IsChildOf(from.Backpack) && item.Parent != from) - { - return; - } - - if (from is not PlayerMobile pm) - { - return; - } - - var miningEntry = new ContextMenuEntry(pm.ToggleMiningStone ? 6179 : 6178); - miningEntry.Color = 0x421F; - list.Add(miningEntry); - - list.Add(new ToggleMiningStoneEntry(pm, false, 6176)); - list.Add(new ToggleMiningStoneEntry(pm, true, 6177)); - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(1); // version - - writer.Write(m_Crafter); - writer.Write((int)m_Quality); - - writer.Write(m_UsesRemaining); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 1: - { - m_Crafter = reader.ReadEntity(); - m_Quality = (ToolQuality)reader.ReadInt(); - goto case 0; - } - case 0: - { - m_UsesRemaining = reader.ReadInt(); - break; - } - } - } - - private class ToggleMiningStoneEntry : ContextMenuEntry - { - private readonly PlayerMobile m_Mobile; - private readonly bool m_Value; - - public ToggleMiningStoneEntry(PlayerMobile mobile, bool value, int number) : base(number) - { - m_Mobile = mobile; - m_Value = value; - - var stoneMining = mobile.StoneMining && mobile.Skills.Mining.Base >= 100.0; - - if (mobile.ToggleMiningStone == value || value && !stoneMining) + Timer.DelayCall( + (tool, m) => { - Flags |= CMEFlags.Disabled; + tool._crafter = m.RawName; + }, + this, + crafter + ); + } + } + + private class ToggleMiningStoneEntry : ContextMenuEntry + { + private PlayerMobile _mobile; + private bool _value; + + public ToggleMiningStoneEntry(PlayerMobile mobile, bool value, int number) : base(number) + { + _mobile = mobile; + _value = value; + + var stoneMining = mobile.StoneMining && mobile.Skills.Mining.Base >= 100.0; + + if (mobile.ToggleMiningStone == value || value && !stoneMining) + { + Flags |= CMEFlags.Disabled; + } + } + + public override void OnClick() + { + var oldValue = _mobile.ToggleMiningStone; + + if (_value) + { + if (oldValue) + { + _mobile.SendLocalizedMessage(1054023); // You are already set to mine both ore and stone! } - } - - public override void OnClick() - { - var oldValue = m_Mobile.ToggleMiningStone; - - if (m_Value) + else if (!_mobile.StoneMining || _mobile.Skills.Mining.Base < 100.0) { - if (oldValue) - { - m_Mobile.SendLocalizedMessage(1054023); // You are already set to mine both ore and stone! - } - else if (!m_Mobile.StoneMining || m_Mobile.Skills.Mining.Base < 100.0) - { - m_Mobile.SendLocalizedMessage( - 1054024 - ); // You have not learned how to mine stone or you do not have enough skill! - } - else - { - m_Mobile.ToggleMiningStone = true; - m_Mobile.SendLocalizedMessage(1054022); // You are now set to mine both ore and stone. - } + // You have not learned how to mine stone or you do not have enough skill! + _mobile.SendLocalizedMessage(1054024); } else { - if (oldValue) - { - m_Mobile.ToggleMiningStone = false; - m_Mobile.SendLocalizedMessage(1054020); // You are now set to mine only ore. - } - else - { - m_Mobile.SendLocalizedMessage(1054021); // You are already set to mine only ore! - } + _mobile.ToggleMiningStone = true; + _mobile.SendLocalizedMessage(1054022); // You are now set to mine both ore and stone. } } + else if (oldValue) + { + _mobile.ToggleMiningStone = false; + _mobile.SendLocalizedMessage(1054020); // You are now set to mine only ore. + } + else + { + _mobile.SendLocalizedMessage(1054021); // You are already set to mine only ore! + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs index bf4efee97..52335a4d1 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs @@ -1,65 +1,43 @@ +using ModernUO.Serialization; using Server.Engines.Harvest; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GargoylesPickaxe : BaseAxe, IUsesRemaining { - public class GargoylesPickaxe : BaseAxe, IUsesRemaining + [Constructible] + public GargoylesPickaxe() : this(Utility.RandomMinMax(101, 125)) { - [Constructible] - public GargoylesPickaxe() : this(Utility.RandomMinMax(101, 125)) - { - } - - [Constructible] - public GargoylesPickaxe(int uses) : base(0xE85 + Utility.Random(2)) - { - Weight = 11.0; - UsesRemaining = uses; - ShowUsesRemaining = true; - } - - public GargoylesPickaxe(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1041281; // a gargoyle's pickaxe - public override HarvestSystem HarvestSystem => Mining.System; - - public override WeaponAbility PrimaryAbility => WeaponAbility.DoubleStrike; - public override WeaponAbility SecondaryAbility => WeaponAbility.Disarm; - - public override int AosStrengthReq => 50; - public override int AosMinDamage => 13; - public override int AosMaxDamage => 15; - public override int AosSpeed => 35; - public override float MlSpeed => 3.00f; - - public override int OldStrengthReq => 25; - public override int OldMinDamage => 1; - public override int OldMaxDamage => 15; - public override int OldSpeed => 35; - - public override int InitMinHits => 31; - public override int InitMaxHits => 60; - - public override WeaponAnimation DefAnimation => WeaponAnimation.Slash1H; - - 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 (Hue == 0x973) - { - Hue = 0x0; - } - } } + + [Constructible] + public GargoylesPickaxe(int uses) : base(0xE85 + Utility.Random(2)) + { + Weight = 11.0; + UsesRemaining = uses; + ShowUsesRemaining = true; + } + + public override int LabelNumber => 1041281; // a gargoyle's pickaxe + public override HarvestSystem HarvestSystem => Mining.System; + + public override WeaponAbility PrimaryAbility => WeaponAbility.DoubleStrike; + public override WeaponAbility SecondaryAbility => WeaponAbility.Disarm; + + public override int AosStrengthReq => 50; + public override int AosMinDamage => 13; + public override int AosMaxDamage => 15; + public override int AosSpeed => 35; + public override float MlSpeed => 3.00f; + + public override int OldStrengthReq => 25; + public override int OldMinDamage => 1; + public override int OldMaxDamage => 15; + public override int OldSpeed => 35; + + public override int InitMinHits => 31; + public override int InitMaxHits => 60; + + public override WeaponAnimation DefAnimation => WeaponAnimation.Slash1H; } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs index 1a1363be4..afe2359c8 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs @@ -1,178 +1,138 @@ using System; +using ModernUO.Serialization; using Server.Engines.Harvest; using Server.Targeting; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class ProspectorsTool : BaseBashing, IUsesRemaining { - public class ProspectorsTool : BaseBashing, IUsesRemaining + [InvalidateProperties] + [SerializableField(0)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _usesRemaining; + + [Constructible] + public ProspectorsTool() : base(0xFB4) { - private int m_UsesRemaining; + Weight = 9.0; + UsesRemaining = 50; + } - [Constructible] - public ProspectorsTool() : base(0xFB4) + public override int LabelNumber => 1049065; // prospector's tool + + public override WeaponAbility PrimaryAbility => WeaponAbility.CrushingBlow; + public override WeaponAbility SecondaryAbility => WeaponAbility.ShadowStrike; + + public override int AosStrengthReq => 40; + public override int AosMinDamage => 13; + public override int AosMaxDamage => 15; + public override int AosSpeed => 33; + + public override int OldStrengthReq => 10; + public override int OldMinDamage => 6; + public override int OldMaxDamage => 8; + public override int OldSpeed => 33; + + bool IUsesRemaining.ShowUsesRemaining + { + get => true; + set { } + } + + public override void OnDoubleClick(Mobile from) + { + if (IsChildOf(from.Backpack) || Parent == from) { - Weight = 9.0; - UsesRemaining = 50; + from.Target = new InternalTarget(this); + } + else + { + from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } + } + + public void Prospect(Mobile from, object toProspect) + { + if (!IsChildOf(from.Backpack) && Parent != from) + { + from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + return; } - public ProspectorsTool(Serial serial) : base(serial) + HarvestSystem system = Mining.System; + + if (!system.GetHarvestDetails(from, this, toProspect, out var tileID, out var map, out var loc)) { + from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. + return; } - public override int LabelNumber => 1049065; // prospector's tool + var def = system.GetDefinition(tileID); - public override WeaponAbility PrimaryAbility => WeaponAbility.CrushingBlow; - public override WeaponAbility SecondaryAbility => WeaponAbility.ShadowStrike; - - public override int AosStrengthReq => 40; - public override int AosMinDamage => 13; - public override int AosMaxDamage => 15; - public override int AosSpeed => 33; - - public override int OldStrengthReq => 10; - public override int OldMinDamage => 6; - public override int OldMaxDamage => 8; - public override int OldSpeed => 33; - - [CommandProperty(AccessLevel.GameMaster)] - public int UsesRemaining + if (def == null || def.Veins.Length <= 1) { - get => m_UsesRemaining; - set - { - m_UsesRemaining = value; - InvalidateProperties(); - } + from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. + return; } - bool IUsesRemaining.ShowUsesRemaining + var bank = def.GetBank(map, loc.X, loc.Y); + + if (bank == null) { - get => true; - set { } + from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. + return; } - public override void OnDoubleClick(Mobile from) + HarvestVein vein = bank.Vein, defaultVein = bank.DefaultVein; + + if (vein == null || defaultVein == null) { - if (IsChildOf(from.Backpack) || Parent == from) - { - from.Target = new InternalTarget(this); - } - else - { - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. - } + from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. + return; } - public void Prospect(Mobile from, object toProspect) + if (vein != defaultVein) { - if (!IsChildOf(from.Backpack) && Parent != from) - { - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. - return; - } - - HarvestSystem system = Mining.System; - - if (!system.GetHarvestDetails(from, this, toProspect, out var tileID, out var map, out var loc)) - { - from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. - return; - } - - var def = system.GetDefinition(tileID); - - if (def == null || def.Veins.Length <= 1) - { - from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. - return; - } - - var bank = def.GetBank(map, loc.X, loc.Y); - - if (bank == null) - { - from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. - return; - } - - HarvestVein vein = bank.Vein, defaultVein = bank.DefaultVein; - - if (vein == null || defaultVein == null) - { - from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. - return; - } - - if (vein != defaultVein) - { - from.SendLocalizedMessage(1049049); // That ore looks to be prospected already. - return; - } - - var veinIndex = Array.IndexOf(def.Veins, vein); - - if (veinIndex < 0) - { - from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. - } - else if (veinIndex >= def.Veins.Length - 1) - { - from.SendLocalizedMessage(1049061); // You cannot improve valorite ore through prospecting. - } - else - { - bank.Vein = def.Veins[veinIndex + 1]; - from.SendLocalizedMessage(1049050 + veinIndex); - - --UsesRemaining; - - if (UsesRemaining <= 0) - { - from.SendLocalizedMessage(1049062); // You have used up your prospector's tool. - Delete(); - } - } + from.SendLocalizedMessage(1049049); // That ore looks to be prospected already. + return; } - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); + var veinIndex = Array.IndexOf(def.Veins, vein); - writer.Write(1); // version - writer.Write(m_UsesRemaining); + if (veinIndex < 0) + { + from.SendLocalizedMessage(1049048); // You cannot use your prospector tool on that. } - - public override void Deserialize(IGenericReader reader) + else if (veinIndex >= def.Veins.Length - 1) { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 1: - { - m_UsesRemaining = reader.ReadInt(); - break; - } - case 0: - { - m_UsesRemaining = 50; - break; - } - } + from.SendLocalizedMessage(1049061); // You cannot improve valorite ore through prospecting. } - - private class InternalTarget : Target + else { - private readonly ProspectorsTool m_Tool; + bank.Vein = def.Veins[veinIndex + 1]; + from.SendLocalizedMessage(1049050 + veinIndex); - public InternalTarget(ProspectorsTool tool) : base(2, true, TargetFlags.None) => m_Tool = tool; + --UsesRemaining; - protected override void OnTarget(Mobile from, object targeted) + if (UsesRemaining <= 0) { - m_Tool.Prospect(from, targeted); + from.SendLocalizedMessage(1049062); // You have used up your prospector's tool. + Delete(); } } } + + private class InternalTarget : Target + { + private ProspectorsTool _tool; + + public InternalTarget(ProspectorsTool tool) : base(2, true, TargetFlags.None) => _tool = tool; + + protected override void OnTarget(Mobile from, object targeted) + { + _tool.Prospect(from, targeted); + } + } } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/Shovel.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/Shovel.cs index 956d34ad3..73cb310bd 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/Shovel.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/Shovel.cs @@ -1,30 +1,13 @@ +using ModernUO.Serialization; using Server.Engines.Harvest; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class Shovel : BaseHarvestTool { - public class Shovel : BaseHarvestTool - { - [Constructible] - public Shovel(int uses = 50) : base(0xF39, uses) => Weight = 5.0; + [Constructible] + public Shovel(int uses = 50) : base(0xF39, uses) => Weight = 5.0; - public Shovel(Serial serial) : base(serial) - { - } - - public override HarvestSystem HarvestSystem => Mining.System; - - 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 HarvestSystem HarvestSystem => Mining.System; } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs index 03d7d2c08..7b8424940 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs @@ -1,53 +1,36 @@ +using ModernUO.Serialization; using Server.Engines.Harvest; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class SturdyPickaxe : BaseAxe, IUsesRemaining { - public class SturdyPickaxe : BaseAxe, IUsesRemaining + [Constructible] + public SturdyPickaxe(int uses = 180) : base(0xE86) { - [Constructible] - public SturdyPickaxe(int uses = 180) : base(0xE86) - { - Weight = 11.0; - Hue = 0x973; - UsesRemaining = uses; - ShowUsesRemaining = true; - } - - public SturdyPickaxe(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1045126; // sturdy pickaxe - public override HarvestSystem HarvestSystem => Mining.System; - - public override WeaponAbility PrimaryAbility => WeaponAbility.DoubleStrike; - public override WeaponAbility SecondaryAbility => WeaponAbility.Disarm; - - public override int AosStrengthReq => 50; - public override int AosMinDamage => 13; - public override int AosMaxDamage => 15; - public override int AosSpeed => 35; - public override float MlSpeed => 3.00f; - - public override int OldStrengthReq => 25; - public override int OldMinDamage => 1; - public override int OldMaxDamage => 15; - public override int OldSpeed => 35; - - public override WeaponAnimation DefAnimation => WeaponAnimation.Slash1H; - - 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(); - } + Weight = 11.0; + Hue = 0x973; + UsesRemaining = uses; + ShowUsesRemaining = true; } + + public override int LabelNumber => 1045126; // sturdy pickaxe + public override HarvestSystem HarvestSystem => Mining.System; + + public override WeaponAbility PrimaryAbility => WeaponAbility.DoubleStrike; + public override WeaponAbility SecondaryAbility => WeaponAbility.Disarm; + + public override int AosStrengthReq => 50; + public override int AosMinDamage => 13; + public override int AosMaxDamage => 15; + public override int AosSpeed => 35; + public override float MlSpeed => 3.00f; + + public override int OldStrengthReq => 25; + public override int OldMinDamage => 1; + public override int OldMaxDamage => 15; + public override int OldSpeed => 35; + + public override WeaponAnimation DefAnimation => WeaponAnimation.Slash1H; } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyShovel.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyShovel.cs index 398035917..94c149ea9 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyShovel.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/SturdyShovel.cs @@ -1,35 +1,18 @@ +using ModernUO.Serialization; using Server.Engines.Harvest; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class SturdyShovel : BaseHarvestTool { - public class SturdyShovel : BaseHarvestTool + [Constructible] + public SturdyShovel(int uses = 180) : base(0xF39, uses) { - [Constructible] - public SturdyShovel(int uses = 180) : base(0xF39, uses) - { - Weight = 5.0; - Hue = 0x973; - } - - public SturdyShovel(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1045125; // sturdy shovel - public override HarvestSystem HarvestSystem => Mining.System; - - 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(); - } + Weight = 5.0; + Hue = 0x973; } + + public override int LabelNumber => 1045125; // sturdy shovel + public override HarvestSystem HarvestSystem => Mining.System; } diff --git a/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs b/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs index 82772546f..17f8f3ee6 100644 --- a/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs +++ b/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs @@ -1,156 +1,155 @@ using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(2, false)] +[Flippable(0x1bdd, 0x1be0)] +public partial class Log : Item, ICommodity, IAxe { - [SerializationGenerator(2, false)] - [Flippable(0x1bdd, 0x1be0)] - public partial class Log : Item, ICommodity, IAxe + [InvalidateProperties] + [SerializedCommandProperty(AccessLevel.GameMaster)] + [SerializableField(0)] + private CraftResource _resource; + + [Constructible] + public Log(int amount = 1) : this(CraftResource.RegularWood, amount) { - [InvalidateProperties] - [SerializedCommandProperty(AccessLevel.GameMaster)] - [SerializableField(0)] - private CraftResource _resource; + } - [Constructible] - public Log(int amount = 1) : this(CraftResource.RegularWood, amount) + [Constructible] + public Log(CraftResource resource) : this(resource, 1) + { + } + + [Constructible] + public Log(CraftResource resource, int amount) : base(0x1BDD) + { + Stackable = true; + Weight = 2.0; + Amount = amount; + + _resource = resource; + Hue = CraftResources.GetHue(resource); + } + + public virtual bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 0, new Board()); + + int ICommodity.DescriptionNumber => CraftResources.IsStandard(_resource) + ? LabelNumber + : 1075062 + ((int)_resource - (int)CraftResource.RegularWood); + + bool ICommodity.IsDeedable => true; + + public override void GetProperties(IPropertyList list) + { + base.GetProperties(list); + + if (!CraftResources.IsStandard(_resource)) { - } + var num = CraftResources.GetLocalizationNumber(_resource); - [Constructible] - public Log(CraftResource resource) : this(resource, 1) - { - } - - [Constructible] - public Log(CraftResource resource, int amount) : base(0x1BDD) - { - Stackable = true; - Weight = 2.0; - Amount = amount; - - _resource = resource; - Hue = CraftResources.GetHue(resource); - } - - public virtual bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 0, new Board()); - - int ICommodity.DescriptionNumber => CraftResources.IsStandard(_resource) - ? LabelNumber - : 1075062 + ((int)_resource - (int)CraftResource.RegularWood); - - bool ICommodity.IsDeedable => true; - - public override void GetProperties(IPropertyList list) - { - base.GetProperties(list); - - if (!CraftResources.IsStandard(_resource)) + if (num > 0) { - var num = CraftResources.GetLocalizationNumber(_resource); - - if (num > 0) - { - list.Add(num); - } - else - { - list.Add(CraftResources.GetName(_resource)); - } + list.Add(num); + } + else + { + list.Add(CraftResources.GetName(_resource)); } } - - private void Deserialize(IGenericReader reader, int version) - { - _resource = version switch - { - 1 => (CraftResource)reader.ReadInt(), - _ => CraftResource.RegularWood - }; - } - - public virtual bool TryCreateBoards(Mobile from, double skill, Item item) - { - if (Deleted || !from.CanSee(this)) - { - return false; - } - - if (from.Skills.Carpentry.Value < skill && - from.Skills.Lumberjacking.Value < skill) - { - item.Delete(); - from.SendLocalizedMessage(1072652); // You cannot work this strange and unusual wood. - return false; - } - - ScissorHelper(from, item, 1, false); - return true; - } } - [SerializationGenerator(0, false)] - public partial class HeartwoodLog : Log + private void Deserialize(IGenericReader reader, int version) { - [Constructible] - public HeartwoodLog(int amount = 1) : base(CraftResource.Heartwood, amount) + _resource = version switch { - } - - public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 100, new HeartwoodBoard()); + 1 => (CraftResource)reader.ReadInt(), + _ => CraftResource.RegularWood + }; } - [SerializationGenerator(0, false)] - public partial class BloodwoodLog : Log + public virtual bool TryCreateBoards(Mobile from, double skill, Item item) { - [Constructible] - public BloodwoodLog(int amount = 1) : base(CraftResource.Bloodwood, amount) + if (Deleted || !from.CanSee(this)) { + return false; } - public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 100, new BloodwoodBoard()); - } - - [SerializationGenerator(0, false)] - public partial class FrostwoodLog : Log - { - [Constructible] - public FrostwoodLog(int amount = 1) : base(CraftResource.Frostwood, amount) + if (from.Skills.Carpentry.Value < skill && + from.Skills.Lumberjacking.Value < skill) { + item.Delete(); + from.SendLocalizedMessage(1072652); // You cannot work this strange and unusual wood. + return false; } - public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 100, new FrostwoodBoard()); - } - - [SerializationGenerator(0, false)] - public partial class OakLog : Log - { - [Constructible] - public OakLog(int amount = 1) : base(CraftResource.OakWood, amount) - { - } - - public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 65, new OakBoard()); - } - - [SerializationGenerator(0, false)] - public partial class AshLog : Log - { - [Constructible] - public AshLog(int amount = 1) : base(CraftResource.AshWood, amount) - { - } - - public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 80, new AshBoard()); - } - - [SerializationGenerator(0, false)] - public partial class YewLog : Log - { - [Constructible] - public YewLog(int amount = 1) : base(CraftResource.YewWood, amount) - { - } - - public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 95, new YewBoard()); + ScissorHelper(from, item, 1, false); + return true; } } + +[SerializationGenerator(0, false)] +public partial class HeartwoodLog : Log +{ + [Constructible] + public HeartwoodLog(int amount = 1) : base(CraftResource.Heartwood, amount) + { + } + + public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 100, new HeartwoodBoard()); +} + +[SerializationGenerator(0, false)] +public partial class BloodwoodLog : Log +{ + [Constructible] + public BloodwoodLog(int amount = 1) : base(CraftResource.Bloodwood, amount) + { + } + + public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 100, new BloodwoodBoard()); +} + +[SerializationGenerator(0, false)] +public partial class FrostwoodLog : Log +{ + [Constructible] + public FrostwoodLog(int amount = 1) : base(CraftResource.Frostwood, amount) + { + } + + public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 100, new FrostwoodBoard()); +} + +[SerializationGenerator(0, false)] +public partial class OakLog : Log +{ + [Constructible] + public OakLog(int amount = 1) : base(CraftResource.OakWood, amount) + { + } + + public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 65, new OakBoard()); +} + +[SerializationGenerator(0, false)] +public partial class AshLog : Log +{ + [Constructible] + public AshLog(int amount = 1) : base(CraftResource.AshWood, amount) + { + } + + public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 80, new AshBoard()); +} + +[SerializationGenerator(0, false)] +public partial class YewLog : Log +{ + [Constructible] + public YewLog(int amount = 1) : base(CraftResource.YewWood, amount) + { + } + + public override bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 95, new YewBoard()); +} diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/BlankScroll.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/BlankScroll.cs index 07f5db4d8..f5e0117cb 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/BlankScroll.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/BlankScroll.cs @@ -1,34 +1,18 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class BlankScroll : Item, ICommodity { - public class BlankScroll : Item, ICommodity + [Constructible] + public BlankScroll(int amount = 1) : base(0xEF3) { - [Constructible] - public BlankScroll(int amount = 1) : base(0xEF3) - { - Stackable = true; - Weight = 1.0; - Amount = amount; - } - - public BlankScroll(Serial serial) : base(serial) - { - } - - int ICommodity.DescriptionNumber => LabelNumber; - bool ICommodity.IsDeedable => Core.ML; - - 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(); - } + Stackable = true; + Weight = 1.0; + Amount = amount; } + + int ICommodity.DescriptionNumber => LabelNumber; + bool ICommodity.IsDeedable => Core.ML; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/Bottle.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/Bottle.cs index ca66258a4..7a7ccbd30 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/Bottle.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/Bottle.cs @@ -1,34 +1,18 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class Bottle : Item, ICommodity { - public class Bottle : Item, ICommodity + [Constructible] + public Bottle(int amount = 1) : base(0xF0E) { - [Constructible] - public Bottle(int amount = 1) : base(0xF0E) - { - Stackable = true; - Weight = 1.0; - Amount = amount; - } - - public Bottle(Serial serial) : base(serial) - { - } - - int ICommodity.DescriptionNumber => LabelNumber; - bool ICommodity.IsDeedable => Core.ML; - - 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(); - } + Stackable = true; + Weight = 1.0; + Amount = amount; } + + int ICommodity.DescriptionNumber => LabelNumber; + bool ICommodity.IsDeedable => Core.ML; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs index 1bad249cc..7ee010cca 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs @@ -1,4 +1,5 @@ using System; +using ModernUO.Serialization; using Server.Factions; using Server.Gumps; using Server.Misc; @@ -6,451 +7,390 @@ using Server.Mobiles; using Server.Network; using Server.Regions; -namespace Server.Items +namespace Server.Items; + +[DispellableField] +[SerializationGenerator(0, false)] +public partial class Moongate : Item { - [DispellableField] - public class Moongate : Item + [SerializableField(0)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private Point3D _target; + + [SerializableField(1)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private Map _targetMap; + + [SerializableField(2)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private bool _dispellable; + + [Constructible] + public Moongate(bool dispellable = true) : this(Point3D.Zero, null, dispellable) { - [Constructible] - public Moongate(bool dispellable = true) : this(Point3D.Zero, null, dispellable) + } + + [Constructible] + public Moongate(Point3D target, Map targetMap = null, bool dispellable = true) : base(0xF6C) + { + Movable = false; + Light = LightType.Circle300; + + Target = target; + TargetMap = targetMap; + Dispellable = dispellable; + } + + public virtual bool ShowFeluccaWarning => false; + + public override void OnDoubleClick(Mobile from) + { + if (!from.Player) { + return; } - [Constructible] - public Moongate(Point3D target, Map targetMap = null, bool dispellable = true) : base(0xF6C) + if (from.InRange(GetWorldLocation(), 1)) { - Movable = false; - Light = LightType.Circle300; + CheckGate(from, 1); + } + else + { + from.SendLocalizedMessage(500446); // That is too far away. + } + } - Target = target; - TargetMap = targetMap; - Dispellable = dispellable; + public override bool OnMoveOver(Mobile m) + { + if (m.Player) + { + CheckGate(m, 0); } - public Moongate(Serial serial) : base(serial) + return true; + } + + public virtual void CheckGate(Mobile m, int range) + { + if (m.Hidden && m.AccessLevel == AccessLevel.Player && Core.ML) { + m.RevealingAction(); } - [CommandProperty(AccessLevel.GameMaster)] - public Point3D Target { get; set; } + new DelayTimer(m, this, range).Start(); + } - [CommandProperty(AccessLevel.GameMaster)] - public Map TargetMap { get; set; } + public virtual void OnGateUsed(Mobile m) + { + } - [CommandProperty(AccessLevel.GameMaster)] - public bool Dispellable { get; set; } + public virtual void UseGate(Mobile m) + { + var flags = m.NetState?.Flags ?? ClientFlags.None; - public virtual bool ShowFeluccaWarning => false; - - public override void OnDoubleClick(Mobile from) + if (Sigil.ExistsOn(m)) { - if (!from.Player) + m.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. + } + else if (TargetMap == Map.Felucca && m is PlayerMobile mobile && mobile.Young) + { + mobile.SendLocalizedMessage(1049543); // You decide against traveling to Felucca while you are still young. + } + else if (m.Kills >= 5 && TargetMap != Map.Felucca || + TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 || + TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 || + TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0) + { + m.SendLocalizedMessage(1019004); // You are not allowed to travel there. + } + else if (m.Spell != null) + { + m.SendLocalizedMessage(1049616); // You are too busy to do that at the moment. + } + else if (TargetMap != null && TargetMap != Map.Internal) + { + BaseCreature.TeleportPets(m, Target, TargetMap); + + m.MoveToWorld(Target, TargetMap); + + if (m.AccessLevel == AccessLevel.Player || !m.Hidden) { - return; + m.PlaySound(0x1FE); } - if (from.InRange(GetWorldLocation(), 1)) - { - CheckGate(from, 1); - } - else + OnGateUsed(m); + } + else + { + m.SendMessage("This moongate does not seem to go anywhere."); + } + } + + public virtual bool ValidateUse(Mobile from, bool message) + { + if (from.Deleted || Deleted) + { + return false; + } + + if (from.Map != Map || !from.InRange(this, 1)) + { + if (message) { from.SendLocalizedMessage(500446); // That is too far away. } + + return false; } - public override bool OnMoveOver(Mobile m) + return true; + } + + public virtual void BeginConfirmation(Mobile from) + { + if (IsInTown(from.Location, from.Map) && !IsInTown(Target, TargetMap) || + from.Map != Map.Felucca && TargetMap == Map.Felucca && ShowFeluccaWarning) { - if (m.Player) + if (from.AccessLevel == AccessLevel.Player || !from.Hidden) { - CheckGate(m, 0); + from.SendSound(0x20E, from); } - return true; + from.CloseGump(); + from.SendGump(new MoongateConfirmGump(from, this)); } - - public virtual void CheckGate(Mobile m, int range) + else { - if (m.Hidden && m.AccessLevel == AccessLevel.Player && Core.ML) - { - m.RevealingAction(); - } - - new DelayTimer(m, this, range).Start(); - } - - public virtual void OnGateUsed(Mobile m) - { - } - - public virtual void UseGate(Mobile m) - { - var flags = m.NetState?.Flags ?? ClientFlags.None; - - if (Sigil.ExistsOn(m)) - { - m.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. - } - else if (TargetMap == Map.Felucca && m is PlayerMobile mobile && mobile.Young) - { - mobile.SendLocalizedMessage(1049543); // You decide against traveling to Felucca while you are still young. - } - else if (m.Kills >= 5 && TargetMap != Map.Felucca || - TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 || - TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 || - TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0) - { - m.SendLocalizedMessage(1019004); // You are not allowed to travel there. - } - else if (m.Spell != null) - { - m.SendLocalizedMessage(1049616); // You are too busy to do that at the moment. - } - else if (TargetMap != null && TargetMap != Map.Internal) - { - BaseCreature.TeleportPets(m, Target, TargetMap); - - m.MoveToWorld(Target, TargetMap); - - if (m.AccessLevel == AccessLevel.Player || !m.Hidden) - { - m.PlaySound(0x1FE); - } - - OnGateUsed(m); - } - else - { - m.SendMessage("This moongate does not seem to go anywhere."); - } - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(1); // version - - writer.Write(Target); - writer.Write(TargetMap); - - // Version 1 - writer.Write(Dispellable); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - Target = reader.ReadPoint3D(); - TargetMap = reader.ReadMap(); - - if (version >= 1) - { - Dispellable = reader.ReadBool(); - } - } - - public virtual bool ValidateUse(Mobile from, bool message) - { - if (from.Deleted || Deleted) - { - return false; - } - - if (from.Map != Map || !from.InRange(this, 1)) - { - if (message) - { - from.SendLocalizedMessage(500446); // That is too far away. - } - - return false; - } - - return true; - } - - public virtual void BeginConfirmation(Mobile from) - { - if (IsInTown(from.Location, from.Map) && !IsInTown(Target, TargetMap) || - from.Map != Map.Felucca && TargetMap == Map.Felucca && ShowFeluccaWarning) - { - if (from.AccessLevel == AccessLevel.Player || !from.Hidden) - { - from.SendSound(0x20E, from); - } - - from.CloseGump(); - from.SendGump(new MoongateConfirmGump(from, this)); - } - else - { - EndConfirmation(from); - } - } - - public virtual void EndConfirmation(Mobile from) - { - if (!ValidateUse(from, true)) - { - return; - } - - UseGate(from); - } - - public virtual void DelayCallback(Mobile from, int range) - { - if (!ValidateUse(from, false) || !from.InRange(this, range)) - { - return; - } - - if (TargetMap != null) - { - BeginConfirmation(from); - } - else - { - from.SendMessage("This moongate does not seem to go anywhere."); - } - } - - public static bool IsInTown(Point3D p, Map map) => - map != null && Region.Find(p, map).GetRegion()?.IsDisabled() == false; - - private class DelayTimer : Timer - { - private readonly Mobile m_From; - private readonly Moongate m_Gate; - private readonly int m_Range; - - public DelayTimer(Mobile from, Moongate gate, int range) : base(TimeSpan.FromSeconds(1.0)) - { - m_From = from; - m_Gate = gate; - m_Range = range; - } - - protected override void OnTick() - { - m_Gate.DelayCallback(m_From, m_Range); - } + EndConfirmation(from); } } - public class ConfirmationMoongate : Moongate + public virtual void EndConfirmation(Mobile from) { - [Constructible] - public ConfirmationMoongate() : this(Point3D.Zero) + if (!ValidateUse(from, true)) { + return; } - [Constructible] - public ConfirmationMoongate(Point3D target, Map targetMap = null) : base(target, targetMap) + UseGate(from); + } + + public virtual void DelayCallback(Mobile from, int range) + { + if (!ValidateUse(from, false) || !from.InRange(this, range)) { + return; } - public ConfirmationMoongate(Serial serial) : base(serial) + if (TargetMap != null) { + BeginConfirmation(from); } - - [CommandProperty(AccessLevel.GameMaster)] - public int GumpWidth { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public int GumpHeight { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public int TitleColor { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public int MessageColor { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public int TitleNumber { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public TextDefinition Message { get; set; } - - public virtual void Warning_Callback(Mobile from, bool okay) + else { - if (okay) - { - EndConfirmation(from); - } - } - - public override void BeginConfirmation(Mobile from) - { - if (GumpWidth > 0 && GumpHeight > 0 && TitleNumber > 0 && Message?.IsEmpty == false) - { - from.CloseGump(); - from.SendGump( - new WarningGump( - TitleNumber, - TitleColor, - Message, - MessageColor, - GumpWidth, - GumpHeight, - okay => Warning_Callback(from, okay) - ) - ); - } - else - { - base.BeginConfirmation(from); - } - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(1); // version - - writer.Write(Message); - - writer.WriteEncodedInt(GumpWidth); - writer.WriteEncodedInt(GumpHeight); - - writer.WriteEncodedInt(TitleColor); - writer.WriteEncodedInt(MessageColor); - - writer.WriteEncodedInt(TitleNumber); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 1: - { - Message = reader.ReadTextDefinition(); - goto case 0; - } - case 0: - { - GumpWidth = reader.ReadEncodedInt(); - GumpHeight = reader.ReadEncodedInt(); - - TitleColor = reader.ReadEncodedInt(); - MessageColor = reader.ReadEncodedInt(); - - TitleNumber = reader.ReadEncodedInt(); - - if (version == 0) - { - var number = reader.ReadEncodedInt(); - var message = reader.ReadString(); - Message = number > 0 ? number : message; - } - - break; - } - } + from.SendMessage("This moongate does not seem to go anywhere."); } } - public class MoongateConfirmGump : Gump + public static bool IsInTown(Point3D p, Map map) => + map != null && Region.Find(p, map).GetRegion()?.IsDisabled() == false; + + private class DelayTimer : Timer { - private readonly Mobile m_From; - private readonly Moongate m_Gate; + private Mobile _from; + private Moongate _gate; + private int _range; - public MoongateConfirmGump(Mobile from, Moongate gate) : base(Core.AOS ? 110 : 20, Core.AOS ? 100 : 30) + public DelayTimer(Mobile from, Moongate gate, int range) : base(TimeSpan.FromSeconds(1.0)) { - m_From = from; - m_Gate = gate; - - if (Core.AOS) - { - Closable = false; - - AddPage(0); - - AddBackground(0, 0, 420, 280, 5054); - - AddImageTiled(10, 10, 400, 20, 2624); - AddAlphaRegion(10, 10, 400, 20); - - AddHtmlLocalized(10, 10, 400, 20, 1062051, 30720); // Gate Warning - - AddImageTiled(10, 40, 400, 200, 2624); - AddAlphaRegion(10, 40, 400, 200); - - if (from.Map != Map.Felucca && gate.TargetMap == Map.Felucca && gate.ShowFeluccaWarning) - { - AddHtmlLocalized( - 10, - 40, - 400, - 200, - 1062050, // This Gate goes to Felucca... Continue to enter the gate, Cancel to stay here - 32512, - false, - true - ); - } - else - { - AddHtmlLocalized( - 10, - 40, - 400, - 200, - 1062049, // Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here - 32512, - false, - true - ); - } - - AddImageTiled(10, 250, 400, 20, 2624); - AddAlphaRegion(10, 250, 400, 20); - - AddButton(10, 250, 4005, 4007, 1); - AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767); // OKAY - - AddButton(210, 250, 4005, 4007, 0); - AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL - } - else - { - AddPage(0); - - AddBackground(0, 0, 420, 400, 5054); - AddBackground(10, 10, 400, 380, 3000); - - AddHtml( - 20, - 40, - 380, - 60, - "Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here" - ); - - AddHtmlLocalized(55, 110, 290, 20, 1011012); // CANCEL - AddButton(20, 110, 4005, 4007, 0); - - AddHtmlLocalized(55, 140, 290, 40, 1011011); // CONTINUE - AddButton(20, 140, 4005, 4007, 1); - } + _from = from; + _gate = gate; + _range = range; } - public override void OnResponse(NetState state, RelayInfo info) + protected override void OnTick() { - if (info.ButtonID == 1) - { - m_Gate.EndConfirmation(m_From); - } + _gate.DelayCallback(_from, _range); + } + } +} + +[SerializationGenerator(1, false)] +public partial class ConfirmationMoongate : Moongate +{ + [SerializableField(0)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private TextDefinition _message; + + [SerializableField(1)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _gumpWidth; + + [SerializableField(2)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _gumpHeight; + + [SerializableField(3)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _titleColor; + + [SerializableField(4)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _messageColor; + + [SerializableField(5)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _titleNumber; + + [Constructible] + public ConfirmationMoongate() : this(Point3D.Zero) + { + } + + [Constructible] + public ConfirmationMoongate(Point3D target, Map targetMap = null) : base(target, targetMap) + { + } + + public virtual void Warning_Callback(Mobile from, bool okay) + { + if (okay) + { + EndConfirmation(from); + } + } + + public override void BeginConfirmation(Mobile from) + { + if (GumpWidth > 0 && GumpHeight > 0 && TitleNumber > 0 && Message?.IsEmpty == false) + { + from.CloseGump(); + from.SendGump( + new WarningGump( + TitleNumber, + TitleColor, + Message, + MessageColor, + GumpWidth, + GumpHeight, + okay => Warning_Callback(from, okay) + ) + ); + } + else + { + base.BeginConfirmation(from); + } + } + + private void Deserialize(IGenericReader reader, int version) + { + base.Deserialize(reader); + + GumpWidth = reader.ReadEncodedInt(); + GumpHeight = reader.ReadEncodedInt(); + + TitleColor = reader.ReadEncodedInt(); + MessageColor = reader.ReadEncodedInt(); + + TitleNumber = reader.ReadEncodedInt(); + + var number = reader.ReadEncodedInt(); + var message = reader.ReadString(); + Message = number > 0 ? number : message; + } +} + +public class MoongateConfirmGump : Gump +{ + private Mobile _from; + private Moongate _gate; + + public MoongateConfirmGump(Mobile from, Moongate gate) : base(Core.AOS ? 110 : 20, Core.AOS ? 100 : 30) + { + _from = from; + _gate = gate; + + if (Core.AOS) + { + Closable = false; + + AddPage(0); + + AddBackground(0, 0, 420, 280, 5054); + + AddImageTiled(10, 10, 400, 20, 2624); + AddAlphaRegion(10, 10, 400, 20); + + AddHtmlLocalized(10, 10, 400, 20, 1062051, 30720); // Gate Warning + + AddImageTiled(10, 40, 400, 200, 2624); + AddAlphaRegion(10, 40, 400, 200); + + if (from.Map != Map.Felucca && gate.TargetMap == Map.Felucca && gate.ShowFeluccaWarning) + { + AddHtmlLocalized( + 10, + 40, + 400, + 200, + 1062050, // This Gate goes to Felucca... Continue to enter the gate, Cancel to stay here + 32512, + false, + true + ); + } + else + { + AddHtmlLocalized( + 10, + 40, + 400, + 200, + 1062049, // Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here + 32512, + false, + true + ); + } + + AddImageTiled(10, 250, 400, 20, 2624); + AddAlphaRegion(10, 250, 400, 20); + + AddButton(10, 250, 4005, 4007, 1); + AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767); // OKAY + + AddButton(210, 250, 4005, 4007, 0); + AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL + } + else + { + AddPage(0); + + AddBackground(0, 0, 420, 400, 5054); + AddBackground(10, 10, 400, 380, 3000); + + AddHtmlLocalized( + 20, + 40, + 380, + 60, + 1062049 // Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here + ); + + AddHtmlLocalized(55, 110, 290, 20, 1011012); // CANCEL + AddButton(20, 110, 4005, 4007, 0); + + AddHtmlLocalized(55, 140, 290, 40, 1011011); // CONTINUE + AddButton(20, 140, 4005, 4007, 1); + } + } + + public override void OnResponse(NetState state, RelayInfo info) + { + if (info.ButtonID == 1) + { + _gate.EndConfirmation(_from); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs index 4b09592df..fdd45e79a 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs @@ -1,319 +1,169 @@ using System; +using System.Runtime.CompilerServices; +using ModernUO.Serialization; using Server.Network; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(2, false)] +public partial class PotionKeg : Item { - public class PotionKeg : Item + public static void Initialize() { - private int m_Held; - private PotionEffect m_Type; + TileData.ItemTable[0x1940].Height = 4; + } - [Constructible] - public PotionKeg() : base(0x1940) - { - UpdateWeight(); - } + [InvalidateProperties] + [SerializableField(0)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private PotionEffect _type; - public PotionKeg(Serial serial) : base(serial) - { - } + [Constructible] + public PotionKeg() : base(0x1940) => UpdateWeight(); - [CommandProperty(AccessLevel.GameMaster)] - public int Held + [SerializableProperty(1)] + [CommandProperty(AccessLevel.GameMaster)] + public int Held + { + get => _held; + set { - get => m_Held; - set + if (_held != value) { - if (m_Held != value) - { - m_Held = value; - UpdateWeight(); - InvalidateProperties(); - } - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public PotionEffect Type - { - get => m_Type; - set - { - m_Type = value; + _held = value; + UpdateWeight(); InvalidateProperties(); + this.MarkDirty(); } } + } - public override int LabelNumber + public override int LabelNumber + { + get { - get + if (_held > 0 && (int)_type >= (int)PotionEffect.Conflagration) { - if (m_Held > 0 && (int)m_Type >= (int)PotionEffect.Conflagration) + return 1072658 + (int)_type - (int)PotionEffect.Conflagration; + } + + return _held > 0 ? 1041620 + (int)_type : 1041641; + } + } + + public virtual void UpdateWeight() + { + var held = Math.Max(0, Math.Min(_held, 100)); + + Weight = 20 + held * 80 / 100; + } + + private void Deserialize(IGenericReader reader, int version) + { + _type = (PotionEffect)reader.ReadInt(); + _held = reader.ReadInt(); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private int GetKegLabel() => + _held switch + { + <= 0 => 502246, // The keg is empty. + < 5 => 502248, // The keg is nearly empty. + < 20 => 502249, // The keg is not very full. + < 30 => 502250, // The keg is about one quarter full. + < 40 => 502251, // The keg is about one third full. + < 47 => 502252, // The keg is almost half full. + < 54 => 502254, // The keg is approximately half full. + < 70 => 502253, // The keg is more than half full. + < 80 => 502255, // The keg is about three quarters full. + < 96 => 502256, // The keg is very full. + < 100 => 502257, // The liquid is almost to the top of the keg. + _ => 502258 // The keg is completely full. + }; + + public override void GetProperties(IPropertyList list) + { + base.GetProperties(list); + + list.Add(GetKegLabel()); + } + + public override void OnSingleClick(Mobile from) + { + base.OnSingleClick(from); + + LabelTo(from, GetKegLabel()); + } + + public override void OnDoubleClick(Mobile from) + { + if (!from.InRange(GetWorldLocation(), 2)) + { + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + return; + } + + if (_held <= 0) + { + from.SendLocalizedMessage(502246); // The keg is empty. + return; + } + + var pack = from.Backpack; + + if (pack?.ConsumeTotal(typeof(Bottle)) == true) + { + from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle... + + var pot = FillBottle(); + + if (pack.TryDropItem(from, pot, false)) + { + from.SendLocalizedMessage(502243); // ...and place it into your backpack. + from.PlaySound(0x240); + + if (--Held == 0) { - return 1072658 + (int)m_Type - (int)PotionEffect.Conflagration; - } - - return m_Held > 0 ? 1041620 + (int)m_Type : 1041641; - } - } - - public virtual void UpdateWeight() - { - var held = Math.Max(0, Math.Min(m_Held, 100)); - - Weight = 20 + held * 80 / 100; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(1); // version - - writer.Write((int)m_Type); - writer.Write(m_Held); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 1: - case 0: - { - m_Type = (PotionEffect)reader.ReadInt(); - m_Held = reader.ReadInt(); - - break; - } - } - - if (version < 1) - { - Timer.StartTimer(UpdateWeight); - } - } - - public override void GetProperties(IPropertyList list) - { - base.GetProperties(list); - - int number; - - if (m_Held <= 0) - { - number = 502246; // The keg is empty. - } - else if (m_Held < 5) - { - number = 502248; // The keg is nearly empty. - } - else if (m_Held < 20) - { - number = 502249; // The keg is not very full. - } - else if (m_Held < 30) - { - number = 502250; // The keg is about one quarter full. - } - else if (m_Held < 40) - { - number = 502251; // The keg is about one third full. - } - else if (m_Held < 47) - { - number = 502252; // The keg is almost half full. - } - else if (m_Held < 54) - { - number = 502254; // The keg is approximately half full. - } - else if (m_Held < 70) - { - number = 502253; // The keg is more than half full. - } - else if (m_Held < 80) - { - number = 502255; // The keg is about three quarters full. - } - else if (m_Held < 96) - { - number = 502256; // The keg is very full. - } - else if (m_Held < 100) - { - number = 502257; // The liquid is almost to the top of the keg. - } - else - { - number = 502258; // The keg is completely full. - } - - list.Add(number); - } - - public override void OnSingleClick(Mobile from) - { - base.OnSingleClick(from); - - int number; - - if (m_Held <= 0) - { - number = 502246; // The keg is empty. - } - else if (m_Held < 5) - { - number = 502248; // The keg is nearly empty. - } - else if (m_Held < 20) - { - number = 502249; // The keg is not very full. - } - else if (m_Held < 30) - { - number = 502250; // The keg is about one quarter full. - } - else if (m_Held < 40) - { - number = 502251; // The keg is about one third full. - } - else if (m_Held < 47) - { - number = 502252; // The keg is almost half full. - } - else if (m_Held < 54) - { - number = 502254; // The keg is approximately half full. - } - else if (m_Held < 70) - { - number = 502253; // The keg is more than half full. - } - else if (m_Held < 80) - { - number = 502255; // The keg is about three quarters full. - } - else if (m_Held < 96) - { - number = 502256; // The keg is very full. - } - else if (m_Held < 100) - { - number = 502257; // The liquid is almost to the top of the keg. - } - else - { - number = 502258; // The keg is completely full. - } - - LabelTo(from, number); - } - - public override void OnDoubleClick(Mobile from) - { - if (from.InRange(GetWorldLocation(), 2)) - { - if (m_Held > 0) - { - var pack = from.Backpack; - - if (pack?.ConsumeTotal(typeof(Bottle)) == true) - { - from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle... - - var pot = FillBottle(); - - if (pack.TryDropItem(from, pot, false)) - { - from.SendLocalizedMessage(502243); // ...and place it into your backpack. - from.PlaySound(0x240); - - if (--Held == 0) - { - from.SendLocalizedMessage(502245); // The keg is now empty. - } - } - else - { - from.SendLocalizedMessage(502244); // ...but there is no room for the bottle in your backpack. - pot.Delete(); - } - } - } - else - { - from.SendLocalizedMessage(502246); // The keg is empty. + from.SendLocalizedMessage(502245); // The keg is now empty. } } else { - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + from.SendLocalizedMessage(502244); // ...but there is no room for the bottle in your backpack. + pot.Delete(); } } + } - public override bool OnDragDrop(Mobile from, Item item) + public override bool OnDragDrop(Mobile from, Item item) + { + if (item is not BasePotion pot) { - if (item is not BasePotion pot) + from.SendLocalizedMessage(502232); // The keg is not designed to hold that type of object. + return false; + } + + var toHold = Math.Min(100 - _held, pot.Amount); + + if (toHold <= 0) + { + from.SendLocalizedMessage(502233); // The keg will not hold any more! + return false; + } + + if (_held == 0) + { + if ((int)pot.PotionEffect >= (int)PotionEffect.Invisibility) { from.SendLocalizedMessage(502232); // The keg is not designed to hold that type of object. return false; } - var toHold = Math.Min(100 - m_Held, pot.Amount); - - if (toHold <= 0) - { - from.SendLocalizedMessage(502233); // The keg will not hold any more! - return false; - } - - if (m_Held == 0) - { - if ((int)pot.PotionEffect >= (int)PotionEffect.Invisibility) - { - from.SendLocalizedMessage(502232); // The keg is not designed to hold that type of object. - return false; - } - - if (GiveBottle(from, toHold)) - { - m_Type = pot.PotionEffect; - Held = toHold; - - from.PlaySound(0x240); - - from.SendLocalizedMessage(502237); // You place the empty bottle in your backpack. - - pot.Consume(toHold); - - if (!pot.Deleted) - { - pot.Bounce(from); - } - - return true; - } - - from.SendLocalizedMessage(502238); // You don't have room for the empty bottle in your backpack. - return false; - } - - if (pot.PotionEffect != m_Type) - { - from.SendLocalizedMessage( - 502236 - ); // You decide that it would be a bad idea to mix different types of potions. - return false; - } - if (GiveBottle(from, toHold)) { - Held += toHold; + _type = pot.PotionEffect; + Held = toHold; from.PlaySound(0x240); @@ -333,56 +183,78 @@ namespace Server.Items return false; } - public bool GiveBottle(Mobile m, int amount) + if (pot.PotionEffect != _type) { - var pack = m.Backpack; + from.SendLocalizedMessage( + 502236 + ); // You decide that it would be a bad idea to mix different types of potions. + return false; + } - var bottle = new Bottle(amount); + if (GiveBottle(from, toHold)) + { + Held += toHold; - if (pack?.TryDropItem(m, bottle, false) != true) + from.PlaySound(0x240); + + from.SendLocalizedMessage(502237); // You place the empty bottle in your backpack. + + pot.Consume(toHold); + + if (!pot.Deleted) { - bottle.Delete(); - return false; + pot.Bounce(from); } return true; } - public BasePotion FillBottle() + from.SendLocalizedMessage(502238); // You don't have room for the empty bottle in your backpack. + return false; + } + + public static bool GiveBottle(Mobile m, int amount) + { + var pack = m.Backpack; + + var bottle = new Bottle(amount); + + if (pack?.TryDropItem(m, bottle, false) != true) { - return m_Type switch - { - PotionEffect.Nightsight => new NightSightPotion(), - PotionEffect.CureLesser => new LesserCurePotion(), - PotionEffect.Cure => new CurePotion(), - PotionEffect.CureGreater => new GreaterCurePotion(), - PotionEffect.Agility => new AgilityPotion(), - PotionEffect.AgilityGreater => new GreaterAgilityPotion(), - PotionEffect.Strength => new StrengthPotion(), - PotionEffect.StrengthGreater => new GreaterStrengthPotion(), - PotionEffect.PoisonLesser => new LesserPoisonPotion(), - PotionEffect.Poison => new PoisonPotion(), - PotionEffect.PoisonGreater => new GreaterPoisonPotion(), - PotionEffect.PoisonDeadly => new DeadlyPoisonPotion(), - PotionEffect.Refresh => new RefreshPotion(), - PotionEffect.RefreshTotal => new TotalRefreshPotion(), - PotionEffect.HealLesser => new LesserHealPotion(), - PotionEffect.Heal => new HealPotion(), - PotionEffect.HealGreater => new GreaterHealPotion(), - PotionEffect.ExplosionLesser => new LesserExplosionPotion(), - PotionEffect.Explosion => new ExplosionPotion(), - PotionEffect.ExplosionGreater => new GreaterExplosionPotion(), - PotionEffect.Conflagration => new ConflagrationPotion(), - PotionEffect.ConflagrationGreater => new GreaterConflagrationPotion(), - PotionEffect.ConfusionBlast => new ConfusionBlastPotion(), - PotionEffect.ConfusionBlastGreater => new GreaterConfusionBlastPotion(), - _ => new NightSightPotion() - }; + bottle.Delete(); + return false; } - public static void Initialize() - { - TileData.ItemTable[0x1940].Height = 4; - } + return true; } + + public BasePotion FillBottle() => + _type switch + { + PotionEffect.Nightsight => new NightSightPotion(), + PotionEffect.CureLesser => new LesserCurePotion(), + PotionEffect.Cure => new CurePotion(), + PotionEffect.CureGreater => new GreaterCurePotion(), + PotionEffect.Agility => new AgilityPotion(), + PotionEffect.AgilityGreater => new GreaterAgilityPotion(), + PotionEffect.Strength => new StrengthPotion(), + PotionEffect.StrengthGreater => new GreaterStrengthPotion(), + PotionEffect.PoisonLesser => new LesserPoisonPotion(), + PotionEffect.Poison => new PoisonPotion(), + PotionEffect.PoisonGreater => new GreaterPoisonPotion(), + PotionEffect.PoisonDeadly => new DeadlyPoisonPotion(), + PotionEffect.Refresh => new RefreshPotion(), + PotionEffect.RefreshTotal => new TotalRefreshPotion(), + PotionEffect.HealLesser => new LesserHealPotion(), + PotionEffect.Heal => new HealPotion(), + PotionEffect.HealGreater => new GreaterHealPotion(), + PotionEffect.ExplosionLesser => new LesserExplosionPotion(), + PotionEffect.Explosion => new ExplosionPotion(), + PotionEffect.ExplosionGreater => new GreaterExplosionPotion(), + PotionEffect.Conflagration => new ConflagrationPotion(), + PotionEffect.ConflagrationGreater => new GreaterConflagrationPotion(), + PotionEffect.ConfusionBlast => new ConfusionBlastPotion(), + PotionEffect.ConfusionBlastGreater => new GreaterConfusionBlastPotion(), + _ => new NightSightPotion() + }; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs index 775def86c..d33d5ce7a 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs @@ -1,356 +1,320 @@ +using ModernUO.Serialization; using Server.Multis; using Server.Prompts; using Server.Regions; -namespace Server.Items +namespace Server.Items; + +[Flippable(0x1f14, 0x1f15, 0x1f16, 0x1f17)] +[SerializationGenerator(2, false)] +public partial class RecallRune : Item { - [Flippable(0x1f14, 0x1f15, 0x1f16, 0x1f17)] - public class RecallRune : Item + [InvalidateProperties] + [SerializableField(1)] + [SerializedCommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] + private string _description; + + [SerializableField(3)] + [SerializedCommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] + private Point3D _target; + + [Constructible] + public RecallRune() : base(0x1F14) { - private string m_Description; - private BaseHouse m_House; - private bool m_Marked; - private Map m_TargetMap; + Weight = 1.0; + CalculateHue(); + } - [Constructible] - public RecallRune() : base(0x1F14) + [SerializableProperty(0)] + [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] + public BaseHouse House + { + get { - Weight = 1.0; - CalculateHue(); - } - - public RecallRune(Serial serial) : base(serial) - { - } - - [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public BaseHouse House - { - get + if (_house?.Deleted == true) { - if (m_House?.Deleted == true) - { - House = null; - } - - return m_House; + House = null; } - set + + return _house; + } + set + { + _house = value; + CalculateHue(); + InvalidateProperties(); + } + } + + [SerializableProperty(2)] + [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] + public bool Marked + { + get => _marked; + set + { + if (_marked != value) { - m_House = value; + _marked = value; CalculateHue(); InvalidateProperties(); } } + } - [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public string Description + [SerializableProperty(4)] + [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] + public Map TargetMap + { + get => _targetMap; + set { - get => m_Description; - set + if (_targetMap != value) { - m_Description = value; + _targetMap = value; + CalculateHue(); InvalidateProperties(); } } + } - [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public bool Marked + private void Deserialize(IGenericReader reader, int version) + { + switch (version) { - get => m_Marked; - set - { - if (m_Marked != value) + case 1: { - m_Marked = value; + _house = reader.ReadEntity(); + goto case 0; + } + case 0: + { + _description = reader.ReadString(); + _marked = reader.ReadBool(); + Target = reader.ReadPoint3D(); + _targetMap = reader.ReadMap(); + CalculateHue(); - InvalidateProperties(); + break; } - } } + } - [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public Point3D Target { get; set; } - - [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public Map TargetMap + private void CalculateHue() + { + if (!_marked) { - get => m_TargetMap; - set - { - if (m_TargetMap != value) - { - m_TargetMap = value; - CalculateHue(); - InvalidateProperties(); - } - } + Hue = 0; } - - public override void Serialize(IGenericWriter writer) + else if (_targetMap == Map.Trammel) { - base.Serialize(writer); - - if (m_House?.Deleted == false) - { - writer.Write(1); // version - - writer.Write(m_House); - } - else - { - writer.Write(0); // version - } - - writer.Write(m_Description); - writer.Write(m_Marked); - writer.Write(Target); - writer.Write(m_TargetMap); + Hue = House != null ? 0x47F : 50; } - - public override void Deserialize(IGenericReader reader) + else if (_targetMap == Map.Felucca) { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 1: - { - m_House = reader.ReadEntity(); - goto case 0; - } - case 0: - { - m_Description = reader.ReadString(); - m_Marked = reader.ReadBool(); - Target = reader.ReadPoint3D(); - m_TargetMap = reader.ReadMap(); - - CalculateHue(); - - break; - } - } + Hue = House != null ? 0x66D : 0; } - - private void CalculateHue() + else if (_targetMap == Map.Ilshenar) { - if (!m_Marked) - { - Hue = 0; - } - else if (m_TargetMap == Map.Trammel) - { - Hue = House != null ? 0x47F : 50; - } - else if (m_TargetMap == Map.Felucca) - { - Hue = House != null ? 0x66D : 0; - } - else if (m_TargetMap == Map.Ilshenar) - { - Hue = House != null ? 0x55F : 1102; - } - else if (m_TargetMap == Map.Malas) - { - Hue = House != null ? 0x55F : 1102; - } - else if (m_TargetMap == Map.Tokuno) - { - Hue = House != null ? 0x47F : 1154; - } + Hue = House != null ? 0x55F : 1102; } - - public void Mark(Mobile m) + else if (_targetMap == Map.Malas) { - m_Marked = true; + Hue = House != null ? 0x55F : 1102; + } + else if (_targetMap == Map.Tokuno) + { + Hue = House != null ? 0x47F : 1154; + } + } - var setDesc = false; - if (Core.AOS) + public void Mark(Mobile m) + { + _marked = true; + + var setDesc = false; + if (Core.AOS) + { + _house = BaseHouse.FindHouseAt(m); + + if (_house == null) { - m_House = BaseHouse.FindHouseAt(m); - - if (m_House == null) - { - Target = m.Location; - m_TargetMap = m.Map; - } - else - { - var sign = m_House.Sign; - - m_Description = (sign?.Name?.Trim()).DefaultIfNullOrEmpty("an unnamed house"); - - setDesc = true; - - var x = m_House.BanLocation.X; - var y = m_House.BanLocation.Y + 2; - var z = m_House.BanLocation.Z; - - var map = m_House.Map; - - if (map?.CanFit(x, y, z, 16, false, false) == false) - { - z = map.GetAverageZ(x, y); - } - - Target = new Point3D(x, y, z); - m_TargetMap = map; - } - } - else - { - m_House = null; Target = m.Location; - m_TargetMap = m.Map; - } - - if (!setDesc) - { - m_Description = BaseRegion.GetRuneNameFor(Region.Find(Target, m_TargetMap)); - } - - CalculateHue(); - InvalidateProperties(); - } - - public override void GetProperties(IPropertyList list) - { - base.GetProperties(list); - - if (m_Marked) - { - string desc; - - if ((desc = m_Description) == null || (desc = desc.Trim()).Length == 0) - { - desc = "an unknown location"; - } - - if (m_TargetMap == Map.Tokuno) - { - list.Add(House != null ? 1063260 : 1063259, $"a recall rune for {desc}"); // ~1_val~ (Tokuno Islands)[(House)] - } - else if (m_TargetMap == Map.Malas) - { - list.Add(House != null ? 1062454 : 1060804, $"a recall rune for {desc}"); // ~1_val~ (Malas)[(House)] - } - else if (m_TargetMap == Map.Felucca) - { - list.Add(House != null ? 1062452 : 1060805, $"a recall rune for {desc}"); // ~1_val~ (Felucca)[(House)] - } - else if (m_TargetMap == Map.Trammel) - { - list.Add(House != null ? 1062453 : 1060806, $"a recall rune for {desc}"); // ~1_val~ (Trammel)[(House)] - } - else if (House != null) - { - list.Add($"a recall rune for {desc} ({m_TargetMap})(House)"); - } - else - { - list.Add($"a recall rune for {desc} ({m_TargetMap})"); - } - } - } - - public override void OnSingleClick(Mobile from) - { - if (m_Marked) - { - var desc = (m_Description?.Trim()).DefaultIfNullOrEmpty("an unknown location"); - - if (m_TargetMap == Map.Tokuno) - { - LabelTo( - from, - House != null ? 1063260 : 1063259, // ~1_val~ (Tokuno Islands)[(House)] - $"a recall rune for {desc}" - ); - } - else if (m_TargetMap == Map.Malas) - { - LabelTo( - from, - House != null ? 1062454 : 1060804, // ~1_val~ (Malas)[(House)] - $"a recall rune for {desc}" - ); - } - else if (m_TargetMap == Map.Felucca) - { - LabelTo( - from, - House != null ? 1062452 : 1060805, // ~1_val~ (Felucca)[(House)] - $"a recall rune for {desc}" - ); - } - else if (m_TargetMap == Map.Trammel) - { - LabelTo( - from, - House != null ? 1062453 : 1060806, // ~1_val~ (Trammel)[(House)] - $"a recall rune for {desc}" - ); - } - else - { - if (House != null) - { - LabelTo(from, $"a recall rune for {desc} ({m_TargetMap})(House)"); - } - else - { - LabelTo(from, $"a recall rune for {desc} ({m_TargetMap})"); - } - } + _targetMap = m.Map; } else { - LabelTo(from, "an unmarked recall rune"); + var sign = _house.Sign; + + _description = (sign?.Name?.Trim()).DefaultIfNullOrEmpty("an unnamed house"); + + setDesc = true; + + var x = _house.BanLocation.X; + var y = _house.BanLocation.Y + 2; + var z = _house.BanLocation.Z; + + var map = _house.Map; + + if (map?.CanFit(x, y, z, 16, false, false) == false) + { + z = map.GetAverageZ(x, y); + } + + Target = new Point3D(x, y, z); + _targetMap = map; } } - - public override void OnDoubleClick(Mobile from) + else { - int number; + _house = null; + Target = m.Location; + _targetMap = m.Map; + } - if (!IsChildOf(from.Backpack)) + if (!setDesc) + { + _description = BaseRegion.GetRuneNameFor(Region.Find(Target, _targetMap)); + } + + CalculateHue(); + InvalidateProperties(); + } + + public override void GetProperties(IPropertyList list) + { + base.GetProperties(list); + + if (_marked) + { + string desc; + + if ((desc = _description) == null || (desc = desc.Trim()).Length == 0) { - number = 1042001; // That must be in your pack for you to use it. + desc = "an unknown location"; + } + + if (_targetMap == Map.Tokuno) + { + list.Add(House != null ? 1063260 : 1063259, $"a recall rune for {desc}"); // ~1_val~ (Tokuno Islands)[(House)] + } + else if (_targetMap == Map.Malas) + { + list.Add(House != null ? 1062454 : 1060804, $"a recall rune for {desc}"); // ~1_val~ (Malas)[(House)] + } + else if (_targetMap == Map.Felucca) + { + list.Add(House != null ? 1062452 : 1060805, $"a recall rune for {desc}"); // ~1_val~ (Felucca)[(House)] + } + else if (_targetMap == Map.Trammel) + { + list.Add(House != null ? 1062453 : 1060806, $"a recall rune for {desc}"); // ~1_val~ (Trammel)[(House)] } else if (House != null) { - number = 1062399; // You cannot edit the description for this rune. - } - else if (m_Marked) - { - number = 501804; // Please enter a description for this marked object. - - from.Prompt = new RenamePrompt(this); + list.Add($"a recall rune for {desc} ({_targetMap})(House)"); } else { - number = 501805; // That rune is not yet marked. + list.Add($"a recall rune for {desc} ({_targetMap})"); } + } + } - from.SendLocalizedMessage(number); + public override void OnSingleClick(Mobile from) + { + if (_marked) + { + var desc = (_description?.Trim()).DefaultIfNullOrEmpty("an unknown location"); + + if (_targetMap == Map.Tokuno) + { + LabelTo( + from, + House != null ? 1063260 : 1063259, // ~1_val~ (Tokuno Islands)[(House)] + $"a recall rune for {desc}" + ); + } + else if (_targetMap == Map.Malas) + { + LabelTo( + from, + House != null ? 1062454 : 1060804, // ~1_val~ (Malas)[(House)] + $"a recall rune for {desc}" + ); + } + else if (_targetMap == Map.Felucca) + { + LabelTo( + from, + House != null ? 1062452 : 1060805, // ~1_val~ (Felucca)[(House)] + $"a recall rune for {desc}" + ); + } + else if (_targetMap == Map.Trammel) + { + LabelTo( + from, + House != null ? 1062453 : 1060806, // ~1_val~ (Trammel)[(House)] + $"a recall rune for {desc}" + ); + } + else + { + if (House != null) + { + LabelTo(from, $"a recall rune for {desc} ({_targetMap})(House)"); + } + else + { + LabelTo(from, $"a recall rune for {desc} ({_targetMap})"); + } + } + } + else + { + LabelTo(from, "an unmarked recall rune"); + } + } + + public override void OnDoubleClick(Mobile from) + { + int number; + + if (!IsChildOf(from.Backpack)) + { + number = 1042001; // That must be in your pack for you to use it. + } + else if (House != null) + { + number = 1062399; // You cannot edit the description for this rune. + } + else if (_marked) + { + number = 501804; // Please enter a description for this marked object. + + from.Prompt = new RenamePrompt(this); + } + else + { + number = 501805; // That rune is not yet marked. } - private class RenamePrompt : Prompt + from.SendLocalizedMessage(number); + } + + private class RenamePrompt : Prompt + { + private RecallRune _rune; + + public RenamePrompt(RecallRune rune) => _rune = rune; + + public override void OnResponse(Mobile from, string text) { - private readonly RecallRune m_Rune; - - public RenamePrompt(RecallRune rune) => m_Rune = rune; - - public override void OnResponse(Mobile from, string text) + if (_rune.House == null && _rune.Marked) { - if (m_Rune.House == null && m_Rune.Marked) - { - m_Rune.Description = text; - from.SendLocalizedMessage(1010474); // The etching on the rune has been changed. - } + _rune.Description = text; + from.SendLocalizedMessage(1010474); // The etching on the rune has been changed. } } } diff --git a/Projects/UOContent/Migrations/Server.Items.BaseHarvestTool.v2.json b/Projects/UOContent/Migrations/Server.Items.BaseHarvestTool.v2.json new file mode 100644 index 000000000..e7229afb0 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseHarvestTool.v2.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "type": "Server.Items.BaseHarvestTool", + "properties": [ + { + "name": "Crafter", + "type": "string", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Quality", + "type": "Server.Items.ToolQuality", + "rule": "EnumMigrationRule" + }, + { + "name": "UsesRemaining", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BlankScroll.v0.json b/Projects/UOContent/Migrations/Server.Items.BlankScroll.v0.json new file mode 100644 index 000000000..bfdcc10ef --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BlankScroll.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BlankScroll" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.Bottle.v0.json b/Projects/UOContent/Migrations/Server.Items.Bottle.v0.json new file mode 100644 index 000000000..7f2112b1c --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.Bottle.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.Bottle" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ConfirmationMoongate.v1.json b/Projects/UOContent/Migrations/Server.Items.ConfirmationMoongate.v1.json new file mode 100644 index 000000000..b92cb3852 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ConfirmationMoongate.v1.json @@ -0,0 +1,54 @@ +{ + "version": 1, + "type": "Server.Items.ConfirmationMoongate", + "properties": [ + { + "name": "Message", + "type": "Server.TextDefinition", + "rule": "PrimitiveUOTypeMigrationRule", + "ruleArguments": [ + "TextDefinition" + ] + }, + { + "name": "GumpWidth", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "GumpHeight", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "TitleColor", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "MessageColor", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "TitleNumber", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GargoylesPickaxe.v0.json b/Projects/UOContent/Migrations/Server.Items.GargoylesPickaxe.v0.json new file mode 100644 index 000000000..077589b79 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GargoylesPickaxe.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GargoylesPickaxe" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.Moongate.v0.json b/Projects/UOContent/Migrations/Server.Items.Moongate.v0.json new file mode 100644 index 000000000..ca7fb7c3a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.Moongate.v0.json @@ -0,0 +1,30 @@ +{ + "version": 0, + "type": "Server.Items.Moongate", + "properties": [ + { + "name": "Target", + "type": "Server.Point3D", + "rule": "PrimitiveUOTypeMigrationRule", + "ruleArguments": [ + "Point3D" + ] + }, + { + "name": "TargetMap", + "type": "Server.Map", + "rule": "PrimitiveUOTypeMigrationRule", + "ruleArguments": [ + "Map" + ] + }, + { + "name": "Dispellable", + "type": "bool", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.PotionKeg.v2.json b/Projects/UOContent/Migrations/Server.Items.PotionKeg.v2.json new file mode 100644 index 000000000..be7b39317 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.PotionKeg.v2.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "type": "Server.Items.PotionKeg", + "properties": [ + { + "name": "Type", + "type": "Server.Items.PotionEffect", + "rule": "EnumMigrationRule" + }, + { + "name": "Held", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ProspectorsTool.v0.json b/Projects/UOContent/Migrations/Server.Items.ProspectorsTool.v0.json new file mode 100644 index 000000000..b898a28de --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ProspectorsTool.v0.json @@ -0,0 +1,14 @@ +{ + "version": 0, + "type": "Server.Items.ProspectorsTool", + "properties": [ + { + "name": "UsesRemaining", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.RecallRune.v2.json b/Projects/UOContent/Migrations/Server.Items.RecallRune.v2.json new file mode 100644 index 000000000..183c323cb --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.RecallRune.v2.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "type": "Server.Items.RecallRune", + "properties": [ + { + "name": "House", + "type": "Server.Multis.BaseHouse", + "rule": "SerializableInterfaceMigrationRule" + }, + { + "name": "Description", + "type": "string", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Marked", + "type": "bool", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Target", + "type": "Server.Point3D", + "rule": "PrimitiveUOTypeMigrationRule", + "ruleArguments": [ + "Point3D" + ] + }, + { + "name": "TargetMap", + "type": "Server.Map", + "rule": "PrimitiveUOTypeMigrationRule", + "ruleArguments": [ + "Map" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.Shovel.v0.json b/Projects/UOContent/Migrations/Server.Items.Shovel.v0.json new file mode 100644 index 000000000..18b0df8b4 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.Shovel.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.Shovel" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.SturdyPickaxe.v0.json b/Projects/UOContent/Migrations/Server.Items.SturdyPickaxe.v0.json new file mode 100644 index 000000000..a97cb8121 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.SturdyPickaxe.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.SturdyPickaxe" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.SturdyShovel.v0.json b/Projects/UOContent/Migrations/Server.Items.SturdyShovel.v0.json new file mode 100644 index 000000000..1e9981caa --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.SturdyShovel.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.SturdyShovel" +} \ No newline at end of file