Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cleans up HonorGump and Honor checks #1853

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions Projects/UOContent/Engines/Virtues/Honor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static void EmbraceHonor(PlayerMobile pm)
}
}

pm.SendGump(new HonorSelf(pm));
pm.SendGump(new HonorSelfGump(pm));
}

public static void ActivateEmbrace(PlayerMobile pm)
Expand All @@ -89,7 +89,7 @@ public static void ActivateEmbrace(PlayerMobile pm)

Timer.DelayCall(
TimeSpan.FromSeconds(duration),
(m) =>
m =>
{
// We get the virtues again, in case it was deleted/dereferenced
var v = VirtueSystem.GetOrCreateVirtues(m);
Expand Down Expand Up @@ -125,32 +125,23 @@ private static void Honor(PlayerMobile source, Mobile target)
}
}

if (target.Hits < target.HitsMax)
if (Core.ML && target is PlayerMobile)
{
source.SendLocalizedMessage(1063166); // You cannot honor this monster because it is too damaged.
source.SendLocalizedMessage(1075614); // You cannot honor other players.
return;
}

if (target.Body.IsHuman && (target is not BaseCreature cret || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
if (target.Hits < target.HitsMax)
{
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
}
source.SendLocalizedMessage(1063166); // You cannot honor this monster because it is too damaged.
return;
}

if (Core.ML && target is PlayerMobile)
// 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)
{
source.SendLocalizedMessage(1075614); // You cannot honor other players.
source.SendLocalizedMessage(1001018); // You cannot perform negative acts
return;
}

Expand Down
30 changes: 30 additions & 0 deletions Projects/UOContent/Engines/Virtues/HonorSelfGump.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Server.Engines.Virtues;
using Server.Mobiles;
using Server.Network;

namespace Server.Gumps;

Check notice on line 5 in Projects/UOContent/Engines/Virtues/HonorSelfGump.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Namespace does not correspond to file location

Namespace does not correspond to file location, must be: 'Server.Engines.Virtues'

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);
}
}
}
28 changes: 0 additions & 28 deletions Projects/UOContent/Gumps/HonorSelf.cs

This file was deleted.

Loading