Quantcast

Now supports 4.0.1.

Christopher Rosell [10-12-10 - 23:26]
Now supports 4.0.1.
Filename
Kungaloosh.toc
kungaloosh.lua
diff --git a/Kungaloosh.toc b/Kungaloosh.toc
index cbcc20c..268f96f 100644
--- a/Kungaloosh.toc
+++ b/Kungaloosh.toc
@@ -1,4 +1,4 @@
-## Interface: 30300
+## Interface: 40000
 ## Title: Kungaloosh
 ## Notes: Automagic raid marking when tanking
 ## Version: 1.3
diff --git a/kungaloosh.lua b/kungaloosh.lua
index 8637748..63abdeb 100644
--- a/kungaloosh.lua
+++ b/kungaloosh.lua
@@ -1,10 +1,12 @@
 local addonname, addon = ...
 local L = addon.L

+local IsCataclysmClient = select(4, GetBuildInfo()) >= 40000
+
 function addon:Initialize()
-	local events = CreateFrame'Frame'
-	events:SetScript('OnEvent', function(frame, e, ...)
-		if type(self[e]) == 'function' then
+	local events = CreateFrame"Frame"
+	events:SetScript("OnEvent", function(frame, e, ...)
+		if type(self[e]) == "function" then
 			self[e](self, ...)
 		end
 	end)
@@ -12,9 +14,9 @@ function addon:Initialize()
 	function self:RegisterEvent(...) events:RegisterEvent(...) end
 	function self:UnregisterEvent(...) events:UnregisterEvent(...) end

-	self:RegisterEvent'ADDON_LOADED'
-	self:RegisterEvent'PLAYER_ROLES_ASSIGNED'
-	self:RegisterEvent'PLAYER_ENTERING_WORLD'
+	self:RegisterEvent"ADDON_LOADED"
+	self:RegisterEvent"PLAYER_ROLES_ASSIGNED"
+	self:RegisterEvent"PLAYER_ENTERING_WORLD"
 end

 function addon:ADDON_LOADED(name)
@@ -29,17 +31,17 @@ function addon:ADDON_LOADED(name)
 			raid_icons = { 8, 7, 1, 2 },
 		}
 	}
-	self.db = LibStub('AceDB-3.0'):New('KungalooshDB', defaults, true)
+	self.db = LibStub("AceDB-3.0"):New("KungalooshDB", defaults, true)

 	self:CreateConfig()

-	self:UnregisterEvent'ADDON_LOADED'
+	self:UnregisterEvent"ADDON_LOADED"

 	self:EnableIfTank()
 end

 function addon:Print(...)
-	print('|cFF33FF99Kungaloosh|r '..string.format(...))
+	print("|cFF33FF99Kungaloosh|r "..string.format(...))
 end

 function addon:PLAYER_ROLES_ASSIGNED()
@@ -61,7 +63,7 @@ function addon:UNIT_THREAT_LIST_UPDATE(unit)
 	local icon = self:GetRaidIconByGUID(guid) or self:GetNextIcon()

 	if icon and GetRaidTargetIndex(unit) == nil then
-		local istanking, status, threatpct, rawthreatpct, threat = UnitDetailedThreatSituation('player', unit)
+		local istanking, status, threatpct, rawthreatpct, threat = UnitDetailedThreatSituation("player", unit)

 		if threat and threat > (self:GetMinThreat() * 100) then
 			SetRaidTarget(unit, icon)
@@ -70,7 +72,7 @@ function addon:UNIT_THREAT_LIST_UPDATE(unit)
 end

 function addon:COMBAT_LOG_EVENT(timestamp, event, sguid, sname, sflags, dguid, dname, dflags)
-	if event == 'UNIT_DIED' then
+	if event == "UNIT_DIED" then
 		local icon = self:GetRaidIconByGUID(dguid)
 		if icon then
 			self.iconguids[icon] = nil
@@ -105,19 +107,19 @@ local function CheckUnit(unit)
 end

 function addon:RAID_TARGET_UPDATE()
-	CheckUnit'player'
-	CheckUnit'target'
-	CheckUnit'pet'
-	CheckUnit'pettarget'
+	CheckUnit"player"
+	CheckUnit"target"
+	CheckUnit"pet"
+	CheckUnit"pettarget"

 	for i = 1,40 do
 		if i <= 5 then
-			CheckUnit('party'..i)
-			CheckUnit('party'..i..'target')
+			CheckUnit("party"..i)
+			CheckUnit("party"..i.."target")
 		end

-		CheckUnit('raid'..i)
-		CheckUnit('raid'..i..'target')
+		CheckUnit("raid"..i)
+		CheckUnit("raid"..i.."target")
 	end
 end

@@ -148,7 +150,7 @@ end

 function addon:GetMinThreat()
 	if self.db.profile.dynamic_minthreat then
-		local level = UnitLevel'player'
+		local level = UnitLevel"player"

 		return (level * level) * 1.2
 	else
@@ -158,15 +160,21 @@ end

 function addon:EnableIfTank()
 	if self.db.profile.enabled_in.dungeon then
-		local istank, ishealer, isdamage = UnitGroupRolesAssigned'player'
+		local istank
+		if IsCataclysmClient then
+			istank = UnitGroupRolesAssigned"player" == "TANK"
+		else
+			istank, _, _ = UnitGroupRolesAssigned"player"
+		end
+
 		if istank then
-			return self:Enable(L['is now enabled since you are assigned as a tank'])
+			return self:Enable(L["is now enabled since you are assigned as a tank"])
 		end
 	end

 	if self.db.profile.enabled_in.raid then
-		if GetPartyAssignment('MAINTANK', 'player') then
-			return self:Enable(L['is now enabled since you are assigned as a tank'])
+		if GetPartyAssignment("MAINTANK", "player") == 1 then
+			return self:Enable(L["is now enabled since you are assigned as a tank"])
 		end
 	end

@@ -176,10 +184,10 @@ end
 function addon:Enable(msg)
 	if self.enabled then return end

-	self:RegisterEvent'PLAYER_REGEN_ENABLED'
-	self:RegisterEvent'UNIT_THREAT_LIST_UPDATE'
-	self:RegisterEvent'RAID_TARGET_UPDATE'
-	self:RegisterEvent'COMBAT_LOG_EVENT'
+	self:RegisterEvent"PLAYER_REGEN_ENABLED"
+	self:RegisterEvent"UNIT_THREAT_LIST_UPDATE"
+	self:RegisterEvent"RAID_TARGET_UPDATE"
+	self:RegisterEvent"COMBAT_LOG_EVENT"
 	self.enabled = true

 	self:ResetState()
@@ -190,10 +198,10 @@ end
 function addon:Disable(msg)
 	if not self.enabled then return end

-	self:UnregisterEvent'PLAYER_REGEN_ENABLED'
-	self:UnregisterEvent'UNIT_THREAT_LIST_UPDATE'
-	self:UnregisterEvent'RAID_TARGET_UPDATE'
-	self:UnregisterEvent'COMBAT_LOG_EVENT'
+	self:UnregisterEvent"PLAYER_REGEN_ENABLED"
+	self:UnregisterEvent"UNIT_THREAT_LIST_UPDATE"
+	self:UnregisterEvent"RAID_TARGET_UPDATE"
+	self:UnregisterEvent"COMBAT_LOG_EVENT"
 	self.enabled = false

 	if msg then self:Print(msg) end
@@ -201,9 +209,9 @@ end

 function addon:Toggle()
 	if not self.enabled then
-		self:Enable(L['is now enabled'])
+		self:Enable(L["is now enabled"])
 	else
-		self:Disable(L['is now disabled'])
+		self:Disable(L["is now disabled"])
 	end
 end

@@ -213,5 +221,5 @@ end

 addon:Initialize()

-_G['SLASH_KUNGALOOSH1'] = '/kungaloosh'
-_G['SLASH_KUNGALOOSH2'] = '/kl'
+_G["SLASH_KUNGALOOSH1"] = "/kungaloosh"
+_G["SLASH_KUNGALOOSH2"] = "/kl"