Quantcast

v0.3

Pawel [05-16-15 - 15:48]
v0.3
Filename
Media/TDIconAlert.tga
Media/TDIconAlertAnts.tga
Modules/TDWarriorDps.lua
Modules/module.lua.template
TDButtons.lua
TDDps.lua
TDDps.toc
TDHelper.lua
diff --git a/Media/TDIconAlert.tga b/Media/TDIconAlert.tga
deleted file mode 100644
index 87ce00e..0000000
Binary files a/Media/TDIconAlert.tga and /dev/null differ
diff --git a/Media/TDIconAlertAnts.tga b/Media/TDIconAlertAnts.tga
deleted file mode 100644
index 447923b..0000000
Binary files a/Media/TDIconAlertAnts.tga and /dev/null differ
diff --git a/Modules/TDWarriorDps.lua b/Modules/TDWarriorDps.lua
deleted file mode 100644
index d040305..0000000
--- a/Modules/TDWarriorDps.lua
+++ /dev/null
@@ -1,132 +0,0 @@
--- Author      : Kaminari
--- Create Date : 13:03 2015-04-20
-
-local _Bloodthirst		= 23881;
-local _WildStrike		= 100130;
-local _RagingBlow		= 85288;
-local _Execute			= 5308;
-local _BladeStorm		= 46924;
-local _StormBolt		= 107570;
-local _DragonRoar		= 118000;
-local _BerserkerRage	= 18499;
-local _Ravager			= 152277;
-local _Recklessness		= 1719;
-
--- auras
-local _Enrage			= 12880;
-local _Bloodsurge		= 46916
-local _SuddenDeath		= 29725
-local _RagingBlowAura	= 131116
-
--- talents
-local _isSuddenDeath = false;
-local _isUnquenchableThirst = false;
-local _isStormBolt = false;
-local _isDragonRoar = false;
-local _isUnquenchableThirst = false;
-local _isRavager = false;
-local _rageMax = 100;
-
---flags
-local _RecklessnessHigh = false;
-
-----------------------------------------------
--- Pre enable, checking talents
-----------------------------------------------
-TDWarriorDps_CheckTalents = function()
-	_isSuddenDeath = TDTalentEnabled("Sudden Death");
-	_isUnquenchableThirst = TDTalentEnabled("Unquenchable Thirst");
-	_isRavager = TDTalentEnabled("Ravager");
-	_isStormBolt = TDTalentEnabled("Storm Bolt");
-	_isDragonRoar = TDTalentEnabled("Dragon Roar");
-
-	_rageMax = UnitPowerMax('player', SPELL_POWER_RAGE);
-end
-
-----------------------------------------------
--- Enabling Addon
-----------------------------------------------
-function TDWarriorDps_EnableAddon(mode)
-	mode = mode or 1;
-	_TD["DPS_Description"] = "TD Warrior DPS supports: Fury";
-	_TD["DPS_OnEnable"] = TDWarriorDps_CheckTalents;
-	if mode == 1 then
-		_TD["DPS_NextSpell"] = TDWarriorDps_Fury
-	end;
-	TDDps_EnableAddon();
-end
-
-----------------------------------------------
--- Main rotation: Elemental
-----------------------------------------------
-TDWarriorDps_Fury = function()
-
-	local lcd, currentSpell = TDEndCast();
-
-	local berserRage = TDDps_SpellCooldown(_BerserkerRage, lcd);
-	local ravager = TDDps_SpellCooldown(_Ravager, lcd);
-	local sb = TDDps_SpellCooldown(_StormBolt, lcd);
-	local dr = TDDps_SpellCooldown(_DragonRoar, lcd);
-	local reck = TDDps_SpellCooldown(_Recklessness, lcd);
-	local enrage = TDAura(_Enrage);
-	local rb, rbCount = TDAura(_RagingBlowAura);
-	local rage = UnitPower('player', SPELL_POWER_RAGE);
-	local bs = TDAura(_Bloodsurge);
-	local sd = TDAura(_SuddenDeath);
-
-	local ph = TD_TargetPercentHealth();
-
-	if _Recklessness and not _RecklessnessHigh then
-		TDGlowIndependent(_Recklessness, 'reck');
-		_RecklessnessHigh = true;
-	elseif _RecklessnessHigh then
-		TDClearGlowIndependent(_Recklessness, 'reck');
-		_RecklessnessHigh = false;
-	end
-
-	if berserRage and not enrage then
-		return _BerserkerRage;
-	end
-
-	if (rage/_rageMax) >= 0.9 and ph > 0.2 then
-		return _WildStrike;
-	end
-
-	if sd then
-		return _Execute;
-	end
-
-	if rbCount >= 2 and ph > 0.2 then
-		return _RagingBlow;
-	end
-
-	if not enrage and (_isUnquenchableThirst or rage < 80) then
-		return _Bloodthirst;
-	end
-
-	if _isRavager and ravager then
-		return _Ravager;
-	end
-
-	if _isStormBolt and sb then
-		return _StormBolt;
-	end
-
-	if _isDragonRoar and dr then
-		return _DragonRoar;
-	end
-
-	if rage >= 30 and ph < 0.2 and enrage then
-		return _Execute;
-	end
-
-	if bs then
-		return _WildStrike;
-	end
-
-	if rbCount > 0 then
-		return _RagingBlow;
-	end
-
-	return _Bloodthirst;
-end
\ No newline at end of file
diff --git a/Modules/module.lua.template b/Modules/module.lua.template
new file mode 100644
index 0000000..5a96e74
--- /dev/null
+++ b/Modules/module.lua.template
@@ -0,0 +1,71 @@
+-- Author      : Kaminari
+-- Create Date : 13:03 2015-04-20
+
+-- Spells
+local _Spell			= 23881;
+
+-- Auras
+local _Aura				= 12880;
+
+-- Talents
+local _isTalent = false;
+
+-- Flags for glow independent
+local _FlagHigh = false;
+
+----------------------------------------------
+-- Pre enable, checking talents
+----------------------------------------------
+TDDps_[Class]_CheckTalents = function()
+	_isTalent = TDTalentEnabled('Talent Name');
+	-- other checking functions
+end
+
+----------------------------------------------
+-- Enabling Addon
+----------------------------------------------
+function TDDps_[Class]_EnableAddon(mode)
+	mode = mode or 1;
+	_TD["DPS_Description"] = "TD [Class] DPS supports: [Spec1], [Spec2], [Spec3]";
+	_TD["DPS_OnEnable"] = TDDps_[Class]_CheckTalents;
+	if mode == 1 then
+		_TD["DPS_NextSpell"] = TDDps_[Class]_[Spec1];
+	end;
+	if mode == 2 then
+		_TD["DPS_NextSpell"] = TDDps_[Class]_[Spec2];
+	end;
+	if mode == 3 then
+		_TD["DPS_NextSpell"] = TDDps_[Class]_[Spec3];
+	end;
+	TDDps_EnableAddon();
+end
+
+----------------------------------------------
+-- Main rotation: [Spec1]
+----------------------------------------------
+TDDps_[Class]_[Spec1] = function()
+
+	local lcd, currentSpell = TDEndCast();
+
+	return _Spell;
+end
+
+----------------------------------------------
+-- Main rotation: [Spec2]
+----------------------------------------------
+TDDps_[Class]_[Spec2] = function()
+
+	local lcd, currentSpell = TDEndCast();
+
+	return _Spell;
+end
+
+----------------------------------------------
+-- Main rotation: [Spec3]
+----------------------------------------------
+TDDps_[Class]_[Spec3] = function()
+
+	local lcd, currentSpell = TDEndCast();
+
+	return _Spell;
+end
\ No newline at end of file
diff --git a/TDButtons.lua b/TDButtons.lua
index ab793bf..30b40c7 100644
--- a/TDButtons.lua
+++ b/TDButtons.lua
@@ -1,69 +1,33 @@

-local numtdOverlays = 0;
-local TDActionSpells = {};
-local TDActionSpellsGlowing = {};
+local TDButton_Spells = {};
+local TDButton_SpellsGlowing = {};

 ----------------------------------------------
 -- Show Overlay on button
 ----------------------------------------------
-function TDActionButton_ShowOverlayGlow(self)
-	if ( self.tdOverlay ) then
-		self.tdOverlay:Show();
-	else
-		numtdOverlays = numtdOverlays + 1;
-		self.tdOverlay = CreateFrame("Frame", "ActionButtonTdOverlay" .. numtdOverlays, UIParent);
-
-		self.tdOverlay:SetParent(self);
-		self.tdOverlay:SetFrameStrata("HIGH")
-		self.tdOverlay:SetWidth(self:GetWidth() * 1.4)
-		self.tdOverlay:SetHeight(self:GetHeight() * 1.4)
-
-		local t = self.tdOverlay:CreateTexture(nil,"OVERLAY")
-		t:SetTexture("Interface\\Cooldown\\ping4")
-		t:SetBlendMode("ADD");
-		t:SetAllPoints(self.tdOverlay);
-		self.tdOverlay.texture = t;
-
-		self.tdOverlay:SetPoint("CENTER",0,0);
-		self.tdOverlay:Show();
-	end
-end
-
-----------------------------------------------
--- Hide Overlay on button
-----------------------------------------------
-function TDActionButton_HideOverlayGlow(self)
-	if ( self.tdOverlay ) then
-		self.tdOverlay:Hide();
-	end
-end
-
-
-----------------------------------------------
--- Show Overlay on button
-----------------------------------------------
-function TDActionButton_Glow(self, id, r, g, b)
-	if ( self.tdOverlays and self.tdOverlays[id] ) then
+function TDButton_Glow(self, id, r, g, b, texture)
+	if (self.tdOverlays and self.tdOverlays[id]) then
 		self.tdOverlays[id]:Show();
 	else
 		if not self.tdOverlays then
 			self.tdOverlays = {};
 		end
-		self.tdOverlays[id] = CreateFrame("Frame", "ActionButtonTdOverlays" .. id, UIParent);
+		texture = texture or 'Interface\\Cooldown\\ping4';
+		self.tdOverlays[id] = CreateFrame('Frame', 'TDButton_Overlay_' .. id, UIParent);

 		self.tdOverlays[id]:SetParent(self);
-		self.tdOverlays[id]:SetFrameStrata("HIGH")
+		self.tdOverlays[id]:SetFrameStrata('HIGH')
 		self.tdOverlays[id]:SetWidth(self:GetWidth() * 1.4)
 		self.tdOverlays[id]:SetHeight(self:GetHeight() * 1.4)

-		local t = self.tdOverlays[id]:CreateTexture(nil, "OVERLAY")
-		t:SetTexture("Interface\\Cooldown\\ping4")
-		t:SetBlendMode("ADD");
+		local t = self.tdOverlays[id]:CreateTexture(nil, 'OVERLAY')
+		t:SetTexture(texture)
+		t:SetBlendMode('ADD');
 		t:SetAllPoints(self.tdOverlays[id]);
 		t:SetVertexColor(r or 1, g or 0, b or 0);
 		self.tdOverlays[id].texture = t;

-		self.tdOverlays[id]:SetPoint("CENTER",0,0);
+		self.tdOverlays[id]:SetPoint('CENTER',0,0);
 		self.tdOverlays[id]:Show();
 	end
 end
@@ -71,8 +35,8 @@ end
 ----------------------------------------------
 -- Hide Overlay on button
 ----------------------------------------------
-function TDActionButton_HideGlow(self, id)
-	if ( self.tdOverlays[id] ) then
+function TDButton_HideGlow(self, id)
+	if (self.tdOverlays[id]) then
 		self.tdOverlays[id]:Hide();
 	end
 end
@@ -80,19 +44,19 @@ end
 ----------------------------------------------
 -- Fetch button spells
 ----------------------------------------------
-function TDFetchActions()
-	TDGlowClear();
-	TDActionSpells = {};
-	TDActionSpellsGlowing = {};
+function TDButton_Fetch()
+	TDButton_GlowClear();
+	TDButton_Spells = {};
+	TDButton_SpellsGlowing = {};
 	local isBartender = IsAddOnLoaded('Bartender4');
 	local isElv = IsAddOnLoaded('ElvUI');

 	if (isBartender) then
-		TDFetchActionsBartender4();
+		TDButton_FetchBartender4();
 	elseif (isElv) then
-		TDFetchActionsElvUI();
+		TDButton_FetchElvUI();
 	else
-		TDFetchActionsBlizzard();
+		TDButton_FetchBlizzard();
 	end
 	print('TDDps: fetched action bars!');
 end
@@ -100,7 +64,7 @@ end
 ----------------------------------------------
 -- Button spells on original blizzard UI
 ----------------------------------------------
-function TDFetchActionsBlizzard()
+function TDButton_FetchBlizzard()
 	local TDActionBarsBlizzard = {'Action', 'MultiBarBottomLeft', 'MultiBarBottomRight', 'MultiBarRight', 'MultiBarLeft'};
     for _, barName in pairs(TDActionBarsBlizzard) do
        for i = 1, 12 do
@@ -116,11 +80,11 @@ function TDFetchActionsBlizzard()
                 actionName = GetSpellInfo(id);
              end
              if actionName then
-                if TDActionSpells[actionName] == nil then
-                   TDActionSpells[actionName] = {};
+                if TDButton_Spells[actionName] == nil then
+                   TDButton_Spells[actionName] = {};
                 end

-                tinsert(TDActionSpells[actionName], button);
+                tinsert(TDButton_Spells[actionName], button);
              end
           end
        end
@@ -130,7 +94,7 @@ end
 ----------------------------------------------
 -- Button spells on ElvUI
 ----------------------------------------------
-function TDFetchActionsElvUI()
+function TDButton_FetchElvUI()
 	local ret = false;
 	for x = 1, 10 do
 		for i = 1, 12 do
@@ -140,11 +104,11 @@ function TDFetchActionsElvUI()
 				if spellId then
 					local actionName, _ = GetSpellInfo(spellId);
 					if actionName then
-						if TDActionSpells[actionName] == nil then
-							TDActionSpells[actionName] = {};
+						if TDButton_Spells[actionName] == nil then
+							TDButton_Spells[actionName] = {};
 						end
 						ret = true;
-						tinsert(TDActionSpells[actionName], button);
+						tinsert(TDButton_Spells[actionName], button);
 					end
 				end
 			end
@@ -156,7 +120,7 @@ end
 ----------------------------------------------
 -- Button spells on Bartender4
 ----------------------------------------------
-function TDFetchActionsBartender4()
+function TDButton_FetchBartender4()
 	local ret = false;
 	for i = 1, 120 do
 		local button = _G['BT4Button' .. i];
@@ -166,11 +130,11 @@ function TDFetchActionsBartender4()
 				local actionName, _ = GetSpellInfo(spellId);
 				print(actionName, spellId);
 				if actionName then
-					if TDActionSpells[actionName] == nil then
-						TDActionSpells[actionName] = {};
+					if TDButton_Spells[actionName] == nil then
+						TDButton_Spells[actionName] = {};
 					end
 					ret = true;
-					tinsert(TDActionSpells[actionName], button);
+					tinsert(TDButton_Spells[actionName], button);
 				end
 			end
 		end
@@ -181,28 +145,20 @@ end
 ----------------------------------------------
 -- Dump spells for debug
 ----------------------------------------------
-function TDDumpSpells()
-	for k, button in pairs(TDActionSpells) do
+function TDButton_Dump()
+	for k, button in pairs(TDButton_Spells) do
 		print(k, button:GetName());
 	end
 end

 ----------------------------------------------
--- Glow spell by id
-----------------------------------------------
-function TDGlowSpellId(spellId)
-	local name = GetSpellInfo(spellId);
-    TDGlowSpell(name);
-end
-
-----------------------------------------------
 -- Glow independent button by spell name
 ----------------------------------------------
-function TDGlowIndependent(spellName, id, r, g, b)
+function TDButton_GlowIndependent(spellName, id, r, g, b, texture)
 	local name = GetSpellInfo(spellName) or spellName;
-	if TDActionSpells[name] ~= nil then
-		for k, button in pairs(TDActionSpells[name]) do
-			TDActionButton_Glow(button, id, r, g, b);
+	if TDButton_Spells[name] ~= nil then
+		for k, button in pairs(TDButton_Spells[name]) do
+			TDActionButton_Glow(button, id, r, g, b, texture);
 		end
 	end
 end
@@ -210,9 +166,9 @@ end
 ----------------------------------------------
 -- Clear glow independent button by spell name
 ----------------------------------------------
-function TDClearGlowIndependent(spellName, id)
+function TDButton_ClearGlowIndependent(spellName, id)
 	local name = GetSpellInfo(spellName) or spellName;
-	for k, button in pairs(TDActionSpells[name]) do
+	for k, button in pairs(TDButton_Spells[name]) do
 		TDActionButton_HideGlow(button, id);
 	end
 end
@@ -220,42 +176,50 @@ end
 ----------------------------------------------
 -- Glow spell by name
 ----------------------------------------------
-function TDGlowSpell(spellName)
-    if TDActionSpells[spellName] ~= nil then
-        for k, button in pairs(TDActionSpells[spellName]) do
-            TDActionButton_ShowOverlayGlow(button);
-        end
-        TDActionSpellsGlowing[spellName] = 1;
-    end
+function TDButton_GlowSpell(spellName)
+	if TDButton_Spells[spellName] ~= nil then
+		for k, button in pairs(TDButton_Spells[spellName]) do
+			TDButton_Glow(button, 'next');
+		end
+		TDButton_SpellsGlowing[spellName] = 1;
+	end
+end
+
+----------------------------------------------
+-- Glow spell by id
+----------------------------------------------
+function TDButton_GlowSpellId(spellId)
+	local name = GetSpellInfo(spellId);
+	TDButton_GlowSpell(name);
 end

 ----------------------------------------------
 -- Glow next spell by name
 ----------------------------------------------
-function TDGlowNextSpell(spellName)
-    TDGlowClear();
-    TDGlowSpell(spellName);
+function TDButton_GlowNextSpell(spellName)
+    TDButton_GlowClear();
+    TDButton_GlowSpell(spellName);
 end

 ----------------------------------------------
 -- Glow next spell by id
 ----------------------------------------------
-function TDGlowNextSpellId(spellId)
+function TDButton_GlowNextSpellId(spellId)
 	local spellName = GetSpellInfo(spellId);
-    TDGlowClear();
-    TDGlowSpell(spellName);
+    TDButton_GlowClear();
+    TDButton_GlowSpell(spellName);
 end

 ----------------------------------------------
 -- Clear all spell glows
 ----------------------------------------------
-function TDGlowClear()
-    for spellName, v in pairs(TDActionSpellsGlowing) do
+function TDButton_GlowClear()
+    for spellName, v in pairs(TDButton_SpellsGlowing) do
         if v == 1 then
-            for k, button in pairs(TDActionSpells[spellName]) do
-                TDActionButton_HideOverlayGlow(button);
+            for k, button in pairs(TDButton_Spells[spellName]) do
+                TDButton_HideGlow(button, 'next');
             end
-            TDActionSpellsGlowing[spellName] = 0;
+            TDButton_SpellsGlowing[spellName] = 0;
         end
     end
 end
@@ -263,11 +227,11 @@ end
 ----------------------------------------------
 -- Frame init
 ----------------------------------------------
-local TDButtonsFrame = CreateFrame("FRAME", "TDButtonsFrame");
-TDButtonsFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
+local TDButton_Frame = CreateFrame('FRAME', 'TDButton_Frame');
+TDButton_Frame:RegisterEvent('PLAYER_ENTERING_WORLD');

-local function eventHandler(self, event, ...)
-	TDFetchActions();
+local function TDButton_EventHandler(self, event, ...)
+	TDButton_Fetch();
 end

-TDButtonsFrame:SetScript("OnEvent", eventHandler);
\ No newline at end of file
+TDButton_Frame:SetScript('OnEvent', TDButton_EventHandler);
\ No newline at end of file
diff --git a/TDDps.lua b/TDDps.lua
index 52be120..ab8faf3 100644
--- a/TDDps.lua
+++ b/TDDps.lua
@@ -1,15 +1,15 @@
 _TD = _TD or {};

-_TD["DPS_Enabled"] 	= 0;
-_TD["DPS_OnEnable"] = nil;
-_TD["DPS_NextSpell"] = nil;
-_TD["DPS_Description"] = "";
-_TD["DPS_Mode"] = 1;
+_TD['DPS_Enabled'] 	= 0;
+_TD['DPS_OnEnable'] = nil;
+_TD['DPS_NextSpell'] = nil;
+_TD['DPS_Description'] = '';
+_TD['DPS_Mode'] = 1;

 DPS_Skill = nil;

 local _DPS_time = 0;
-local TDDps_Frame = CreateFrame("frame");
+local TDDps_Frame = CreateFrame('frame');

 ----------------------------------------------
 -- Disable dps addon functionality
@@ -18,13 +18,13 @@ function TDDps_DisableAddon()
 	TDDps_Frame:Hide();

 	TDDps_Frame:UnregisterAllEvents();
-	TDDps_Frame:SetScript("OnUpdate", nil);
-	TDDps_Frame:SetScript("OnEvent", nil);
+	TDDps_Frame:SetScript('OnUpdate', nil);
+	TDDps_Frame:SetScript('OnEvent', nil);

-	print(_TD["DPS_Description"]);
+	print(_TD['DPS_Description']);

 	DPS_Skill = nil;
-	_TD["DPS_Enabled"] = 0;
+	_TD['DPS_Enabled'] = 0;
 end

 ----------------------------------------------
@@ -35,32 +35,32 @@ function TDDps_EnableAddon(mode)

 	print('enabling');

-	if _TD["DPS_NextSpell"] == nil then
-		print("TDDPS: No addon selected, cannot enable");
+	if _TD['DPS_NextSpell'] == nil then
+		print('TDDPS: No addon selected, cannot enable');
 		return;
 	end

-	if _TD["DPS_Enabled"] == 1 then
+	if _TD['DPS_Enabled'] == 1 then
 		return;
 	end

-	_TD["DPS_Mode"] = mode;
+	_TD['DPS_Mode'] = mode;

 	TDDps_Frame:Show();

-	TDDps_Frame:RegisterEvent("PLAYER_TARGET_CHANGED");
-	TDDps_Frame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED");
-
-	TDFetchActions();
+	TDDps_Frame:RegisterEvent('PLAYER_TARGET_CHANGED');
+	TDDps_Frame:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED');
+
+	TDButton_Fetch();

-	if _TD["DPS_OnEnable"] then
-		_TD["DPS_OnEnable"]();
+	if _TD['DPS_OnEnable'] then
+		_TD['DPS_OnEnable']();
 	end

-	TDDps_Frame:SetScript("OnUpdate", TDDps_OnUpdate);
-	TDDps_Frame:SetScript("OnEvent", TDDps_OnEvent);
+	TDDps_Frame:SetScript('OnUpdate', TDDps_OnUpdate);
+	TDDps_Frame:SetScript('OnEvent', TDDps_OnEvent);

-	_TD["DPS_Enabled"] = 1;
+	_TD['DPS_Enabled'] = 1;
 	print('enabled');
 end

@@ -71,15 +71,10 @@ function TDDps_InvokeNextSpell()
 	-- invoke spell check
 	local oldSkill = DPS_Skill;

-	DPS_Skill = _TD["DPS_NextSpell"]();
-
+	DPS_Skill = _TD['DPS_NextSpell']();
+
 	if (oldSkill ~= DPS_Skill or oldSkill == nil) and DPS_Skill ~= nil then
-
-		TDGlowNextSpellId(DPS_Skill);
-
-		if _TD["DPS_Debug"] then
-			print ('skill: '..DPS_Skill);
-		end
+		TDButton_GlowNextSpellId(DPS_Skill);
 	end
 end

@@ -87,14 +82,14 @@ end
 -- Event Script, Target Change, Specializaton Change
 ----------------------------------------------
 function TDDps_OnEvent(event)
-	if event == "PLAYER_TARGET_CHANGED" then
-		if (UnitIsFriend("player", "target")) then
+	if event == 'PLAYER_TARGET_CHANGED' then
+		if (UnitIsFriend('player', 'target')) then
 			TDGlowClear();
 			return;
 		else
 			TDDps_InvokeNextSpell();
 		end
-	elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
+	elseif event == 'ACTIVE_TALENT_GROUP_CHANGED' then
 		TDDps_CheckPlayer();
 	end
 end
@@ -108,4 +103,29 @@ function TDDps_OnUpdate(self, elapsed)
 		_DPS_time = 0;
 		TDDps_InvokeNextSpell();
     end
-end
\ No newline at end of file
+end
+
+----------------------------------------------
+-- Load appropriate addon for class
+----------------------------------------------
+function TDDps_LoadModule()
+	local class = UnitClass('player');
+	class = class:gsub(' ', '');
+	local module = 'TDDps_' .. class;
+
+	if not IsAddOnLoaded(module) then
+		LoadAddOn(module)
+	end
+
+	if not IsAddOnLoaded(module) then
+		print('TDDps: Could not find class module.');
+		return;
+	end
+
+	local mode = GetSpecialization();
+	local init = module .. '_EnableAddon';
+
+	_G[init](mode);
+end
+
+-- PLAYER_ALIVE
\ No newline at end of file
diff --git a/TDDps.toc b/TDDps.toc
index 11c0a40..832a6b7 100644
--- a/TDDps.toc
+++ b/TDDps.toc
@@ -1,4 +1,5 @@
 ## Title: TDDps
+## Notes: Rotation helper framework.
 ## Version: 1.0
 ## Author: Kaminari
 ## Interface: 60000
diff --git a/TDHelper.lua b/TDHelper.lua
index 3015152..0897b29 100644
--- a/TDHelper.lua
+++ b/TDHelper.lua
@@ -1,8 +1,11 @@

+-- Global cooldown spell id
+_GlobalCooldown = 61304;
+
 ----------------------------------------------
 -- Current Specialisation name
 ----------------------------------------------
-function TDSpecName()
+function TD_SpecName()
 	local currentSpec = GetSpecialization();
 	local currentSpecName = currentSpec and select(2, GetSpecializationInfo(currentSpec)) or "None";
 	return currentSpecName;
@@ -11,7 +14,7 @@ end
 ----------------------------------------------
 -- Is talent enabled
 ----------------------------------------------
-function TDTalentEnabled(talent)
+function TD_TalentEnabled(talent)
 	local found = false;
 	for i=1,7 do
 		for j=1,3 do
@@ -27,7 +30,7 @@ end
 ----------------------------------------------
 -- Is aura on player
 ----------------------------------------------
-function TDAura(name, atLeast)
+function TD_Aura(name, atLeast)
 	atLeast = atLeast or 0.2;
 	local spellName = GetSpellInfo(name);
 	local _, _, _, count, _, _, expirationTime = UnitAura("player", spellName);
@@ -41,7 +44,7 @@ end
 ----------------------------------------------
 -- Is aura on target
 ----------------------------------------------
-function TDTargetAura(name, TMinus)
+function TD_TargetAura(name, TMinus)
 	TMinus = TMinus or 0;
 	local spellName = GetSpellInfo(name) or name;
 	local _, _, _, _, _, _, expirationTime = UnitAura("target", spellName, nil, 'PLAYER|HARMFUL');
@@ -54,13 +57,17 @@ end
 ----------------------------------------------
 -- When current cast will end
 ----------------------------------------------
-function TDEndCast()
-	local c = GetTime()*1000;
+function TD_EndCast()
+	local t = GetTime();
+	local c = t*1000;
 	local spell, _, _, _, _, endTime = UnitCastingInfo("player");
+	local gstart, gduration = GetSpellCooldown(_GlobalCooldown);
+	local gcd = gduration - (t - gstart);
+	if gcd < 0 then gcd = 0; end;
 	if endTime == nil then
-		return 0, "";
+		return 0, "", gcd;
 	end
-	return (endTime - c)/1000, spell;
+	return (endTime - c)/1000, spell, gcd;
 end

 ----------------------------------------------
@@ -81,7 +88,7 @@ end
 ----------------------------------------------
 -- Simple calculation of global cooldown
 ----------------------------------------------
-function TDDps_GlobalCooldown()
+function TD_GlobalCooldown()
 	local haste = UnitSpellHaste("player");
 	local gcd = 1.5 / ((haste / 100) + 1);
 	if gcd < 1 then
@@ -94,7 +101,7 @@ end
 ----------------------------------------------
 -- Stacked spell CD, charges and max charges
 ----------------------------------------------
-function TDDps_SpellCharges(spell)
+function TD_SpellCharges(spell)
 	local currentCharges, maxCharges, cooldownStart, cooldownDuration = GetSpellCharges(spell);
 	local cd = cooldownDuration - (GetTime() - cooldownStart);
 	if cd > cooldownDuration then
@@ -106,28 +113,32 @@ end
 ----------------------------------------------
 -- Is Spell Available
 ----------------------------------------------
-function TDDps_SpellCooldown(spell, minus)
-	minus = minus or 0;
-	local start, duration, enabled = GetSpellCooldown(spell);
-	if enabled and duration == 0 and start == 0 then
-		return true;
-	elseif enabled then
-		return (duration - (GetTime() - start) - minus) < 0.1;
-	else
-		return false;
-	end;
+function TD_SpellAvailable(spell, minus)
+	local cd = TD_Cooldown(spell, minus);
+	return cd <= 0, cd;
 end

+
 ----------------------------------------------
--- Real spell cooldown
+-- Spell Cooldown
 ----------------------------------------------
-function TDDps_SpellCooldownReal(spell)
+function TD_Cooldown(spell, minus)
+	minus = minus or 0;
 	local start, duration, enabled = GetSpellCooldown(spell);
 	if enabled and duration == 0 and start == 0 then
 		return 0;
 	elseif enabled then
-		return (duration - (GetTime() - start));
+		return (duration - (GetTime() - start) - minus);
 	else
-		return false;
+		return 100000;
 	end;
 end
+
+----------------------------------------------
+-- Current or Future Mana Percent
+----------------------------------------------
+function TD_Mana(minus, afterTime)
+	local _, casting = GetManaRegen();
+	local mana = UnitPower("player", 0) - minus + (casting * afterTime);
+	return mana / UnitPowerMax("player", 0), mana;
+end