Thread Tools Display Modes
07-19-09, 09:08 AM   #1
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
Battleground Instances

I was wondering if there is anyway to grab the current open instances for a BG?

For example, when you open up the PvP window and goto the Battlegrounds tab and say you choose WSG. There's First Available, then all the current WSG's in progress.

So say there's WSG 1, 2, 4, 5 currently going, is there anyway to grab this info?

I did some looking around in the API and couldn't find anything.

Thanks.
  Reply With Quote
07-19-09, 12:04 PM   #2
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Originally Posted by Subere View Post
I was wondering if there is anyway to grab the current open instances for a BG?

For example, when you open up the PvP window and goto the Battlegrounds tab and say you choose WSG. There's First Available, then all the current WSG's in progress.

So say there's WSG 1, 2, 4, 5 currently going, is there anyway to grab this info?

I did some looking around in the API and couldn't find anything.

Thanks.
http://wowprogramming.com/docs/api/G...ldInstanceInfo

That returns info for the selected battleground. You can find out which one is selected by using

http://wowprogramming.com/docs/api/G...tedBattlefield

If you want to automate this, you can choose which battleground is selected by calling :Click() on BattlegroundTypeN, where N is a number between 1 (Alterac Valley) and 5 (Strand of the Ancients).
  Reply With Quote
07-19-09, 11:25 PM   #3
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
Thanks a bunch. Not sure how I missed those :s
  Reply With Quote
07-20-09, 09:12 AM   #4
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
Another things that's popped up:

I'm still new to LUA and the WoW API, is there a better way of selecting the BG to que for besides BattlegroundTypeN:Click() that's more dynamic?

Or is there a way to do something like:

Code:
id = 2
BattlegroundType..id:Click()
Thanks again.
  Reply With Quote
07-20-09, 09:22 AM   #5
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Code:
id = 2
 _G['BattlegroundType'..id]:Click()
You're basically fetching the button by name out of the global table.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
07-20-09, 11:16 AM   #6
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
So I have a slash command that calls a function (say test()) and for some reason I have to type it twice for it to queue. Do you know why this is and what I have to do for it work on the first go?

Code:
function test(bgID)
    _G['BattlegroundType'..bgID]:Click()
    JoinBattlefield(0)
end
  Reply With Quote
07-20-09, 11:42 AM   #7
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Now a more lenghty explanation of whats probably going on:

Digging a bit in Blizz' Code showed me that executing the BattlegroundTypeN:Click() basically leads to the function RequestBattlegroundInstanceInfo(N).

The RequestX-functions basically require data gathered from the server, so it's not available instantly. So, at the moment of JoinBattlefield() it's still not acquired.

A moment later, after you've typed it for the second type, the data becomes available, so JoinBattlefield() works properly.

To circumvent it:
You have to call JoinBattlefield() after the instance-data is received from the server. Maybe there's an event for it - you could try registering UPDATE_BATTLEFIELD_STATUS and then updating at that time.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
07-20-09, 12:20 PM   #8
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
I found:

http://wowprogramming.com/docs/api/R...ndInstanceInfo

It says the event PVPQUEUE_ANYWHERE_SHOW fires when the data is ready.

I got it working now somewhat. There's that event and another one that seems to be related (PVPQUEUE_ANYWHERE_UPDATE_AVAILABLE) but neither are documented on WoWwiki or wowprogramming and neither seem to be returning anything.

Now this is where my current problem is. The UPDATE_BATTLEFIELD_STATUS returns the queue id so I can use that with GetBattlefieldStatus to check the status if I'm queued and what not, but with nothing being returned from the 2 PVPQUEUE_ANYWHERE events I'm not sure how to check what's triggering it.

For example, if I reload ui, it triggers that event, even if I'm not currently queued for a bg.
  Reply With Quote
07-20-09, 12:54 PM   #9
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
It's a bit hackish, but you could set a local variable to the id you're requesting info for. For example:

Code:
local requestID
function test(bgID)
    requestID = bgID
    _G['BattlegroundType'..bgID]:Click()
end
And then in the event-function:
Code:
function event()
    if(requestID) then
         -- do some stuff with requestID
         requestID = nil
    end
end
Blizz seems to handle this in a similiar way, because they store the currently selected ID (after you've clicked on BattlegroundTypeN) in PVPBattlegroundFrame.selectedBG. You could maybe also use that one.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
07-20-09, 01:47 PM   #10
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
Thanks a bunch yet again. Got it working.

I think I'm going to have problems when I try to implement queuing for multiple BGs at the same time.

I really don't understand having an event that returns nil and gets triggered by numerous things that aren't even necessarily related. Bah.
  Reply With Quote
07-20-09, 03:07 PM   #11
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
Acutally I lied :[

One last problem, the Click() isn't triggering the event when I get out of a bg if I queue again.

I think it has something to do with the fact it's calling Click() on the same thing twice because I choose the same BG.

What should I do to fix this?
  Reply With Quote
07-20-09, 03:23 PM   #12
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
I think, it's probably a good idea to paste your current code, so that other people and myself can check if something's wrong there

Other than that, it could well be that the BattlegroundTypeN-button doesn't request the server for more data, because it checks if the battleground-ID is the same as before.

I would suggest trying to replace the BattlegroundTypeN-clicking with a call to RequestBattlegroundInstanceInfo(bgID) directly - notice however that this circumvents anything that had to do with the actual clicking, so variables like PVPBattlegroundFrame.selectedBG don't become updated.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
07-20-09, 03:34 PM   #13
Subere
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 41
Well I'm 99% sure the problem is calling it a second time, it isn't triggering the event again.

It works if I type the command to que for a different bg, just not if I choose the same bg back to back. It also ques when I open the PvP window which does trigger the event and it shows the slash command worked because it reset my test var that I check before quing (I set it to nil after I've queued).

Would replacing the click with RequestBattlegroundInstanceInfo(bgID) work? The problem I was having before and why I used the click was if I didn't, JoinBattlefield(0) would just queue for whatever bg was last selected. I also tried just changing the value of PVPBattlegroundFrame.selectedBG, though I might have done it wrong or gone about it in the wrong way.

EDIT: Works fine now. Dropped the click for:

Code:
PVPBattlegroundFrame.selectedBG = bgID
RequestBattlegroundInstanceInfo(bgID)

Last edited by Subere : 07-21-09 at 02:25 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Battleground Instances


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off