UnitIsUnit Unit Characteristics trigger doesn't always work properly
nekizalb opened this issue ยท 0 comments
Describe the bug
When comparing UnitIsUnit triggers, the comparison often compares the wrong units and activates or deactivates incorrectly.
Do you have an error log of what happened?
no errors
To Reproduce
- Create a WA that uses the Stats -> Unit Characteristics trigger (example: https://pastebin.com/enU45H8p)
- Set Unit to Focus, set UnitIsUnit to Target
- Set some sort of display to see the aura is active
- Target something. Notice the aura activates without a focus set --BAD
- Set a focus and clear target. Aura deactivates --GOOD
- Target the focus. Aura activates --GOOD
- Target something else, Aura stays active --BAD
Did you try having WeakAuras as the only enabled addon and everything else (especially something like ElvUI) disabled?
Yes
Which version of WeakAuras are you using?
2.17.4
Are you on World of Warcraft Classic or Retail?
- Classic
- [X ] Retail
Was it working in a previous version? If yes, which was the last good one?
Unsure
Additional Info
I did some digging, and believe this is the source of the error. I'm not sure how to tackle a fix, so I wasn't able to propose a PR. But I wanted to share my debugging.
The UnitIsUnit trigger condition correctly registers the trigger for notifications on unit changes to both the source unit and comparison unit (Prototypes.lua lines 1532 and 1534), however the generated trigger function takes in the modified unit, and compares to the (generated) hard-coded comparison unit (Prototypes.lua lines 1546 and 1569).
Extracted generated trigger function.
return function(state, event, unit)
unit = string.lower(unit)
local smart = false
local extraUnit = "target";
error(unit)
local specificUnitCheck = true
local unitisunit = UnitIsUnit(unit, extraUnit)
local name = UnitName(unit)
local class = select(2, UnitClass(unit))
local hostility = WeakAuras.GetPlayerReaciton(unit)
local character = UnitIsPlayer(unit) and 'player' or 'npc'
local level = UnitLevel(unit)
local attackable = UnitCanAttack('player', unit)
if((unitisunit) and (WeakAuras.UnitExistsFixed(unit, smart) and specificUnitCheck)) then
--snip
return true else return false end end
This essentially boils down to
function(modifiedUnit)
return UnitIsUnit(modifiedUnit, 'target')
end
Since target is updated much more frequently than focus, this function frequently returns true erroneously.
Since the trigger is activated by multiple units changing, I believe the UnitIsUnit should be more specific on the comparison, however with the complexities of group logic, it's unclear to me how to accomplish that without affecting the complex logic present.