Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
 static VT_eDamageElement Curtain_FMonsterList_QueryFinalDamageType(int monsterid)
 {
     //VTank is running.
     uTank2.LootPlugins.GameItemInfo mon = uTank2.PluginCore.PC.FWorldTracker_GetWithID(monsterid);
     if (mon == null)
     {
         return(VT_eDamageElement.None);
     }
     return((VT_eDamageElement)(int)uTank2.PluginCore.PC.FMonsterList_QueryFinalDamageType(mon));
 }
Esempio n. 3
0
        void Think()
        {
            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);
                    }
                }

                idsRequested = true;
            }

            if (CoreManager.Current.Actions.BusyState != 0)
            {
                return;
            }

            if (DoAutoStack())
            {
                return;
            }

            if (DoAutoPack())
            {
                return;
            }

            // If we've gotten to this point no items were moved.
            Stop();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }