Thread Tools Display Modes
05/02/14, 10:17 AM   #1
mra4nii
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
Detect if unit is Boss

Hello,

Is there a method/function to detect if the unit under focus is a boss? I can't find any function in wiki for this and so far the only way i see to do that is to check what textures are used to draw the target health bar borders.
  Reply With Quote
05/03/14, 03:13 AM   #2
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by mra4nii View Post
Hello,

Is there a method/function to detect if the unit under focus is a boss? I can't find any function in wiki for this and so far the only way i see to do that is to check what textures are used to draw the target health bar borders.
afaik IsDecoratedDisplayName()
  Reply With Quote
05/03/14, 04:11 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by mra4nii View Post
Hello,

Is there a method/function to detect if the unit under focus is a boss? I can't find any function in wiki for this and so far the only way i see to do that is to check what textures are used to draw the target health bar borders.
Lua Code:
  1. if GetUnitDifficulty("reticleover") == MONSTER_DIFFICULTY_DEADLY then
  2.    d("This unit is boss!")
  3. end

All return values:
http://wiki.esoui.com/Globals#UIMonsterDifficulty

Default unit frames uses just 3 return values:
MONSTER_DIFFICULTY_NORMAL
MONSTER_DIFFICULTY_HARD
MONSTER_DIFFICULTY_DEADLY
  Reply With Quote
05/03/14, 09:09 AM   #4
gamegenius86
 
gamegenius86's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 27
Actually Deadly does not always mean boss. I've ran across deadly monsters that do not have the Boss Bar.

Also how would you use IsDecoratedDisplayName() in context to your target?

Imo i would compare something(because there is no API call to get this) against the BossRank Globals. But since there is no way to get this, i have no idea >.<

Last edited by gamegenius86 : 05/03/14 at 09:17 AM.
  Reply With Quote
05/03/14, 10:27 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by gamegenius86 View Post
Actually Deadly does not always mean boss. I've ran across deadly monsters that do not have the Boss Bar.

Also how would you use IsDecoratedDisplayName() in context to your target?

Imo i would compare something(because there is no API call to get this) against the BossRank Globals. But since there is no way to get this, i have no idea >.<
OK, I have found another method:
Lua Code:
  1. for i = 1, MAX_BOSSES do  --global constant MAX_BOSSES = 6
  2.    local bossTag = "boss" .. i
  3.    if DoesUnitExist(bossTag) then
  4.       if GetUnitName("reticleover") == GetUnitName(bossTag) then
  5.          d("This unit is boss!")
  6.       end
  7.    end
  8. end

If you do not want to run this check all the time, you can use EVENT_BOSSES_CHANGED. I did not try it, but BossBar (unit frame that is displayed over the compass) is registered for this event.

Last edited by Garkin : 05/03/14 at 10:34 AM.
  Reply With Quote
05/03/14, 11:38 AM   #6
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
This code probably looks a bit better:

Lua Code:
  1. local bossCount = 0
  2. local bossUnitTags = {}
  3. for i = 1, MAX_BOSSES do         --global constant MAX_BOSSES = 6
  4.    bossTags[i] = "boss" .. i
  5. end
  6.  
  7. local function OnBossesChanged()
  8.    bossCount = 0
  9.    for i, bossTag in ipairs(bossUnitTags) do
  10.       if DoesUnitExist(bossTag) then
  11.          bossCount = bossCount + 1
  12.       end
  13.    end
  14. end
  15.  
  16. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_BOSSES_CHANGED, OnBossesChanged)
  17.  
  18. --returns true if unit is boss
  19. function IsUnitBoss(unitTag)
  20.    if bossCount > 0 and unitTag ~= nil then
  21.       for i, bossTag in ipairs(bossUnitTags) do
  22.          if GetUnitName(unitTag) == GetUnitName(bossTag) then
  23.             return true
  24.          end
  25.       end
  26.    end
  27.    
  28.    return false
  29. end
  Reply With Quote
05/03/14, 06:42 PM   #7
mra4nii
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
Oh my, that's what happens when the question is too vague
Sorry guys, my problem is to detect those units who have their health bar different from default one as first step. And such bar have not only Boss units.

Originally Posted by Iyanga View Post
Nope, that function is related to player names, not sure what it does anyway.

Originally Posted by Garkin View Post
Lua Code:
  1. if GetUnitDifficulty("reticleover") == MONSTER_DIFFICULTY_DEADLY then
  2.    d("This unit is boss!")
  3. end

All return values:
http://wiki.esoui.com/Globals#UIMonsterDifficulty

Default unit frames uses just 3 return values:
MONSTER_DIFFICULTY_NORMAL
MONSTER_DIFFICULTY_HARD
MONSTER_DIFFICULTY_DEADLY
Yep, i found this too on closer look to raw globals and turns out that this is exactly what i need.
There are 5, not 3 values:
["MONSTER_DIFFICULTY_NONE"] = 0 - snakes, caravan guars(enviroment mobs) and... Players. Perhaps in Cyrodiil enemy players have another difficulty. Didn't get there to check
["MONSTER_DIFFICULTY_EASY"] = 1 - regular mobs, npc
["MONSTER_DIFFICULTY_NORMAL"] = 2 - mobs what have health bar sides decorated with 1 square, solo dungeon boss
["MONSTER_DIFFICULTY_HARD"] = 3 - mobs what have health bar sides decorated with 2 square. location boss and its army. public dungeon bosses afaik have this rank too.
["MONSTER_DIFFICULTY_DEADLY"] = 4 - no idea, not sure what decoration it has, didn't have a chance to see such mobs.

Now second step is to understand how this difficulty coefficient affect the, let's call it, real level of mobs. Is lvl + difficulty * some_constant), or maybe difficulty * level.

I found GetUnitEffectiveLevel, but is not what i need. In fact, from what i've seen, this function always returns same value as GetUnitLevel.

Any thoughts?

Last edited by mra4nii : 05/03/14 at 06:48 PM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Detect if unit is Boss


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