diff --git a/Conditionals.lua b/Conditionals.lua index de6262f..8bf92d4 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -2775,33 +2775,80 @@ CleveRoids.Keywords = { end) end, + -- [party] or [party:unitid] - check if unit is in your party + -- Default unit is conditionals.target party = function(conditionals) - return CleveRoids.IsTargetInGroupType(conditionals.target, "party") - end, - - noparty = function(conditionals) - return not CleveRoids.IsTargetInGroupType(conditionals.target, "party") - end, - - raid = function(conditionals) - return CleveRoids.IsTargetInGroupType(conditionals.target, "raid") - end, - - noraid = function(conditionals) - return not CleveRoids.IsTargetInGroupType(conditionals.target, "raid") - end, - - group = function(conditionals) - if type(conditionals.group) ~= "table" then - conditionals.group = { "party", "raid" } + local unit = conditionals.party + if unit == true or unit == nil then + unit = conditionals.target end - return Or(conditionals.group, function(groups) - if groups == "party" then + return CleveRoids.IsTargetInGroupType(unit, "party") + end, + + -- [noparty] or [noparty:unitid] - check if unit is NOT in your party + noparty = function(conditionals) + local unit = conditionals.noparty + if unit == true or unit == nil then + unit = conditionals.target + end + return not CleveRoids.IsTargetInGroupType(unit, "party") + end, + + -- [raid] or [raid:unitid] - check if unit is in your raid + -- Default unit is conditionals.target + raid = function(conditionals) + local unit = conditionals.raid + if unit == true or unit == nil then + unit = conditionals.target + end + return CleveRoids.IsTargetInGroupType(unit, "raid") + end, + + -- [noraid] or [noraid:unitid] - check if unit is NOT in your raid + noraid = function(conditionals) + local unit = conditionals.noraid + if unit == true or unit == nil then + unit = conditionals.target + end + return not CleveRoids.IsTargetInGroupType(unit, "raid") + end, + + -- [group] or [group:party] or [group:raid] or [group:party/raid] + -- Checks if the PLAYER is in a group (not unit membership) + group = function(conditionals) + local groupVal = conditionals.group + -- Boolean form [group] - check if in any group + if groupVal == true then + return GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0 + end + -- Value form [group:party] or [group:raid] or [group:party/raid] + return Multi(groupVal, function(groupType) + if groupType == "party" then return GetNumPartyMembers() > 0 - elseif groups == "raid" then + elseif groupType == "raid" then return GetNumRaidMembers() > 0 end - end) + return false + end, conditionals, "group") + end, + + -- [nogroup] or [nogroup:party] or [nogroup:raid] or [nogroup:party/raid] + -- Checks if the PLAYER is NOT in a group + nogroup = function(conditionals) + local groupVal = conditionals.nogroup + -- Boolean form [nogroup] - check if not in any group + if groupVal == true then + return GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 + end + -- Value form with De Morgan's law via NegatedMulti + return NegatedMulti(groupVal, function(groupType) + if groupType == "party" then + return GetNumPartyMembers() == 0 + elseif groupType == "raid" then + return GetNumRaidMembers() == 0 + end + return true + end, conditionals, "nogroup") end, checkchanneled = function(conditionals) diff --git a/README.md b/README.md index 8a78060..5316796 100644 --- a/README.md +++ b/README.md @@ -514,7 +514,7 @@ Default `[noimmune]` checks the debuff school (bleed). | druidmana | [druidmana:>=X] | * | | Druid mana in form | | equipped | [equipped:Daggers2] | * | * | Item/type equipped | | form | [form:0/1/2] | * | * | Shapeshift form | -| group | [group:party/raid] | * | | In group type | +| group | [group:party/raid] | * | * | Player in group type | | known | [known:"Name">#2] | * | * | Spell/talent known | | mybuff | [mybuff:"Name"=X] | * | | Total buff count | @@ -577,11 +577,11 @@ Default `@unitid` is usually `@target` if not specified. | member | [member] | * | | In party OR raid | | notarget | [notarget] | | | Player has no target | | outrange | [outrange:"Name"] | | | Out of spell range | -| party | [party] | | * | In party | +| party | [party]/[party:unitid] | | * | Unit in party | | power | [power:>=50] | * | | Unit power % | | powerlost | [powerlost:>=X] | * | | Unit power lost | | powertype | [powertype:mana/rage] | * | * | Power type | -| raid | [raid] | | * | In raid | +| raid | [raid]/[raid:unitid] | | * | Unit in raid | | rawhp | [rawhp:>=1000] | * | | Unit HP raw | | rawpower | [rawpower:>=500] | * | | Unit power raw | | targeting | [targeting:player] | * | * | Unit targeting X |