diff --git a/Projects/UOContent/Gumps/ConfirmReleaseGump.cs b/Projects/UOContent/Gumps/ConfirmReleaseGump.cs index a65482f4cf..0afae0efef 100644 --- a/Projects/UOContent/Gumps/ConfirmReleaseGump.cs +++ b/Projects/UOContent/Gumps/ConfirmReleaseGump.cs @@ -1,45 +1,52 @@ using Server.Mobiles; using Server.Network; -namespace Server.Gumps +namespace Server.Gumps; + +public class ConfirmReleaseGump : StaticGump { - public class ConfirmReleaseGump : Gump - { - private readonly Mobile m_From; - private readonly BaseCreature m_Pet; + private readonly Mobile _from; + private readonly BaseCreature _pet; - public ConfirmReleaseGump(Mobile from, BaseCreature pet) : base(50, 50) - { - m_From = from; - m_Pet = pet; + public ConfirmReleaseGump(Mobile from, BaseCreature pet) : base(50, 50) + { + _from = from; + _pet = pet; + } - m_From.CloseGump(); + protected override void BuildLayout(ref StaticGumpBuilder builder) + { + builder.AddPage(); - AddPage(0); + builder.AddBackground(0, 0, 270, 120, 5054); + builder.AddBackground(10, 10, 250, 100, 3000); - AddBackground(0, 0, 270, 120, 5054); - AddBackground(10, 10, 250, 100, 3000); + // Are you sure you want to release your pet? + builder.AddHtmlLocalized(20, 15, 230, 60, 1046257, true, true); - AddHtmlLocalized(20, 15, 230, 60, 1046257, true, true); // Are you sure you want to release your pet? + builder.AddButton(20, 80, 4005, 4007, 2); + builder.AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE - AddButton(20, 80, 4005, 4007, 2); - AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE + builder.AddButton(135, 80, 4005, 4007, 1); + builder.AddHtmlLocalized(170, 80, 75, 20, 1011012); // CANCEL + } - AddButton(135, 80, 4005, 4007, 1); - AddHtmlLocalized(170, 80, 75, 20, 1011012); // CANCEL - } + public override void SendTo(NetState ns) + { + _from.CloseGump(); + base.SendTo(ns); + } - public override void OnResponse(NetState sender, in RelayInfo info) + public override void OnResponse(NetState sender, in RelayInfo info) + { + if (info.ButtonID != 2 || _pet.Deleted || + !(_pet.Controlled && _from == _pet.ControlMaster && + _from.CheckAlive() && _pet.Map == _from.Map && _pet.InRange(_from, 14))) { - if (info.ButtonID != 2 || m_Pet.Deleted || - !(m_Pet.Controlled && m_From == m_Pet.ControlMaster && - m_From.CheckAlive() && m_Pet.Map == m_From.Map && m_Pet.InRange(m_From, 14))) - { - return; - } - - m_Pet.ControlTarget = null; - m_Pet.ControlOrder = OrderType.Release; + return; } + + _pet.ControlTarget = null; + _pet.ControlOrder = OrderType.Release; } } diff --git a/Projects/UOContent/Gumps/TithingGump.cs b/Projects/UOContent/Gumps/TithingGump.cs index 66589d01ad..6c837bef55 100644 --- a/Projects/UOContent/Gumps/TithingGump.cs +++ b/Projects/UOContent/Gumps/TithingGump.cs @@ -2,125 +2,129 @@ using Server.Items; using Server.Network; -namespace Server.Gumps +namespace Server.Gumps; + +public class TithingGump : StaticGump { - public class TithingGump : Gump - { - private readonly Mobile m_From; - private int m_Offer; + // TODO: What's the maximum? + private const int MaxTitheAmount = 100000; + private readonly Mobile _from; + private int _offer; - public TithingGump(Mobile from, int offer) : base(160, 40) - { - var totalGold = from.TotalGold; + public TithingGump(Mobile from) : base(160, 40) => _from = from; - offer = Math.Clamp(offer, 0, totalGold); + protected override void BuildLayout(ref StaticGumpBuilder builder) + { + builder.AddPage(); - m_From = from; - m_Offer = offer; + builder.AddImage(30, 30, 102); - AddPage(0); + // May your wealth bring blessings to those in need, if tithed upon this most sacred site. + builder.AddHtmlLocalized(95, 100, 120, 100, 1060198, 0); - AddImage(30, 30, 102); + builder.AddHtmlLocalized(57, 274, 50, 20, 3000311); // Gold: + // AddLabel(57, 274, 0, "Gold:"); + builder.AddLabelPlaceholder(87, 274, 53, "goldOffer"); - AddHtmlLocalized( - 95, - 100, - 120, - 100, - 1060198, - 0 - ); // May your wealth bring blessings to those in need, if tithed upon this most sacred site. + builder.AddHtmlLocalized(57, 274, 50, 20, 1079251); // Tithe: + // AddLabel(137, 274, 0, "Tithe:"); + builder.AddLabelPlaceholder(172, 274, 53, "titheOffer"); - AddLabel(57, 274, 0, "Gold:"); - AddLabel(87, 274, 53, (totalGold - offer).ToString()); + builder.AddButton(105, 230, 5220, 5220, 2); + builder.AddButton(113, 230, 5222, 5222, 2); + builder.AddLabel(108, 228, 0, "<"); + builder.AddLabel(112, 228, 0, "<"); - AddLabel(137, 274, 0, "Tithe:"); - AddLabel(172, 274, 53, offer.ToString()); + builder.AddButton(127, 230, 5223, 5223, 1); + builder.AddLabel(131, 228, 0, "<"); - AddButton(105, 230, 5220, 5220, 2); - AddButton(113, 230, 5222, 5222, 2); - AddLabel(108, 228, 0, "<"); - AddLabel(112, 228, 0, "<"); + builder.AddButton(147, 230, 5224, 5224, 3); + builder.AddLabel(153, 228, 0, ">"); - AddButton(127, 230, 5223, 5223, 1); - AddLabel(131, 228, 0, "<"); + builder.AddButton(168, 230, 5220, 5220, 4); + builder.AddButton(176, 230, 5222, 5222, 4); + builder.AddLabel(172, 228, 0, ">"); + builder.AddLabel(176, 228, 0, ">"); - AddButton(147, 230, 5224, 5224, 3); - AddLabel(153, 228, 0, ">"); + builder.AddButton(217, 272, 4023, 4024, 5); + } - AddButton(168, 230, 5220, 5220, 4); - AddButton(176, 230, 5222, 5222, 4); - AddLabel(172, 228, 0, ">"); - AddLabel(176, 228, 0, ">"); + protected override void BuildStrings(ref GumpStringsBuilder builder) + { + var totalGold = _from.TotalGold; - AddButton(217, 272, 4023, 4024, 5); - } + // Just in case + _offer = Math.Clamp(_offer, 0, totalGold); + + builder.SetStringSlot("goldOffer", (totalGold - _offer).ToString("N0")); + builder.SetStringSlot("titheOffer", _offer.ToString("N0")); + } - public override void OnResponse(NetState sender, in RelayInfo info) + public override void OnResponse(NetState sender, in RelayInfo info) + { + switch (info.ButtonID) { - switch (info.ButtonID) - { - case 0: + case 0: + { + // You have decided to tithe no gold to the shrine. + _from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); + break; + } + case 1: + case 2: + case 3: + case 4: + { + _offer = info.ButtonID switch { - // You have decided to tithe no gold to the shrine. - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); - break; + 1 => _offer - 100, + 2 => 0, + 3 => _offer + 100, + 4 => _from.TotalGold, + _ => 0 + }; + + _from.SendGump(this); + break; + } + case 5: + { + var totalGold = _from.TotalGold; + + _offer = Math.Clamp(_offer, 0, totalGold); + + if (_from.TithingPoints + _offer > MaxTitheAmount) + { + _offer = MaxTitheAmount - _from.TithingPoints; } - case 1: - case 2: - case 3: - case 4: + + if (_offer <= 0) { - var offer = info.ButtonID switch - { - 1 => m_Offer - 100, - 2 => 0, - 3 => m_Offer + 100, - 4 => m_From.TotalGold, - _ => 0 - }; - - m_From.SendGump(new TithingGump(m_From, offer)); + // You have decided to tithe no gold to the shrine. + _from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); break; } - case 5: + + var pack = _from.Backpack; + + // TODO: At some point this was changed on OSI to only work from bank/account funds + if (pack?.ConsumeTotal(typeof(Gold), _offer) == true) { - var totalGold = m_From.TotalGold; - - m_Offer = Math.Clamp(m_Offer, 0, totalGold); - - if (m_From.TithingPoints + m_Offer > 100000) // TODO: What's the maximum? - { - m_Offer = 100000 - m_From.TithingPoints; - } - - if (m_Offer <= 0) - { - // You have decided to tithe no gold to the shrine. - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); - break; - } - - var pack = m_From.Backpack; - - if (pack?.ConsumeTotal(typeof(Gold), m_Offer) == true) - { - // You tithe gold to the shrine as a sign of devotion. - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195); - m_From.TithingPoints += m_Offer; - - m_From.PlaySound(0x243); - m_From.PlaySound(0x2E6); - } - else - { - // You do not have enough gold to tithe that amount! - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060194); - } + // You tithe gold to the shrine as a sign of devotion. + _from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195); + _from.TithingPoints += _offer; - break; + _from.PlaySound(0x243); + _from.PlaySound(0x2E6); } - } + else + { + // You do not have enough gold to tithe that amount! + _from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060194); + } + + break; + } } } } diff --git a/Projects/UOContent/Gumps/YoungGumps.cs b/Projects/UOContent/Gumps/YoungGumps.cs index 2d93cbbbaa..85dbce2d19 100644 --- a/Projects/UOContent/Gumps/YoungGumps.cs +++ b/Projects/UOContent/Gumps/YoungGumps.cs @@ -1,101 +1,101 @@ using Server.Accounting; using Server.Network; -namespace Server.Gumps +namespace Server.Gumps; + +public class YoungDungeonWarningGump : StaticGump { - public class YoungDungeonWarning : Gump + public YoungDungeonWarningGump() : base(150, 200) { - public YoungDungeonWarning() : base(150, 200) - { - AddBackground(0, 0, 250, 170, 0xA28); - - AddHtmlLocalized( - 20, - 43, - 215, - 70, - 1018030, - true, - true - ); // Warning: monsters may attack you on site down here in the dungeons! - - AddButton(70, 123, 0xFA5, 0xFA7, 0); - AddHtmlLocalized(105, 125, 100, 35, 1011036); // OKAY - } } - public class YoungDeathNotice : Gump + protected override void BuildLayout(ref StaticGumpBuilder builder) { - public YoungDeathNotice() : base(100, 15) - { - Closable = false; + builder.AddBackground(0, 0, 250, 170, 0xA28); - AddBackground(25, 10, 425, 444, 0x13BE); + // Warning: monsters may attack you on site down here in the dungeons! + builder.AddHtmlLocalized(20, 43, 215, 70, 1018030, true, true); - AddImageTiled(33, 20, 407, 425, 0xA40); - AddAlphaRegion(33, 20, 407, 425); + builder.AddButton(70, 123, 0xFA5, 0xFA7, 0); + builder.AddHtmlLocalized(105, 125, 100, 35, 1011036); // OKAY + } +} - AddHtmlLocalized(190, 24, 120, 20, 1046287, 0x7D00); // You have died. +public class YoungDeathNoticeGump : StaticGump +{ + public YoungDeathNoticeGump() : base(100, 15) + { + } + + protected override void BuildLayout(ref StaticGumpBuilder builder) + { + builder.SetNoClose(); - // As a ghost you cannot interact with the world. You cannot touch items nor can you use them. - AddHtmlLocalized(50, 50, 380, 40, 1046288, 0x7FFF); - // You can pass through doors as though they do not exist. However, you cannot pass through walls. - AddHtmlLocalized(50, 100, 380, 45, 1046289, 0x7FFF); - // Since you are a new player, any items you had on your person at the time of your death will be in your backpack upon resurrection. - AddHtmlLocalized(50, 140, 380, 60, 1046291, 0x7FFF); - // To be resurrected you must find a healer in town or wandering in the wilderness. Some powerful players may also be able to resurrect you. - AddHtmlLocalized(50, 204, 380, 65, 1046292, 0x7FFF); - // While you are still in young status, you will be transported to the nearest healer (along with your items) at the time of your death. - AddHtmlLocalized(50, 269, 380, 65, 1046293, 0x7FFF); - // To rejoin the world of the living simply walk near one of the NPC healers, and they will resurrect you as long as you are not marked as a criminal. - AddHtmlLocalized(50, 334, 380, 70, 1046294, 0x7FFF); + builder.AddBackground(25, 10, 425, 444, 0x13BE); - AddButton(195, 410, 0xF8, 0xF9, 0); - } + builder.AddImageTiled(33, 20, 407, 425, 0xA40); + builder.AddAlphaRegion(33, 20, 407, 425); + + builder.AddHtmlLocalized(190, 24, 120, 20, 1046287, 0x7D00); // You have died. + + // As a ghost you cannot interact with the world. You cannot touch items nor can you use them. + builder.AddHtmlLocalized(50, 50, 380, 40, 1046288, 0x7FFF); + // You can pass through doors as though they do not exist. However, you cannot pass through walls. + builder.AddHtmlLocalized(50, 100, 380, 45, 1046289, 0x7FFF); + // Since you are a new player, any items you had on your person at the time of your death will be in your backpack upon resurrection. + builder.AddHtmlLocalized(50, 140, 380, 60, 1046291, 0x7FFF); + // To be resurrected you must find a healer in town or wandering in the wilderness. Some powerful players may also be able to resurrect you. + builder.AddHtmlLocalized(50, 204, 380, 65, 1046292, 0x7FFF); + // While you are still in young status, you will be transported to the nearest healer (along with your items) at the time of your death. + builder.AddHtmlLocalized(50, 269, 380, 65, 1046293, 0x7FFF); + // To rejoin the world of the living simply walk near one of the NPC healers, and they will resurrect you as long as you are not marked as a criminal. + builder.AddHtmlLocalized(50, 334, 380, 70, 1046294, 0x7FFF); + + builder.AddButton(195, 410, 0xF8, 0xF9, 0); } +} - public class RenounceYoungGump : Gump +public class RenounceYoungGump : StaticGump +{ + public RenounceYoungGump() : base(150, 50) { - public RenounceYoungGump() : base(150, 50) - { - AddBackground(0, 0, 450, 400, 0xA28); - - AddHtmlLocalized(0, 30, 450, 35, 1013004); //
Renouncing 'Young Player' Status
- - /* As a 'Young' player, you are currently under a system of protection that prevents - * you from being attacked by other players and certain monsters.

- * - * If you choose to renounce your status as a 'Young' player, you will lose this protection. - * You will become vulnerable to other players, and many monsters that had only glared - * at you menacingly before will now attack you on sight!

- * - * Select OKAY now if you wish to renounce your status as a 'Young' player, otherwise - * press CANCEL. - */ - AddHtmlLocalized(30, 70, 390, 210, 1013005, true, true); - - AddButton(45, 298, 0xFA5, 0xFA7, 1); - AddHtmlLocalized(78, 300, 100, 35, 1011036); // OKAY - - AddButton(178, 298, 0xFA5, 0xFA7, 0); - AddHtmlLocalized(211, 300, 100, 35, 1011012); // CANCEL - } + } - public override void OnResponse(NetState sender, in RelayInfo info) + protected override void BuildLayout(ref StaticGumpBuilder builder) + { + builder.AddBackground(0, 0, 450, 400, 0xA28); + + builder.AddHtmlLocalized(0, 30, 450, 35, 1013004); //
Renouncing 'Young Player' Status
+ + /* As a 'Young' player, you are currently under a system of protection that prevents + * you from being attacked by other players and certain monsters.

+ * + * If you choose to renounce your status as a 'Young' player, you will lose this protection. + * You will become vulnerable to other players, and many monsters that had only glared + * at you menacingly before will now attack you on sight!

+ * + * Select OKAY now if you wish to renounce your status as a 'Young' player, otherwise + * press CANCEL. + */ + builder.AddHtmlLocalized(30, 70, 390, 210, 1013005, true, true); + + builder.AddButton(45, 298, 0xFA5, 0xFA7, 1); + builder. AddHtmlLocalized(78, 300, 100, 35, 1011036); // OKAY + + builder.AddButton(178, 298, 0xFA5, 0xFA7, 0); + builder.AddHtmlLocalized(211, 300, 100, 35, 1011012); // CANCEL + } + + public override void OnResponse(NetState sender, in RelayInfo info) + { + var from = sender.Mobile; + + if (info.ButtonID != 1) { - var from = sender.Mobile; - - if (info.ButtonID == 1) - { - if (from.Account is Account acc) - { - acc.RemoveYoungStatus(502085); // You have chosen to renounce your `Young' player status. - } - } - else - { - from.SendLocalizedMessage(502086); // You have chosen not to renounce your `Young' player status. - } + from.SendLocalizedMessage(502086); // You have chosen not to renounce your `Young' player status. + return; } + + (from.Account as Account)?.RemoveYoungStatus(502085); // You have chosen to renounce your `Young' player status. } } diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index 5a59e55af5..767c833ef4 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -4431,7 +4431,7 @@ public bool YoungDeathTeleport() private void SendYoungDeathNotice() { - SendGump(new YoungDeathNotice()); + SendGump(new YoungDeathNoticeGump()); } public override void OnSpeech(SpeechEventArgs e) diff --git a/Projects/UOContent/Regions/BaseRegion.cs b/Projects/UOContent/Regions/BaseRegion.cs index e0e4e615fb..dbe924594a 100644 --- a/Projects/UOContent/Regions/BaseRegion.cs +++ b/Projects/UOContent/Regions/BaseRegion.cs @@ -77,7 +77,7 @@ public override void OnEnter(Mobile m) { if (m is PlayerMobile mobile && mobile.Young && !YoungProtected) { - mobile.SendGump(new YoungDungeonWarning()); + mobile.SendGump(new YoungDungeonWarningGump()); } }