diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index d6b9eb9a2..66064b87b 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -7105,23 +7105,17 @@ public partial class Mobile : IHued, IComparable, ISpawnable, IObjectPro return false; } - if (item.Parent != null) + if (item.Parent is Item parent) { - if (item.Parent is Item parent) + if (!(CanSee(parent) && parent.IsChildVisibleTo(this, item))) { - if (!(CanSee(parent) && parent.IsChildVisibleTo(this, item))) - { - return false; - } - } - else if (item.Parent is Mobile mobile) - { - if (!CanSee(mobile)) - { - return false; - } + return false; } } + else if (item.Parent is Mobile mobile && !CanSee(mobile)) + { + return false; + } if (item is BankBox box && m_AccessLevel <= AccessLevel.Counselor && (box.Owner != this || !box.Opened)) { diff --git a/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs b/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs index 68f9b3580..77a7997e2 100644 --- a/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs +++ b/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs @@ -466,6 +466,10 @@ public class BandageContext : Timer { healer.SendLocalizedMessage(501042); // Target cannot be resurrected at that location. } + else if ((healer as PlayerMobile)?.Young == true && (patient as PlayerMobile)?.Young == false) + { + healer.SendLocalizedMessage(500952); // As a young player, you may not use beneficial skills on older players. + } else if (healer.CanBeBeneficial(patient, true, true)) { healer.DoBeneficial(patient); diff --git a/Projects/UOContent/Misc/Notoriety.cs b/Projects/UOContent/Misc/Notoriety.cs index e86c81ecc..3d8a5b6c6 100644 --- a/Projects/UOContent/Misc/Notoriety.cs +++ b/Projects/UOContent/Misc/Notoriety.cs @@ -44,15 +44,8 @@ namespace Server.Misc return GuildStatus.Waring; } - private static bool CheckBeneficialStatus(GuildStatus from, GuildStatus target) - { - if (from == GuildStatus.Waring || target == GuildStatus.Waring) - { - return false; - } - - return true; - } + private static bool CheckBeneficialStatus(GuildStatus from, GuildStatus target) => + from != GuildStatus.Waring && target != GuildStatus.Waring; /*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target ) { @@ -70,20 +63,16 @@ namespace Server.Misc return true; } + if (from.Region.IsPartOf() || target.Region.IsPartOf()) + { + return false; + } + var bcFrom = from as BaseCreature; var bcTarg = target as BaseCreature; - var pmFrom = from as PlayerMobile; - var pmTarg = target as PlayerMobile; - if (pmFrom == null && bcFrom?.Summoned == true) - { - pmFrom = bcFrom.SummonMaster as PlayerMobile; - } - - if (pmTarg == null && bcTarg?.Summoned == true) - { - pmTarg = bcTarg.SummonMaster as PlayerMobile; - } + var pmFrom = (bcFrom?.GetMaster() ?? from) as PlayerMobile; + var pmTarg = (bcTarg?.GetMaster() ?? target) as PlayerMobile; if (pmFrom != null && pmTarg != null) { @@ -124,11 +113,6 @@ namespace Server.Misc return false; } - if (from.Region.IsPartOf() || target.Region.IsPartOf()) - { - return false; - } - var map = from.Map; var targetFaction = Faction.Find(target, true); @@ -143,7 +127,7 @@ namespace Server.Misc return true; // In felucca, anything goes } - if (!from.Player) + if (!from.Player && pmFrom?.AccessLevel != AccessLevel.Player) { return true; // NPCs have no restrictions } @@ -153,9 +137,9 @@ namespace Server.Misc return false; // Players cannot heal uncontrolled mobiles } - if (pmFrom?.Young == true && pmTarg?.Young != true) + if (pmFrom?.Young == true && pmTarg?.Young == false) { - return false; // Young players cannot perform beneficial actions towards older players + return false; // Young players cannot perform beneficial actions towards non-young players or pets } if (from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && @@ -175,20 +159,16 @@ namespace Server.Misc return true; } + if (from.Region.IsPartOf() || target.Region.IsPartOf()) + { + return false; + } + var bcFrom = from as BaseCreature; - var pmFrom = from as PlayerMobile; - var pmTarg = target as PlayerMobile; var bcTarg = target as BaseCreature; - if (pmFrom == null && bcFrom?.Summoned == true) - { - pmFrom = bcFrom.SummonMaster as PlayerMobile; - } - - if (pmTarg == null && bcTarg?.Summoned == true) - { - pmTarg = bcTarg.SummonMaster as PlayerMobile; - } + var pmFrom = (bcFrom?.GetMaster() ?? from) as PlayerMobile; + var pmTarg = (bcTarg?.GetMaster() ?? target) as PlayerMobile; if (pmFrom != null && pmTarg != null) { @@ -224,11 +204,6 @@ namespace Server.Misc return false; } - if (from.Region.IsPartOf() || target.Region.IsPartOf()) - { - return false; - } - var map = from.Map; if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) @@ -236,16 +211,11 @@ namespace Server.Misc return true; // In felucca, anything goes } - if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null && - bc.GetMaster().AccessLevel == AccessLevel.Player)) + if (!from.Player && pmFrom?.AccessLevel != AccessLevel.Player) { - if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && - pmTarg?.CheckYoungProtection(from) == true) - { - return false; - } - - return true; // Uncontrolled NPCs are only restricted by the young system + // Uncontrolled NPCs are only restricted by the young system + return CheckAggressor(from.Aggressors, target) || CheckAggressed(from.Aggressed, target) || + (target as PlayerMobile)?.CheckYoungProtection(from) != true; } var fromGuild = GetGuildFor(from.Guild as Guild, from); @@ -258,7 +228,7 @@ namespace Server.Misc } if (bcTarg?.Controlled == true - || (bcTarg?.Summoned == true && bcTarg.SummonMaster != from && bcTarg.SummonMaster.Player)) + || bcTarg?.Summoned == true && bcTarg.SummonMaster != from && bcTarg.SummonMaster.Player) { return false; // Cannot harm other controlled mobiles from players } @@ -278,23 +248,24 @@ namespace Server.Misc public static Guild GetGuildFor(Guild def, Mobile m) { - var g = def; - - if (m is BaseCreature c && c.Controlled && c.ControlMaster != null) + if (m is not BaseCreature c || !c.Controlled || c.ControlMaster == null) { - c.DisplayGuildTitle = false; - - if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder is OrderType.Attack or OrderType.Guard)) - { - g = (Guild)(c.Guild = c.ControlMaster.Guild); - } - else if (c.Map == Map.Internal || c.ControlMaster.Guild == null) - { - g = (Guild)(c.Guild = null); - } + return def; } - return g; + c.DisplayGuildTitle = false; + + if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder is OrderType.Attack or OrderType.Guard)) + { + return (Guild)(c.Guild = c.ControlMaster.Guild); + } + + if (c.Map == Map.Internal || c.ControlMaster.Guild == null) + { + return (Guild)(c.Guild = null); + } + + return def; } public static int CorpseNotoriety(Mobile source, Corpse target) diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index c29772d42..3efb322b9 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -2621,12 +2621,9 @@ namespace Server.Mobiles } } - if (Young && DuelContext == null) + if (Young && DuelContext == null && YoungDeathTeleport()) { - if (YoungDeathTeleport()) - { - Timer.StartTimer(TimeSpan.FromSeconds(2.5), SendYoungDeathNotice); - } + Timer.StartTimer(TimeSpan.FromSeconds(2.5), SendYoungDeathNotice); } if (DuelContext?.Registered != true || !DuelContext.Started || m_DuelPlayer?.Eliminated != false) diff --git a/Projects/UOContent/Skills/Stealing.cs b/Projects/UOContent/Skills/Stealing.cs index c0459a621..f2f270b29 100644 --- a/Projects/UOContent/Skills/Stealing.cs +++ b/Projects/UOContent/Skills/Stealing.cs @@ -18,6 +18,7 @@ namespace Server.SkillHandlers { public static readonly bool ClassicMode = false; public static readonly bool SuspendOnMurder = false; + private const int MaxWeightToSteal = 10; public static void Initialize() { @@ -80,6 +81,7 @@ namespace Server.SkillHandlers var root = toSteal.RootParent; var mobRoot = root as Mobile; + var rootIsPlayer = mobRoot?.Player == true; StealableArtifacts.StealableInstance si = toSteal.Parent == null || !toSteal.Movable ? StealableArtifacts.GetStealableInstance(toSteal) @@ -93,16 +95,23 @@ namespace Server.SkillHandlers { m_Thief.SendMessage("You may not steal in this area."); } - else if (mobRoot?.Player == true && !IsInGuild(m_Thief)) + else if ((m_Thief as PlayerMobile)?.Young == true && (rootIsPlayer || mobRoot is BaseCreature)) + { + m_Thief.SendLocalizedMessage(502700); // You cannot steal from people or monsters right now. Practice on chests and barrels. + } + else if (rootIsPlayer && !IsInGuild(m_Thief)) { m_Thief.SendLocalizedMessage(1005596); // You must be in the thieves guild to steal from other players. } - else if (SuspendOnMurder && mobRoot?.Player == true && IsInGuild(m_Thief) && - m_Thief.Kills > 0) + else if (SuspendOnMurder && rootIsPlayer && IsInGuild(m_Thief) && m_Thief.Kills > 0) { m_Thief.SendLocalizedMessage(502706); // You are currently suspended from the thieves guild. } - else if (root is BaseVendor vendor && vendor.IsInvulnerable) + else if ((mobRoot as PlayerMobile)?.Young == true) + { + m_Thief.SendLocalizedMessage(502699); // You cannot steal from the Young. + } + else if ((root as BaseVendor)?.IsInvulnerable == true) { m_Thief.SendLocalizedMessage(1005598); // You can't steal from shopkeepers. } @@ -114,10 +123,6 @@ namespace Server.SkillHandlers { m_Thief.SendLocalizedMessage(500237); // Target can not be seen. } - else if (m_Thief.Backpack?.CheckHold(m_Thief, toSteal, false, true) != true) - { - m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else. - } else if (toSteal is Sigil sig) { var pl = PlayerState.Find(m_Thief); @@ -206,6 +211,10 @@ namespace Server.SkillHandlers m_Thief.SendLocalizedMessage(1005588); // You must join a faction to do that } } + else if (m_Thief.Backpack?.CheckHold(m_Thief, toSteal, false, true) != true) + { + m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else. + } else if (si == null && (toSteal.Parent == null || !toSteal.Movable)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! @@ -250,9 +259,10 @@ namespace Server.SkillHandlers { var w = toSteal.Weight + toSteal.TotalWeight; - if (w > 10) + if (w > MaxWeightToSteal) { - m_Thief.SendMessage("That is too heavy to steal."); + // This item is too heavy to steal from someone's backpack. + m_Thief.SendLocalizedMessage(502722); } else { diff --git a/Projects/UOContent/Spells/Base/Spell.cs b/Projects/UOContent/Spells/Base/Spell.cs index ec04e9158..16af9faf8 100644 --- a/Projects/UOContent/Spells/Base/Spell.cs +++ b/Projects/UOContent/Spells/Base/Spell.cs @@ -831,6 +831,12 @@ namespace Server.Spells return false; } + if ((Caster as PlayerMobile)?.Young == true && (target as PlayerMobile)?.Young == false) + { + Caster.SendLocalizedMessage(500278); // As a young player, you may not cast beneficial spells onto older players. + return false; + } + if (Caster.CanBeBeneficial(target, true, allowDead) && CheckSequence()) { Caster.DoBeneficial(target);