From 7dfb45d4eb2db8f3776e2e70bc62814a26c039ec Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Tue, 23 Jul 2024 20:31:02 -0700 Subject: [PATCH] fix: Removes wrong error message from Fireflies (#1884) --- .../Veteran Rewards/RewardDemolitionGump.cs | 48 +- .../Christmas/2010/Addons/FireFliesDeed.cs | 424 +++++++++--------- 2 files changed, 225 insertions(+), 247 deletions(-) diff --git a/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs b/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs index a5cac8407..270c2af29 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs @@ -36,36 +36,36 @@ namespace Server.Gumps return; } - if (info.ButtonID == (int)Buttons.Confirm) + if (info.ButtonID != (int)Buttons.Confirm) { - var m = sender.Mobile; - var house = BaseHouse.FindHouseAt(m); + return; + } - if (house?.IsOwner(m) == true) - { - if (m.InRange(item.Location, 2)) - { - var deed = m_Addon.Deed; + var m = sender.Mobile; + var house = BaseHouse.FindHouseAt(m); - if (deed != null) - { - m.AddToBackpack(deed); - house.Addons.Remove(item); - item.Delete(); - } - } - else - { - m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. - } - } - else + if (house?.IsOwner(m) != true) + { + // You can only re-deed this decoration if you are the house owner or originally placed the decoration. + m.SendLocalizedMessage(1049784); + return; + } + + if (m.InRange(item.Location, 2)) + { + var deed = m_Addon.Deed; + + if (deed != null) { - m.SendLocalizedMessage( - 1049784 - ); // You can only re-deed this decoration if you are the house owner or originally placed the decoration. + m.AddToBackpack(deed); + house.Addons.Remove(item); + item.Delete(); } } + else + { + m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } private enum Buttons diff --git a/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs b/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs index eddea7359..643b31d4d 100644 --- a/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs +++ b/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs @@ -4,244 +4,222 @@ using Server.Multis; using Server.Network; using Server.Targeting; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0)] +public partial class Fireflies : Item, IAddon { - [SerializationGenerator(0)] - public partial class Fireflies : Item, IAddon + [Constructible] + public Fireflies(int itemID = 0x1596) : base(itemID) { - [Constructible] - public Fireflies(int itemID = 0x1596) - : base(itemID) - { - LootType = LootType.Blessed; - Movable = false; - } - - public override int LabelNumber => 1150061; - - public bool FacingSouth => ItemID == 0x2336; - - public Item Deed => new FirefliesDeed(); - - public bool CouldFit(IPoint3D p, Map map) - { - if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true) - { - return false; - } - - return FacingSouth ? - BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map) : - BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); - } - - public override void OnDoubleClick(Mobile from) - { - if (from.InRange(Location, 3)) - { - var house = BaseHouse.FindHouseAt(this); - - if (house?.IsOwner(from) == true) - { - from.CloseGump(); - from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration? - } - else - { - from.SendLocalizedMessage( - 1049784 - ); // You can only re-deed this decoration if you are the house owner or originally placed the decoration. - } - } - else - { - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. - } - } + LootType = LootType.Blessed; + Movable = false; } - [SerializationGenerator(0)] - public partial class FirefliesDeed : Item + public override int LabelNumber => 1150061; + + public bool FacingSouth => ItemID == 0x2336; + + public Item Deed => new FirefliesDeed(); + + public bool CouldFit(IPoint3D p, Map map) { - [Constructible] - public FirefliesDeed() - : base(0x14F0) + if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true) { - LootType = LootType.Blessed; - Weight = 1.0; + return false; } - public override int LabelNumber => 1150061; + return FacingSouth + ? BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map) + : BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); + } - public override void OnDoubleClick(Mobile from) + public override void OnDoubleClick(Mobile from) + { + if (!from.InRange(Location, 3)) { - if (IsChildOf(from.Backpack)) - { - var house = BaseHouse.FindHouseAt(from); - - if (house?.IsOwner(from) == true) - { - from.CloseGump(); - - if (!from.SendGump(new FacingGump(this, from))) - { - from.SendLocalizedMessage(1150062); // You fail to re-deed the holiday fireflies. - } - } - else - { - from.SendLocalizedMessage(502092); // You must be in your house to do this. - } - } - else - { - from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. - } + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + return; } - private class FacingGump : Gump + var house = BaseHouse.FindHouseAt(this); + + if (house?.IsOwner(from) == true) { - private readonly FirefliesDeed m_Deed; - private readonly Mobile m_Placer; - - public FacingGump(FirefliesDeed deed, Mobile player) - : base(150, 50) - { - m_Deed = deed; - m_Placer = player; - - Closable = true; - Disposable = true; - Draggable = true; - Resizable = false; - - AddPage(0); - - AddBackground(0, 0, 300, 150, 0xA28); - - AddItem(90, 30, 0x2332); - AddItem(180, 30, 0x2336); - - AddButton(50, 35, 0x868, 0x869, (int)Buttons.East); - AddButton(145, 35, 0x868, 0x869, (int)Buttons.South); - } - - public override void OnResponse(NetState sender, in RelayInfo info) - { - int m_ItemID; - - switch (info.ButtonID) - { - case (int)Buttons.East: - m_ItemID = 0x2332; - break; - case (int)Buttons.South: - m_ItemID = 0x2336; - break; - default: return; - } - - m_Placer.Target = new InternalTarget(m_Deed, m_ItemID); - } - - private enum Buttons - { - Cancel, - South, - East - } + from.CloseGump(); + // Do you wish to re-deed this decoration? + from.SendGump(new RewardDemolitionGump(this, 1049783)); } - - private class InternalTarget : Target + else { - private readonly FirefliesDeed m_FirefliesDeed; - private readonly int m_ItemID; - - public InternalTarget(FirefliesDeed m_Deed, int itemid) - : base(-1, true, TargetFlags.None) - { - m_FirefliesDeed = m_Deed; - m_ItemID = itemid; - } - - protected override void OnTarget(Mobile from, object targeted) - { - if (m_FirefliesDeed?.Deleted != false) - { - return; - } - - if (m_FirefliesDeed.IsChildOf(from.Backpack)) - { - var house = BaseHouse.FindHouseAt(from); - - if (house?.IsOwner(from) == true) - { - var p = targeted as IPoint3D; - var map = from.Map; - - if (p == null || map == null || map == Map.Internal) - { - return; - } - - var p3d = new Point3D(p); - var id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; - - if (map.CanFit(p3d, id.Height)) - { - house = BaseHouse.FindHouseAt(p3d, map, id.Height); - - if (house?.IsOwner(from) == true) - { - var north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); - var west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); - - bool isclear = true; - - foreach (Fireflies fireflies in Map.Malas.GetItemsAt(p3d)) - { - if (fireflies.Z == p3d.Z) - { - isclear = false; - } - } - - if ((m_ItemID == 0x2336 && north || m_ItemID == 0x2332 && west) && isclear) - { - var flies = new Fireflies(m_ItemID); - - house.Addons.Add(flies); - - flies.MoveToWorld(p3d, from.Map); - - m_FirefliesDeed.Delete(); - } - else - { - from.SendLocalizedMessage(1150065); // Holiday fireflies must be placed next to a wall. - } - } - else - { - from.SendLocalizedMessage(1042036); // That location is not in your house. - } - } - else - { - from.SendLocalizedMessage(500269); // You cannot build that there. - } - } - else - { - from.SendLocalizedMessage(502092); // You must be in your house to do this. - } - } - else - { - from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. - } - } + // You can only re-deed this decoration if you are the house owner or originally placed the decoration. + from.SendLocalizedMessage(1049784); + } + } +} + +[SerializationGenerator(0)] +public partial class FirefliesDeed : Item +{ + [Constructible] + public FirefliesDeed() : base(0x14F0) + { + LootType = LootType.Blessed; + Weight = 1.0; + } + + public override int LabelNumber => 1150061; + + public override void OnDoubleClick(Mobile from) + { + if (!IsChildOf(from.Backpack)) + { + from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + return; + } + + var house = BaseHouse.FindHouseAt(from); + + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(502092); // You must be in your house to do this. + return; + } + + from.CloseGump(); + from.SendGump(new FacingGump(this, from)); + } + + private class FacingGump : Gump + { + private readonly FirefliesDeed _deed; + private readonly Mobile _placer; + + public FacingGump(FirefliesDeed deed, Mobile player) : base(150, 50) + { + _deed = deed; + _placer = player; + + Closable = true; + Disposable = true; + Draggable = true; + Resizable = false; + + AddPage(0); + + AddBackground(0, 0, 300, 150, 0xA28); + + AddItem(90, 30, 0x2332); + AddItem(180, 30, 0x2336); + + AddButton(50, 35, 0x868, 0x869, (int)Buttons.East); + AddButton(145, 35, 0x868, 0x869, (int)Buttons.South); + } + + public override void OnResponse(NetState sender, in RelayInfo info) + { + if (info.ButtonID == (int)Buttons.Cancel) + { + return; + } + + int itemId = info.ButtonID switch + { + (int)Buttons.East => 0x2332, + (int)Buttons.South => 0x2336, + _ => 0 + }; + + _placer.Target = new InternalTarget(_deed, itemId); + } + + private enum Buttons + { + Cancel, + South, + East + } + } + + private class InternalTarget : Target + { + private readonly FirefliesDeed _firefliesDeed; + private readonly int _itemId; + + public InternalTarget(FirefliesDeed _deed, int itemId) : base(-1, true, TargetFlags.None) + { + _firefliesDeed = _deed; + _itemId = itemId; + } + + protected override void OnTarget(Mobile from, object targeted) + { + if (_firefliesDeed?.Deleted != false) + { + return; + } + + if (!_firefliesDeed.IsChildOf(from.Backpack)) + { + from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + return; + } + + var house = BaseHouse.FindHouseAt(from); + + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(502092); // You must be in your house to do this. + return; + } + + var p = targeted as IPoint3D; + var map = from.Map; + + if (p == null || map == null || map == Map.Internal) + { + return; + } + + var p3d = new Point3D(p); + var id = TileData.ItemTable[_itemId & TileData.MaxItemValue]; + + if (!map.CanFit(p3d, id.Height)) + { + from.SendLocalizedMessage(500269); // You cannot build that there. + return; + } + + house = BaseHouse.FindHouseAt(p3d, map, id.Height); + + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(1042036); // That location is not in your house. + return; + } + + var north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); + var west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); + + if ((_itemId != 0x2336 || !north) && (_itemId != 0x2332 || !west)) + { + from.SendLocalizedMessage(1150065); // Holiday fireflies must be placed next to a wall. + return; + } + + foreach (Fireflies fireflies in Map.Malas.GetItemsAt(p3d)) + { + if (fireflies.Z == p3d.Z) + { + from.SendLocalizedMessage(1150065); // Holiday fireflies must be placed next to a wall. + return; + } + } + + var flies = new Fireflies(_itemId); + house.Addons.Add(flies); + flies.MoveToWorld(p3d, from.Map); + _firefliesDeed.Delete(); } } }