コード例 #1
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack) || Parent == from)
            {
                bool anvil, forge;
                DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);

                if (anvil && forge)
                {
                    BaseTool m_Tool = new SmithHammer();
                    string   IsFrom = "Main";
                    from.SendMenu(new BlacksmithMenu(from, BlacksmithMenu.Main(from), IsFrom, m_Tool));

                    if (m_Tool != null)
                    {
                        m_Tool.Delete();
                    }
                }
                else
                {
                    from.SendAsciiMessage("You must be near an anvil and a forge to smith items.");
                }
            }
            else
            {
                from.SendAsciiMessage("That must be in your pack for you to use it.");
            }
        }
コード例 #2
0
ファイル: DefGlassblowing.cs プロジェクト: AsYlum-/ModernUO
    public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
    {
        if (tool?.Deleted != false || tool.UsesRemaining < 0)
        {
            return(1044038); // You have worn out your tool!
        }

        if (!BaseTool.CheckTool(tool, from))
        {
            return(1048146); // If you have a tool equipped, you must use that tool.
        }

        if (!(from is PlayerMobile mobile && mobile.Glassblowing && mobile.Skills.Alchemy.Base >= 100.0))
        {
            return(1044634); // You havent learned glassblowing.
        }

        if (!BaseTool.CheckAccessible(tool, from))
        {
            return(1044263); // The tool must be on your person to use.
        }

        DefBlacksmithy.CheckAnvilAndForge(from, 2, out _, out var forge);

        return(forge ? 0 : 1044628); // You must be near a forge to blow glass.
    }
コード例 #3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.FindItemOnLayer(Layer.OneHanded) is SmithHammer)
            {
                bool hasForge, hasAnvil;
                DefBlacksmithy.CheckAnvilAndForge(from, 4, out hasAnvil, out hasForge);

                if (hasForge && hasAnvil)
                {
                    CraftSubRes subRes = CustomCraftMenu.GetSubRes(DefBlacksmithy.CraftSystem, GetType(), null);
                    int         num    = CraftResources.GetIndex(m_Resource);

                    if (subRes == null || !CustomCraftMenu.ResourceInfoList.ContainsKey(subRes))
                    {
                        from.SendAsciiMessage("You can't use that.");
                        return;
                    }

                    if (from.Skills[DefBlacksmithy.CraftSystem.MainSkill].Base < subRes.RequiredSkill)
                    {
                        from.SendAsciiMessage("You cannot work this strange and unusual metal.");
                        return;
                    }

                    from.SendGump(new CraftGump(from, DefBlacksmithy.CraftSystem, (BaseTool)from.FindItemOnLayer(Layer.OneHanded), null, num));
                }
                else
                {
                    from.SendAsciiMessage("You need to be close to a forge and anvil.");
                }
            }
            else
            {
                from.SendAsciiMessage("You need to equip a smith's hammer.");
            }

            base.OnDoubleClick(from);
        }
コード例 #4
0
        private void SalvageIngots(Mobile from)
        {
            Item[] tools = from.Backpack.FindItemsByType(typeof(BaseTool));

            bool ToolFound = false;

            foreach (Item tool in tools)
            {
                if (tool is BaseTool && ((BaseTool)tool).CraftSystem == DefBlacksmithy.CraftSystem)
                {
                    ToolFound = true;
                }
            }

            if (!ToolFound)
            {
                from.SendLocalizedMessage(1079822);   // You need a blacksmithing tool in order to salvage ingots.
                return;
            }

            bool anvil, forge;

            DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);

            if (!forge)
            {
                from.SendLocalizedMessage(1044265);   // You must be near a forge.
                return;
            }

            int salvaged    = 0;
            int notSalvaged = 0;

            Container sBag = this;

            List <Item> Smeltables = sBag.FindItemsByType <Item>();

            for (int i = Smeltables.Count - 1; i >= 0; i--)
            {
                Item item = Smeltables[i];

                if (item is BaseArmor)
                {
                    if (Resmelt(from, item, ((BaseArmor)item).Resource))
                    {
                        salvaged++;
                    }
                    else
                    {
                        notSalvaged++;
                    }
                }
                else if (item is BaseWeapon)
                {
                    if (Resmelt(from, item, ((BaseWeapon)item).Resource))
                    {
                        salvaged++;
                    }
                    else
                    {
                        notSalvaged++;
                    }
                }
                else if (item is DragonBardingDeed)
                {
                    if (Resmelt(from, item, ((DragonBardingDeed)item).Resource))
                    {
                        salvaged++;
                    }

                    else
                    {
                        notSalvaged++;
                    }
                }
            }
            if (m_Failure)
            {
                from.SendLocalizedMessage(1079975);                   // You failed to smelt some metal for lack of skill.
                m_Failure = false;
            }
            else
            {
                from.SendLocalizedMessage(1079973, String.Format("{0}\t{1}", salvaged, salvaged + notSalvaged));                     // Salvaged: ~1_COUNT~/~2_NUM~ blacksmithed items
            }
        }
コード例 #5
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            bool hasForge, hasAnvil;

            DefBlacksmithy.CheckAnvilAndForge(from, 4, out hasAnvil, out hasForge);

            if (targeted is BaseIngot && m_Tool is BaseTool)
            {
                if (hasAnvil && hasForge)
                {
                    BaseTool    tool   = (BaseTool)m_Tool;
                    BaseIngot   ingot  = (BaseIngot)targeted;
                    CraftSubRes subRes = CustomCraftMenu.GetSubRes(DefBlacksmithy.CraftSystem, targeted.GetType(), null);
                    int         num    = CraftResources.GetIndex(ingot.Resource);

                    if (subRes == null || !CustomCraftMenu.ResourceInfoList.ContainsKey(subRes))
                    {
                        from.SendAsciiMessage("You can't use that.");
                        return;
                    }

                    if (from.Skills[DefBlacksmithy.CraftSystem.MainSkill].Base < subRes.RequiredSkill)
                    {
                        from.SendAsciiMessage("You cannot work this strange and unusual metal.");
                        return;
                    }

                    from.SendGump(new CraftGump(from, m_CraftSystem, tool, null, num));
                    //from.SendMenu( new CustomCraftMenu( from, DefBlacksmithy.CraftSystem, ( (BaseTool)m_Tool ), -1, targeted.GetType(), CustomCraftMenu.ResourceInfoList[subRes].ResourceIndex ) );
                }
                else
                {
                    from.SendAsciiMessage("You need to be close to a forge and anvil to smith.");
                }
            }
            else if (targeted is BaseIngot && !(m_Tool is BaseTool))
            {
                from.SendAsciiMessage("You need to use a smith's hammer on that.");
            }
            else
            {
                if (!hasAnvil)
                {
                    from.SendAsciiMessage("You need to be close to an anvil to repair.");
                    return;
                }

                int number;

                if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1044277;
                    }
                    // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;
                    }
                    // That item has been repaired many times, and will break if repairs are attempted again.
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;
                            // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }
                from.SendAsciiMessage(CliLoc.LocToString(number));
            }
        }
コード例 #6
0
ファイル: SalvageBag.cs プロジェクト: nogu3ira/xrunuo
        public void SalvageIngots(Mobile from)
        {
            bool hasTool = false;

            foreach (Item item in from.Backpack.Items)
            {
                if (item is BaseTool && ((BaseTool)item).CraftSystem == DefBlacksmithy.CraftSystem)
                {
                    hasTool = true;
                    break;
                }
            }

            if (!hasTool)
            {
                from.SendLocalizedMessage(1079822);                   // You need a blacksmithing tool in order to salvage ingots.
                return;
            }

            bool anvil, forge;

            DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);

            if (!anvil)
            {
                from.SendLocalizedMessage(1044266);                   // You must be near an anvil
                return;
            }

            if (!forge)
            {
                from.SendLocalizedMessage(1044265);                   // You must be near a forge
                return;
            }

            int count    = 0;
            int oldCount = this.TotalItems;

            int message = -1;

            for (int i = 0; i < this.Items.Count; i++)
            {
                Item item = (Item)this.Items[i];

                bool success       = false;
                bool isStoreBought = false;
                bool lackMining    = false;

                Resmelt.Process(DefBlacksmithy.CraftSystem, from, item, false, out success, out isStoreBought, out lackMining);

                if (lackMining)
                {
                    message = 1079975;                     // You failed to smelt some metal for lack of skill.
                }
                else if (success)
                {
                    count++;
                    i--;
                }
            }

            if (message != -1)
            {
                from.SendLocalizedMessage(message);
            }

            if (count > 0)
            {
                from.PlaySound(0x2A);
                from.PlaySound(0x240);
            }

            from.SendLocalizedMessage(1079973, String.Format("{0}\t{1}", count, oldCount));                 // Salvaged: ~1_COUNT~/~2_NUM~ blacksmithed items
        }