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

feat: Fixes beneficial notoriety checks and adds better young restrictions/messaging #2000

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 7 additions & 13 deletions Projects/Server/Mobiles/Mobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7105,23 +7105,17 @@ public virtual bool CanSee(Item item)
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))
{
Expand Down
4 changes: 4 additions & 0 deletions Projects/UOContent/Items/Skill Items/Misc/Bandage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ public static BandageContext BeginHeal(Mobile healer, Mobile patient)
{
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);
Expand Down
101 changes: 36 additions & 65 deletions Projects/UOContent/Misc/Notoriety.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@ private static GuildStatus GetGuildStatus(Mobile m)
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 )
{
Expand All @@ -70,20 +63,16 @@ public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
return true;
}

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)
if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
{
pmFrom = bcFrom.SummonMaster as PlayerMobile;
return false;
}

if (pmTarg == null && bcTarg?.Summoned == true)
{
pmTarg = bcTarg.SummonMaster as PlayerMobile;
}
var bcFrom = from as BaseCreature;
var bcTarg = target as BaseCreature;

var pmFrom = (bcFrom?.GetMaster() ?? from) as PlayerMobile;
var pmTarg = (bcTarg?.GetMaster() ?? target) as PlayerMobile;

if (pmFrom != null && pmTarg != null)
{
Expand Down Expand Up @@ -124,11 +113,6 @@ public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
return false;
}

if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
{
return false;
}

var map = from.Map;

var targetFaction = Faction.Find(target, true);
Expand All @@ -143,7 +127,7 @@ public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
return true; // In felucca, anything goes
}

if (!from.Player)
if (!from.Player && pmFrom?.AccessLevel != AccessLevel.Player)
{
return true; // NPCs have no restrictions
}
Expand All @@ -155,7 +139,7 @@ public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)

if (pmFrom?.Young == true && pmTarg?.Young != true)
{
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 &&
Expand All @@ -175,20 +159,16 @@ public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
return true;
}

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)
if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
{
pmFrom = bcFrom.SummonMaster as PlayerMobile;
return false;
}

if (pmTarg == null && bcTarg?.Summoned == true)
{
pmTarg = bcTarg.SummonMaster as PlayerMobile;
}
var bcFrom = from as BaseCreature;
var bcTarg = target as BaseCreature;

var pmFrom = (bcFrom?.GetMaster() ?? from) as PlayerMobile;
var pmTarg = (bcTarg?.GetMaster() ?? target) as PlayerMobile;

if (pmFrom != null && pmTarg != null)
{
Expand Down Expand Up @@ -224,28 +204,18 @@ public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
return false;
}

if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
{
return false;
}

var map = from.Map;

if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
{
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);
Expand All @@ -258,7 +228,7 @@ public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
}

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
}
Expand All @@ -278,23 +248,24 @@ public static bool Mobile_AllowHarmful(Mobile from, Mobile target)

public static Guild GetGuildFor(Guild def, Mobile m)
{
var g = def;
if (m is not BaseCreature c || !c.Controlled || c.ControlMaster == null)
{
return def;
}

c.DisplayGuildTitle = false;

if (m is BaseCreature c && c.Controlled && c.ControlMaster != null)
if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder is OrderType.Attack or OrderType.Guard))
{
c.DisplayGuildTitle = false;
return (Guild)(c.Guild = c.ControlMaster.Guild);
}

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);
}
if (c.Map == Map.Internal || c.ControlMaster.Guild == null)
{
return (Guild)(c.Guild = null);
}

return g;
return def;
}

public static int CorpseNotoriety(Mobile source, Corpse target)
Expand Down
7 changes: 2 additions & 5 deletions Projects/UOContent/Mobiles/PlayerMobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2625,12 +2625,9 @@ public override void OnDeath(Container c)
}
}

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)
Expand Down
31 changes: 21 additions & 10 deletions Projects/UOContent/Skills/Stealing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class Stealing
{
public static readonly bool ClassicMode = false;
public static readonly bool SuspendOnMurder = false;
private const int MaxWeightToSteal = 10;

public static void Initialize()
{
Expand Down Expand Up @@ -80,6 +81,8 @@ private Item TryStealItem(Item toSteal, ref bool caught)

var root = toSteal.RootParent;
var mobRoot = root as Mobile;
var rootIsPlayer = mobRoot?.Player == true;
var vendor = root as BaseVendor;

StealableArtifacts.StealableInstance si = toSteal.Parent == null || !toSteal.Movable
? StealableArtifacts.GetStealableInstance(toSteal)
Expand All @@ -93,16 +96,23 @@ private Item TryStealItem(Item toSteal, ref bool caught)
{
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 || vendor == null && 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 (vendor?.IsInvulnerable == true)
{
m_Thief.SendLocalizedMessage(1005598); // You can't steal from shopkeepers.
}
Expand All @@ -114,10 +124,6 @@ private Item TryStealItem(Item toSteal, ref bool caught)
{
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);
Expand Down Expand Up @@ -206,6 +212,10 @@ private Item TryStealItem(Item toSteal, ref bool caught)
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!
Expand Down Expand Up @@ -250,9 +260,10 @@ private Item TryStealItem(Item toSteal, ref bool caught)
{
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
{
Expand Down
6 changes: 6 additions & 0 deletions Projects/UOContent/Spells/Base/Spell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,12 @@ public bool CheckBSequence(Mobile target, bool allowDead = false)
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);
Expand Down
Loading