public override void OnTrigger(Mobile from)
        {
            if (!IsEnemy(from))
            {
                return;
            }

            Conceal();

            DoVisibleEffect();
            Effects.PlaySound(this.Location, this.Map, this.EffectSound);
            DoAttackEffect(from);

            int silverToAward = (from.Alive ? 20 : 40);

            if (silverToAward > 0 && m_Placer != null && m_Faction != null)
            {
                PlayerState victimState = PlayerState.Find(from);

                if (victimState != null && victimState.CanGiveSilverTo(m_Placer) && victimState.KillPoints > 0)
                {
                    int silverGiven = m_Faction.AwardSilver(m_Placer, silverToAward);

                    if (silverGiven > 0)
                    {
                        // TODO: Get real message
                        if (from.Alive)
                        {
                            m_Placer.SendMessage("You have earned {0} silver pieces because {1} fell for your trap.", silverGiven, from.Name);
                        }
                        else
                        {
                            m_Placer.SendLocalizedMessage(1042736, String.Format("{0} silver\t{1}", silverGiven, from.Name)); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
                        }
                    }

                    victimState.OnGivenSilverTo(m_Placer);
                }
            }

            from.LocalOverheadMessage(MessageType.Regular, MessageHue, AttackMessage);
        }
Esempio n. 2
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;
                        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
                }
            }
Esempio n. 3
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
                }
            }
            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);

                    double minskill = targ.TrapPower;
                    //modify minskill with detect hidden skill
                    if (from.Skills[SkillName.DetectHidden].Base > 50.0)
                    {
                        minskill -= (from.Skills[SkillName.DetectHidden].Base - 50.0);
                    }
                    double maxskill = minskill + 50;

                    //What this means is that with a trappower of 125 (level 5 tmap) and
                    //GM DH, min RT skill to unlock is 75 and max is 100, OR, rather,
                    //DH and RT need to be above a combined 175 to have a chance at disarming
                    //the trap.
                    //Level 4 power (100), they need to have above 150 total to have a chance.

                    if (from.AccessLevel >= AccessLevel.GameMaster)                        //This line added by Old Salty
                    {
                        from.SendMessage(string.Format("minskill is {0}, maxskill is {1}", minskill, maxskill));
                    }

                    if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, minskill, maxskill))
                    {
                        targ.TrapPower = 0;
                        targ.TrapLevel = 0;
                        targ.TrapType  = TrapType.None;
                        from.SendLocalizedMessage(502377);                         // You successfully render the trap harmless
                    }
                    else
                    {
                        //chance to set off trap...
                        if (targ.OnFailDisarm(from))
                        {
                        }
                        else
                        {
                            from.SendLocalizedMessage(502372);                             // You fail to disarm the trap... but you don't set it off
                        }
                    }

                    //pla: set 10 second delay before next skill use
                    from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(10.0);
                }
                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 (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
                {
                    from.SendLocalizedMessage(502373);                     // That does'nt appear to be trapped
                }
            }
Esempio n. 5
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);

                    int nTrapLevel = targ.TrapLevel * 10;

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

                    if ((int)(from.Skills[SkillName.RemoveTrap].Value) < nTrapLevel)
                    {
                        from.SendMessage("This trap looks too complicated for you.");
                        return;
                    }

                    from.PlaySound(0x241);

                    // if ( from.CheckTargetSkill( SkillName.RemoveTrap, targ, targ.TrapPower, targ.TrapPower + 30 ) )
                    nTrapLevel = nTrapLevel + 20;
                    if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, 0, nTrapLevel))
                    {
                        targ.TrapPower = 0;
                        targ.TrapLevel = 0;
                        targ.TrapType  = TrapType.None;
                        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, 125.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 Item)
                {
                    if ((Item)targeted is HiddenTrap)
                    {
                        from.PlaySound(0x241);

                        if (from.CheckSkill(SkillName.RemoveTrap, 0, 125))
                        {
                            Item HideTrap = (Item)targeted;
                            HideTrap.Delete();
                            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
                    {
                        from.SendLocalizedMessage(502373);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502373);                       // That does'nt appear to be trapped
                }
            }
Esempio n. 6
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)
                {
                    if (from.Skills[SkillName.Lockpicking].Value < 50)
                    {
                        from.SendLocalizedMessage(502366);                           // You do not know enough about locks.  Become better at picking locks.
                        return;
                    }
                    else if (from.Skills[SkillName.DetectHidden].Value < 50)
                    {
                        from.SendLocalizedMessage(502367);                           // You are not perceptive enough.  Become better at detect hidden.
                        return;
                    }

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

                    int minskill;
                    int maxskill;
                    LockableContainer lc = targ as LockableContainer;
                    if (lc != null && (targ.TrapType == TrapType.ExplosionTrap || targ.TrapType == TrapType.PoisonTrap))
                    {
                        // values used for tinkertraps
                        maxskill = targ.TrapPower;
                        minskill = (int)(targ.TrapPower * 0.8);
                    }
                    else                     // original values
                    {
                        maxskill = targ.TrapPower + 30;
                        minskill = targ.TrapPower;
                    }

                    if (from.CheckTargetSkill(SkillName.RemoveTrap, targ, minskill, maxskill))
                    {
                        targ.TrapPower = 0;
                        targ.TrapLevel = 0;
                        targ.TrapType  = TrapType.None;
                        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 commander = trap.Faction != null && trap.Faction.IsCommander(from);

                    bool isOwner = (trap.Placer == from || commander);


                    if (!commander && from.Skills[SkillName.Lockpicking].Value < 50)
                    {
                        from.SendLocalizedMessage(502366);                           // You do not know enough about locks.  Become better at picking locks.
                    }
                    else if (!commander && from.Skills[SkillName.DetectHidden].Value < 50)
                    {
                        from.SendLocalizedMessage(502367);                           // You are not perceptive enough.  Become better at detect hidden.
                    }
                    else 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 (trap.Faction != null && 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 (from.CheckTargetSkill(SkillName.RemoveTrap, trap, 80.0, 100.0) || commander)
                        {
                            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
                {
                    from.SendLocalizedMessage(502373);                       // That doesn't appear to be trapped
                }
            }
Esempio n. 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 TrappableContainer targ)
                {
                    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))
                    {
                        targ.TrapPower = 0;
                        targ.TrapLevel = 0;
                        targ.TrapType  = TrapType.None;
                        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 trap)
                {
                    Faction faction           = Faction.Find(from);
                    FactionTrapRemovalKit kit = from.Backpack?.FindItemByType <FactionTrapRemovalKit>();

                    bool isOwner = trap.Placer == from || trap.Faction?.IsCommander(from) == true;

                    if (faction == null)
                    {
                        from.SendLocalizedMessage(
                            1010538); // You may not disarm faction traps unless you are in an opposing faction
                    }
                    else if (trap.Faction != null && faction == trap.Faction && !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.ConsumeCharge(from);
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502373); // That doesn't appear to be trapped
                }
            }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is BaseCreature)
                {
                    BaseCreature creature = (BaseCreature)targeted;

                    if (from.CheckTargetSkill(SkillName.RemoveTrap, creature, 30, 100))
                    {
                        if (creature is Turret)
                        {
                            creature.Kill();
                            from.SendMessage("You have disarmed the trap.");
                        }
                        else
                        {
                            from.SendLocalizedMessage(502816);                               // You feel that such an action would be inappropriate
                        }
                    }
                }
                else if (targeted is BoulderTrap)
                {
                    BoulderTrap bouldertrap = (BoulderTrap)targeted;

                    if (from.Skills.RemoveTrap.Base >= 75.0)
                    {
                        bouldertrap.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                    }
                    else if (from.CheckTargetSkill(SkillName.RemoveTrap, bouldertrap, 50, 85))
                    {
                        bouldertrap.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                        from.Skills.RemoveTrap.Base += 1;
                    }
                    else
                    {
                        from.SendMessage("You fail to disarm the trap.");
                    }
                }
                else if (targeted is BoulderTrap2)
                {
                    BoulderTrap2 bouldertrap2 = (BoulderTrap2)targeted;

                    if (from.Skills.RemoveTrap.Base >= 75.0)
                    {
                        bouldertrap2.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                    }
                    else if (from.CheckTargetSkill(SkillName.RemoveTrap, bouldertrap2, 50, 85))
                    {
                        bouldertrap2.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                        from.Skills.RemoveTrap.Base += 1;
                    }
                    else
                    {
                        from.SendMessage("You fail to disarm the trap.");
                    }
                }
                else if (targeted is MovingTrap)
                {
                    MovingTrap movingtrap = (MovingTrap)targeted;

                    if (from.Skills.RemoveTrap.Base >= 30.0)
                    {
                        movingtrap.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                    }
                    else if (from.CheckTargetSkill(SkillName.RemoveTrap, movingtrap, 0, 30))
                    {
                        movingtrap.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                        from.Skills.RemoveTrap.Base += 1;
                    }
                    else
                    {
                        from.SendMessage("You fail to disarm the trap.");
                    }
                }
                else if (targeted is MovingTrap2)
                {
                    MovingTrap2 movingtrap2 = (MovingTrap2)targeted;

                    if (from.Skills.RemoveTrap.Base >= 30.0)
                    {
                        movingtrap2.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                    }

                    else if (from.CheckTargetSkill(SkillName.RemoveTrap, movingtrap2, 0, 30))
                    {
                        movingtrap2.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                        from.Skills.RemoveTrap.Base += 1;
                    }
                    else
                    {
                        from.SendMessage("You fail to disarm the trap.");
                    }
                }
                else if (targeted is MovingTreeTrap)
                {
                    MovingTreeTrap movingtreetrap = (MovingTreeTrap)targeted;

                    if (from.Skills.RemoveTrap.Base >= 30.0)
                    {
                        movingtreetrap.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                    }
                    else if (from.CheckTargetSkill(SkillName.RemoveTrap, movingtreetrap, 15, 50))
                    {
                        movingtreetrap.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                        from.Skills.RemoveTrap.Base += 1;
                    }
                    else
                    {
                        from.SendMessage("You fail to disarm the trap.");
                    }
                }
                else if (targeted is MovingTreeTrap2)
                {
                    MovingTreeTrap2 movingtreetrap2 = (MovingTreeTrap2)targeted;

                    if (from.Skills.RemoveTrap.Base >= 30.0)
                    {
                        movingtreetrap2.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                    }

                    else if (from.CheckTargetSkill(SkillName.RemoveTrap, movingtreetrap2, 15, 50))
                    {
                        movingtreetrap2.Delete();
                        from.PlaySound(0x5CE);
                        from.SendMessage("You have disarmed the trap.");
                        from.Skills.RemoveTrap.Base += 1;
                    }
                    else
                    {
                        from.SendMessage("You fail to disarm the trap.");
                    }
                }

                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))
                    {
                        targ.TrapPower = 0;
                        targ.TrapLevel = 0;
                        targ.TrapType  = TrapType.None;
                        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
                {
                    from.SendLocalizedMessage(502373);                       // That does'nt appear to be trapped
                }
            }