diff --git a/Conditionals.lua b/Conditionals.lua index 8f716b4..683be23 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -2361,5 +2361,51 @@ CleveRoids.Keywords = { if type(args) ~= "table" then return false end return not CleveRoids.ValidateSwingTimer(args.operator, args.amount) end, conditionals, "nostimer") + end, + + -- Checks if the target uses a specific power type (mana, rage, energy) + powertype = function(conditionals) + local unit = conditionals.target or "target" + if not UnitExists(unit) then return false end + + return Or(conditionals.powertype, function(powerTypeName) + local powerType = UnitPowerType(unit) + local powerTypeLower = string.lower(powerTypeName or "") + + if powerTypeLower == "mana" then + return powerType == 0 + elseif powerTypeLower == "rage" then + return powerType == 1 + elseif powerTypeLower == "focus" then + return powerType == 2 + elseif powerTypeLower == "energy" then + return powerType == 3 + end + + return false + end) + end, + + -- Checks if the target does NOT use a specific power type + nopowertype = function(conditionals) + local unit = conditionals.target or "target" + if not UnitExists(unit) then return true end + + return NegatedMulti(conditionals.nopowertype, function(powerTypeName) + local powerType = UnitPowerType(unit) + local powerTypeLower = string.lower(powerTypeName or "") + + if powerTypeLower == "mana" then + return powerType ~= 0 + elseif powerTypeLower == "rage" then + return powerType ~= 1 + elseif powerTypeLower == "focus" then + return powerType ~= 2 + elseif powerTypeLower == "energy" then + return powerType ~= 3 + end + + return true + end, conditionals, "nopowertype") end } diff --git a/README.md b/README.md index 2944bbe..412ca5a 100644 --- a/README.md +++ b/README.md @@ -658,6 +658,7 @@ See the **[Macro Syntax Guide](#macro-syntax-guide)** above for detailed syntax | party | [party] | | * | If the @unitid is in your party. | | power | [power:>=X]
[power:>=X/<=Y] | * | | The @unitid power (mana/rage/energy) **PERCENT** compared to X. | | powerlost | [powerlost:>=X]
[powerlost:>=X/<=Y] | * | | The @unitid power (mana/rage/energy) lost compared to X. | +| powertype | [powertype:mana]
[powertype:rage]
[powertype:energy]
[powertype:mana/rage] | * | * | If the @unitid uses the specified power type(s). Valid types: mana, rage, energy, focus. Useful for checking if NPCs use mana or for player class detection. | | raid | [raid] | | * | If the @unitid is in your raid. | | rawhp | [rawhp:>=X]
[rawhp:>=X/<=Y] | * | | The @unitid health compared to X. | | rawpower | [rawpower:>=X]
[rawpower:>=X/<=Y] | * | | The @unitid power (mana/rage/energy) compared to X. |