Quantcast

- added BuffGain: should be useful for 3.2 moonkin cycle

Sidoine De Wispelaere [06-28-09 - 11:25]
- added BuffGain: should be useful for 3.2 moonkin cycle
- predict energy gain

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@72 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Condition.lua
Ovale.lua
Ovale.toc
OvaleIcone.lua
diff --git a/Condition.lua b/Condition.lua
index 8c5db26..2b685a1 100644
--- a/Condition.lua
+++ b/Condition.lua
@@ -234,6 +234,24 @@ Ovale.conditions=
 			return timeLeft-timeBefore
 		end
 	end,
+	-- Test if a time has elapsed since the last buff gain
+	-- 1 : buff spell id
+	-- 2 : time since the buff gain
+	BuffGain = function(condition)
+		local spell, rank, icon = Ovale:GetSpellInfoOrNil(condition[1])
+		if (spell) then
+			if (not Ovale.buff[spell]) then
+				return 0
+			end
+			local timeGain = Ovale.buff[spell].gain
+			if (not timeGain or (Ovale.maintenant > timeGain + condition[2]) or Ovale.buff[spell].icon~=icon) then
+				return 0
+			else
+				return timeGain + condition[2] - Ovale.maintenant
+			end
+		end
+		return nil
+	end,
 	-- Test if a buff is active
 	-- 1 : the buff spell id
 	-- stacks : minimum number of stacks
@@ -350,6 +368,33 @@ Ovale.conditions=
 	-- 1 : "less" or "more"
 	-- 2 : the mana/energy/rage... limit
 	Mana = function(condition)
+		if (condition[1] == "more") then
+			local _,className = UnitClass("player")
+			if (className == "ROGUE" or (className == "DRUID" and GetShapeshiftForm(true) == 3)) then
+				local current = UnitPower("player")
+				if (current > condition[2]) then
+					return 0
+				else
+					local rate= 10
+					if (className == "ROGUE") then
+						local i=1
+						local rush = Ovale:GetSpellInfoOrNil(13750)
+						while (true) do
+							local name = UnitBuff("player", i)
+							if (not name) then
+								break
+							end
+							if (name == rush) then
+								rate = rate * 2
+								break
+							end
+							i = i + 1
+						end
+					end
+					return (condition[2] - current) / rate
+				end
+			end
+		end
 		return compare(UnitPower("player"), condition[1], condition[2])
 	end,
 	ManaPercent = function(condition)
diff --git a/Ovale.lua b/Ovale.lua
index e295cb8..c244daf 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -29,6 +29,7 @@ Ovale.possibleAura = { player = {}, target = {}}
 Ovale.targetGUID = nil
 Ovale.spellInfo = {}
 Ovale.currentSpellInfo = nil
+Ovale.buff = {}

 Ovale.arbre = {}

@@ -278,6 +279,7 @@ function Ovale:PLAYER_TARGET_CHANGED()
 end
 ]]

+
 function Ovale:UNIT_AURA(event, unit)
 	if (unit == "player") then
 		local hateBase = GetCombatRatingBonus(18)
@@ -288,12 +290,24 @@ function Ovale:UNIT_AURA(event, unit)
 		local hateClasse = 0
 		local i=1;

-
 		while (true) do
-			local name =  UnitBuff("player", i);
+			local name, rank, iconTexture, count, debuffType, duration, expirationTime, source =  UnitBuff("player", i);
 			if (not name) then
 				break
 			end
+			if (not self.buff[name]) then
+				self.buff[name] = {}
+			end
+			self.buff[name].icon = iconTexture
+			self.buff[name].count = count
+			self.buff[name].duration = duration
+			self.buff[name].expirationTime = expirationTime
+			self.buff[name].source = source
+			if (not self.buff[name].present) then
+				self.buff[name].gain = Ovale.maintenant
+			end
+			self.buff[name].lastSeen = Ovale.maintenant
+			self.buff[name].present = true

 			if (name == self.RETRIBUTION_AURA or name == self.MOONKIN_AURA) then
 				hateCommune = 3
@@ -310,6 +324,13 @@ function Ovale:UNIT_AURA(event, unit)
 			end
 			i = i + 1;
 		end
+
+		for k,v in pairs(self.buff) do
+			if (v.lastSeen ~= Ovale.maintenant) then
+				v.present = false
+			end
+		end
+
 		self.spellHaste = hateBase + hateCommune + hateSorts + hateHero + hateClasse
 		self.meleeHaste = hateBase + hateCommune + hateCaC + hateHero + hateClasse
 --		print("spellHaste = "..self.spellHaste)
@@ -394,7 +415,7 @@ function Ovale:OnEnable()
     self:RegisterEvent("UPDATE_BINDINGS");
     self:RegisterEvent("UNIT_AURA");
     self:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
-
+
     -- self:RegisterEvent("PLAYER_TARGET_CHANGED")
     -- self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")

@@ -415,7 +436,7 @@ end

 function Ovale:OnDisable()
     -- Called when the addon is disabled
-    self:UnregisterEvent("ACTIONBAR_PAGE_CHANGED")
+	self:UnregisterEvent("ACTIONBAR_PAGE_CHANGED")
     self:UnregisterEvent("PLAYER_REGEN_ENABLED")
     self:UnregisterEvent("PLAYER_REGEN_DISABLED")
     self:UnregisterEvent("PLAYER_TALENT_UPDATE")
diff --git a/Ovale.toc b/Ovale.toc
index 3f8b339..69e9227 100644
--- a/Ovale.toc
+++ b/Ovale.toc
@@ -1,9 +1,9 @@
-## Interface: 30100
+## Interface: 30200
 ## Title: Ovale
 ## Notes: Show the icon of the next spell to cast
 ## Notes-frFR: Affiche l'icône du prochain sort à lancer
 ## Author: Sidoine
-## Version: 3.1.13
+## Version: 3.2.0
 ## OptionalDeps: Ace3
 ## SavedVariables: OvaleDB
 ## SavedVariablesPerCharacter: OvaleDBPC
diff --git a/OvaleIcone.lua b/OvaleIcone.lua
index 5acf153..2e0d589 100644
--- a/OvaleIcone.lua
+++ b/OvaleIcone.lua
@@ -36,9 +36,12 @@
 		if (meilleureAction~=self.actionCourante or self.ancienneAttente==nil or
 			(minAttente~=0 and minAttente>self.ancienneAttente+0.01) or
 			(Ovale.maintenant + minAttente < self.finAction-0.01)) then
+			if (meilleureAction~=self.actionCourante or self.ancienneAttente==nil or
+					(minAttente~=0 and minAttente>self.ancienneAttente+0.01)) then
+				self.debutAction = Ovale.maintenant
+			end
 			self.actionCourante = meilleureAction
-			self.debutAction = Ovale.maintenant
-			self.finAction = minAttente + self.debutAction
+			self.finAction = minAttente + Ovale.maintenant
 			if (minAttente == 0) then
 				self.cd:Hide()
 			else