From 01e63e9831e353723d7a2d3c660ac30a8e9f5be6 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Mon, 9 Dec 2013 02:15:46 +0000 Subject: [PATCH] Add IsEnraged() script condition. - Use LibDispellable-1.0 if available to check for enrage buffs. - Re-implement state:GetStealable() as state:GetAuraWithProperty() to check for an aura with an arbitrary matching property. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1253 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- .pkgmeta | 9 ++++----- Ovale.toc | 2 +- OvaleAura.lua | 22 ++++++++++++++++------ compiler.pl | 2 ++ conditions/BuffStealable.lua | 6 +----- conditions/IsEnraged.lua | 38 ++++++++++++++++++++++++++++++++++++++ conditions/conditions.xml | 1 + embeds.xml | 1 + 8 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 conditions/IsEnraged.lua diff --git a/.pkgmeta b/.pkgmeta index 357222d..5cd4ebb 100644 --- a/.pkgmeta +++ b/.pkgmeta @@ -6,12 +6,11 @@ externals: Libs/AceConsole-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConsole-3.0 Libs/AceDB-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDB-3.0 Libs/AceDBOptions-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDBOptions-3.0 - Libs/AceGUI-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceGUI-3.0 Libs/AceEvent-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceEvent-3.0 + Libs/AceGUI-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceGUI-3.0 Libs/AceLocale-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0 Libs/AceTimer-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceTimer-3.0 - Libs/LibStub: svn://svn.wowace.com/wow/ace3/mainline/trunk/LibStub + Libs/CallbackHandler-1.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/CallbackHandler-1.0 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 + Libs/LibDispellable-1.0: git://git.wowace.com/wow/libdispellable-1-0/mainline.git + Libs/LibStub: svn://svn.wowace.com/wow/ace3/mainline/trunk/LibStub diff --git a/Ovale.toc b/Ovale.toc index 280b66d..72ad35f 100644 --- a/Ovale.toc +++ b/Ovale.toc @@ -5,7 +5,7 @@ ## Notes-frFR: Affiche l'icône du prochain sort à lancer ## Author: Sidoine ## Version: @project-version@ -## OptionalDeps: Ace3, CallbackHandler-1.0, LibBabble-CreatureType-3.0, LibDualSpec-1.0, LibRangeCheck-2.0, LibStub, Masque, Recount, Skada +## OptionalDeps: Ace3, CallbackHandler-1.0, LibBabble-CreatureType-3.0, LibDualSpec-1.0, LibDispellable-1.0, LibRangeCheck-2.0, LibStub, Masque, Recount, Skada ## SavedVariables: OvaleDB ## SavedVariablesPerCharacter: OvaleDBPC ## X-Category: Combat diff --git a/OvaleAura.lua b/OvaleAura.lua index 800e403..22fdcb3 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -19,6 +19,7 @@ Ovale.OvaleAura = OvaleAura local OvalePool = Ovale.OvalePool -- Forward declarations for module dependencies. +local LibDispellable = LibStub("LibDispellable-1.0", true) local OvaleData = nil local OvaleFuture = nil local OvaleGUID = nil @@ -208,6 +209,14 @@ local function RemoveAurasOnGUID(auraDB, guid) end end +local function IsEnrageEffect(auraId) + local boolean = OvaleData.buffSpellList.enrage[auraId] + if LibDispellable then + boolean = LibDispellable:IsEnrageEffect(auraId) + end + return boolean or nil +end + local function IsWithinAuraLag(time1, time2) local auraLag = OvaleOptions:GetProfile().apparence.auraLag return (time1 - time2 < auraLag/1000) and (time2 - time1 < auraLag/1000) @@ -415,6 +424,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, ic aura.filter = filter aura.icon = icon aura.debuffType = debuffType + aura.enrage = IsEnrageEffect(auraId) aura.stealable = isStealable aura.value1, aura.value2, aura.value3 = value1, value2, value3 @@ -1056,10 +1066,10 @@ statePrototype.RemoveAuraOnGUID = function(state, guid, auraId, filter, mine, at end end -statePrototype.GetStealable = function(state, unitId) +statePrototype.GetAuraWithProperty = function(state, unitId, propertyName, filter) local count = 0 - local start, ending = math.huge, 0 local guid = OvaleGUID:GetGUID(unitId) + local start, ending = math.huge, 0 local now = state.currentTime -- Loop through auras not kept in the simulator that match the criteria. @@ -1068,7 +1078,7 @@ statePrototype.GetStealable = function(state, unitId) for casterGUID in pairs(whoseTable) do local aura = GetStateAura(state, guid, auraId, self_guid) if state:IsActiveAura(aura, now) and not aura.state then - if aura.stealable and aura.filter == "HELPFUL" then + if aura[propertyName] and aura.filter == filter then count = count + 1 start = (aura.start < start) and aura.start or start ending = (aura.ending > ending) and aura.ending or ending @@ -1082,7 +1092,7 @@ statePrototype.GetStealable = function(state, unitId) for auraId, whoseTable in pairs(state.aura[guid]) do for casterGUID, aura in pairs(whoseTable) do if state:IsActiveAura(aura, now) then - if aura.stealable and aura.filter == "HELPFUL" then + if aura[propertyName] and aura.filter == filter then count = count + 1 start = (aura.start < start) and aura.start or start ending = (aura.ending > ending) and aura.ending or ending @@ -1092,9 +1102,9 @@ statePrototype.GetStealable = function(state, unitId) end end if count > 0 then - return count, start, ending + return start, ending end - return 0, 0, math.huge + return nil end do diff --git a/compiler.pl b/compiler.pl index 07b03ce..1256c18 100644 --- a/compiler.pl +++ b/compiler.pl @@ -78,6 +78,8 @@ $m{GameTooltip}{SetOwner} = true; $m{GameTooltip}{SetText} = true; $m{GameTooltip}{Show} = true; +$m{LibDispellable}{IsEnrageEffect} = true; + $m{LibDualSpec}{EnhanceDatabase} = true; $m{LibDualSpec}{EnhanceOptions} = true; diff --git a/conditions/BuffStealable.lua b/conditions/BuffStealable.lua index 3821589..c4171c5 100644 --- a/conditions/BuffStealable.lua +++ b/conditions/BuffStealable.lua @@ -29,11 +29,7 @@ do local function BuffStealable(condition) local target = ParseCondition(condition) - local count, start, ending = state:GetStealable(target) - if count > 0 then - return start, ending - end - return nil + return state:GetAuraWithProperty(target, "stealable", "HELPFUL") end OvaleCondition:RegisterCondition("buffstealable", false, BuffStealable) diff --git a/conditions/IsEnraged.lua b/conditions/IsEnraged.lua new file mode 100644 index 0000000..1fc5286 --- /dev/null +++ b/conditions/IsEnraged.lua @@ -0,0 +1,38 @@ +--[[-------------------------------------------------------------------- + Ovale Spell Priority + Copyright (C) 2013 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 TestBoolean = OvaleCondition.TestBoolean + local state = OvaleState.state + + --- Test if the target is enraged. + -- @name IsEnraged + -- @paramsig boolean + -- @param yesno Optional. If yes, then return true if enraged. If no, then return true if not enraged. + -- Default is yes. + -- Valid values: yes. "no" currently doesn't work. + -- @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 A boolean value. + -- @usage + -- if target.IsEnraged() Spell(soothe) + + local function IsEnraged(condition) + local yesno = condition[1] + return state:GetAuraWithProperty(target, "enraged", "HELPFUL") + end + + OvaleCondition:RegisterCondition("isfeared", false, IsFeared) +end \ No newline at end of file diff --git a/conditions/conditions.xml b/conditions/conditions.xml index 4c086df..d3192b2 100644 --- a/conditions/conditions.xml +++ b/conditions/conditions.xml @@ -45,6 +45,7 @@