#Help debugging a WA for detecting the target of an enemy cast

113 messages · Page 1 of 1 (latest)

dull ibex
#

So, I have a WA I use for detecting the target of specified casts and highlighting their nameplate. The problem I'm finding is that whenever mobs chain cast abilities (for example, any mob that spams the 'shoot' spell) the target does not properly update. The frame of the PREVIOUSLY targetted person will be highlighted while the cast is going off targeting a different player.

EDIT: On more testing, this also seems to apply for a mob that switches target at all. If a mob is being tanked, but they switch target to a new random player to cast some spell, the tank's nameplate will be highlighted rather than the target of the spell.

    if ts then
        local changed = false
        for _, state in pairs(s) do
            state.show = false
            state.changed = true
            changed = true
        end
        for cloneID, state in pairs(ts) do
            if state and state.show and state.destUnit then
                s[cloneID] = CopyTable(state)
                s[cloneID].unit = state.destUnit
                s[cloneID].changed = true
                changed = true
            end
        end
        return changed
    end
end```

Here's the code I'm using to update the target. Any help is greatly appreciated. If there's some information about the triggers needed I'm happy to provide. Thank you!
dull ibex
#

As I'm looking at it more, this seems to be a weird quirk of how I'm triggering this which is based on a cast trigger from nameplate. The trigger state is populated by the info just before the cast starts (so the mob's target prior to beginning the cast of the spell). Is there a good way to delay the trigger state just slightly to read the correct target?

torpid patrol
#

Just don't do anything unless it has a target. Or do an arbitrary delay of your choice via C_Timer.After

#

If what you say is indeed the issue.

#

But just post the aura in the future and not only a single code snippet.

dull ibex
#

What's the best way to post the entire aura?

#

and how do I check if the spell has a target? assuming that's what you mean

torpid patrol
#

Export it to wago and post the link here. Bonus points since people that aren't at the PC can then also check the aura out.

dull ibex
#

Gotcha

#

Will do that really quickly

torpid patrol
#

If it has a target. If it doesn't, destunit would be "" or false or whatever

dull ibex
#
                s[cloneID] = CopyTable(state)
                s[cloneID].unit = state.destUnit
                s[cloneID].changed = true
                changed = true```
Is that not what the conditional on this line is doing?
torpid patrol
#

I'm on my phone, I didn't read your code.

#

Even as a code block it gets all mashed together on this screen size.

dull ibex
#

Oh I see. Okay I will find out how to upload to wago and post the link

torpid patrol
#

But your conditional there only checks for destUnit being truthy

#

destUnit could be "" and that would still be true

dull ibex
#

Ohh I see. That makes sense. Let me try that

torpid patrol
#

(idk if destUnit is "" when there's no target, just a guess. Check it out yourself)

dull ibex
#

Oh I think there's a misunderstanding. The issue isn't spells that have no target

#

It's that the triggerstate that WA is passing does not include the updated target

#

So let me lay out the scenario and exactly what's going wrong

#

Mob is currently targetting the tank to do white hits

#

Mob starts a spell cast, targetting non-tank party member

#

The triggerstate has the destination unit as the tank, rather than the non-tank party member being targetted by the spel

#

Thus my weakaura is highlighting the tank's frame, rather than the party member actually being targetted by the spell

#

This works the same way if the mob is chain casting spells. IE The mob casts on party member A. Finishes cast. Begins casting again on party member B. Party member A's frame is highlighted, rather than party member B

torpid patrol
#

Sure, unlucky.

#

WA does what the game tells it.
In the first place, there is no "target of a cast" you can determine when something is casting. You can only determine whatever it is targeting in that moment.

dull ibex
#

Sure yeah I've been told that before

#

But I'm looking at other WAs that do something similar, but they work properly

#

This one for instance I'm comparing against

#

It always shows the cast next to the appropriate frame

#

But frankly I can't understand everything going on to just copy it, and it odesn't quite have the functionality I want

#

The big difference I see is that it's triggering UNIT_SPELLCAST_START, as opposed to my WA using the player/unit info -> cast -> nameplate section as a trigger

torpid patrol
#

It just constructs the target like that

#

Which is exactly what I described. There is no "magic"

#

It's checking the target of the mob and not the target of the cast (since that's impossible as mentioned)

torpid patrol
dull ibex
#

Then I don't get what it's doing that I'm not

torpid patrol
#

Well neither I nor anyone else can tell you anything, since you never posted your aura.

dull ibex
#

Okay sorry, let me get on that

#

Hmm is there a lockout on new accounts posting an aura?

torpid patrol
#

No, you don't even need an account

dull ibex
#

Oh yikes my ad blocker was blocking the import form

#

I really appreciate the help by the way, I have been banging my head against this for over an hour and comparing to other similar WAs

dull ibex
#

So I tried doing the same thing the other wa was doing by just building out the entire table

#

The problem is I don't understand how "[sourceguid]target" maps to the actual target I want

#

Unless again there's some magic and concatenating the string "target" is actually doing something else further down the line

#

and it does not appear to work for how I'm returning the state

dull ibex
# torpid patrol It just constructs the target like that

Sorry I'm trying to understand this. I just don't understand how appending "target" to a guid gets me where I want to go here. That's why I kept referring to it as "magic". I don't understand the meaning of guid+"target" or how that maps to anything or why WAs can now associate that with the appropriate frame

#

It's certainly not doing it correctly in my case, so apparently this other WA is doing something under the hood that's invisible to me

torpid patrol
#

new region type for a while now already. you can still give it an icon for /wa options look

#

(even though in this case, that's the wrong call to make technically)

torpid patrol
dull ibex
#

Hmmm I see

torpid patrol
#

not a GUID, a unit id

dull ibex
#

Oh I see I might just be fetching the wrong thing here. in the example aura, they do this:
function(allstates, event, ...)
local caster,GUID,spellID = ...;

#

In my aura I'm doing this:
function(s,e,num,ts)

#

I assumed caster is being mapped to sourceunit, GUID is being mapped to destunit, and spellid is spellid of course

#

from the triggerstate

#

as far as I can tell I'm doing everything exactly as they are

#

But yet I am still getting the incorrect target for the spell

#

for cloneID, state in pairs(ts) do
if state and state.show and state.destUnit then
local unitTarget = state.sourceUnit .. "target";
s[cloneID] = CopyTable(state)
s[cloneID].show = true
s[cloneID].changed = true
s[cloneID].unit = unitTarget
changed = true
end
end

#

Relevant snippet here, which is exactly (?) what the other WA which has correct behavior is doing for determining the target of a spell

#

I'm wondering if there's some bug with weak auras [player/unit info] -> [cast] -> [nameplate] passing of the state, that is not present whenever simply triggering by UNIT_SPELLCAST_START

#

The destination unit from the trigger state info is always wrong

#

Or rather, it's always behind the actual state of the game at the start of the cast

#

Mob M is attacking target A. M begins channeling a spell on target B. Trigger state on [player/unit info] -> [cast] -> [nameplate] says that M's target is A (Incorrect)

#

Meanwhile, UNIT_SPELLCAST_START trigger state says that M's target is B (correct)

torpid patrol
#

no, it works perfectly fine 🤷‍♂️

dull ibex
#

Then why am I getting two different results from the exact same lines of code?

#

The only thing I'm changing is the trigger condition

#

You can test this for yourself and compare the triggerstate values from the two trigger conditions

#

Just have it spit out the state.destUnit values

#

whenever a mob changes targets to cast a spell

torpid patrol
#

as I said, it works fine

dull ibex
#

Sorry my testing indicates otherwise

#

The two states do not agree

torpid patrol
#

Then your code or testing is most likely faulty, but I don't have the time to look at it right now
Could totally be that you found a huge issue though that no one ever noticed before.

dull ibex
#

despite it being ostensibly from the same event

#

The built in weakaura trigger is not correctly passing the updated state

#

while UNIT_SPELLCAST_START is

torpid patrol
#

no

#

^this is an overly simplistic example, and it works perfectly fine even for mobs that change their target multile times etc.

#

at least I see none of what you mention

dull ibex
#

Just tested

#

your has the same bug mine does

#

Let me try to find a quick way to make a video clip for you

#

The tank's frame is highlighting

#

while a spell is being cast on a non-tank party member (as shown by the other WA)

#

actually probably a screenshot should do

#

Note I disabled everything except your WA and the other one I linked that uses unit_spellcast_start

#

Okay wait, no sorry I'm just incorrect. That is working correctly

#

I think I just missed one of the other spell's that were going off the first time I tested

torpid patrol
#

as opposed to your aura this is set up to glow on legit all hostile casts as opposed to just a few.

#

just for showcasing purposes

dull ibex
#

Yeah

#

wait wait I wonder if the difference is this checkbox I didn't notice before

#

"Advance

#

Would that be the difference in getting the correct updates?

torpid patrol
#

it does what the tooltip says

dull ibex
#

Okay that looks like that's what I've been missing all along

#

Well I appreciate your help. I'm kind of frustrated that the solution seems to have just been an option I didn't even notice about the polling rate haha. You were really helpful and patient and I think I learned a bit about the wow api and custom code in WAs