Thread Tools Display Modes
Prev Previous Post   Next Post Next
Unread 12-31-12, 11:17 AM   #1
htordeux
A Murloc Raider
Join Date: Apr 2007
Posts: 5
get class spec of Enemy Unit in BG

Hello,
I want to get class & spec of EnemyUnit in BG ( "target", "raid1target"...
the function print correctly the class & Spec but returns nil,nil,nil when I want to use it in an other function.
e.g.
local unit = "target"
local enemyRole,enemySpec,enemyClass = jps_EnemySpec_BG(unit)
print("|cFFFFff00",enemyRole,enemySpec,enemyClass)

returns nil,nil,nil
I don't understand why?


Lua Code:
  1. function jps_EnemySpec_BG(unit)
  2.     if not UnitExists(unit) then unit = "player"
  3.     else unit = "target" end
  4.  
  5.     if CheckInteractDistance(unit,1)  then
  6.         NotifyInspect(unit)
  7.     end
  8.     local f=CreateFrame("Frame")
  9.     f:RegisterEvent("INSPECT_READY")
  10.     f:SetScript("OnEvent",function(self,event,...)
  11.         if event == "INSPECT_READY" then
  12.             local specID = GetInspectSpecialization(unit)
  13.             local enemySpec = select(2,GetSpecializationInfoByID(specID))
  14.             local enemyRole = select(6,GetSpecializationInfoByID(specID))
  15.             local enemyClass = select(7,GetSpecializationInfoByID(specID))
  16.             print(specID,"-",UnitName(unit),"is",jps_tableSpec[specID],"-",enemyClass,"-",enemySpec,"-",enemyRole)
  17.         end
  18.         f:UnregisterEvent("INSPECT_READY")
  19.     end)
  20.  
  21. return enemyRole,enemySpec,enemyClass
  22. end

Ps jps_tableSpec is a simple table of differnts spec

Lua Code:
  1. jps_tableSpec =
  2. {
  3.   [250]="Blood", [251]="Frost", [252]="Unholy", [102]="Balance", [103]="Feral",
  4.   [104]="Guardian", [105]="Restoration", [253]="Beast Mastery", [254]="Marksmanship",
  5.   [255]="Survival", [62]="Arcane", [63]="Fire", [64]="Frost", [268]="Brewmaster",
  6.   [270]="Mistweaver", [269]="Windwalker", [65]="Holy", [66]="Protection",
  7.   [70]="Retribution", [256]="Discipline", [257]="Holy", [258]="Shadow",
  8.   [259]="Assassination", [260]="Combat", [261]="Subtlety", [262]="Elemental",
  9.   [263]="Enhancement", [264]="Restoration", [265]="Affliction", [266]="Demonology",
  10.   [267]="Destruction", [71]="Arms", [72]="Fury", [73]="Protection",
  11.   [0]="Unknown Spec"
  12. }
htordeux is offline   Reply With Quote
 

Go BackWoWInterface » Developer Discussions » General Authoring Discussion » get class spec of Enemy Unit in BG

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off