Quantcast WoWInterface - View Single Post - Faction from GetPlayerInfoByGUID()
View Single Post
12-02-12, 02:50 PM   #20
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
I left it as a global so I could test it directly in-game, if you're going to use it then it should probably be localized.

I should mention that the reason I had it cache the results wasn't for faster lookups but because sometimes OnTooltipSetUnit would fire more than once and I didn't want it calling the function again.

I actually have to make a slight edit because unit GUIDs on the PTR (which was where I was testing this) are not the same as they are on live, which I didn't realize when I posted it. It's just the check that the GUID belongs to a player-type unit, which isn't strictly necessary anyway.

Using debugprofilestop and scanning a handful of units it takes anywhere between 0.1 and 0.3 milliseconds for the first lookup. For reference, 60 fps is one frame every ~16 milliseconds, so I don't think it'll be too much of a problem.

I did notice one caveat while scanning for players in the combat log to test it: if they're sufficiently higher level than you the tooltip doesn't say what faction they are, just their name and "Level ?? Race Class (Player)". I don't know how much this matters because as long as it doesn't match your faction string it's probably not your faction.

An alternative might be to compare the :GetTextColor of the first line of the tooltip (the name) since it appears to be colored based on reaction.

edit: I don't think it actually does change the color of the text unless it has a unit id or something, so that won't work.

Last edited by semlar : 12-02-12 at 03:44 PM.
  Reply With Quote