Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-15-13, 08:58 AM   #1
zbugrkx
A Fallenroot Satyr
Join Date: Jul 2013
Posts: 25
damage meter issue related to Pet OwnerName and OwnerID

Hi Everyone !

I'm working on porting an old addon back from Cata. so far everything works fine except (it seems) Pet. (it's a kind of DPS meter)

The way used in there to get the ownername,ownerID and petID is a bit scriptic for me (i'm not a huge LUA expert, i'm just digging info and fixing with the resources i find)

Basically the issue is that (it seems) each time a hunter uses stampede, or any other classes that seem to have some weird pets, the addon floods me with errors :

Code:
Message: Interface\AddOns\dMeter\Core.lua:411: bad argument #1 to 'band' (number expected, got string)
Time: 07/14/13 14:37:15
Count: 4
Stack: [C]: ?
[C]: in function `band'
Interface\AddOns\dMeter\Core.lua:411: in function <Interface\AddOns\dMeter\Core.lua:409>
Interface\AddOns\dMeter\Core.lua:435: in function <Interface\AddOns\dMeter\Core.lua:424>
Interface\AddOns\dMeter\Core.lua:2734: in function <Interface\AddOns\dMeter\Core.lua:2636>
Interface\AddOns\dMeter\Core.lua:3193: in function <Interface\AddOns\dMeter\Core.lua:3191>

Locals:
Below is the part of code that it is complaining about

Code:
	local function _RelevantMember(flag)

		if bit.band(flag, 0x0000FC00) == 0x00000400 then
			if bit.band(flag, 0x0000000F) == 0x00000001 or  bit.band(flag, 0x0000000F) == 0x00000002 or bit.band(flag, 0x0000000F) == 0x00000004 then
				return true
			end
		end

	end

	local function _GetOwner(petid)

		if C_Pets[petid] then
			return C_Pets[petid]["OwnerID"], C_Pets[petid]["OwnerName"]
		end

		return nil
	end

	local function _CheckForOwner(petid)

		if GetNumGroupMembers() > 0 then
			for i = 1, GetNumGroupMembers() do
				if UnitGUID("raidpet"..i.."") == petid then
					return UnitGUID("raid"..i..""), UnitName("raid"..i.."")
				end
			end
		elseif GetNumGroupMembers() > 0 then
			for i = 1, GetNumGroupMembers() do
				if UnitGUID("partypet"..i.."") == petid then
					return UnitGUID("party"..i..""), UnitName("party"..i.."")
				end
			end
			if UnitGUID("pet") == petid then
				return UnitGUID("player"), UnitName("player")
			end
		else
			if UnitGUID("pet") == petid then
				return UnitGUID("player"), UnitName("player")
			end
		end

		return nil

	end

	local function _AddStupidEntryOrderPetsToOwner(petid, ownerid, ownername)

		if stupidOrderPets[petid] then
			for i = 1, #stupidOrderPets[petid] do
				_AddPet(ownerid,ownername,stupidOrderPets[petid][i])
			end
			stupidOrderPets[petid] = nil
		end

	end 

	local function _AddStupidEntryOrderPet(source, target)

		if not stupidOrderPets[source] then
			stupidOrderPets[source] = {target}
		else
			table.insert(stupidOrderPets, target)
		end

	end

	local function _RelevantPet(flag, guid)

		if (bit.band(flag,0x0000FC00) == 0x00000800 and bit.band(flag,0x000000F0) == 0x00000020) or bit.band(flag,0x0000FC00) == 0x00001000 or bit.band(flag,0x0000FC00) == 0x00002000 or bit.band(guid,0x00F0000000000000) == 0x0040000000000000 then
			local owner, ownername = _CheckForOwner(guid)
			if not owner then
				owner, ownername = _GetOwner(guid)
				return owner, ownername
			else
				return owner, ownername
			end
		end

	end

	local function _RelevantMob(flag, guid, name)

		if not guid then
			return false
		end

		if name == "The Skyfire" then
			return true
		end

		if bit.band(flag,0x000000F0) == 0x00000040 or bit.band(flag,0x000000F0) == 0x00000020 then
			local owner = _RelevantPet(flag, guid)
			if not owner then
				return true
			end

		end

		return false

	end
Any idea or help for fixing would be very appreciated as i'm totally facing a wall on that part currently. i've been doing some digging on the web, wowiki api sites etc etc.. i could find that all these bit.band are searching for the HEX values that seem to be attributed to an npc,a player,enemi etc etc.. so my "guess" is that some IDs or the way they are reported have changed and its not just giving a number like it is expecting but a string....

Many thanks for your time and help!

BuG
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » damage meter issue related to Pet OwnerName and OwnerID


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