Thread Tools Display Modes
03-21-11, 04:35 AM   #1
daylesan
A Fallenroot Satyr
Join Date: Feb 2011
Posts: 22
Get raid target icon from destGUID

I want to check if a unit (identified through the destGUID parameter) from a COMBAT_LOG_EVENT_UNFILTERED event has been marked with a raid marker.

Is there a better/simpler way of doing it than this?
1) upon receiving the combat log event, go through all unitID's and check if they are raid marked
2) if a raid marked unitID has been found, get its unitGUID
3) compare the destGUID from the combat log event with the unitGUID from step 2. If they match, destGUID is raid marked.
  Reply With Quote
03-21-11, 05:18 AM   #2
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
As there is no api call for IsRaidMarked, I don't think there is a easier way =(
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
03-21-11, 06:46 AM   #3
oomp
A Murloc Raider
 
oomp's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 7
Don't use destGUID, use destFlags...

Lua Code:
  1. local function GetIconIndex(flags)
  2.     local number, mask, mark
  3.     if bit.band(flags, COMBATLOG_OBJECT_SPECIAL_MASK) ~= 0 then
  4.         for i=1,8 do
  5.             mask = COMBATLOG_OBJECT_RAIDTARGET1 * (2 ^ (i - 1))
  6.             mark = bit.band(flags, mask) == mask
  7.             if mark then number = i break end
  8.         end
  9.     end
  10.     return number
  11. end

This will return a number from 1 to 8 corresponding to each mark, or nil if the target doesn't have a mark, see here for more information. However, if you are intent on using destGUID, I suppose you could do the following, assuming the unit you are checking is a player with a valid unitId:

Lua Code:
  1. local function GetRaidTargetIndexFromGUID(guid)
  2.     local name = select(6, GetPlayerInfoByGUID(guid)) -- Get the unit's name; works globally
  3.     local icon = GetRaidTargetIndex(name) -- Returns a number from 1 to 8, or nil
  4.     return icon
  5. end

Last edited by oomp : 03-22-11 at 08:15 AM.
  Reply With Quote
03-21-11, 09:12 AM   #4
daylesan
A Fallenroot Satyr
Join Date: Feb 2011
Posts: 22
Originally Posted by oomp View Post
Don't use destGUID, use destFlags...

Lua Code:
  1. local function GetIconIndex(flags)
  2.     local number, mask, mark
  3.     if bit.band(flag, COMBATLOG_OBJECT_SPECIAL_MASK) ~= 0 then
  4.         for i=1,8 do
  5.             mask = COMBATLOG_OBJECT_RAIDTARGET1 * (2 ^ (i - 1))
  6.             mark = bit.band(flags, mask) == mask
  7.             if mark then number = i break end
  8.         end
  9.     end
  10.     return number
  11. end

This will return a number from 1 to 8 corresponding to each mark, or nil if the target doesn't have a mark, see here for more information. However, if you are intent on using destGUID, I suppose you could do the following, assuming the unit you are checking is a player with a valid unitId:
Thank you, that looks a lot cleaner than what I had in mind.
  Reply With Quote
03-21-11, 11:32 AM   #5
daylesan
A Fallenroot Satyr
Join Date: Feb 2011
Posts: 22
There's a small error: bit.band(flag, COMBATLOG_OBJECT_SPECIAL_MASK) should be bit.band(flags, COMBATLOG_OBJECT_SPECIAL_MASK)

Even after fixing that, the function always returns nil though. Here's the code for review

Lua Code:
  1. function ezInterrupt:COMBAT_LOG_EVENT_UNFILTERED(_,_,event,sourceGUID,_,_,_,destName,destFlags,spellID,_,_,extraID, ...)
  2.     if event == "SPELL_INTERRUPT" and (sourceGUID == UnitGUID("player") or sourceGUID == UnitGUID("pet")) then
  3.         local raidIconIndex = self:GetRaidIconIndex(destFlags)
  4.         print(tostring(raidIconIndex))
  5. -- cut off the rest of the code

and

Lua Code:
  1. function ezInterrupt:GetRaidIconIndex(flags)
  2.     local number, mask, mark
  3.     if bit.band(flags, COMBATLOG_OBJECT_SPECIAL_MASK) ~= 0 then
  4.         for i=1,8 do
  5.             mask = COMBATLOG_OBJECT_RAIDTARGET1 * (2 ^ (i - 1))
  6.             mark = bit.band(flags, mask) == mask
  7.             if mark then number = i break end
  8.         end
  9.     end
  10.     return number
  11. end
  Reply With Quote
03-21-11, 03:04 PM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Combat log processing has the potential to be executed very frequently so I would suggest changing what you've posted to:
Code:
local bit_and = bit.band

local RaidIconMaskToIndex = {
	[COMBATLOG_OBJECT_RAIDTARGET1] = 1,
	[COMBATLOG_OBJECT_RAIDTARGET2] = 2,
	[COMBATLOG_OBJECT_RAIDTARGET3] = 3,
	[COMBATLOG_OBJECT_RAIDTARGET4] = 4,
	[COMBATLOG_OBJECT_RAIDTARGET5] = 5,
	[COMBATLOG_OBJECT_RAIDTARGET6] = 6,
	[COMBATLOG_OBJECT_RAIDTARGET7] = 7,
	[COMBATLOG_OBJECT_RAIDTARGET8] = 8
}

function ezInterrupt:COMBAT_LOG_EVENT_UNFILTERED(_, _, event, sourceGUID, _, sourceFlags, _, destName, destFlags, spellID, _, _, extraID, ...)
	if event == "SPELL_INTERRUPT" and bit_and(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) then
		local raidIconIndex = RaidIconMaskToIndex[bit_and(destFlags, COMBATLOG_OBJECT_RAIDTARGET_MASK)]
		print(tostring(raidIconIndex))
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get raid target icon from destGUID


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