SetCommodity() public méthode

public SetCommodity ( Item item ) : bool
item Item
Résultat bool
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028;                     // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    Item targetedItem = (Item)targeted;
                    if (targetedItem.Association > 0)
                    {
                        from.SendLocalizedMessage(1047027);  // That is not a commodity the bankers will fill a commodity deed with.
                        return;
                    }
                    BankBox          box = from.FindBankNoCreate();
                    CommodityDeedBox cox = CommodityDeedBox.Find(m_Deed);

                    // Veteran Rewards mods
                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box) ||
                        cox != null && cox.IsSecure && ((Item)targeted).IsChildOf(cox))
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            m_Deed.Hue = 0x47;
                            number     = 1047030;                         // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027;                             // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        if (m_Deed.EraML)
                        {
                            number = 1080526;                             // That must be in your bank box or commodity deed box to use it.
                        }
                        else
                        {
                            number = 1047026;                             // That must be in your bank box to use it.
                        }
                    }
                }
                else
                {
                    number = 1047027;                     // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Exemple #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028; // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    BankBox          box  = from.FindBankNoCreate();
                    CommodityDeedBox cox  = CommodityDeedBox.Find(m_Deed);
                    GalleonHold      hold = ((Item)targeted).RootParent as GalleonHold;

                    // Veteran Rewards mods
                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box) ||
                        (cox != null && cox.IsSecure && ((Item)targeted).IsChildOf(cox)) ||
                        hold != null)
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            number = 1047030; // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        if (Core.ML)
                        {
                            number = 1080526; // That must be in your bank box or commodity deed box to use it.
                        }
                        else
                        {
                            number = 1047026; // That must be in your bank box to use it.
                        }
                    }
                }
                else
                {
                    number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Exemple #3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028;                     // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    BankBox box = from.FindBankNoCreate();

                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box))
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            m_Deed.Hue = 0x592;
                            number     = 1047030;                         // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027;                             // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        if (Core.ML)
                        {
                            number = 1080526;                             // That must be in your bank box or commodity deed box to use it.
                        }
                        else
                        {
                            number = 1047026;                             // That must be in your bank box to use it.
                        }
                    }
                }
                else
                {
                    number = 1047027;                     // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Exemple #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028;                     // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    Container box = m_Deed.Parent as Container;

                    if (box == null || ((Item)targeted).Parent != box)
                    {
                        number = 1080526;                         // That must be in your bank box or commodity deed box to use it.
                    }
                    else
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            number = 1047030;                             // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027;                             // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                }
                else
                {
                    number = 1047027;                     // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Exemple #5
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                string number;

                if (m_Deed.Commodity != null)
                {
                    number = "The commodity deed has already been filled.";
                }
                else if (targeted is Item)
                {
                    BankBox box = from.BankBox;

                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box))
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            number = "The commodity deed has been filled.";
                        }
                        else
                        {
                            number = "That is not a commodity the bankers will fill a commodity deed with.";
                        }
                    }
                    else
                    {
                        number = "That must be in your bank box to use it.";
                    }
                }
                else
                {
                    number = "That is not a commodity the bankers will fill a commodity deed with.";
                }

                from.SendAsciiMessage(number);
            }
        private bool GiveItems(Mobile from, Type type, int amt, StorageEntry entry)
        {
            int amount = amt;

            while (amount > 60000)
            {
                CommodityDeed deed = new CommodityDeed();
                Item item = Loot.Construct(type);
                item.Amount = 60000;
                deed.SetCommodity(item);
                amount -= 60000;

                if (from.Backpack == null || !from.Backpack.TryDropItem(from, deed, false))
                {
                    deed.Delete();
                    return false;
                }
                else
                    entry.RemoveCommodity(type, 60000);
            }

            CommodityDeed deed2 = new CommodityDeed();
            Item item2 = Loot.Construct(type);
            item2.Amount = amount;
            deed2.SetCommodity(item2);

            if (from.Backpack == null || !from.Backpack.TryDropItem(from, deed2, false))
            {
                deed2.Delete();
                return false;
            }
            else
                entry.RemoveCommodity(type, amount);

            return true;
        }
Exemple #7
0
		private void TakeCommodities(Container c, Type type, ref int amount)
		{
            if (c == null)
                return;

			Item[] items = c.FindItemsByType(typeof(CommodityDeed));
			List<Item> toSell = new List<Item>();
			
			foreach(Item item in items)
			{
                CommodityDeed commodityDeed = item as CommodityDeed;

                if (commodityDeed != null && commodityDeed.Commodity != null && commodityDeed.Commodity.GetType() == type)
				{
					Item commodity = commodityDeed.Commodity;

                    if (commodity.Amount <= amount)
					{
						toSell.Add(item);
                        amount -= commodity.Amount;
					}
					else
					{
						CommodityDeed newDeed = new CommodityDeed();
						Item newItem = Loot.Construct(type);
						newItem.Amount = amount;
						newDeed.SetCommodity(newItem);
						
						commodity.Amount -= amount;
						commodityDeed.InvalidateProperties();
						toSell.Add(newDeed);
						amount = 0;
					}
				}
			}
			
			foreach(Item item in toSell)
			{
				AddInventory(null, item);
			}
		}
Exemple #8
0
		public void WithdrawInventory(Mobile from, int amount, CommodityBrokerEntry entry)
		{
			if(from == null || Plot == null || entry == null || !m_CommodityEntries.Contains(entry))
				return;
				
			Container pack = from.Backpack;
			
			if(pack != null)
			{
				while(amount > 60000)
				{
					CommodityDeed deed = new CommodityDeed();
					Item item = Loot.Construct(entry.CommodityType);
					item.Amount = 60000;
					deed.SetCommodity(item);
					pack.DropItem(deed);
					amount -= 60000;
					entry.Stock -= 60000;
				}
				
				CommodityDeed deed2 = new CommodityDeed();
				Item newitem = Loot.Construct(entry.CommodityType);
                newitem.Amount = amount;
                deed2.SetCommodity(newitem);
				pack.DropItem(deed2);
				entry.Stock -= amount;
			}
			
			if(Plot != null && from == Plot.Owner)
				from.SendLocalizedMessage(1150221, String.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName != null ? Plot.ShopName : "a shop with no name")); // You have removed ~1_QUANTITY~ units of ~2_ITEMNAME~ from the inventory of "~3_SHOPNAME~"
		}
Exemple #9
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028;                     // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    BankBox box          = from.FindBankNoCreate();
                    string  XferResource = "...";
                    int     XferAmount   = 0;
                    int     r            = 0;

                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box))
                    {
                        // RESOURCE EDIT
                        if (targeted is BaseIngot) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseIngot youringots = (BaseIngot)targeted;
                            string    s_resource = Convert.ToString(youringots.Resource);
                            XferAmount = youringots.Amount;
                            switch (s_resource)
                            {
                            case "Iron": r = 1; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "DullCopper": r = 2; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "ShadowIron": r = 3; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Copper": r = 4; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Bronze": r = 5; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Gold": r = 6; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Silver": r = 7; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Agapite": r = 8; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Verite": r = 9; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Valorite": r = 10; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Jade": r = 11; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Moonstone": r = 12; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;

                            case "Sunstone": r = 13; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                //case "": r = 13; box.DropItem(new YaksCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                            }
                        }
                        else if (targeted is BaseLeather) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseLeather youritem   = (BaseLeather)targeted;
                            string      s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                            case "RegularLeather": r = 101; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "SpinedLeather": r = 102; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "HornedLeather": r = 103; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "BarbedLeather": r = 104; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "DaemonLeather": r = 105; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "DragonLeather": r = 106; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                            }
                        }
                        else if (targeted is BaseScales) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseScales youritem   = (BaseScales)targeted;
                            string     s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                            case "RedScales": r = 201; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "YellowScales": r = 202; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "BlackScales": r = 203; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "GreenScales": r = 204; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "WhiteScales": r = 205; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "BlueScales": r = 206; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                //case "IceScales": r = 207; box.DropItem(new YaksCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                            }
                        }
                        else if (targeted is BaseLog)// || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseLog youritem   = (BaseLog)targeted;
                            string  s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                            case "Regular": r = 301; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Oak": r = 302; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Ash": r = 303; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Yew": r = 304; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Heartwood": r = 305; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Bloodwood": r = 306; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Frostwood": r = 307; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Pine": r = 308; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Cedar": r = 309; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Cherry": r = 310; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Mahogany": r = 311; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                            }
                        }
                        else if (targeted is BaseBoards)// || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseBoards youritem   = (BaseBoards)targeted;
                            string     s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                            case "Regular": r = 401; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Oak": r = 402; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Ash": r = 03; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Yew": r = 404; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Heartwood": r = 405; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Bloodwood": r = 406; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Frostwood": r = 407; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Pine": r = 408; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Cedar": r = 409; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Cherry": r = 410; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            case "Mahogany": r = 411; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                            }
                        }
                        else
                        {
                            if (m_Deed.SetCommodity((Item)targeted))
                            {
                                number = 1047030; // The commodity deed has been filled.
                            }
                            else
                            {
                                number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                            }
                        }
                    }
                    else
                    {
                        number = 1047026;                         // That must be in your bank box to use it.
                    }
                }
                else
                {
                    number = 1047027;                     // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }