Quantcast

v7.1.3 - Vehicle and talent fix, print will now obey settings

Pawel [12-16-16 - 03:39]
v7.1.3 - Vehicle and talent fix, print will now obey settings
Filename
MaxDps.toc
core.lua
helper.lua
diff --git a/MaxDps.toc b/MaxDps.toc
index 8b726b3..71a3416 100644
--- a/MaxDps.toc
+++ b/MaxDps.toc
@@ -1,6 +1,6 @@
 ## Title: MaxDps
 ## Notes: Rotation helper framework.
-## Version: 7.1.2
+## Version: 7.1.3
 ## Author: Kaminaris
 ## Interface: 70100
 ## SavedVariables: MaxDpsOptions
diff --git a/core.lua b/core.lua
index 631b04e..85639f2 100644
--- a/core.lua
+++ b/core.lua
@@ -173,6 +173,14 @@ function MaxDps:OnInitialize()
 	self.optionsFrame = LibStub('AceConfigDialog-3.0'):AddToBlizOptions('MaxDps', 'MaxDps');
 end

+MaxDps.DefaultPrint = MaxDps.Print;
+function MaxDps:Print(...)
+	if self.db.global.disabledInfo then
+		return;
+	end
+	MaxDps:DefaultPrint(...);
+end
+
 function MaxDps:EnableRotation()
 	self:Print(self.Colors.Info .. 'Enabling');

@@ -232,6 +240,9 @@ function MaxDps:OnEnable()
 	self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED');
 	self:RegisterEvent('UPDATE_MACROS');
 	self:RegisterEvent('VEHICLE_UPDATE');
+
+	self:RegisterEvent('UNIT_ENTERED_VEHICLE');
+	self:RegisterEvent('UNIT_EXITED_VEHICLE');
 	--	self:RegisterEvent('PLAYER_REGEN_ENABLED');

 	self:Print(self.Colors.Info .. 'Initialized');
@@ -241,6 +252,18 @@ function MaxDps:PLAYER_TALENT_UPDATE()
 	self:DisableRotation();
 end

+function MaxDps:UNIT_ENTERED_VEHICLE(event, unit)
+	if unit == 'player' and self.rotationEnabled then
+		self:DisableRotation();
+	end
+end
+
+function MaxDps:UNIT_EXITED_VEHICLE(event, unit)
+	if unit == 'player' and self.ModuleLoaded then
+		self:EnableRotation();
+	end
+end
+
 function MaxDps:PLAYER_ENTERING_WORLD()
 	self:UpdateButtonGlow();
 end
diff --git a/helper.lua b/helper.lua
index 30ddfc8..5e4522b 100644
--- a/helper.lua
+++ b/helper.lua
@@ -21,6 +21,28 @@ function MaxDps:SpecName()
 	return currentSpecName;
 end

+function MaxDps:CheckTalents()
+	self.PlayerTalents = {};
+	self.PlayerSpec = GetActiveSpecGroup();
+	for talentRow = 1, 7 do
+		for talentCol = 1, 3 do
+			local _, name, _, sel, _, id = GetTalentInfo(talentRow, talentCol, self.PlayerSpec);
+			if sel then
+				self.PlayerTalents[id] = name;
+			end
+		end
+	end
+end
+
+function MaxDps:HasTalent(talent)
+	for id, name in pairs(self.PlayerTalents) do
+		if id == talent or name == talent then
+			return true;
+		end
+	end
+	return false;
+end
+
 function MaxDps:TalentEnabled(talent)
 	local found = false;
 	for i=1,7 do
@@ -45,7 +67,7 @@ end

 function MaxDps:Aura(name, timeShift)
 	timeShift = timeShift or 0.2;
-	local spellName = GetSpellInfo(name);
+	local spellName = GetSpellInfo(name) or name;
 	local _, _, _, count, _, _, expirationTime = UnitAura('player', spellName);
 	local time = GetTime();
 	if expirationTime ~= nil and (expirationTime - time) > timeShift then
@@ -56,7 +78,7 @@ end

 function MaxDps:UnitAura(name, timeShift, unit)
 	timeShift = timeShift or 0.2;
-	local spellName = GetSpellInfo(name);
+	local spellName = GetSpellInfo(name) or name;
 	local _, _, _, count, _, _, expirationTime = UnitAura(unit, spellName);
 	if expirationTime ~= nil and (expirationTime - GetTime()) > timeShift then
 		return true, count;