Quantcast

- bug with scrolling icons

Sidoine De Wispelaere [01-02-10 - 12:13]
- bug with scrolling icons
- added from X until Y (like between X and Y but X must be before Y)

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@180 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Condition.lua
Ovale.lua
Ovale.toc
OvaleCompile.lua
OvaleFrame.lua
defaut/Druide.lua
diff --git a/Condition.lua b/Condition.lua
index 8207975..c531e47 100644
--- a/Condition.lua
+++ b/Condition.lua
@@ -204,12 +204,23 @@ local function GetTargetAura(condition, filter, target)
 		stacks = 1
 	end
 	local spellId = condition[1]
-	local aura = Ovale:GetAura(target, filter, spellId, condition.forceduration)
-	-- if Ovale.trace then
-	--	Ovale:Print("GetTargetAura = start = ".. nilstring(aura.start) .. " end = "..nilstring(aura.ending).." stacks = " ..nilstring(aura.stacks).."/"..stacks)
-	-- end
+	local aura = Ovale:GetAura(target, filter, spellId)
+	if Ovale.trace then
+		Ovale:Print("GetTargetAura = start = ".. nilstring(aura.start) .. " end = "..nilstring(aura.ending).." stacks = " ..nilstring(aura.stacks).."/"..stacks)
+	end
+
 	if (not condition.mine or aura.mine) and aura.stacks>=stacks then
-		return aura.start, aura.ending
+		local ending
+		if condition.forceduration then
+			if Ovale.spellInfo[name] and Ovale.spellInfo[name].duration then
+				ending = aura.start + Ovale.spellInfo[name].duration
+			else
+				ending = aura.start + condition.forceduration
+			end
+		else
+			ending = aura.ending
+		end
+		return aura.start, ending
 	else
 		return 0,0
 	end
diff --git a/Ovale.lua b/Ovale.lua
index fbc8b13..ca4ac77 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -782,6 +782,12 @@ function Ovale:AddRune(time, type, value)
 	end
 end

+function Ovale:Log(text)
+	if self.trace then
+		self:Print(text)
+	end
+end
+
 function Ovale:GetAura(target, filter, spellId, forceduration)
 	if not self.aura[target] then
 		self.aura[target] = {}
@@ -815,17 +821,8 @@ function Ovale:GetAura(target, filter, spellId, forceduration)
 			myAura.mine = (unitCaster == "player")
 			myAura.start = expirationTime - duration

-			if self.spellInfo[name] and forceduration then
-				if self.spellInfo[name].duration then
-					duration = self.spellInfo[name].duration
-				else
-					duration = forceduration
-				end
-			end
-
 			if expirationTime>0 then
-				myAura.ending = myAura.start + duration
-
+				myAura.ending = expirationTime
 			else
 				myAura.ending = nil
 			end
@@ -1279,26 +1276,17 @@ function Ovale:CalculerMeilleureAction(element)
 		local startA, endA = Ovale:CalculerMeilleureAction(element.a)
 		return addTime(startA, -element.time), addTime(endA, -element.time)
 	elseif (element.type == "between") then
-		if (Ovale.trace) then
-			self:Print(element.time.."s between")
-		end
+		self:Log("between")
 		local tempsA = Ovale:CalculerMeilleureAction(element.a)
-		if (tempsA==nil) then
-			if Ovale.trace then Ovale:Print(element.type.." return nil") end
-			if element.comparison == "more"	then
-				return 0
-			else
-				return nil
-			end
-		end
 		local tempsB = Ovale:CalculerMeilleureAction(element.b)
-		if (tempsB==nil) then
+		if tempsB==nil and tempsA==nil then
+			Ovale:Log("diff returns 0 because the two nodes are nil")
+			return 0
+		end
+
+		if tempsA==nil or tempsB==nil then
 			if Ovale.trace then Ovale:Print(element.type.." return nil") end
-			if element.comparison == "more"	then
-				return 0
-			else
-				return nil
-			end
+			return nil
 		end
 		local diff
 		if tempsA>tempsB then
@@ -1306,11 +1294,28 @@ function Ovale:CalculerMeilleureAction(element)
 		else
 			diff = tempsB - tempsA
 		end
-
-		if element.comparison == "more" and diff>element.time then
+		Ovale:Log("diff returns "..diff)
+		return diff
+	elseif element.type == "fromuntil" then
+		self:Log("fromuntil")
+		local tempsA = Ovale:CalculerMeilleureAction(element.a)
+		if (tempsA==nil) then
+			if Ovale.trace then Ovale:Print(element.type.." return nil") end
+			return nil
+		end
+		local tempsB = Ovale:CalculerMeilleureAction(element.b)
+		if (tempsB==nil) then
+			if Ovale.trace then Ovale:Print(element.type.." return nil") end
+			return nil
+		end
+		return tempsB - tempsA
+	elseif element.type == "compare" then
+		self:Log("compare "..element.comparison.." "..element.time)
+		local tempsA = Ovale:CalculerMeilleureAction(element.a)
+		if element.comparison == "more" and (not tempsA or tempsA>element.time) then
 			if Ovale.trace then Ovale:Print(element.type.." return 0") end
 			return 0
-		elseif element.comparison == "less" and diff<element.time then
+		elseif element.comparison == "less" and tempsA and tempsA<element.time then
 			if Ovale.trace then Ovale:Print(element.type.." return 0") end
 			return 0
 		end
diff --git a/Ovale.toc b/Ovale.toc
index 4c60db9..4a564e9 100644
--- a/Ovale.toc
+++ b/Ovale.toc
@@ -3,8 +3,8 @@
 ## Notes: Show the icon of the next spell to cast
 ## Notes-frFR: Affiche l'icône du prochain sort à lancer
 ## Author: Sidoine
-## Version: 3.3.7
-## OptionalDeps: Ace3, ButtonFacade, Recount
+## Version: 3.3.8
+## OptionalDeps: Ace3, ButtonFacade, Recount, LibBabble-CreatureType-3.0
 ## SavedVariables: OvaleDB
 ## SavedVariablesPerCharacter: OvaleDBPC
 ## X-Category: Combat
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 2c9af07..73981c5 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -143,8 +143,13 @@ local function ParseBefore(a,b)
 	return AddNode(newNode)
 end

-local function ParseBetween(comp,t,a,b)
-	local newNode = {type="between", comparison=comp, time=tonumber(t), a=node[tonumber(a)], b=node[tonumber(b)]}
+local function ParseBetween(a,b)
+	local newNode = {type="between", a=node[tonumber(a)], b=node[tonumber(b)]}
+	return AddNode(newNode)
+end
+
+local function ParseFromUntil(a,b)
+	local newNode = {type="fromuntil", a=node[tonumber(a)], b=node[tonumber(b)]}
 	return AddNode(newNode)
 end

@@ -153,6 +158,11 @@ local function ParseOr(a,b)
 	return AddNode(newNode)
 end

+local function ParseCompare(comp,t,a)
+	local newNode = {type="compare", comparison=comp, time=tonumber(t), a=node[tonumber(a)]}
+	return AddNode(newNode)
+end
+
 local function ParseGroup(text)
 	local nodes={}

@@ -211,13 +221,17 @@ local function ParseAddIcon(params, text)
 	while (1==1) do
 		local was = text
 		text = string.gsub(text, "(%w+)%s*%((.-)%)", ParseFunction)
-		text = string.gsub(text, "([lesmor]+)%s+than%s+(%d+%.?%d*)s%s+between%s+node(%d+)%s+and%s+node(%d+)", ParseBetween)
+		text = string.gsub(text, "between%s+node(%d+)%s+and%s+node(%d+)", ParseBetween)
+		text = string.gsub(text, "from%s+node(%d+)%s+until%s+node(%d+)", ParseFromUntil)
 		text = string.gsub(text, "node(%d+)%s+and%s+node(%d+)", ParseAnd)
 		text = string.gsub(text, "node(%d+)%s+or%s+node(%d+)", ParseOr)
 		text = string.gsub(text, "(%d+%.?%d*)s%s+before%s+node(%d+)", ParseBefore)
 		text = string.gsub(text, "if%s+node(%d+)%s+node(%d+)",ParseIf)
 		text = string.gsub(text, "unless%s+node(%d+)%s+node(%d+)",ParseUnless)
 		text = string.gsub(text, "{([node%d ]*)}", ParseGroup)
+		text = string.gsub(text, "(more)%s+than%s+(%d+%.?%d*)s%s+node(%d+)", ParseCompare)
+		text = string.gsub(text, "(less)%s+than%s+(%d+%.?%d*)s%s+node(%d+)", ParseCompare)
+
 		if (was == text) then
 			break
 		end
@@ -355,7 +369,11 @@ function Ovale:DebugNode(node)
 	elseif (node.type == "before") then
 		text = node.time .. "s before "..self:DebugNode(node.a)
 	elseif (node.type == "between") then
-		text = node.time .. "s between "..self:DebugNode(node.a).." and "..self:DebugNode(node.b)
+		text = "between "..self:DebugNode(node.a).." and "..self:DebugNode(node.b)
+	elseif (node.type == "fromuntil") then
+		text = "from "..self:DebugNode(node.a).." until "..self:DebugNode(node.b)
+	elseif (node.type == "compare") then
+		text = node.comparison.." than "..node.time.."s "..self:DebugNode(node.a)
 	else
 		text = "#unknown node type#"
 	end
diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index aeb9b37..0a5b943 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -156,7 +156,7 @@ do
 				start = actionCooldownStart + actionCooldownDuration
 			end

-			if (node.params.nocd and node.params.nocd == 1 and start~=nil and start>Ovale.maintenant+1.5) then
+			if (node.params.nocd and start~=nil and Ovale.maintenant<start-node.params.nocd) then
 				action.icons[1]:Update(element, nil)
 			else
 				action.icons[1]:Update(element, start, actionTexture, actionInRange, actionCooldownStart, actionCooldownDuration,
@@ -173,7 +173,7 @@ do
 				action.waitStart = nil
 			end

-			if Ovale.db.profile.apparence.moving then
+			if Ovale.db.profile.apparence.moving and start then
 				local top=1-(Ovale.maintenant - action.icons[1].debutAction)/(action.icons[1].finAction-action.icons[1].debutAction)
 				if top<0 then
 					top = 0
diff --git a/defaut/Druide.lua b/defaut/Druide.lua
index 5cda8ee..b0a8c4f 100644
--- a/defaut/Druide.lua
+++ b/defaut/Druide.lua
@@ -66,7 +66,8 @@ AddIcon help=main
 {
 	if Stance(1) # bear
 	{
-		Spell(MANGLEBEAR)
+		unless TargetDebuffExpires(LACERATE 4) and TargetDebuffPresent(LACERATE)
+			Spell(MANGLEBEAR)

 		if Mana(more 10) and TargetDebuffExpires(LACERATE 4 stacks=5)
 			Spell(LACERATE)