Thread Tools Display Modes
07/04/14, 02:01 AM   #1
simosf
Join Date: Jul 2014
Posts: 5
Event_combat_event

Hello to all,
i'm trying to make a very very simple addon for testing reasons, that simply shows me which mob is attacking me and what skill it uses.

For some reason the EVENT_COMBAT_EVENT is only showing always me as SOURCE and only shows the skills i'm using instead of the enemy mob as well. Anyone has any idea why it shows only my attacks and not the enemie's (NPC mob in my case)?

Thank you very much for your time.

Part of my code is this:

EVENT_MANAGER:RegisterForEvent( "tlw" , EVENT_COMBAT_EVENT , MyEventOnHit )

local function MyEventOnHit( eventCode , result , isError , abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log )
lblCounter:SetText(sourceName..":"..abilityName)
end
  Reply With Quote
07/04/14, 02:17 AM   #2
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
I noticed that you are registering the event before you defined the handler. So right now your code is registering nil as a event handler - not your code.
Edit: Actually it is registering whatever happens to be in the global variable "MyEventOnHit". I just asumed it would be nil.

This would be the proper order:
Lua Code:
  1. --Declare the handler
  2. local function MyEventOnHit( eventCode , result , isError , abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log )
  3.     lblCounter:SetText(sourceName..":"..abilityName)
  4. end
  5.  
  6. --Register then handler with the event
  7. EVENT_MANAGER:RegisterForEvent( "tlw" , EVENT_COMBAT_EVENT , MyEventOnHit )

Also, it could be that a second event firing directly after the NPC event is overwriting the label. I would use d and .. to output the data into chat.
Lua Code:
  1. --Declare the handler
  2. local function MyEventOnHit(...)
  3.     --takes any amount of parameters and feeds them to d()
  4.     d(...)
  5. end
  6.  
  7. EVENT_MANAGER:RegisterForEvent( "tlw" , EVENT_COMBAT_EVENT , MyEventOnHit )

Last edited by zgrssd : 07/04/14 at 02:20 AM.
  Reply With Quote
07/04/14, 02:28 AM   #3
simosf
Join Date: Jul 2014
Posts: 5
Hello - thank you for your answer and your time.

I only copy/pasted part of the code - so it was not clear.
Yes my real code has first the local function declared and later on on the code i put the event.

The event is fired without any problems, as i can see at the label what i hit.

In order to avoid the 'overwrite label' scenario, i started fight with a mob - but i never attacked it, so it was only the mob attacking me. Still nothing showing his attacks. If I hit, i can see in my addon my name and my attack, but not when the mob attacks me. Any other idea?
  Reply With Quote
07/04/14, 02:59 AM   #4
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by simosf View Post
Hello - thank you for your answer and your time.

I only copy/pasted part of the code - so it was not clear.
Yes my real code has first the local function declared and later on on the code i put the event.

The event is fired without any problems, as i can see at the label what i hit.

In order to avoid the 'overwrite label' scenario, i started fight with a mob - but i never attacked it, so it was only the mob attacking me. Still nothing showing his attacks. If I hit, i can see in my addon my name and my attack, but not when the mob attacks me. Any other idea?
You asume that if you do not attack the event will not fire for you. It could very well be that the event fires for you directly after every attack the mob makes against you. I never used it so I am not sure.
But I do know that asumptions are the primary source of bugs.

Restructure it tou output in the chat. It should at least give you a hint at was is really happening.

And please give us your full code. I spend half of yesterday trying to figure out why my logic was not working, till I realised I had declared a second (lower tier) local variable. So my top level local that was fed to return was never even written too.
  Reply With Quote
07/04/14, 03:08 AM   #5
simosf
Join Date: Jul 2014
Posts: 5
I'm gratefull for your help (:

I'll change the code to post to chat and then if the problem still exists i'll post the full addon so you can see (is not that not big).

What do i need to add to show at chat ?
d(sourceName..":"..abilityName) ??
  Reply With Quote
07/04/14, 03:27 AM   #6
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by simosf View Post
I'm gratefull for your help (:

I'll change the code to post to chat and then if the problem still exists i'll post the full addon so you can see (is not that not big).

What do i need to add to show at chat ?
d(sourceName..":"..abilityName) ??
If you want to learn everything there is about an event, just feed all it's parameters to d():
Lua Code:
  1. local function MyEventOnHit(...)
  2.     d("MyEventOnHit: ", ...)
  3. end
  4.  
  5. EVENT_MANAGER:RegisterForEvent( "tlw" , EVENT_COMBAT_EVENT , MyEventOnHit )

... is a placeholdeer for "everything that you get as pararameter". If you put ... in your parameter list, any amount and any types of parameters can be given to your function. You can then handle the ... parameter via select statements. Or just relay it too anotehr function directly.
d itself uses ... too, to take any amount of parameters.

If you have BugEater isntalled I would disable it for now. It can sometimes cause issues with the output of d()
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Event_combat_event


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