Example #1
0
        private void Make(Mobile from, int amount, Type type)
        {
            End();

            if (from.Deleted || !from.Alive)
            {
                return;
            }

            if (from.Backpack == null || !m_Shafts.IsChildOf(from) || !m_Feathers.IsChildOf(from))
            {
                from.SendAsciiMessage("Those resources do not belong to you.");
                return;
            }

            int resCost = amount;

            if (from.CheckSkill(SkillName.Fletching, -10.0, 50.0))
            {
                Item item = null;
                try
                {
                    ConstructorInfo ctor = type.GetConstructor(ctorTypes);
                    if (ctor != null)
                    {
                        ctorArgs[0] = amount;
                        item        = ctor.Invoke(ctorArgs) as Item;
                    }
                }
                catch
                {
                }

                if (item != null)
                {
                    from.AddToBackpack(item);
                    from.SendAsciiMessage("You create the item{0} and place {1} in your pack.", amount > 1 ? "s" : "", amount > 1 ? "them" : "it");
                }
                else
                {
                    from.SendAsciiMessage("Unable to create that.");
                    resCost = 0;
                }
            }
            else
            {
                from.SendAsciiMessage("You failed to create the item{0}.", amount > 1 ? "s" : "");
                resCost = (int)(amount * (100.0 - from.Skills[SkillName.Fletching].Value) / 100.0);
                if (resCost < amount * 0.05)
                {
                    resCost = (int)(amount * 0.05);
                }
                if (resCost < 1)
                {
                    resCost = 1;
                }
            }

            m_Shafts.Amount   -= resCost;
            m_Feathers.Amount -= resCost;

            if (m_Shafts.Amount <= 0)
            {
                m_Shafts.Delete();
            }
            if (m_Feathers.Amount <= 0)
            {
                m_Feathers.Delete();
            }
        }