Skip to content

Commit

Permalink
Fixes notoriety
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Jan 20, 2025
1 parent ea53c8f commit 15c948a
Showing 1 changed file with 32 additions and 50 deletions.
82 changes: 32 additions & 50 deletions Projects/UOContent/Misc/Notoriety.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,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 @@ -117,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 @@ -136,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 @@ -148,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 @@ -168,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 @@ -217,24 +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)
{
// Uncontrolled NPCs are only restricted by the young system
return CheckAggressor(from.Aggressors, target) || CheckAggressed(from.Aggressed, target) ||
pmTarg?.CheckYoungProtection(from) != true;
(target as PlayerMobile)?.CheckYoungProtection(from) != true;
}

var fromGuild = GetGuildFor(from.Guild as Guild, from);
Expand All @@ -247,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 @@ -267,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;
}

if (m is 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))
{
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

0 comments on commit 15c948a

Please sign in to comment.