View Single Post
03-24-24, 05:46 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,937
It won't work exactly like that. This, theoretically, is what you want to use. You might have to tweak it but I think it's coded up the way you need it to be.



Lua Code:
  1. local addonName, addon = ...
  2. local llRI = nil
  3. local npcToWatch = 205089
  4.  
  5. local function OnEvent(self,event,...)
  6.    if event == "PLAYER_TARGET_CHANGED" then
  7.  
  8.       local guid = UnitGUID("target")
  9.       if guid == nil then return end
  10.  
  11.       local guidType, _, _, _, _, npc_id, _ = strsplit("-",guid)
  12.       if guidType == "Creature" and tonumber(npc_id) == npcToWatch then      
  13.          if GetRaidTargetIndex("target") == nil then
  14.             if llRI == nil then
  15.                llRI = 0
  16.             end
  17.             llRI = (llRI % 8) + 1
  18.             if GetRaidTargetIndex("target") ~= llRI then
  19.                SetRaidTarget("target", llRI)
  20.                PlaySound(SOUNDKIT.GM_CHAT_WARNING)
  21.             end
  22.          end
  23.       end
  24.    end
  25. end
  26.  
  27. local f = CreateFrame("Frame")
  28. f:RegisterEvent("PLAYER_TARGET_CHANGED")
  29. f:SetScript("OnEvent",OnEvent)

UnitGUID("target") will only return a value if you have physically targetted a mob - I mentioned PLAYER_TARGET_CHANGED event being the one to watch for that happening to do your work.

Unless you are only ever going to need that one single creature then you will have to edit your addon, reload your UI so you can do it again for the next target of interest. And when they rebuild the GUIDs you will likely have to change the numbers again. It depends on whether these are special entities that keep their GUID permanently like players.

However, you could add in a slash command that allows you to type in the id of the next npc if you will need to repeat this for each npc you will be going after and to cater for GUID changes. I will leave that task up to you, but all you will need to do in that block of code is grab the id you typed and set that to the variable set up for it.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 03-24-24 at 05:49 AM.
  Reply With Quote