Exemplo n.º 1
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 == 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))
                    {
                        switch (targ.TrapType)
                        {
                        case TrapType.ExplosionTrap:
                            from.LocalOverheadMessage(Network.MessageType.Regular, 0x78, 502374);                                       // You carefully remove the trigger for the purple potion.
                            break;

                        case TrapType.DartTrap:
                            from.LocalOverheadMessage(Network.MessageType.Regular, 0x62, 502375);                                       // You carefully remove the dart from the firing mechanism.
                            break;

                        case TrapType.PoisonTrap:
                            from.LocalOverheadMessage(Network.MessageType.Regular, 0x44, 502376);                                       // The poison leaks harmlessly away due to your deft touch.
                            break;

                        default:
                            from.LocalOverheadMessage(Network.MessageType.Regular, 0x53, 502377);                                       // You successfully render the trap harmless
                            break;
                        }

                        targ.TrapEnabled = false;
                        targ.TrapPower   = 0;
                        targ.TrapLevel   = 0;
                        targ.TrapType    = TrapType.None;
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= 0.2)
                        {
                            from.SendLocalizedMessage(502370);                               // Oops.

                            targ.ExecuteTrap(from);
                        }
                        else
                        {
                            from.SendLocalizedMessage(502371);                               // You breathe a sigh of relief, as you fail to disarm the trap, but 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 (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.Client);

                            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 GoblinTrap)
                {
                    GoblinTrap targ = (GoblinTrap)targeted;

                    from.Direction = from.GetDirectionTo(targ);
                    from.PlaySound(0x241);

                    if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, 0.0, 100.0))
                    {
                        from.LocalOverheadMessage(Network.MessageType.Regular, 0x53, 502377);                           // You successfully render the trap harmless
                        GoblinTrapGenerator.DisableTrap(from, targ);
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= 0.2)
                        {
                            from.SendLocalizedMessage(502370);                               // Oops.
                            targ.ExecuteTrap(from);
                        }
                        else
                        {
                            from.SendLocalizedMessage(502371);                               // You breathe a sigh of relief, as you fail to disarm the trap, but don't set it off.
                        }
                    }
                }
                else if (targeted is FloorTrap)
                {
                    FloorTrap targ = (FloorTrap)targeted;

                    from.Direction = from.GetDirectionTo(targ);
                    from.PlaySound(0x241);

                    if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, targ.TinkerLevel, 110.0))
                    {
                        new FloorTrapKit().MoveToWorld(targ.Location, targ.Map);

                        from.LocalOverheadMessage(Network.MessageType.Regular, 0x53, 502377);                           // You successfully render the trap harmless
                        targ.Expire();
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= 0.2)
                        {
                            from.SendLocalizedMessage(502370);                               // Oops.
                            targ.ExecuteTrap(from);
                        }
                        else
                        {
                            targ.FailedRemoveTrapAttempt();
                            from.SendLocalizedMessage(502371);                               // You breathe a sigh of relief, as you fail to disarm the trap, but don't set it off.
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502373);                       // That does'nt appear to be trapped
                }
            }
Exemplo n.º 2
0
        public static void Container_Snoop(Container cont, Mobile from)
        {
            if (from.AccessLevel > AccessLevel.Player || from.InRange(cont.GetWorldLocation(), 1))
            {
                Mobile root = cont.RootParent as Mobile;

                if (root != null && !root.Alive)
                {
                    return;
                }

                if (root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
                {
                    from.SendLocalizedMessage(500209); // You can not peek into the container.
                    return;
                }

                if (root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
                {
                    from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target.
                    return;
                }

                if (root != null && from.AccessLevel == AccessLevel.Player && from.Skills[SkillName.Snooping].Value < Utility.Random(100))
                {
                    Map map = from.Map;

                    if (map != null)
                    {
                        string message = String.Format("You notice {0} attempting to peek into {1}'s belongings.", from.Name, root.Name);

                        IPooledEnumerable eable = map.GetClientsInRange(from.Location, 8);

                        System.Collections.ArrayList list = new System.Collections.ArrayList();

                        foreach (NetState ns in eable)
                        {
                            list.Add(ns);
                        }

                        eable.Free();

                        foreach (NetState ns in list)
                        {
                            if (ns == root.NetState)
                            {
                                root.SendAsciiMessage("You notice {0} attempting to peek into your belongings!", from.Name);
                            }
                            else if (ns != from.NetState)
                            {
                                ns.Mobile.SendAsciiMessage(message);
                            }
                        }
                    }
                }

                // custom change: only lose karma when snooping good guys
                if (from.AccessLevel == AccessLevel.Player && root != null && root.Karma > 0)
                {
                    Titles.AwardKarma(from, -5, true);
                }

                if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0))
                {
                    TrapableContainer tc = cont as TrapableContainer;

                    if (from.AccessLevel == AccessLevel.Player && tc != null && tc.Trapped && tc.TrapType == TrapType.MagicTrap)
                    {
                        tc.ExecuteTrap(from);
                    }
                    cont.DisplayTo(from);
                }
                else
                {
                    from.SendLocalizedMessage(500210); // You failed to peek into the container.
                }
            }
            else
            {
                from.SendLocalizedMessage(500446); // That is too far away.
            }
        }