(fix/prototypes) item count, item equipped, cooldown/charges/count

This commit is contained in:
NoM0Re
2025-02-08 15:05:57 +01:00
parent 5cdb9aed28
commit 0ee4e79d36
3 changed files with 72 additions and 105 deletions
+2 -2
View File
@@ -2382,7 +2382,7 @@ do
local unit, name, _ = ...; local unit, name, _ = ...;
if(unit == "player") then if(unit == "player") then
if(gcdSpellName ~= name) then if(gcdSpellName ~= name) then
local icon = GetSpellTexture(name); local _,_,icon = GetSpellInfo(name or 0);
gcdSpellName = name; gcdSpellName = name;
gcdSpellIcon = icon; gcdSpellIcon = icon;
if not WeakAuras.IsPaused() then if not WeakAuras.IsPaused() then
@@ -2390,7 +2390,7 @@ do
end end
end end
end end
elseif(event == "UNIT_INVENTORY_CHANGED" and ... and ... == "player" or event == "BAG_UPDATE_COOLDOWN" or event == "PLAYER_EQUIPMENT_CHANGED") then elseif(event == "UNIT_INVENTORY_CHANGED" and ... == "player" or event == "BAG_UPDATE_COOLDOWN" or event == "PLAYER_EQUIPMENT_CHANGED") then
Private.CheckItemSlotCooldowns(); Private.CheckItemSlotCooldowns();
end end
Private.StopProfileSystem("generictrigger cd tracking"); Private.StopProfileSystem("generictrigger cd tracking");
+2 -2
View File
@@ -1686,7 +1686,7 @@ function Private.Modernize(data, oldSnapshot)
end end
end end
--[[if data.internalVersion < 77 then if data.internalVersion < 77 then
-- fix data broken by wago export -- fix data broken by wago export
local triggerFix = { local triggerFix = {
talent = { talent = {
@@ -1748,7 +1748,7 @@ function Private.Modernize(data, oldSnapshot)
fixData(triggerData.trigger, triggerFix) fixData(triggerData.trigger, triggerFix)
end end
fixData(data.load, loadFix) fixData(data.load, loadFix)
end]] end
if data.internalVersion < 79 then if data.internalVersion < 79 then
if data.triggers then if data.triggers then
+68 -101
View File
@@ -3231,13 +3231,7 @@ Private.event_prototypes = {
type = "spell", type = "spell",
events = {}, events = {},
loadInternalEventFunc = function(trigger, untrigger) loadInternalEventFunc = function(trigger, untrigger)
trigger.spellName = type(trigger.spellName) ~= "table" and trigger.spellName or 0; local spellName = type(trigger.spellName) ~= "table" and trigger.spellName or 0;
local spellName;
if (trigger.use_exact_spellName) then
spellName = trigger.spellName;
else
spellName = type(trigger.spellName) == "number" and GetSpellInfo(trigger.spellName) or trigger.spellName;
end
if spellName == nil then return {} end if spellName == nil then return {} end
local events = { local events = {
"SPELL_COOLDOWN_CHANGED:" .. spellName, "SPELL_COOLDOWN_CHANGED:" .. spellName,
@@ -3254,27 +3248,17 @@ Private.event_prototypes = {
force_events = "SPELL_COOLDOWN_FORCE", force_events = "SPELL_COOLDOWN_FORCE",
name = L["Cooldown/Charges/Count"], name = L["Cooldown/Charges/Count"],
loadFunc = function(trigger) loadFunc = function(trigger)
trigger.spellName = type(trigger.spellName) ~= "table" and trigger.spellName or 0; local spellName = type(trigger.spellName) ~= "table" and trigger.spellName or 0;
local spellName; WeakAuras.WatchSpellCooldown(spellName, trigger.use_matchedRune)
if (trigger.use_exact_spellName) then
spellName = trigger.spellName;
else
spellName = type(trigger.spellName) == "number" and GetSpellInfo(trigger.spellName) or trigger.spellName;
end
WeakAuras.WatchSpellCooldown(spellName, trigger.use_matchedRune);
if (trigger.use_showgcd) then if (trigger.use_showgcd) then
WeakAuras.WatchGCD(); WeakAuras.WatchGCD();
end end
end, end,
init = function(trigger) init = function(trigger)
trigger.spellName = type(trigger.spellName) ~= "table" and trigger.spellName or 0; local spellName = type(trigger.spellName) ~= "table" and trigger.spellName or 0
local spellName; print(spellName)
if (trigger.use_exact_spellName) then
spellName = trigger.spellName;
else
spellName = type(trigger.spellName) == "number" and GetSpellInfo(trigger.spellName) or trigger.spellName;
end
local ret = {} local ret = {}
local showOnCheck = "false"; local showOnCheck = "false";
if (trigger.genericShowOn == "showOnReady") then if (trigger.genericShowOn == "showOnReady") then
showOnCheck = "startTime and startTime == 0 or gcdCooldown"; showOnCheck = "startTime and startTime == 0 or gcdCooldown";
@@ -3283,15 +3267,8 @@ Private.event_prototypes = {
elseif (trigger.genericShowOn == "showAlways") then elseif (trigger.genericShowOn == "showAlways") then
showOnCheck = "startTime ~= nil"; showOnCheck = "startTime ~= nil";
end end
local trackSpecificCharge = trigger.use_trackcharge and trigger.trackcharge and trigger.trackcharge ~= ""
local track = trigger.track or "auto" table.insert(ret, ([=[
if track == "auto" and trackSpecificCharge then
track = "charges"
end
if (type(spellName) == "string") then
spellName = string.format("%q", spellName)
end
table.insert(ret, ([=[
local spellname = %s local spellname = %s
local ignoreRuneCD = %s local ignoreRuneCD = %s
local showgcd = %s; local showgcd = %s;
@@ -3302,69 +3279,43 @@ Private.event_prototypes = {
local genericShowOn = %s local genericShowOn = %s
local expirationTime = startTime and duration and startTime + duration local expirationTime = startTime and duration and startTime + duration
state.spellname = spellname; state.spellname = spellname;
]=]):format( ]=]):format(spellName,
spellName,
(trigger.use_matchedRune and "true" or "false"), (trigger.use_matchedRune and "true" or "false"),
(trigger.use_showgcd and "true" or "false"), (trigger.use_showgcd and "true" or "false"),
showOnCheck showOnCheck
)) ))
table.insert(ret, [=[ table.insert(ret, ([=[
if paused then if (state.expirationTime ~= expirationTime) then
if not state.paused then state.expirationTime = expirationTime;
state.paused = true state.changed = true;
state.expirationTime = nil
state.changed = true
end
if state.remaining ~= startTime then
state.remaining = startTime
state.changed = true
end
else
if (state.expirationTime ~= expirationTime) then
state.expirationTime = expirationTime;
state.changed = true;
end
if state.paused then
state.paused = false
state.remaining = nil
state.changed = true
end
end
if (state.duration ~= duration) then
state.duration = duration;
state.changed = true;
end
state.progressType = 'timed';
]=])
if(trigger.use_remaining and trigger.genericShowOn ~= "showOnReady") then
table.insert(ret, ([[
local remaining = 0;
if (not paused and expirationTime and expirationTime > 0) then
remaining = expirationTime - GetTime();
local remainingCheck = %s;
if(remaining >= remainingCheck and remaining > 0) then
local event = "COOLDOWN_REMAINING_CHECK:" .. %s
Private.ExecEnv.ScheduleScan(expirationTime - remainingCheck, event);
end
end
]]):format(tonumber(trigger.remaining or 0) or 0, spellName))
end end
if (state.duration ~= duration) then
state.duration = duration;
state.changed = true;
end
state.progressType = 'timed';
]=]))
return table.concat(ret) if(trigger.use_remaining and trigger.genericShowOn ~= "showOnReady") then
table.insert(ret, ([[
local remaining = 0;
if (expirationTime and expirationTime > 0) then
remaining = expirationTime - GetTime();
local remainingCheck = %s;
if(remaining >= remainingCheck and remaining > 0) then
local event = "COOLDOWN_REMAINING_CHECK:" .. %s
Private.ExecEnv.ScheduleScan(expirationTime - remainingCheck, event);
end
end
]]):format(tonumber(trigger.remaining or 0) or 0, spellName))
end
return table.concat(ret)
end, end,
GetNameAndIcon = function(trigger) GetNameAndIcon = function(trigger)
local spellName local name, _, icon = GetSpellInfo(trigger.spellName or 0)
if (trigger.use_exact_spellName) then return name or "Invalid", icon
spellName = tonumber(trigger.spellName)
else
spellName = type(trigger.spellName) == "number" and GetSpellInfo(trigger.spellName) or trigger.spellName
end
if spellName then
local name, _, icon = GetSpellInfo(spellName)
return name, icon
end
end, end,
statesParameter = "one", statesParameter = "one",
progressType = "timed", progressType = "timed",
@@ -3424,7 +3375,7 @@ Private.event_prototypes = {
}, },
{ {
name = "charges", name = "charges",
display = L["Stacks"], display = L["Charges"],
type = "number", type = "number",
store = true, store = true,
conditionType = "number", conditionType = "number",
@@ -3445,7 +3396,7 @@ Private.event_prototypes = {
store = true store = true
}, },
{ {
hidden = true, hidden = true,
name = "maxCharges", name = "maxCharges",
store = true, store = true,
display = L["Max Charges"], display = L["Max Charges"],
@@ -3484,7 +3435,8 @@ Private.event_prototypes = {
test = "true", test = "true",
conditionType = "bool", conditionType = "bool",
conditionTest = function(state, needle) conditionTest = function(state, needle)
return state and state.show and (IsUsableSpell(state.spellname or "") == (needle == 1)) return state and state.show and
((IsUsableSpell((type(state.spellname) == "number" and GetSpellInfo(state.spellname)) or state.spellname) == 1 and true or false) == (needle == 1))
end, end,
conditionEvents = { conditionEvents = {
"SPELL_UPDATE_USABLE", "SPELL_UPDATE_USABLE",
@@ -3499,7 +3451,8 @@ Private.event_prototypes = {
test = "true", test = "true",
conditionType = "bool", conditionType = "bool",
conditionTest = function(state, needle) conditionTest = function(state, needle)
return state and state.show and (select(2, IsUsableSpell(state.spellname or "")) == (needle == 1)); return state and state.show and
((select(2, IsUsableSpell((type(state.spellname) == "number" and GetSpellInfo(state.spellname)) or state.spellname)) == 1 and true or false) == (needle == 1))
end, end,
conditionEvents = { conditionEvents = {
"SPELL_UPDATE_USABLE", "SPELL_UPDATE_USABLE",
@@ -3772,8 +3725,7 @@ Private.event_prototypes = {
local itemName = type(trigger.itemName) == "number" and trigger.itemName or string.format("%q", trigger.itemName or "0") local itemName = type(trigger.itemName) == "number" and trigger.itemName or string.format("%q", trigger.itemName or "0")
local ret = [=[ local ret = [=[
local itemname = %s; local itemname = %s;
local name = GetItemInfo(itemname or 0) or "Invalid" local name, _, _, _, _, _, _, _, _, icon = GetItemInfo(itemname or 0) or "Invalid"
local icon = GetItemIcon(itemname or 0)
local showgcd = %s local showgcd = %s
local startTime, duration, enabled, gcdCooldown = WeakAuras.GetItemCooldown(itemname, showgcd); local startTime, duration, enabled, gcdCooldown = WeakAuras.GetItemCooldown(itemname, showgcd);
local expirationTime = startTime + duration local expirationTime = startTime + duration
@@ -3796,8 +3748,7 @@ Private.event_prototypes = {
"[[" .. (trigger.genericShowOn or "") .. "]]"); "[[" .. (trigger.genericShowOn or "") .. "]]");
end, end,
GetNameAndIcon = function(trigger) GetNameAndIcon = function(trigger)
local name = GetItemInfo(trigger.itemName or 0) local name, _, _, _, _, _, _, _, _, icon = GetItemInfo(trigger.itemName or 0)
local icon = GetItemIcon(trigger.itemName or 0)
return name, icon return name, icon
end, end,
statesParameter = "one", statesParameter = "one",
@@ -4973,6 +4924,10 @@ Private.event_prototypes = {
trigger.use_includeCharges and "true" or "nil" trigger.use_includeCharges and "true" or "nil"
) )
end, end,
GetNameAndIcon = function(trigger)
local name, _, _, _, _, _, _, _, _, icon = GetItemInfo(trigger.itemName or 0)
return name, icon
end,
args = { args = {
{ {
name = "itemName", name = "itemName",
@@ -5045,14 +5000,14 @@ Private.event_prototypes = {
}, },
{ {
name = "icon", name = "icon",
init = "GetItemIcon(itemName or '')", init = "icon",
hidden = true, hidden = true,
store = true, store = true,
test = "true" test = "true"
}, },
{ {
name = "name", name = "name",
init = "itemName and itemName ~= '' and GetItemInfo(itemName) or itemName", init = "itemName ~= '' and itemName",
hidden = true, hidden = true,
store = true, store = true,
test = "true" test = "true"
@@ -5802,12 +5757,23 @@ Private.event_prototypes = {
local itemName = type(trigger.itemName) == "number" and trigger.itemName or string.format("%q", trigger.itemName or "0") local itemName = type(trigger.itemName) == "number" and trigger.itemName or string.format("%q", trigger.itemName or "0")
local ret = [[ local ret = [[
local inverse = %s; local inverse = %s
local triggerItemName = %s local triggerItemName = %s
local itemName, _, _, _, _, _, _, _, _, icon = GetItemInfo(triggerItemName) local _, _, _, _, icon = GetItemInfo(triggerItemName)
local itemSlot = %s; local itemSlot = %s
local equipped = WeakAuras.CheckForItemEquipped(itemName, itemSlot); ]]
]];
if trigger.use_exact_itemName then
ret = ret ..[[
local itemName = triggerItemName
local equipped = WeakAuras.CheckForItemEquipped(triggerItemName, itemSlot)
]]
else
ret = ret ..[[
local itemName = GetItemInfo(triggerItemName)
local equipped = WeakAuras.CheckForItemEquipped(itemName, itemSlot)
]]
end
return ret:format(trigger.use_inverse and "true" or "false", itemName, trigger.use_itemSlot and trigger.itemSlot or "nil"); return ret:format(trigger.use_inverse and "true" or "false", itemName, trigger.use_itemSlot and trigger.itemSlot or "nil");
end, end,
@@ -5822,7 +5788,8 @@ Private.event_prototypes = {
display = L["Item"], display = L["Item"],
type = "item", type = "item",
required = true, required = true,
test = "true" test = "true",
showExactOption = true
}, },
{ {
name = "itemSlot", name = "itemSlot",