Example #1
0
        public static int MobileNotoriety(Mobile source, IDamageable damageable)
        {
            if (damageable is PublicMoongate)
            {
                return(Notoriety.Innocent);
            }

            var target = damageable as Mobile;

            if (target == null)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (Core.AOS)
            {
                if (target.Blessed)
                {
                    return(Notoriety.Invulnerable);
                }

                if (target is BaseVendor && ((BaseVendor)target).IsInvulnerable)
                {
                    return(Notoriety.Invulnerable);
                }

                if (target is PlayerVendor || target is TownCrier)
                {
                    return(Notoriety.Invulnerable);
                }
            }

            var context = EnemyOfOneSpell.GetContext(source);

            if (context != null && context.IsEnemy(target))
            {
                return(Notoriety.Enemy);
            }

            if (PVPArenaSystem.IsEnemy(source, target))
            {
                return(Notoriety.Enemy);
            }

            if (PVPArenaSystem.IsFriendly(source, target))
            {
                return(Notoriety.Ally);
            }

            if (target.IsStaff())
            {
                return(Notoriety.CanBeAttacked);
            }

            if (source.Player && target is BaseCreature)
            {
                var bc = (BaseCreature)target;

                var master = bc.GetMaster();

                if (master != null && master.IsStaff())
                {
                    return(Notoriety.CanBeAttacked);
                }

                master = bc.ControlMaster;

                if (Core.ML && master != null && !bc.ForceNotoriety)
                {
                    if (source == master && CheckAggressor(target.Aggressors, source))
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (CheckAggressor(source.Aggressors, bc))
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    return(MobileNotoriety(source, master));
                }
            }

            if (target.Murderer)
            {
                return(Notoriety.Murderer);
            }

            if (target.Body.IsMonster && IsSummoned(target as BaseCreature))
            {
                if (!(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem))
                {
                    return(Notoriety.Murderer);
                }
            }

            if (target is BaseCreature)
            {
                if (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)
                {
                    return(Notoriety.Murderer);
                }
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(source))
                {
                    return(Notoriety.Murderer);
                }

                return(Notoriety.Innocent);
            }

            if (source.Player && target is BaseEscort)
            {
                return(Notoriety.Innocent);
            }
            #endregion

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            var sourceGuild = GetGuildFor(source.Guild as Guild, source);
            var targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild)
                {
                    return(Notoriety.Ally);
                }

                if (sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }

                if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            if (Settings.Enabled)
            {
                var srcFaction = Faction.Find(source, true, true);
                var trgFaction = Faction.Find(target, true, true);

                if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
                {
                    return(Notoriety.Enemy);
                }
            }

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, damageable) && source.Map == Faction.Facet)
            {
                return(Notoriety.Enemy);
            }

            if (Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent...
            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !(target is PlayerMobile))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (!Core.ML && !target.CanBeginAction(typeof(PolymorphSpell)))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (source is PlayerMobile && CheckPetAggressor((PlayerMobile)source, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (source is PlayerMobile && CheckPetAggressed((PlayerMobile)source, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature)
            {
                var bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (source is BaseCreature)
            {
                var bc     = (BaseCreature)source;
                var master = bc.GetMaster();

                if (master != null)
                {
                    if (CheckAggressor(master.Aggressors, target))
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (MobileNotoriety(master, target) == Notoriety.CanBeAttacked)
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (target is BaseCreature)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            return(Notoriety.Innocent);
        }
Example #2
0
        public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            var target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                {
                    return(true);
                }

                from.SendLocalizedMessage(1075456);                 // You are not allowed to damage this NPC unless your on the Guilty Quest
                return(false);
            }
            #endregion

            var map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true);                // In felucca, anything goes
            }
            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
            {
                from = ((BaseCreature)from).SummonMaster;
            }

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
            {
                target = ((BaseCreature)target).SummonMaster;
            }

            var bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile &&
                    ((PlayerMobile)target).CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true);                // Uncontrolled NPCs are only restricted by the young system
            }

            var fromGuild   = GetGuildFor(from.Guild as Guild, from);
            var targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null)
            {
                if (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))
                {
                    return(true);                    // Guild allies or enemies can be harmful
                }
            }

            if (target is BaseCreature)
            {
                if (((BaseCreature)target).Controlled)
                {
                    return(false);                    // Cannot harm other controlled mobiles
                }
                if (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)
                {
                    return(false);                    // Cannot harm other controlled mobiles
                }
            }

            if (target.Player)
            {
                return(false);                // Cannot harm other players
            }
            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false);                    // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #3
0
        public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            Mobile target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                {
                    return(true);
                }

                from.SendLocalizedMessage(1075456); // You are not allowed to damage this NPC unless your on the Guilty Quest
                return(false);
            }
            #endregion

            #region Dueling
            PlayerMobile pmFrom = from as PlayerMobile;
            PlayerMobile pmTarg = target as PlayerMobile;

            if (pmFrom == null && from is BaseCreature)
            {
                BaseCreature bcFrom = (BaseCreature)from;

                if (bcFrom.Summoned)
                {
                    pmFrom = bcFrom.SummonMaster as PlayerMobile;
                }
            }

            if (pmTarg == null && target is BaseCreature)
            {
                BaseCreature bcTarg = (BaseCreature)target;

                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.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.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 != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
            {
                return(false);
            }

            Engines.ConPVP.SafeZone sz = from.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone;

            if (sz != null /*&& sz.IsDisabled()*/)
            {
                return(false);
            }

            sz = target.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone;

            if (sz != null /*&& sz.IsDisabled()*/)
            {
                return(false);
            }
            #endregion

            Map map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }
            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
            {
                from = ((BaseCreature)from).SummonMaster;
            }

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
            {
                target = ((BaseCreature)target).SummonMaster;
            }

            BaseCreature bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true); // Uncontrolled NPCs are only restricted by the young system
            }

            if (XmlPoints.AreChallengers(from, target))
            {
                return(true);
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
            {
                return(true); // Guild allies or enemies can be harmful
            }
            if (target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)))
            {
                return(false); // Cannot harm other controlled mobiles
            }
            if (target.Player)
            {
                return(false); // Cannot harm other players
            }
            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false); // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #4
0
        public static int MobileNotoriety(Mobile source, IDamageable damagable)
        {
            Mobile target = damagable as Mobile;

            if (target == null)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            #region Dueling
            if (source is PlayerMobile && target is PlayerMobile)
            {
                PlayerMobile pmFrom = (PlayerMobile)source;
                PlayerMobile pmTarg = (PlayerMobile)target;

                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

            if (target.IsStaff())
            {
                return(Notoriety.CanBeAttacked);
            }

            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                Mobile master = bc.GetMaster();

                if (master != null && master.IsStaff())
                {
                    return(Notoriety.CanBeAttacked);
                }

                master = bc.ControlMaster;

                if (Core.ML && master != null && !bc.ForceNotoriety)
                {
                    if ((source == master && CheckAggressor(target.Aggressors, source)) || (CheckAggressor(source.Aggressors, bc)))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else
                    {
                        return(MobileNotoriety(source, master));
                    }
                }

                if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                Gregorio gregorio = (Gregorio)target;

                if (Gregorio.IsMurderer(source))
                {
                    return(Notoriety.Murderer);
                }

                return(Notoriety.Innocent);
            }
            else if (source.Player && target is Engines.Quests.BaseEscort)
            {
                return(Notoriety.Innocent);
            }
            #endregion

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            if (XmlPoints.AreTeamMembers(source, target))
            {
                return(Notoriety.Ally);
            }
            else if (XmlPoints.AreChallengers(source, target))
            {
                return(Notoriety.Enemy);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
            {
                return(Notoriety.Enemy);
            }

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))   //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent...
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !(target is PlayerMobile) || !Core.ML && !target.CanBeginAction(typeof(Server.Spells.Seventh.PolymorphSpell)))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (source is BaseCreature)
            {
                BaseCreature bc     = (BaseCreature)source;
                Mobile       master = bc.GetMaster();

                if (master != null)
                {
                    if (CheckAggressor(master.Aggressors, target) || MobileNotoriety(master, target) == Notoriety.CanBeAttacked || target is BaseCreature)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            return(Notoriety.Innocent);
        }
Example #5
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                Mobile master = bc.GetMaster();

                if (master != null && master.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }

                master = bc.ControlMaster;

                if (Core.ML && master != null)
                {
                    if (source == master && CheckAggressor(target.Aggressors, source))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else
                    {
                        return(MobileNotoriety(source, master));
                    }
                }

                if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                Gregorio gregorio = (Gregorio)target;

                if (Gregorio.IsMurderer(source))
                {
                    return(Notoriety.Murderer);
                }

                return(Notoriety.Innocent);
            }
            else if (source.Player && target is Engines.Quests.BaseEscort)
            {
                return(Notoriety.Innocent);
            }
            #endregion

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
            {
                return(Notoriety.Enemy);
            }

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !TransformationSpellHelper.UnderTransformation(target) && !AnimalForm.UnderTransformation(target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (source is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)source;

                Mobile master = bc.GetMaster();
                if (master != null && CheckAggressor(master.Aggressors, target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            return(Notoriety.Innocent);
        }