+ Reply to Thread
Results 1 to 3 of 3

Thread: Pet .owner Issues

  1. #1
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default Pet .owner Issues

    Hi all

    Over a long period of time ive had a few complaints about necro mage pets merging with the wrong owner. Now several times I have looked over my unit builder and as yet to find an issue. This leads me to believe there is an API issue with either nameSecondary or .owner

    Shortend version of my unit builder:

    Code:
    function SuperMeter.Unit(params)
    	local session = SuperMeter.Session(true)
    
    	if returnCaster then
    		unitName = params.casterName
    		unitID = params.caster
    	end
    
    	if returnTarget then
    		unitName = params.targetName
    		unitID = params.target
    	end
    
    	if unitName and session.units[unitID] then
    		if not session.units[unitID].name then
    			session.units[unitID] = nil
    		end
    	end
    
    	if session.units[unitID] then
    		return session.units[unitID]
    	end
    
    	for k,v in pairs (session.units) do
    		if unitName and unitName == session.units[k].name then
    			return session.units[k]
    		end
    		if unitID and unitID == session.units[k].pet then --- Return pet if it exists
    			return session.units[k]
    		end
    	end
    
    	if not session.units[unitID] then --- Unit did not exist in my addon table, build a new one
    		if not SuperMeter_instance and not params.caster then return end
    		if not SuperMeter_instance and not params.target then return end
    		
    		if unitID then
    			owner = Inspect.Unit.Detail(unitID .. ".owner") --- Get Owner
    			unit = Inspect.Unit.Detail(unitID)
    		end
    		
    		if not unit then
    			unit = {id = "Unknown", name = unitName}
    		end
    		
    		if session.units[unit.id] then
    			return session.units[unit.id]
    		end
    		
    		for k,v in pairs (session.units) do
    			if unit.name and unit.name == session.units[k].name then
    				return session.units[k]
    			end
    			if unit.id and unit.id == session.units[k].pet then --- Return pet if it exists
    				return session.units[k]
    			end
    		end
    		
    		if unit.nameSecondary then
    			for k,v in pairs (session.units) do
    				local name = string.match(unit.nameSecondary, "%a+") --- Use name secondary to check owner, only used for non group members usually
    				if name == session.units[k].name then
    					session.units[k].pet = unitID
    					return session.units[k]
    				end
    			end
    		end
    		
    		if not owner and unit.relation == "friendly" and unit.nameSecondary then return end
    		if owner then unit = owner end
    		
    		if SuperMeter.Battle[unit.id] or SuperMeter_forced or SuperMeter_instance then
    			run = true
    		end
    		
    		if not unit.blocked and unit.combat or unit.relation == "hostile" then
    			run = true
    		end
    		
    		if unit.name == "" or unit.name == " " then
    			unit.name = nil
    		end
    		
    		if not run then return end
    		
    		local data = {
    			abilities = {},
    			calling = unit.calling,
    			combatlog = {},
    			damage = 0,
    			damageAbsorbIn = 0,
    			damageAbsorbed = 0,
    			damageAvoidIn = 0,
    			damageAvoided = 0,
    			damageBlockIn = 0,
    			damageBlocked = 0,
    			damageCritical = 0,
    			damageDeflectIn = 0,
    			damageDeflected = 0,
    			damageIn = 0,
    			damageMissed = 0,
    			damageMitigable = 0,
    			damageNonCritical = 0,
    			damageOut = 0,
    			damageTaken = 0,
    			damageTakenCritical = 0,
    			damageTakenNonCritical = 0,
    			healing = 0,
    			healingCritical = 0,
    			healingIn = 0,
    			healingNonCritical = 0,
    			healingOut = 0,
    			healingTaken = 0,
    			healingTakenCritical = 0,
    			healingTakenNonCritical = 0,
    			level = unit.level,
    			name = unit.name,
    			overHealing = 0,
    			overHealingCritical = 0,
    			overHealingOut = 0,
    			overKill = 0,
    			overKillCritical = 0,
    			overKillNonCritical = 0,
    			overKillOut = 0,
    			overhealingNonCritical = 0,
    			pet = "N/A",
    			player = unit.player,
    			relation = unit.relation,
    		}
    		
    		if data then
    			data.casters = {damage = {}, damageAbsorbed = {}, damageBlocked = {}, damageDeflected = {}, healing = {}, overHealing = {}, overKill = {}, event = {}}
    			data.targets = {damage = {}, damageAbsorbed = {}, damageBlocked = {}, damageDeflected = {}, healing = {}, overHealing = {}, overKill = {}, event = {}}
    		end
    		
    		if owner then
    			data.pet = unitID --- Put the pets id to the owners table
    		end
    		
    		if not session.units[unit.id] then
    			session.units[unit.id] = data
    		end
    		
    		if unit then
    			return session.units[unit.id]
    		end
    	end
    end
    If I have missed something please alert me, otherwise there is an API issue.
    Last edited by Ferather; 08-23-2013 at 09:51 AM.

  2. #2
    Wym
    Wym is offline
    Shadowlander
    Join Date
    Jun 2012
    Posts
    25

    Default

    Not sure if i understand all of your code from looking at it for just five minutes, but, if two pets have the same name (pet name not changed from default), or a pet has the same name as a player, won't the red part possibly return the wrong pet / player?

    Code:
    
    		for k,v in pairs (session.units) do
    			if unit.name and unit.name == session.units[k].name then
    				return session.units[k]
    			end
    			if unit.id and unit.id == session.units[k].pet then --- Return pet if it exists
    				return session.units[k]
    			end
    		end
    

  3. #3
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default

    Aha thank you, not sure if that was causing the issue since the users report did not specify unit names I did not look there.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts