What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

PurchasePanel.CurrentTabItems

Dgc2002

Member
Joined
Jan 15, 2010
Messages
197
Reaction score
0
First: I might just make a thread called "Help Dgc" rather than spam this subforum so much

On topic:

I'm messing around with some other parts of the API and wanted to make a little bot that would run around to all the vendors looking for chromatics/5 links/6 links/6 sockets. For some reason I'm getting weird results with PurchasePanel.CurrentTabItems. Here is roughly the code I'm using:

Code:
        private int tickCount = 0;
        private int loopCount = 0;
        public void Tick()
        {                
            tickCount++;
                if (LokiPoe.InGameState.IsPurchaseWindowOpen && tickCount > loopCount * 200)
                {
                    foreach (var tab in LokiPoe.InGameState.PurchasePanel.Tabs)
                    {
                        LokiPoe.InGameState.PurchasePanel.SwitchToTab(tab);
                        Log.Debug("TickCount: " + tickCount + ", LoopCount: " + loopCount);
                        Log.Debug("Item Count for panel " + tab + ": " + LokiPoe.InGameState.PurchasePanel.CurrentTabItems.Count);
                        foreach (var tabItem in LokiPoe.InGameState.PurchasePanel.CurrentTabItems)
                        {
                            Log.Debug("--------New Item--------");
                            Log.Debug("Name: " + tabItem.Item.Name);
                            Log.Debug("Socket Count: " + tabItem.Item.SocketCount);
                            Log.Debug("Max Link Count: " + tabItem.Item.MaxLinkCount);
                            Log.Debug("Is Chromatic: " + tabItem.Item.IsChromatic);
                        }
                    }
                    loopCount++;
                }
        }

I'm having it loop through ever so often to try to eliminate the possibility of having an empty list due to checking too soon. My output is usually:
Code:
Item Count for panel -2-: 0
TickCount: 1, LoopCount: 0
[ClearAllKeyStates]
Item Count for panel -1-: 0
TickCount: 1, LoopCount: 0
[ClearAllKeyStates]
Item Count for panel -3-: 0
Once in a while it will pick up on one or two items without much obvious consistency. I've tried several NPCs with no pattern there either.

edit:
Just tried this with my stash:

Code:
                if (LokiPoe.InGameState.IsStashPanelOpen && tickCount > loopCount * 200)
                {
                    //foreach (var tab in LokiPoe.InGameState.StashPanel.Tabs)
                    //{
                        LokiPoe.InGameState.StashPanel.SwitchToTab(LokiPoe.InGameState.StashPanel.CurrentTab.ToString());
                        Log.Debug("TickCount: " + tickCount + ", LoopCount: " + loopCount);
                        Log.Debug("Item Count for panel " + LokiPoe.InGameState.StashPanel.CurrentTab + ": " + LokiPoe.InGameState.StashPanel.CurrentTabItems.Count);                       
                        foreach (var tabItem in LokiPoe.InGameState.StashPanel.CurrentTabItems)
                        {
                            Log.Debug("--------New Item--------");
                            Log.Debug("Name: " + tabItem.Name);
                            Log.Debug("Socket Count: " + tabItem.SocketCount);
                            Log.Debug("Max Link Count: " + tabItem.MaxLinkCount);
                            Log.Debug("Is Chromatic: " + tabItem.IsChromatic);
                        }
                    //}
                    loopCount++;
                }

and that worked fine. So my code isn't completely botched.
 
Last edited:
The PurchasePanel requires something extra to be done that the other panels don't.

PurchasePanel.UpdateCurrentTabItems must be called after you switch the tab (SwitchToTab), because the API has to mouse over all items in order to know how much it costs (since the only way to get that info is from the tooltip, or calculating it yourself).

Once UpdateCurrentTabItems is called (you'll see the function working as it does), the items for sale will be available in the API itself, along with the price (VendorItem.Cost, a list of name/quantity entries), as well as if you can currently afford it based on the client knowing you have currency in a loaded stash tab.

Make sure to handle return codes for the functions, and one thing to keep in mind is that after you buy something, you need to keep track of how many times you are trying to buy, since the client does have some refresh issues with thinking you can still afford something that you cannot. Luckily, the client behavior has been updated to not allow you to pickup an item to the cursor virtually if you can't afford it, but that's just more logic you'd have to deal with if you don't fast move to buy.
 
Back
Top