#Wondering what is the best way to retrieve a spell caster's Unit

43 messages · Page 1 of 1 (latest)

gloomy shuttle
#

My Env Info: WOW 3.4.3 + WA 5.12.8

I'm trying to do some practice for tracking a spell's caster and target

basically I can retrieve sourceGUID, sourceName, destGUID, destName from CLEU:SPELL_CAST_SUCCESS

so next I wanna do this:

sourceUnit = MyFunction(sourceGUID, sourceName) destUnit = sourceUnit .. "target"

then do something else, in this case a sourceUnit/destUnit is required

I've learned several ways to achieve that, for instance using param sourceGUID, assuming that UnitExists(unit) is always true

`1. local unit = "target"
if UnitGUID(unit) == sourceGUID then return unit

  1. local unit = "focus"
    if UnitGUID(unit) == sourceGUID then return unit

  2. for i=1, 40 do
    local unit = "nameplate"..i
    if UnitGUID(unit) == sourceGUID then return unit
    end
    end

  3. for _,v in pairs(C_NamePlate.GetNamePlates()) do
    local unit = v.namePlateUnitToken
    if UnitGUID(unit) == sourceGUID then return unit
    end

  4. for unit in WA_IterateGroupMembers() do
    if UnitGUID(unit) == sourceGUID or UnitGUID(unit.."target") == sourceGUID then return unit
    end

6.1 for i=1, GetNumSubgroupMembers() do
local unit = "party"..i
if UnitGUID(unit) == sourceGUID or UnitGUID(unit.."target") == sourceGUID then return unit
end

6.2 for i=1, GetNumGroupMembers() do
unit = "raid"..i
if UnitGUID(unit) == sourceGUID or UnitGUID(unit.."target") == sourceGUID then return unit
end`

I understand that I should always check 1 and 2 to quickly get a result, then use 3 or 4, then 5 or 6.1+6.2

wondering is this the best way that we can have in WA?
if so, which performs better comparing 3 and 4, 5 and 6.1+6.2 ?

or anyone can share a better solution please.
thanks in advance!
❤️ ❤️ ❤️

unkempt pecan
#

Using unit events.

gloomy shuttle
#

@unkempt pecan thanks for your attention, could you please share more details

unkempt pecan
#

I don't know if the events exist for your version, which game version is it?

gloomy shuttle
#

@unkempt pecan my bad, I forgot to mention that I'm playing wow3.4.3, and using WA 5.12.8

ornate cliff
#

Since it was introduced in TBC, it's probably there for you

#

The spellId payload was only added in Cata apparently though, I guess before that it only carried the spell name? Idk, you'd have to check that out yourself

gloomy shuttle
#

@ornate cliff that's worth trying, I'll give it shot, thanks for your attention.

gloomy shuttle
#

hmm...interesting...
I can extract all 3 params from the payload :unitTarget, castGUID, spellID
probably because wow-classic-3.4.3 is already upgraded in the core

but I'm confused by the unitTarget, it seems to be the "caster unit" instead of "the unit that spell pointing to"
@ornate cliff do you know more about that please?

unkempt pecan
#

It's the caster

gloomy shuttle
#

comparing to "CLEU:SPELL_CAST_SUCCESS"
it looks like "UNIT_SPELLCAST_SUCCEEDED" is detecting a smaller range
am I understanding correctly?

ornate cliff
#

A smaller range? As in, from less in-game distance away? Not that I'm aware

#

Or do you mean just the amount of info it carries? Then yes, obviously

#

The advantage is that you can filter unit events by the unit you're interested in. UNIT_SPELLCAST_SUCCEEDED:player would only fire for any casts you do, as opposed to CLEU which would fire for anyones casts

#

And you directly have the unitId of the caster as well instead of having to jump through the hoops you talked about earlier

#

And instead of CLEUs limited spell cast start/success/fail, unit spellcsst events offer more detailed checks:

gloomy shuttle
#

that is amazing, I'm a fresh hand in WA, that is absolutely the next thing that I'm going to dig into deeper!!!

however...at this point I'm still concerned about the "smaller range" issue
from my tests below, I'm standing a bit far from the fight, not in combat,
so if I cast a spell on myself, both of CLEU:SPELL_CAST_SUCCESS and UNIT_SPELLCAST_SUCCEEDED can reflect that
when the mod casts a spell (in my sight but not close enough to activate the nameplate), just only CLEU is fired

ornate cliff
#

Well, might as well be more limited in range then

#

Never bothered or mattered for me personally in that case

gloomy shuttle
#

yea normally in a boss fight, no one stands so far away from the battle ground🤣
so basically UNIT_SPELLCAST... is wide/powerful enough to monitor any specific spells and then construct an alert based on that

ornate cliff
#

It is.
But it's also worth noting that for many applications you realistically either need only the default "cast" trigger,
or, if you need custom code, you can just watch the cast trigger and react to that.

gloomy shuttle
#

that makes sense, I've done some practices on default cast trigger, but there is something else that I wanna try,
like when a spell is casted from the boss, which unit it comes from, which target unit it points to, if it's pointing to me or some mate near me, I should be warned to move away, assuming it's AOE

ornate cliff
#

Doesn't your Boss Mod add-on handle all relevant cases of that?

#

And you can also do that with a cast trigger

#

At least some of it, I'm not too sure if "boss" is a valid unit from the unit drop-down in there.
But you can make a condition check for target unit = player and then to smth with that

gloomy shuttle
#

yea I just want to challenge myself to do so in WA🤣

yes there is a "boss" option in unit drop-down

unkempt pecan
#

The unit events require a unit. So a nameplate for example.

#

The thing you where looking for.

#

The thing you need to have to know what they target.

gloomy shuttle
#

@unkempt pecan this might be a silly question, in raid, my team mate "AAA" is also a valid unit, is that correct?

unkempt pecan
#

Any group member is a valid unit.

#

As in, they have a valid unit

#

The name isn't a unit.

gloomy shuttle
#

oh I see...so WA_IterateGroupMembers() gives me all the members units in a smarter way so that I don't have to loop part1,2,3... and raid1,2,3...

#

@unkempt pecan @ornate cliff could you please take a look at that and help me understand... I got confused again...

ornate cliff
#

But idk if that's still acceptable for all functions requiring a unit token

gloomy shuttle
# ornate cliff

could you please share this link, I wanna read into that👍

ornate cliff