ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   You only die twice if in group? (https://www.esoui.com/forums/showthread.php?t=6888)

patrick_smyth 03/09/17 04:22 PM

You only die twice if in group?
 
I wonder if someone can help me.

I am alpha testing a mod which (among other things) monitors EVENT_UNIT_DEATH_STATE_CHANGED.

The mod is only interested in triggers where the isDead argument is true and IsUnitPlayer(unitTag) is true.

When the player is solo and dies everything works as expected.

The problem comes when the player is in a group. In the group case it gets triggered twice when the player dies. When any other group member dies it works fine as it is only triggered once.

The double triggers come in quick succession, before the player has a chance to decide whether to spend a soul gem to revive or go to a wayshrine.

Does anyone know whether this is expected behaviour?

Am I missing something and the two invocations are different? They look identical to me :confused:

Could the number of death triggers be different in other circumstances? :confused:

Before I try to concoct a workaround I would like to know more.

Dolgubon 03/09/17 08:40 PM

I have no idea if it's expected or not. Have you tried passing just the function d to the the event manager? That will print out everything that it gets passed, if there's more than two variables. Other than that, you might need to add a timer to ignore the second one.

Solinur 03/10/17 10:20 AM

You will get one event with the unittag = "player" and a second one with the unittag "group1" assuming that group1 is the player. Both will return true to IsUnitPlayer(unitTag) obviously. You can either just use unittag == "player" to select only for those events.

If you want to have a more elegent version you can try to use AddfilterForEvent:

Lua Code:
  1. EVENT_MANAGER:AddFilterForEvent([same as name as in your event declaration], EVENT_UNIT_DEATH_STATE_CHANGED,  REGISTER_FILTER_UNIT_TAG , "player")

Then the event will only fire if the unittag matches "player". But I guess you usually won't get flooded with death events to a point where perfomance is an issue :D

Btw: This happens with all events where a target might have more then one unittag, also the unittags "reticleover", "reticleoverplayer" and "reticleovertarget" can cause similar issues.

PS: more on AddFilterForEvent is here: http://wiki.esoui.com/AddFilterForEvent

patrick_smyth 03/10/17 03:21 PM

Thank-you
 
Thank-you to Dolgubon and decay2.

I now have a much clearer picture of what is going on. I am going to test my new knowledge by modifying some code. Then more testing :)


All times are GMT -6. The time now is 05:57 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI