From 14bc38e3753dc0167b5331ed45e0d5851c5e29b3 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 7 Jun 2025 10:58:01 -1000 Subject: [PATCH] fix: Removes the absurb 6 hour skill edge case and fixes target cancellations (#2212) --- Projects/Server/Mobiles/Mobile.cs | 2 ++ Projects/UOContent/Skills/Begging.cs | 24 +++-------------- Projects/UOContent/Skills/DetectHidden.cs | 7 ++++- Projects/UOContent/Skills/Peacemaking.cs | 33 ++++++++--------------- Projects/UOContent/Skills/Stealing.cs | 11 ++++++-- 5 files changed, 32 insertions(+), 45 deletions(-) diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index 5b4e7a992..f217b0fe1 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -661,6 +661,7 @@ public partial class Mobile : IHued, IComparable, ISpawnable, IObjectPro } } + [CommandProperty(AccessLevel.Administrator)] public long NextActionTime { get; set; } public long NextActionMessage { get; set; } @@ -675,6 +676,7 @@ public partial class Mobile : IHued, IComparable, ISpawnable, IObjectPro public virtual bool CanRegenStam => Alive; public virtual bool CanRegenMana => Alive; + [CommandProperty(AccessLevel.Administrator)] public long NextSkillTime { get; set; } public List Aggressors { get; private set; } diff --git a/Projects/UOContent/Skills/Begging.cs b/Projects/UOContent/Skills/Begging.cs index 0267aa682..1855050af 100644 --- a/Projects/UOContent/Skills/Begging.cs +++ b/Projects/UOContent/Skills/Begging.cs @@ -21,23 +21,18 @@ namespace Server.SkillHandlers m.SendLocalizedMessage(500397); // To whom do you wish to grovel? - return TimeSpan.FromHours(6.0); + return TimeSpan.FromSeconds(30.0); } private class InternalTarget : Target { - private bool m_SetSkillTime = true; - public InternalTarget() : base(12, false, TargetFlags.None) { } - protected override void OnTargetFinish(Mobile from) + protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { - if (m_SetSkillTime) - { - from.NextSkillTime = Core.TickCount; - } + from.NextSkillTime = Core.TickCount; } protected override void OnTarget(Mobile from, object targeted) @@ -81,8 +76,6 @@ namespace Server.SkillHandlers from.Animate(32, 5, 1, true, false, 0); // Bow new InternalTimer(from, targ).Start(); - - m_SetSkillTime = false; } } else // Not a Mobile @@ -125,16 +118,7 @@ namespace Server.SkillHandlers else if (m_From.CheckTargetSkill(SkillName.Begging, m_Target, 0.0, 100.0)) { var toConsume = theirPack.GetAmount(typeof(Gold)) / 10; - var max = 10 + m_From.Fame / 2500; - - if (max > 14) - { - max = 14; - } - else if (max < 10) - { - max = 10; - } + var max = Math.Clamp(10 + m_From.Fame / 2500, 10, 14); if (toConsume > max) { diff --git a/Projects/UOContent/Skills/DetectHidden.cs b/Projects/UOContent/Skills/DetectHidden.cs index a0fcecafd..f7f909fc9 100644 --- a/Projects/UOContent/Skills/DetectHidden.cs +++ b/Projects/UOContent/Skills/DetectHidden.cs @@ -18,7 +18,7 @@ namespace Server.SkillHandlers src.SendLocalizedMessage(500819); // Where will you search? src.Target = new InternalTarget(); - return TimeSpan.FromSeconds(6.0); + return TimeSpan.FromSeconds(30.0); } private class InternalTarget : Target @@ -27,6 +27,11 @@ namespace Server.SkillHandlers { } + protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) + { + from.NextSkillTime = Core.TickCount; + } + protected override void OnTarget(Mobile src, object targ) { var foundAnyone = false; diff --git a/Projects/UOContent/Skills/Peacemaking.cs b/Projects/UOContent/Skills/Peacemaking.cs index c963395d5..437249bba 100644 --- a/Projects/UOContent/Skills/Peacemaking.cs +++ b/Projects/UOContent/Skills/Peacemaking.cs @@ -27,27 +27,22 @@ namespace Server.SkillHandlers from.RevealingAction(); from.SendLocalizedMessage(1049525); // Whom do you wish to calm? from.Target = new InternalTarget(from, instrument); - from.NextSkillTime = Core.TickCount + 21600000; + from.NextSkillTime = Core.TickCount + 30000; // 30s timeout on the targeter } private class InternalTarget : Target { private readonly BaseInstrument m_Instrument; - private bool m_SetSkillTime = true; public InternalTarget(Mobile from, BaseInstrument instrument) : base( BaseInstrument.GetBardRange(from, SkillName.Peacemaking), false, TargetFlags.None - ) => - m_Instrument = instrument; + ) => m_Instrument = instrument; - protected override void OnTargetFinish(Mobile from) + protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { - if (m_SetSkillTime) - { - from.NextSkillTime = Core.TickCount; - } + from.NextSkillTime = Core.TickCount; } protected override void OnTarget(Mobile from, object targeted) @@ -60,21 +55,19 @@ namespace Server.SkillHandlers } else if (from.Region.IsPartOf()) { - from.SendMessage("You may not peacemake in this area."); + from.SendMessage("You may not use peacemaking in this area."); } else if (targ.Region.IsPartOf()) { - from.SendMessage("You may not peacemake there."); + from.SendMessage("You may not use peacemaking there."); } else if (!m_Instrument.IsChildOf(from.Backpack)) { - from.SendLocalizedMessage( - 1062488 - ); // The instrument you are trying to play is no longer in your backpack! + // The instrument you are trying to play is no longer in your backpack! + from.SendLocalizedMessage(1062488); } else { - m_SetSkillTime = false; from.NextSkillTime = Core.TickCount + 10000; if (targeted == from) @@ -149,17 +142,14 @@ namespace Server.SkillHandlers if (!from.CanBeHarmful(targ, false)) { from.SendLocalizedMessage(1049528); - m_SetSkillTime = true; } else if (bc?.Uncalmable == true) { from.SendLocalizedMessage(1049526); // You have no chance of calming that creature. - m_SetSkillTime = true; } else if (bc?.BardPacified == true) { from.SendLocalizedMessage(1049527); // That creature is already being calmed. - m_SetSkillTime = true; } else if (!BaseInstrument.CheckMusicianship(from)) { @@ -193,10 +183,10 @@ namespace Server.SkillHandlers targ.Combatant = null; targ.Warmode = false; + from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target. if (bc != null) { - from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target. - + // You play hypnotic music, calming your target. var seconds = 100 - diff / 1.5; if (seconds > 120) @@ -212,8 +202,7 @@ namespace Server.SkillHandlers } else { - from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target. - + // You play hypnotic music, calming your target. // You hear lovely music, and forget to continue battling! targ.SendLocalizedMessage(500616); } diff --git a/Projects/UOContent/Skills/Stealing.cs b/Projects/UOContent/Skills/Stealing.cs index 6d4c4226b..92cba48cb 100644 --- a/Projects/UOContent/Skills/Stealing.cs +++ b/Projects/UOContent/Skills/Stealing.cs @@ -62,7 +62,7 @@ public static class Stealing m.SendLocalizedMessage(502698); // Which item do you want to steal? } - return TimeSpan.FromSeconds(10.0); + return TimeSpan.FromSeconds(30.0); } private class StealingTarget : Target @@ -75,6 +75,11 @@ public static class Stealing AllowNonlocal = true; } + protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) + { + from.NextSkillTime = Core.TickCount; + } + private Item TryStealItem(Item toSteal, ref bool caught) { Item stolen = null; @@ -83,7 +88,7 @@ public static class Stealing var mobRoot = root as Mobile; var rootIsPlayer = mobRoot?.Player == true; - StealableArtifacts.StealableInstance si = toSteal.Parent == null || !toSteal.Movable + var si = toSteal.Parent == null || !toSteal.Movable ? StealableArtifacts.GetStealableInstance(toSteal) : null; @@ -404,6 +409,8 @@ public static class Stealing pm.PermaFlags.Add(mobRoot); pm.Delta(MobileDelta.Noto); } + + from.NextSkillTime = Core.TickCount + 10000; // 10 seconds cooldown } } }