Add talent, spec, risk, and instance type load conditions

This commit is contained in:
andrew6180
2025-10-17 12:20:04 -07:00
parent 72b01063bc
commit 0f04c2ba3b
8 changed files with 199 additions and 143 deletions
+1 -1
View File
@@ -236,7 +236,7 @@ local function singleTest(arg, trigger, name, value, operator, use_exact)
return TestForMultiSelect(trigger, arg);
elseif(arg.type == "toggle") then
return TestForToggle(trigger, arg);
elseif (arg.type == "spell" or arg.type == "item") then
elseif (arg.type == "spell" or arg.type == "item" or arg.type == "talent" or arg.type == "mysticenchant") then
if arg.test then
if arg.showExactOption then
return "("..arg.test:format(value, tostring(use_exact) or "false") ..")";
-12
View File
@@ -1930,9 +1930,6 @@ function Private.Modernize(data, oldSnapshot)
if data.internalVersion < 77 then
-- fix data broken by wago export
local triggerFix = {
talent = {
multi = true
},
herotalent = {
multi = true
},
@@ -1946,15 +1943,6 @@ function Private.Modernize(data, oldSnapshot)
arena_spec = true
}
local loadFix = {
talent = {
multi = true
},
talent2 = {
multi = true
},
talent3 = {
multi = true
},
herotalent = {
multi = true
},
+81 -99
View File
@@ -892,17 +892,41 @@ function WeakAuras.GetEffectiveRangedAttackPower()
return base + pos + neg
end
local function valuesForTalentFunction(trigger)
return function()
local single_class = Private.checkForSingleLoadCondition(trigger, "class")
if not single_class then
single_class = select(2, UnitClass("player"));
end
return Private.talentInfo[single_class]
function WeakAuras.IsTalentKnownForLoad(spell, exact)
local result = WeakAuras.IsTalentKnown(spell)
if exact or result then
return result
end
return false
end
function WeakAuras.IsTalentKnown(spell)
if (spell) then
if tonumber(spell) then
return C_CharacterAdvancement.IsKnownSpellID(spell) and true or false;
else
-- name of talent zzz
if (GetSpellInfo(spell)) then -- maybe talent ability?
return true
end
end
end
return false
end
function WeakAuras.IsSpecActive(specID)
specID = specID and tonumber(specID)
if not specID then return false end
return SpecializationUtil.GetActiveSpecialization() == specID
end
function WeakAuras.IsMysticEnchantApplied(spellID)
spellID = spellID and tonumber(spellID)
if not spellID then return false end
return MysticEnchantUtil.IsEnchantApplied("player", spellID)
end
---helper to check if a condition is checked and have a single value, and return it
function Private.checkForSingleLoadCondition(trigger, name, validateFn)
local use_name = "use_"..name
@@ -1036,102 +1060,39 @@ Private.load_prototype = {
init = "arg"
},
{
name = "class_and_spec",
display = L["Class and Specialization"],
name = "specialization",
display = L["Talent Specialization"],
type = "multiselect",
values = "spec_types_all",
test = "WeakAuras.CheckClassSpec(%s)",
events = {"UNIT_SPEC_CHANGED_player", "WA_DELAYED_PLAYER_ENTERING_WORLD"},
values = "specialization_types",
test = "WeakAuras.IsSpecActive(%s)",
preamble = "wipe(WeakAuras.specialization_types) for i = 1, SpecializationUtil.GetNumSpecializations() do WeakAuras.specialization_types[i] = i .. \". \" .. SpecializationUtil.GetSpecializationInfo(i) end",
events = {"ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED"},
init = "arg"
},
{
name = "talent",
name = "knowntalent",
display = L["Talent"],
type = "multiselect",
values = valuesForTalentFunction,
test = "WeakAuras.CheckTalentByIndex(%d, %d)",
multiConvertKey = nil,
events = {"PLAYER_TALENT_UPDATE", "SPELL_UPDATE_USABLE"},
inverse = nil,
extraOption = nil,
control = "WeakAurasMiniTalent",
multiNoSingle = true, -- no single mode
multiTristate = true, -- values can be true/false/nil
multiAll = true, -- require all tests
orConjunctionGroup = "talent",
multiUseControlWhenFalse = true,
enable = function(trigger)
return (Private.checkForSingleLoadCondition(trigger, "class") ~= nil)
end,
hidden = function(trigger)
return not (Private.checkForSingleLoadCondition(trigger, "class") ~= nil)
end,
type = "talent",
test = "WeakAuras.IsTalentKnownForLoad(%s, %s)",
events = {"ASCENSION_KNOWN_ENTRIES_UPDATED"},
orConjunctionGroup = "knowntalent",
showExactOption = true,
},
{
name = "talent2",
display = L["Or Talent"],
type = "multiselect",
values = valuesForTalentFunction,
test = "WeakAuras.CheckTalentByIndex(%d, %d)",
multiConvertKey = nil,
events = {"PLAYER_TALENT_UPDATE", "SPELL_UPDATE_USABLE"},
inverse = nil,
extraOption = nil,
control = "WeakAurasMiniTalent",
multiNoSingle = true, -- no single mode
multiTristate = true, -- values can be true/false/nil
multiAll = true, -- require all tests
orConjunctionGroup = "talent",
multiUseControlWhenFalse = true,
enable = function(trigger)
return (trigger.use_talent ~= nil or trigger.use_talent2 ~= nil) and (
(Private.checkForSingleLoadCondition(trigger, "class") ~= nil)
)
end,
hidden = function(trigger)
return not((trigger.use_talent ~= nil or trigger.use_talent2 ~= nil) and (
(Private.checkForSingleLoadCondition(trigger, "class") ~= nil))
)
end,
name = "mysticenchantactive",
display = L["Mystic Enchant"],
type = "mysticenchant",
test = "WeakAuras.IsMysticEnchantApplied(%s)",
events = {"MYSTIC_ENCHANT_PRESET_SET_ACTIVE_RESULT", "MYSTIC_ENCHANT_SLOT_UPDATE", "PLAYER_EQUIPMENT_CHANGED", "SPELLS_CHANGED"},
showExactOption = true,
},
{
name = "talent3",
display = L["Or Talent"],
type = "multiselect",
values = valuesForTalentFunction,
test = "WeakAuras.CheckTalentByIndex(%d, %d)",
multiConvertKey = nil,
events = {"PLAYER_TALENT_UPDATE", "SPELL_UPDATE_USABLE"},
inverse = nil,
extraOption = nil,
control = "WeakAurasMiniTalent",
multiNoSingle = true, -- no single mode
multiTristate = true, -- values can be true/false/nil
multiAll = true, -- require all tests
orConjunctionGroup = "talent",
multiUseControlWhenFalse = true,
enable = function(trigger)
return ((trigger.use_talent ~= nil and trigger.use_talent2 ~= nil) or trigger.use_talent3 ~= nil) and (
(Private.checkForSingleLoadCondition(trigger, "class") ~= nil)
)
end,
hidden = function(trigger)
return not(((trigger.use_talent ~= nil and trigger.use_talent2 ~= nil) or trigger.use_talent3 ~= nil) and (
(Private.checkForSingleLoadCondition(trigger, "class") ~= nil)
))
end
},
{
name = "glyph",
display = L["Glyph"],
type = "multiselect",
values = function(trigger)
Private.InitializeGlyphs(trigger and trigger.glyph)
return Private.glyph_types
end,
sorted = true,
sortOrder = Private.glyph_sorted or {},
test = "WeakAuras.IsGlyphActive(%s)",
events = {"GLYPH_ADDED", "GLYPH_REMOVED", "GLYPH_UPDATED", "USE_GLYPH"},
name = "not_mysticenchantactive",
display = WeakAuras.newFeatureString .. L["|cFFFF0000Not|r Mystic Enchant"],
type = "mysticenchant",
test = "not WeakAuras.IsMysticEnchantApplied(%s)",
events = {"MYSTIC_ENCHANT_PRESET_SET_ACTIVE_RESULT", "MYSTIC_ENCHANT_SLOT_UPDATE", "PLAYER_EQUIPMENT_CHANGED", "SPELLS_CHANGED"},
showExactOption = true,
},
{
name = "spellknown",
@@ -1146,7 +1107,7 @@ Private.load_prototype = {
display = WeakAuras.newFeatureString .. L["|cFFFF0000Not|r Spell Known"],
type = "spell",
test = "not WeakAuras.IsSpellKnownForLoad(%s, %s)",
events = {"SPELLS_CHANGED", "UNIT_PET"},
events = {"SPELLS_CHANGED", "UNIT_PET", "CHARACTER_ADVANCEMENT_PENDING_BUILD_UPDATED"},
showExactOption = true
},
{
@@ -1276,6 +1237,15 @@ Private.load_prototype = {
test = "Private.ExecEnv.CheckGroupMemberType(%s, group_leader)",
optional = true,
},
{
name = "ruleset",
display = "PvP Ruleset",
type = "multiselect",
width = WeakAuras.normalWidth,
init = "arg",
values = "ruleset_types",
events = {"ZONE_CHANGED_NEW_AREA", "PLAYER_FLAGS_CHANGED"}
},
{
name ="locationTitle",
display = L["Location"],
@@ -8011,6 +7981,10 @@ Private.event_prototypes = {
tinsert(events, "PARTY_MEMBERS_CHANGED")
tinsert(events, "RAID_ROSTER_UPDATE")
end
if trigger.use_ruleset ~= nil then
tinsert(events, "ZONE_CHANGED_NEW_AREA")
tinsert(events, "PLAYER_FLAGS_CHANGED")
end
if trigger.use_instance_difficulty ~= nil
or trigger.use_instance_size ~= nil
then
@@ -8127,9 +8101,17 @@ Private.event_prototypes = {
init = "Private.ExecEnv.GroupType()",
events = {"PARTY_MEMBERS_CHANGED", "RAID_ROSTER_UPDATE"}
},
{
name = "ruleset",
display = "PvP Ruleset",
type = "multiselect",
values = "ruleset_types",
init = "WeakAuras.Ruleset()",
events = {"ZONE_CHANGED_NEW_AREA", "PLAYER_FLAGS_CHANGED"}
},
{
name = "instance_size",
display = L["Instance Type"].." "..L["|cffff0000deprecated|r"],
display = L["Instance Type"],
desc = constants.instanceFilterDeprecated,
type = "multiselect",
values = "instance_types",
@@ -8139,7 +8121,7 @@ Private.event_prototypes = {
},
{
name = "instance_difficulty",
display = L["Instance Difficulty"].." "..L["|cffff0000deprecated|r"],
display = L["Instance Difficulty"],
desc = constants.instanceFilterDeprecated,
type = "multiselect",
values = "difficulty_types",
+13 -4
View File
@@ -1212,6 +1212,9 @@ do
end
end
WeakAuras.specialization_types = {}
for i = 1, #SPEC_SWAP_SPELLS do WeakAuras.specialization_types[i] = L["Talent Specialization"] .. " " .. i end
Private.faction_group = {
Alliance = L["Alliance"],
Horde = L["Horde"],
@@ -2556,10 +2559,19 @@ Private.group_types = {
raid = L["In Raid"]
}
Private.ruleset_types = {
one = L["None"],
pve = NO_RISK_PVE,
pvp = NO_RISK_PVP,
highrisk = HIGH_RISK_PVP,
}
Private.difficulty_types = {
none = L["None"],
normal = PLAYER_DIFFICULTY1,
heroic = PLAYER_DIFFICULTY2
heroic = PLAYER_DIFFICULTY2,
mythic = "Mythic",
ascended = "Ascended",
}
Private.raid_role_types = {
@@ -3288,9 +3300,6 @@ Private.data_stub = {
class = {
multi = {},
},
talent = {
multi = {},
},
},
actions = {
init = {},
+30 -5
View File
@@ -747,7 +747,7 @@ local function singleTest(arg, trigger, use, name, value, operator, use_exact, c
return name;
end
end
elseif (arg.type == "spell") then
elseif (arg.type == "spell" or arg.type == "talent" or arg.type == "mysticenchant") then
if arg.showExactOption then
return "("..arg.test:format(value, tostring(use_exact) or "false") ..")";
else
@@ -841,6 +841,9 @@ local function ConstructFunction(prototype, trigger, skipOptional)
end
else
local value = trigger[name]
if name == "knowntalent" then
dprint(WeakAuras.IsTalentKnownForLoad(value))
end
local operator = name and trigger[name.."_operator"]
local caseInsensitive = name and trigger[name.."_caseInsensitive"]
local use_exact = name and trigger["use_exact_" .. name]
@@ -1473,6 +1476,20 @@ function Private.ExecEnv.GroupType()
return "solo";
end
function WeakAuras.Ruleset()
local ruleset = C_Player:GetRuleset()
if ruleset == Enum.Ruleset.NoRiskPvE then
return "pve"
end
if ruleset == Enum.Ruleset.NoRiskPvP then
return "pvp"
end
if ruleset == Enum.Ruleset.HighRiskPvP then
return "highrisk"
end
return "none"
end
local function GetInstanceTypeAndSize()
local size, difficulty
local inInstance, Type = IsInInstance()
@@ -1502,10 +1519,14 @@ local function GetInstanceTypeAndSize()
difficulty = "heroic"
end
else
if difficultyIndex == 1 or difficultyIndex == 2 then
if difficultyIndex == 1 then
difficulty = "normal"
elseif difficultyIndex == 3 or difficultyIndex == 4 then
elseif difficultyIndex == 2 then
difficulty = "heroic"
elseif difficultyIndex == 3 then
difficulty = "mythic"
elseif difficultyIndex == 4 then
difficulty = "ascended"
end
end
return size, difficulty, instanceType, ZoneMapID
@@ -1593,6 +1614,9 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
local group = Private.ExecEnv.GroupType()
local groupSize = GetNumGroupMembers()
local ruleset = WeakAuras.Ruleset()
local specialization = SpecializationUtil.GetActiveSpecialization()
local changed = 0;
local shouldBeLoaded, couldBeLoaded;
local parentsToCheck = {}
@@ -1604,8 +1628,8 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
if (data and not data.controlledChildren) then
local loadFunc = loadFuncs[id];
local loadOpt = loadFuncsForOptions[id];
shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, alive, inEncounter, pvp, vehicle, vehicleUi, mounted, class, player, realm, guild, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, encounter_id, size, difficulty);
couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, alive, inEncounter, pvp, vehicle, vehicleUi, mounted, class, player, realm, guild, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, encounter_id, size, difficulty);
shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, alive, inEncounter, pvp, vehicle, vehicleUi, mounted, class, specialization, player, realm, guild, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, ruleset, zone, zoneId, subzone, encounter_id, size, difficulty);
couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, alive, inEncounter, pvp, vehicle, vehicleUi, mounted, class, specialization, player, realm, guild, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, ruleset, zone, zoneId, subzone, encounter_id, size, difficulty);
if(shouldBeLoaded and not loaded[id]) then
changed = changed + 1;
@@ -1694,6 +1718,7 @@ loadFrame:RegisterEvent("PLAYER_REGEN_DISABLED");
loadFrame:RegisterEvent("PLAYER_REGEN_ENABLED");
loadFrame:RegisterEvent("PLAYER_ROLES_ASSIGNED");
loadFrame:RegisterEvent("SPELLS_CHANGED");
loadFrame:RegisterEvent("ASCENSION_KNOWN_ENTRIES_UPDATED");
loadFrame:RegisterEvent("UNIT_INVENTORY_CHANGED")
loadFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
loadFrame:RegisterEvent("PLAYER_DEAD")