Beispiel #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Addon == null || !m_Addon.Deleted)
            {
                return;
            }

            Mobile m     = sender.Mobile;
            int    index = info.ButtonID;

            switch (index)
            {
            case 0: { m_Addon.Using = false; break; }

            case 1:
            {
                RepairBenchDefinition tool = m_Addon.Tools.Find(x => x.Skill == m_Skill);

                tool.SkillValue = 0;
                tool.Charges    = 0;

                m.SendLocalizedMessage(1158873, String.Format("#{0}", tool.Cliloc));         // You clear all the ~1_SKILL~ charges from the bench.

                m.SendGump(new RepairBenchGump(m, m_Addon));
                break;
            }
            }
        }
Beispiel #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Addon == null || m_Addon.Deleted)
                {
                    return;
                }

                if (!m_Addon.CheckAccessible(from, m_Addon))
                {
                    m_Addon.Using = false;
                    m_Addon.AccessibleFailMessage(from);
                    return;
                }

                if (targeted is RepairDeed)
                {
                    RepairDeed deed = (RepairDeed)targeted;

                    if (m_Addon.Tools.Any(x => x.Skill == deed.RepairSkill && x.Charges >= 500))
                    {
                        from.SendLocalizedMessage(1158778); // This would exceed the maximum charges allowed on this magic item.
                        from.Target = new InternalTarget(from, m_Gump, m_Addon);
                    }
                    else if (m_Addon.Tools.Any(x => x.Skill == deed.RepairSkill && x.Charges != 0 && x.SkillValue != deed.SkillLevel))
                    {
                        from.SendLocalizedMessage(1158866); // The repair bench contains deeds that do not match the skill of the deed you are trying to add.
                        from.Target = new InternalTarget(from, m_Gump, m_Addon);
                    }
                    else
                    {
                        RepairBenchDefinition tool = m_Addon.Tools.Find(x => x.Skill == deed.RepairSkill);

                        tool.SkillValue = deed.SkillLevel;
                        tool.Charges++;

                        deed.Delete();

                        from.Target = new InternalTarget(from, m_Gump, m_Addon);
                    }
                }
                else if (targeted is Container)
                {
                    Container c = targeted as Container;

                    for (int i = c.Items.Count - 1; i >= 0; --i)
                    {
                        if (i < c.Items.Count && c.Items[i] is RepairDeed)
                        {
                            RepairDeed deed = (RepairDeed)c.Items[i];

                            if (m_Addon.Tools.Any(x => x.Skill == deed.RepairSkill && x.Charges >= 500))
                            {
                                from.SendLocalizedMessage(1158778); // This would exceed the maximum charges allowed on this magic item.
                            }
                            else if (m_Addon.Tools.Any(x => x.Skill == deed.RepairSkill && x.SkillValue == deed.SkillLevel))
                            {
                                RepairBenchDefinition tool = m_Addon.Tools.Find(x => x.Skill == deed.RepairSkill);

                                tool.SkillValue = deed.SkillLevel;
                                tool.Charges++;

                                deed.Delete();
                            }
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1158865); // That is not a valid repair contract or container.
                }

                m_Gump.StopTimer(from);
                from.CloseGump(typeof(RepairBenchGump));
                from.SendGump(new RepairBenchGump(from, m_Addon));
            }