Quantcast Detecting the Group Position of an Arena Oppenent - WoWInterface
Thread Tools Display Modes
08-22-14, 11:41 AM   #1
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 32
Detecting the Group Position of an Arena Oppenent

Hey, i got the following macro:
/focus [@arena1]
Due to macro space problems i usually have to edit the macro for the case that the enemy healer is arena2 or arena3 (etc.).
What i thought about doing is, writing a script which detects the positon of the healer in the enemy arena team and then edits my macro automatically for me. I am aware that this is only working outside of combat, which is fine, because i just want it to work during the preparation time. Also i dont mind if i have to fire the script manually while waiting in the prep zone.
Because Blizzard already implemented the detection of the enemy specs during the prep phase i thought i could use this to filter the enemy team.
The idea is to listen for the event that fires when information about arena opponents are available. Then use it to get information about enemy specializations. In the end filter the information to get the postion of the healer in the enemy team.
local f=CreateFrame("Frame")
	local numOpps=GetNumArenaOpponentSpecs()
	for i=1,numOpps do		
		local specID=GetArenaOpponentSpec(i)		
		local _,spec,_,_,_,role,_=GetSpecializationInfoByID(specID)			
		if specID>0 and role="HEALER" then	
			--/run index=GetMacroIndexByName("name"); print(i) use this to get macroIndex 
			EditMarco(index,nil,nil,"/focus [@arena"..i.."]",1,1)			
Links to the functions/events i used in my code:

Last edited by Sylen : 08-22-14 at 11:42 AM. Reason: Changed thread title to state the topic more clearly
  Reply With Quote
08-22-14, 02:19 PM   #2
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,616
A few problems with your code that should be raising errors in-game:
  • You misspelled "EditMacro" as "EditMarco".
  • You're referring to a variable "index" which you don't define anywhere.

Other than that you're definitely on the right track. I'd suggest checking for InCombatLockdown() before proceeding with anything else in the event handler, just in case. I'd also use some nice variables at the top to contain the desired macro name and template, so it's easier to customize them, eg.

local MACRO_NAME = "FocusHealer"
local MACRO_BODY = "/focus [@arena%d]"
Then in your event handler you can pass the desired text as "string.format(MACRO_BODY, i)". You can also just pass the macro name to EditMacro instead of an index; I'd suggest doing that for the sake of simplicity and avoiding an extra function call.

Finally, go get BugSack. The default error display, even if you have it enabled, is simply not good enough for addon development, as it is incapable of showing errors that occur early in the loading sequence -- and that's where most of your errors will occur during development. Being able to see the error messages your code is raising is invaluable, as the message will tell you exactly what the problem is, and exactly where in your code it is.
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » Detecting the Group Position of an Arena Oppenent

Thread Tools
Display Modes

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