Exemplo n.º 1
0
        public override void StartTeleport(Mobile m)
        {
            Item RewardItem = null;

            switch (Utility.Random(4))
            {
            case 1:
            {
                RewardItem        = new WyrmsHeart();
                RewardItem.Amount = 50;
                break;
            }

            case 2:
            {
                RewardItem = new Seed(); break;
            }

            case 3:
            {
                RewardItem          = new GoldenSkull();
                RewardItem.Hue      = 0x793;
                RewardItem.Name     = "Skull of Iniquity";
                RewardItem.LootType = LootType.Regular;

                break;
            }

            default:
            {
                Item Reward = new Log();
                Reward.Amount = 750;
                RewardItem    = new CommodityDeed(Reward);
                break;
            }
            }

            m.AddToBackpack(RewardItem);
            DoTeleport(m);
        }
Exemplo n.º 2
0
        public override void StartTeleport(Mobile m)
        {
            Item RewardItem = null;

            switch (Utility.Random(4))
            {
                case 1:
                    {
                        RewardItem = new WyrmsHeart();
                        RewardItem.Amount = 50;
                        break;
                    }
                case 2:
                    {
                        RewardItem = new Seed(); break;
                    }
                case 3:
                    {
                        RewardItem = new GoldenSkull();
                        RewardItem.Hue = 0x793;
                        RewardItem.Name = "Skull of Iniquity";
                        RewardItem.LootType = LootType.Regular;

                        break;
                    }
                default:
                    {
                        Item Reward = new Log();
                        Reward.Amount = 750;
                        RewardItem = new CommodityDeed(Reward);
                        break;
                    }
            }

            m.AddToBackpack(RewardItem);
            DoTeleport(m);
        }
Exemplo n.º 3
0
			public InternalTarget( CommodityDeed deed ) : base( 3, false, TargetFlags.None )
			{
				m_Deed = deed;
			}
Exemplo n.º 4
0
 public InternalTarget(CommodityDeed deed) : base(3, false, TargetFlags.None)
 {
     m_Deed = deed;
 }
Exemplo n.º 5
0
		public override Item Withdraw( ref int amount, bool makedeed )
		{
			Item resource = base.Withdraw( ref amount, false );
			
			if( resource != null )
			{	
				//if they want you to make a deed and it's a valid deed item
				if( makedeed && ( resource is ICommodity ) && resource.Stackable )
				{
					CommodityDeed deed = new CommodityDeed( resource );
					return deed;
					
				}
				
				return resource;
			}
			return null;
		}
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 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);
			}
		}
Exemplo n.º 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~"
		}
Exemplo n.º 9
0
		private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
		{
			if (amount > bii.Amount)
				amount = bii.Amount;

			if (amount < 1)
				return;

			if (ResourcePool.IsPooledResource(bii.Type) && ResourcePool.GetTotalCount(bii.Type) > 0)
			{
				ResourcePool.SellOff(bii.Type, amount, this.Serial, buyer);
			}
			else
			{
				bii.Amount -= amount;
			}

			object o = bii.GetObject();

			if (o is Item)
			{
				Item item = (Item)o;

				// all weapons and armor are exceptional during server wars
				if (Server.Misc.TestCenter.Enabled == true)
				{
					if (item is BaseArmor)
					{
						(item as BaseArmor).Quality = ArmorQuality.Exceptional;
						(item as BaseArmor).Durability = ArmorDurabilityLevel.Fortified;
						(item as BaseArmor).Identified = true;
					}
					if (item is BaseWeapon)
					{
						(item as BaseWeapon).Quality = WeaponQuality.Exceptional;
						(item as BaseWeapon).DurabilityLevel = WeaponDurabilityLevel.Fortified;
						(item as BaseWeapon).Identified = true;
					}
				}

				if (item.Stackable)
				{
					item.Amount = amount;

					if (ResourcePool.IsPooledResource(item.GetType()) && item.Amount >= 100)
						item = new CommodityDeed(item);

					if (cont == null || !cont.TryDropItem(buyer, item, false))
						item.MoveToWorld(buyer.Location, buyer.Map);
				}
				else
				{
					item.Amount = 1;

					if (cont == null || !cont.TryDropItem(buyer, item, false))
						item.MoveToWorld(buyer.Location, buyer.Map);

					for (int i = 1; i < amount; i++)
					{
						item = bii.GetObject() as Item;

						if (item != null)
						{
							item.Amount = 1;

							if (cont == null || !cont.TryDropItem(buyer, item, false))
								item.MoveToWorld(buyer.Location, buyer.Map);
						}
					}
				}
			}
			else if (o is Mobile)
			{
				Mobile m = (Mobile)o;

				m.Direction = (Direction)Utility.Random(8);
				m.MoveToWorld(buyer.Location, buyer.Map);
				m.PlaySound(m.GetIdleSound());

				if (m is BaseCreature)
					((BaseCreature)m).SetControlMaster(buyer);

				for (int i = 1; i < amount; ++i)
				{
					m = bii.GetObject() as Mobile;

					if (m != null)
					{
						m.Direction = (Direction)Utility.Random(8);
						m.MoveToWorld(buyer.Location, buyer.Map);

						if (m is BaseCreature)
							((BaseCreature)m).SetControlMaster(buyer);
					}
				}
			}
		}
 public SellInfo(CommodityDeed deed, Mobile mobile, ExchangeTypeInfo info)
     : base(mobile, info,deed.Commodity.Amount)
 {
     deed.Delete();
 }
Exemplo n.º 11
0
		// Attempt to encode a commodity deed with new data

		public static bool RCDEncode( CommodityDeed cd, string sData )
		{
			ClassNameTranslator cnt = new ClassNameTranslator();

			// Make sure there isn't already a resource attached to the deed			

			if( cd.CommodityAmount > 0 )
			{
				RCDLogger.Log(LogType.Text,  
					string.Format("{0}:{1}:{2}:{3}:{4}", 
					cd.Serial.ToString(),
					cnt.TranslateClass(cd.Type),
					cd.CommodityAmount.ToString(),
					cd.Location,
					"ALREADY FILLED") );	

				RCDCaller.SendMessage( "Warning! Filled deed detected... see logfile!" );

				return false;			
			}

			// Perform the replacement
           		
			int iStartIDX = sData.IndexOf("\"");
			int iEndIDX = sData.IndexOf("\"", iStartIDX + 1);
								                                                                
			string sType = sData.Substring((iStartIDX + 1), (iEndIDX - iStartIDX - 1));

			Type tType = ScriptCompiler.FindTypeByName( sType );

			if ( tType == null )
			{
				// Invalid

				RCDLogger.Log(LogType.Text,  
					string.Format("{0}:{1}:{2}:{3}:{4}", 
					cd.Serial.ToString(),
					sType,
					"",
					cd.Location,
					"INVALID") );								
				
				RCDCaller.SendMessage( "Warning! Invalid type detected... see logfile!" );
				return false;
			}

			// Next work out the quantity of the data we're going to map to the deed
								
			iStartIDX = sData.IndexOf(",", iEndIDX) + 1;
			iEndIDX = sData.Length;
                                
			string sQuantity = sData.Substring(iStartIDX , (iEndIDX - iStartIDX));
			int iQuantity;

			try
			{
				iQuantity =  Convert.ToInt32(sQuantity);
			}
			catch (Exception e)
			{
				Console.WriteLine( "RemapCommDeeds: Exception - (trying to convert {0} to an integer)", sQuantity);

				RCDLogger.Log(LogType.Text,  
					string.Format("{0}:{1}:{2}:{3}:{4}", 
					cd.Serial.ToString(),
					cd.Type.ToString(),
					sQuantity,
					cd.Location,
					"INVALID") );								

				RCDCaller.SendMessage( "Warning! Invalid quantity detected (non numeric)... see logfile!" );
				return false; 
			}

			// All good, encode it...

			cd.Type = tType;
			cd.CommodityAmount = iQuantity;
			cd.Description = string.Format("{0} {1}", iQuantity, cnt.TranslateClass( tType ));
                                																								                               								
			RCDLogger.Log(LogType.Text,  
				string.Format("{0}:{1}:{2}:{3}:{4}", 
				cd.Serial.ToString(),
				sType,
				iQuantity,
				cd.Location,
				"PATCHED") );								

			return true;
		}