Exemplo n.º 1
0
		/// <summary>
		/// This will return an item to sell in the following Priority: Any Non SpellComponent (Pea)/TradeNote, SpellComponent (Peas), TradeNote
		/// </summary>
		/// <param name="looter"></param>
		/// <returns></returns>
		private WorldObject GetSellItem(VTClassic.LootCore looter)
		{
			Collection<WorldObject> sellObjects = new Collection<WorldObject>();

			foreach (WorldObject playerObj in CoreManager.Current.WorldFilter.GetInventory())
			{
				// Safety check to prevent equipped items from being sold.
				if (playerObj.Values(LongValueKey.EquipableSlots, 0) > 0)
					continue;

				// Convert the vendor item into a VT GameItemInfo object
				uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithID(playerObj.Id);

				if (itemInfo == null)
				{
					Debug.WriteToChat("AutoBuySell.GetSellItem(), itemInfo == null for " + playerObj.Name);
					continue;
				}

				// Get the loot profile result for this object
				// result.IsNoLoot will always be false so we must check the Keep # against items in inventory.
				uTank2.LootPlugins.LootAction result = looter.GetLootDecision(itemInfo);

				if (!result.IsSell)
					continue;

				sellObjects.Add(playerObj);
			}

			if (sellObjects.Count == 0)
				return null;

			foreach (WorldObject sellObject in sellObjects)
			{
				if (sellObject.ObjectClass != ObjectClass.SpellComponent && sellObject.ObjectClass != ObjectClass.TradeNote)
					return sellObject;
			}

			WorldObject cheapest = null;

			foreach (WorldObject sellObject in sellObjects)
			{
				if (sellObject.ObjectClass != ObjectClass.TradeNote)
				{
					if (cheapest == null || cheapest.Values(LongValueKey.Value) > sellObject.Values(LongValueKey.Value))
						cheapest = sellObject;
				}
			}

			if (cheapest != null)
				return cheapest;

			foreach (WorldObject sellObject in sellObjects)
			{
				if (cheapest == null || cheapest.Values(LongValueKey.Value) > sellObject.Values(LongValueKey.Value))
					cheapest = sellObject;
			}

			return cheapest;
		}
Exemplo n.º 2
0
		/// <summary>
		/// This will return an object to buy. Keep # rules are returned first, then Keep rules.
		/// </summary>
		/// <param name="looter"></param>
		/// <param name="openVendor"></param>
		/// <param name="buyAmount"></param>
		/// <returns></returns>
		private WorldObject GetBuyItem(VTClassic.LootCore looter, Vendor openVendor, out int buyAmount)
		{
			// See if we can find a Keep # rule first.
			foreach (WorldObject vendorObj in openVendor)
			{
				// Convert the vendor item into a VT GameItemInfo object
				uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithVendorObjectTemplateID(vendorObj.Id);

				if (itemInfo == null)
				{
					Debug.WriteToChat("AutoBuySell.GetBuyItem(), itemInfo == null for " + vendorObj.Name);
					continue;
				}

				// Get the loot profile result for this object
				// result.IsNoLoot will always be false so we must check the Keep # against items in inventory.
				// The keep # is returned as Data1
				uTank2.LootPlugins.LootAction result = looter.GetLootDecision(itemInfo);

				if (!result.IsKeepUpTo)
					continue;

				// Find out how many of this item we have in our inventory
				int currentAmountInInventory = 0;

				foreach (WorldObject playerObj in CoreManager.Current.WorldFilter.GetInventory())
				{
					if (vendorObj.Name == playerObj.Name)
					{
						if (playerObj.Values(LongValueKey.StackCount) == 0)
							currentAmountInInventory++;
						else
							currentAmountInInventory += playerObj.Values(LongValueKey.StackCount);
					}
				}

				// If we have more than our Keep #, lets continue through the rest of the vendors item
				if (currentAmountInInventory >= result.Data1)
					continue;

				// Ok, we need to buy some of this item, how many should we buy?
				buyAmount = result.Data1 - currentAmountInInventory;

				// We can't add more than 5000 of any one item to the vendor buy pane.
				if (buyAmount > 5000)
					buyAmount = 5000;

				return vendorObj;
			}

			// Ok, we didn't find a Keep # rule, lets search all Keep rules now.
			foreach (WorldObject vendorObj in openVendor)
			{
				// Convert the vendor item into a VT GameItemInfo object
				uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithVendorObjectTemplateID(vendorObj.Id);

				if (itemInfo == null)
				{
					Debug.WriteToChat("AutoBuySell.GetBuyItem(), itemInfo == null for " + vendorObj.Name);
					continue;
				}

				// Get the loot profile result for this object
				// result.IsNoLoot will always be false
				uTank2.LootPlugins.LootAction result = looter.GetLootDecision(itemInfo);

				if (!result.IsKeep)
					continue;

				// Ok, we need to buy some of this item, how many should we buy?
				buyAmount = 5000;

				return vendorObj;
			}

			buyAmount = 0;

			return null;
		}