Exemplo n.º 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.");
            }
        }
Exemplo n.º 2
0
    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.
    }
Exemplo n.º 3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!Movable)
            {
                return;
            }

            if (RootParent is BaseCreature)
            {
                from.SendLocalizedMessage(500447); // That is not accessible
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendLocalizedMessage(501976); // The ore is too far away.
                return;
            }

            if (!DefBlacksmithy.CheckForge(from, 1))
            {
                from.SendFailureMessage("You must be near a forge to smelt ore!");
                return;
            }

            var oreType = GetType();

            var oreEntry = ZhConfig.Resources.Ores.Entries.Single(e => e.ResourceType == oreType);

            var difficulty = oreEntry.SmeltSkillRequired;

            if (!from.ShilCheckSkill(SkillName.Mining, (int)difficulty, 0))
            {
                Consume(1);
                from.SendFailureMessage("You destroy some ore.");
                return;
            }

            var ingot = GetIngot();

            ingot.Amount = Amount;
            from.PlaySound(0x2B);
            from.AddToBackpack(ingot);
            from.SendSuccessMessage($"You create {Amount} ingots and place them in your pack.");
            Delete();
            return;
        }
Exemplo n.º 4
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!Movable)
            {
                return;
            }

            if (RootParent is BaseCreature)
            {
                from.SendLocalizedMessage(500447); // That is not accessible
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendLocalizedMessage(1060178); // You are too far away to perform that action!
                return;
            }

            if (!DefBlacksmithy.CheckForge(from, 1))
            {
                from.SendFailureMessage("You must be near a forge to smelt sand!");
                return;
            }

            if (!from.ShilCheckSkill(SkillName.Blacksmith, points: 0))
            {
                Consume(1);
                from.SendFailureMessage("You waste some sand.");
                return;
            }

            var glass = new RawGlass(Amount);

            from.PlaySound(0x2B);
            from.AddToBackpack(glass);
            from.SendSuccessMessage($"You create {Amount} raw glass and place it in your pack.");
            Delete();
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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
            }
        }
Exemplo n.º 7
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));
            }
        }
Exemplo n.º 8
0
 public static void Initialize()
 {
     CraftSystem = new DefBlacksmithy();
 }
Exemplo n.º 9
0
        public static SmallSmithBOD CreateRandomFor(Mobile m)
        {
            SmallBulkEntry[] entries;
            bool             useMaterials;

            if (useMaterials = Utility.RandomBool())
            {
                entries = SmallBulkEntry.BlacksmithArmor;
            }
            else
            {
                entries = SmallBulkEntry.BlacksmithWeapons;
            }

            if (entries.Length > 0)
            {
                double theirSkill = m.Skills[SkillName.Blacksmith].Base;
                int    amountMax;

                if (theirSkill >= 70.1)
                {
                    amountMax = Utility.RandomList(10, 15, 20, 20);
                }
                else if (theirSkill >= 50.1)
                {
                    amountMax = Utility.RandomList(10, 15, 15, 20);
                }
                else
                {
                    amountMax = Utility.RandomList(10, 10, 15, 20);
                }

                BulkMaterialType material = BulkMaterialType.None;

                if (useMaterials && theirSkill >= 70.1)
                {
                    for (int i = 0; i < 20; ++i)
                    {
                        BulkMaterialType check    = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
                        double           skillReq = 0.0;

                        switch (check)
                        {
                        case BulkMaterialType.DullCopper: skillReq = 65.0; break;

                        case BulkMaterialType.ShadowIron: skillReq = 70.0; break;

                        case BulkMaterialType.Copper: skillReq = 75.0; break;

                        case BulkMaterialType.Bronze: skillReq = 80.0; break;

                        case BulkMaterialType.Gold: skillReq = 85.0; break;

                        case BulkMaterialType.Agapite: skillReq = 90.0; break;

                        case BulkMaterialType.Verite: skillReq = 95.0; break;

                        case BulkMaterialType.Valorite: skillReq = 100.0; break;

                        case BulkMaterialType.Spined: skillReq = 65.0; break;

                        case BulkMaterialType.Horned: skillReq = 80.0; break;

                        case BulkMaterialType.Barbed: skillReq = 99.0; break;
                        }

                        if (theirSkill >= skillReq)
                        {
                            material = check;
                            break;
                        }
                    }
                }

                double excChance = 0.0;

                if (theirSkill >= 70.1)
                {
                    excChance = (theirSkill + 80.0) / 200.0;
                }

                bool reqExceptional = (excChance > Utility.RandomDouble());

                SmallBulkEntry entry = null;

//				m_CraftSystem = new DefBlacksmithy();
//				m_CraftSystem.CustomSystem( from );
//				CraftSystem system = DefBlacksmithy.CraftSystem;
                CraftSystem system = new DefBlacksmithy();
                system.CustomSystem(m);

                for (int i = 0; i < 150; ++i)
                {
                    SmallBulkEntry check = entries[Utility.Random(entries.Length)];

                    CraftItem item = system.CraftItems.SearchFor(check.Type);

                    if (item != null)
                    {
                        bool   allRequiredSkills = true;
                        double chance            = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);

                        if (allRequiredSkills && chance >= 0.0)
                        {
                            if (reqExceptional)
                            {
                                chance = item.GetExceptionalChance(system, chance, m);
                            }

                            if (chance > 0.0)
                            {
                                entry = check;
                                break;
                            }
                        }
                    }
                }

                if (entry != null)
                {
                    return(new SmallSmithBOD(entry, material, amountMax, reqExceptional));
                }
            }

            return(null);
        }
Exemplo n.º 10
0
        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
        }