diff --git a/Projects/UOContent/Items/Containers/TreasureChest.cs b/Projects/UOContent/Items/Containers/TreasureChest.cs index b578438c4..d0f9f3acb 100644 --- a/Projects/UOContent/Items/Containers/TreasureChest.cs +++ b/Projects/UOContent/Items/Containers/TreasureChest.cs @@ -1,83 +1,31 @@ -namespace Server.Items +namespace Server.Items; + +[Flippable(0xe43, 0xe42)] +[Serializable(0, false)] +public partial class WoodenTreasureChest : BaseTreasureChest { - [Flippable(0xe43, 0xe42)] - public class WoodenTreasureChest : BaseTreasureChest + [Constructible] + public WoodenTreasureChest() : base(0xE43) + { + } +} + +[Flippable(0xe41, 0xe40)] +[Serializable(0, false)] +public partial class MetalGoldenTreasureChest : BaseTreasureChest +{ + [Constructible] + public MetalGoldenTreasureChest() : base(0xE41) + { + } +} + +[Flippable(0x9ab, 0xe7c)] +[Serializable(0, false)] +public partial class MetalTreasureChest : BaseTreasureChest +{ + [Constructible] + public MetalTreasureChest() : base(0x9AB) { - [Constructible] - public WoodenTreasureChest() : base(0xE43) - { - } - - public WoodenTreasureChest(Serial serial) : base(serial) - { - } - - 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(); - } - } - - [Flippable(0xe41, 0xe40)] - public class MetalGoldenTreasureChest : BaseTreasureChest - { - [Constructible] - public MetalGoldenTreasureChest() : base(0xE41) - { - } - - public MetalGoldenTreasureChest(Serial serial) : base(serial) - { - } - - 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(); - } - } - - [Flippable(0x9ab, 0xe7c)] - public class MetalTreasureChest : BaseTreasureChest - { - [Constructible] - public MetalTreasureChest() : base(0x9AB) - { - } - - public MetalTreasureChest(Serial serial) : base(serial) - { - } - - 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(); - } } } diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs index 1f8f4c6fa..28dacc9a7 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs @@ -1,124 +1,94 @@ using System; -namespace Server.Items +namespace Server.Items; + +[Serializable(0, false)] +public partial class TreasureChestLevel1 : LockableContainer { - public class TreasureChestLevel1 : LockableContainer + [Constructible] + public TreasureChestLevel1() : base(0xE41) { - private const int m_Level = 1; + SetChestAppearance(); + Movable = false; - [Constructible] - public TreasureChestLevel1() - : base(0xE41) + TrapType = TrapType.DartTrap; + TrapPower = Utility.Random(1, 25); + Locked = true; + + RequiredSkill = 57; + LockLevel = RequiredSkill - Utility.Random(1, 10); + MaxLockLevel = RequiredSkill + Utility.Random(1, 10); + + // According to OSI, loot in level 1 chest is: + // Gold 25 - 50 + // Bolts 10 + // Gems + // Normal weapon + // Normal armour + // Normal clothing + // Normal jewelry + + // Gold + DropItem(new Gold(Utility.Random(30, 100))); + + // Drop bolts + // DropItem( new Bolt( 10 ) ); + + // Gems + if (Utility.RandomBool()) { - SetChestAppearance(); - Movable = false; - - TrapType = TrapType.DartTrap; - TrapPower = m_Level * Utility.Random(1, 25); - Locked = true; - - RequiredSkill = 57; - LockLevel = RequiredSkill - Utility.Random(1, 10); - MaxLockLevel = RequiredSkill + Utility.Random(1, 10); - - // According to OSI, loot in level 1 chest is: - // Gold 25 - 50 - // Bolts 10 - // Gems - // Normal weapon - // Normal armour - // Normal clothing - // Normal jewelry - - // Gold - DropItem(new Gold(Utility.Random(30, 100))); - - // Drop bolts - // DropItem( new Bolt( 10 ) ); - - // Gems - if (Utility.RandomBool()) - { - var GemLoot = Loot.RandomGem(); - GemLoot.Amount = Utility.Random(1, 3); - DropItem(GemLoot); - } - - // Weapon - if (Utility.RandomBool()) - { - DropItem(Loot.RandomWeapon()); - } - - // Armour - if (Utility.RandomBool()) - { - DropItem(Loot.RandomArmorOrShield()); - } - - // Clothing - if (Utility.RandomBool()) - { - DropItem(Loot.RandomClothing()); - } - - // Jewelry - if (Utility.RandomBool()) - { - DropItem(Loot.RandomJewelry()); - } + var gems = Loot.RandomGem(); + gems.Amount = Utility.Random(1, 3); + DropItem(gems); } - public TreasureChestLevel1(Serial serial) - : base(serial) + // Weapon + if (Utility.RandomBool()) { + DropItem(Loot.RandomWeapon()); } - public override bool Decays => true; - - public override bool IsDecoContainer => false; - - public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); - - public override int DefaultGumpID => 0x42; - - public override int DefaultDropSound => 0x42; - - public override Rectangle2D Bounds => new(18, 105, 144, 73); - - private void SetChestAppearance() + // Armour + if (Utility.RandomBool()) { - var UseFirstItemId = Utility.RandomBool(); - - switch (Utility.RandomList(0, 1, 2)) - { - case 0: // Large Crate - ItemID = UseFirstItemId ? 0xe3c : 0xe3d; - GumpID = 0x44; - break; - - case 1: // Medium Crate - ItemID = UseFirstItemId ? 0xe3e : 0xe3f; - GumpID = 0x44; - break; - - case 2: // Small Crate - ItemID = UseFirstItemId ? 0x9a9 : 0xe7e; - GumpID = 0x44; - break; - } + DropItem(Loot.RandomArmorOrShield()); } - public override void Serialize(IGenericWriter writer) + // Clothing + if (Utility.RandomBool()) { - base.Serialize(writer); - writer.Write(1); // version + DropItem(Loot.RandomClothing()); } - public override void Deserialize(IGenericReader reader) + // Jewelry + if (Utility.RandomBool()) { - base.Deserialize(reader); - var version = reader.ReadInt(); + DropItem(Loot.RandomJewelry()); } } + + public override bool Decays => true; + + public override bool IsDecoContainer => false; + + public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); + + public override int DefaultGumpID => 0x44; + + public override int DefaultDropSound => 0x42; + + public override Rectangle2D Bounds => new(18, 105, 144, 73); + + private void SetChestAppearance() + { + ItemID = Utility.Random(6) switch + { + 0 => 0xe3c, // Large Crate + 1 => 0xe3d, // Large Crate + 2 => 0xe3e, // Medium Crate + 3 => 0xe3f, // Medium Crate + 4 => 0x9a9, // Small Crate + _ => 0xe7e // Small Crate + }; + } } diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel2.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel2.cs index 14e4d3946..00ff932ac 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel2.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel2.cs @@ -1,147 +1,116 @@ using System; -namespace Server.Items +namespace Server.Items; + +[Serializable(0, false)] +public partial class TreasureChestLevel2 : LockableContainer { - public class TreasureChestLevel2 : LockableContainer + [Constructible] + public TreasureChestLevel2() : base(0xE41) { - private const int m_Level = 2; + SetChestAppearance(); + Movable = false; - [Constructible] - public TreasureChestLevel2() - : base(0xE41) + TrapType = TrapType.ExplosionTrap; + TrapPower = 2 * Utility.Random(1, 25); + Locked = true; + + RequiredSkill = 72; + LockLevel = RequiredSkill - Utility.Random(1, 10); + MaxLockLevel = RequiredSkill + Utility.Random(1, 10); + + // According to OSI, loot in level 2 chest is: + // Gold 80 - 150 + // Arrows 10 + // Reagents + // Scrolls + // Potions + // Gems + + // Gold + DropItem(new Gold(Utility.Random(70, 100))); + + // Drop bolts + // DropItem( new Arrow( 10 ) ); + + // Reagents + for (var i = Utility.Random(3); i > 0; i--) { - SetChestAppearance(); - Movable = false; - - TrapType = TrapType.ExplosionTrap; - TrapPower = m_Level * Utility.Random(1, 25); - Locked = true; - - RequiredSkill = 72; - LockLevel = RequiredSkill - Utility.Random(1, 10); - MaxLockLevel = RequiredSkill + Utility.Random(1, 10); - - // According to OSI, loot in level 2 chest is: - // Gold 80 - 150 - // Arrows 10 - // Reagents - // Scrolls - // Potions - // Gems - - // Gold - DropItem(new Gold(Utility.Random(70, 100))); - - // Drop bolts - // DropItem( new Arrow( 10 ) ); - - // Reagents - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var ReagentLoot = Loot.RandomReagent(); - ReagentLoot.Amount = Utility.Random(1, m_Level); - DropItem(ReagentLoot); - } - - // Scrolls - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - Item ScrollLoot = Loot.RandomScroll(0, 39, SpellbookType.Regular); - ScrollLoot.Amount = Utility.Random(1, 8); - DropItem(ScrollLoot); - } - - // Potions - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var PotionLoot = Loot.RandomPotion(); - DropItem(PotionLoot); - } - - // Gems - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var GemLoot = Loot.RandomGem(); - GemLoot.Amount = Utility.Random(1, 6); - DropItem(GemLoot); - } + var reagents = Loot.RandomReagent(); + reagents.Amount = Utility.Random(1, 2); + DropItem(reagents); } - public TreasureChestLevel2(Serial serial) - : base(serial) + // Scrolls + if (Utility.RandomBool()) { + var scrolls = Loot.RandomScroll(0, 39, SpellbookType.Regular); + scrolls.Amount = Utility.Random(1, 8); + DropItem(scrolls); } - public override bool Decays => true; - - public override bool IsDecoContainer => false; - - public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); - - public override int DefaultGumpID => 0x42; - - public override int DefaultDropSound => 0x42; - - public override Rectangle2D Bounds => new(18, 105, 144, 73); - - private void SetChestAppearance() + // Potions + if (Utility.RandomBool()) { - var UseFirstItemId = Utility.RandomBool(); - - switch (Utility.RandomList(0, 1, 2, 3, 4, 5, 6, 7)) - { - case 0: // Large Crate - ItemID = UseFirstItemId ? 0xe3c : 0xe3d; - GumpID = 0x44; - break; - - case 1: // Medium Crate - ItemID = UseFirstItemId ? 0xe3e : 0xe3f; - GumpID = 0x44; - break; - - case 2: // Small Crate - ItemID = UseFirstItemId ? 0x9a9 : 0xe7e; - GumpID = 0x44; - break; - - case 3: // Wooden Chest - ItemID = UseFirstItemId ? 0xe42 : 0xe43; - GumpID = 0x49; - break; - - case 4: // Metal Chest - ItemID = UseFirstItemId ? 0x9ab : 0xe7c; - GumpID = 0x4A; - break; - - case 5: // Metal Golden Chest - ItemID = UseFirstItemId ? 0xe40 : 0xe41; - GumpID = 0x42; - break; - - case 6: // Keg - ItemID = 0xe7f; - GumpID = 0x3e; - break; - - case 7: // Barrel - ItemID = 0xe77; - GumpID = 0x3e; - break; - } + DropItem(Loot.RandomPotion()); } - public override void Serialize(IGenericWriter writer) + // Gems + if (Utility.RandomBool()) { - base.Serialize(writer); - writer.Write(1); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); + var gems = Loot.RandomGem(); + gems.Amount = Utility.Random(1, 6); + DropItem(gems); } } + + public override bool Decays => true; + + public override bool IsDecoContainer => false; + + public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); + + public override int DefaultGumpID => 0x42; + + public override int DefaultDropSound => 0x42; + + public override Rectangle2D Bounds => new(18, 105, 144, 73); + + private static readonly ValueTuple[] _chestAppearances = + { + // Large Crate + ValueTuple.Create(0xe3c, 0x44), + ValueTuple.Create(0xe3d, 0x44), + + // Medium Crate + ValueTuple.Create(0xe3e, 0x44), + ValueTuple.Create(0xe3f, 0x44), + + // Small Crate + ValueTuple.Create(0x9a9, 0x44), + ValueTuple.Create(0xe7e, 0x44), + + // Wooden Chest + ValueTuple.Create(0xe42, 0x49), + ValueTuple.Create(0xe43, 0x49), + + // Metal Chest + ValueTuple.Create(0x9ab, 0x4A), + ValueTuple.Create(0xe7c, 0x4A), + + // Metal Golden Chest + ValueTuple.Create(0xe40, 0x42), + ValueTuple.Create(0xe41, 0x42), + + // Keg + ValueTuple.Create(0xe7f, 0x3e), + + // Barrel + ValueTuple.Create(0xe77, 0x3e), + }; + + private void SetChestAppearance() + { + (ItemID, GumpID) = _chestAppearances.RandomElement(); + } } diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs index bcd179d9a..a4368ea8d 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs @@ -1,166 +1,143 @@ using System; -namespace Server.Items +namespace Server.Items; + +[Serializable(0, false)] +public partial class TreasureChestLevel3 : LockableContainer { - public class TreasureChestLevel3 : LockableContainer + [Constructible] + public TreasureChestLevel3() : base(0xE41) { - private const int m_Level = 3; + SetChestAppearance(); + Movable = false; - [Constructible] - public TreasureChestLevel3() - : base(0xE41) + TrapType = TrapType.PoisonTrap; + TrapPower = 3 * Utility.Random(1, 25); + Locked = true; + + RequiredSkill = 84; + LockLevel = RequiredSkill - Utility.Random(1, 10); + MaxLockLevel = RequiredSkill + Utility.Random(1, 10); + + // According to OSI, loot in level 3 chest is: + // Gold 250 - 350 + // Arrows 10 + // Reagents + // Scrolls + // Potions + // Gems + // Magic Wand + // Magic weapon + // Magic armour + // Magic clothing (not implemented) + // Magic jewelry (not implemented) + + // Gold + DropItem(new Gold(Utility.Random(180, 240))); + + // Drop bolts + // DropItem( new Arrow( 10 ) ); + + // Reagents + for (var i = Utility.Random(2); i >= 0; i--) { - SetChestAppearance(); - Movable = false; - - TrapType = TrapType.PoisonTrap; - TrapPower = m_Level * Utility.Random(1, 25); - Locked = true; - - RequiredSkill = 84; - LockLevel = RequiredSkill - Utility.Random(1, 10); - MaxLockLevel = RequiredSkill + Utility.Random(1, 10); - - // According to OSI, loot in level 3 chest is: - // Gold 250 - 350 - // Arrows 10 - // Reagents - // Scrolls - // Potions - // Gems - // Magic Wand - // Magic weapon - // Magic armour - // Magic clothing (not implemented) - // Magic jewelry (not implemented) - - // Gold - DropItem(new Gold(Utility.Random(180, 240))); - - // Drop bolts - // DropItem( new Arrow( 10 ) ); - - // Reagents - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var ReagentLoot = Loot.RandomReagent(); - ReagentLoot.Amount = Utility.Random(1, 9); - DropItem(ReagentLoot); - } - - // Scrolls - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - Item ScrollLoot = Loot.RandomScroll(0, 47, SpellbookType.Regular); - ScrollLoot.Amount = Utility.Random(1, 12); - DropItem(ScrollLoot); - } - - // Potions - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var PotionLoot = Loot.RandomPotion(); - DropItem(PotionLoot); - } - - // Gems - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var GemLoot = Loot.RandomGem(); - GemLoot.Amount = Utility.Random(1, 9); - DropItem(GemLoot); - } - - // Magic Wand - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - DropItem(Loot.RandomWand()); - } - - // Equipment - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var item = Loot.RandomArmorOrShieldOrWeapon(); - - if (item is BaseWeapon weapon) - { - weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(m_Level); - weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(m_Level); - weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(m_Level); - weapon.Quality = WeaponQuality.Regular; - } - else if (item is BaseArmor armor) - { - armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(m_Level); - armor.Durability = (ArmorDurabilityLevel)Utility.Random(m_Level); - armor.Quality = ArmorQuality.Regular; - } - - DropItem(item); - } - - // Clothing - for (var i = Utility.Random(1, 2); i > 1; i--) - { - DropItem(Loot.RandomClothing()); - } - - // Jewelry - for (var i = Utility.Random(1, 2); i > 1; i--) - { - DropItem(Loot.RandomJewelry()); - } + var reagents = Loot.RandomReagent(); + reagents.Amount = Utility.Random(1, 9); + DropItem(reagents); } - public TreasureChestLevel3(Serial serial) - : base(serial) + // Scrolls + for (var i = Utility.Random(3); i > 0; i--) { + var scrolls = Loot.RandomScroll(0, 47, SpellbookType.Regular); + scrolls.Amount = Utility.Random(1, 12); + DropItem(scrolls); } - public override bool Decays => true; - - public override bool IsDecoContainer => false; - - public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); - - public override int DefaultGumpID => 0x42; - - public override int DefaultDropSound => 0x42; - - public override Rectangle2D Bounds => new(18, 105, 144, 73); - - private void SetChestAppearance() + // Potions + for (var i = Utility.Random(3); i > 0; i--) { - var UseFirstItemId = Utility.RandomBool(); - switch (Utility.RandomList(0, 1, 2)) + DropItem(Loot.RandomPotion()); + } + + // Gems + for (var i = Utility.Random(3); i > 0; i--) + { + var gems = Loot.RandomGem(); + gems.Amount = Utility.Random(1, 9); + DropItem(gems); + } + + // Magic Wand + for (var i = Utility.Random(3); i > 0; i--) + { + DropItem(Loot.RandomWand()); + } + + // Equipment + for (var i = Utility.Random(3); i > 0; i--) + { + var item = Loot.RandomArmorOrShieldOrWeapon(); + + if (item is BaseWeapon weapon) { - case 0: // Wooden Chest - ItemID = UseFirstItemId ? 0xe42 : 0xe43; - GumpID = 0x49; - break; - - case 1: // Metal Chest - ItemID = UseFirstItemId ? 0x9ab : 0xe7c; - GumpID = 0x4A; - break; - - case 2: // Metal Golden Chest - ItemID = UseFirstItemId ? 0xe40 : 0xe41; - GumpID = 0x42; - break; + weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(3); + weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(3); + weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(3); + weapon.Quality = WeaponQuality.Regular; } + else if (item is BaseArmor armor) + { + armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(3); + armor.Durability = (ArmorDurabilityLevel)Utility.Random(3); + armor.Quality = ArmorQuality.Regular; + } + + DropItem(item); } - public override void Serialize(IGenericWriter writer) + // Clothing + for (var i = Utility.Random(3); i > 0; i--) { - base.Serialize(writer); - writer.Write(1); // version + DropItem(Loot.RandomClothing()); } - public override void Deserialize(IGenericReader reader) + // Jewelry + for (var i = Utility.Random(3); i > 0; i--) { - base.Deserialize(reader); - var version = reader.ReadInt(); + DropItem(Loot.RandomJewelry()); } } + + public override bool Decays => true; + + public override bool IsDecoContainer => false; + + public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); + + public override int DefaultGumpID => 0x42; + + public override int DefaultDropSound => 0x42; + + public override Rectangle2D Bounds => new(18, 105, 144, 73); + + private static readonly ValueTuple[] _chestAppearances = + { + // Wooden Chest + ValueTuple.Create(0xe42, 0x49), + ValueTuple.Create(0xe43, 0x49), + + // Metal Chest + ValueTuple.Create(0x9ab, 0x4A), + ValueTuple.Create(0xe7c, 0x4A), + + // Metal Golden Chest + ValueTuple.Create(0xe40, 0x42), + ValueTuple.Create(0xe41, 0x42), + }; + + private void SetChestAppearance() + { + (ItemID, GumpID) = _chestAppearances.RandomElement(); + } } diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs index ba550a924..0c223e215 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs @@ -1,175 +1,149 @@ using System; -namespace Server.Items +namespace Server.Items; + +[Serializable(0, false)] +public partial class TreasureChestLevel4 : LockableContainer { - public class TreasureChestLevel4 : LockableContainer + [Constructible] + public TreasureChestLevel4() : base(0xE41) { - private const int m_Level = 4; + SetChestAppearance(); + Movable = false; - [Constructible] - public TreasureChestLevel4() - : base(0xE41) + TrapType = TrapType.ExplosionTrap; + TrapPower = 4 * Utility.Random(10, 25); + Locked = true; + + RequiredSkill = 92; + LockLevel = RequiredSkill - Utility.Random(1, 10); + MaxLockLevel = RequiredSkill + Utility.Random(1, 10); + + // According to OSI, loot in level 4 chest is: + // Gold 500 - 900 + // Reagents + // Scrolls + // Blank scrolls + // Potions + // Gems + // Magic Wand + // Magic weapon + // Magic armour + // Magic clothing (not implemented) + // Magic jewelry (not implemented) + // Crystal ball (not implemented) + + // Gold + DropItem(new Gold(Utility.Random(200, 400))); + + // Reagents + for (var i = Utility.Random(4); i > 0; i--) { - SetChestAppearance(); - Movable = false; - - TrapType = TrapType.ExplosionTrap; - TrapPower = m_Level * Utility.Random(10, 25); - Locked = true; - - RequiredSkill = 92; - LockLevel = RequiredSkill - Utility.Random(1, 10); - MaxLockLevel = RequiredSkill + Utility.Random(1, 10); - - // According to OSI, loot in level 4 chest is: - // Gold 500 - 900 - // Reagents - // Scrolls - // Blank scrolls - // Potions - // Gems - // Magic Wand - // Magic weapon - // Magic armour - // Magic clothing (not implemented) - // Magic jewelry (not implemented) - // Crystal ball (not implemented) - - // Gold - DropItem(new Gold(Utility.Random(200, 400))); - - // Reagents - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var ReagentLoot = Loot.RandomReagent(); - ReagentLoot.Amount = 12; - DropItem(ReagentLoot); - } - - // Scrolls - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - Item ScrollLoot = Loot.RandomScroll(0, 47, SpellbookType.Regular); - ScrollLoot.Amount = 16; - DropItem(ScrollLoot); - } - - // Drop blank scrolls - DropItem(new BlankScroll(Utility.Random(1, m_Level))); - - // Potions - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var PotionLoot = Loot.RandomPotion(); - DropItem(PotionLoot); - } - - // Gems - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var GemLoot = Loot.RandomGem(); - GemLoot.Amount = 12; - DropItem(GemLoot); - } - - // Magic Wand - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - DropItem(Loot.RandomWand()); - } - - // Equipment - for (var i = Utility.Random(1, m_Level); i > 1; i--) - { - var item = Loot.RandomArmorOrShieldOrWeapon(); - - if (item is BaseWeapon weapon) - { - weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(m_Level); - weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(m_Level); - weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(m_Level); - weapon.Quality = WeaponQuality.Regular; - } - else if (item is BaseArmor armor) - { - armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(m_Level); - armor.Durability = (ArmorDurabilityLevel)Utility.Random(m_Level); - armor.Quality = ArmorQuality.Regular; - } - - DropItem(item); - } - - // Clothing - for (var i = Utility.Random(1, 2); i > 1; i--) - { - DropItem(Loot.RandomClothing()); - } - - // Jewelry - for (var i = Utility.Random(1, 2); i > 1; i--) - { - DropItem(Loot.RandomJewelry()); - } - - // Crystal ball (not implemented) + var reagents = Loot.RandomReagent(); + reagents.Amount = 12; + DropItem(reagents); } - public TreasureChestLevel4(Serial serial) - : base(serial) + // Scrolls + for (var i = Utility.Random(4); i > 0; i--) { + var scroll = Loot.RandomScroll(0, 47, SpellbookType.Regular); + scroll.Amount = 16; + DropItem(scroll); } - public override bool Decays => true; + // Drop blank scrolls + DropItem(new BlankScroll(Utility.Random(1, 4))); - public override bool IsDecoContainer => false; - - public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); - - public override int DefaultGumpID => 0x42; - - public override int DefaultDropSound => 0x42; - - public override Rectangle2D Bounds => new(18, 105, 144, 73); - - private void SetChestAppearance() + // Potions + for (var i = Utility.Random(4); i > 0; i--) { - var UseFirstItemId = Utility.RandomBool(); + DropItem(Loot.RandomPotion()); + } - switch (Utility.Random(4)) + // Gems + for (var i = Utility.Random(4); i > 0; i--) + { + var gems = Loot.RandomGem(); + gems.Amount = 12; + DropItem(gems); + } + + // Magic Wand + for (var i = Utility.Random(4); i > 0; i--) + { + DropItem(Loot.RandomWand()); + } + + // Equipment + for (var i = Utility.Random(4); i > 0; i--) + { + var item = Loot.RandomArmorOrShieldOrWeapon(); + + if (item is BaseWeapon weapon) { - case 0: // Wooden Chest - ItemID = UseFirstItemId ? 0xe42 : 0xe43; - GumpID = 0x49; - break; - - case 1: // Metal Chest - ItemID = UseFirstItemId ? 0x9ab : 0xe7c; - GumpID = 0x4A; - break; - - case 2: // Metal Golden Chest - ItemID = UseFirstItemId ? 0xe40 : 0xe41; - GumpID = 0x42; - break; - - case 3: // Keg - ItemID = 0xe7f; - GumpID = 0x3e; - break; + weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(4); + weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(4); + weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(4); + weapon.Quality = WeaponQuality.Regular; } + else if (item is BaseArmor armor) + { + armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(4); + armor.Durability = (ArmorDurabilityLevel)Utility.Random(4); + armor.Quality = ArmorQuality.Regular; + } + + DropItem(item); } - public override void Serialize(IGenericWriter writer) + // Clothing + for (var i = Utility.Random(3); i > 0; i--) { - base.Serialize(writer); - writer.Write(1); // version + DropItem(Loot.RandomClothing()); } - public override void Deserialize(IGenericReader reader) + // Jewelry + for (var i = Utility.Random(3); i > 0; i--) { - base.Deserialize(reader); - var version = reader.ReadInt(); + DropItem(Loot.RandomJewelry()); } + + // Crystal ball (not implemented) + } + + public override bool Decays => true; + + public override bool IsDecoContainer => false; + + public override TimeSpan DecayTime => TimeSpan.FromMinutes(Utility.Random(15, 60)); + + public override int DefaultGumpID => 0x42; + + public override int DefaultDropSound => 0x42; + + public override Rectangle2D Bounds => new(18, 105, 144, 73); + + private static readonly ValueTuple[] _chestAppearances = + { + // Wooden Chest + ValueTuple.Create(0xe42, 0x49), + ValueTuple.Create(0xe43, 0x49), + + // Metal Chest + ValueTuple.Create(0x9ab, 0x4A), + ValueTuple.Create(0xe7c, 0x4A), + + // Metal Golden Chest + ValueTuple.Create(0xe40, 0x42), + ValueTuple.Create(0xe41, 0x42), + + // Keg + ValueTuple.Create(0xe7f, 0x3e), + }; + + private void SetChestAppearance() + { + (ItemID, GumpID) = _chestAppearances.RandomElement(); } } diff --git a/Projects/UOContent/Migrations/Server.Items.MetalGoldenTreasureChest.v0.json b/Projects/UOContent/Migrations/Server.Items.MetalGoldenTreasureChest.v0.json new file mode 100644 index 000000000..c4e11b5e3 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.MetalGoldenTreasureChest.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.MetalGoldenTreasureChest" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.MetalTreasureChest.v0.json b/Projects/UOContent/Migrations/Server.Items.MetalTreasureChest.v0.json new file mode 100644 index 000000000..75aa355b8 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.MetalTreasureChest.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.MetalTreasureChest" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel1.v0.json b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel1.v0.json new file mode 100644 index 000000000..a02072708 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel1.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.TreasureChestLevel1" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel2.v0.json b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel2.v0.json new file mode 100644 index 000000000..321df3f4d --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel2.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.TreasureChestLevel2" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel3.v0.json b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel3.v0.json new file mode 100644 index 000000000..5e279bc26 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel3.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.TreasureChestLevel3" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel4.v0.json b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel4.v0.json new file mode 100644 index 000000000..eeb91f0cd --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.TreasureChestLevel4.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.TreasureChestLevel4" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.WoodenTreasureChest.v0.json b/Projects/UOContent/Migrations/Server.Items.WoodenTreasureChest.v0.json new file mode 100644 index 000000000..73b84ec68 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.WoodenTreasureChest.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.WoodenTreasureChest" +} \ No newline at end of file