Inheritance: CraftSystem
Exemple #1
0
        public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
        {
            if (tool == null || tool.Deleted || tool.UsesRemaining < 0)
            {
                return(1044038);                // You have worn out your tool!
            }
            else if (!BaseTool.CheckTool(tool, from))
            {
                return(1048146);                // If you have a tool equipped, you must use that tool.
            }
            else if (!BaseTool.CheckAccessible(tool, from))
            {
                return(1044263);                // The tool must be on your person to use.
            }
            bool anvil, forge;

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

            if (anvil && forge)
            {
                return(0);
            }

            return(1044267);            // You must be near an anvil and a forge to smith items.
        }
        public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
        {
            if (tool == null || tool.Deleted || tool.UsesRemaining < 0)
            {
                return(1044038);                // You have worn out your tool!
            }
            else if (!BaseTool.CheckTool(tool, from))
            {
                return(1048146);                // If you have a tool equipped, you must use that tool.
            }
            else if (!(from is PlayerMobile && ((PlayerMobile)from).Glassblowing && from.Skills[SkillName.Alchemy].Base >= 100.0))
            {
                return(1044634);                // You havent learned glassblowing.
            }
            else if (!BaseTool.CheckAccessible(tool, from))
            {
                return(1044263);                // The tool must be on your person to use.
            }
            bool anvil, forge;

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

            if (forge)
            {
                return(0);
            }

            return(1044628);            // You must be near a forge to blow glass.
        }
        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.
        }
Exemple #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int num = m_CraftSystem.CanCraft(from, m_Tool, null);

                if (num > 0)
                {
                    if (num == 1044267)
                    {
                        bool anvil, forge;

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

                        if (!anvil)
                        {
                            num = 1044266;                             // You must be near an anvil
                        }
                        else if (!forge)
                        {
                            num = 1044265;                             // You must be near a forge.
                        }
                    }

                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, num));
                }
                else
                {
                    SmeltResult result        = SmeltResult.Invalid;
                    bool        isStoreBought = false;
                    int         message;

                    if (targeted is BaseArmor)
                    {
                        result        = Resmelt(from, (BaseArmor)targeted, ((BaseArmor)targeted).Resource);
                        isStoreBought = !((BaseArmor)targeted).PlayerConstructed;
                    }
                    else if (targeted is BaseWeapon)
                    {
                        result        = Resmelt(from, (BaseWeapon)targeted, ((BaseWeapon)targeted).Resource);
                        isStoreBought = !((BaseWeapon)targeted).PlayerConstructed;
                    }
                    else if (targeted is DragonBardingDeed)
                    {
                        result        = Resmelt(from, (DragonBardingDeed)targeted, ((DragonBardingDeed)targeted).Resource);
                        isStoreBought = false;
                    }

                    switch (result)
                    {
                    default:
                    case SmeltResult.Invalid: message = 1044272; break;                             // You can't melt that down into ingots.

                    case SmeltResult.NoSkill: message = 1044269; break;                             // You have no idea how to work this metal.

                    case SmeltResult.Success: message = isStoreBought ? 500418 : 1044270; break;    // You melt the item down into ingots.
                    }

                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
                }
            }
Exemple #5
0
 public static void Initialize()
 {
     m_CraftSystem = new DefBlacksmithy();
 }
Exemple #6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem is DefBlacksmithy)
                {
                    bool anvil, forge;
                    DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);

                    if (anvil && forge)
                    {
                        // You must be near a forge and and anvil to repair items.
                        number = 1044282;
                    }
                }

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426;                         // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423;                         // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153;                             // You don't have the required skills to attempt this item.
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789;                             // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number = 1044279;                                     // You repair the item.

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);

                                    if (m_Contract != null)
                                    {
                                        m_Contract.Delete();
                                    }
                                }
                                else
                                {
                                    number = 1044037;                                     // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037;                                 // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else 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 (m_Tool == null)
                        {
                            skillLevel = m_SkillLevel;
                        }

                        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))
                    {
                        if (m_Contract != null)
                        {
                            // You cannot repair that item with this type of repair contract.
                            number = 1061136;
                        }
                        else
                        {
                            // You cannot repair that using this type of tool.
                            number = 1061139;
                        }
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHits <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.Hits, weapon.MaxHits))
                        {
                            weapon.MaxHits -= toWeaken;
                            weapon.Hits     = Math.Max(0, weapon.Hits - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.Hits, weapon.MaxHits))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.Hits = weapon.MaxHits;

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                weapon.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name);
                            }
                        }
                        else
                        {
                            if (m_Contract != null)
                            {
                                // You fail to repair the item and the repair contract is destroyed.
                                number = 1061137;
                            }
                            else
                            {
                                // You fail to repair the item.
                                number = 1044280;
                            }

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        if (m_Contract != null)
                        {
                            m_Contract.Delete();
                        }
                    }
                }
                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 (m_Tool == null)
                        {
                            skillLevel = m_SkillLevel;
                        }

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

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        if (m_Contract != null)
                        {
                            // You cannot repair that item with this type of repair contract.
                            number = 1061136;
                        }
                        else
                        {
                            // You cannot repair that using this type of tool.
                            number = 1061139;
                        }
                    }
                    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;

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                armor.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name);
                            }
                        }
                        else
                        {
                            if (m_Contract != null)
                            {
                                // You fail to repair the item and the repair contract is destroyed.
                                number = 1061137;
                            }
                            else
                            {
                                // You fail to repair the item.
                                number = 1044280;
                            }

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        if (m_Contract != null)
                        {
                            m_Contract.Delete();
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044283;                     // You cannot repair that.

                    SkillName skill = m_CraftSystem.MainSkill;

                    double value = from.Skills[skill].Value;

                    if (targeted is BlankScroll)
                    {
                        Item contract = null;

                        if (value < 50.0)
                        {
                            // You must be at least apprentice level to create a repair service contract.
                            number = 1047005;
                        }
                        else
                        {
                            if (skill == SkillName.Blacksmith)
                            {
                                contract = new RepairContract(ContractType.Blacksmith, value, from.Name);
                            }
                            else if (skill == SkillName.Carpentry)
                            {
                                contract = new RepairContract(ContractType.Carpenter, value, from.Name);
                            }
                            else if (skill == SkillName.Fletching)
                            {
                                contract = new RepairContract(ContractType.Fletcher, value, from.Name);
                            }
                            else if (skill == SkillName.Tailoring)
                            {
                                contract = new RepairContract(ContractType.Tailor, value, from.Name);
                            }
                            else if (skill == SkillName.Tinkering)
                            {
                                contract = new RepairContract(ContractType.Tinker, value, from.Name);
                            }
                        }

                        if (contract != null)
                        {
                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                contract.Cheater_Name = String.Format("This item crafted by GM {0}", from.Name);
                            }

                            from.AddToBackpack(contract);

                            number = 1044154;                             // You create the item.

                            BlankScroll scroll = targeted as BlankScroll;

                            if (scroll.Amount >= 2)
                            {
                                scroll.Amount -= 1;
                            }
                            else
                            {
                                scroll.Delete();
                            }
                        }
                    }
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                if (m_Tool != null)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);

                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);
                }
            }
		public static void Initialize()
		{
			m_CraftSystem = new DefBlacksmithy();
		}