Quantcast Checking if raid group is in combat with a specific boss... - Page 2 - WoWInterface
Thread Tools Display Modes
07-24-13, 01:49 AM   #21
Niketa
A Cyclonian
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 41
Ok I am up waaaayyyy too late. Here's what I have so far.

Lua Code:
  1. local bossNPCID = {
  2.     [55294] = true, -- Ultraxion
  3.    
  4.     -- Madness of Deathwing... check combat log next time to see if there's any NPC that shows up regardless of what platform we start at.--
  5.     [56846] = true, -- Madness of Deathwing: Arm Tentacle
  6.     [56167] = true, -- Madness of Deathwing: Arm Tentacle
  7.     [56168] = true, -- Madness of Deathwing: Wing Tentacle (Need to check if there's a second NPCID during raid, only one listed on WoWhead.)
  8.     [56173] = true, -- Madness of Deathwing: Deathwing
  9.     ----------------------------------------------------------------------------------------------------------------------------------------
  10.    
  11.     [52530] = true, -- Alysrazor
  12.     [52409] = true, -- Ragnaros
  13.     [46753] = true, -- Al'akir
  14.     [33136] = true, -- Yogg-Saron: Guardian of Yogg-Saron
  15.     [60410] = true, -- Elegon
  16.     [36597] = true, -- The Lich King
  17.     [10184] = true, -- Onyxia
  18.     [16152] = true, -- Attumen the Huntsman
  19.     [19622] = true, -- Kael'thas Sunstrider
  20.     [28859] = true, -- Malygos
  21.     [28860] = true, -- Sartharion
  22.     [69712] = true, -- Ji-Kun
  23.    
  24.     --TEST NPCIDS
  25.     [12129] = true,
  26.     --[[
  27.     [] = true,
  28.     [] = true,
  29.     [] = true,
  30.     [] = true,
  31.     [] = true,
  32.     [] = true,
  33.     [] = true,
  34.     [] = true,
  35.     ]]
  36. }
  37.  
  38. local mobIDfromGUID = setmetatable ({}, { __index = function(t, guid)
  39.     local mobID = tonumber(strsub(guid, 6, 10), 16)
  40.     t[guid] = mobID
  41.     return mobID
  42. end })
  43.  
  44. local events = CreateFrame("Frame")
  45.  
  46. events:RegisterEvent("PLAYER_ENTERING_WORLD")
  47. events:RegisterEvent("PARTY_LEADER_CHANGED")
  48.  
  49. events:SetScript("OnEvent", function(self, event, ...)
  50.     if event == "PLAYER_REGEN_DISABLED" then
  51.         events:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  52.     else
  53.         return self[event] and self[event](self, event, ...)
  54.     end
  55. end)
  56.  
  57. function events:PLAYER_ENTERING_WORLD(event)
  58.     local ininstance, instancetype = IsInInstance("player")
  59.     local isgroupleader = UnitIsGroupLeader("player")
  60.    
  61.     if ininstance == 1 and instancetype == "raid" then -- check if player is in a raid instance
  62.         if isgroupleader then -- enable functionality if player is raid leader
  63.             print("|cff00ff00Niketa's Mount Looter enabled!")
  64.             events:RegisterEvent("PLAYER_REGEN_DISABLED")
  65.         else -- print error message if player is not raid leader and disable functionality
  66.             print("|cff00ff00Niketa's Mount Looter disabled: You need to be raid leader to use this addon.")
  67.             events:UnregisterEvent("PLAYER_REGEN_DISABLED")
  68.         end
  69.     end
  70. end
  71.  
  72. events.PARTY_LEADER_CHANGED = events.PLAYER_ENTERING_WORLD -- creates alias of PEW function for PLC
  73.  
  74. function events:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
  75.     local _, eventType = ...
  76.     if eventType == "SPELL_AURA_APPLIED" then
  77.         return
  78.     end
  79.    
  80.     local _, _, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _ = ...
  81.     local mobIDa, mobIDb = mobIDfromGUID[sourceGUID], mobIDfromGUID[destGUID]
  82.        
  83.     if bossNPCID[mobIDa] or bossNPCID[mobIDb] then -- if mob is found in the bossNPCID table...
  84.         events:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  85.         events:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") -- !!!!!!!!!!!!!!DON'T FORGET TO DISABLE THIS WHEN REVERTING LOOT SETTINGS!!!!!!!!!!!!!!
  86.        
  87.         -- need to be able to access this for PARTY_LOOT_METHOD_CHANGED
  88.         if bossNPCID[mobIDa] then
  89.             local mobName = sourceName
  90.         elseif bossNPCID[mobIDb] then
  91.             local mobName = destName
  92.         end
  93.         ------------------------------------------------
  94.        
  95.         local method, threshold = GetLootMethod(), GetLootThreshold()
  96.            
  97.         if method ~= "master" then
  98.             if threshold ~= 4 then
  99.                 SetLootMethod("master", UnitName("player"))
  100.                 -- set variable to trigger setlootthreshold
  101.             else
  102.                 SetLootMethod("master", UnitName("player"))
  103.             end
  104.         else
  105.             if threshold ~= 4 then
  106.                 SetLootThreshold(4)
  107.             end        
  108.         end
  109.     end
  110. end

I know one thing I still am uncertain of how to approach is sharing variables between events... such as passing the original method and threshold to my LOOT_OPENED to set it back.

Also being able to trigger the correct things to happen on PARTY_LOOT_METHOD_CHANGED. What I was doing before for setting loot master and epic threshold if neither were already set is setting up a global variable or a local variable defined outside of the events as a trigger variable so that on this event if that is true then set threshold to epic (that goes along with the above, trying to figure out a more efficient way).
Also, this event needs to do something when the loot method is changed before the mob is killed (but also not do it on the original change).

So basically...
Pull the boss.
Set master looter if boss matches.
Set epic threshold (which I'm doing by the PARTY_LOOT_METHOD_CHANGED because I can't call SetLootThreshold() right after SetLootMethod()... not sure if there's another way I can set the treshold with the method since doing it together will revert the method back to what it was prior to the change).

If the boss isn't killed (wipe/reset) and the player changes the loot method for whatever reason, I need to execute a block of code. Will also need the same kind of thing when I get to the looting too since I don't want any looting happening during the boss or in between boss kills to revert the settings until the boss actually dies.

What I was doing for this all before was just overall... terrible (defining local variables as nil, setting values of them in events and using them in other events... just a lot of random "trigger" variables for different scenarios).

Anyway I really need to get to bed... it's late... and I'm rambling.



Man this stuff is addicting. lol




Just now seeing your latest message, I'll look it over and revise more tomorrow.

Last edited by Niketa : 07-24-13 at 02:06 AM. Reason: One of my comments was messed up.
  Reply With Quote
07-24-13, 07:15 AM   #22
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,011
Originally Posted by Niketa View Post
I set nmlmethod and nmlthreshold as global so I could access them for different events (because I need to be able to retrieve these values on LOOT_OPENED to revert the settings). What would a better approach be?
The better approach would be to define them locally at the top of your main file.
Lua Code:
  1. local addon, private_table = ...
  2. local nmlmethod, nmlthreshold = "Bob", "Sally"
  3.  
  4. function addon:ExampleOne()
  5.     print(nmlmethod) -- prints "Bob" without the quotes
  6. end
  7.  
  8. function addon:ExampleTwo()
  9.     print(nmlthreshhold.. " likes ".. nmlmethod) -- prints "Sally likes Bob" without the quotes
  10. end
  Reply With Quote
07-25-13, 06:07 PM   #23
Niketa
A Cyclonian
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 41
Ok as far as functionality I think I'm done... I just need to test to make sure it works on all the stored bosses (which I run most of the raids this weekend, a couple I will have to check aside from my raids).

Is there anything that I've done that I should have done differently?

Lua Code:
  1. local bossNPCID = {
  2.     [55294] = true, -- Ultraxion
  3.    
  4.     -- Madness of Deathwing... check combat log next time to see if there's any NPC that shows up regardless of what platform we start at.--
  5.     [56846] = true, -- Madness of Deathwing: Arm Tentacle
  6.     [56167] = true, -- Madness of Deathwing: Arm Tentacle
  7.     [56168] = true, -- Madness of Deathwing: Wing Tentacle (Need to check if there's a second NPCID during raid, only one listed on WoWhead.)
  8.     [56173] = true, -- Madness of Deathwing: Deathwing
  9.     ----------------------------------------------------------------------------------------------------------------------------------------
  10.    
  11.     [52530] = true, -- Alysrazor
  12.     [52409] = true, -- Ragnaros
  13.     [46753] = true, -- Al'akir
  14.     [33136] = true, -- Yogg-Saron: Guardian of Yogg-Saron
  15.     [60410] = true, -- Elegon
  16.     [36597] = true, -- The Lich King
  17.     [10184] = true, -- Onyxia
  18.     [16152] = true, -- Attumen the Huntsman
  19.     [19622] = true, -- Kael'thas Sunstrider
  20.     [28859] = true, -- Malygos
  21.     [28860] = true, -- Sartharion
  22.     [69712] = true -- Ji-Kun
  23. }
  24.  
  25. local mobIDfromGUID = setmetatable ({}, { __index = function(t, guid)
  26.     local mobID = tonumber(strsub(guid, 6, 10), 16)
  27.     t[guid] = mobID
  28.     return mobID
  29. end })
  30.  
  31. local events = CreateFrame("Frame")
  32. local method, threshold, thresholdtrigger, revertthreshold, mobName, nokill, loottrigger = nil
  33.  
  34. events:RegisterEvent("PLAYER_ENTERING_WORLD")
  35. events:RegisterEvent("PARTY_LEADER_CHANGED")
  36.  
  37. events:SetScript("OnEvent", function(self, event, ...)
  38.     return self[event] and self[event](self, event, ...)
  39. end)
  40.  
  41. function events:PLAYER_ENTERING_WORLD(event)
  42.     local ininstance, instancetype = IsInInstance("player")
  43.     local isgroupleader = UnitIsGroupLeader("player")
  44.    
  45.     if ininstance == 1 and instancetype == "raid" then -- check if player is in a raid instance
  46.         if isgroupleader then -- enable functionality if player is raid leader
  47.             print("|cff00ff00Niketa's Mount Looter enabled!")
  48.             self:RegisterEvent("PLAYER_REGEN_DISABLED")
  49.             self:RegisterEvent("PLAYER_REGEN_ENABLED")
  50.         else -- print error message if player is not raid leader and disable functionality
  51.             print("|cff00ff00Niketa's Mount Looter disabled: You need to be raid leader to use this addon.")
  52.             self:UnregisterEvent("PLAYER_REGEN_DISABLED")
  53.             self:RegisterEvent("PLAYER_REGEN_ENABLED")
  54.         end
  55.     end
  56. end
  57.  
  58. events.PARTY_LEADER_CHANGED = events.PLAYER_ENTERING_WORLD -- creates alias of PEW function for PLC
  59.  
  60. function events:PLAYER_REGEN_DISABLED(event)
  61.     self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  62. end
  63.  
  64. function events:PLAYER_REGEN_ENABLED(event)
  65.     self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  66. end
  67.  
  68. function events:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
  69.     local _, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _ = ...
  70.     local mobIDa, mobIDb = mobIDfromGUID[sourceGUID], mobIDfromGUID[destGUID]
  71.    
  72.     -- get mobName from either sourceName or destName
  73.     if bossNPCID[mobIDa] then
  74.         mobName = sourceName
  75.     elseif bossNPCID[mobIDb] then
  76.         mobName = destName
  77.     end
  78.     ---------------------------------------------------
  79.    
  80.     if not bossNPCID[mobIDa] and not bossNPCID[mobIDb] then -- if not in table quit
  81.         return
  82.     elseif eventType == "UNIT_DIED" and bossNPCID[mobIDb] then -- only register if boss is dest and dead
  83.         nokill, mobName = nil
  84.         loottrigger = true
  85.         self:RegisterEvent("LOOT_OPENED")
  86.         return
  87.     elseif nokill then
  88.         return
  89.     end
  90.    
  91.     -- if boss matches and it's the first pull change loot ------------------------
  92.    
  93.     self:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
  94.    
  95.     nokill = true -- flag as pulled but not killed
  96.    
  97.     if not method and not threshold then
  98.     method, threshold = GetLootMethod(), GetLootThreshold()
  99.     else
  100.         return
  101.     end
  102.  
  103.     if method ~= "master" then
  104.         if threshold ~= 4 then -- set both
  105.             SetLootMethod("master", UnitName("player"))
  106.             thresholdtrigger = true -- set variable to trigger setlootthreshold
  107.         else -- not master, but already epic; set master
  108.             SetLootMethod("master", UnitName("player"))
  109.         end
  110.     elseif threshold ~= 4 then -- if master and not epic, set epic
  111.             SetLootThreshold(4)
  112.     end
  113. end
  114.  
  115. function events:PARTY_LOOT_METHOD_CHANGED(event, ...)
  116.     if thresholdtrigger then
  117.         thresholdtrigger = nil
  118.         SetLootThreshold(4)
  119.     elseif revertthreshold then
  120.         revertthreshold = nil
  121.         SetLootThreshold(threshold)
  122.         threshold = nil
  123.         self:UnregisterEvent(self)
  124.     else -- loot method changed manually before kill
  125.         local newmethod, newthreshold = GetLootMethod(), GetLootThreshold()
  126.        
  127.         if newmethod ~= "master" then -- changed method
  128.             if newmethod ~= method then -- if new method is not stored method, restore threshold and reset
  129.                 SetLootThreshold(threshold)
  130.                 print("|cff00ff00Niketa's Mount Looter: You've changed your loot method before killing "..mobName..". Your previous loot threshold has been restored and your new settings will be saved next time you engage "..mobName..".")
  131.                 method, threshold, mobName, nokill = nil
  132.                 self:UnregisterEvent(self)
  133.             else -- restore threshold, no reset
  134.                 SetLootThreshold(threshold)
  135.                 method, threshold = nil
  136.             end
  137.         elseif newthreshold ~= 4 then -- changed threshold
  138.             if newthreshold ~= threshold then -- if new threshold is not stored threshold, restore method and reset
  139.                 if method ~= "master" then
  140.                 SetLootMethod(method)
  141.                 end
  142.            
  143.                 print("|cff00ff00Niketa's Mount Looter: You've changed your loot threshold before killing "..mobName..". Your previous loot method has been restored and your new settings will be saved next time you engage "..mobName..".")
  144.                 method, threshold, mobName, nokill = nil
  145.                 self:UnregisterEvent(self)
  146.             else -- restore method, no reset
  147.                 if method ~= "master" then
  148.                 SetLootMethod(method)
  149.                 method, threshold = nil
  150.                 end
  151.             end
  152.         end
  153.     end
  154. end
  155.  
  156. function events:LOOT_OPENED(event, ...)
  157.     if not method or not threshold then
  158.         loottrigger = nil
  159.         self:UnregisterEvent(self)
  160.         self:UnregisterEvent("PARTY_LOOT_METHOD_CHANGED")
  161.     elseif loottrigger then
  162.         loottrigger = nil
  163.         SetLootMethod(method)
  164.         method = nil
  165.         revertthreshold = true
  166.         self:UnregisterEvent(self)
  167.     end
  168. end

Last edited by Niketa : 07-25-13 at 06:14 PM.
  Reply With Quote
07-25-13, 09:18 PM   #24
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Just from a quick glance, a few suggestions:

Code:
function events:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
	local _, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _ = ...
Since you now have a dedicated function for this event, you might as well just name the variables directly as the function receives them, rather than receiving them as a vararg and naming them later. There's also no need to capture those last two underscore variables, unless you're actually using them, in which case you should give them descriptive names so it's clear they're not "junk" like the other underscores.

Code:
function events:COMBAT_LOG_EVENT_UNFILTERED(event, _, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName)
In the same function, you look up bossNPCID[mobIDa] and bossNPCID[mobIDb] multiple times each. You should look them up just once, and store the values in variables, to avoid extra table lookups. Similarly, always check for return conditions before doing other work:

[code]
function events:COMBAT_LOG_EVENT_UNFILTERED(event, _, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName)
local mobIDa, mobIDb = mobIDfromGUID[sourceGUID], mobIDfromGUID[destGUID]
local bossIDa, bossIDb = bossNPCID[mobIDa], bossNPCID[mobIDb]

-- Quit if nokill is set, or the NPC isn't a listed boss:
if nokill or (not bossIDa and not bossIDb) then
return
-- ...or if the boss died:
elseif eventType == "UNIT_DIED" and bossIDb then
nokill, mobName = nil, nil
loottrigger = true
return self:RegisterEvent("LOOT_OPENED")
end

-- Get mobName from either sourceName or destName.
-- Since the NPC is definitely a boss at this point, it must be one
-- or the other, so no need to explicitly check bossIDb too.
mobName = bossIDa and sourceName or destName

-- insert other code here, starting with the RegisterEvent line
end

Finally, the loot-related block in your CLEU handler looks a bit off. As written, you will never change the loot method unless it's set to something other than "master" on the very first time that code runs. After the first time, the "method" and "threshold" variables are already set, so you'll just return out.

If that's not intentional, you should fix it. I can't really think of a reason to check and set the method/threshold variables inside CLEU anyway -- any changes to the loot method or threshold will trigger PARTY_LOOT_METHOD_CHANGED, which you're already handling separately, so that should be the only place you need to set those variables.

If you're seeing issues while logging in in a group (eg. PLMC doesn't fire at login so you don't know anything about the loot method when CLEU starts firing), add a PLAYER_LOGIN handler that calls your PARTY_LOOT_METHOD_CHANGED method (just like your PARTY_LEADER_CHANGED handler calls your PLAYER_ENTERING_WORLD method).

Also:

Code:
self:UnregisterEvent(self)
I don't know what you were trying to do here, but this line will cause an error, because "self" in that scope is a pointer to the "events" frame, and the UnregisterEvent method requires a string, not a frame pointer. I think you may have meant to unregister the currently handled event, in which case you should change this line to:

Code:
self:UnregisterEvent(event)
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
07-26-13, 04:33 PM   #25
Niketa
A Cyclonian
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 41
Originally Posted by Phanx View Post
Similarly, always check for return conditions before doing other work:

...

-- Quit if nokill is set, or the NPC isn't a listed boss:
if nokill or (not bossIDa and not bossIDb) then
return
-- ...or if the boss died:
elseif eventType == "UNIT_DIED" and bossIDb then
nokill, mobName = nil, nil
loottrigger = true
return self:RegisterEvent("LOOT_OPENED")
end
If it's written like that, wouldn't it never be able to reach the "UNIT_DIED" event? On the first pull it sets nokill = true (the code should only be ran on the pull, so I set this to keep it from repeatedly trying to change the loot settings). So after the first pull when everything is set, this is true, so it would never be able to tell if the boss died because you're checking nokill before UNIT_DIED and nokill doesn't get reset until UNIT_DIED.



Finally, the loot-related block in your CLEU handler looks a bit off. As written, you will never change the loot method unless it's set to something other than "master" on the very first time that code runs. After the first time, the "method" and "threshold" variables are already set, so you'll just return out.
The first time the code runs should be the first pull of a matching boss and that should also be the only time that piece of code runs. Once we know we're fighting the right boss and it's not dead, there's no reason to keep setting master looter and epic threshold throughout the fight. So any other CLEU events during the same pull shouldn't keep trying to change the loot settings.

As far as the defining method and threshold in the CLEU I've done that because I need to know the settings before changing to master looter and epic threshold because once the boss is killed and looted, those settings need to be restored.

So if I pull the boss and it changes to master and epic, then the PLMC fires and gets current loot settings, it'll record them as master and epic, not whatever the settings were before the change.


Lua Code:
  1. if method ~= "master" then
  2.         if threshold ~= 4 then -- set both
  3.             SetLootMethod("master", UnitName("player"))
  4.             thresholdtrigger = true -- set variable to trigger setlootthreshold
  5.         else -- not master, but already epic; set master
  6.             SetLootMethod("master", UnitName("player"))
  7.         end
  8.     elseif threshold ~= 4 then -- if master and not epic, set epic
  9.             SetLootThreshold(4)
  10.     end

Say I'm in a raid and I have my loot settings at group loot and uncommon. Once I pull the boss and it registers that it's found in the table, I start looking at the PLMC, get my current settings for later and then change to master looter and epic threshold. If my loot is not master yet (which it's not), it checks what my threshold is and since it's not epic, it sets master looter then sends a trigger to PLMC to set to epic (so we know it only does this PLMC code on the pull). If my settings were group and epic, it would see that I'm not master, but I'm already epic, so it just sets it to master.
If my method is already master though it'll check my threshold and if it's not already epic, set it to epic and if it is, then it obviously doesn't need to do anything.

Once the boss is killed, LOOT_OPENED is registered which sets the method back to the previous method (if the method was not originally master since that will cause an error for not specifying the loot master) and then send a new trigger to PLMC (to make sure it only registers on this when looting) to set the threshold back to the original threshold.

The other part of the PLMC are if the player manually changes any loot settings before killing the boss.
So say mid fight someone realizes they don't actually want to master loot it, so if they set either the threshold or method back to what it was before the pull, it automatically changes the other one to match their previous but doesn't reset the code... that way it doesn't just change it back. The extra bit of LOOT_OPENED handles resetting all of the variables and unregistering events in the event that the player did this.
If the player changes the loot settings mid fight or after a wipe before another pull (etc) to something that wasn't what they had it previous, then it sets the other one back to their previous and resets the block of code so that next time they pull, it'll record their new settings and revert to those when the boss is killed. At this point, the code is reset they can freely change the other setting as well if they please and it shouldn't do anything.

I've tested this on Onyxia and reg Alysrazor and Ragnaros so far. Onyxia and Alys worked as should and Rag switched but did not revert the settings (and that... I'm not sure why. I didn't think to look at my combat log to check if it registered as Rag dying... which actually it probably didn't since he doesn't actually... die on reg. If that's the case, couldn't I just add to the CLEU to check if fighting Rag on normal then register my UNIT_DIED code when UnitHealth is... whatever 10% is?)


And I fixed the other two issues (yeah I derped on the unregistering).

Last edited by Niketa : 07-26-13 at 04:37 PM.
  Reply With Quote
07-26-13, 04:59 PM   #26
Niketa
A Cyclonian
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 41
Originally Posted by Phanx View Post
-- Get mobName from either sourceName or destName.
-- Since the NPC is definitely a boss at this point, it must be one
-- or the other, so no need to explicitly check bossIDb too.
mobName = bossIDa and sourceName or destName
I forgot to ask about this. How exactly does that work? Wouldn't it need to know if it's bossIDa or bossIDb to determine whether or not to use sourceName or destName?

For example, if the event is something like...

Niketa melees Onyxia (even though Niketa is a priest, we'll pretend XD).

In this case Onyxia would be bossIDb and should look for the destName to get "Onyxia".

But bossIDa would return my ID which would be 0 and then my name.
  Reply With Quote
07-26-13, 05:51 PM   #27
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Originally Posted by Niketa View Post
Wouldn't it need to know if it's bossIDa or bossIDb to determine whether or not to use sourceName or destName?
Lua Code:
  1. if nokill or (not bossIDa and not bossIDb) then return end
This exits the function if neither of the IDs match bosses in the table. This means that either bossIDa or bossIDb must be a boss, and if it's not one then it must be the other.

That being said, you might want to write this more explicitly for the sake of the person reading it.
  Reply With Quote
07-26-13, 09:51 PM   #28
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
mobName = bossIDa and sourceName or destName
is functionally identical to

Code:
if bossIDa then
   mobName = sourceName
else
   mobName = destName
end
As explained in the comment in the code I posted, if the function has not already quit running by this point (via return) then either bossIDa or bossIDb is non-nil, so if bossIDa is nil, then bossIDb must not be, so there's no reason to slow down the code adding a check for a condition that will always pass.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Checking if raid group is in combat with a specific boss...

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