Example #1
0
        public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
        {
            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            Map map = from.Map;

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(from, target))
            {
                return(false);
            }

            if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }
            if (!from.Player)
            {
                return(true); // NPCs have no restrictions
            }
            if (target is BaseCreature && !((BaseCreature)target).Controlled)
            {
                return(false); // Players cannot heal uncontrolled mobiles
            }
            if (from is PlayerMobile && ((PlayerMobile)from).Young && target is BaseCreature &&
                ((BaseCreature)target).Controlled)
            {
                return(true);
            }

            if (from is PlayerMobile && ((PlayerMobile)from).Young &&
                (!(target is PlayerMobile) || !((PlayerMobile)target).Young))
            {
                return(false); // Young players cannot perform beneficial actions towards older players
            }
            Guild fromGuild   = from.Guild as Guild;
            Guild targetGuild = target.Guild as Guild;

            if (fromGuild != null && targetGuild != null)
            {
                if (targetGuild == fromGuild || fromGuild.IsAlly(targetGuild))
                {
                    return(true); // Guild members can be beneficial
                }
            }

            return(CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target)));
        }
Example #2
0
        public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
        {
            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            var map = from.Map;

            #region Factions/VvV
            if (Settings.Enabled)
            {
                var targetFaction = Faction.Find(target, true);

                if ((!Core.ML || map == Faction.Facet) && targetFaction != null)
                {
                    if (Faction.Find(from, true) != targetFaction)
                    {
                        return(false);
                    }
                }
            }

            if (ViceVsVirtueSystem.Enabled)
            {
                if (ViceVsVirtueSystem.IsEnemy(from, target))
                {
                    return(false);
                }
            }
            #endregion

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                return(false);
            }
            #endregion

            if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0)
            {
                return(true);                // In felucca, anything goes
            }
            if (!from.Player)
            {
                return(true);                // NPCs have no restrictions
            }
            if (target is BaseCreature && !((BaseCreature)target).Controlled)
            {
                return(false);                // Players cannot heal uncontrolled mobiles
            }
            if (from is PlayerMobile && ((PlayerMobile)from).Young && target is BaseCreature &&
                ((BaseCreature)target).Controlled)
            {
                return(true);
            }

            if (from is PlayerMobile && ((PlayerMobile)from).Young &&
                (!(target is PlayerMobile) || !((PlayerMobile)target).Young))
            {
                return(false);                // Young players cannot perform beneficial actions towards older players
            }
            var fromGuild   = from.Guild as Guild;
            var targetGuild = target.Guild as Guild;

            if (fromGuild != null && targetGuild != null)
            {
                if (targetGuild == fromGuild || fromGuild.IsAlly(targetGuild))
                {
                    return(true);                    // Guild members can be beneficial
                }
            }

            return(CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target)));
        }
Example #3
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 #4
0
        public static int CorpseNotoriety(Mobile source, Corpse target)
        {
            if (target.AccessLevel > AccessLevel.VIP)
            {
                return(Notoriety.CanBeAttacked);
            }

            Body body = target.Amount;

            var cretOwner = target.Owner as BaseCreature;

            if (cretOwner != null)
            {
                var sourceGuild = GetGuildFor(source.Guild as Guild, source);
                var targetGuild = GetGuildFor(target.Guild, target.Owner);

                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(cretOwner, true, true);

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

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

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

                var actual = Notoriety.CanBeAttacked;

                if (target.Murderer)
                {
                    actual = Notoriety.Murderer;
                }
                else if (body.IsMonster && IsSummoned(cretOwner))
                {
                    actual = Notoriety.Murderer;
                }
                else if (cretOwner.AlwaysMurderer || cretOwner.IsAnimatedDead)
                {
                    actual = Notoriety.Murderer;
                }

                if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice))
                {
                    return(actual);
                }

                var sourceParty = Party.Get(source);

                foreach (var m in target.Aggressors)
                {
                    if (m == source || (sourceParty != null && Party.Get(m) == sourceParty) || (sourceGuild != null && m.Guild == sourceGuild))
                    {
                        return(actual);
                    }
                }

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

                if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0))
                {
                    return(Notoriety.Criminal);
                }

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

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

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

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

                if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
                {
                    foreach (var m in target.Aggressors)
                    {
                        if (m == source || m is BaseFactionGuard)
                        {
                            return(Notoriety.Enemy);
                        }
                    }
                }

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

                if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }

                var list = target.Aggressors;

                foreach (var m in list)
                {
                    if (m == source)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                return(Notoriety.Innocent);
            }
        }
Example #5
0
        public static int MobileNotoriety(Mobile source, IDamageable damageable)
        {
            Mobile target = damageable as Mobile;

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

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

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

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

            EnemyOfOneContext 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);
            }

            var bc = target as BaseCreature;

            if (source.Player && bc != null)
            {
                Mobile master = bc.GetMaster();

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

                master = bc.ControlMaster;

                if (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(bc))
            {
                if (!(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem))
                {
                    return(Notoriety.Murderer);
                }
            }

            if (bc != null && (bc.AlwaysMurderer || bc.IsAnimatedDead))
            {
                return(Notoriety.Murderer);
            }

            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)
                {
                    return(Notoriety.Ally);
                }

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

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

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, target) && (ViceVsVirtueSystem.EnhancedRules || source.Map == ViceVsVirtueSystem.Facet))
            {
                return(Notoriety.Enemy);
            }

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

            if (bc != null && bc.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 (!(bc != null && ((BaseCreature)target).InitialInnocent))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !(target is PlayerMobile))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

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

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

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

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

            if (bc != null)
            {
                if (bc.AlwaysInnocent)
                {
                    return(Notoriety.Innocent);
                }

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

            if (source is BaseCreature creature)
            {
                Mobile master = creature.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 #6
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);
            }

            Map map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }

            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 pm && pm.CheckYoungProtection(from))
                {
                    return(false);
                }

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

            // 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;
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild 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 (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable))
            {
                return(true);
            }

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

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

            return(true);
        }
Example #7
0
        public static int CorpseNotoriety(Mobile source, Corpse target)
        {
            if (target.AccessLevel > AccessLevel.VIP)
            {
                return(Notoriety.CanBeAttacked);
            }

            Body body = (Body)target.Amount;

            BaseCreature cretOwner = target.Owner as BaseCreature;

            if (cretOwner != null)
            {
                Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
                Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner);

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

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

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

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

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

                int actual = Notoriety.CanBeAttacked;

                if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)))
                {
                    actual = Notoriety.Murderer;
                }

                if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice))
                {
                    return(actual);
                }

                Party sourceParty = Party.Get(source);

                List <Mobile> list = target.Aggressors;

                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty))
                    {
                        return(actual);
                    }
                }

                return(Notoriety.Innocent);
            }
            else
            {
                if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)))
                {
                    return(Notoriety.Murderer);
                }

                if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0))
                {
                    return(Notoriety.Criminal);
                }

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

                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.Owner, true, true);

                if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
                {
                    List <Mobile> secondList = target.Aggressors;

                    for (int i = 0; i < secondList.Count; ++i)
                    {
                        if (secondList[i] == source || secondList[i] is BaseFactionGuard)
                        {
                            return(Notoriety.Enemy);
                        }
                    }
                }

                if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable)
                {
                    return(Notoriety.CanBeAttacked);
                }

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

                if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }

                List <Mobile> list = target.Aggressors;

                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i] == source)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                return(Notoriety.Innocent);
            }
        }
Example #8
0
        /*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target )
         * {
         * if ( from == GuildStatus.Waring && target == GuildStatus.Waring )
         * return true;
         *
         * return false;
         * }*/

        public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
        {
            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            #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.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.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;

            #region Factions/VvV
            if (Factions.Settings.Enabled)
            {
                Faction targetFaction = Faction.Find(target, true);

                if ((!Core.ML || map == Faction.Facet) && targetFaction != null)
                {
                    if (Faction.Find(from, true) != targetFaction)
                    {
                        return(false);
                    }
                }
            }

            if (ViceVsVirtueSystem.Enabled)
            {
                if (ViceVsVirtueSystem.IsEnemy(from, target))
                {
                    return(false);
                }
            }
            #endregion

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                return(false);
            }
            #endregion

            if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }
            if (!from.Player)
            {
                return(true); // NPCs have no restrictions
            }
            if (target is BaseCreature && !((BaseCreature)target).Controlled)
            {
                return(false); // Players cannot heal uncontrolled mobiles
            }
            if (XmlPoints.AreInAnyGame(target))
            {
                return(XmlPoints.AreTeamMembers(from, target));
            }

            if (from is PlayerMobile && ((PlayerMobile)from).Young && target is BaseCreature &&
                ((BaseCreature)target).Controlled)
            {
                return(true);
            }

            if (from is PlayerMobile && ((PlayerMobile)from).Young && (!(target is PlayerMobile) || !((PlayerMobile)target).Young))
            {
                return(false); // Young players cannot perform beneficial actions towards older players
            }
            Guild fromGuild   = from.Guild as Guild;
            Guild targetGuild = target.Guild as Guild;

            if (fromGuild != null && targetGuild != null && (targetGuild == fromGuild || fromGuild.IsAlly(targetGuild)))
            {
                return(true); // Guild members can be beneficial
            }
            return(CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target)));
        }
Example #9
0
        public static int MobileNotoriety(Mobile source, IDamageable damageable)
        {
            Mobile target = damageable 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);
                }
            }

            if (Factions.Settings.Enabled)
            {
                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 (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, damageable) && 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 #10
0
        public static int CorpseNotoriety(Mobile source, Corpse target)
        {
            if (target.AccessLevel > AccessLevel.VIP)
            {
                return(Notoriety.CanBeAttacked);
            }

            Body body = target.Amount;

            if (target.Owner is BaseCreature creatureOwner)
            {
                Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
                Guild targetGuild = GetGuildFor(target.Guild, target.Owner);

                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 (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, creatureOwner) && (ViceVsVirtueSystem.EnhancedRules || source.Map == ViceVsVirtueSystem.Facet))
                {
                    return(Notoriety.Enemy);
                }

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

                int actual = Notoriety.CanBeAttacked;

                if (target.Murderer)
                {
                    actual = Notoriety.Murderer;
                }
                else if (body.IsMonster && IsSummoned(creatureOwner))
                {
                    actual = Notoriety.Murderer;
                }
                else if (creatureOwner.AlwaysMurderer || creatureOwner.IsAnimatedDead)
                {
                    actual = Notoriety.Murderer;
                }

                if (DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)
                {
                    return(actual);
                }

                Party sourceParty = Party.Get(source);

                bool any = false;

                for (var index = 0; index < target.Aggressors.Count; index++)
                {
                    var m = target.Aggressors[index];

                    if (m.IsPlayer())
                    {
                        any = true;
                        break;
                    }
                }

                if (!any)
                {
                    return(actual);
                }

                for (var index = 0; index < target.Aggressors.Count; index++)
                {
                    Mobile m = target.Aggressors[index];

                    if (m == source || sourceParty != null && Party.Get(m) == sourceParty || sourceGuild != null && m.Guild == sourceGuild)
                    {
                        return(actual);
                    }
                }

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

                if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0)
                {
                    return(Notoriety.Criminal);
                }

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

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

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

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

                if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }

                List <Mobile> list = target.Aggressors;

                for (var index = 0; index < list.Count; index++)
                {
                    Mobile m = list[index];

                    if (m == source)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                return(Notoriety.Innocent);
            }
        }
Example #11
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 (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable))
            {
                return(true);
            }

            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);
        }