From 59ed0a5bb4723e62aa9fff6a8b8e00510ed3f903 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Wed, 23 Nov 2022 13:37:39 -0800 Subject: [PATCH] fix: Codegens quivers (#1271) --- .../UOContent/Items/Quivers/BaseQuiver.cs | 923 ++++++++---------- .../UOContent/Items/Quivers/ElvenQuiver.cs | 36 +- .../UOContent/Items/Quivers/QuiverOfBlight.cs | 50 +- .../UOContent/Items/Quivers/QuiverOfFire.cs | 50 +- .../UOContent/Items/Quivers/QuiverOfIce.cs | 50 +- .../Items/Quivers/QuiverOfLightning.cs | 50 +- .../Server.Items.BaseQuiver.v1.json | 66 ++ .../Server.Items.ElvenQuiver.v0.json | 4 + .../Server.Items.QuiverOfBlight.v0.json | 4 + .../Server.Items.QuiverOfFire.v0.json | 4 + .../Server.Items.QuiverOfIce.v0.json | 4 + .../Server.Items.QuiverOfLightning.v0.json | 4 + 12 files changed, 573 insertions(+), 672 deletions(-) create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseQuiver.v1.json create mode 100644 Projects/UOContent/Migrations/Server.Items.ElvenQuiver.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.QuiverOfBlight.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.QuiverOfFire.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.QuiverOfIce.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.QuiverOfLightning.v0.json diff --git a/Projects/UOContent/Items/Quivers/BaseQuiver.cs b/Projects/UOContent/Items/Quivers/BaseQuiver.cs index 02223f383..28da55c4d 100644 --- a/Projects/UOContent/Items/Quivers/BaseQuiver.cs +++ b/Projects/UOContent/Items/Quivers/BaseQuiver.cs @@ -1,580 +1,475 @@ using System; +using ModernUO.Serialization; using Server.Engines.Craft; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(1, false)] +public partial class BaseQuiver : Container, ICraftable, IAosItem { - public class BaseQuiver : Container, ICraftable, IAosItem + private static Type[] m_Ammo = { typeof(Arrow), typeof(Bolt) }; + + [SerializableField(0, setter: "private")] + [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] + private AosAttributes _attributes; + + [SerializableFieldSaveFlag(0)] + private bool ShouldSerializeAosAttributes() => !_attributes.IsEmpty; + + [SerializableFieldDefault(0)] + private AosAttributes AttributesDefaultValue() => new(this); + + [InvalidateProperties] + [SerializableField(1)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _lowerAmmoCost; + + [SerializableFieldSaveFlag(1)] + private bool ShouldSerializeLowerAmmoCost() => _lowerAmmoCost != 0; + + [InvalidateProperties] + [SerializableField(2)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _weightReduction; + + [SerializableFieldSaveFlag(2)] + private bool ShouldSerializeWeightReduction() => _weightReduction != 0; + + [InvalidateProperties] + [SerializableField(3)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _damageIncrease; + + [SerializableFieldSaveFlag(3)] + private bool ShouldSerializeDamageIncrease() => _damageIncrease != 0; + + [InvalidateProperties] + [SerializableField(4)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private string _crafter; + + [SerializableFieldSaveFlag(4)] + private bool ShouldSerializeCrafter() => _crafter != null; + + [InvalidateProperties] + [SerializableField(5)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private ClothingQuality _quality; + + [SerializableFieldSaveFlag(5)] + private bool ShouldSerializeQuality() => _quality != ClothingQuality.Regular; + + [SerializableFieldDefault(5)] + private ClothingQuality QualityDefaultValue() => ClothingQuality.Regular; + + [InvalidateProperties] + [SerializableField(6)] + [SerializedCommandProperty(AccessLevel.GameMaster)] + private int _capacity; + + [SerializableFieldSaveFlag(6)] + private bool ShouldSerializeCapacity() => _capacity != 0; + + public BaseQuiver(int itemID = 0x2FB7) : base(itemID) { - private static readonly Type[] m_Ammo = + Weight = 2.0; + Capacity = 500; + Layer = Layer.Cloak; + + Attributes = new AosAttributes(this); + + DamageIncrease = 10; + } + + public override int DefaultGumpID => 0x108; + public override int DefaultMaxItems => 1; + public override int DefaultMaxWeight => 50; + public override double DefaultWeight => 2.0; + + public Item Ammo => Items.Count > 0 ? Items[0] : null; + + public virtual int OnCraft( + int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, + BaseTool tool, CraftItem craftItem, int resHue + ) + { + Quality = (ClothingQuality)quality; + + if (makersMark) { - typeof(Arrow), typeof(Bolt) - }; - - private int m_Capacity; - - private Mobile m_Crafter; - private int m_DamageIncrease; - private int m_LowerAmmoCost; - private ClothingQuality m_Quality; - private int m_WeightReduction; - - public BaseQuiver(int itemID = 0x2FB7) : base(itemID) - { - Weight = 2.0; - Capacity = 500; - Layer = Layer.Cloak; - - Attributes = new AosAttributes(this); - - DamageIncrease = 10; + Crafter = from.RawName; } - public BaseQuiver(Serial serial) : base(serial) + return quality; + } + + public override void OnAfterDuped(Item newItem) + { + if (newItem is not BaseQuiver quiver) { + return; } - public override int DefaultGumpID => 0x108; - public override int DefaultMaxItems => 1; - public override int DefaultMaxWeight => 50; - public override double DefaultWeight => 2.0; + quiver.Attributes = new AosAttributes(newItem, Attributes); + } - [CommandProperty(AccessLevel.GameMaster, canModify: true)] - public AosAttributes Attributes { get; private set; } + public override void UpdateTotal(Item sender, TotalType type, int delta) + { + InvalidateProperties(); - [CommandProperty(AccessLevel.GameMaster)] - public int Capacity + base.UpdateTotal(sender, type, delta); + } + + public override int GetTotal(TotalType type) + { + var total = base.GetTotal(type); + + if (type == TotalType.Weight) { - get => m_Capacity; - set + total -= total * _weightReduction / 100; + } + + return total; + } + + public bool CheckType(Item item) + { + var type = item.GetType(); + var ammo = Ammo; + + if (ammo != null) + { + if (ammo.GetType() == type) { - m_Capacity = value; - InvalidateProperties(); + return true; } } - - [CommandProperty(AccessLevel.GameMaster)] - public int LowerAmmoCost + else { - get => m_LowerAmmoCost; - set + for (var i = 0; i < m_Ammo.Length; i++) { - m_LowerAmmoCost = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int WeightReduction - { - get => m_WeightReduction; - set - { - m_WeightReduction = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int DamageIncrease - { - get => m_DamageIncrease; - set - { - m_DamageIncrease = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public Mobile Crafter - { - get => m_Crafter; - set - { - m_Crafter = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public ClothingQuality Quality - { - get => m_Quality; - set - { - m_Quality = value; - InvalidateProperties(); - } - } - - public Item Ammo => Items.Count > 0 ? Items[0] : null; - - public virtual int OnCraft( - int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, - BaseTool tool, CraftItem craftItem, int resHue - ) - { - Quality = (ClothingQuality)quality; - - if (makersMark) - { - Crafter = from; - } - - return quality; - } - - public override void OnAfterDuped(Item newItem) - { - if (newItem is not BaseQuiver quiver) - { - return; - } - - quiver.Attributes = new AosAttributes(newItem, Attributes); - } - - public override void UpdateTotal(Item sender, TotalType type, int delta) - { - InvalidateProperties(); - - base.UpdateTotal(sender, type, delta); - } - - public override int GetTotal(TotalType type) - { - var total = base.GetTotal(type); - - if (type == TotalType.Weight) - { - total -= total * m_WeightReduction / 100; - } - - return total; - } - - public bool CheckType(Item item) - { - var type = item.GetType(); - var ammo = Ammo; - - if (ammo != null) - { - if (ammo.GetType() == type) + if (type == m_Ammo[i]) { return true; } } - else + } + + return false; + } + + public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) + { + if (!CheckType(item)) + { + if (message) { - for (var i = 0; i < m_Ammo.Length; i++) - { - if (type == m_Ammo[i]) - { - return true; - } - } + m.SendLocalizedMessage( 1074836 ); // The container can not hold that type of object. } return false; } - public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) + if (Items.Count < DefaultMaxItems) { - if (!CheckType(item)) - { - if (message) - { - m.SendLocalizedMessage( 1074836 ); // The container can not hold that type of object. - } - - return false; - } - - if (Items.Count < DefaultMaxItems) - { - return item.Amount <= m_Capacity && base.CheckHold(m, item, message, checkItems, plusItems, plusWeight); - } - - if (checkItems) - { - return false; - } - - Item ammo = Ammo; - - return ammo?.Deleted == false && ammo.Amount + item.Amount <= m_Capacity; + return item.Amount <= _capacity && base.CheckHold(m, item, message, checkItems, plusItems, plusWeight); } - public override void AddItem(Item dropped) + if (checkItems) { - base.AddItem(dropped); - - InvalidateWeight(); + return false; } - public override void RemoveItem(Item dropped) - { - base.RemoveItem(dropped); + Item ammo = Ammo; - InvalidateWeight(); + return ammo?.Deleted == false && ammo.Amount + item.Amount <= _capacity; + } + + public override void AddItem(Item dropped) + { + base.AddItem(dropped); + + InvalidateWeight(); + } + + public override void RemoveItem(Item dropped) + { + base.RemoveItem(dropped); + + InvalidateWeight(); + } + + public override void OnAdded(IEntity parent) + { + if (parent is Mobile mob) + { + Attributes.AddStatBonuses(mob); + } + } + + public override void OnRemoved(IEntity parent) + { + if (parent is Mobile mob) + { + Attributes.RemoveStatBonuses(mob); + } + } + + public override void GetProperties(IPropertyList list) + { + base.GetProperties(list); + + if (_crafter != null) + { + list.Add(1050043, _crafter); // crafted by ~1_NAME~ } - public override void OnAdded(IEntity parent) + if (_quality == ClothingQuality.Exceptional) { - if (parent is Mobile mob) - { - Attributes.AddStatBonuses(mob); - } + list.Add(1063341); // exceptional } - public override void OnRemoved(IEntity parent) + var ammo = Ammo; + + if (ammo == null) { - if (parent is Mobile mob) - { - Attributes.RemoveStatBonuses(mob); - } + list.Add(1075265, $"0\t{Capacity}"); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows + } + else if (ammo is Arrow) + { + list.Add(1075265, $"{ammo.Amount}\t{Capacity}"); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows + } + else if (ammo is Bolt) + { + list.Add(1075266, $"{ammo.Amount}\t{Capacity}"); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ bolts } - public override void GetProperties(IPropertyList list) + int prop; + + if ((prop = _damageIncrease) != 0) { - base.GetProperties(list); - - if (m_Crafter != null) - { - list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ - } - - if (m_Quality == ClothingQuality.Exceptional) - { - list.Add(1063341); // exceptional - } - - var ammo = Ammo; - - if (ammo != null) - { - if (ammo is Arrow) - { - list.Add(1075265, $"{ammo.Amount}\t{Capacity}"); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows - } - else if (ammo is Bolt) - { - list.Add(1075266, $"{ammo.Amount}\t{Capacity}"); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ bolts - } - } - else - { - list.Add(1075265, $"0\t{Capacity}"); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows - } - - int prop; - - if ((prop = m_DamageIncrease) != 0) - { - list.Add(1074762, prop); // Damage modifier: ~1_PERCENT~% - } - - int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0, chaos = 0, direct = 0; - - AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct); - - if (phys != 0) - { - list.Add(1060403, phys); // physical damage ~1_val~% - } - - if (fire != 0) - { - list.Add(1060405, fire); // fire damage ~1_val~% - } - - if (cold != 0) - { - list.Add(1060404, cold); // cold damage ~1_val~% - } - - if (pois != 0) - { - list.Add(1060406, pois); // poison damage ~1_val~% - } - - if (nrgy != 0) - { - list.Add(1060407, nrgy); // energy damage ~1_val - } - - if (chaos != 0) - { - list.Add(1072846, chaos); // chaos damage ~1_val~% - } - - if (direct != 0) - { - list.Add(1079978, direct); // Direct Damage: ~1_PERCENT~% - } - - list.Add(1075085); // Requirement: Mondain's Legacy - - if ((prop = Attributes.DefendChance) != 0) - { - list.Add(1060408, prop); // defense chance increase ~1_val~% - } - - if ((prop = Attributes.BonusDex) != 0) - { - list.Add(1060409, prop); // dexterity bonus ~1_val~ - } - - if ((prop = Attributes.EnhancePotions) != 0) - { - list.Add(1060411, prop); // enhance potions ~1_val~% - } - - if ((prop = Attributes.CastRecovery) != 0) - { - list.Add(1060412, prop); // faster cast recovery ~1_val~ - } - - if ((prop = Attributes.CastSpeed) != 0) - { - list.Add(1060413, prop); // faster casting ~1_val~ - } - - if ((prop = Attributes.AttackChance) != 0) - { - list.Add(1060415, prop); // hit chance increase ~1_val~% - } - - if ((prop = Attributes.BonusHits) != 0) - { - list.Add(1060431, prop); // hit point increase ~1_val~ - } - - if ((prop = Attributes.BonusInt) != 0) - { - list.Add(1060432, prop); // intelligence bonus ~1_val~ - } - - if ((prop = Attributes.LowerManaCost) != 0) - { - list.Add(1060433, prop); // lower mana cost ~1_val~% - } - - if ((prop = Attributes.LowerRegCost) != 0) - { - list.Add(1060434, prop); // lower reagent cost ~1_val~% - } - - if ((prop = Attributes.Luck) != 0) - { - list.Add(1060436, prop); // luck ~1_val~ - } - - if ((prop = Attributes.BonusMana) != 0) - { - list.Add(1060439, prop); // mana increase ~1_val~ - } - - if ((prop = Attributes.RegenMana) != 0) - { - list.Add(1060440, prop); // mana regeneration ~1_val~ - } - - if (Attributes.NightSight != 0) - { - list.Add(1060441); // night sight - } - - if ((prop = Attributes.ReflectPhysical) != 0) - { - list.Add(1060442, prop); // reflect physical damage ~1_val~% - } - - if ((prop = Attributes.RegenStam) != 0) - { - list.Add(1060443, prop); // stamina regeneration ~1_val~ - } - - if ((prop = Attributes.RegenHits) != 0) - { - list.Add(1060444, prop); // hit point regeneration ~1_val~ - } - - if ((prop = Attributes.SpellDamage) != 0) - { - list.Add(1060483, prop); // spell damage increase ~1_val~% - } - - if ((prop = Attributes.BonusStam) != 0) - { - list.Add(1060484, prop); // stamina increase ~1_val~ - } - - if ((prop = Attributes.BonusStr) != 0) - { - list.Add(1060485, prop); // strength bonus ~1_val~ - } - - if ((prop = Attributes.WeaponSpeed) != 0) - { - list.Add(1060486, prop); // swing speed increase ~1_val~% - } - - if ((prop = m_LowerAmmoCost) > 0) - { - list.Add(1075208, prop); // Lower Ammo Cost ~1_Percentage~% - } - - var weight = ammo != null ? ammo.Weight + ammo.Amount : 0; - - list.Add( - 1072241, // Contents: ~1_COUNT~/~2_MAXCOUNT items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones - $"{Items.Count}\t{DefaultMaxItems}\t{(int)weight}\t{DefaultMaxWeight}" - ); - - if ((prop = m_WeightReduction) != 0) - { - list.Add(1072210, prop); // Weight reduction: ~1_PERCENTAGE~% - } + list.Add(1074762, prop); // Damage modifier: ~1_PERCENT~% } - private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) + int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0, chaos = 0, direct = 0; + + AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct); + + if (phys != 0) { - if (setIf) - { - flags |= toSet; - } + list.Add(1060403, phys); // physical damage ~1_val~% } - private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; - - public override void Serialize(IGenericWriter writer) + if (fire != 0) { - base.Serialize(writer); - - writer.Write(0); // version - - var flags = SaveFlag.None; - - SetSaveFlag(ref flags, SaveFlag.Attributes, !Attributes.IsEmpty); - SetSaveFlag(ref flags, SaveFlag.LowerAmmoCost, m_LowerAmmoCost != 0); - SetSaveFlag(ref flags, SaveFlag.WeightReduction, m_WeightReduction != 0); - SetSaveFlag(ref flags, SaveFlag.DamageIncrease, m_DamageIncrease != 0); - SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); - SetSaveFlag(ref flags, SaveFlag.Quality, true); - SetSaveFlag(ref flags, SaveFlag.Capacity, m_Capacity > 0); - - writer.WriteEncodedInt((int)flags); - - if (GetSaveFlag(flags, SaveFlag.Attributes)) - { - Attributes.Serialize(writer); - } - - if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) - { - writer.Write(m_LowerAmmoCost); - } - - if (GetSaveFlag(flags, SaveFlag.WeightReduction)) - { - writer.Write(m_WeightReduction); - } - - if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) - { - writer.Write(m_DamageIncrease); - } - - if (GetSaveFlag(flags, SaveFlag.Crafter)) - { - writer.Write(m_Crafter); - } - - if (GetSaveFlag(flags, SaveFlag.Quality)) - { - writer.Write((int)m_Quality); - } - - if (GetSaveFlag(flags, SaveFlag.Capacity)) - { - writer.Write(m_Capacity); - } + list.Add(1060405, fire); // fire damage ~1_val~% } - public override void Deserialize(IGenericReader reader) + if (cold != 0) { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - var flags = (SaveFlag)reader.ReadEncodedInt(); - - Attributes = new AosAttributes(this); - - if (GetSaveFlag(flags, SaveFlag.Attributes)) - { - Attributes.Deserialize(reader); - } - - if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) - { - m_LowerAmmoCost = reader.ReadInt(); - } - - if (GetSaveFlag(flags, SaveFlag.WeightReduction)) - { - m_WeightReduction = reader.ReadInt(); - } - - if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) - { - m_DamageIncrease = reader.ReadInt(); - } - - if (GetSaveFlag(flags, SaveFlag.Crafter)) - { - m_Crafter = reader.ReadEntity(); - } - - if (GetSaveFlag(flags, SaveFlag.Quality)) - { - m_Quality = (ClothingQuality)reader.ReadInt(); - } - - if (GetSaveFlag(flags, SaveFlag.Capacity)) - { - m_Capacity = reader.ReadInt(); - } + list.Add(1060404, cold); // cold damage ~1_val~% } - public virtual void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, ref int chaos, ref int direct - ) + if (pois != 0) { + list.Add(1060406, pois); // poison damage ~1_val~% } - public void InvalidateWeight() + if (nrgy != 0) { - if (RootParent is Mobile m) - { - m.UpdateTotals(); - } + list.Add(1060407, nrgy); // energy damage ~1_val } - [Flags] - private enum SaveFlag + if (chaos != 0) { - None = 0x00000000, - Attributes = 0x00000001, - DamageModifier = 0x00000002, - LowerAmmoCost = 0x00000004, - WeightReduction = 0x00000008, - Crafter = 0x00000010, - Quality = 0x00000020, - Capacity = 0x00000040, - DamageIncrease = 0x00000080 + list.Add(1072846, chaos); // chaos damage ~1_val~% + } + + if (direct != 0) + { + list.Add(1079978, direct); // Direct Damage: ~1_PERCENT~% + } + + list.Add(1075085); // Requirement: Mondain's Legacy + + if ((prop = Attributes.DefendChance) != 0) + { + list.Add(1060408, prop); // defense chance increase ~1_val~% + } + + if ((prop = Attributes.BonusDex) != 0) + { + list.Add(1060409, prop); // dexterity bonus ~1_val~ + } + + if ((prop = Attributes.EnhancePotions) != 0) + { + list.Add(1060411, prop); // enhance potions ~1_val~% + } + + if ((prop = Attributes.CastRecovery) != 0) + { + list.Add(1060412, prop); // faster cast recovery ~1_val~ + } + + if ((prop = Attributes.CastSpeed) != 0) + { + list.Add(1060413, prop); // faster casting ~1_val~ + } + + if ((prop = Attributes.AttackChance) != 0) + { + list.Add(1060415, prop); // hit chance increase ~1_val~% + } + + if ((prop = Attributes.BonusHits) != 0) + { + list.Add(1060431, prop); // hit point increase ~1_val~ + } + + if ((prop = Attributes.BonusInt) != 0) + { + list.Add(1060432, prop); // intelligence bonus ~1_val~ + } + + if ((prop = Attributes.LowerManaCost) != 0) + { + list.Add(1060433, prop); // lower mana cost ~1_val~% + } + + if ((prop = Attributes.LowerRegCost) != 0) + { + list.Add(1060434, prop); // lower reagent cost ~1_val~% + } + + if ((prop = Attributes.Luck) != 0) + { + list.Add(1060436, prop); // luck ~1_val~ + } + + if ((prop = Attributes.BonusMana) != 0) + { + list.Add(1060439, prop); // mana increase ~1_val~ + } + + if ((prop = Attributes.RegenMana) != 0) + { + list.Add(1060440, prop); // mana regeneration ~1_val~ + } + + if (Attributes.NightSight != 0) + { + list.Add(1060441); // night sight + } + + if ((prop = Attributes.ReflectPhysical) != 0) + { + list.Add(1060442, prop); // reflect physical damage ~1_val~% + } + + if ((prop = Attributes.RegenStam) != 0) + { + list.Add(1060443, prop); // stamina regeneration ~1_val~ + } + + if ((prop = Attributes.RegenHits) != 0) + { + list.Add(1060444, prop); // hit point regeneration ~1_val~ + } + + if ((prop = Attributes.SpellDamage) != 0) + { + list.Add(1060483, prop); // spell damage increase ~1_val~% + } + + if ((prop = Attributes.BonusStam) != 0) + { + list.Add(1060484, prop); // stamina increase ~1_val~ + } + + if ((prop = Attributes.BonusStr) != 0) + { + list.Add(1060485, prop); // strength bonus ~1_val~ + } + + if ((prop = Attributes.WeaponSpeed) != 0) + { + list.Add(1060486, prop); // swing speed increase ~1_val~% + } + + if ((prop = _lowerAmmoCost) > 0) + { + list.Add(1075208, prop); // Lower Ammo Cost ~1_Percentage~% + } + + var weight = ammo != null ? ammo.Weight + ammo.Amount : 0; + + list.Add( + 1072241, // Contents: ~1_COUNT~/~2_MAXCOUNT items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones + $"{Items.Count}\t{DefaultMaxItems}\t{(int)weight}\t{DefaultMaxWeight}" + ); + + if ((prop = _weightReduction) != 0) + { + list.Add(1072210, prop); // Weight reduction: ~1_PERCENTAGE~% + } + } + + private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; + + private void Deserialize(IGenericReader reader, int version) + { + var flags = (SaveFlag)reader.ReadEncodedInt(); + + _attributes = new AosAttributes(this); + + if (GetSaveFlag(flags, SaveFlag.Attributes)) + { + _attributes.Deserialize(reader); + } + + if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) + { + _lowerAmmoCost = reader.ReadInt(); + } + + if (GetSaveFlag(flags, SaveFlag.WeightReduction)) + { + _weightReduction = reader.ReadInt(); + } + + if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) + { + _damageIncrease = reader.ReadInt(); + } + + if (GetSaveFlag(flags, SaveFlag.Crafter)) + { + _crafter = reader.ReadEntity()?.RawName; + } + + if (GetSaveFlag(flags, SaveFlag.Quality)) + { + _quality = (ClothingQuality)reader.ReadInt(); + } + + if (GetSaveFlag(flags, SaveFlag.Capacity)) + { + _capacity = reader.ReadInt(); + } + } + + public virtual void AlterBowDamage( + ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, ref int chaos, ref int direct + ) + { + } + + public void InvalidateWeight() + { + if (RootParent is Mobile m) + { + m.UpdateTotals(); } } } diff --git a/Projects/UOContent/Items/Quivers/ElvenQuiver.cs b/Projects/UOContent/Items/Quivers/ElvenQuiver.cs index fe51e2256..d2a93eccd 100644 --- a/Projects/UOContent/Items/Quivers/ElvenQuiver.cs +++ b/Projects/UOContent/Items/Quivers/ElvenQuiver.cs @@ -1,29 +1,13 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[Flippable(0x2FB7, 0x3171)] +[SerializationGenerator(0)] +public partial class ElvenQuiver : BaseQuiver { - [Flippable(0x2FB7, 0x3171)] - public class ElvenQuiver : BaseQuiver - { - [Constructible] - public ElvenQuiver() => WeightReduction = 30; + [Constructible] + public ElvenQuiver() => WeightReduction = 30; - public ElvenQuiver(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1032657; // elven quiver - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.WriteEncodedInt(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadEncodedInt(); - } - } + public override int LabelNumber => 1032657; // elven quiver } diff --git a/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs b/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs index c0ed1bd11..62e92fff6 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfBlight.cs @@ -1,37 +1,21 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0)] +public partial class QuiverOfBlight : ElvenQuiver { - public class QuiverOfBlight : ElvenQuiver + [Constructible] + public QuiverOfBlight() => Hue = 0x4F3; + + public override int LabelNumber => 1073111; // Quiver of Blight + + public override void AlterBowDamage( + ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, + ref int chaos, ref int direct + ) { - [Constructible] - public QuiverOfBlight() => Hue = 0x4F3; - - public QuiverOfBlight(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1073111; // Quiver of Blight - - public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct - ) - { - phys = fire = nrgy = chaos = direct = 0; - cold = pois = 50; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.WriteEncodedInt(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadEncodedInt(); - } + phys = fire = nrgy = chaos = direct = 0; + cold = pois = 50; } } diff --git a/Projects/UOContent/Items/Quivers/QuiverOfFire.cs b/Projects/UOContent/Items/Quivers/QuiverOfFire.cs index 8caf6aa2a..736f7c929 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfFire.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfFire.cs @@ -1,37 +1,21 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0)] +public partial class QuiverOfFire : ElvenQuiver { - public class QuiverOfFire : ElvenQuiver + [Constructible] + public QuiverOfFire() => Hue = 0x4E7; + + public override int LabelNumber => 1073109; // quiver of fire + + public override void AlterBowDamage( + ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, + ref int chaos, ref int direct + ) { - [Constructible] - public QuiverOfFire() => Hue = 0x4E7; - - public QuiverOfFire(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1073109; // quiver of fire - - public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct - ) - { - cold = pois = nrgy = chaos = direct = 0; - phys = fire = 50; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.WriteEncodedInt(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadEncodedInt(); - } + cold = pois = nrgy = chaos = direct = 0; + phys = fire = 50; } } diff --git a/Projects/UOContent/Items/Quivers/QuiverOfIce.cs b/Projects/UOContent/Items/Quivers/QuiverOfIce.cs index 281519a7a..864164c09 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfIce.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfIce.cs @@ -1,37 +1,21 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0)] +public partial class QuiverOfIce : ElvenQuiver { - public class QuiverOfIce : ElvenQuiver + [Constructible] + public QuiverOfIce() => Hue = 0x4ED; + + public override int LabelNumber => 1073110; // quiver of ice + + public override void AlterBowDamage( + ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, + ref int chaos, ref int direct + ) { - [Constructible] - public QuiverOfIce() => Hue = 0x4ED; - - public QuiverOfIce(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1073110; // quiver of ice - - public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct - ) - { - fire = pois = nrgy = chaos = direct = 0; - phys = cold = 50; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.WriteEncodedInt(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadEncodedInt(); - } + fire = pois = nrgy = chaos = direct = 0; + phys = cold = 50; } } diff --git a/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs b/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs index d00563ab0..4f8d333b7 100644 --- a/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs +++ b/Projects/UOContent/Items/Quivers/QuiverOfLightning.cs @@ -1,37 +1,21 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0)] +public partial class QuiverOfLightning : ElvenQuiver { - public class QuiverOfLightning : ElvenQuiver + [Constructible] + public QuiverOfLightning() => Hue = 0x4F9; + + public override int LabelNumber => 1073112; // Quiver of Lightning + + public override void AlterBowDamage( + ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, + ref int chaos, ref int direct + ) { - [Constructible] - public QuiverOfLightning() => Hue = 0x4F9; - - public QuiverOfLightning(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1073112; // Quiver of Lightning - - public override void AlterBowDamage( - ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, - ref int chaos, ref int direct - ) - { - fire = cold = pois = chaos = direct = 0; - phys = nrgy = 50; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.WriteEncodedInt(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadEncodedInt(); - } + fire = cold = pois = chaos = direct = 0; + phys = nrgy = 50; } } diff --git a/Projects/UOContent/Migrations/Server.Items.BaseQuiver.v1.json b/Projects/UOContent/Migrations/Server.Items.BaseQuiver.v1.json new file mode 100644 index 000000000..5999423c2 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseQuiver.v1.json @@ -0,0 +1,66 @@ +{ + "version": 1, + "type": "Server.Items.BaseQuiver", + "properties": [ + { + "name": "Attributes", + "type": "Server.AosAttributes", + "usesSaveFlag": true, + "rule": "RawSerializableMigrationRule", + "ruleArguments": [ + "DeserializationRequiresParent" + ] + }, + { + "name": "LowerAmmoCost", + "type": "int", + "usesSaveFlag": true, + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "WeightReduction", + "type": "int", + "usesSaveFlag": true, + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "DamageIncrease", + "type": "int", + "usesSaveFlag": true, + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Crafter", + "type": "string", + "usesSaveFlag": true, + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Quality", + "type": "Server.Items.ClothingQuality", + "usesSaveFlag": true, + "rule": "EnumMigrationRule" + }, + { + "name": "Capacity", + "type": "int", + "usesSaveFlag": true, + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ElvenQuiver.v0.json b/Projects/UOContent/Migrations/Server.Items.ElvenQuiver.v0.json new file mode 100644 index 000000000..1cb6cbc89 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ElvenQuiver.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.ElvenQuiver" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.QuiverOfBlight.v0.json b/Projects/UOContent/Migrations/Server.Items.QuiverOfBlight.v0.json new file mode 100644 index 000000000..535deea1f --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.QuiverOfBlight.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.QuiverOfBlight" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.QuiverOfFire.v0.json b/Projects/UOContent/Migrations/Server.Items.QuiverOfFire.v0.json new file mode 100644 index 000000000..9874258e0 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.QuiverOfFire.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.QuiverOfFire" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.QuiverOfIce.v0.json b/Projects/UOContent/Migrations/Server.Items.QuiverOfIce.v0.json new file mode 100644 index 000000000..14d03773b --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.QuiverOfIce.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.QuiverOfIce" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.QuiverOfLightning.v0.json b/Projects/UOContent/Migrations/Server.Items.QuiverOfLightning.v0.json new file mode 100644 index 000000000..43ce52809 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.QuiverOfLightning.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.QuiverOfLightning" +} \ No newline at end of file