View Single Post
06/22/14, 07:33 PM   #1
Specko
 
Specko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
Event Listener Based On Another Event Fire

Hello All,

Sorry if I missed this somewhere else, but here is my question. I have an event listeners for EVENT_COMBAT_EVENT and EVENT_ALLIANCE_POINT_UPDATE. What I'm wanting to do I have a popup only when there is an alliance point gain and the result of a combat event is a kill. I thought that I might be able to just set the label for the kill popup only when I get a killing blow. However, my function is triggering when someone releases or is rezzed. So the bug is getting a killing blow popup twice. Here is the relevant code. All help is very much appreciated.

Code:
  function KillingBlow.CheckForApGain( alliancePoints, playSound, difference)
	if difference == 0 then
		KBC.Label:SetText("")
	end
  end


  function KillingBlow.Combat(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)

	local playerName = GetUnitName("player") .. "^Mx"

	if hitValue ~= 0  and damageType ~= 1 then
		if sourceType == COMBAT_UNIT_TYPE_PLAYER then
			if playerName == sourceName then
				KBC.label:SetText(abilityName .. " Killing Blow!")
				KillingBlow.CheckForApGain()
			end
		end
	end

	if sourceType == COMBAT_UNIT_TYPE_PLAYER  then
		if playerName == sourceName then
			if result == 2260 or result == 2265 then
				KillingBlow:simpleAnimation(KBC.label)
			end
		end
	else
		return
	end
  end

	em:RegisterForEvent(self.addonName, EVENT_COMBAT_EVENT, KillingBlow.Combat )
	em:RegisterForEvent(self.addonName, EVENT_ALLIANCE_POINT_UPDATE, KillingBlow.CheckForApGain)
  Reply With Quote