NPC name via API

Hi

Is there anyway to grab the name of an npc through the api using the npc guid.

I cannot use ‘target’.

But how are you not getting the npc name if you can get their guid and not use the target unit id? Both name and guid are available in COMBAT_LOG_EVENT for example

There is https://wow.gamepedia.com/API_GetPlayerInfoByGUID but that only works for players

I am getting the guid via loot :slight_smile: however maybe the combat log could be a hack…

Normally when you loot, the unit being looted is the current target. Can you not just do this?

local function OnEvent(self, event)
	print(event, UnitName("target"))
end

local f = CreateFrame("Frame")
f:RegisterEvent("LOOT_READY")
f:SetScript("OnEvent", OnEvent)

Edit: oh right, I forgot AoE looting is a thing :confounded:
https://wow.gamepedia.com/API_GetLootSourceInfo

Yup its the aoe problem, as useful as it is, it doesn’t help here.

However I came up with a hack for now which does the job but needs some tinkering.

Hi,
do you mind sharing your solution? :eyes:

Regards

Ok so its not ideal and I need to decide on the best route to keep tables small but

using combat log I keep a table of items { destGUID, destName }

then when I need to I scan the table and if I get a match on the guid then I can get the name.

just need to do table = {} at some point but at what point I haven’t decided yet

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.