WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Get UnitId of UnitIds target (https://www.wowinterface.com/forums/showthread.php?t=56816)

vectros 10-30-18 03:49 PM

Get UnitId of UnitIds target
 
Hello,

I am developing my own addon and I came to a place where I encountered the following problem:

1. I have NPC's UnitID
2. I want to compare that UnitIDs TARGET with player for example.
3. if UnitIsUnit(unitID-target, "player") then doesn't work unfortunately (I've tried all combinations of that).

Is there any way to achieve that?

Seems like there's no way to compare UnitID variable with some selector ("target", "player" etc). Am I right?

Thanks

Rilgamon 10-30-18 03:54 PM

Every unit has a unique GUID. If you have a valid unitid you can query it.

myrroddin 10-30-18 04:46 PM

You've tried all the combinations you thought of, but did you try
Code:

if UnitIsUnit("targettarget", "player" then
    -- do stuff
end


vectros 10-31-18 12:16 AM

Thank you for your replies.

1. I do have valid stored in a variable: UID. I can see it, because with message(UID) it's displayed on my screen.

2. I did think about that and it works indeed. However that works only with my target. I would like to check if every UID stored is targeting me.

I think I need a method that allows to compare variables.

local player = UnitGUID("player") -- this is my GUID
local UID = ("unitData.name) -- this is variable stored in array for multiple creatures. I would need to get it's target somehow and compare it with my GUID.

The problem is:

How do I get UID's target?
If I have UID's target, how do I compare 2 variables?

Rilgamon 10-31-18 01:38 AM

You can't know if all enemies are targeting you. Only those with a valid unitid. That means you iterate over your group, over their targets and then their targets. Only those unitids are valid and can be checked. If nobody you know targets a unit you can't know it's target.

vectros 10-31-18 02:06 AM

So let's say I have an array of various valid unitdIDs that are are not in my group, neither I target them and mousover them (I have not connection with them besides them being on the same server).

This means that I will not be able to check what's their target right?

That implicates that I will not be able to create my addon :(

Xrystal 10-31-18 02:14 AM

Yes, unfortunately, what you are asking is likely to be impossible within wow's allowed functionality. Addons can make suggestions and tell you what to do but only based on what information is available. So unit wise is raidx, player, partyx, target, pet, focus, mouseover and their equivalent targets. So your addon would have to assume your player is at lease monitoring the potential attackers in the area ( I know I do ) and would then allow them to either simply mouseover them one by one or target them, and on the indirect scenario of being in a group of some sort or having a pet then you can do similar tests that way.

vectros 10-31-18 02:22 AM

Thanks for your help again.

I think mouseovertarget will partially solve my problem.

I will now have two variables:

UnitIDsTarget = ("mouseovertarget")
local player = UnitGUID("player")

is there a function that allows to compare variables not selectors?

Something like: UnitIsUnit(UnitIDsTarget, player). Because errors I've been getting with this make me think that this function is only for selectors.

Rilgamon 10-31-18 03:07 AM

Keep in mind that there is no valid unitid for targets in a storage. The moment the unit that targets it changes its target the same unitid means another unit.

vectros 10-31-18 03:36 AM

Sure. However I have an object, which one of it's property will be UnitIDsTarget

It will be

NPCData.UnitIDsTarget

and it will be saved in array. So I will have multiple UnitIDs. But the problem stays the same:

Which function should I check if two variables are the same.

UnitIsUnit(variable1, variable2).

Rilgamon 10-31-18 08:50 AM

Only the GUID can handle this when there are units without a valid unitid.

semlar 10-31-18 05:20 PM

For the sake of clarity, the term unitID specifically refers to unit tokens like target, mouseover, and player, and these are used by the various Unit functions to get information about them.

OP keeps using the term to refer to something that is not a unitID, and it's unclear what they do have and what exactly they're trying to do with it.

There are many ways to get information about what's targeting you, but how you do it depends on what you need it for. Are they players or npcs, are they in the open world or in a battleground, do they have nameplates, etc.

This is also almost the exact same question that was asked a week ago by someone trying to make a nameplate addon for a private server.

If you are the same person let me save you some time. Burning Crusade came out 10 years ago. The API has undergone drastic changes since then; nobody here can help you develop an addon for an outdated version of the game simply because the differences between the codebases are too great.

vectros 11-01-18 01:57 AM

Hi,

Thank you for your replies.

If there's no way to compare variables like these tokens it means that I will not be able to develop the addon indeed.

I really appreciate your time.


All times are GMT -6. The time now is 06:24 PM.

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