mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user