feat: add myspellhaste conditional (#4)

* feat: add myspellhaste conditional

* review: fix myspellhaste proxy fallback, document it, register with macrocheck

---------

Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
This commit is contained in:
liiora
2026-09-10 14:06:27 -05:00
committed by GitHub
co-authored by Brues
parent 6f78be8394
commit 080c1243b6
3 changed files with 54 additions and 1 deletions
+9
View File
@@ -286,6 +286,15 @@ function API.GetSpellBonusHealing()
return GetSpellBonusHealing()
end
-- Spell haste for `unit` as a percentage: 0 unhasted, positive when casts are
-- sped up, negative while slowed (Curse of Tongues). 0 for a unit that doesn't
-- resolve. Vanilla has no haste API at all -- ClassicAPI derives this from the
-- UNIT_MOD_CAST_SPEED descriptor field the server folds into the cast time, so
-- it's exact and needs no nampower GetUnitField dependency.
function API.UnitSpellHaste(unit)
return UnitSpellHaste(unit)
end
--------------------------------------------------------------------------------
-- Unit Health
--------------------------------------------------------------------------------
+43
View File
@@ -3249,6 +3249,25 @@ function CleveRoids.ValidatePowerLost(unit, operator, amount)
return false
end
-- Checks the given unit's spell haste percentage vs the given amount
-- unit: The unit we're checking
-- operator: valid comparitive operator symbol
-- amount: The required amount, in percent (0 = unhasted, negative = slowed)
-- returns: True or false
-- NOTE: the shared arg parser doesn't accept a sign on the amount, so a
-- specific negative threshold ([myspellhaste:<-10]) can't be written; use
-- [myspellhaste:<0] to test for being slowed at all.
function CleveRoids.ValidateSpellHaste(unit, operator, amount)
if not unit or not operator or not amount then return false end
local haste = CleveRoids.ClassicAPI.UnitSpellHaste(unit)
if CleveRoids.operators[operator] then
return CleveRoids.comparators[operator](haste, amount)
end
return false
end
-- Checks whether or not the given unit has hp in percent vs the given amount
-- unit: The unit we're checking
-- operator: valid comparitive operator symbol
@@ -6482,6 +6501,30 @@ CleveRoids.Keywords = {
end, conditionals, "mylevel")
end,
myspellhaste = function(conditionals)
return Multi(conditionals.myspellhaste, function(args)
if type(args) ~= "table" then return false end
-- Handle multi-comparison (e.g., >50&<80)
if args.comparisons and type(args.comparisons) == "table" then
local haste = CleveRoids.ClassicAPI.UnitSpellHaste("player")
-- ALL comparisons must pass (AND logic)
for _, comp in ipairs(args.comparisons) do
if not CleveRoids.operators[comp.operator] then
return false
end
if not CleveRoids.comparators[comp.operator](haste, comp.amount) then
return false
end
end
return true
end
return CleveRoids.ValidateSpellHaste("player", args.operator, args.amount)
end, conditionals, "myspellhaste")
end,
myhp = function(conditionals)
return Multi(conditionals.myhp, function(args)
if type(args) ~= "table" then return false end
+2 -1
View File
@@ -669,6 +669,7 @@ local function validateConditional(conditional, args, action)
button = true,
form = true, stance = true,
level = true, mylevel = true,
myspellhaste = true,
distance = true, nodistance = true,
swingtimer = true, stimer = true,
rangedtimer = true, rtimer = true,
@@ -689,7 +690,7 @@ local function validateConditional(conditional, args, action)
if args and type(args) == "string" then
local hasHpOrPower = safeStringFind(baseCond, "hp") or safeStringFind(baseCond, "power") or
safeStringFind(baseCond, "mana") or safeStringFind(baseCond, "energy") or
safeStringFind(baseCond, "rage") or
safeStringFind(baseCond, "rage") or safeStringFind(baseCond, "haste") or
safeStringFind(baseCond, "combo") or baseCond == "stat"
if hasHpOrPower then
local hasOperator = safeStringFind(args, "[<>=~]+")