View Single Post
03-23-24, 10:07 PM   #7
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
Originally Posted by Xrystal View Post
Ah, then nope, not possible to do that.

Not sure where that ID you are talking about comes from as the GUID value which is a short term unique id for everything in the game is much longer than a single number.

"Creature-0-1465-0-2105-448-000043F59F"
Which is an example provided on https://warcraft.wiki.gg/wiki/API_UnitGUID page.

Unless you have already extracted the ID element from the GUID.
The ID for that creature is 448 with the three immediately before referencing the server, instance and zone they are in.

I cannot see a reverse equivalent except for players (https://warcraft.wiki.gg/wiki/API_GetPlayerInfoByGUID).

So, the nearest you could get ( assuming it is the GUID you are talking about ) is to cycle through all the possible targets via the /target ( or more precisely in this case /targetenemy) command or tab target and use the PLAYER_CHANGED_TARGET or UNIT_TARGET events to identify a target switch or
use the UPDATE_MOUSEOVER_UNIT event to identify an entity under the mouse when you move it.

see the following pages for more info:
https://warcraft.wiki.gg/wiki/UNIT_TARGET
https://warcraft.wiki.gg/wiki/PLAYER_TARGET_CHANGED
https://warcraft.wiki.gg/wiki/UPDATE_MOUSEOVER_UNIT

and use UnitGUID to get their unique ID and check it against the one(s) you want.

Once you have identified the correct target you could then use ( https://warcraft.wiki.gg/wiki/API_SetRaidTargetIcon ) to set an icon on that entity so people can see it.

I am assuming this is so that everyone targets the same entity.


I obviously haven't tried this myself, but it would be my first steps in attempting such a task.

There is no way to do this without you utilising a hardware action ( keypress, slash command, mousemove etc ) for each target change.

I found another macro that determines the NPC by ID (based on the example of achievement Something's Not Quite Right....).


Lua Code:
  1. /run local guid = UnitGUID("target");local type, _, _, _, _, npc_id, _ = strsplit("-",guid);if type == "Creature" and tonumber(npc_id) == 205089 then print("\124cFF00FF00YES\124r") else print("\124cFFFF0000NO\124r") end

Is this how it will work?

Lua Code:
  1. local addonName, addon = ...
  2. local guid = UnitGUID("target");local type, _, _, _, _, npc_id, _ = strsplit("-",guid);if type == "Creature" and tonumber(npc_id) == 205089
  3. if GetRaidTargetIndex("target") == nil then if llRI == null then llRI = 0 end llRI = (llRI % 8) + 1 SetRaidTarget("target", llRI) PlaySound(SOUNDKIT.GM_CHAT_WARNING) end
  Reply With Quote