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

            Mobile target = damageable as Mobile;

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

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

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

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

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

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

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

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

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

            return(Notoriety.Innocent);
        }
Beispiel #2
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
            }
            // 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
            }

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

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

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

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

                Party sourceParty = Party.Get(source);

                foreach (Mobile 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);
                }

                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;

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

                return(Notoriety.Innocent);
            }
        }
Beispiel #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    from.SendLocalizedMessage(502816); // You feel that such an action would be inappropriate
                }
                else if (targeted is IRemoveTrapTrainingKit)
                {
                    ((IRemoveTrapTrainingKit)targeted).OnRemoveTrap(from);
                }
                else if (targeted is LockableContainer && ((LockableContainer)targeted).Locked)
                {
                    from.SendLocalizedMessage(501283); // That is locked.
                }
                else if (targeted is TrapableContainer)
                {
                    TrapableContainer targ = (TrapableContainer)targeted;

                    from.Direction = from.GetDirectionTo(targ);

                    if (targ.TrapType == TrapType.None)
                    {
                        from.SendLocalizedMessage(502373); // That doesn't appear to be trapped
                    }
                    else if (targ is TreasureMapChest && TreasureMapInfo.NewSystem)
                    {
                        TreasureMapChest tChest = (TreasureMapChest)targ;

                        if (tChest.Owner != from)
                        {
                            from.SendLocalizedMessage(1159010); // That is not your chest!
                        }
                        else if (IsDisarming(from, tChest))
                        {
                            from.SendLocalizedMessage(1159059); // You are already manipulating the trigger mechanism...
                        }
                        else if (IsBeingDisarmed(tChest))
                        {
                            from.SendLocalizedMessage(1159063); // That trap is already being disarmed.
                        }
                        else if (tChest.AncientGuardians.Any(g => !g.Deleted))
                        {
                            from.PrivateOverheadMessage(MessageType.Regular, 1150, 1159060, from.NetState); // *Your attempt fails as the the mechanism jams and you are attacked by an Ancient Chest Guardian!*
                        }
                        else
                        {
                            from.PlaySound(0x241);

                            from.PrivateOverheadMessage(MessageType.Regular, 1150, 1159057, from.NetState); // *You delicately manipulate the trigger mechanism...*

                            StartChestDisarmTimer(from, tChest);
                        }
                    }
                    else
                    {
                        from.PlaySound(0x241);

                        if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, targ.TrapPower - 10, targ.TrapPower + 10))
                        {
                            targ.TrapPower = 0;
                            targ.TrapLevel = 0;
                            targ.TrapType  = TrapType.None;
                            targ.InvalidateProperties();
                            from.SendLocalizedMessage(502377); // You successfully render the trap harmless
                        }
                        else
                        {
                            from.SendLocalizedMessage(502372); // You fail to disarm the trap... but you don't set it off
                        }
                    }
                }
                else if (targeted is VvVTrap)
                {
                    VvVTrap trap = targeted as VvVTrap;

                    if (!ViceVsVirtueSystem.IsVvV(from))
                    {
                        from.SendLocalizedMessage(1155496); // This item can only be used by VvV participants!
                    }
                    else
                    {
                        if (from == trap.Owner || ((from.Skills[SkillName.RemoveTrap].Value - 80.0) / 20.0) > Utility.RandomDouble())
                        {
                            VvVTrapKit kit = new VvVTrapKit(trap.TrapType);
                            trap.Delete();

                            if (!from.AddToBackpack(kit))
                            {
                                kit.MoveToWorld(from.Location, from.Map);
                            }

                            if (trap.Owner != null && from != trap.Owner)
                            {
                                Guild fromG  = from.Guild as Guild;
                                Guild ownerG = trap.Owner.Guild as Guild;

                                if (fromG != null && fromG != ownerG && !fromG.IsAlly(ownerG) && ViceVsVirtueSystem.Instance != null &&
                                    ViceVsVirtueSystem.Instance.Battle != null && ViceVsVirtueSystem.Instance.Battle.OnGoing)
                                {
                                    ViceVsVirtueSystem.Instance.Battle.Update(from, UpdateType.Disarm);
                                }
                            }

                            from.PrivateOverheadMessage(MessageType.Regular, 1154, 1155413, from.NetState);
                        }
                        else if (.1 > Utility.RandomDouble())
                        {
                            trap.Detonate(from);
                        }
                    }
                }
                else if (targeted is GoblinFloorTrap)
                {
                    GoblinFloorTrap targ = (GoblinFloorTrap)targeted;

                    if (from.InRange(targ.Location, 3))
                    {
                        from.Direction = from.GetDirectionTo(targ);

                        if (targ.Owner == null)
                        {
                            Item item = new FloorTrapComponent();

                            if (from.Backpack == null || !from.Backpack.TryDropItem(from, item, false))
                            {
                                item.MoveToWorld(from.Location, from.Map);
                            }
                        }

                        targ.Delete();
                        from.SendLocalizedMessage(502377); // You successfully render the trap harmless
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502373); // That does'nt appear to be trapped
                }
            }
Beispiel #5
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 && ViceVsVirtueSystem.IsEnemy(from, target))
            {
                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 targetGuild = target.Guild as Guild;

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

            return(CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target)));
        }
Beispiel #6
0
            protected override void OnTarget(Mobile src, object targ)
            {
                bool foundAnyone = false;

                Point3D p;

                if (targ is Mobile)
                {
                    p = ((Mobile)targ).Location;
                }
                else if (targ is Item)
                {
                    p = ((Item)targ).Location;
                }
                else if (targ is IPoint3D)
                {
                    p = new Point3D((IPoint3D)targ);
                }
                else
                {
                    p = src.Location;
                }

                double srcSkill = src.Skills[SkillName.DetectHidden].Value;
                int    range    = (int)(srcSkill / 10.0);

                if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
                {
                    range /= 2;
                }

                BaseHouse house = BaseHouse.FindHouseAt(p, src.Map, 16);

                bool inHouse = (house != null && house.IsFriend(src));

                if (inHouse)
                {
                    range = 22;
                }

                if (range > 0)
                {
                    IPooledEnumerable inRange = src.Map.GetMobilesInRange(p, range);

                    foreach (Mobile trg in inRange)
                    {
                        if (trg.Hidden && src != trg)
                        {
                            double ss = srcSkill + Utility.Random(21) - 10;
                            double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random(21) - 10;

                            if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || (inHouse && house.IsInside(trg))))
                            {
                                if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y))
                                {
                                    continue;
                                }

                                trg.RevealingAction();
                                trg.SendLocalizedMessage(500814); // You have been revealed!
                                foundAnyone = true;
                            }
                        }
                    }

                    inRange.Free();

                    bool faction = Faction.Find(src) != null;
                    bool vvv     = ViceVsVirtueSystem.IsVvV(src);

                    if (faction || vvv)
                    {
                        IPooledEnumerable itemsInRange = src.Map.GetItemsInRange(p, range);

                        foreach (Item item in itemsInRange)
                        {
                            if (faction && item is BaseFactionTrap)
                            {
                                BaseFactionTrap trap = (BaseFactionTrap)item;

                                if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0))
                                {
                                    src.SendLocalizedMessage(1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName)); // You reveal a trap placed by a faction:

                                    trap.Visible = true;
                                    trap.BeginConceal();

                                    foundAnyone = true;
                                }
                            }
                            else if (vvv && (item is VvVSigil || item is VvVTrap) && Utility.Random(100) <= srcSkill)
                            {
                                if (item is VvVTrap && item.ItemID == VvVTrap.HiddenID)
                                {
                                    ((VvVTrap)item).OnRevealed(src);
                                }
                                else if (!item.Visible)
                                {
                                    item.Visible = true;
                                }
                            }
                        }

                        itemsInRange.Free();
                    }
                }

                if (!foundAnyone)
                {
                    src.SendLocalizedMessage(500817); // You can see nothing hidden there.
                }
            }
Beispiel #7
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    from.SendLocalizedMessage(502816); // You feel that such an action would be inappropriate
                }
                else if (targeted is TrapableContainer)
                {
                    TrapableContainer targ = (TrapableContainer)targeted;

                    from.Direction = from.GetDirectionTo(targ);

                    if (targ.TrapType == Server.Items.TrapType.None)
                    {
                        from.SendLocalizedMessage(502373); // That doesn't appear to be trapped
                        return;
                    }

                    from.PlaySound(0x241);

                    if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, targ.TrapPower, targ.TrapPower + 30))
                    {
                        targ.TrapPower = 0;
                        targ.TrapLevel = 0;
                        targ.TrapType  = Server.Items.TrapType.None;
                        targ.InvalidateProperties();
                        from.SendLocalizedMessage(502377); // You successfully render the trap harmless
                    }
                    else
                    {
                        from.SendLocalizedMessage(502372); // You fail to disarm the trap... but you don't set it off
                    }
                }
                else if (targeted is BaseFactionTrap)
                {
                    BaseFactionTrap trap    = (BaseFactionTrap)targeted;
                    Faction         faction = Faction.Find(from);

                    FactionTrapRemovalKit kit = (from.Backpack == null ? null : from.Backpack.FindItemByType(typeof(FactionTrapRemovalKit)) as FactionTrapRemovalKit);

                    bool isOwner = (trap.Placer == from || (trap.Faction != null && trap.Faction.IsCommander(from)));

                    if (faction == null)
                    {
                        from.SendLocalizedMessage(1010538); // You may not disarm faction traps unless you are in an opposing faction
                    }
                    else if (faction == trap.Faction && trap.Faction != null && !isOwner)
                    {
                        from.SendLocalizedMessage(1010537); // You may not disarm traps set by your own faction!
                    }
                    else if (!isOwner && kit == null)
                    {
                        from.SendLocalizedMessage(1042530); // You must have a trap removal kit at the base level of your pack to disarm a faction trap.
                    }
                    else
                    {
                        if ((Core.ML && isOwner) || (from.CheckTargetSkill(SkillName.RemoveTrap, trap, 80.0, 100.0) && from.CheckTargetSkill(SkillName.Tinkering, trap, 80.0, 100.0)))
                        {
                            from.PrivateOverheadMessage(MessageType.Regular, trap.MessageHue, trap.DisarmMessage, from.NetState);

                            if (!isOwner)
                            {
                                int silver = faction.AwardSilver(from, trap.SilverFromDisarm);

                                if (silver > 0)
                                {
                                    from.SendLocalizedMessage(1008113, true, silver.ToString("N0")); // You have been granted faction silver for removing the enemy trap :
                                }
                            }

                            trap.Delete();
                        }
                        else
                        {
                            from.SendLocalizedMessage(502372); // You fail to disarm the trap... but you don't set it off
                        }

                        if (!isOwner && kit != null)
                        {
                            kit.ConsumeCharge(from);
                        }
                    }
                }
                else if (targeted is VvVTrap)
                {
                    VvVTrap trap = targeted as VvVTrap;

                    if (!ViceVsVirtueSystem.IsVvV(from))
                    {
                        from.SendLocalizedMessage(1155496); // This item can only be used by VvV participants!
                    }
                    else
                    {
                        if (from == trap.Owner || ((from.Skills[SkillName.RemoveTrap].Value - 80.0) / 20.0) > Utility.RandomDouble())
                        {
                            VvVTrapKit kit = new VvVTrapKit(trap.TrapType);
                            trap.Delete();

                            if (!from.AddToBackpack(kit))
                            {
                                kit.MoveToWorld(from.Location, from.Map);
                            }

                            if (trap.Owner != null && from != trap.Owner)
                            {
                                Guild fromG  = from.Guild as Guild;
                                Guild ownerG = trap.Owner.Guild as Guild;

                                if (fromG != null && fromG != ownerG && !fromG.IsAlly(ownerG) && ViceVsVirtueSystem.Instance != null &&
                                    ViceVsVirtueSystem.Instance.Battle != null && ViceVsVirtueSystem.Instance.Battle.OnGoing)
                                {
                                    ViceVsVirtueSystem.Instance.Battle.Update(from, UpdateType.Disarm);
                                }
                            }

                            from.PrivateOverheadMessage(Server.Network.MessageType.Regular, 1154, 1155413, from.NetState);
                        }
                        else if (.1 > Utility.RandomDouble())
                        {
                            trap.Detonate(from);
                        }
                    }
                }
                else if (targeted is GoblinFloorTrap)
                {
                    GoblinFloorTrap targ = (GoblinFloorTrap)targeted;

                    if (from.InRange(targ.Location, 3))
                    {
                        from.Direction = from.GetDirectionTo(targ);

                        if (targ.Owner == null)
                        {
                            Item item = new FloorTrapComponent();

                            if (from.Backpack == null || !from.Backpack.TryDropItem(from, item, false))
                            {
                                item.MoveToWorld(from.Location, from.Map);
                            }
                        }

                        targ.Delete();
                        from.SendLocalizedMessage(502377); // You successfully render the trap harmless
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502373); // That does'nt appear to be trapped
                }
            }
Beispiel #8
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);
            }

            var context = EnemyOfOneSpell.GetContext(source);

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

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

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

            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 (target.Murderer || (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) || (source is PlayerMobile && CheckPetAggressor((PlayerMobile)source, target)))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target) || (source is PlayerMobile && CheckPetAggressed((PlayerMobile)source, 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);
        }
Beispiel #9
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);
            }
        }
Beispiel #10
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)));
        }