Code:
local buffNames = {
["Potion of the Mountains"]=true,
["Potion of Mogu Power"]=true,
["Potion of the Jade Serpent"]=true,
["Virmen's Bite"]=true,
}
local spellNames = { -- unsure which one shows in the combat log, so I'm adding both buff name and spell name for the time being
["Potion of the Mountains"]=true,
["Potion of Mogu Power"]=true,
["Master Mana Potion"]=true,
["Potion of Focus"]=true,
["Virmen's Bite"]=true,
["Potion of the Jade Serpent"]=true,
["Master Healing Potion"]=true,
}
local select, table, pairs, tinsert, print =
select, table, pairs, tinsert, print
local GetUnitName, GetInstanceInfo, UnitBuff, GetNumGroupMembers, UnitInRaid =
GetUnitName, GetInstanceInfo, UnitBuff, GetNumGroupMembers, UnitInRaid
local a = CreateFrame("Frame")
local enabled = 'true';
SLASH_PPC1 = '/PPC';
local function SlashCmd(cmd,self)
if (cmd == 'enable') then
enabled = 'true';
DEFAULT_CHAT_FRAME:AddMessage("Prepotcheck Enabled",1,0,0);
elseif (cmd == 'disable') then
enabled = 'false';
DEFAULT_CHAT_FRAME:AddMessage("Prepotcheck Disabled",0,1,0);
else
DEFAULT_CHAT_FRAME:AddMessage("Unknown command. Enter either '/ppc enable' to activate Prepotcheck, or '/ppc disable' to deactivate it.",1,0,0);
end
end
SlashCmdList["PPC"] = SlashCmd;
a:SetScript("OnEvent", function(self, event, ...)
if (enabled == 'true') then
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local subEvent, srcName, spellName = (select(2,...)), (select(5,...)), (select(13,...))
local raidIndex = UnitInRaid(srcName)
if subEvent == "SPELL_CAST_SUCCESS" and spellNames[spellName] and raidIndex then
self.pots = self.pots or {}
self.pots[GetUnitName(("raid%d"):format(raidIndex),true)] = spellName
end
elseif event == "PLAYER_REGEN_DISABLED" then
local n = GetNumGroupMembers()
local nP=(select(5, GetInstanceInfo()))
if nP and (nP >= 10) and (n>0) then
self.pots = self.pots and table.wipe(self.pots) or {}
self.prepots = self.prepots and table.wipe(self.prepots) or {}
for id=1, n do
local uID = ("raid%d"):format(id)
for buffName in pairs(buffNames) do
if UnitBuff(uID, buffName) then
self.prepots[GetUnitName(uID,true)] = true
break
end
end
end
end
elseif event == "PLAYER_REGEN_ENABLED" then
local n = GetNumGroupMembers()
local nP=(select(5, GetInstanceInfo()))
if nP and (nP >= 10) and (n>0) then
local noprepot, noinpot = {}, {}
for id=1, n do
local name = GetUnitName(("raid%d"):format(id),true)
if not self.prepots[name] then tinsert(noprepot, name) end
if not self.pots[name] then tinsert(noinpot, name) end
end
if (#noprepot>0) then
print("Players that did not have a potion buff when combat started: "..table.concat(noprepot, ", "))
else
print("Everyone had a potion buff when combat started!")
end
if (#noinpot>0) then
print("Players that did not use a potion in combat: "..table.concat(noinpot, ", "))
else
print("Everyone used a potion during combat!")
end
end
end
end)
a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
a:RegisterEvent("PLAYER_REGEN_ENABLED")
a:RegisterEvent("PLAYER_REGEN_DISABLED")
DEFAULT_CHAT_FRAME:AddMessage("Prepotcheck loaded - watching for bads.",1,0,0)