mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Resolve item sets via ClassicAPI; drop Reliquary dependency
Item-set membership and set info now read ItemSet.dbc directly through ClassicAPI instead of the nampower/Reliquary glue, so set features no longer require the Reliquary DLL to be installed. - ClassicAPI.lua: add GetItemSetIDByID and GetItemSetInfo wrappers. - Utility.lua: repoint ResolveSetItems, CountEquippedSetItemsBySetId, GetEquippedItemSetInfo, and GetEquippedSetPieceCount at the ClassicAPI accessors. Set-name matching now uses the DBC name (localized; identical to the old enUS path on English clients). - NampowerAPI.lua: remove the now-unused GetItemSet/GetItemSetId/ GetItemSetItems/GetItemSetBonuses, the dead GetSpellEffectRadius (no callers, only radius source was Reliquary), and the orphaned RQ_SafeCall. - Init.lua: drop hasReliquary detection and its startup feature line. - Conditionals.lua: update the [set:] comment (no longer Reliquary-gated).
This commit is contained in:
@@ -137,6 +137,24 @@ function API.GetInventoryItemID(unit, slot)
|
||||
return GetInventoryItemID(unit, slot)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Item Set
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- ItemSet.dbc ID that `itemID` belongs to, or nil if it isn't part of a set
|
||||
-- (or isn't cached yet). Reads the item's m_itemSet field directly -- no
|
||||
-- Reliquary, no per-set ItemID[] scan.
|
||||
function API.GetItemSetIDByID(itemID)
|
||||
return C_Item.GetItemSetIDByID(itemID)
|
||||
end
|
||||
|
||||
-- Table describing an ItemSet.dbc row, or nil if `setID` doesn't resolve:
|
||||
-- { setID, name (localized), requiredSkill, requiredSkillRank,
|
||||
-- items = { itemID, ... }, bonuses = { { spellID, threshold }, ... } }
|
||||
function API.GetItemSetInfo(setID)
|
||||
return C_Item.GetItemSetInfo(setID)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Spell
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
+2
-2
@@ -5751,8 +5751,8 @@ CleveRoids.Keywords = {
|
||||
|
||||
-- [set:SetName>=N] — true if equipped piece count of named set meets comparison
|
||||
-- [set:SetName] — true if any pieces of that set are equipped (count > 0)
|
||||
-- [set:123>=3] — numeric IDs also supported (Nampower only, no Reliquary needed)
|
||||
-- Name lookup requires Reliquary (for DBC set name); ID lookup requires Nampower
|
||||
-- [set:123>=3] — numeric IDs also supported
|
||||
-- Both name and ID lookups resolve from ItemSet.dbc via ClassicAPI
|
||||
set = function(conditionals)
|
||||
return Multi(conditionals.set, function(args)
|
||||
if type(args) == "table" and args.operator and args.amount then
|
||||
|
||||
@@ -22,7 +22,6 @@ CleveRoids.mouseOverUnit = nil
|
||||
-- Environment flags
|
||||
CleveRoids.hasSuperwow = SetAutoloot and true or false
|
||||
CleveRoids.hasTurtle = (type(_G.TURTLE_WOW_VERSION) ~= "nil")
|
||||
CleveRoids.hasReliquary = (RQ_GetVersion ~= nil)
|
||||
CleveRoids.supported = CleveRoids.hasTurtle
|
||||
|
||||
CleveRoids.ParsedMsg = {}
|
||||
@@ -291,14 +290,6 @@ local function PrintFeatures()
|
||||
end
|
||||
end
|
||||
if CleveRoids.hasUnitXP then table.insert(features, "UnitXP") end
|
||||
if CleveRoids.hasReliquary then
|
||||
local ok, major, minor, patch = pcall(RQ_GetVersion)
|
||||
if ok and major then
|
||||
table.insert(features, string.format("Reliquary v%d.%d.%d", major, minor, patch))
|
||||
else
|
||||
table.insert(features, "Reliquary")
|
||||
end
|
||||
end
|
||||
if CleveRoids.hasTurtle then table.insert(features, "Turtle") end
|
||||
|
||||
if table.getn(features) > 0 then
|
||||
|
||||
-112
@@ -3531,117 +3531,5 @@ function API.GetUnitMaxPower(unitToken, powerType)
|
||||
return UnitManaMax(unitToken)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- RELIQUARY DBC FUNCTIONS (optional DLL)
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Safe Reliquary call wrapper — returns nil on missing DLL or lookup failure
|
||||
local function RQ_SafeCall(func, ...)
|
||||
if not func then return nil end
|
||||
local ok, result = pcall(func, unpack(arg))
|
||||
if ok then return result end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Get item set data from DBC by set ID
|
||||
-- Returns: { name, itemId_1..17, setSpellId_1..8, setThreshold_1..8 } or nil
|
||||
function API.GetItemSet(setId)
|
||||
if not setId or not _G.RQ_GetItemSet then return nil end
|
||||
return RQ_SafeCall(_G.RQ_GetItemSet, setId)
|
||||
end
|
||||
|
||||
-- Get the set ID for an item (via Nampower's GetItemStatsField)
|
||||
-- Returns: setId (number) or nil if item has no set
|
||||
function API.GetItemSetId(itemId)
|
||||
if not itemId then return nil end
|
||||
local setId = API.GetItemField(itemId, "itemSet")
|
||||
if setId and setId ~= 0 then return setId end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Get all item IDs belonging to a set (from Reliquary DBC)
|
||||
-- Returns: { itemId1, itemId2, ... } or nil
|
||||
function API.GetItemSetItems(setId)
|
||||
local setData = API.GetItemSet(setId)
|
||||
if not setData then return nil end
|
||||
|
||||
local items = {}
|
||||
for i = 1, 17 do
|
||||
local id = setData["itemId_" .. i]
|
||||
if id then
|
||||
id = tonumber(id)
|
||||
if id and id ~= 0 then
|
||||
table.insert(items, id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table.getn(items) > 0 then return items end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Get set bonus spell/threshold pairs from DBC
|
||||
-- Returns: { { spellId = N, threshold = N }, ... } or nil
|
||||
function API.GetItemSetBonuses(setId)
|
||||
local setData = API.GetItemSet(setId)
|
||||
if not setData then return nil end
|
||||
|
||||
local bonuses = {}
|
||||
for i = 1, 8 do
|
||||
local spellId = setData["setSpellId_" .. i]
|
||||
local threshold = setData["setThreshold_" .. i]
|
||||
if spellId and threshold then
|
||||
spellId = tonumber(spellId)
|
||||
threshold = tonumber(threshold)
|
||||
if spellId and spellId ~= 0 and threshold and threshold > 0 then
|
||||
table.insert(bonuses, { spellId = spellId, threshold = threshold })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table.getn(bonuses) > 0 then return bonuses end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Get spell effect radius in yards from DBC
|
||||
-- spellId: the spell to look up
|
||||
-- effectIndex: 1, 2, or 3 (which effect slot, default 1)
|
||||
-- Returns: radius (number) or nil
|
||||
function API.GetSpellEffectRadius(spellId, effectIndex)
|
||||
effectIndex = effectIndex or 1
|
||||
if not spellId then return nil end
|
||||
|
||||
-- Get the radius index from the spell's effect via Nampower
|
||||
local radiusField = "effectRadiusIndex"
|
||||
local rec = API.GetSpellRecord(spellId)
|
||||
if not rec then return nil end
|
||||
|
||||
-- effectRadiusIndex is an array field — access by effect index
|
||||
local radiusIndex = nil
|
||||
if rec.effectRadiusIndex then
|
||||
if type(rec.effectRadiusIndex) == "table" then
|
||||
radiusIndex = rec.effectRadiusIndex[effectIndex]
|
||||
else
|
||||
-- Single value (effect 1 only)
|
||||
if effectIndex == 1 then
|
||||
radiusIndex = rec.effectRadiusIndex
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not radiusIndex or radiusIndex == 0 then return nil end
|
||||
|
||||
-- Try Reliquary for the SpellRadius DBC lookup
|
||||
if _G.RQ_GetSpellRadius then
|
||||
local radiusData = RQ_SafeCall(_G.RQ_GetSpellRadius, radiusIndex)
|
||||
if radiusData and radiusData.radius then
|
||||
local radius = tonumber(radiusData.radius)
|
||||
if radius and radius > 0 then return radius end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Expose API globally for other addons
|
||||
_G.CleveRoidsNampowerAPI = API
|
||||
|
||||
+33
-66
@@ -7038,28 +7038,30 @@ end
|
||||
|
||||
-- Database of set bonus modifiers for debuff durations
|
||||
-- Structure: [spellID] = { items = {itemID1, itemID2, ...}, threshold = X, modifier = function(baseDuration) }
|
||||
-- When Reliquary is available, items can be omitted and setId used instead (auto-resolves from DBC)
|
||||
-- When a setId is given, items can be omitted and resolved from ItemSet.dbc
|
||||
CleveRoids.setbonusModifiers = CleveRoids.setbonusModifiers or {}
|
||||
|
||||
-- Cache: setId -> { itemId1, itemId2, ... } (resolved from Reliquary or hardcoded)
|
||||
-- Cache: setId -> { itemId1, itemId2, ... } (resolved from ItemSet.dbc or hardcoded)
|
||||
local setItemCache = {}
|
||||
|
||||
-- Resolve set items: use Reliquary DBC if available, otherwise fall back to hardcoded list
|
||||
-- Resolve set items: use the ItemSet.dbc lookup when a setId is given, otherwise
|
||||
-- fall back to the hardcoded list on the modifier.
|
||||
local function ResolveSetItems(modifier)
|
||||
-- If items are already provided (hardcoded), use them directly
|
||||
if modifier.items and table.getn(modifier.items) > 0 then
|
||||
return modifier.items
|
||||
end
|
||||
|
||||
-- Try Reliquary DBC lookup by setId
|
||||
if modifier.setId and CleveRoids.NampowerAPI then
|
||||
-- DBC lookup by setId via ClassicAPI
|
||||
if modifier.setId then
|
||||
-- Check cache first
|
||||
if setItemCache[modifier.setId] then
|
||||
return setItemCache[modifier.setId]
|
||||
end
|
||||
|
||||
local items = CleveRoids.NampowerAPI.GetItemSetItems(modifier.setId)
|
||||
if items then
|
||||
local info = CleveRoids.ClassicAPI.GetItemSetInfo(modifier.setId)
|
||||
local items = info and info.items
|
||||
if items and table.getn(items) > 0 then
|
||||
setItemCache[modifier.setId] = items
|
||||
return items
|
||||
end
|
||||
@@ -7069,7 +7071,7 @@ local function ResolveSetItems(modifier)
|
||||
end
|
||||
|
||||
-- Function to count how many items from a set are currently equipped
|
||||
-- Accepts either a direct items table or a modifier entry with setId for Reliquary lookup
|
||||
-- Accepts either a direct items table or a modifier entry with setId for DBC lookup
|
||||
function CleveRoids.CountEquippedSetItems(items)
|
||||
if not items or type(items) ~= "table" then return 0 end
|
||||
|
||||
@@ -7091,37 +7093,19 @@ function CleveRoids.CountEquippedSetItems(items)
|
||||
return count
|
||||
end
|
||||
|
||||
-- Count equipped set items by set ID (uses Nampower to check each slot's itemSet field)
|
||||
-- Falls back to CountEquippedSetItems with Reliquary item list if GetItemStatsField unavailable
|
||||
-- Count equipped set items by set ID, comparing each equipped slot's own set
|
||||
-- membership (ClassicAPI GetItemSetIDByID) against the target set.
|
||||
function CleveRoids.CountEquippedSetItemsBySetId(setId)
|
||||
if not setId then return 0 end
|
||||
|
||||
-- Fast path: use Nampower GetItemStatsField to check itemSet directly per slot
|
||||
if CleveRoids.NampowerAPI and CleveRoids.NampowerAPI.GetItemField then
|
||||
local count = 0
|
||||
for slot = 1, 19 do
|
||||
local itemID = CleveRoids.GetEquippedItemID(slot)
|
||||
if itemID then
|
||||
local itemSetId = CleveRoids.NampowerAPI.GetItemSetId(itemID)
|
||||
if itemSetId == setId then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
local count = 0
|
||||
for slot = 1, 19 do
|
||||
local itemID = CleveRoids.GetEquippedItemID(slot)
|
||||
if itemID and CleveRoids.ClassicAPI.GetItemSetIDByID(itemID) == setId then
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Fallback: resolve set item list and count matches
|
||||
local items = setItemCache[setId]
|
||||
if not items and CleveRoids.NampowerAPI then
|
||||
items = CleveRoids.NampowerAPI.GetItemSetItems(setId)
|
||||
if items then setItemCache[setId] = items end
|
||||
end
|
||||
if items then
|
||||
return CleveRoids.CountEquippedSetItems(items)
|
||||
end
|
||||
|
||||
return 0
|
||||
return count
|
||||
end
|
||||
|
||||
-- Apply set bonus modifiers to a debuff duration
|
||||
@@ -7172,7 +7156,7 @@ end
|
||||
|
||||
-- Helper function to register a set bonus modifier
|
||||
-- Usage: CleveRoids.RegisterSetBonusModifier(spellID, itemsTable, threshold, modifierFunction)
|
||||
-- With Reliquary: CleveRoids.RegisterSetBonusModifier(spellID, nil, threshold, modifierFunction, setId)
|
||||
-- With a setId: CleveRoids.RegisterSetBonusModifier(spellID, nil, threshold, modifierFunction, setId)
|
||||
function CleveRoids.RegisterSetBonusModifier(spellID, items, threshold, modifierFunc, setId)
|
||||
if not spellID or not threshold or not modifierFunc then
|
||||
return false
|
||||
@@ -7191,17 +7175,17 @@ function CleveRoids.RegisterSetBonusModifier(spellID, items, threshold, modifier
|
||||
return true
|
||||
end
|
||||
|
||||
-- Get info about an equipped item's set (combines Nampower + Reliquary)
|
||||
-- Get info about an equipped item's set (from ItemSet.dbc via ClassicAPI)
|
||||
-- Returns: setName, setId, equippedCount, totalPieces, items or nil
|
||||
function CleveRoids.GetEquippedItemSetInfo(itemId)
|
||||
if not itemId or not CleveRoids.NampowerAPI then return nil end
|
||||
if not itemId then return nil end
|
||||
|
||||
local setId = CleveRoids.NampowerAPI.GetItemSetId(itemId)
|
||||
local setId = CleveRoids.ClassicAPI.GetItemSetIDByID(itemId)
|
||||
if not setId then return nil end
|
||||
|
||||
local setData = CleveRoids.NampowerAPI.GetItemSet(setId)
|
||||
local setName = setData and setData.name_enUS or nil
|
||||
local items = CleveRoids.NampowerAPI.GetItemSetItems(setId)
|
||||
local info = CleveRoids.ClassicAPI.GetItemSetInfo(setId)
|
||||
local setName = info and info.name or nil
|
||||
local items = info and info.items or nil
|
||||
local totalPieces = items and table.getn(items) or 0
|
||||
local equippedCount = CleveRoids.CountEquippedSetItemsBySetId(setId)
|
||||
|
||||
@@ -7211,7 +7195,7 @@ end
|
||||
-- Count equipped pieces of a named or ID-referenced item set
|
||||
-- nameOrId: set name (string, e.g. "Judgement Battlegear") or set ID (number)
|
||||
-- Returns: equipped count (number), setId (number or nil)
|
||||
-- Name lookup requires Reliquary; ID lookup requires Nampower
|
||||
-- Both name and ID lookups resolve from ItemSet.dbc via ClassicAPI
|
||||
function CleveRoids.GetEquippedSetPieceCount(nameOrId)
|
||||
if not nameOrId then return 0, nil end
|
||||
|
||||
@@ -7221,25 +7205,17 @@ function CleveRoids.GetEquippedSetPieceCount(nameOrId)
|
||||
return CleveRoids.CountEquippedSetItemsBySetId(numericId), numericId
|
||||
end
|
||||
|
||||
-- String: scan equipped items and match by set name from DBC
|
||||
if not CleveRoids.NampowerAPI or not CleveRoids.NampowerAPI.GetItemSetId then
|
||||
return 0, nil
|
||||
end
|
||||
|
||||
-- Scan equipped items to resolve set name → set ID, then count via fast path
|
||||
-- String: scan equipped items and match by set name from ItemSet.dbc
|
||||
local lowerName = string.lower(nameOrId)
|
||||
|
||||
for slot = 1, 19 do
|
||||
local itemID = CleveRoids.GetEquippedItemID(slot)
|
||||
if itemID then
|
||||
local setId = CleveRoids.NampowerAPI.GetItemSetId(itemID)
|
||||
local setId = CleveRoids.ClassicAPI.GetItemSetIDByID(itemID)
|
||||
if setId then
|
||||
local setData = CleveRoids.NampowerAPI.GetItemSet(setId)
|
||||
if setData then
|
||||
local dbcName = setData.name_enUS
|
||||
if dbcName and string.lower(dbcName) == lowerName then
|
||||
return CleveRoids.CountEquippedSetItemsBySetId(setId), setId
|
||||
end
|
||||
local info = CleveRoids.ClassicAPI.GetItemSetInfo(setId)
|
||||
if info and info.name and string.lower(info.name) == lowerName then
|
||||
return CleveRoids.CountEquippedSetItemsBySetId(setId), setId
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -7248,18 +7224,9 @@ function CleveRoids.GetEquippedSetPieceCount(nameOrId)
|
||||
return 0, nil
|
||||
end
|
||||
|
||||
-- Get spell effect radius in yards (Nampower + Reliquary)
|
||||
-- spellId: the spell to look up
|
||||
-- effectIndex: 1, 2, or 3 (which effect slot, default 1)
|
||||
-- Returns: radius in yards or nil
|
||||
function CleveRoids.GetSpellEffectRadius(spellId, effectIndex)
|
||||
if not CleveRoids.NampowerAPI then return nil end
|
||||
return CleveRoids.NampowerAPI.GetSpellEffectRadius(spellId, effectIndex)
|
||||
end
|
||||
|
||||
-- DRUID set bonus modifiers
|
||||
-- Dreamwalker Regalia (4/9): Increases Moonfire duration by 3 seconds and Insect Swarm by 2 seconds
|
||||
-- setId 536 = Dreamwalker Regalia; hardcoded items as fallback when Reliquary unavailable
|
||||
-- setId 536 = Dreamwalker Regalia; hardcoded items as fallback when DBC lookup unavailable
|
||||
local DREAMWALKER_SET_ID = 536
|
||||
local dreamwalkerItems = { 47372, 47373, 47374, 47375, 47376, 47377, 47378, 47379, 47380 }
|
||||
local dreamwalkerMoonfireModifier = function(base) return base + 3 end
|
||||
@@ -7285,7 +7252,7 @@ CleveRoids.setbonusModifiers[24976] = { setId = DREAMWALKER_SET_ID, items = drea
|
||||
CleveRoids.setbonusModifiers[24977] = { setId = DREAMWALKER_SET_ID, items = dreamwalkerItems, threshold = 4, modifier = dreamwalkerInsectSwarmModifier } -- Insect Swarm Rank 5
|
||||
|
||||
-- Haruspex's Garb (3/5): Increases Faerie Fire duration by 5 seconds
|
||||
-- setId 474 = Haruspex's Garb; hardcoded items as fallback when Reliquary unavailable
|
||||
-- setId 474 = Haruspex's Garb; hardcoded items as fallback when DBC lookup unavailable
|
||||
local HARUSPEX_SET_ID = 474
|
||||
local haruspexItems = { 19613, 19955, 19840, 19839, 19838 }
|
||||
local haruspexFaerieFireModifier = function(base) return base + 5 end
|
||||
|
||||
Reference in New Issue
Block a user