void uTankCallBack(int obj, uTank2.LootPlugins.LootAction result, bool getsuccess) { try { if (!getsuccess) { return; } for (int i = 0; i < itemsWaitingForCallback.Count; i++) { ItemWaitingForCallback itemWaitingForCallback = itemsWaitingForCallback[i]; if (itemWaitingForCallback.ItemInfoIdentArgs.IdentifiedItem.Id == obj) { itemsWaitingForCallback.RemoveAt(i); itemWaitingForCallback.ItemInfoCallBack(itemWaitingForCallback.ItemInfoIdentArgs, !result.IsNoLoot, result.IsSalvage, result.RuleName); break; } } } catch (Exception ex) { Debug.LogException(ex); } }
public bool GetLootRuleInfoFromItemInfo(ItemInfoIdentArgs itemInfoIdentArgs, ItemInfoCallback itemInfoCallback) { try { if (uTank2.PluginCore.PC.FLootPluginQueryNeedsID(itemInfoIdentArgs.IdentifiedItem.Id)) { // public delegate void delFLootPluginClassifyCallback(int obj, LootAction result, bool getsuccess); //uTank2.PluginCore.delFLootPluginClassifyCallback callback = new uTank2.PluginCore.delFLootPluginClassifyCallback(uTankCallBack); //uTank2.PluginCore.PC.FLootPluginClassifyCallback(itemInfoIdentArgs.IdentifiedItem.Id, callback); ItemWaitingForCallback itemWaitingForCallback = new ItemWaitingForCallback(itemInfoIdentArgs, itemInfoCallback); itemsWaitingForCallback.Add(itemWaitingForCallback); uTank2.PluginCore.PC.FLootPluginClassifyCallback(itemInfoIdentArgs.IdentifiedItem.Id, uTankCallBack); } else { uTank2.LootPlugins.LootAction result = uTank2.PluginCore.PC.FLootPluginClassifyImmediate(itemInfoIdentArgs.IdentifiedItem.Id); itemInfoCallback(itemInfoIdentArgs, !result.IsNoLoot, result.IsSalvage, result.RuleName); } } catch (NullReferenceException) // Virindi tank probably not loaded. { return(false); } return(true); }
private void DoTestMode() { Debug.WriteToChat("Buy Items:"); using (Vendor openVendor = CoreManager.Current.WorldFilter.OpenVendor) { 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.DoTestMode(), 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 = ((VTClassic.LootCore)lootProfile).GetLootDecision(itemInfo); if (result.IsKeepUpTo || result.IsKeep) { Debug.WriteToChat(vendorObj.Name); } } } Debug.WriteToChat("Sell Items:"); foreach (WorldObject playerObj in CoreManager.Current.WorldFilter.GetInventory()) { // Safety check to prevent equipped items from being sold. // Changed from -- if (playerObj.Values(LongValueKey.EquipableSlots, 0) > 0) // Equipable slots is always > 0 for armor. Equipped Slots is only > 0 if equiped if (playerObj.Values(LongValueKey.EquippedSlots, 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.DoTestMode(), 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 = ((VTClassic.LootCore)lootProfile).GetLootDecision(itemInfo); if (result.IsSell) { Debug.WriteToChat("Sell: " + playerObj.Name); } } }
void Think() { bool waitingForIds = false; if (!idsRequested) { foreach (WorldObject item in CoreManager.Current.WorldFilter.GetInventory()) { // If the item is equipped or wielded, don't process it. if (item.Values(LongValueKey.EquippedSlots, 0) > 0 || item.Values(LongValueKey.Slot, -1) == -1) { continue; } // Convert the item into a VT GameItemInfo object uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithID(item.Id); if (itemInfo == null) { // This happens all the time for aetheria that has been converted continue; } if (((VTClassic.LootCore)lootProfile).DoesPotentialItemNeedID(itemInfo)) { CoreManager.Current.Actions.RequestId(item.Id); waitingForIds = true; } } idsRequested = true; } foreach (WorldObject item in CoreManager.Current.WorldFilter.GetInventory()) { // If the item is equipped or wielded, don't process it. if (item.Values(LongValueKey.EquippedSlots, 0) > 0 || item.Values(LongValueKey.Slot, -1) == -1) { continue; } if (itemIdsAdded.Contains(item.Id)) { continue; } // Convert the item into a VT GameItemInfo object uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithID(item.Id); if (itemInfo == null) { // This happens all the time for aetheria that has been converted continue; } if (!((VTClassic.LootCore)lootProfile).DoesPotentialItemNeedID(itemInfo)) { uTank2.LootPlugins.LootAction result = ((VTClassic.LootCore)lootProfile).GetLootDecision(itemInfo); if (!result.IsKeep) { continue; } itemIdsAdded.Add(item.Id); CoreManager.Current.Actions.TradeAdd(item.Id); return; } waitingForIds = true; } if (waitingForIds) { return; } MyClasses.VCS_Connector.SendChatTextCategorized("CommandLine", "<{" + PluginCore.PluginName + "}>: " + "Auto Add To Trade - Inventory scan complete.", 5, Settings.SettingsManager.Misc.OutputTargetWindow.Value); Stop(); }
void Think() { if (CoreManager.Current.Actions.OpenedContainer == 0) { Stop(); return; } // Sometimes it takes a bit before we actually get the item information for the items inside the container if (CoreManager.Current.WorldFilter.GetByContainer(CoreManager.Current.Actions.OpenedContainer).Count == 0) { return; } bool waitingForIds = false; // First we request id's for items that need them if (!idsRequested) { foreach (WorldObject wo in CoreManager.Current.WorldFilter.GetByContainer(CoreManager.Current.Actions.OpenedContainer)) { if (uTank2.PluginCore.PC.FLootPluginQueryNeedsID(wo.Id)) { CoreManager.Current.Actions.RequestId(wo.Id); waitingForIds = true; } } idsRequested = true; } if (CoreManager.Current.Actions.BusyState != 0) { return; } foreach (WorldObject wo in CoreManager.Current.WorldFilter.GetByContainer(CoreManager.Current.Actions.OpenedContainer)) { if (!uTank2.PluginCore.PC.FLootPluginQueryNeedsID(wo.Id)) { // If this is an item on our corpse, loot it if (Settings.SettingsManager.Looting.AutoLootMyCorpses.Value && CoreManager.Current.WorldFilter[CoreManager.Current.Actions.OpenedContainer].Name == "Corpse of " + CoreManager.Current.CharacterFilter.Name) { } else { uTank2.LootPlugins.LootAction result = uTank2.PluginCore.PC.FLootPluginClassifyImmediate(wo.Id); if (result.IsNoLoot) { continue; } if (result.IsSalvage) { if (!Settings.SettingsManager.Looting.LootSalvage.Value) { continue; } } else if (!result.IsKeep && !result.IsKeepUpTo) { continue; } if (blackLitedItems.Contains(wo.Name)) { continue; } // Check the keep # if (result.IsKeepUpTo) { int totalInInventory = 0; foreach (WorldObject inventoryItem in CoreManager.Current.WorldFilter.GetInventory()) { uTank2.LootPlugins.LootAction inventoryItemResult = uTank2.PluginCore.PC.FLootPluginClassifyImmediate(inventoryItem.Id); if (inventoryItemResult.IsKeepUpTo && result.RuleName == inventoryItemResult.RuleName && result.Data1 == inventoryItemResult.Data1 && wo.Name == inventoryItem.Name) { if (inventoryItem.Values(LongValueKey.StackMax, 0) > 0) { totalInInventory += inventoryItem.Values(LongValueKey.StackCount, 1); } else { totalInInventory++; } } } if (totalInInventory >= result.Data1) { continue; } } } if (currentWorkingId != wo.Id) { currentWorkingId = wo.Id; currentWorkingIdFirstAttempt = DateTime.UtcNow; } else { if (DateTime.UtcNow - currentWorkingIdFirstAttempt > TimeSpan.FromSeconds(10)) { Debug.WriteToChat("Blacklisting item: " + wo.Id + ", " + wo.Name); blackLitedItems.Add(wo.Name); continue; } } CoreManager.Current.Actions.MoveItem(wo.Id, CoreManager.Current.CharacterFilter.Id); return; } waitingForIds = true; } if (!waitingForIds) { if (CoreManager.Current.WorldFilter[CoreManager.Current.Actions.OpenedContainer].ObjectClass != ObjectClass.Corpse) { Debug.WriteToChat("No more lootable items found."); } Stop(); } }
bool DoAutoPack() { bool waitingForIds = false; // Get all of our side pack information and put them in the correct order int[] packs = new int[CoreManager.Current.WorldFilter[CoreManager.Current.CharacterFilter.Id].Values(LongValueKey.PackSlots) + 1]; // Main pack packs[0] = CoreManager.Current.CharacterFilter.Id; // Load the side pack information foreach (WorldObject obj in CoreManager.Current.WorldFilter.GetByContainer(CoreManager.Current.CharacterFilter.Id)) { if (obj.ObjectClass != ObjectClass.Container) { continue; } packs[obj.Values(LongValueKey.Slot) + 1] = obj.Id; } // Process our inventory Collection <ItemToProcess> itemsToProcess = new Collection <ItemToProcess>(); foreach (WorldObject item in CoreManager.Current.WorldFilter.GetInventory()) { if (blackLitedItems.Contains(item.Id)) { continue; } // If the item is equipped or wielded, don't process it. if (item.Values(LongValueKey.EquippedSlots, 0) > 0 || item.Values(LongValueKey.Slot, -1) == -1) { continue; } // If the item is a container or a foci, don't process it. if (item.ObjectClass == ObjectClass.Container || item.ObjectClass == ObjectClass.Foci) { continue; } // Convert the item into a VT GameItemInfo object uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithID(item.Id); if (itemInfo == null) { // This happens all the time for aetheria that has been converted continue; } if (((VTClassic.LootCore)lootProfile).DoesPotentialItemNeedID(itemInfo)) { waitingForIds = true; continue; } uTank2.LootPlugins.LootAction result = ((VTClassic.LootCore)lootProfile).GetLootDecision(itemInfo); if (!result.IsKeepUpTo) { continue; } // Separate the Data1 int result into a byte[]. Meaning, turn 123456 into { 1, 2, 3, 4, 5, 6 } char[] packNumbersAsChar = result.Data1.ToString().ToCharArray(); byte[] packNumbers = new byte[packNumbersAsChar.Length]; for (int i = 0; i < packNumbersAsChar.Length; i++) { packNumbers[i] = byte.Parse(packNumbersAsChar[i].ToString()); } // If this item is already in its primary pack, we don't need to queue it up. if (item.Container == packs[packNumbers[0]]) { continue; } int[] targetPackIds = new int[packNumbers.Length]; for (int i = 0; i < packNumbers.Length; i++) { targetPackIds[i] = packs[packNumbers[i]]; } ItemToProcess itemToProcess = new ItemToProcess(item.Id, targetPackIds); itemsToProcess.Add(itemToProcess); } // Lets go through our list and see if any items are in their primary target pack for (int i = itemsToProcess.Count - 1; i >= 0; i--) { ItemToProcess itemToProcess = itemsToProcess[i]; WorldObject item = CoreManager.Current.WorldFilter[itemToProcess.Id]; if (item == null) { itemsToProcess.RemoveAt(i); continue; } if (item.Container == itemToProcess.TargetPackIds[0]) { itemsToProcess.RemoveAt(i); } } Collection <int> itemsToSkip = new Collection <int>(); // Lets see if we can find an item that can be moved to its target pack for (int packIndex = 0; packIndex < 10; packIndex++) { for (int i = itemsToProcess.Count - 1; i >= 0; i--) { ItemToProcess itemToProcess = itemsToProcess[i]; WorldObject item = CoreManager.Current.WorldFilter[itemToProcess.Id]; if (itemToProcess.TargetPackIds.Length <= packIndex) { continue; } if (itemsToSkip.Contains(item.Id)) { continue; } // Check to see if this item is already in the target pack if (item.Container == itemToProcess.TargetPackIds[packIndex]) { itemsToSkip.Add(item.Id); continue; } // Check to see that the target is even a pack. WorldObject target = CoreManager.Current.WorldFilter[itemToProcess.TargetPackIds[packIndex]]; if (target == null || (target.ObjectClass != ObjectClass.Container && target.ObjectClass != ObjectClass.Player)) { continue; } if (Util.GetFreePackSlots(itemToProcess.TargetPackIds[packIndex]) > 0) { if (currentWorkingId != item.Id) { currentWorkingId = item.Id; currentWorkingIdFirstAttempt = DateTime.UtcNow; } else { if (DateTime.UtcNow - currentWorkingIdFirstAttempt > TimeSpan.FromSeconds(10)) { Debug.WriteToChat("Blacklisting item: " + item.Id + ", " + item.Name); blackLitedItems.Add(item.Id); return(true); } } CoreManager.Current.Actions.MoveItem(item.Id, itemToProcess.TargetPackIds[packIndex], 0, true); return(true); } } } if (waitingForIds) { return(true); } return(false); }
/// <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); }
/// <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); }