Quantcast

Introduce new spell priority feature ``wait=N''.

Johnny C. Lam [09-02-13 - 15:41]
Introduce new spell priority feature ``wait=N''.

Setting wait=N in a Spell() or Item() action will cause that action to
have priority over later actions if the later actions start within N
seconds of that action's start time.

In the following example, Crusader Strike will be suggested over later
actions as long as it is within 0.2 seconds of the Crusader Strike
cooldown, otherwise Judgment will be suggested within 0.2 seconds of the
Judgment cooldown, followed by Templars Verdict or Holy Prism using normal
start time comparisons.

    Spell(crusader_strike wait=0.2)
    Spell(judgment wait=0.2)
    Spell(templars_verdict)
    Spell(holy_prism)

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1015 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleBestAction.lua
diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua
index ebc13c4..6a71a03 100644
--- a/OvaleBestAction.lua
+++ b/OvaleBestAction.lua
@@ -361,21 +361,33 @@ local function ComputeGroup(element)
 					return nil
 				elseif priority and priority > bestPriority then
 					-- If the new spell has a higher priority than the previous one, then choose the
-					-- higher priority spell its cast is pushed back too far by the lower priority one.
-					if start - bestStart < bestCastTime * 0.75 then
+					-- higher priority spell if its cast is pushed back too far by the lower priority one.
+					if newElement and newElement.params and newElement.params.wait then
+						if start and start - bestStart < newElement.params.wait then
+							replace = true
+						end
+					elseif start - bestStart < bestCastTime * 0.75 then
 						replace = true
 					end
 				elseif priority and priority < bestPriority then
 					-- If the new spell has a lower priority than the previous one, then choose the
 					-- lower priority spell only if it doesn't push back the cast of the higher priority
 					-- one by too much.
-					if bestStart - start > castTime * 0.75 then
+					if bestElement and bestElement.params and bestElement.params.wait then
+						if bestStart - start > bestElement.params.wait then
+							replace = true
+						end
+					elseif bestStart - start > castTime * 0.75 then
 						replace = true
 					end
 				else
 					-- If the spells have the same priority, then pick the one with an earlier cast time.
 					-- TODO: why have a 0.01 second threshold here?
-					if bestStart - start > 0.01 then
+					if bestElement and bestElement.params and bestElement.params.wait then
+						if bestStart - start > bestElement.params.wait then
+							replace = true
+						end
+					elseif bestStart - start > 0.01 then
 						replace = true
 					end
 				end