Implement RuneOfPowerRemains() condition.
Johnny C. Lam [04-25-14 - 20:55]
Implement RuneOfPowerRemains() condition.
This translates SimC's "buff.rune_of_power.remains" by returning the
remaining time of the most recently-placed Rune of Power if the player is
currently standing within a Rune of Power.
The assumption here is that the player is standing in the most
recently-placed Rune of Power.
This fixes ticket #341.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1320 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvaleSimulationCraft.lua b/OvaleSimulationCraft.lua
index 1542a8c..81e79d2 100644
--- a/OvaleSimulationCraft.lua
+++ b/OvaleSimulationCraft.lua
@@ -335,7 +335,6 @@ do
tinsert(simc.symbols, "molten_armor_buff")
return "if BuffExpires(molten_armor_buff) Spell(molten_armor)"
end,
- ["^rune_of_power$"] = false, -- XXX
["^water_elemental$"] = "if pet.Present(no) Spell(water_elemental)",
-- Monk
["^chi_sphere$"] = false,
@@ -641,6 +640,7 @@ do
tinsert(simc.symbols, "arcane_charge_debuff")
return "DebuffStacks(arcane_charge_debuff)"
end,
+ ["^buff%.rune_of_power%.remains$"] = "RuneOfPowerRemains()",
-- Monk
["^dot%.zen_sphere%.ticking$"] = function(simc, action)
tinsert(simc.symbols, "zen_sphere_buff")
diff --git a/conditions/RuneOfPowerRemains.lua b/conditions/RuneOfPowerRemains.lua
new file mode 100644
index 0000000..ffb078d
--- /dev/null
+++ b/conditions/RuneOfPowerRemains.lua
@@ -0,0 +1,55 @@
+--[[--------------------------------------------------------------------
+ Ovale Spell Priority
+ Copyright (C) 2014 Johnny C. Lam
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License in the LICENSE
+ file accompanying this program.
+--]]--------------------------------------------------------------------
+
+local _, Ovale = ...
+
+do
+ local OvaleCondition = Ovale.OvaleCondition
+ local OvaleState = Ovale.OvaleState
+
+ local type = type
+ local API_GetTotemInfo = GetTotemInfo
+ local Compare = OvaleCondition.Compare
+ local TestValue = OvaleCondition.TestValue
+ local state = OvaleState.state
+
+ local RUNE_OF_POWER_BUFF = 116014
+
+ --- Get the remaining time in seconds before the latest Rune of Power expires.
+ --- Returns non-zero only if the player is standing within an existing Rune of Power.
+ -- @name RuneOfPowerRemains
+ -- @paramsig number or boolean
+ -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
+ -- @param number Optional. The number to compare against.
+ -- @return The number of seconds.
+ -- @return A boolean value for the result of the comparison.
+ -- @usage
+ -- if RuneOfPowerRemains() < CastTime(rune_of_power) Spell(rune_of_power)
+
+ local function RuneOfPowerRemains(condition)
+ local comparator, limit = condition[1], condition[2]
+ local aura = state:GetAura("player", RUNE_OF_POWER_BUFF, "HELPFUL")
+ if aura then
+ local start, ending
+ for totemSlot = 1, 2 do
+ local haveTotem, name, startTime, duration = API_GetTotemInfo(totemSlot)
+ if haveTotem and startTime and (not start or startTime > start) then
+ start = startTime
+ ending = startTime + duration
+ end
+ end
+ if start then
+ return TestValue(start, ending, ending - start, start, -1, comparator, limit)
+ end
+ end
+ return Compare(0, comparator, limit)
+ end
+
+ OvaleCondition:RegisterCondition("runeofpowerremains", false, RuneOfPowerRemains)
+end
diff --git a/conditions/files.xml b/conditions/files.xml
index 25086c1..81491ee 100644
--- a/conditions/files.xml
+++ b/conditions/files.xml
@@ -76,6 +76,7 @@
<Script file="RelativeLevel.lua" />
<Script file="RemainingCastTime.lua" />
<Script file="RuneCount.lua" />
+ <Script file="RuneOfPowerRemains.lua" />
<Script file="Runes.lua" />
<Script file="Snapshot.lua" />
<Script file="Speed.lua" />