Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,463 +1,491 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Items;
|
||||
using Server.Guilds;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Factions;
|
||||
using Server.Guilds;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.SkillHandlers;
|
||||
using Server.Spells.Seventh;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class NotorietyHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Notoriety.Hues[Notoriety.Innocent] = 0x59;
|
||||
Notoriety.Hues[Notoriety.Ally] = 0x3F;
|
||||
Notoriety.Hues[Notoriety.CanBeAttacked] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Criminal] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Enemy] = 0x90;
|
||||
Notoriety.Hues[Notoriety.Murderer] = 0x22;
|
||||
Notoriety.Hues[Notoriety.Invulnerable] = 0x35;
|
||||
|
||||
Notoriety.Handler = MobileNotoriety;
|
||||
public class NotorietyHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Notoriety.Hues[Notoriety.Innocent] = 0x59;
|
||||
Notoriety.Hues[Notoriety.Ally] = 0x3F;
|
||||
Notoriety.Hues[Notoriety.CanBeAttacked] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Criminal] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Enemy] = 0x90;
|
||||
Notoriety.Hues[Notoriety.Murderer] = 0x22;
|
||||
Notoriety.Hues[Notoriety.Invulnerable] = 0x35;
|
||||
|
||||
Notoriety.Handler = MobileNotoriety;
|
||||
|
||||
Mobile.AllowBeneficialHandler = Mobile_AllowBeneficial;
|
||||
Mobile.AllowHarmfulHandler = Mobile_AllowHarmful;
|
||||
}
|
||||
Mobile.AllowBeneficialHandler = Mobile_AllowBeneficial;
|
||||
Mobile.AllowHarmfulHandler = Mobile_AllowHarmful;
|
||||
}
|
||||
|
||||
private enum GuildStatus { None, Peaceful, Waring }
|
||||
private static GuildStatus GetGuildStatus(Mobile m)
|
||||
{
|
||||
if (m.Guild == null)
|
||||
return GuildStatus.None;
|
||||
if (((Guild)m.Guild).Enemies.Count == 0 && m.Guild.Type == GuildType.Regular)
|
||||
return GuildStatus.Peaceful;
|
||||
|
||||
private static GuildStatus GetGuildStatus( Mobile m )
|
||||
{
|
||||
if ( m.Guild == null )
|
||||
return GuildStatus.None;
|
||||
if ( ((Guild)m.Guild).Enemies.Count == 0 && m.Guild.Type == GuildType.Regular )
|
||||
return GuildStatus.Peaceful;
|
||||
return GuildStatus.Waring;
|
||||
}
|
||||
|
||||
return GuildStatus.Waring;
|
||||
}
|
||||
private static bool CheckBeneficialStatus(GuildStatus from, GuildStatus target)
|
||||
{
|
||||
if (from == GuildStatus.Waring || target == GuildStatus.Waring)
|
||||
return false;
|
||||
|
||||
private static bool CheckBeneficialStatus( GuildStatus from, GuildStatus target )
|
||||
{
|
||||
if ( from == GuildStatus.Waring || target == GuildStatus.Waring )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target )
|
||||
{
|
||||
if ( from == GuildStatus.Waring && target == GuildStatus.Waring )
|
||||
return true;
|
||||
|
||||
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target )
|
||||
{
|
||||
if ( from == GuildStatus.Waring && target == GuildStatus.Waring )
|
||||
return true;
|
||||
return false;
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}*/
|
||||
public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
|
||||
{
|
||||
if (from == null || target == null || from.AccessLevel > AccessLevel.Player ||
|
||||
target.AccessLevel > AccessLevel.Player)
|
||||
return true;
|
||||
|
||||
public static bool Mobile_AllowBeneficial( Mobile from, Mobile target )
|
||||
{
|
||||
if ( from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player )
|
||||
return true;
|
||||
#region Dueling
|
||||
|
||||
#region Dueling
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
|
||||
if ( pmFrom == null && from is BaseCreature bcFrom )
|
||||
{
|
||||
if ( bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
}
|
||||
if (pmFrom == null && from is BaseCreature bcFrom)
|
||||
if (bcFrom.Summoned)
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmTarg == null && target is BaseCreature bcTarg )
|
||||
{
|
||||
if ( bcTarg.Summoned )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
}
|
||||
if (pmTarg == null && target is BaseCreature bcTarg)
|
||||
if (bcTarg.Summoned)
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) )
|
||||
return false;
|
||||
if (pmFrom != null && pmTarg != null)
|
||||
{
|
||||
if (pmFrom.DuelContext != pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated) )
|
||||
return false;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied ||
|
||||
pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null && pmFrom.DuelContext.IsSuddenDeath )
|
||||
return false;
|
||||
if (pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null &&
|
||||
pmFrom.DuelContext.IsSuddenDeath)
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant )
|
||||
return false;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted &&
|
||||
pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
|
||||
pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant)
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started )
|
||||
return true;
|
||||
}
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
return false;
|
||||
if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
|
||||
return false;
|
||||
|
||||
if ( from.Region.GetRegion( typeof( SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
if (from.Region.GetRegion(typeof(SafeZone)) is SafeZone sz /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
sz = target.Region.GetRegion( typeof( SafeZone ) ) as SafeZone;
|
||||
sz = target.Region.GetRegion(typeof(SafeZone)) as SafeZone;
|
||||
|
||||
if ( sz != null /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
#endregion
|
||||
if (sz != null /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
Map map = from.Map;
|
||||
#endregion
|
||||
|
||||
#region Factions
|
||||
Faction targetFaction = Faction.Find( target, true );
|
||||
Map map = from.Map;
|
||||
|
||||
if ( (!Core.ML || map == Faction.Facet) && targetFaction != null )
|
||||
{
|
||||
if ( Faction.Find( from, true ) != targetFaction )
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
#region Factions
|
||||
|
||||
Faction targetFaction = Faction.Find(target, true);
|
||||
|
||||
if ( map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0 )
|
||||
return true; // In felucca, anything goes
|
||||
if ((!Core.ML || map == Faction.Facet) && targetFaction != null)
|
||||
if (Faction.Find(from, true) != targetFaction)
|
||||
return false;
|
||||
|
||||
if ( !from.Player )
|
||||
return true; // NPCs have no restrictions
|
||||
#endregion
|
||||
|
||||
if ( target is BaseCreature creature && !creature.Controlled )
|
||||
return false; // Players cannot heal uncontrolled mobiles
|
||||
|
||||
if ( pmFrom?.Young == true || pmTarg?.Young == true )
|
||||
return false; // Young players cannot perform beneficial actions towards older players
|
||||
if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0)
|
||||
return true; // In felucca, anything goes
|
||||
|
||||
if ( from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) )
|
||||
return true; // Guild members can be beneficial
|
||||
if (!from.Player)
|
||||
return true; // NPCs have no restrictions
|
||||
|
||||
return CheckBeneficialStatus( GetGuildStatus( from ), GetGuildStatus( target ) );
|
||||
}
|
||||
if (target is BaseCreature creature && !creature.Controlled)
|
||||
return false; // Players cannot heal uncontrolled mobiles
|
||||
|
||||
public static bool Mobile_AllowHarmful( Mobile from, Mobile target )
|
||||
{
|
||||
if ( from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player )
|
||||
return true;
|
||||
if (pmFrom?.Young == true || pmTarg?.Young == true)
|
||||
return false; // Young players cannot perform beneficial actions towards older players
|
||||
|
||||
#region Dueling
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
if (from.Guild is Guild fromGuild && target.Guild is Guild targetGuild &&
|
||||
(targetGuild == fromGuild || fromGuild.IsAlly(targetGuild)))
|
||||
return true; // Guild members can be beneficial
|
||||
|
||||
if ( pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
return CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target));
|
||||
}
|
||||
|
||||
if ( pmTarg == null && bcTarg?.Summoned == true )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
|
||||
{
|
||||
if (from == null || target == null || from.AccessLevel > AccessLevel.Player ||
|
||||
target.AccessLevel > AccessLevel.Player)
|
||||
return true;
|
||||
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) )
|
||||
return false;
|
||||
#region Dueling
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated) )
|
||||
return false;
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant )
|
||||
return false;
|
||||
if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned)
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started )
|
||||
return true;
|
||||
}
|
||||
if (pmTarg == null && bcTarg?.Summoned == true)
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
return false;
|
||||
if (pmFrom != null && pmTarg != null)
|
||||
{
|
||||
if (pmFrom.DuelContext != pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
|
||||
return false;
|
||||
|
||||
if ( from.Region.GetRegion( typeof( SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied ||
|
||||
pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
|
||||
return false;
|
||||
|
||||
sz = target.Region.GetRegion( typeof( SafeZone ) ) as SafeZone;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted &&
|
||||
pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
|
||||
pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
|
||||
return false;
|
||||
|
||||
if ( sz != null /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
#endregion
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
|
||||
return true;
|
||||
}
|
||||
|
||||
Map map = from.Map;
|
||||
if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
|
||||
return false;
|
||||
|
||||
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
|
||||
return true; // In felucca, anything goes
|
||||
if (from.Region.GetRegion(typeof(SafeZone)) is SafeZone sz /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
if ( !from.Player && !(from is BaseCreature bc && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player ) )
|
||||
{
|
||||
if ( !CheckAggressor( from.Aggressors, target ) && !CheckAggressed( from.Aggressed, target ) && pmTarg?.CheckYoungProtection( from ) == true )
|
||||
return false;
|
||||
sz = target.Region.GetRegion(typeof(SafeZone)) as SafeZone;
|
||||
|
||||
return true; // Uncontrolled NPCs are only restricted by the young system
|
||||
}
|
||||
if (sz != null /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
Guild fromGuild = GetGuildFor( from.Guild as Guild, from );
|
||||
Guild targetGuild = GetGuildFor( target.Guild as Guild, target );
|
||||
#endregion
|
||||
|
||||
if ( fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly( targetGuild ) || fromGuild.IsEnemy( targetGuild )) )
|
||||
return true; // Guild allies or enemies can be harmful
|
||||
Map map = from.Map;
|
||||
|
||||
if ( bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from )
|
||||
return false; // Cannot harm other controlled mobiles
|
||||
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return true; // In felucca, anything goes
|
||||
|
||||
if ( target.Player )
|
||||
return false; // Cannot harm other players
|
||||
if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null &&
|
||||
bc.GetMaster().AccessLevel == AccessLevel.Player))
|
||||
{
|
||||
if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) &&
|
||||
pmTarg?.CheckYoungProtection(from) == true)
|
||||
return false;
|
||||
|
||||
if ( bcTarg?.InitialInnocent != true )
|
||||
{
|
||||
if ( Notoriety.Compute( from, target ) == Notoriety.Innocent )
|
||||
return false; // Cannot harm innocent mobiles
|
||||
}
|
||||
return true; // Uncontrolled NPCs are only restricted by the young system
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Guild fromGuild = GetGuildFor(from.Guild as Guild, from);
|
||||
Guild targetGuild = GetGuildFor(target.Guild as Guild, target);
|
||||
|
||||
public static Guild GetGuildFor( Guild def, Mobile m )
|
||||
{
|
||||
Guild g = def;
|
||||
if (fromGuild != null && targetGuild != null &&
|
||||
(fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
|
||||
return true; // Guild allies or enemies can be harmful
|
||||
|
||||
if ( m is BaseCreature c && c.Controlled && c.ControlMaster != null )
|
||||
{
|
||||
c.DisplayGuildTitle = false;
|
||||
if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from)
|
||||
return false; // Cannot harm other controlled mobiles
|
||||
|
||||
if ( c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder == OrderType.Attack || c.ControlOrder == 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 (target.Player)
|
||||
return false; // Cannot harm other players
|
||||
|
||||
return g;
|
||||
}
|
||||
if (bcTarg?.InitialInnocent != true)
|
||||
if (Notoriety.Compute(from, target) == Notoriety.Innocent)
|
||||
return false; // Cannot harm innocent mobiles
|
||||
|
||||
public static int CorpseNotoriety( Mobile source, Corpse target )
|
||||
{
|
||||
if ( target.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
return true;
|
||||
}
|
||||
|
||||
Body body = target.Amount;
|
||||
public static Guild GetGuildFor(Guild def, Mobile m)
|
||||
{
|
||||
Guild g = def;
|
||||
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild, target.Owner );
|
||||
if (m is BaseCreature c && c.Controlled && c.ControlMaster != null)
|
||||
{
|
||||
c.DisplayGuildTitle = false;
|
||||
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target.Owner, true, true );
|
||||
List<Mobile> list = target.Aggressors;
|
||||
if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder == OrderType.Attack ||
|
||||
c.ControlOrder == 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 ( sourceGuild != null && targetGuild != null )
|
||||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
if ( target.Owner is BaseCreature creature )
|
||||
{
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
return Notoriety.Enemy;
|
||||
public static int CorpseNotoriety(Mobile source, Corpse target)
|
||||
{
|
||||
if (target.AccessLevel > AccessLevel.Player)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( CheckHouseFlag( source, creature, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
Body body = target.Amount;
|
||||
|
||||
int actual = Notoriety.CanBeAttacked;
|
||||
Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
|
||||
Guild targetGuild = GetGuildFor(target.Guild, target.Owner);
|
||||
|
||||
if ( target.Kills >= 5 || body.IsMonster && IsSummoned( creature ) || creature.AlwaysMurderer || creature.IsAnimatedDead )
|
||||
actual = Notoriety.Murderer;
|
||||
Faction srcFaction = Faction.Find(source, true, true);
|
||||
Faction trgFaction = Faction.Find(target.Owner, true, true);
|
||||
List<Mobile> list = target.Aggressors;
|
||||
|
||||
if ( DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice )
|
||||
return actual;
|
||||
if (sourceGuild != null && targetGuild != null)
|
||||
{
|
||||
if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
|
||||
return Notoriety.Ally;
|
||||
if (sourceGuild.IsEnemy(targetGuild))
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
Party sourceParty = Party.Get( source );
|
||||
if (target.Owner is BaseCreature creature)
|
||||
{
|
||||
if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
|
||||
return Notoriety.Enemy;
|
||||
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source || sourceParty != null && Party.Get( list[i] ) == sourceParty )
|
||||
return actual;
|
||||
}
|
||||
if (CheckHouseFlag(source, creature, target.Location, target.Map))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
int actual = Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.Kills >= 5 || body.IsMonster )
|
||||
return Notoriety.Murderer;
|
||||
if (target.Kills >= 5 || body.IsMonster && IsSummoned(creature) || creature.AlwaysMurderer ||
|
||||
creature.IsAnimatedDead)
|
||||
actual = Notoriety.Murderer;
|
||||
|
||||
if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return Notoriety.Criminal;
|
||||
if (DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)
|
||||
return actual;
|
||||
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
{
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source || list[i] is BaseFactionGuard )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
}
|
||||
Party sourceParty = Party.Get(source);
|
||||
|
||||
if ( CheckHouseFlag( source, target.Owner, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i] == source || sourceParty != null && Party.Get(list[i]) == sourceParty)
|
||||
return actual;
|
||||
|
||||
if ( !(target.Owner is PlayerMobile) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
if (target.Kills >= 5 || body.IsMonster)
|
||||
return Notoriety.Murderer;
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return Notoriety.Criminal;
|
||||
|
||||
/* Must be thread-safe */
|
||||
public static int MobileNotoriety( Mobile source, Mobile target )
|
||||
{
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i] == source || list[i] is BaseFactionGuard)
|
||||
return Notoriety.Enemy;
|
||||
|
||||
if ( Core.AOS && ( target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor || target is TownCrier ) )
|
||||
return Notoriety.Invulnerable;
|
||||
if (CheckHouseFlag(source, target.Owner, target.Location, target.Map))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
PlayerMobile pmFrom = source as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
if (!(target.Owner is PlayerMobile))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
#region Dueling
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext )
|
||||
return pmFrom.DuelContext.IsAlly( pmFrom, pmTarg ) ? Notoriety.Ally : Notoriety.Enemy;
|
||||
}
|
||||
#endregion
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i] == source)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
if ( source.Player && !target.Player && pmFrom != null && bcTarg != null )
|
||||
{
|
||||
Mobile master = bcTarg.GetMaster();
|
||||
/* Must be thread-safe */
|
||||
public static int MobileNotoriety(Mobile source, Mobile target)
|
||||
{
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
|
||||
if ( master != null && master.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (Core.AOS && (target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor ||
|
||||
target is TownCrier))
|
||||
return Notoriety.Invulnerable;
|
||||
|
||||
master = bcTarg.ControlMaster;
|
||||
PlayerMobile pmFrom = source as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
|
||||
if ( Core.ML && master != null )
|
||||
{
|
||||
if ( ( source == master && CheckAggressor( bcTarg.Aggressors, source ) ) || ( CheckAggressor( source.Aggressors, bcTarg ) ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
#region Dueling
|
||||
|
||||
return MobileNotoriety( source, master );
|
||||
}
|
||||
if (pmFrom != null && pmTarg != null)
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished &&
|
||||
pmFrom.DuelContext == pmTarg.DuelContext)
|
||||
return pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy;
|
||||
|
||||
if ( !bcTarg.Summoned && !bcTarg.Controlled && pmFrom.EnemyOfOneType == bcTarg.GetType() )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if ( target.Kills >= 5 || target.Body.IsMonster && IsSummoned( bcTarg ) && !( target is BaseFamiliar ) && !( target is ArcaneFey ) && !( target is Golem ) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true )
|
||||
return Notoriety.Murderer;
|
||||
if (target.AccessLevel > AccessLevel.Player)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.Criminal )
|
||||
return Notoriety.Criminal;
|
||||
if (source.Player && !target.Player && pmFrom != null && bcTarg != null)
|
||||
{
|
||||
Mobile master = bcTarg.GetMaster();
|
||||
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild as Guild, target );
|
||||
if (master != null && master.AccessLevel > AccessLevel.Player)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( sourceGuild != null && targetGuild != null )
|
||||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
master = bcTarg.ControlMaster;
|
||||
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target, true, true );
|
||||
if (Core.ML && master != null)
|
||||
{
|
||||
if (source == master && CheckAggressor(bcTarg.Aggressors, source) ||
|
||||
CheckAggressor(source.Aggressors, bcTarg))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
return Notoriety.Enemy;
|
||||
return MobileNotoriety(source, master);
|
||||
}
|
||||
|
||||
if ( SkillHandlers.Stealing.ClassicMode && pmTarg?.PermaFlags.Contains( source ) == true )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (!bcTarg.Summoned && !bcTarg.Controlled && pmFrom.EnemyOfOneType == bcTarg.GetType())
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
if ( bcTarg?.AlwaysAttackable == true )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (target.Kills >= 5 ||
|
||||
target.Body.IsMonster && IsSummoned(bcTarg) && !(target is BaseFamiliar) && !(target is ArcaneFey) &&
|
||||
!(target is Golem) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true)
|
||||
return Notoriety.Murderer;
|
||||
|
||||
if ( CheckHouseFlag( source, target, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (target.Criminal)
|
||||
return Notoriety.Criminal;
|
||||
|
||||
if ( bcTarg?.InitialInnocent != true )
|
||||
{
|
||||
if ( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( bcTarg ) && pmTarg == null || !Core.ML && !target.CanBeginAction( typeof( Spells.Seventh.PolymorphSpell ) ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
|
||||
Guild targetGuild = GetGuildFor(target.Guild as Guild, target);
|
||||
|
||||
if ( CheckAggressor( source.Aggressors, target ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (sourceGuild != null && targetGuild != null)
|
||||
{
|
||||
if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
|
||||
return Notoriety.Ally;
|
||||
if (sourceGuild.IsEnemy(targetGuild))
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
if ( CheckAggressed( source.Aggressed, target ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
Faction srcFaction = Faction.Find(source, true, true);
|
||||
Faction trgFaction = Faction.Find(target, true, true);
|
||||
|
||||
if ( bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard && bcTarg.ControlTarget == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
|
||||
return Notoriety.Enemy;
|
||||
|
||||
if ( source is BaseCreature bc )
|
||||
{
|
||||
Mobile master = bc.GetMaster();
|
||||
if (Stealing.ClassicMode && pmTarg?.PermaFlags.Contains(source) == true)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( master != null && CheckAggressor( master.Aggressors, target ) || MobileNotoriety( master, target ) == Notoriety.CanBeAttacked || bcTarg != null )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
if (bcTarg?.AlwaysAttackable == true)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
if (CheckHouseFlag(source, target, target.Location, target.Map))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
public static bool CheckHouseFlag( Mobile from, Mobile m, Point3D p, Map map )
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( p, map, 16 );
|
||||
if (bcTarg?.InitialInnocent != true)
|
||||
if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bcTarg) && pmTarg == null ||
|
||||
!Core.ML && !target.CanBeginAction(typeof(PolymorphSpell)))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( house == null || house.Public || !house.IsFriend( from ) )
|
||||
return false;
|
||||
if (CheckAggressor(source.Aggressors, target))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( m != null && house.IsFriend( m ) )
|
||||
return false;
|
||||
if (CheckAggressed(source.Aggressed, target))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null )
|
||||
return !house.IsFriend( c.ControlMaster );
|
||||
if (bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard &&
|
||||
bcTarg.ControlTarget == source)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
return true;
|
||||
}
|
||||
if (source is BaseCreature bc)
|
||||
{
|
||||
Mobile master = bc.GetMaster();
|
||||
|
||||
public static bool IsPet( BaseCreature c )
|
||||
{
|
||||
return (c != null && c.Controlled);
|
||||
}
|
||||
if (master != null && CheckAggressor(master.Aggressors, target) ||
|
||||
MobileNotoriety(master, target) == Notoriety.CanBeAttacked || bcTarg != null)
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
public static bool IsSummoned( BaseCreature c )
|
||||
{
|
||||
return (c != null && /*c.Controlled &&*/ c.Summoned);
|
||||
}
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
public static bool CheckAggressor( List<AggressorInfo> list, Mobile target )
|
||||
{
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
if ( list[i].Attacker == target )
|
||||
return true;
|
||||
public static bool CheckHouseFlag(Mobile from, Mobile m, Point3D p, Map map)
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(p, map, 16);
|
||||
|
||||
return false;
|
||||
}
|
||||
if (house == null || house.Public || !house.IsFriend(from))
|
||||
return false;
|
||||
|
||||
public static bool CheckAggressed( List<AggressorInfo> list, Mobile target )
|
||||
{
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
if (m != null && house.IsFriend(m))
|
||||
return false;
|
||||
|
||||
if ( !info.CriminalAggression && info.Defender == target )
|
||||
return true;
|
||||
}
|
||||
if (m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null)
|
||||
return !house.IsFriend(c.ControlMaster);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsPet(BaseCreature c)
|
||||
{
|
||||
return c != null && c.Controlled;
|
||||
}
|
||||
|
||||
public static bool IsSummoned(BaseCreature c)
|
||||
{
|
||||
return c != null && /*c.Controlled &&*/ c.Summoned;
|
||||
}
|
||||
|
||||
public static bool CheckAggressor(List<AggressorInfo> list, Mobile target)
|
||||
{
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i].Attacker == target)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckAggressed(List<AggressorInfo> list, Mobile target)
|
||||
{
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
|
||||
if (!info.CriminalAggression && info.Defender == target)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private enum GuildStatus
|
||||
{
|
||||
None,
|
||||
Peaceful,
|
||||
Waring
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue