new command feedpet, new conditional pethappiness

This commit is contained in:
Seraphic8x2244
2026-08-25 09:26:59 -05:00
committed by Brues
parent 5c31232b52
commit d5baecaf41
3 changed files with 119 additions and 0 deletions
+50
View File
@@ -5403,6 +5403,23 @@ local function MakeTypedPowerKeyword(condKey, unitDefault, powerType)
end
end
local PET_HAPPINESS_STATES = {
unhappy = 1,
content = 2,
happy = 3,
}
local function ResolvePetHappinessState(value)
local state = tonumber(value)
if state then
return state
end
if type(value) ~= "string" then
return nil
end
return PET_HAPPINESS_STATES[GetLowercaseString(value)]
end
-- A list of Conditionals and their functions to validate them
CleveRoids.Keywords = {
exists = function(conditionals)
@@ -7222,6 +7239,39 @@ CleveRoids.Keywords = {
end, conditionals, "nopet")
end,
-- Hunter pet happiness: 1=unhappy, 2=content, 3=happy.
pethappiness = function(conditionals)
local happiness = GetPetHappiness()
local _, isHunterPet = HasPetUI()
if not isHunterPet or not happiness then
return false
end
if conditionals.pethappiness == true then
return true
end
return Multi(conditionals.pethappiness, function(requiredState)
return happiness == ResolvePetHappinessState(requiredState)
end, conditionals, "pethappiness")
end,
nopethappiness = function(conditionals)
local happiness = GetPetHappiness()
local _, isHunterPet = HasPetUI()
if not isHunterPet or not happiness then
return true
end
if conditionals.nopethappiness == true then
return false
end
return NegatedMulti(conditionals.nopethappiness, function(forbiddenState)
return happiness ~= ResolvePetHappinessState(forbiddenState)
end, conditionals, "nopethappiness")
end,
-- [focus] / [nofocus] - whether a focus is set. Covers pfUI's emulated focus
-- and ClassicAPI's native focus token (set via /focus or the FOCUSTARGET keybind).
focus = function(conditionals)