From 8123b36a1961ffa4890a4201b7cee9a2240bed71 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 5 Apr 2013 06:20:49 +0000 Subject: [PATCH] Add StaggerRemains() to get the remaining Stagger damage on a target. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@891 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleCondition.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/OvaleCondition.lua b/OvaleCondition.lua index 2cdec49..9dcfe27 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -65,6 +65,7 @@ local API_UnitIsUnit = UnitIsUnit local API_UnitLevel = UnitLevel local API_UnitPower = UnitPower local API_UnitPowerMax = UnitPowerMax +local API_UnitStagger = UnitStagger -- static property for GetRunesCooldown(), indexed by rune name local self_runes = {} @@ -2498,6 +2499,37 @@ OvaleCondition.conditions.spellpower = function(condition) return Compare(OvalePaperDoll.spellBonusDamage, condition[1], condition[2]) end +--- Get the remaining amount of damage Stagger will cause to the target. +-- @name StaggerRemains +-- @paramsig number +-- @param target Optional. Sets the target to check. The target may also be given as a prefix to the condition. +-- Defaults to target=player. +-- Valid values: player, target, focus, pet. +-- @return The amount of damage. +-- @usage +-- if StaggerRemains() / MaxHealth() >0.4 Spell(purifying_brew) + +OvaleCondition.conditions.staggerremains = function(condition) + local target = GetTarget(condition) + local start, ending, stacks + -- Heavy Stagger + start, ending, stacks = OvaleState:GetAura(target, 124273, "HARMFUL") + if not stacks or stacks == 0 then + -- Moderate Stagger + start, ending, stacks = OvaleState:GetAura(target, 124274, "HARMFUL") + end + if not stacks or stacks == 0 then + -- Light Stagger + start, ending, stacks = OvaleState:GetAura(target, 124275, "HARMFUL") + end + if start and ending and start < ending and stacks and stacks > 0 then + local stagger = API_UnitStagger(target) + return start, ending, 0, ending, -1 * stagger / (ending - start) + else + return 0, nil, 0, 0, 0 + end +end + --- Test if the player is in a given stance. -- @name Stance -- @paramsig boolean -- 1.7.9.5