Quantcast

- added functions that returns a time-dependent value and operators to manipulate them

Sidoine De Wispelaere [01-23-11 - 21:19]
- added functions that returns a time-dependent value and operators to manipulate them
- updated shaman, hunter, druid, warrior, paladin and rogue scripts to match SimulationCraft scripts
- T11 check for warrior and druid

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@345 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Condition.lua
Ovale.lua
Ovale.toc
OvaleCompile.lua
OvaleEquipement.lua
defaut/Chaman.lua
defaut/Chasseur.lua
defaut/Chevalier.lua
defaut/Druide.lua
defaut/Guerrier.lua
defaut/Mage.lua
defaut/Paladin.lua
defaut/Voleur.lua
diff --git a/Condition.lua b/Condition.lua
index 5b7a7af..96f01db 100644
--- a/Condition.lua
+++ b/Condition.lua
@@ -135,7 +135,7 @@ end

 local function getTarget(condition)
 	if (not condition) then
-		return "target"
+		return "player"
 	else
 		return condition
 	end
@@ -179,7 +179,7 @@ end
 local lastEnergyValue = nil
 local lastEnergyTime

-local function GetManaTime(mana, withBerserker)
+local function GetManaAndRate(withBerserker)
 	local _,className = UnitClass("player")
 	local current = Ovale.state.mana
 	if current~=lastEnergyValue then
@@ -203,11 +203,17 @@ local function GetManaTime(mana, withBerserker)
 			end
 		end
 	elseif className == "HUNTER" then
-		rate = 4.08 * (100 + Ovale.meleeHaste) /100
+		rate = 4 * (100 + Ovale.meleeHaste) /100
 	else
 		rate = 0
 	end

+	return lastEnergyValue, lastEnergyTime, rate
+end
+
+local function GetManaTime(mana, withBerserker)
+	local lastEnergyValue, lastEnergyTime, rate = GetManaAndRate(withBerserker)
+
 	if rate > 0 then
 		local limit = math.ceil((mana - lastEnergyValue) / rate + lastEnergyTime)
 		return limit
@@ -276,34 +282,37 @@ local function GetTargetAura(condition, filter, target)
 	end
 end

-local lastSaved
-local savedHealth
-local targetGUID
-local lastSPD=0.0001
+local lastSaved = {}
+local savedHealth = {}
+local targetGUID = {}
+local lastSPD = {}

-local function getTargetDead()
+local function getTargetDead(target)
 	local second = math.floor(Ovale.maintenant)
-	if targetGUID~=UnitGUID("target") then
-		lastSaved = nil
-		targetGUID = UnitGUID("target")
-		savedHealth = {}
+	if targetGUID[target] ~=UnitGUID(target) then
+		lastSaved[target] = nil
+		targetGUID[target] = UnitGUID(target)
+		savedHealth[target] = {}
 	end
-	local newHealth = UnitHealth("target")
-	if UnitHealthMax("target")==1 then
+	local newHealth = UnitHealth(target)
+	if UnitHealthMax(target)==1 then
 		return Ovale.maintenant + 10000
 	end
-	if second~=lastSaved and targetGUID then
-		lastSaved = second
+	if second~=lastSaved[target] and targetGUID[target] then
+		lastSaved[target] = second
 		local mod10 = second % 10
-		local prevHealth = savedHealth[mod10]
-		savedHealth[mod10] = newHealth
+		local prevHealth = savedHealth[target][mod10]
+		savedHealth[target][mod10] = newHealth
 		if prevHealth and prevHealth>newHealth then
-			lastSPD = 10/(prevHealth-newHealth)
+			lastSPD[target] = 10/(prevHealth-newHealth)
 --			print("dps = " .. (1/lastSPD))
 		end
 	end
+	if not lastSPD[target] then
+		lastSPD[target] = 0.001
+	end
 	-- Rough estimation
-	return Ovale.maintenant + newHealth * lastSPD
+	return Ovale.maintenant + newHealth * lastSPD[target]
 end

 Ovale.conditions=
@@ -329,7 +338,7 @@ Ovale.conditions=
 	-- 3 : limit
 	ArmorSetParts = function(condition)
 		local nombre = 0
-		if (OvaleEquipement.nombre[condition[1]]) then
+		if OvaleEquipement.nombre[condition[1]] then
 			nombre = OvaleEquipement.nombre[condition[1]]
 		end
 		return compare(nombre, condition[2], condition[3])
@@ -354,6 +363,14 @@ Ovale.conditions=
 		end
 		return addTime(ending, -timeBefore)
 	end,
+	buffExpires = function(condition)
+		local start, ending = GetTargetAura(condition, "HELPFUL", getTarget(condition.target))
+		if ending then
+			return ending - start, start, -1
+		else
+			return nil
+		end
+	end,
 	-- Test if a time has elapsed since the last buff gain
 	-- 1 : buff spell id
 	-- 2 : time since the buff gain
@@ -376,10 +393,27 @@ Ovale.conditions=
 	-- 1 : the buff spell id
 	-- stacks : minimum number of stacks
 	BuffPresent = function(condition)
-		local start, ending = GetTargetAura(condition, "HELPFUL", "player")
+		local start, ending = GetTargetAura(condition, "HELPFUL", getTarget(condition.target))
 		local timeBefore = avecHate(condition[2], condition.haste)
 		return start, addTime(ending, -timeBefore)
 	end,
+	BuffStealable = function(condition)
+		local i = 1
+		local stealable = false
+		local target = getTarget(condition.target)
+		while true do
+			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitBuff(target, i)
+			if not name then
+				break
+			end
+			if isStealable then
+				stealable = true
+				break
+			end
+			i = i + 1
+		end
+		return testbool(stealable, condition[1])
+	end,
 	Casting = function(condition)
 		if Ovale.currentSpellId == condition[1] then
 			return Ovale.startCast, Ovale.endCast
@@ -394,6 +428,10 @@ Ovale.conditions=
 		end
 		return compare(castTime/1000, condition[2], condition[3])
 	end,
+	castTime = function(condition)
+		local name, rank, icon, cost, isFunnel, powerType, castTime = Ovale:GetSpellInfoOrNil(condition[1])
+		return castTime/1000, 0, 0
+	end,
 	-- Test if a list of checkboxes is off
 	-- 1,... : the checkboxes names
 	CheckBoxOff = function(condition)
@@ -414,6 +452,32 @@ Ovale.conditions=
 		end
 		return 0
 	end,
+		Class = function(condition)
+		local loc, noloc = UnitClass(getTarget(condition.target))
+		return testbool(noloc == condition[1], condition[2])
+	end,
+	-- Test the target classification
+	-- 1 : normal, elite, or worldboss
+	Classification = function(condition)
+		local classification
+		local target = getTarget(condition.target)
+		if UnitLevel(target)==-1 then
+			classification = "worldboss"
+		else
+			classification = UnitClassification(target);
+			if (classification == "rareelite") then
+				classification = "elite"
+			elseif (classification == "rare") then
+				classification = "normal"
+			end
+		end
+
+		if (condition[1]==classification) then
+			return 0
+		else
+			return nil
+		end
+	end,
 	-- Test how many combo points a feral druid or a rogue has
 	-- 1 : "less" or "more"
 	-- 2 : the limit
@@ -424,13 +488,43 @@ Ovale.conditions=
 	Counter = function(condition)
 		return compare(Ovale.counter[condition[1]], condition[2], condition[3])
 	end,
+	CreatureType = function(condition)
+		for _,v in pairs(condition) do
+			if (UnitCreatureType(getTarget(condition.target)) == LBCT[v]) then
+				return 0
+			end
+		end
+		return nil
+	end,
+	DeadIn = function(condition)
+		local deadAt = getTargetDead(getTarget(condition.target))
+		if condition[1] == "more" then
+			return 0, addTime(deadAt, -condition[2])
+		else
+			return addTime(deadAt, -condition[2]), nil
+		end
+	end,
+	-- Test if a debuff will expire on the target after a given time, or if there is less than the
+	-- given number of stacks (if stackable)
+	-- 1 : buff spell id
+	-- 2 : expiration time
+	-- stacks : how many stacks
+	-- mine : 1 means that if the debuff is not ours, the debuff is ignored
 	DebuffExpires = function(condition)
-		local start, ending = GetTargetAura(condition, "HARMFUL", "player")
+		local start, ending = GetTargetAura(condition, "HARMFUL", getTarget(condition.target))
 		local tempsMax = avecHate(condition[2], condition.haste)
 		return addTime(ending, -tempsMax)
 	end,
+	debuffExpires = function(condition)
+		local start, ending = GetTargetAura(condition, "HARMFUL", getTarget(condition.target))
+		if ending then
+			return ending - start, start, -1
+		else
+			return nil
+		end
+	end,
 	DebuffPresent = function(condition)
-		local start, ending = GetTargetAura(condition, "HARMFUL", "player")
+		local start, ending = GetTargetAura(condition, "HARMFUL", getTarget(condition.target))
 		local timeBefore = avecHate(condition[2], condition.haste)
 		return start, addTime(ending, -timeBefore)
 	end,
@@ -484,17 +578,43 @@ Ovale.conditions=
 	InCombat = function(condition)
 		return testbool(Ovale.enCombat, condition[1])
 	end,
+	TargetInRange = function(condition)
+		local spellName = GetSpellInfo(condition[1])
+		return testbool(IsSpellInRange(spellName,getTarget(condition.target))==1,condition[2])
+	end,
 	ItemCount = function(condition)
 		return compare(GetItemCount(condition[1]), condition[2], condition[3])
 	end,
+	IsCasting = function(condition)
+		local casting
+		local target = getTarget(condition.target)
+		local spellId = condition.spell
+		if not spellId then
+			return testbool(UnitCastingInfo(target) or UnitChannelInfo(target), condition[1])
+		else
+			local spellName = GetSpellInfo(spellId)
+			return testbool(UnitCastingInfo(target)==spellName or UnitChannelInfo(target) == spellName, condition[1])
+		end
+	end,
 	IsFeared = function(condition)
 		buildFearSpellList()
 		return testbool(not HasFullControl() and isDebuffInList(fearSpellList), condition[1])
 	end,
+	IsFriend = function(condition)
+		return testbool(UnitIsFriend("player", getTarget(condition.target)), condition[1])
+	end,
 	IsIncapacitated = function(condition)
 		buildIncapacitateSpellList()
 		return testbool(not HasFullControl() and isDebuffInList(incapacitateSpellList), condition[1])
 	end,
+	IsInterruptible = function(condition)
+		local target = getTarget(condition.target)
+		local spell, rank, name, icon, start, ending, isTradeSkill, castID, protected = UnitCastingInfo(target)
+		if not spell then
+			spell, rank, name, icon, start, ending, isTradeSkill, protected = UnitChannelInfo(target)
+		end
+		return testbool(protected ~= nil and not protected, condition[1])
+	end,
 	IsRooted = function(condition)
 		buildRootSpellList()
 		return testbool(isDebuffInList(rootSpellList), condition[1])
@@ -503,6 +623,19 @@ Ovale.conditions=
 		buildStunSpellList()
 		return testbool(not HasFullControl() and isDebuffInList(stunSpellList), condition[1])
 	end,
+	-- Test the target level difference with the player
+	-- 1 : "less" or "more"
+	-- 2 : [target level]-[player level] limit
+	TargetRelativeLevel = function(condition)
+		local difference
+		if (UnitLevel("target") == -1) then
+			difference = 3
+		else
+			difference = UnitLevel("target") - UnitLevel("player")
+		end
+
+		return compare(difference, condition[1], condition[2])
+	end,
 	LastSpellDamage = function(condition)
 		local spellId = condition[1]
 		if not Ovale.spellDamage[spellId] then
@@ -514,13 +647,22 @@ Ovale.conditions=
 	-- 1 : "less" or "more"
 	-- 2 : the limit
 	Level = function(condition)
-		return compare(UnitLevel("player"), condition[1], condition[2])
+		return compare(UnitLevel(getTarget(condition.target)), condition[1], condition[2])
+	end,
+	Life = function(condition)
+		local target = getTarget(condition.target)
+		return compare(UnitHealth(target), condition[1], condition[2])
+	end,
+	LifeMissing = function(condition)
+		local target = getTarget(condition.target)
+		return compare(UnitHealthMax(target)-UnitHealth(target), condition[1], condition[2])
 	end,
 	-- Test if the player life is bellow/above a given value in percent
 	-- 1 : "less" or "more"
 	-- 2 : the limit, in percent
 	LifePercent = function(condition)
-		return compare(UnitHealth("player")/UnitHealthMax("player"), condition[1], condition[2]/100)
+		local target = getTarget(condition.target)
+		return compare(UnitHealth(target)/UnitHealthMax(target), condition[1], condition[2]/100)
 	end,
 	-- Test if a list item is selected
 	-- 1 : the list name
@@ -537,16 +679,29 @@ Ovale.conditions=
 	-- 1 : "less" or "more"
 	-- 2 : the mana/energy/rage... limit
 	Mana = function(condition)
-		local limit = GetManaTime(condition[2], false)
-		if condition[1]=="more" then
-			return limit, nil
+		local target = getTarget(condition.target)
+		if target == "player" then
+			local limit = GetManaTime(condition[2], false)
+			if condition[1]=="more" then
+				return limit, nil
+			else
+				return 0,limit
+			end
 		else
-			return 0,limit
+			return compare(UnitPower(target), condition[1], condition[2])
 		end
 	end,
+	mana = function(condition)
+		return GetManaAndRate(false)
+	end,
 	ManaPercent = function(condition)
 		return compare(UnitPower("player")/UnitPowerMax("player"), condition[1], condition[2]/100)
 	end,
+	manaPercent = function(condition)
+		local value, t, rate = GetManaAndRate(false)
+		local conversion = 100/UnitPowerMax("player")
+		return value * conversion, t, rate * conversion
+	end,
 	OtherDebuffExpires = function(condition)
 		Ovale:EnableOtherDebuffs()
 		local otherDebuff = Ovale.otherDebuffs[condition[1]]
@@ -671,9 +826,13 @@ Ovale.conditions=
 		return compare(Ovale.state.shard, condition[1], condition[2])
 	end,
 	Speed = function(condition)
-		return compare(GetUnitSpeed("player")*100/7, condition[1], condition[2])
+		return compare(GetUnitSpeed(getTarget(condition.target))*100/7, condition[1], condition[2])
+	end,
+	spell = function(condition)
+		local actionCooldownStart, actionCooldownDuration, actionEnable = Ovale:GetComputedSpellCD(condition[1])
+		return actionCooldownDuration, actionCooldownStart, -1
 	end,
-	-- Test if the player is in a given stance
+-- Test if the player is in a given stance
 	-- 1 : the stance
 	Stance = function(condition)
 		if (GetShapeshiftForm(true) == condition[1]) then
@@ -696,157 +855,10 @@ Ovale.conditions=
 		end
 		return compare(Ovale.pointsTalent[condition[1]], condition[2], condition[3])
 	end,
-	TargetBuffStealable = function(condition)
-		local i = 1
-		local stealable = false
-		local target = getTarget(condition.target)
-		while true do
-			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitBuff(target, i)
-			if not name then
-				break
-			end
-			if isStealable then
-				stealable = true
-				break
-			end
-			i = i + 1
-		end
-		return testbool(stealable, condition[1])
-	end,
-	-- Test if a buff is present on the target
-	-- 1 : buff spell id
-	-- stacks : how many stacks
-	TargetBuffPresent = function(condition)
-		local start, ending = GetTargetAura(condition, "HELPFUL")
-		local tempsMin = avecHate(condition[2], condition.haste)
-		return start, addTime(ending, -tempsMin)
-	end,
-	TargetClass = function(condition)
-		local loc, noloc = UnitClass("target")
-		return testbool(noloc == condition[1], condition[2])
-	end,
-	-- Test the target classification
-	-- 1 : normal, elite, or worldboss
-	TargetClassification = function(condition)
-		local classification
-		if UnitLevel("target")==-1 then
-			classification = "worldboss"
-		else
-			classification = UnitClassification("target");
-			if (classification == "rareelite") then
-				classification = "elite"
-			elseif (classification == "rare") then
-				classification = "normal"
-			end
-		end
-
-		if (condition[1]==classification) then
-			return 0
-		else
-			return nil
-		end
-	end,
-	TargetCreatureType = function(condition)
-		for _,v in pairs(condition) do
-			if (UnitCreatureType("target") == LBCT[v]) then
-				return 0
-			end
-		end
-		return nil
-	end,
-	TargetDeadIn = function(condition)
-		local deadAt = getTargetDead()
-		if condition[1] == "more" then
-			return 0, addTime(deadAt, -condition[2])
-		else
-			return addTime(deadAt, -condition[2]), nil
-		end
-	end,
-	-- Test if a debuff will expire on the target after a given time, or if there is less than the
-	-- given number of stacks (if stackable)
-	-- 1 : buff spell id
-	-- 2 : expiration time
-	-- stacks : how many stacks
-	-- mine : 1 means that if the debuff is not ours, the debuff is ignored
-	TargetDebuffExpires = function(condition)
-		local start, ending = GetTargetAura(condition, "HARMFUL")
-		local tempsMax = avecHate(condition[2], condition.haste)
-		return addTime(ending, -tempsMax)
-	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 start, ending = GetTargetAura(condition, "HARMFUL")
-		local tempsMin = avecHate(condition[2], condition.haste)
-		return start, addTime(ending, -tempsMin)
-	end,
-	TargetInRange = function(condition)
-		local spellName = GetSpellInfo(condition[1])
-		return testbool(IsSpellInRange(spellName,getTarget(condition.target))==1,condition[2])
-	end,
-	TargetIsCasting = function(condition)
-		local casting
-		local target = getTarget(condition.target)
-		local spellId = condition.spell
-		if not spellId then
-			return testbool(UnitCastingInfo(target) or UnitChannelInfo(target), condition[1])
-		else
-			local spellName = GetSpellInfo(spellId)
-			return testbool(UnitCastingInfo(target)==spellName or UnitChannelInfo(target) == spellName, condition[1])
-		end
-	end,
-	TargetIsFriend = function(condition)
-		return testbool(UnitIsFriend("player", getTarget(condition.target)), condition[1])
-	end,
-	TargetIsInterruptible = function(condition)
-		local target = getTarget(condition.target)
-		local spell, rank, name, icon, start, ending, isTradeSkill, castID, protected = UnitCastingInfo(target)
-		if not spell then
-			spell, rank, name, icon, start, ending, isTradeSkill, protected = UnitChannelInfo(target)
-		end
-		return testbool(protected ~= nil and not protected, condition[1])
-	end,
-	TargetLife = function(condition)
-		local target = getTarget(condition.target)
-		return compare(UnitHealth(target), condition[1], condition[2])
-	end,
-	TargetLifeMissing = function(condition)
-		local target = getTarget(condition.target)
-		return compare(UnitHealthMax(target)-UnitHealth(target), condition[1], condition[2])
-	end,
-	-- Test if the target life is bellow/above a given value in percent
-	-- 1 : "less" or "more"
-	-- 2 : the limit, in percents
-	TargetLifePercent = function(condition)
-		local target = getTarget(condition.target)
-		return compare(UnitHealth(target)/UnitHealthMax(target), condition[1], condition[2]/100)
-	end,
-	TargetMana = function(condition)
-		local target = getTarget(condition.target)
-		return compare(UnitPower(target), condition[1], condition[2])
-	end,
-	-- Test the target level difference with the player
-	-- 1 : "less" or "more"
-	-- 2 : [target level]-[player level] limit
-	TargetRelativeLevel = function(condition)
-		local difference
-		if (UnitLevel("target") == -1) then
-			difference = 3
-		else
-			difference = UnitLevel("target") - UnitLevel("player")
-		end
-
-		return compare(difference, condition[1], condition[2])
-	end,
-	TargetSpeed = function(condition)
-		return compare(GetUnitSpeed(getTarget(condition.target))*100/7, condition[1], condition[2])
-	end,
 	-- Test if the target's target is the player (or is not)
 	-- 1 : "yes" (it should be the player) or "no"
-	TargetTargetIsPlayer = function(condition)
-		return testbool(UnitIsUnit("player","targettarget"), condition[1])
+	TargetIsPlayer = function(condition)
+		return testbool(UnitIsUnit("player",getTarget(condition.target).."target"), condition[1])
 	end,
 	Threat = function(condition)
 		local isTanking, status, threatpct = UnitDetailedThreatSituation("player", getTarget(condition.target))
@@ -861,6 +873,9 @@ Ovale.conditions=
 			return 0, Ovale.combatStartTime + condition[2]
 		end
 	end,
+	timeToDie = function(condition)
+		return 0, getTargetDead(getTarget(condition.target)), -1
+	end,
 	TotemExpires = function(condition)
 		local haveTotem, totemName, startTime, duration = GetTotemInfo(totemType[condition[1]])
 		if not startTime then
diff --git a/Ovale.lua b/Ovale.lua
index ed13f52..56c12c2 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -1814,7 +1814,7 @@ function Ovale:CalculerMeilleureAction(element)
 				self:Print("Function "..element.func.." not found")
 				return nil
 			end
-			local start, ending = classe(element.params)
+			local start, ending, rate = classe(element.params)

 			if (Ovale.trace) then
 				local parameterList = element.func.."("
@@ -1824,10 +1824,10 @@ function Ovale:CalculerMeilleureAction(element)
 				self:Print("Function "..parameterList..") returned "..nilstring(start)..","..nilstring(ending))
 			end

-			return start, ending
+			return start, ending, rate
 		end
 	elseif element.type == "time" then
-		return element.value
+		return element.value, 0, 0
 	elseif element.type == "after" then
 		local timeA = Ovale:CalculerMeilleureAction(element.time)
 		local startA, endA = Ovale:CalculerMeilleureAction(element.a)
@@ -1974,6 +1974,83 @@ function Ovale:CalculerMeilleureAction(element)
 			endB = endA
 		end
 		return startB, endB
+	elseif element.type == "operator" then
+		local a,b,c = self:CalculerMeilleureAction(element.a)
+		local x,y,z = self:CalculerMeilleureAction(element.b)
+
+		if not a or not x then
+			self:Log("operator: a or x is nil")
+			return nil
+		end
+
+		self:Log(a.."+(t-"..b..")*"..c.. element.operator..x.."+(t-"..y..")*"..z)
+
+		if element.operator == "*" then
+			if c == 0 then
+				return a*x, y, a*z
+			elseif z == 0 then
+				return x*a, b, x*c
+			else
+				self:Print("ERROR: at least one value must be constant when multiplying")
+				self.bug = true
+			end
+		elseif element.operator == "+" then
+			if c+z == 0 then
+				return a+x, 0, 0
+			else
+				return a+x, (b*c+y*z)/(c+z), c+z
+			end
+		elseif element.operator == '-' then
+			if c-z == 0 then
+				return a-x, 0, 0
+			else
+				return a-x, (b*c-y*z)/(c-z), c-z
+			end
+		elseif element.operator == '/' then
+			if z == 0 then
+				return a/x, b, c/x
+			else
+				self:Print("ERROR: second operator of / must be constant")
+				self.bug = true
+			end
+		elseif element.operator == '<' then
+			-- a + (t-b)*c = x + (t-y)*z
+			-- (t-b)*c - (t-y)*z = x - a
+			-- t*c - b*c - t*z + y*z = x - a
+			-- t*(c-z) = x - a + b*c + y*z
+			-- t = (x-a + b*c + y*z)/(c-z)
+			if c == z then
+				if a-b*c < x-y*z then
+					return 0
+				else
+					return nil
+				end
+			else
+				local t = (x-a + b*c + y*z)/(c-z)
+				if c > z then
+					return 0, t
+				else
+					return t, nil
+				end
+			end
+		elseif element.operator == '>' then
+			if c == z then
+				self:Log("> with c==z")
+				if a-b*c > x-y*z then
+					self:Log("a>x")
+					return 0
+				else
+					return nil
+				end
+			else
+				local t = (x-a + b*c + y*z)/(c-z)
+				if c < z then
+					return 0, t
+				else
+					return t, nil
+				end
+			end
+		end
 	elseif (element.type == "group") then
 		local meilleurTempsFils
 		local bestEnd
diff --git a/Ovale.toc b/Ovale.toc
index 9e193b1..e1aa8da 100644
--- a/Ovale.toc
+++ b/Ovale.toc
@@ -17,6 +17,7 @@ Locale-enUS.lua
 Locale-zhTW.lua
 Ovale.lua
 Condition.lua
+OvaleEquipement.lua
 OvaleIcone.lua
 OvaleIcone.xml
 OvaleFrame.lua
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 70bd472..3c1ff77 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -39,8 +39,21 @@ local function ParseTime(value)
 	return AddNode({type="time", value=tonumber(value)})
 end

-local function ParseFunction(func, params)
+local function ParseNumber(dummy, value)
+	return dummy..AddNode({type="time", value=tonumber(value)})
+end
+
+local function ParseFunction(prefix, func, params)
 	local paramList = ParseParameters(params)
+	if func ~= "" then
+		paramList.target = prefix
+	else
+		func = prefix
+	end
+	if string.find(func, "Target") == 1 then
+		paramList.target = "target"
+		func = string.sub(func, 7)
+	end
 	local newNode = { type="function", func=func, params=paramList}
 	return AddNode(newNode)
 end
@@ -186,6 +199,11 @@ local function ParseOr(a,b)
 	return AddNode(newNode)
 end

+local function ParseOp(a, op, b)
+	local newNode = {type="operator", operator=op, a=node[tonumber(a)], b=node[tonumber(b)]}
+	return AddNode(newNode)
+end
+
 local function ParseCompare(comp,t,a)
 	local newNode = {type="compare", comparison=comp, time=node[tonumber(t)], a=node[tonumber(a)]}
 	return AddNode(newNode)
@@ -264,7 +282,7 @@ local function ParseAddIcon(params, text)
 	local original = text
 	while (1==1) do
 		local was = text
-		text = string.gsub(text, "(%w+)%s*%((.-)%)", ParseFunction)
+		text = string.gsub(text, "(%w+)%.?(%w*)%s*%((.-)%)", ParseFunction)
 		text = string.gsub(text, "(%d+%.?%d*)s", ParseTime)
 		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)
@@ -274,7 +292,7 @@ local function ParseAddIcon(params, text)
 		text = string.gsub(text, "(at most)%s+node(%d+)%s+node(%d+)", ParseCompare)
 		text = string.gsub(text, "node(%d+)%s+before%s+node(%d+)", ParseBefore)
 		text = string.gsub(text, "node(%d+)%s+after%s+node(%d+)", ParseAfter)
-
+		text = string.gsub(text, "([^%w])(%d+%.?%d*)", ParseNumber)
 		if (was == text) then
 			break
 		end
@@ -282,6 +300,7 @@ local function ParseAddIcon(params, text)

 	while (1==1) do
 		local was = text
+		text = string.gsub(text, "node(%d+)%s*([%*%+%-%/%>%<])%s*node(%d+)", ParseOp)
 		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, "if%s+node(%d+)%s+node(%d+)",ParseIf)
diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua
new file mode 100644
index 0000000..d4fd196
--- /dev/null
+++ b/OvaleEquipement.lua
@@ -0,0 +1,75 @@
+OvaleEquipement = LibStub("AceAddon-3.0"):NewAddon("OvaleEquipement", "AceEvent-3.0")
+
+OvaleEquipement.nombre = {}
+
+function OvaleEquipement:OnEnable()
+	self:RegisterEvent("UNIT_INVENTORY_CHANGED")
+	self:RegisterEvent("PLAYER_ENTERING_WORLD")
+end
+
+function OvaleEquipement:OnDisable()
+	self:UnregisterEvent("UNIT_INVENTORY_CHANGED")
+	self:UnregisterEvent("PLAYER_ENTERING_WORLD")
+end
+
+function OvaleEquipement:GetItemId(slot)
+	local link = GetInventoryItemLink("player", GetInventorySlotInfo(slot))
+	if not link then return nil end
+	local a, b, itemId = string.find(link, "item:(%d+)");
+	return tonumber(itemId);
+end
+
+local itemTier =
+{
+	--Feral druid
+	[60286] = "T11",
+	[60288] = "T11",
+	[60287] = "T11",
+	[60289] = "T11",
+	[60290] = "T11",
+	[65189] = "T11",
+	[65190] = "T11",
+	[65191] = "T11",
+	[65192] = "T11",
+	[65193] = "T11",
+	--Fury/Arm warrior
+	[60323] = "T11",
+	[60324] = "T11",
+	[60325] = "T11",
+	[60326] = "T11",
+	[60327] = "T11",
+	[65264] = "T11",
+	[65265] = "T11",
+	[65266] = "T11",
+	[65267] = "T11",
+	[65268] = "T11",
+}
+
+local itemSlots = {"HeadSlot", "ShoulderSlot", "ChestSlot", "HandsSlot", "LegsSlot"}
+
+function OvaleEquipement:Refresh()
+	self.nombre = {}
+	for i=1,#itemSlots do
+		local itemId = self:GetItemId(itemSlots[i])
+		if itemId then
+			local tier = itemTier[itemId]
+			if tier~=nil then
+				if not self.nombre[tier] then
+					self.nombre[tier] = 1
+				else
+					self.nombre[tier] = self.nombre[tier] + 1
+				end
+			end
+		end
+	end
+end
+
+function OvaleEquipement:UNIT_INVENTORY_CHANGED(event, arg1)
+	if (arg1 == "player") then
+		self:Refresh()
+	end
+end
+
+function OvaleEquipement:PLAYER_ENTERING_WORLD(event)
+	self:Refresh()
+end
\ No newline at end of file
diff --git a/defaut/Chaman.lua b/defaut/Chaman.lua
index becb5ce..1af4889 100644
--- a/defaut/Chaman.lua
+++ b/defaut/Chaman.lua
@@ -78,20 +78,21 @@ AddIcon help=main mastery=1
 		if WeaponEnchantExpires(mainhand 400) Spell(FLAMETHONG)
 	}
 	if BuffExpires(LIGHTNINGSHIELD 2) Spell(LIGHTNINGSHIELD)
-	if CheckBoxOn(aoe)
-	{
-		if TotemExpires(fire) Spell(MAGMATOTEM)
-		unless TotemExpires(fire) Spell(FIRENOVA)
-		if ManaPercent(less 90) Spell(THUNDERSTORM)
-	}
-	if CheckBoxOn(aoe) Spell(CHAINLIGHTNING)
-	Spell(UNLEASHELEMENTS)
+#	if CheckBoxOn(aoe)
+#	{
+#		if TotemExpires(fire) Spell(MAGMATOTEM)
+#		unless TotemExpires(fire) Spell(FIRENOVA)
+#		if ManaPercent(less 90) Spell(THUNDERSTORM)
+#	}
 	if TargetDebuffExpires(FLAMESHOCK 0 mine=1) Spell(FLAMESHOCK)
 	unless TargetDebuffExpires(FLAMESHOCK 1.6 haste=spell mine=1) Spell(LAVABURST)
+	if BuffPresent(LIGHTNINGSHIELD stacks=9) Spell(EARTHSHOCK)
+	if TotemExpires(fire) Spell(SEARINGTOTEM)
+	if CheckBoxOn(aoe) Spell(CHAINLIGHTNING)
+#	Spell(UNLEASHELEMENTS)

-	if BuffPresent(LIGHTNINGSHIELD stacks=9) Spell(EARTHSHOCK)
-	if CheckBoxOn(chain) and CastTime(LIGHTNINGBOLT more 1.5) and at least 0s from Spell(LAVABURST) until EndCastTime(CHAINLIGHTNING)
-			Spell(CHAINLIGHTNING)
+#	if CheckBoxOn(chain) and CastTime(LIGHTNINGBOLT more 1.5) and at least 0s from Spell(LAVABURST) until EndCastTime(CHAINLIGHTNING)
+#			Spell(CHAINLIGHTNING)

 	Spell(LIGHTNINGBOLT)
 }
@@ -104,27 +105,39 @@ AddIcon help=main mastery=2
 		if WeaponEnchantExpires(offhand 400) Spell(FLAMETHONGWEAPON)
 	}

+	if BuffExpires(LIGHTNINGSHIELD) Spell(LIGHTNINGSHIELD)
+
 	if CheckBoxOn(aoe)
 	{
-		if TotemExpires(fire) Spell(MAGMATOTEM)
-		if BuffExpires(LIGHTNINGSHIELD) Spell(LIGHTNINGSHIELD)
 		if BuffPresent(MAELSTROMWEAPON stacks=5) Spell(CHAINLIGHTNING)
+		if TotemExpires(fire) Spell(MAGMATOTEM)
 		if TotemPresent(fire) Spell(FIRENOVA)
+		Spell(LAVALASH)
+		if BuffPresent(MAELSTROMWEAPON stacks=4) Spell(CHAINLIGHTNING)
 		Spell(UNLEASHELEMENTS)
+		if TargetDebuffExpires(FLAMESHOCK 0 mine=1) Spell(FLAMESHOCK)
+		Spell(EARTHSHOCK)
+		Spell(STORMSTRIKE)
+		Spell(FIRENOVA)
+		if BuffPresent(MAELSTROMWEAPON stacks=2) Spell(CHAINLIGHTNING)
+		Spell(LAVABURST)
 	}

 	if CheckBoxOff(aoe)
 	{
-		Spell(UNLEASHELEMENTS)
-		if TotemExpires(fire) Spell(SEARINGTOTEM)
-		if BuffExpires(LIGHTNINGSHIELD) Spell(LIGHTNINGSHIELD)
 		if BuffPresent(MAELSTROMWEAPON stacks=5) Spell(LIGHTNINGBOLT)
+		if TotemExpires(fire) Spell(SEARINGTOTEM)
+		Spell(LAVALASH)
+		if BuffPresent(MAELSTROMWEAPON stacks=4) Spell(LIGHTNINGBOLT)
+		Spell(UNLEASHELEMENTS)
+		if TargetDebuffExpires(FLAMESHOCK 0 mine=1) Spell(FLAMESHOCK)
+		Spell(EARTHSHOCK)
+		Spell(STORMSTRIKE)
+		Spell(FIRENOVA)
+		if BuffPresent(MAELSTROMWEAPON stacks=2) Spell(LIGHTNINGBOLT)
+		Spell(LAVABURST)
 	}
-
-	Spell(STORMSTRIKE)
-	Spell(LAVALASH)
-	if TargetDebuffExpires(FLAMESHOCK 2 haste=spell mine=1) Spell(FLAMESHOCK)
-	Spell(EARTHSHOCK)
+
 	Spell(SHAMANISTICRAGE priority=2)
 	Spell(FERALSPIRIT priority=2)
 }
diff --git a/defaut/Chasseur.lua b/defaut/Chasseur.lua
index 671bf64..63a9f70 100644
--- a/defaut/Chasseur.lua
+++ b/defaut/Chasseur.lua
@@ -50,6 +50,7 @@ Define(LOCKANDLOAD 56453)
 Define(FRENZYEFFECT 19615)
 Define(MARKEDFORDEATH 88691)
 Define(FIRE 82926)
+Define(BEASTWITHIN 34692)

 AddCheckBox(multi SpellName(MULTISHOT))
 ScoreSpells(FOCUSFIRE KILLCOMMAND ARCANESHOT KILLSHOT STEADYSHOT SERPENTSTING
@@ -58,25 +59,27 @@ ScoreSpells(FOCUSFIRE KILLCOMMAND ARCANESHOT KILLSHOT STEADYSHOT SERPENTSTING

 AddIcon help=main mastery=1
 {
+	if Mana(more 24) and TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
 	if TargetLifePercent(less 20) Spell(KILLSHOT)
-	if Mana(less 40) {Spell(FERVOR) Spell(COBRASHOT) Spell(STEADYSHOT)}
-	if TargetBuffPresent(FRENZYEFFECT stacks=5 target=pet) Spell(FOCUSFIRE)
-	if CheckBoxOn(multi) Spell(MULTISHOT)
-	if TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
-	if TargetInRange(GROWL) Spell(KILLCOMMAND)
-	Spell(ARCANESHOT)
+	if Mana(less 20) Spell(FERVOR)
+	if TargetBuffPresent(FRENZYEFFECT stacks=5 target=pet) and BuffExpires(BEASTWITHIN 0) Spell(FOCUSFIRE)
+	if Mana(more 56)
+	{
+		if CheckBoxOn(multi) Spell(MULTISHOT)
+		Spell(ARCANESHOT)
+	}
 	Spell(COBRASHOT)
 	Spell(STEADYSHOT)
 }

 AddIcon help=main mastery=2
 {
+    if Mana(more 24) and TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
+    if TargetDebuffPresent(SERPENTSTING) and Mana(more 49) Spell(CHIMERASHOT)
     if TargetLifePercent(less 20) Spell(KILLSHOT)
+	if BuffPresent(FIRE) Spell(AIMEDSHOT)
+    if Mana(less 40) or Counter(ss equal 1) Spell(STEADYSHOT)
     if CheckBoxOn(multi) Spell(MULTISHOT)
-    if TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
-    if TargetDebuffPresent(SERPENTSTING) Spell(CHIMERASHOT)
-    if BuffPresent(FIRE) Spell(AIMEDSHOT)
-    if Mana(less 44) or Counter(ss equal 1) Spell(STEADYSHOT)
     unless 1.6s before Spell(CHIMERASHOT) Spell(ARCANESHOT)
     if Mana(more 66) Spell(ARCANESHOT)
     unless 0.25s before Spell(CHIMERASHOT) Spell(STEADYSHOT)
@@ -84,33 +87,29 @@ AddIcon help=main mastery=2

 AddIcon help=main mastery=3
 {
-    if TargetLifePercent(less 20) Spell(KILLSHOT)
-    if Mana(less 35) and BuffExpires(LOCKANDLOAD) {Spell(COBRASHOT) Spell(STEADYSHOT)}
-    if Mana(more 35) and TargetDebuffExpires(BLACKARROW 0 mine=1) Spell(BLACKARROW)
-    if Mana(more 25) and TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
+    if Mana(more 24) and TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
     if TargetDebuffExpires(EXPLOSIVESHOT 0 mine=1) Spell(EXPLOSIVESHOT)
-    if BuffPresent(LOCKANDLOAD) Spell (KILLCOMMAND)
-    if BuffPresent(LOCKANDLOAD) Spell (EXPLOSIVESHOT)
-    unless 1.5s before Spell(BLACKARROW) {Spell(COBRASHOT) Spell(STEADYSHOT)}
-    if CheckBoxOn(multi) Spell(MULTISHOT)
-    if Mana(more 57) Spell(ARCANESHOT)
-    unless 1.5s before Spell(EXPLOSIVESHOT) {Spell(COBRASHOT) Spell(STEADYSHOT)}
+    if Mana(more 35) and TargetDebuffExpires(BLACKARROW 0 mine=1) Spell(BLACKARROW)
+    if TargetLifePercent(less 20) Spell(KILLSHOT)
+    if Mana(more 70) and BuffExpires(LOCKANDLOAD)
+	{
+		if CheckBoxOn(multi) Spell(MULTISHOT)
+		Spell(ARCANESHOT)
+	}
+    Spell(COBRASHOT)
+	Spell(STEADYSHOT)
 }


 AddIcon help=cd
 {
-	unless BuffPresent(ASPECTOFTHEHAWK) Spell(ASPECTOFTHEHAWK)
-	if TalentPoints(TALENTTRACKING more 0) and Tracking(TRACKBEASTS no) and Tracking(TRACKDEMONS no) and Tracking(TRACKDRAGONKIN no)
-			and Tracking(TRACKELEMENTALS no) and Tracking(TRACKGIANTS no) and Tracking(TRACKHUMANOIDS no) and Tracking(TRACKUNDEAD no)
-				Spell(TRACKBEASTS)
-
+	unless BuffPresent(ASPECTOFTHEHAWK) or BuffPresent(ASPECTOFTHEFOX) Spell(ASPECTOFTHEHAWK)
 	if TargetDebuffExpires(HUNTERSMARK 2) and TargetDebuffExpires(MARKEDFORDEATH 0) and TargetDeadIn(more 20) Spell(HUNTERSMARK nored=1)
 	Spell(BESTIALWRATH usable=1)
 	Item(Trinket0Slot usable=1)
 	Item(Trinket1Slot usable=1)
 	Spell(CALLOFTHEWILD usable=1)
-	Spell(RAPIDFIRE)
+	unless BuffPresent(heroism) Spell(RAPIDFIRE)
 	Spell(READINESS)
 }
 ]]
diff --git a/defaut/Chevalier.lua b/defaut/Chevalier.lua
index 066216c..a16be67 100644
--- a/defaut/Chevalier.lua
+++ b/defaut/Chevalier.lua
@@ -136,25 +136,30 @@ AddIcon help=main mastery=2
 {
 	if BuffExpires(strengthagility 2) and CheckBoxOn(horn) Spell(HORNOFWINTER)

-	if TargetDebuffExpires(BLOODPLAGUE 0 mine=1) and TargetDebuffExpires(FROSTFEVER 0 mine=1) Spell(OUTBREAK)
-	if TargetDebuffExpires(BLOODPLAGUE 0 mine=1) and Runes(unholy 1) Spell(PLAGUESTRIKE)
-	if TargetDebuffExpires(FROSTFEVER 0 mine=1) and Runes(frost 1)
+	Spell(PILLAROFFROST)
+	if BuffPresent(FREEZINGFOG) Spell(HOWLINGBLAST)
+
+	if TargetDebuffExpires(BLOODPLAGUE 2 mine=1) and TargetDebuffExpires(FROSTFEVER 2 mine=1) Spell(OUTBREAK)
+	if TargetDebuffExpires(FROSTFEVER 2 mine=1) and Runes(frost 1)
 	{
 		if Glyph(GLYPHHOWLINGBLAST) Spell(HOWLINGBLAST)
 		unless Glyph(GLYPHHOWLINGBLAST) Spell(ICYTOUCH)
 	}

+	if PetPresent(no) Spell(RAISEDEAD priority=2)
+
+	if TargetDebuffExpires(BLOODPLAGUE 2 mine=1) and Runes(unholy 1) Spell(PLAGUESTRIKE)
+
 	if Runes(unholy 2 frost 2 nodeath=1) or Runes(death 2) Spell(OBLITERATE)
 	if BuffPresent(KILLINGMACHINE) and Runes(unholy 1 frost 1) Spell(OBLITERATE)
-	if Runes(blood 2) Spell(BLOODSTRIKE)
 	Spell(FROSTSTRIKE usable=1)
-	if BuffPresent(FREEZINGFOG) Spell(HOWLINGBLAST)
+	if Runes(blood 2) Spell(BLOODSTRIKE)
 	if Runes(unholy 1 frost 1) Spell(OBLITERATE)
 	if Runes(blood 1) Spell(BLOODSTRIKE)

-	if PetPresent(no) Spell(RAISEDEAD priority=2)
-	if CheckBoxOn(horn) Spell(HORNOFWINTER priority=2)
 	unless Runes(frost 1 unholy 1) Spell(BLOODTAP priority=2)
+	Spell(EMPOWERRUNEWEAPON priority=2)
+	if CheckBoxOn(horn) Spell(HORNOFWINTER priority=2)
 }

 AddIcon help=aoe mastery=2
@@ -176,21 +181,24 @@ AddIcon help=aoe mastery=2
 AddIcon help=main mastery=3
 {
 	if BuffExpires(strengthagility 2) and CheckBoxOn(horn) Spell(HORNOFWINTER)
-	if TargetDebuffExpires(BLOODPLAGUE 0 mine=1) and TargetDebuffExpires(FROSTFEVER 0 mine=1) Spell(OUTBREAK)
+	#if TargetDebuffExpires(BLOODPLAGUE 0 mine=1) and TargetDebuffExpires(FROSTFEVER 0 mine=1) Spell(OUTBREAK)
+	if TargetDebuffExpires(BLOODPLAGUE 3 mine=1) and Runes(unholy 1) Spell(PLAGUESTRIKE)
+	if TargetDebuffExpires(FROSTFEVER 3 mine=1) and Runes(frost 1) Spell(ICYTOUCH)
 	if Runes(unholy 1) and TargetBuffPresent(SHADOWINFUSION stacks=5 target=pet) Spell(DARKTRANSFORMATION)
-	if Runes(blood 2 frost 2 nodeath=1) Spell(FESTERINGSTRIKE)
-	if Runes(death 4) or Runes(unholy 2) Spell(DEATHANDECAY)
 	if Runes(death 4) or Runes(unholy 2) Spell(SCOURGESTRIKE)
+	if Runes(blood 2 frost 2 nodeath=1) Spell(FESTERINGSTRIKE)
+#	if Runes(death 4) or Runes(unholy 2) Spell(DEATHANDECAY)
 	unless BuffPresent(RUNICCORRUPTION mine=1)
 	{
 		if BuffPresent(SUDDENDOOM mine=1) Spell(DEATHCOIL usable=1)
-		if Mana(more 80) Spell(DEATHCOIL usable=1)
+		if Mana(more 90) Spell(DEATHCOIL usable=1)
 	}
-	if Runes(blood 1 frost 1 nodeath=1) Spell(FESTERINGSTRIKE)
-	if Runes(unholy 1) Spell(DEATHANDECAY)
 	if Runes(unholy 1) Spell(SCOURGESTRIKE)
-
+	if Runes(blood 1 frost 1 nodeath=1) Spell(FESTERINGSTRIKE)
+#	if Runes(unholy 1) Spell(DEATHANDECAY)
 	if Mana(more 54) Spell(DEATHCOIL usable=1)
+	unless Runes(unholy 1) Spell(BLOODTAP priority=2)
+	unless Runes(unholy 1) Spell(EMPOWERRUNEWEAPON priority=2)
 	Spell(HORNOFWINTER)
 }

diff --git a/defaut/Druide.lua b/defaut/Druide.lua
index bf622da..fba8efa 100644
--- a/defaut/Druide.lua
+++ b/defaut/Druide.lua
@@ -59,6 +59,7 @@ Define(SWIPECAT 62078) #cat aoe
 Define(THRASH 77758) #bear aoe bleed
 Define(TIGERSFURY 5217) #cat buff
 	SpellInfo(TIGERSFURY cd=30)
+Define(TYPHOON 50516)
 Define(WRATH 5176) #moonkin
 	SpellInfo(WRATH eclipse=-13)

@@ -72,6 +73,7 @@ Define(ECLIPSESOLAR 48517) #Increased by starfire
 Define(SHOOTINGSTARS 93400)
 Define(STAMPEDE 81022)
 Define(FAERIEFIREDEBUFF 91565)
+Define(STRENGTHOFTHEPANTHER 90166) #feral T11 4-pieces bonus

 AddCheckBox(multi L(AOE))
 AddCheckBox(lucioles SpellName(FAERIEFIRE) default)
@@ -88,11 +90,12 @@ ScoreSpells(FAERIEFERAL DEMOROAR MANGLEBEAR LACERATE SAVAGEROAR RIP
 AddIcon help=main mastery=1
 {
 	#Contributed by Grabielz
-	if CheckBoxOn(lucioles) and TargetDebuffExpires(lowerarmor 2) and TargetDeadIn(more 15)
+	if CheckBoxOn(lucioles) and TargetDebuffExpires(FAERIEFIRE 3 mine=1 stacks=3) and TargetDebuffExpires(lowerarmor 2 mine=0) and TargetDeadIn(more 15)
 		Spell(FAERIEFIRE nored=1)

 	if Speed(more 0)
 	{
+		Spell(TYPHOON)
 		if BuffPresent(SHOOTINGSTARS) Spell(STARSURGE)
 		if TargetDebuffExpires(INSECTSWARM 4 mine=1) and TargetDeadIn(more 6)
 			Spell(INSECTSWARM)
@@ -101,6 +104,12 @@ AddIcon help=main mastery=1
 		Spell(MOONFIRE)
 	}

+	if TargetDebuffExpires(MOONFIRE 1 mine=1) and TargetDebuffExpires(SUNFIRE 1 mine=1) and TargetDeadIn(more 6)
+	{
+		if BuffPresent(ECLIPSESOLAR)
+			Spell(SUNFIRE nored=1)
+		Spell(MOONFIRE nored=1)
+	}

 	if TargetDebuffExpires(INSECTSWARM 1 mine=1) and TargetDeadIn(more 6)
 		Spell(INSECTSWARM nored=1)
@@ -108,13 +117,6 @@ AddIcon help=main mastery=1
 	if TargetDebuffExpires(INSECTSWARM 3 mine=1) and TargetDeadIn(more 6) and BuffPresent(ECLIPSESOLAR) and Eclipse(less 16)
 		Spell(INSECTSWARM nored=1)

-	if TargetDebuffExpires(MOONFIRE 1 mine=1) and TargetDebuffExpires(SUNFIRE 1 mine=1) and TargetDeadIn(more 6)
-	{
-		if BuffPresent(ECLIPSESOLAR)
-			Spell(SUNFIRE nored=1)
-		Spell(MOONFIRE nored=1)
-	}
-
 	Spell(STARSURGE)

 	if BuffPresent(ECLIPSELUNAR) or Eclipse(equal -100)
@@ -177,59 +179,88 @@ AddIcon help=main mastery=2

 	if Stance(3) # cat
 	{
-		if BuffPresent(STAMPEDE) Spell(RAVAGE)
+		#tigers_fury,if=energy<=26
+		if Mana(less 27) Spell(TIGERSFURY)
+
+		#mangle_cat,if=set_bonus.tier11_4pc_melee&(buff.t11_4pc_melee.stack<3|buff.t11_4pc_melee.remains<3)
+		if ArmorSetParts(T11 more 3) and BuffExpires(STRENGTHOFTHEPANTHER 3 stacks=3) Spell(MANGLECAT)

+		#faerie_fire_feral,if=debuff.faerie_fire.stack<3|!(debuff.sunder_armor.up|debuff.expose_armor.up)
 		if CheckBoxOn(lucioles) and	TargetDebuffExpires(lowerarmor 2 mine=0) and TargetDebuffExpires(FAERIEFIREDEBUFF 3 stacks=3) and TargetDeadIn(more 15)
 			Spell(FAERIEFERAL)
-
-		#De-synchronize Roar and Rip if are both present but will expire with less than 6 seconds between
-		#TODO: don't work correctly, I think
-		#if ComboPoints(more 2) and BuffPresent(SAVAGEROAR 6) and TargetDebuffPresent(RIP 6 mine=1) and
-		#		less than 6s between BuffExpires(SAVAGEROAR) and TargetDebuffExpires(RIP mine=1 forceduration=22)
-		#{
-		#	Spell(RIP)
-		#}
-
-		#Extends Rip with shred if glyph
-		if Glyph(GLYPHOFSHRED) and TargetDebuffPresent(RIP mine=1) and TargetDebuffExpires(RIP 4 mine=1) and Counter(ripshreds less 3) Spell(SHRED)
-
-		#Enter fury before applying rip
-
-		if ComboPoints(more 4)
-		{
-			if TargetDeadIn(less 7) Spell(FEROCIOUSBITE priority=4)
-			#Rip has priority over Savage Roar
-			if BuffExpires(BERSERK 0) and TargetDebuffExpires(RIP 1 mine=1) Spell(TIGERSFURY)
-			if TargetDebuffExpires(RIP 0 mine=1) Spell(RIP)
-			if BuffExpires(SAVAGEROAR 2) Spell(SAVAGEROAR)
-			#If both are already present for at least 6 seconds, try Ferocious bite
-			if {TargetDebuffPresent(RIP 10 mine=1) and BuffPresent(SAVAGEROAR 6)} or TargetLifePercent(less 25)
-			{
-				#if BuffExpires(BERSERK 0) or {BuffPresent(BERSERK) and Mana(less 20)} I don't know what is the point of this
-				Spell(FEROCIOUSBITE)
-			}
-		}

+		#mangle_cat,if=debuff.mangle.remains<=2&(!debuff.mangle.up|debuff.mangle.remains>=0.0)
 		if TargetDebuffExpires(bleed 0) and CheckBoxOn(mangle)
 			Spell(MANGLECAT)
-		if TargetDebuffExpires(RAKE 0 mine=1) and TargetDeadIn(more 10)
+
+		#ravage,if=buff.stampede_cat.up&buff.stampede_cat.remains<=1
+		if BuffPresent(STAMPEDE) and BuffExpires(STAMPEDE 1) Spell(RAVAGE)
+
+		#berserk,if=time_to_max_energy>=2.0&!buff.tigers_fury.up&cooldown.tigers_fury.remains>15
+		if 2s before Mana(more 99) and BuffExpires(TIGERSFURY) and 15s before Spell(TIGERSFURY) Spell(BERSERK)
+
+		#ferocious_bite,if=buff.combo_points.stack>=1&dot.rip.ticking&dot.rip.remains<=1&target.health_pct<=25
+		if ComboPoints(more 0) and TargetDebuffPresent(RIP mine=1) and TargetDebuffExpires(RIP 1 mine=1) and TargetLifePercent(less 25)
+			Spell(FEROCIOUSBITE)
+
+		#ferocious_bite,if=buff.combo_points.stack>=5&dot.rip.ticking&target.health_pct<=25
+		if ComboPoints(more 4) and TargetDebuffPresent(RIP mine=1) and TargetLifePercent(less 25)
+			Spell(FEROCIOUSBITE)
+
+		#rip,if=buff.combo_points.stack>=5&target.time_to_die>=6&dot.rip.remains<2.0&(buff.berserk.up|dot.rip.remains<=cooldown.tigers_fury.remains)
+		if ComboPoints(more 4) and TargetDeadIn(more 6) and TargetDebuffExpires(RIP 2 mine=1) and
+				{BuffPresent(BERSERK) or {target.debuffExpires(RIP mine=1)<spell(TIGERSFURY)}}
+			Spell(RIP)
+
+		#rake,if=target.time_to_die>=8.5&buff.tigers_fury.up&dot.rake.remains<9.0&(!dot.rake.ticking|dot.rake.multiplier<multiplier)
+		#not sure what this multiplier is
+		if TargetDeadIn(more 8.5) and BuffPresent(TIGERSFURY) and TargetDebuffExpires(RAKE 0 mine=1)
 			Spell(RAKE)
-
-		if CheckBoxOn(shred)
-		{
-			if Mana(more 69) Spell(SHRED priority=2)
-			if BuffPresent(CLEARCASTING) or TargetDeadIn(less 10) or BuffPresent(BERSERK)
-					Spell(SHRED)
-			if ComboPoints(less 5) and TargetDebuffExpires(RIP 3 mine=1) Spell(SHRED)
-			#if ComboPoints(less 1) and BuffExpires(SAVAGEROAR 2) Spell(SHRED) no longer necessary, savage roar upkeeping is less important
-		}
-		if CheckBoxOff(shred) Spell(CLAW)
+		#rake,if=target.time_to_die>=dot.rake.remains&dot.rake.remains<3.0&(buff.berserk.up|energy>=71|(cooldown.tigers_fury.remains+0.8)>=dot.rake.remains)
+		if {target.timeToDie()>target.debuffExpires(RAKE mine=1)} and TargetDebuffExpires(RAKE 3 mine=1) and {BuffPresent(BERSERK) or Mana(more 70) or
+				{{spell(TIGERSFURY)+0.8}>target.debuffExpires(RAKE mine=1)}}
+			Spell(RAKE)
+
+		#shred,if=buff.omen_of_clarity.react
+		if BuffPresent(CLEARCASTING) Spell(SHRED)
+
+		#savage_roar,if=buff.combo_points.stack>=1&buff.savage_roar.remains<=1
+		if ComboPoints(more 0) and BuffExpires(SAVAGEROAR 1) Spell(SAVAGEROAR)
+
+		#savage_roar,if=target.time_to_die>=9&buff.combo_points.stack>=5&dot.rip.ticking&dot.rip.remains<=12&@(dot.rip.remains-buff.savage_roar.remains)<=3
+		if TargetDeadIn(more 9) and ComboPoints(more 4) and TargetDebuffPresent(RIP mine=1) and TargetDebuffExpires(RIP 12 mine=1)
+				and {{target.debuffExpires(RIP mine=1) - buffExpires(SAVAGEROAR)}<3}
+			Spell(SAVAGEROAR)
+
+		#ferocious_bite,if=(target.time_to_die<=4&buff.combo_points.stack>=5)|target.time_to_die<=1
+		if {TargetDeadIn(less 4) and ComboPoints(more 4)} or TargetDeadIn(less 1) Spell(FEROCIOUSBITE)
+		#ferocious_bite,if=level>80&buff.combo_points.stack>=5&dot.rip.remains>=14.0&buff.savage_roar.remains>=10.0
+		if ComboPoints(more 4) and TargetDebuffPresent(RIP 14 mine=1) and BuffPresent(SAVAGEROAR 10) Spell(FEROCIOUSBITE)
+		#shred,extend_rip=1,if=dot.rip.ticking&dot.rip.remains<=4&target.health_pct>25
+		if Glyph(GLYPHOFSHRED) and Counter(ripshreds less 3) and TargetDebuffPresent(RIP mine=1) and TargetDebuffExpires(RIP 4 mine=1) and TargetLifePercent(more 25) Spell(SHRED)
+
+		#ravage,if=buff.stampede_cat.up&!buff.omen_of_clarity.react&buff.tigers_fury.up
+		if BuffPresent(STAMPEDE) and BuffExpires(CLEARCASTING) and BuffPresent(TIGERSFURY) Spell(RAVAGE)
+		#mangle_cat,if=set_bonus.tier11_4pc_melee&buff.t11_4pc_melee.stack<3
+		if ArmorSetParts(T11 more 3) and BuffExpires(STRENGTHOFTHEPANTHER 0 stacks=3) Spell(MANGLECAT)
+
+		#shred,if=buff.combo_points.stack<=4&dot.rake.remains>3.0&dot.rip.remains>3.0&(time_to_max_energy<=2.0|(buff.berserk.up&energy>=20))
+		if ComboPoints(less 5) and TargetDebuffPresent(RAKE 3 mine=1) and TargetDebuffPresent(RIP 3 mine=1) and {2s before Mana(more 99) or {BuffPresent(BERSERK) and Mana(more 20)}}
+			Spell(SHRED)
+		#shred,if=cooldown.tigers_fury.remains<=3.0
+		if 3s before Spell(TIGERSFURY) Spell(SHRED)
+		#shred,if=target.time_to_die<=dot.rake.duration
+		if target.timeToDie()<target.debuffExpires(RAKE mine=1) Spell(SHRED)
+		#shred,if=buff.combo_points.stack=0&(buff.savage_roar.remains<=2.0|dot.rake.remains>=5.0)
+		if ComboPoints(less 1) and {BuffExpires(SAVAGEROAR 2) or TargetDebuffPresent(RAKE 5 mine=1)} Spell(SHRED)
+		#shred,if=!dot.rip.ticking|time_to_max_energy<=1.0
+		if TargetDebuffExpires(RIP 0 mine=1) or 1s before Mana(more 99) Spell(SHRED)
 	}
 }

 AddIcon help=cd mastery=2
 {
-	unless BuffPresent(TIGERSFURY) Spell(BERSERK)
+	#unless BuffPresent(TIGERSFURY) Spell(BERSERK)
 	Item(Trinket0Slot usable=1)
 	Item(Trinket1Slot usable=1)
 }
diff --git a/defaut/Guerrier.lua b/defaut/Guerrier.lua
index 9e5e27a..67122f3 100644
--- a/defaut/Guerrier.lua
+++ b/defaut/Guerrier.lua
@@ -26,6 +26,7 @@ Define(DEMOSHOUT 1160)
 Define(DEVASTATE 20243)
 	SpellAddTargetDebuff(DEVASTATE SUNDERARMORDEBUFF=30)
 Define(EXECUTE 5308)
+	SpellAddBuff(EXECUTE EXECUTIONER=9)
 Define(HEROICLEAP 6544)
 Define(HEROICSTRIKE 78)
 	SpellInfo(HEROICSTRIKE cd=3)
@@ -69,11 +70,14 @@ Define(WHIRLWIND 1680)

 #Buffs
 Define(BLOODSURGE 46916)
-Define(TASTEFORBLOOD 56636)
+Define(TASTEFORBLOOD 60503)
 Define(ENRAGE 14202)
 Define(EXECUTIONER 90806)
 Define(SUNDERARMORDEBUFF 58567)
 Define(RENDDEBUFF 94009)
+Define(INCITE 86627)
+Define(BATTLETRANCE 12964)
+Define(SLAUGHTER 84584)

 #Talents
 Define(SLAMTALENT 2233)
@@ -97,13 +101,22 @@ AddIcon help=main mastery=1
 	if TargetDebuffExpires(SUNDERARMORDEBUFF 3 stacks=3) and CheckBoxOn(sunder) and TargetDebuffExpires(lowerarmor 2 mine=0) Spell(SUNDERARMOR nored=1)

 	if Mana(less 20) Spell(DEADLYCALM)
+	if CheckBoxOn(multi)
+	{
+		Spell(SWEEPINGSTRIKES)
+		if BuffExpires(SWEEPINGSTRIKES) and BuffExpires(DEADLYCALM) Spell(BLADESTORM)
+		Spell(CLEAVE)
+	}
+	if BuffExpires(TASTEFORBLOOD 1.5) Spell(OVERPOWER)
 	if TargetDebuffExpires(RENDDEBUFF) Spell(REND)
-	if CheckBoxOn(multi) Spell(BLADESTORM)
 	Spell(COLOSSUSSMASH)
 	Spell(MORTALSTRIKE)
-	Spell(OVERPOWER usable=1)
+	#overpower,if=!buff.lambs_to_the_slaughter.up&rage>35&target.health_pct<20
+	if BuffExpires(SLAUGHTER 0) and Mana(more 35) and TargetLifePercent(less 20)
+		Spell(OVERPOWER)
     if TargetLifePercent(less 20) Spell(EXECUTE)
-	Spell(SLAM)
+	Spell(OVERPOWER)
+	unless 1.5s before Spell(MORTALSTRIKE) Spell(SLAM)
 }

 AddIcon help=main mastery=2
@@ -113,16 +126,19 @@ AddIcon help=main mastery=2
 	if TargetClassification(worldboss) and CheckBoxOn(demo) and TargetDebuffExpires(lowerphysicaldamage 2) Spell(DEMOSHOUT nored=1)
 	if TargetDebuffExpires(SUNDERARMORDEBUFF 3 stacks=3) and CheckBoxOn(sunder) and TargetDebuffExpires(lowerarmor 2 mine=0) Spell(SUNDERARMOR nored=1)

+	if BuffExpires(EXECUTIONER 1.5 stacks=5) and TargetLifePercent(less 20) Spell(EXECUTE)
+
 	if CheckBoxOn(multi) Spell(WHIRLWIND)
 	Spell(COLOSSUSSMASH)
-    if TargetLifePercent(less 20) and BuffExpires(EXECUTIONER 0 stacks=5) Spell(EXECUTE)
-	Spell(RAGINGBLOW usable=1)
-    if TargetLifePercent(less 20) Spell(EXECUTE) #Just spam execute
-	Spell(BLOODTHIRST)
+	if TargetDebuffPresent(COLOSSUSSMASH mine=1) and TargetLifePercent(less 20) Spell(EXECUTE)
+	if BuffExpires(DEATHWISH 0) and BuffExpires(RECKLESSNESS 0) and BuffExpires(ENRAGE 0) and Mana(less 15) and
+		1s before Spell(RAGINGBLOW) Spell(BERSERKERRAGE)
+	if {BuffPresent(DEATHWISH) or BuffPresent(RECKLESSNESS) or BuffPresent(ENRAGE) or BuffPresent(BERSERKERRAGE)}
+		and TargetLifePercent(more 20) Spell(RAGINGBLOW)
+
+    Spell(BLOODTHIRST)
 	Spell(VICTORYRUSH usable=1)
-	#if TargetLifePercent(less 20) and BuffExpires(EXECUTIONER 3) Spell(EXECUTE)
 	if BuffPresent(BLOODSURGE) Spell(SLAM)
-    if BuffExpires(DEATHWISH) and BuffExpires(RECKLESSNESS) and BuffExpires(ENRAGE) Spell(BERSERKERRAGE)
 }


@@ -145,10 +161,27 @@ AddIcon help=main mastery=3
 	Spell(DEVASTATE)
 }

-AddIcon help=offgcd
+AddIcon help=offgcd mastery=1
+{
+	if target.IsInterruptible() Spell(PUMMEL)
+	if CheckBoxOn(multi) Spell(CLEAVE)
+	if Mana(more 65) or BuffPresent(DEADLYCALM) or BuffPresent(INCITE) or BuffPresent(BATTLETRANCE)
+		Spell(HEROICSTRIKE)
+}
+
+AddIcon help=offgcd mastery=2
+{
+	if target.IsInterruptible() Spell(PUMMEL)
+	if CheckBoxOn(multi) Spell(CLEAVE)
+	if {Mana(more 60) or BuffPresent(BATTLETRANCE) or BuffPresent(INCITE)} and TargetLifePercent(more 20)
+		Spell(HEROICSTRIKE)
+}
+
+AddIcon help=offgcd mastery=3
 {
-	if Mana(more 60) and CheckBoxOn(multi) Spell(CLEAVE)
-	if Mana(more 60) and CheckBoxOff(multi) Spell(HEROICSTRIKE)
+	if target.IsInterruptible() Spell(SHIELDBASH)
+	if CheckBoxOn(multi) Spell(CLEAVE)
+	if Mana(more 60) Spell(HEROICSTRIKE)
 }

 AddIcon help=cd mastery=1
diff --git a/defaut/Mage.lua b/defaut/Mage.lua
index e9b16b9..b5183a0 100644
--- a/defaut/Mage.lua
+++ b/defaut/Mage.lua
@@ -1,46 +1,53 @@
 Ovale.defaut["MAGE"]=
 [[
+#Contributed by Hinalover
 #Spells
 Define(ARCANEBARRAGE 44425) #arcane instant
-	SpellAddDebuff(ARCANEBARRAGE ARCANEBLASTDEBUFF=0)
+    SpellAddDebuff(ARCANEBARRAGE ARCANEBLASTDEBUFF=0)
 Define(ARCANEBLAST 30451) #arcane stacks*4 cost increased
-	SpellAddDebuff(ARCANEBLAST ARCANEBLASTDEBUFF=10)
+    SpellAddDebuff(ARCANEBLAST ARCANEBLASTDEBUFF=10)
 Define(ARCANEMISSILES 5143) #arcane channel
-	SpellAddDebuff(ARCANEMISSILES ARCANEBLASTDEBUFF=0 ARCANEMISSILEBUFF=0)
-Define(ARCANEPOWER 12042) #arcane cd
-	SpellInfo(ARCANEPOWER cd=84)
+    SpellAddDebuff(ARCANEMISSILES ARCANEBLASTDEBUFF=0 ARCANEMISSILEBUFF=0)
+Define(ARCANEPOWER 12042) #arcane cd
+    SpellInfo(ARCANEPOWER cd=84)
 Define(COLDSNAP 11958) #frost reset cd
+    SpellInfo(COLDSNAP cd=384)
 Define(COMBUSTION 11129) #fire cd consume dot
-	SpellInfo(COMBUSTION cd=180)
+    SpellInfo(COMBUSTION cd=180)
+Define(COUNTERSPELL 2139)
+    SpellInfo(COUNTERSPELL cd=24)
 Define(DEEPFREEZE 44572) #frost instant
-	SpellAddBuff(DEEPFREEZE FINGERSOFFROST=-1)
+    SpellAddBuff(DEEPFREEZE FINGERSOFFROST=-1)
 Define(EVOCATION 12051)
-	SpellInfo(EVOCATION cd=240)
+    SpellInfo(EVOCATION cd=240)
 Define(FIREBLAST 2136) #fire instant
 Define(FIREBALL 133) #fire 2.5
 Define(FLAMEORB 82731)
-	SpellInfo(FLAMEORB cd=60)
+    SpellInfo(FLAMEORB cd=60)
 Define(FROSTBOLT 116) #frost
 Define(FROSTFIREBOLT 44614) #frost+fire
-	SpellAddBuff(FROSTFIREBOLT BRAINFREEZE=-1 FINGERSOFFROST=-1)
+    SpellAddBuff(FROSTFIREBOLT BRAINFREEZE=-1 FINGERSOFFROST=-1)
 Define(ICEARMOR 7302)
 Define(ICELANCE 30455) #frost instant
-	SpellAddBuff(ICELANCE FINGERSOFFROST=-1)
+    SpellAddBuff(ICELANCE FINGERSOFFROST=-1)
 Define(ICYVEINS 12472) #frost cd
-	SpellInfo(ICYVEINS cd=144)
+    SpellInfo(ICYVEINS cd=144)
 Define(LIVINGBOMB 44457) #fire dot
-	SpellAddTargetDebuff(LIVINGBOMB LIVINGBOMB=12)
+    SpellAddTargetDebuff(LIVINGBOMB LIVINGBOMB=12)
 Define(MAGEARMOR 6117)
 Define(MIRRORIMAGE 55342)
-	SpellInfo(MIRRORIMAGE cd=180)
+    SpellInfo(MIRRORIMAGE cd=180)
 Define(MOLTENARMOR 30482)
-Define(PRESENCEOFMIND 12043) #arcane next spell instant
 Define(PYROBLAST 11366) #fire dot
-	SpellAddTargetDebuff(PYROBLAST PYROBLAST=12)
-	SpellAddBuff(PYROBLAST HOTSTREAK=0)
+    SpellAddTargetDebuff(PYROBLAST PYROBLAST=12)
+    SpellAddBuff(PYROBLAST HOTSTREAK=0)
 Define(SCORCH 2948) #fire 1.5 (cast while moving with firestarter talent)
+Define(SPELLSTEAL 30449)
 Define(SUMMONWATERELEMENTAL 31687) #frost pet
-	SpellInfo(SUMMONWATERELEMENTAL cd=180)
+    SpellInfo(SUMMONWATERELEMENTAL cd=180)
+
+Define(PETFREEZE 33395) #Frost pet freeze ability
+    SpellInfo(PETFREEZE cd=25)

 #Buff
 Define(BRAINFREEZE 57761) #frost (instant fireball/frostfire bolt)
@@ -48,93 +55,147 @@ Define(FINGERSOFFROST 44544) #frost boost ice lance/deep freeze
 Define(HOTSTREAK 48108) #fire instant pyroblast
 Define(ARCANEBLASTDEBUFF 36032)
 Define(ARCANEMISSILEBUFF 79683)
+Define(PRESENCEOFMIND 12043) #arcane next spell instant
+Define(CLEARCASTING 12536)

 #Item
 Define(MANAGEMITEM 36799)
+Define(VOLCANICPOTION 58091)

 #Debuff
 Define(IGNITE 12654)
+Define(CRITICALMASS 22959)
+Define(SHADOWANDFLAME 17800)

 #Talent
 Define(FIRESTARTERTALENT 11431)

-ScoreSpells(SCORCH PYROBLAST LIVINGBOMB FROSTFIREBOLT FIREBALL SUMMONWATERELEMENTAL FROSTBOLT ARCANEBLAST ARCANEMISSILES ARCANEBARRAGE
-			DEEPFREEZE ICELANCE)
+#CheckBoxes
+AddListItem(fb fb SpellName(FIREBALL) default)
+AddListItem(fb ffb SpellName(FROSTFIREBOLT) mastery=2)
+AddListItem(frb frb SpellName(FROSTBOLT) default)
+AddListItem(frb ffb SpellName(FROSTFIREBOLT) mastery=3)
+
+ScoreSpells(SCORCH PYROBLAST LIVINGBOMB FROSTFIREBOLT FIREBALL SUMMONWATERELEMENTAL PETFREEZE FROSTBOLT ARCANEBLAST ARCANEMISSILES ARCANEBARRAGE
+            DEEPFREEZE ICELANCE)

 AddIcon help=main mastery=1
 {
-	unless InCombat() if BuffExpires(MAGEARMOR 400) and BuffExpires(MOLTENARMOR 400) and BuffExpires(ICEARMOR 400) Spell(MAGEARMOR)
-
-	Spell(FLAMEORB)
-	if Speed(more 0) Spell(ARCANEBARRAGE)
-	unless 15s before Spell(EVOCATION)
-	{
-		#Mana conserve
-		if DebuffPresent(ARCANEBLASTDEBUFF stacks=4) or
-			{ManaPercent(less 90) and DebuffPresent(ARCANEBLASTDEBUFF stacks=3)} or
-			{ManaPercent(less 85) and DebuffPresent(ARCANEBLASTDEBUFF stacks=2)}
-		{
-			if BuffPresent(ARCANEMISSILEBUFF) Spell(ARCANEMISSILES usable=1)
-			Spell(ARCANEBARRAGE)
-		}
-		if ManaPercent(less 60) Item(MANAGEMITEM usable=1)
-		Spell(ARCANEBLAST)
-	}
-	if 15s before Spell(EVOCATION)
-	{
-		if ManaPercent(less 40) Spell(EVOCATION)
+    unless InCombat() if BuffExpires(MAGEARMOR 400) and BuffExpires(MOLTENARMOR 400) and BuffExpires(ICEARMOR 400) Spell(MAGEARMOR)
+
+    if BuffPresent(PRESENCEOFMIND) Spell(ARCANEBLAST)
+    if TargetDeadIn(less 34) and ManaPercent(more 5) Spell(ARCANEBLAST)
+    if BuffPresent(CLEARCASTING) and DebuffPresent(ARCANEBLASTDEBUFF stacks=2) Spell(ARCANEBLAST)
+
+    if 26s before Spell(EVOCATION) and ManaPercent(more 26) Spell(ARCANEBLAST)
+    if ManaPercent(more 94) Spell(ARCANEBLAST)
+    if DebuffPresent(ARCANEBLASTDEBUFF) unless DebuffPresent(ARCANEBLASTDEBUFF stacks=4) or BuffPresent(heroism)
 		Spell(ARCANEBLAST)
-	}
+
+	if DebuffPresent(ARCANEBLASTDEBUFF) and BuffPresent(heroism) unless DebuffPresent(ARCANEBLASTDEBUFF stacks=3)
+        Spell(ARCANEBLAST)
+
+	if TargetDeadIn(more 31) Spell(EVOCATION)
+    Spell(ARCANEMISSILES)
+    Spell(ARCANEBARRAGE)
+    if Speed(more 0) Spell(FIREBLAST)
+    if Speed(more 0) Spell(ICELANCE)
 }

 AddIcon help=main mastery=2
 {
-	unless InCombat() if BuffExpires(MAGEARMOR 400) and BuffExpires(MOLTENARMOR 400) and BuffExpires(ICEARMOR 400) Spell(MOLTENARMOR)
-
-	Spell(FLAMEORB)
-	if TalentPoints(FIRESTARTERTALENT more 0) and Speed(more 0) Spell(SCORCH)
-	if BuffPresent(HOTSTREAK) Spell(PYROBLAST)
-	if TargetDebuffExpires(LIVINGBOMB 0 mine=1) and TargetDeadIn(more 12) Spell(LIVINGBOMB)
-	if TargetDebuffExpires(PYROBLAST 2.5 haste=spell mine=1) Spell(PYROBLAST)
-	Spell(FIREBALL)
+    unless InCombat() if BuffExpires(MAGEARMOR 400) and BuffExpires(MOLTENARMOR 400) and BuffExpires(ICEARMOR 400) Spell(MOLTENARMOR)
+
+    if TargetDebuffExpires(CRITICALMASS) and TargetDebuffExpires(SHADOWANDFLAME) Spell(SCORCH)
+    if TargetDebuffPresent(LIVINGBOMB mine=1) and TargetDebuffPresent(IGNITE mine=1)
+            and TargetDebuffPresent(PYROBLAST mine=1)
+        Spell(COMBUSTION)
+    if TargetDebuffExpires(LIVINGBOMB 0 mine=1) and TargetDeadIn(more 12) Spell(LIVINGBOMB)
+    if BuffPresent(HOTSTREAK) Spell(PYROBLAST)
+    if TalentPoints(FIRESTARTERTALENT more 0) and Speed(more 0) Spell(SCORCH)
+    if ManaPercent(less 5) Spell(SCORCH)
+    if List(fb fb) and TargetDeadIn(less 60) Spell(FIREBALL)
+    if List(fb ffb) and TargetDeadIn(less 60) Spell(FROSTFIREBOLT)
+    if List(fb fb) and ManaPercent(more 39) Spell(FIREBALL)
+    if List(fb ffb) and ManaPercent(more 39) Spell(FROSTFIREBOLT)
+    if ManaPercent(less 95)
+    {
+           unless 60s before Spell(EVOCATION) Spell(SCORCH)
+    }
+    Spell(EVOCATION)
+    Spell(SCORCH)
 }

 AddIcon help=main mastery=3
 {
-	unless InCombat() if BuffExpires(MAGEARMOR 400) and BuffExpires(MOLTENARMOR 400) and BuffExpires(ICEARMOR 400) Spell(MOLTENARMOR)
+    unless InCombat() if BuffExpires(MAGEARMOR 400) and BuffExpires(MOLTENARMOR 400) and BuffExpires(ICEARMOR 400) Spell(MOLTENARMOR)

-	Spell(FLAMEORB)
-	if PetPresent(no) Spell(SUMMONWATERELEMENTAL)
-	if BuffPresent(FINGERSOFFROST) or Speed(more 0) {Spell(DEEPFREEZE) Spell(ICELANCE)}
-	if BuffPresent(BRAINFREEZE) Spell(FROSTFIREBOLT)
-	Spell(FROSTBOLT)
+    if PetPresent(no) Spell(SUMMONWATERELEMENTAL)
+    if BuffPresent(FINGERSOFFROST stacks=1)  Spell(DEEPFREEZE)
+    if BuffPresent(BRAINFREEZE) and BuffPresent(FINGERSOFFROST) Spell(FROSTFIREBOLT)
+    if BuffPresent(FINGERSOFFROST stacks=2) Spell(ICELANCE)
+    Spell(PETFREEZE)
+    if BuffPresent(FINGERSOFFROST stacks=2) Spell(ICELANCE)
+    if BuffPresent(MOLTENARMOR) and {{manaPercent()*8} < target.timeToDie()} Spell(MAGEARMOR)
+    if ManaPercent(less 5) and TargetDeadIn(less 60) Spell(EVOCATION)
+    if List(frb frb) Spell(FROSTBOLT)
+    if List(frb ffb) Spell(FROSTFIREBOLT)
+    if Speed(more 0) Spell(ICELANCE)
+    if Speed(more 0) Spell(FIREBLAST)
 }

 AddIcon help=cd mastery=1
 {
-	if DebuffPresent(ARCANEBLAST stacks=3) Spell(ARCANEPOWER)
-	Spell(PRESENCEOFMIND)
-	Item(Trinket0Slot usable=1)
-	Item(Trinket1Slot usable=1)
-	Spell(MIRRORIMAGE)
+    if BuffPresent(heroism) or TargetDeadIn(less 40) Item(VOLCANICPOTION)
+    if TargetBuffStealable(yes) Spell(SPELLSTEAL)
+    if TargetIsInterruptible(yes) Spell(COUNTERSPELL)
+    if TargetDeadIn(more 29) Spell(MIRRORIMAGE)
+    if TargetDeadIn(less 34) Spell(ARCANEPOWER)
+    if 26s before Spell(EVOCATION)
+    {
+          if DebuffPresent(ARCANEBLAST stacks=3) or DebuffPresent(ARCANEBLAST stacks=4) Spell(ARCANEPOWER)
+    }
+    if TargetDeadIn(less 35) Item(MANAGEMITEM)
+    if 26s before Spell(EVOCATION)
+    {
+          if DebuffPresent(ARCANEBLASTDEBUFF stacks=3) Item(MANAGEMITEM)
+    }
+    if TargetDeadIn(more 14) Spell(FLAMEORB)
+    Spell(PRESENCEOFMIND)
+    Item(Trinket0Slot usable=1)
+    Item(Trinket1Slot usable=1)
 }

 AddIcon help=cd mastery=2
 {
-	if TargetDebuffPresent(LIVINGBOMB mine=1) and TargetDebuffPresent(IGNITE mine=1)
-			and TargetDebuffPresent(PYROBLAST mine=1)
-		Spell(COMBUSTION)
-	Item(Trinket0Slot usable=1)
-	Item(Trinket1Slot usable=1)
-	Spell(MIRRORIMAGE)
+    if BuffPresent(heroism) or TargetDeadIn(less 40) Item(VOLCANICPOTION)
+    if TargetBuffStealable(yes) Spell(SPELLSTEAL)
+    if TargetIsInterruptible(yes) Spell(COUNTERSPELL)
+    if ManaPercent(less 85) Item(MANAGEMITEM)
+    if TargetDeadIn(more 24) Spell(MIRRORIMAGE)
+    if TargetDeadIn(more 11) Spell(FLAMEORB)
+    Item(Trinket0Slot usable=1)
+    Item(Trinket1Slot usable=1)
 }

 AddIcon help=cd mastery=3
 {
-	Spell(ICYVEINS)
-	Item(Trinket0Slot usable=1)
-	Item(Trinket1Slot usable=1)
-	Spell(MIRRORIMAGE)
+    if BuffPresent(heroism) or TargetDeadIn(less 40) Item(VOLCANICPOTION)
+    if TargetBuffStealable(yes) Spell(SPELLSTEAL)
+    if TargetIsInterruptible(yes) Spell(COUNTERSPELL)
+    if ManaPercent(less 85) Item(MANAGEMITEM)
+    unless 15s before Spell(DEEPFREEZE)
+    {
+          unless 30s before Spell(FLAMEORB)
+          {
+               unless 30s before Spell(ICYVEINS)  Spell(COLDSNAP)
+          }
+    }
+    if TargetDeadIn(more 11) Spell(FLAMEORB)
+    if TargetDeadIn(more 24) Spell(MIRRORIMAGE)
+    Spell(ICYVEINS)
+    Item(Trinket0Slot usable=1)
+    Item(Trinket1Slot usable=1)
 }

 ]]
\ No newline at end of file
diff --git a/defaut/Paladin.lua b/defaut/Paladin.lua
index d2fa6ba..71ca493 100644
--- a/defaut/Paladin.lua
+++ b/defaut/Paladin.lua
@@ -16,6 +16,7 @@ Define(DIVINEPROTECTION 498)
 Define(DIVINESTORM 53385)
 Define(EXORCISM 879)
 	SpellAddBuff(EXORCISM THEARTOFWAR=0)
+Define(GUARDIANOFANCIENTKINGS 86150)
 Define(HAMMEROFWRATH 24275)
 	SpellInfo(HAMMEROFWRATH cd=6)
 Define(HAMMEROFTHERIGHTEOUS 53595)
@@ -57,6 +58,7 @@ AddIcon help=main mastery=1

 AddIcon help=cd mastery=1
 {
+	Spell(GUARDIANOFANCIENTKINGS)
 	Spell(AVENGINGWRATH)
 	Spell(DIVINEFAVOR)
 	Item(Trinket0Slot usable=1)
@@ -88,6 +90,7 @@ AddIcon help=main mastery=2

 AddIcon help=cd mastery=2
 {
+	Spell(GUARDIANOFANCIENTKINGS)
 	Spell(AVENGINGWRATH)
 	Spell(DIVINEPROTECTION)
     Item(Trinket0Slot usable=1)
@@ -101,27 +104,43 @@ AddIcon help=main mastery=3
 		if BuffExpires(SEALRIGHTEOUSNESS 400) and BuffExpires(SEALOFTRUTH 400) Spell(SEALOFTRUTH)
 	}

-	if HolyPower(more 2) and BuffExpires(HANDOFLIGHT) and TargetDeadIn(more 20) Spell(ZEALOTRY)
-    if {HolyPower(more 0) or BuffPresent(HANDOFLIGHT)} and BuffExpires(INQUISITION) Spell(INQUISITION)
-	if  HolyPower(more 2) or BuffPresent(HANDOFLIGHT)
-	{
-		if CheckBoxOff(aoe)  Spell(TEMPLARSVERDICT)
-		if CheckBoxOn(aoe) Spell(DIVINESTORM)
-	}
-    Spell(CRUSADERSTRIKE)
-    unless 0.5s before Spell(CRUSADERSTRIKE)
+	#judgement,if=buff.judgements_of_the_pure.down
+	if BuffExpires(JUDGEMENTSOFTHEPURE 0) Spell(JUDGEMENT)
+	#inquisition,if=(buff.inquisition.down|buff.inquisition.remains<5)&(buff.holy_power.react==3|buff.hand_of_light.react)
+	if BuffExpires(INQUISITION 5) and {HolyPower(equal 3) or BuffPresent(HANDOFLIGHT)} Spell(INQUISITION)
+	#exorcism,if=buff.the_art_of_war.react
+	if BuffPresent(THEARTOFWAR) Spell(EXORCISM)
+	#hammer_of_wrath
+	if TargetLifePercent(less 20) or BuffPresent(AVENGINGWRATH) Spell(HAMMEROFWRATH)
+	#templars_verdict,if=buff.holy_power.react==3
+	if HolyPower(more 2) {if CheckBoxOn(aoe) Spell(DIVINESTORM) Spell(TEMPLARSVERDICT)}
+	#crusader_strike,if=buff.hand_of_light.react&(buff.hand_of_light.remains>2)&(buff.holy_power.react<3)
+	if BuffPresent(HANDOFLIGHT 3) and HolyPower(less 3) Spell(CRUSADERSTRIKE)
+	#templars_verdict,if=buff.hand_of_light.react
+	if BuffPresent(HANDOFLIGHT) {if CheckBoxOn(aoe) Spell(DIVINESTORM) Spell(TEMPLARSVERDICT)}
+	#crusader_strike
+	Spell(CRUSADERSTRIKE)
+	#judgement,if=buff.judgements_of_the_pure.remains<2
+	if BuffExpires(JUDGEMENTSOFTHEPURE 2) Spell(JUDGEMENT)
+	#wait,sec=0.1,if=cooldown.crusader_strike.remains<0.75
+	unless 0.75 before Spell(CRUSADERSTRIKE)
 	{
-   		if TargetLifePercent(less 20) or BuffPresent(AVENGINGWRATH) Spell(HAMMEROFWRATH)
-   		if BuffPresent(THEARTOFWAR) Spell(EXORCISM)
-   		Spell(JUDGEMENT)
-   		Spell(HOLYWRATH)
+		#judgement
+		Spell(JUDGEMENT)
+		#holy_wrath
+		Spell(HOLYWRATH)
+		#consecration
+		if CheckBoxOn(aoe) Spell(CONSECRATE)
+		#divine_plea
+		Spell(DIVINEPLEA)
 	}
-    if CheckBoxOn(aoe) Spell(CONSECRATE)
 }

 AddIcon help=cd mastery=3
 {
-	Spell(AVENGINGWRATH)
+	Spell(GUARDIANOFANCIENTKINGS)
+	if BuffExpires(ZEALOTRY)
+		Spell(AVENGINGWRATH)
     Item(Trinket0Slot usable=1)
     Item(Trinket1Slot usable=1)
 }
diff --git a/defaut/Voleur.lua b/defaut/Voleur.lua
index e3c4285..c614f7f 100644
--- a/defaut/Voleur.lua
+++ b/defaut/Voleur.lua
@@ -4,6 +4,8 @@ Ovale.defaut["ROGUE"] =
 Define(ADRENALINERUSH 13750)
 	SpellInfo(ADRENALINERUSH cd=180)
 	SpellAddBuff(ADRENALINERUSH ADRENALINERUSH=15)
+Define(AMBUSH 8676)
+	SpellInfo(AMBUSH combo=2 mana=60)
 Define(BACKSTAB 53)
 	SpellInfo(BACKSTAB combo=1)
 Define(BLADEFLURRY 13877)
@@ -25,6 +27,8 @@ Define(GARROTE 703)
 	SpellAddTargetDebuff(GARROTE GARROTE=18)
 Define(MUTILATE 1329)
 	SpellInfo(MUTILATE combo=1)
+Define(PREMEDITATION 14183)
+	SpellInfo(PREMEDITATION cd=20)
 Define(PREPARATION 14185)
 	SpellInfo(PREPARATION cd=300)
 Define(REVEALINGSTRIKE 84617)
@@ -35,15 +39,33 @@ Define(RUPTURE 1943)
 	SpellAddTargetDebuff(RUPTURE RUPTURE=8)
 Define(SINISTERSTRIKE 1752)
 	SpellInfo(SINISTERSTRIKE combo=1)
+Define(SHADOWDANCE 51713)
+	SpellInfo(SHADOWDANCE cd=60)
+	SpellAddBuff(SHADOWDANCE SHADOWDANCE=6)
+Define(SHADOWSTEP 36554)
+	SpellInfo(SHADOWSTEP cd=20)
+	SpellAddBuff(SHADOWSTEP SHADOWSTEPBUFF=10)
 Define(SLICEANDDICE 5171)
 	SpellInfo(SLICEANDDICE combo=-5)
 	SpellAddBuff(SLICEANDDICE SLICEANDDICE=10)
+Define(STEALTH 1784)
 Define(TRICKSOFTHETRADE 57934)
 	SpellInfo(TRICKSOFTHETRADE cd=30)
+Define(VANISH 1856)
+	SpellInfo(VANISH cd=180)
+	SpellAddBuff(VANISH VANISHBUFF=3)
 Define(VENDETTA 79140)
 	SpellInfo(VENDETTA cd=120)
 	SpellAddTargetDebuff(VENDETTA VENDETTA=30)

+#Buffs
+Define(SHADOWSTEPBUFF 36563)
+Define(VANISHBUFF 11327)
+
+#Items
+Define(INSTANTPOISON 43231)
+Define(DEADLYPOISON 43233)
+
 #Talents
 Define(TALENTCUTTOTHECHASE 2070)

@@ -51,74 +73,132 @@ ScoreSpells(SLICEANDDICE HUNGERFORBLOOD ENVENOM RUPTURE EVISCERATE MUTILATE SINI

 AddIcon help=main mastery=1
 {
+	unless InCombat()
+	{
+		if WeaponEnchantExpires(mainhand 400) Item(INSTANTPOISON)
+		if WeaponEnchantExpires(offhand 400) Item(DEADLYPOISON)
+	}
+
+	if BuffPresent(STEALTHED) Spell(GARROTE)
 	unless BuffPresent(SLICEANDDICE) if ComboPoints(more 0)	Spell(SLICEANDDICE)
 	if TargetDebuffExpires(VENDETTA) and TargetDeadIn(more 20) Spell(VENDETTA)

-	if ComboPoints(more 3) and Mana(more 69)
+	if ComboPoints(more 3)
 	{
-		if BuffExpires(SLICEANDDICE 12)
-		{
-			if TalentPoints(TALENTCUTTOTHECHASE more 0)
-				Spell(ENVENOM)
-			Spell(SLICEANDDICE)
-		}
-		if TargetDebuffExpires(RUPTURE 0) and TargetDeadIn(more 6)
+		#rupture,if=!ticking&combo_points>=4&target.time_to_die>15&buff.slice_and_dice.remains>6
+		if TargetDebuffExpires(RUPTURE 0 mine=1) and TargetDeadIn(more 15) and BuffPresent(SLICEANDDICE 6)
 			Spell(RUPTURE)
-		Spell(ENVENOM)
+		#envenom,if=combo_points>=4&buff.envenom.down
+		#envenom,if=combo_points>=4&energy>90
+		if BuffExpires(ENVENOM 0) or Mana(more 89) Spell(ENVENOM)
 	}
+
+	#envenom,if=combo_points>=2&buff.slice_and_dice.remains<2
+	if TalentPoints(TALENTCUTTOTHECHASE more 0) and ComboPoints(more 1) and BuffExpires(SLICEANDDICE 2)
+		Spell(ENVENOM)
+
 	if ComboPoints(less 4)
 	{
+		#backstab,if=combo_points<4&target.health_pct<35
 		if TargetLifePercent(less 35) Spell(BACKSTAB)
 		Spell(MUTILATE)
 	}
 }

+AddIcon help=cd mastery=1
+{
+	if Mana(less 70) Spell(COLDBLOOD)
+	Item(Trinket0Slot usable=1)
+	Item(Trinket1Slot usable=1)
+	if Mana(more 50) Spell(VANISH)
+}
+
 AddIcon help=main mastery=2
 {
-	unless BuffPresent(SLICEANDDICE) if ComboPoints(more 0)	Spell(SLICEANDDICE)
-
-	if ComboPoints(more 4) and Mana(more 69)
+	unless InCombat()
 	{
-		if BuffExpires(SLICEANDDICE 12) Spell(SLICEANDDICE)
-
-		if TargetDebuffExpires(RUPTURE 0) and TargetDeadIn(more 6)
-			Spell(RUPTURE)
-		Spell(EVISCERATE)
+		if WeaponEnchantExpires(mainhand 400) Item(INSTANTPOISON)
+		if WeaponEnchantExpires(offhand 400) Item(DEADLYPOISON)
 	}
+
+	#slice_and_dice,if=buff.slice_and_dice.down&time<4
+	#slice_and_dice,if=buff.slice_and_dice.remains<2&combo_points>=3
+	if {BuffExpires(SLICEANDDICE 0) and ComboPoints(more 0)} or {BuffExpires(SLICEANDDICE 2) and ComboPoints(more 2)}
+		Spell(SLICEANDDICE)

-	if ComboPoints(equal 4) Spell(REVEALINGSTRIKE)
-	if ComboPoints(less 4) Spell(SINISTERSTRIKE)
+	#rupture,if=!ticking&combo_points=5&target.time_to_die>10
+	if ComboPoints(more 4) and TargetDebuffExpires(RUPTURE 0 mine=1) and TargetDeadIn(more 10) Spell(RUPTURE)
+	#eviscerate,if=combo_points=5&buff.slice_and_dice.remains>7&dot.rupture.remains>6
+	if ComboPoints(more 4) and BuffPresent(SLICEANDDICE 7) and TargetDebuffPresent(RUPTURE 6 mine=1) Spell(EVISCERATE)
+	#eviscerate,if=combo_points>=4&buff.slice_and_dice.remains>4&energy>40&dot.rupture.remains>5
+	if ComboPoints(more 3) and BuffPresent(SLICEANDDICE 4) and Mana(more 40) and TargetDebuffPresent(RUPTURE 5 mine=1)
+		Spell(EVISCERATE)
+	#eviscerate,if=combo_points=5&target.time_to_die<10
+	if ComboPoints(more 4) and TargetDeadIn(less 10) Spell(EVISCERATE)
+	#revealing_strike,if=combo_points=4&buff.slice_and_dice.remains>8
+	if ComboPoints(equal 4) and BuffPresent(SLICEANDDICE 8) Spell(REVEALINGSTRIKE)
+	#sinister_strike,if=combo_points<5
+	if ComboPoints(less 5) Spell(SINISTERSTRIKE)
+}
+
+AddIcon help=cd mastery=2
+{
+	#adrenaline_rush,if=energy<20
+	unless BuffPresent(KILLINGSPREE) if Mana(less 20) Spell(ADRENALINERUSH)
+	Item(Trinket0Slot usable=1)
+	Item(Trinket1Slot usable=1)
+}
+
+AddIcon help=aoe mastery=2
+{
+	Spell(BLADEFLURRY)
+	unless BuffPresent(ADRENALINERUSH) Spell(KILLINGSPREE)
 }

 AddIcon help=main mastery=3
 {
-	unless BuffPresent(SLICEANDDICE) if ComboPoints(more 0)	Spell(SLICEANDDICE)
-
-	if ComboPoints(more 4) and Mana(more 69)
+	unless InCombat()
 	{
-		if BuffExpires(SLICEANDDICE 12) Spell(SLICEANDDICE)
-
-		if TargetDebuffExpires(RUPTURE 0) and TargetDeadIn(more 6)
-			Spell(RUPTURE)
-		Spell(EVISCERATE)
+		if WeaponEnchantExpires(mainhand 400) Item(INSTANTPOISON)
+		if WeaponEnchantExpires(offhand 400) Item(DEADLYPOISON)
 	}
-
-	if ComboPoints(less 4)
+
+	if BuffPresent(STEALTH) or BuffPresent(VANISHBUFF)
 	{
-		if TargetDebuffExpires(bleed 0) Spell(HEMORRHAGE)
-		Spell(BACKSTAB)
+		Spell(PREMEDITATION)
+		Spell(GARROTE)
+		#ambush,if=combo_points<=2
+		if ComboPoints(less 3) Spell(AMBUSH)
 	}
+
+	#slice_and_dice,if=buff.slice_and_dice.remains<2
+	if BuffExpires(SLICEANDDICE 2) and ComboPoints(more 0) Spell(SLICEANDDICE)
+	#rupture,if=combo_points=5&!ticking
+	if ComboPoints(more 4) and TargetDebuffExpires(RUPTURE 0 mine=1) Spell(RUPTURE)
+	#recuperate,if=combo_points=5&dot.rupture.remains>8&buff.slice_and_dice.remains>8
+	#eviscerate,if=combo_points=5&dot.rupture.remains>1
+	if ComboPoints(more 4) and TargetDebuffPresent(RUPTURE 1 main=1) Spell(EVISCERATE)
+	#eviscerate,if=combo_points>=4&buff.shadow_dance.up
+	if ComboPoints(more 3) and BuffPresent(SHADOWDANCE) Spell(EVISCERATE)
+	#backstab,if=combo_points<4
+	if ComboPoints(less 4) Spell(BACKSTAB)
+	#backstab,if=cooldown.honor_among_thieves.remains>1.75
+	#TODO: need a rogue to test how to know when the last combo point was gained
+	Spell(BACKSTAB)
 }

-AddIcon help=cd
+AddIcon help=cd mastery=3
 {
-	unless BuffPresent(KILLINGSPREE) Spell(ADRENALINERUSH)
-	unless BuffPresent(ADRENALINERUSH) Spell(KILLINGSPREE)
-	Spell(BLADEFLURRY)
-	if Mana(less 70) Spell(COLDBLOOD)
+	#shadow_dance,if=time>10&energy>75&combo_points<=1&cooldown.shadowstep.remains<=0
+	if Mana(more 75) and ComboPoints(less 2) and Spell(SHADOWSTEP) Spell(SHADOWDANCE)
+	#vanish,if=time>10&energy>60&combo_points<=1&cooldown.shadowstep.remains<=0&!buff.shadow_dance.up
+	if Mana(more 60) and ComboPoints(less 2) and Spell(SHADOWSTEP) and BuffExpires(SHADOWDANCE 0) Spell(VANISH)
+	#actions+=/shadowstep,if=buff.stealthed.up|buff.shadow_dance.up
+	if BuffPresent(STEALTH) or BuffPresent(SHADOWDANCE) or BuffPresent(VANISHBUFF) Spell(SHADOWSTEP)
+	#preparation,if=cooldown.vanish.remains>60
+	unless 60s before Spell(VANISH) Spell(PREPARATION)
 	Item(Trinket0Slot usable=1)
 	Item(Trinket1Slot usable=1)
-	Spell(PREPARATION)
 }

 AddIcon size=small