View Single Post
07-23-13, 07:04 PM   #16
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
The code I currently have is all over the place and will give you a headache. It's currently functional in my test environment (have not been able to test all bosses yet since I don't lead my raids until the weekend) but I'm starting over from scratch to try do it right.

This is what I have so far. Obviously it's not done, but this is the new direction I'm heading based on the feedback you guys have given.

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 events = CreateFrame("Frame")
  39.  
  40. events:RegisterEvent("PLAYER_ENTERING_WORLD")
  41. events:RegisterEvent("PARTY_LEADER_CHANGED")
  42.  
  43. events:SetScript("OnEvent",function(self,event,...)
  44.     if event == "PLAYER_ENTERING_WORLD" or event == "PARTY_LEADER_CHANGED" then
  45.         local ininstance, instancetype = IsInInstance("player") -- check if player is in a raid and in an instance
  46.         local isgroupleader = UnitIsGroupLeader("player") -- check if player is raid leader
  47.        
  48.         if ininstance == 1 and instancetype == "raid" and isgroupleader then -- if player is group leader in a raid and currently in an instance enable functionality
  49.             print("|cff00ff00Niketa's Mount Looter enabled!")
  50.             events:RegisterEvent("PLAYER_REGEN_DISABLED")
  51.             events:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") --!!!!!!!!!!!!!!!!!! DON'T FORGET TO DISABLE THIS WHEN REVERTING LOOT SETTINGS!!!!!!!!!!!!!!
  52.         elseif ininstance == 1 and instancetype == "raid" and not isgroupleader then -- if player is in a raid and in instance but not group leader, "error" message
  53.             print("|cff00ff00Niketa's Mount Looter disabled: You need to be raid leader to use this addon.")
  54.         end
  55.     end
  56.    
  57.     if event == "PLAYER_REGEN_DISABLED" then -- on entering combat, start looking at CLEU
  58.         events:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  59.        
  60.     end
  61.    
  62.     if event == "COMBAT_LOG_EVENT_UNFILTERED" and eventType ~= "SPELL_AURA_APPLIED" then
  63.         local _, _, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _ = ...
  64.         local enemyNPCIDa = tonumber(strsub(sourceGUID, 6, 10), 16)
  65.         local enemyNPCIDb = tonumber(strsub(destGUID, 6, 10), 16)
  66.        
  67.         if bossNPCID[enemyNPCIDa] or bossNPCID[enemyNPCIDb] then -- if enemy is in table then set loot and unregister CLEU
  68.             events:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  69.            
  70.             nmlmethod, nmlthreshold = GetLootMethod(), GetLootThreshold()
  71.            
  72.             if nmlmethod == "master" and nmlthreshold ~= 4 then -- only set threshold if already master
  73.                 print("no thresh")
  74.                
  75.                 SetLootThreshold(4)
  76.             elseif nmlmethod ~= "master" and nmlthreshold == 4 then -- only set method if already epic
  77.                 print("no method")
  78.                
  79.                 SetLootMethod("master",UnitName("player"))
  80.             elseif nmlmethod ~= "master" and nmlthreshold ~= 4 then -- set both
  81.                 print("no thresh or method")
  82.                
  83.                 nmlnodead = 1 -- set nil when reverting settings
  84.                 nmlsetthreshold = 1 -- trigger PARTY_LOOT_METHOD_CHANGED to set to epic
  85.                
  86.                 SetLootMethod("master",UnitName("player"))
  87.          -- else do nothing
  88.             end
  89.         end
  90.     end
  91.    
  92.     if event == "PARTY_LOOT_METHOD_CHANGED" and nmlsetthreshold == 1 then
  93.         nmlsetthreshold = nil
  94.        
  95.         SetLootThreshold(4)
  96.     end
  97. end)


Is this a step in the right direction or am I still way off?

(* I just realized I forgot to add in your suggestion about caching the NPCID so I don't keep calling local enemyNPCID. I don't really understand your code for that [as far as metatables go]; would you mind explaining so I actually understand what I'm writing [we don't want another issue like my local variables for CLEU, lol]? *)

Last edited by Niketa : 07-23-13 at 08:12 PM.
  Reply With Quote