105 lines
3.1 KiB
Lua
105 lines
3.1 KiB
Lua
-- SM_Utils.lua
|
||
|
||
-- function SM_Collections:MessageSplit(inputstr, sep)
|
||
-- print("分割1")
|
||
-- if not inputstr or inputstr == "" then
|
||
-- return {}
|
||
-- end
|
||
-- if sep == nil then
|
||
-- sep = "%s"
|
||
-- end
|
||
-- local t = {}
|
||
-- for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
|
||
-- table.insert(t, str)
|
||
-- end
|
||
-- return t
|
||
-- end
|
||
|
||
|
||
-- 消息分割函数
|
||
function SM_Collections:MessageSplit(msg, delimiter)
|
||
print("分割2")
|
||
local result = {}
|
||
local from = 1
|
||
local delim_from, delim_to = string.find(msg, delimiter, from)
|
||
|
||
while delim_from do
|
||
table.insert(result, string.sub(msg, from, delim_from - 1))
|
||
from = delim_to + 1
|
||
delim_from, delim_to = string.find(msg, delimiter, from)
|
||
end
|
||
|
||
table.insert(result, string.sub(msg, from))
|
||
return result
|
||
end
|
||
|
||
function SM_Collections:GetMountInfo(spellID)
|
||
local info = self.Mounts[spellID]
|
||
if info then
|
||
return unpack(info, 1, 9)
|
||
end
|
||
end
|
||
|
||
-- 坐骑技能ID到生物显示ID的映射表
|
||
SM_Collections.SpellToDisplayIDMap = {
|
||
-- 常见的坐骑技能ID映射
|
||
[65643] = 34554, -- 请用正确的显示ID替换这些示例值
|
||
[65644] = 29256,
|
||
[65645] = 29257,
|
||
[66090] = 30358,
|
||
-- 可根据需要添加更多映射
|
||
}
|
||
|
||
function SM_Collections:GetCreatureDisplayID(itemID, itemType)
|
||
-- 检查itemID是否有效
|
||
if not itemID or type(itemID) ~= "number" or itemID <= 0 then
|
||
if itemType == "mount" then
|
||
return 16358 -- 返回默认坐骑ID
|
||
elseif itemType == "companion" then
|
||
return 7380 -- 返回默认小伙伴ID
|
||
else
|
||
return 1 -- 返回默认ID
|
||
end
|
||
end
|
||
if itemType == "mount" then
|
||
-- 首先尝试使用Mount.lua中的数据
|
||
if SM_Collections.SpellToDisplayIDMap and SM_Collections.SpellToDisplayIDMap[itemID] then
|
||
local mountData = SM_Collections.SpellToDisplayIDMap[itemID]
|
||
if mountData.effectMiscValue then
|
||
return mountData.effectMiscValue
|
||
end
|
||
end
|
||
|
||
-- 再尝试使用本地映射表
|
||
local mountInfo = self:GetMountInfo(itemID)
|
||
if mountInfo then
|
||
return mountInfo -- 第一个返回值就是 creatureDisplayID
|
||
end
|
||
|
||
-- 如果本地映射表中没有,提示错误
|
||
|
||
return 16358 -- 返回一个默认模型ID,避免显示错误
|
||
elseif itemType == "companion" then
|
||
-- 使用Companions.lua中的数据
|
||
if SM_Collections.Companions and SM_Collections.Companions[itemID] then
|
||
local companionData = SM_Collections.Companions[itemID]
|
||
if companionData.effectMiscValue then
|
||
return companionData.effectMiscValue
|
||
end
|
||
end
|
||
|
||
-- 如果上面的方法失败,返回默认ID
|
||
|
||
return 7380 -- 默认小伙伴ID
|
||
elseif itemType == "card" then
|
||
local cardMap = {
|
||
[26502] = 26502, -- 拉格纳罗斯
|
||
[24248] = 24248, -- 巫妖王
|
||
[19299] = 19299, -- 死亡耳语者
|
||
[32588] = 32588, -- 伊利丹
|
||
}
|
||
return cardMap[itemID] or itemID
|
||
end
|
||
return itemID
|
||
end
|