local bossNPCID = {
[55294] = true, -- Ultraxion
-- 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.--
[56846] = true, -- Madness of Deathwing: Arm Tentacle
[56167] = true, -- Madness of Deathwing: Arm Tentacle
[56168] = true, -- Madness of Deathwing: Wing Tentacle (Need to check if there's a second NPCID during raid, only one listed on WoWhead.)
[56173] = true, -- Madness of Deathwing: Deathwing
----------------------------------------------------------------------------------------------------------------------------------------
[52530] = true, -- Alysrazor
[52409] = true, -- Ragnaros
[46753] = true, -- Al'akir
[33136] = true, -- Yogg-Saron: Guardian of Yogg-Saron
[60410] = true, -- Elegon
[36597] = true, -- The Lich King
[10184] = true, -- Onyxia
[16152] = true, -- Attumen the Huntsman
[19622] = true, -- Kael'thas Sunstrider
[28859] = true, -- Malygos
[28860] = true, -- Sartharion
[69712] = true -- Ji-Kun
}
local mobIDfromGUID = setmetatable ({}, { __index = function(t, guid)
local mobID = tonumber(strsub(guid, 6, 10), 16)
t[guid] = mobID
return mobID
end })
local events = CreateFrame("Frame")
local method, threshold, thresholdtrigger, revertthreshold, mobName, nokill, loottrigger = nil
events:RegisterEvent("PLAYER_ENTERING_WORLD")
events:RegisterEvent("PARTY_LEADER_CHANGED")
events:SetScript("OnEvent", function(self, event, ...)
return self[event] and self[event](self, event, ...)
end)
function events:PLAYER_ENTERING_WORLD(event)
local ininstance, instancetype = IsInInstance("player")
local isgroupleader = UnitIsGroupLeader("player")
if ininstance == 1 and instancetype == "raid" then -- check if player is in a raid instance
if isgroupleader then -- enable functionality if player is raid leader
print("|cff00ff00Niketa's Mount Looter enabled!")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
else -- print error message if player is not raid leader and disable functionality
print("|cff00ff00Niketa's Mount Looter disabled: You need to be raid leader to use this addon.")
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
end
end
end
events.PARTY_LEADER_CHANGED = events.PLAYER_ENTERING_WORLD -- creates alias of PEW function for PLC
function events:PLAYER_REGEN_DISABLED(event)
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
function events:PLAYER_REGEN_ENABLED(event)
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
function events:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local _, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _ = ...
local mobIDa, mobIDb = mobIDfromGUID[sourceGUID], mobIDfromGUID[destGUID]
-- get mobName from either sourceName or destName
if bossNPCID[mobIDa] then
mobName = sourceName
elseif bossNPCID[mobIDb] then
mobName = destName
end
---------------------------------------------------
if not bossNPCID[mobIDa] and not bossNPCID[mobIDb] then -- if not in table quit
return
elseif eventType == "UNIT_DIED" and bossNPCID[mobIDb] then -- only register if boss is dest and dead
nokill, mobName = nil
loottrigger = true
self:RegisterEvent("LOOT_OPENED")
return
elseif nokill then
return
end
-- if boss matches and it's the first pull change loot ------------------------
self:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
nokill = true -- flag as pulled but not killed
if not method and not threshold then
method, threshold = GetLootMethod(), GetLootThreshold()
else
return
end
if method ~= "master" then
if threshold ~= 4 then -- set both
SetLootMethod("master", UnitName("player"))
thresholdtrigger = true -- set variable to trigger setlootthreshold
else -- not master, but already epic; set master
SetLootMethod("master", UnitName("player"))
end
elseif threshold ~= 4 then -- if master and not epic, set epic
SetLootThreshold(4)
end
end
function events:PARTY_LOOT_METHOD_CHANGED(event, ...)
if thresholdtrigger then
thresholdtrigger = nil
SetLootThreshold(4)
elseif revertthreshold then
revertthreshold = nil
SetLootThreshold(threshold)
threshold = nil
self:UnregisterEvent(self)
else -- loot method changed manually before kill
local newmethod, newthreshold = GetLootMethod(), GetLootThreshold()
if newmethod ~= "master" then -- changed method
if newmethod ~= method then -- if new method is not stored method, restore threshold and reset
SetLootThreshold(threshold)
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..".")
method, threshold, mobName, nokill = nil
self:UnregisterEvent(self)
else -- restore threshold, no reset
SetLootThreshold(threshold)
method, threshold = nil
end
elseif newthreshold ~= 4 then -- changed threshold
if newthreshold ~= threshold then -- if new threshold is not stored threshold, restore method and reset
if method ~= "master" then
SetLootMethod(method)
end
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..".")
method, threshold, mobName, nokill = nil
self:UnregisterEvent(self)
else -- restore method, no reset
if method ~= "master" then
SetLootMethod(method)
method, threshold = nil
end
end
end
end
end
function events:LOOT_OPENED(event, ...)
if not method or not threshold then
loottrigger = nil
self:UnregisterEvent(self)
self:UnregisterEvent("PARTY_LOOT_METHOD_CHANGED")
elseif loottrigger then
loottrigger = nil
SetLootMethod(method)
method = nil
revertthreshold = true
self:UnregisterEvent(self)
end
end