Quantcast

- a lot of fixes for shaman (elemental and enhancement) and mage (fire and arcane)

Sidoine De Wispelaere [05-03-09 - 14:35]
- a lot of fixes for shaman (elemental and enhancement) and mage (fire and arcane)
- and a small fix for rogue (better refresh for slice and dice)
- added DebuffExpires function
- added an optional time parameter to TargetDebuffPresent (see enh shaman)
- added SpellAddDebuff, SpellAddTargetDebuff options(see Mage) for casted spells that add a buff or a debuff (better than doNotRepeat for DOTs because it allows stacking! I should correct other scripts)


git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@51 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
.pkgmeta
Condition.lua
Ovale.lua
Ovale.toc
OvaleCompile.lua
OvaleIcone.lua
defaut/Chaman.lua
defaut/Mage.lua
defaut/Voleur.lua
embeds.xml
diff --git a/.pkgmeta b/.pkgmeta
index 66edb34..3bc71e8 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -11,4 +11,6 @@ externals:
     Libs/AceLocale-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0
     Libs/LibStub: svn://svn.wowace.com/wow/ace3/mainline/trunk/LibStub
     Libs/LibBabble-CreatureType-3.0: svn://svn.wowace.com/wow/libbabble-creaturetype-3-0/mainline/trunk
+    Libs/CallbackHandler-1.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/CallbackHandler-1.0
+

\ No newline at end of file
diff --git a/Condition.lua b/Condition.lua
index 28443df..39bb292 100644
--- a/Condition.lua
+++ b/Condition.lua
@@ -52,6 +52,39 @@ local function testbool(a, condition)
 	end
 end

+local function GetTargetAura(condition, filter, target)
+	local spellId = condition[1]
+	local auraName, auraRank, auraIcon = Ovale:GetSpellInfoOrNil(spellId)
+	local i=1;
+	local timeLeft = nil
+	local stacksLeft = nil
+	while (true) do
+		local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable =  UnitAura(target, i, filter);
+		if (not name) then
+			break
+		end
+		if (not condition.mine or unitCaster=="player") then
+			if (name == auraName and icon == auraIcon) then
+				timeLeft = expirationTime - Ovale.maintenant
+				stacksLeft = count
+				break
+			end
+		end
+		i = i + 1;
+	end
+
+	if (Ovale.currentSpellInfo and spellId and Ovale.currentSpellInfo[target][filter] and
+		Ovale.currentSpellInfo[target][filter][spellId]) then
+		if (not timeLeft or timeLeft < Ovale.attenteFinCast) then
+			stacksLeft = 1
+		else
+			stacksLeft = stacksLeft + 1
+		end
+		timeLeft = Ovale.currentSpellInfo[target][filter][spellId] + Ovale.attenteFinCast
+	end
+	return timeLeft, stacksLeft
+end
+
 Ovale.conditions=
 {
 	-- Test if a white hit just occured
@@ -84,54 +117,25 @@ Ovale.conditions=
 	-- 1 : buff spell id
 	-- 2 : expiration time
 	BuffExpires = function(condition)
-		local buffName = Ovale:GetSpellInfoOrNil(condition[1])
-		local i=1;
-		while (true) do
-			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable =  UnitBuff("player", i);
-			if (not name) then
-				break
-			end
-			if (name == buffName) then
-				local timeLeft = expirationTime - Ovale.maintenant
-				local timeBefore = avecHate(condition[2], condition.haste)
-				if (timeLeft<timeBefore) then
-					return 0
-				else
-					return timeLeft-timeBefore
-				end
-			end
-			i = i + 1;
+		local timeLeft, stacksLeft = GetTargetAura(condition, "HELPFUL", "player")
+		local timeBefore = avecHate(condition[2], condition.haste)
+		if (not timeLeft or timeLeft<timeBefore) then
+			return 0
+		else
+			return timeLeft-timeBefore
 		end
-		return 0
 	end,
 	-- Test if a buff is active
 	-- 1 : the buff spell id
 	-- stacks : minimum number of stacks
 	BuffPresent = function(condition)
-		if (not condition[1]) then
+		local timeLeft, stacksLeft = GetTargetAura(condition, "HELPFUL", "player")
+
+		if (timeLeft and (not condition.stacks or stacksLeft>=condition.stacks)) then
+			return 0
+		else
 			return nil
 		end
-		local buffName, buffRank, buffIcon = Ovale:GetSpellInfoOrNil(condition[1])
-		i=1;
-		while (true) do
-			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable =  UnitBuff("player", i);
-			if (not name) then
-				break
-			end
-			if (name == buffName and icon==buffIcon) then
-				if (condition.stacks) then
-					if (count>=condition.stacks) then
-						return 0
-					else
-						return nil
-					end
-				else
-					return 0
-				end
-			end
-			i = i + 1;
-		end
-		return nil
 	end,
 	Casting = function(condition)
 		local spell = UnitCastingInfo("player")
@@ -171,6 +175,17 @@ Ovale.conditions=
 		local points = GetComboPoints("player")
 		return compare(points, condition[1], condition[2])
 	end,
+	DebuffExpires = function(condition)
+		local timeLeft, stacksLeft = GetTargetAura(condition, "HARMFUL", "player")
+		local tempsMax = avecHate(condition[2], condition.haste)
+		if (not timeLeft or timeLeft<tempsMax) then
+			return 0
+		elseif (stacksLeft~=0 and condition.stacks and stacksLeft<condition.stacks) then
+			return 0
+		else
+			return timeLeft-tempsMax
+		end
+	end,
 	HasShield = function(condition)
 		local _,_,id = string.find(GetInventoryItemLink("player",GetInventorySlotInfo("SecondaryHandSlot")) or "","(item:%d+:%d+:%d+:%d+)")
 		if (not id) then
@@ -213,6 +228,9 @@ Ovale.conditions=
 	Mana = function(condition)
 		return compare(UnitPower("player"), condition[1], condition[2])
 	end,
+	ManaPercent = function(condition)
+		return compare(UnitPower("player")/UnitPowerMax("player"), condition[1], condition[2]/100)
+	end,
 	-- Test if any player pet is present (or not)
 	-- 1 : "yes" or "no"
 	PetPresent = function(condition)
@@ -304,59 +322,32 @@ Ovale.conditions=
 	-- stacks : how many stacks
 	-- mine : 1 means that if the debuff is not ours, the debuff is ignored
 	TargetDebuffExpires = function(condition)
-		local debuffName = Ovale:GetSpellInfoOrNil(condition[1])
-		i=1;
-		while (true) do
-			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable =  UnitDebuff("target", i);
-			if (not name) then
-				break
-			end
-			if (not condition.mine or unitCaster=="player") then
-				if (name == debuffName) then
-					local timeLeft = expirationTime - Ovale.maintenant
-					local tempsMax = avecHate(condition[2], condition.haste)
-					if (timeLeft<tempsMax) then
-						return 0
-					elseif (count~=0 and condition.stacks and count<condition.stacks) then
-						return 0
-					else
-						return timeLeft-tempsMax
-					end
-				end
-			end
-			i = i + 1;
+		local timeLeft, stacksLeft = GetTargetAura(condition, "HARMFUL", "target")
+		local tempsMax = avecHate(condition[2], condition.haste)
+		if (not timeLeft or timeLeft<tempsMax) then
+			return 0
+		elseif (stacksLeft~=0 and condition.stacks and stacksLeft<condition.stacks) then
+			return 0
+		else
+			return timeLeft-tempsMax
 		end
-		return 0
 	end,
 	-- Test if a debuff is present on the target
 	-- 1 : debuff spell id
 	-- stacks : how many stacks
 	-- mine : 1 means that the debuff must be yours
 	TargetDebuffPresent = function(condition)
-		local debuffName = Ovale:GetSpellInfoOrNil(condition[1])
-		i=1;
-		while (true) do
-			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable =  UnitDebuff("target", i);
-			if (not name) then
-				break
-			end
-			if (not condition.mine or unitCaster=="player") then
-				if (name == debuffName) then
-					local timeLeft = expirationTime - Ovale.maintenant
-					if (count~=0 and condition.stacks) then
-						if (count<condition.stacks) then
-							return nil
-						else
-							return 0
-						end
-					else
-						return 0
-					end
-				end
+		local timeLeft, stacksLeft = GetTargetAura(condition, "HARMFUL", "target")
+
+		if (timeLeft and (condition[2]==nil or timeLeft>condition[2])) then
+			if (stacksLeft~=0 and condition.stacks and stacksLeft<condition.stacks) then
+				return nil
+			else
+				return 0
 			end
-			i = i + 1;
+		else
+			return nil
 		end
-		return nil
 	end,
 	-- Test if the target life is bellow/above a given value in percent
 	-- 1 : "less" or "more"
diff --git a/Ovale.lua b/Ovale.lua
index 32079a9..c6f045f 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -29,6 +29,8 @@ Ovale.meleeHaste = 0
 Ovale.aura = { player = {}, target = {}}
 Ovale.possibleAura = { player = {}, target = {}}
 Ovale.targetGUID = nil
+Ovale.spellInfo = {}
+Ovale.currentSpellInfo = nil

 Ovale.arbre = {}

@@ -598,16 +600,19 @@ end

 function Ovale:InitCalculerMeilleureAction()
 	self.attenteFinCast = 0
+	self.currentSpellInfo = nil

 	-- On attend que le sort courant soit fini
 	local spell, rank, displayName, icon, startTime, endTime, isTradeSkill = UnitCastingInfo("player")
 	if (spell) then
 		self.attenteFinCast = endTime/1000 - Ovale.maintenant
+		self.currentSpellInfo = self.spellInfo[spell]
 	end

 	local spell, rank, displayName, icon, startTime, endTime, isTradeSkill = UnitChannelInfo("player")
 	if (spell and not Ovale.canStopChannelling[spell]) then
 		self.attenteFinCast = endTime/1000 - Ovale.maintenant
+		self.currentSpellInfo = self.spellInfo[spell]
 	end
 end

diff --git a/Ovale.toc b/Ovale.toc
index da0bc78..70eb8d2 100644
--- a/Ovale.toc
+++ b/Ovale.toc
@@ -3,7 +3,7 @@
 ## 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.6
+## Version: 3.1.7
 ## OptionalDeps: Ace3
 ## SavedVariables: OvaleDB
 ## SavedVariablesPerCharacter: OvaleDBPC
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 1a516a2..cc015e9 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -8,6 +8,9 @@ local function ParseParameters(params)
 	for k,v in string.gmatch(params, "(%w+)=(%w+)") do
 		if (string.match(v,"^%-?%d+%.?%d*$")) then
 			v = tonumber(v)
+		end
+		if (string.match(k,"^%-?%d+%.?%d*$")) then
+			k = tonumber(k)
 		end
 		paramList[k] = v
 	end
@@ -30,6 +33,42 @@ local function ParseFunction(func, params)
 	return "node"..#node
 end

+local function ParseSpellAddDebuff(params)
+	local paramList = ParseParameters(params)
+	local spell = Ovale:GetSpellInfoOrNil(paramList[1])
+	if (spell) then
+		if (not Ovale.spellInfo[spell]) then
+			Ovale.spellInfo[spell] = { player = {}, target = {}}
+		end
+		Ovale.spellInfo[spell].player.HARMFUL = paramList
+	end
+	return ""
+end
+
+local function ParseSpellAddBuff(params)
+	local paramList = ParseParameters(params)
+	local spell = Ovale:GetSpellInfoOrNil(paramList[1])
+	if (spell) then
+		if (not Ovale.spellInfo[spell]) then
+			Ovale.spellInfo[spell] = { player = {}, target = {} }
+		end
+		Ovale.spellInfo[spell].player.HELPFUL = paramList
+	end
+	return ""
+end
+
+local function ParseSpellAddTargetDebuff(params)
+	local paramList = ParseParameters(params)
+	local spell = Ovale:GetSpellInfoOrNil(paramList[1])
+	if (spell) then
+		if (not Ovale.spellInfo[spell]) then
+			Ovale.spellInfo[spell] = { player = {}, target = {} }
+		end
+		Ovale.spellInfo[spell].target.HARMFUL = paramList
+	end
+	return ""
+end
+
 local function ParseIf(a, b)
 	local newNode = {type="if", a=node[tonumber(a)], b=node[tonumber(b)]}
 	node[#node+1] = newNode
@@ -194,7 +233,7 @@ function Ovale:Compile(text)

 	-- On remplace les constantes par leur valeur
 	for k,v in pairs(defines) do
-		text = string.gsub(text, "([^%w])"..k.."([^%w])", "%1"..v.."%2")
+		text = subtest(text, "([^%w])"..k.."([^%w])", "%1"..v.."%2")
 	end

 	-- Fonctions
@@ -204,6 +243,9 @@ function Ovale:Compile(text)
 	-- Options diverses
 	Ovale.canStopChannelling = {}
 	text = string.gsub(text, "CanStopChannelling%s*%(%s*(%w+)%s*%)", ParseCanStopChannelling)
+	text = string.gsub(text, "SpellAddBuff%s*%((.-)%)", ParseSpellAddBuff)
+	text = string.gsub(text, "SpellAddDebuff%s*%((.-)%)", ParseSpellAddDebuff)
+	text = string.gsub(text, "SpellAddTargetDebuff%s*%((.-)%)", ParseSpellAddTargetDebuff)

 	-- On vire les espaces en trop
 	text = string.gsub(text, "\n", " ")
diff --git a/OvaleIcone.lua b/OvaleIcone.lua
index 8972376..5acf153 100644
--- a/OvaleIcone.lua
+++ b/OvaleIcone.lua
@@ -60,7 +60,8 @@
 		end

 		local start, duration, enable = GetActionCooldown(meilleureAction)
-		if (Ovale.maintenant + minAttente > start + duration and minAttente > 0) then
+		if (Ovale.maintenant + minAttente > start + duration + 0.01 and minAttente > 0
+			and minAttente>Ovale.attenteFinCast) then
 			self.icone:SetVertexColor(0.75,0,0)
 		else
 			self.icone:SetVertexColor(1,1,1)
diff --git a/defaut/Chaman.lua b/defaut/Chaman.lua
index aa11db7..3383a61 100644
--- a/defaut/Chaman.lua
+++ b/defaut/Chaman.lua
@@ -11,6 +11,10 @@ Define(STORMSTRIKE 17364)
 Define(LAVALASH 60103)
 Define(LIGHTNINGSHIELD 324)
 Define(MAELSTROMWEAPON 53817)
+Define(ELEMENTALMASTERY 16166)
+Define(SHAMANISTICRAGE 30823)
+Define(THUNDERSTORM 51490)
+Define(FERALSPIRIT 51533)

 AddCheckBox(chain SpellName(CHAINLIGHTNING))
 AddCheckBox(melee L(Melee))
@@ -19,7 +23,7 @@ AddIcon
 {
 	unless CheckBoxOn(melee)
 	{
-		if BuffExpires(FLAMETHONG 2) Spell(FLAMETHONG)
+	#	if BuffExpires(FLAMETHONG 2) Spell(FLAMETHONG)
 		if BuffExpires(WATERSHIELD 2) Spell(WATERSHIELD)
 		if TargetDebuffExpires(FLAMESHOCK 0) Spell(FLAMESHOCK)
 		Spell(LAVABURST doNotRepeat=1)
@@ -29,7 +33,7 @@ AddIcon
 	if CheckBoxOn(melee)
 	{
 		if TargetDebuffExpires(FLAMESHOCK 0) Spell(FLAMESHOCK)
-		if TargetDebuffPresent(FLAMESHOCK) Spell(EARTHSHOCK)
+		if TargetDebuffPresent(FLAMESHOCK 5) Spell(EARTHSHOCK)
 		if BuffExpires(LIGHTNINGSHIELD 0) Spell(LIGHTNINGSHIELD)
 		Spell(STORMSTRIKE)
 		Spell(LAVALASH)
@@ -38,4 +42,17 @@ AddIcon
 	}
 }

+AddIcon
+{
+	Spell(ELEMENTALMASTERY)
+	Spell(FERALSPIRIT)
+}
+
+AddIcon size=small
+{
+	if ManaPercent(less 25)
+		Spell(SHAMANISTICRAGE)
+	if ManaPercent(less 50)
+		Spell(THUNDERSTORM)
+}
 ]]
\ No newline at end of file
diff --git a/defaut/Mage.lua b/defaut/Mage.lua
index e2c7333..a17ee39 100644
--- a/defaut/Mage.lua
+++ b/defaut/Mage.lua
@@ -26,6 +26,10 @@ Define(PRESENCEOFMIND 12043)

 AddCheckBox(scorch SpellName(SCORCH))

+SpellAddDebuff(ARCANEBLAST ARCANEBLAST=10)
+SpellAddTargetDebuff(SCORCH IMPROVEDSCORCH=30)
+SpellAddTargetDebuff(LIVINGBOMB LIVINGBOMB=12)
+
 AddIcon
 {
        if TalentPoints(TALENTLIVINGBOMB more 0)
@@ -33,7 +37,7 @@ AddIcon
               #Fire spec
               if BuffPresent(HOTSTREAK) Spell(PYROBLAST)
               if TargetDebuffExpires(LIVINGBOMB 0 mine=1) Spell(LIVINGBOMB)
-              if TargetDebuffExpires(IMPROVEDSCORCH 2 stacks=5) and CheckBoxOn(scorch) Spell(SCORCH)
+              if TargetDebuffExpires(IMPROVEDSCORCH 5.5 stacks=5) and CheckBoxOn(scorch) Spell(SCORCH)
               if TalentPoints(TALENTPIERCINGICE more 0)
                      Spell(FROSTFIREBOLT)
               if TalentPoints(TALENTPIERCINGICE less 1)
@@ -50,7 +54,7 @@ AddIcon
        if TalentPoints(TALENTARCANEBARRAGE more 0)
        {
               #Arcane spec
-              unless BuffPresent(ARCANEBLAST stacks=3) or {BuffPresent(ARCANEBLAST stacks=2) and Casting(ARCANEBLAST)}
+              if DebuffExpires(ARCANEBLAST 0 stacks=3)
                      Spell(ARCANEBLAST)
               Spell(ARCANEMISSILES)
        }
diff --git a/defaut/Voleur.lua b/defaut/Voleur.lua
index fdd78f3..f41409c 100644
--- a/defaut/Voleur.lua
+++ b/defaut/Voleur.lua
@@ -28,12 +28,6 @@ AddIcon
 			Spell(SLICEANDDICE)
 	}

-	unless TargetDebuffPresent(RUPTURE)
-	{
-		if ComboPoints(more 3)
-			Spell(RUPTURE)
-	}
-
 	if {TargetDebuffPresent(RUPTURE) or TargetDebuffPresent(DEEPWOUNDS) or TargetDebuffPresent(REND)
 		or TargetDebuffPresent(RIP)} and BuffExpires(HUNGERFORBLOOD 2)
 		Spell(HUNGERFORBLOOD)
@@ -46,6 +40,10 @@ AddIcon
 				Spell(ENVENOM)
 			Spell(SLICEANDDICE)
 		}
+
+		if TargetDebuffExpires(RUPTURE 0)
+			Spell(RUPTURE)
+
 		if TalentPoints(TALENTVILEPOISONS more 0)
 			Spell(ENVENOM)
 		Spell(EVISCERATE)
diff --git a/embeds.xml b/embeds.xml
index 7f3aded..fe03baa 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -2,6 +2,7 @@
 ..\FrameXML\UI.xsd">

   <Script file="Libs\LibStub\LibStub.lua"/>
+  <Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml" />
   <Include file="Libs\AceLocale-3.0\AceLocale-3.0.xml" />
   <Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml" />
   <Include file="Libs\AceDB-3.0\AceDB-3.0.xml" />
@@ -11,4 +12,5 @@
   <Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml" />
   <Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml" />
   <Include file="Libs\LibBabble-CreatureType-3.0\lib.xml" />
+  <Include file="Libs\LibBabble-CreatureType-3.0\lib.xml" />
 </Ui>