Thread Tools Display Modes
Prev Previous Post   Next Post Next
08/05/16, 02:21 PM   #1
Justinon
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 8
COMBAT_EVENT kill detection for mobs

Hey everyone, I'm currently trying to work out how to detect if the player has killed a mob, and I believe this is done using EVENT_COMBAT_EVENT. I'm trying to use the 'result' parameter, pairing it with ACTION_RESULT_DIED, ACTION_RESULT_KILLING_BLOW, and ACTION_RESULT_TARGET_DEAD, like so:
Lua Code:
  1. local function OnCombatEvent(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId)
  2.     d("event fired!")
  3.     if result == ACTION_RESULT_DIED or result == ACTION_RESULT_KILLING_BLOW or result == ACTION_RESULT_TARGET_DEAD then
  4.         d("Killed!")
  5.         --Do some stuff
  6.     end
  7. end
  8.  
  9. EVENT_MANAGER:RegisterForEvent(myNameSpace, EVENT_COMBAT_EVENT, OnCombatEvent)
  10. EVENT_MANAGER:AddFilterForEvent(myNameSpace, EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_TARGET_DEAD)
  11. EVENT_MANAGER:AddFilterForEvent(myNameSpace, EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_DIED)
  12. EVENT_MANAGER:AddFilterForEvent(myNameSpace, EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_KILLING_BLOW)

But for some reason, I cannot get "killed" to be printed. I understand that the event only fires on player or pet actions, but I believed at least Killing Blow should be detected from the player's final, killing attack. Any suggestions for what I'm doing wrong?

Also, I tried commenting out the filters, but to no avail. Thank you!

EDIT 1: Okay so I realized that something is indeed wrong with the filters, because after reloadui it actually worked when commenting them out. However, I'm now still trying to figure out what to do with the filters

EDIT 2: After commenting out two of the three events, the "killed" is finally fired. So to me it's appearing like adding the filters together won't allow it to fire for these events. I thought that the filter would make it so that only those results would trigger the event, but now I'm not so sure how it works.

EDIT 3: Okay so I found out that, contrary to the ESOUI page, you do NOT need to pass the namespace in.

Last edited by Justinon : 08/05/16 at 02:56 PM. Reason: Realized something
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » COMBAT_EVENT kill detection for mobs


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