fix: Cleans up HonorGump and Honor checks (#1853)
### Summary - Moves `HonorSelf` gump to the Virtues folder. - Renames `HonorSelf` to `HonorSelfGump` - Makes `HonorSelfGump` a static gump. - Changes the text in the gump to a cliloc. - Collapses some of the checks for honoring to simplify the logic. - Moves the player check higher to fix the wrong error message displaying when trying to honor damaged players.
This commit is contained in:
parent
ac3e4fcc97
commit
8b1014f395
3 changed files with 42 additions and 49 deletions
|
|
@ -67,7 +67,7 @@ public static class HonorVirtue
|
|||
}
|
||||
}
|
||||
|
||||
pm.SendGump(new HonorSelf(pm));
|
||||
pm.SendGump(new HonorSelfGump(pm));
|
||||
}
|
||||
|
||||
public static void ActivateEmbrace(PlayerMobile pm)
|
||||
|
|
@ -89,7 +89,7 @@ public static class HonorVirtue
|
|||
|
||||
Timer.DelayCall(
|
||||
TimeSpan.FromSeconds(duration),
|
||||
(m) =>
|
||||
m =>
|
||||
{
|
||||
// We get the virtues again, in case it was deleted/dereferenced
|
||||
var v = VirtueSystem.GetOrCreateVirtues(m);
|
||||
|
|
@ -125,32 +125,23 @@ public static class HonorVirtue
|
|||
}
|
||||
}
|
||||
|
||||
if (Core.ML && target is PlayerMobile)
|
||||
{
|
||||
source.SendLocalizedMessage(1075614); // You cannot honor other players.
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.Hits < target.HitsMax)
|
||||
{
|
||||
source.SendLocalizedMessage(1063166); // You cannot honor this monster because it is too damaged.
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.Body.IsHuman && (target is not BaseCreature cret || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
|
||||
// Allow honor on blue if not in a guarded region or blue in Felucca
|
||||
if (target.Body.IsHuman && (target is not BaseCreature cret || !cret.AlwaysAttackable && !cret.AlwaysMurderer) &&
|
||||
reg?.IsDisabled() == true && (map?.Rules & MapRules.HarmfulRestrictions) != 0)
|
||||
{
|
||||
if (reg?.IsDisabled() != true)
|
||||
{
|
||||
// Allow honor on blue if not in a guarded region
|
||||
}
|
||||
else if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
{
|
||||
// Allow honor on blue if in Fel
|
||||
}
|
||||
else
|
||||
{
|
||||
source.SendLocalizedMessage(1001018); // You cannot perform negative acts
|
||||
return; // cannot honor in trammel town on blue
|
||||
}
|
||||
}
|
||||
|
||||
if (Core.ML && target is PlayerMobile)
|
||||
{
|
||||
source.SendLocalizedMessage(1075614); // You cannot honor other players.
|
||||
source.SendLocalizedMessage(1001018); // You cannot perform negative acts
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
30
Projects/UOContent/Engines/Virtues/HonorSelfGump.cs
Normal file
30
Projects/UOContent/Engines/Virtues/HonorSelfGump.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using Server.Engines.Virtues;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps;
|
||||
|
||||
public class HonorSelfGump : StaticGump<HonorSelfGump>
|
||||
{
|
||||
private readonly PlayerMobile _from;
|
||||
|
||||
public HonorSelfGump(PlayerMobile from) : base(150, 50) => _from = from;
|
||||
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddBackground(0, 0, 245, 145, 9250);
|
||||
builder.AddButton(157, 101, 247, 248, 1);
|
||||
builder.AddButton(81, 100, 241, 248, 0);
|
||||
|
||||
// Are you sure you want to use honor points on yourself?
|
||||
builder.AddHtmlLocalized(21, 20, 203, 70, 1071218, true);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
HonorVirtue.ActivateEmbrace(_from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
using Server.Engines.Virtues;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class HonorSelf : Gump
|
||||
{
|
||||
private readonly PlayerMobile m_from;
|
||||
|
||||
public HonorSelf(PlayerMobile from) : base(150, 50)
|
||||
{
|
||||
m_from = from;
|
||||
AddBackground(0, 0, 245, 145, 9250);
|
||||
AddButton(157, 101, 247, 248, 1);
|
||||
AddButton(81, 100, 241, 248, 0);
|
||||
AddHtml(21, 20, 203, 70, "Are you sure you want to use honor points on yourself?", true);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
HonorVirtue.ActivateEmbrace(m_from);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue