View Single Post
11/25/17, 02:32 AM   #13
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Originally Posted by dorrino View Post
unitId only exist in some events like EVENT_EFFECT_CHANGED or EVENT_COMBAT_EVENT to distinguish between different units with the same name (at least that's the reason that i know).

None of the game functions returns these unitIds nor takes them as input parameters.
That was my understanding as well. In fact I even tested this for Srendarr extensively many months ago, and all events that returned unitId always returned 0 regardless of the unit or whether it was targeted. Unless something has changed in the API I do not see how it would be possible to use unitId in order to track unit-specific buffs/debuffs with or without a reload.

The method I ended up using relied on name matching and timestamps, but if they changed the API to allow a non-zero value to ever be returned for unitId from combat events, I would happily migrate the code.

Will have to test...

EDIT: OK, so the events that return unitId DO return a unique value now, and those values DO persist through reloads. In theory those SHOULD be usable at least for the purpose of short duration buff and debuff tracking.

HOWEVER, the problem I ran into is that EVENT_RETICLE_TARGET_CHANGED basically doesn't return ANY information (other than eventCode), let along unitId, which sort of makes tracking the buff/debuff information in a table of ability ID's with unitId sub-keys pointless, since you can't actually look up the current target specifically by unitId when your reticle target changes.

If you only care about the player's buffs/debuffs on reload, you could just run a function on init that checks GetUnitBuffInfo('player', i) in a for loop, and for any buff/debuff abilityIDs on the player just reload your buff/debuff indicators with the updated finish time.

You can probably find some examples in Srendarr's AuraControl.lua file.

EDIT EDIT: @ZOS_ChipHilseberg, please add unitID return to EVENT_RETICLE_TARGET_CHANGED and/or GetUnitBuffInfo()!


Last edited by Phinix : 11/25/17 at 12:53 PM.
  Reply With Quote