"SELECT enchantID FROM item_enchantment_random_tiers WHERE tier=%d AND ( (exclusiveSubClass IS NULL AND class='%s') OR exclusiveSubClass=%d OR class='ANY' ) ORDER BY RAND() LIMIT 1",
tier, itemClass, itemSubClass
)
local query = WorldDBQuery(queryStr)
if query then -- 增加空判断,避免查询无结果时报错
return query:GetUInt32(0)
else
return nil
end
end
function OnLoot(event, player, item, count)
local slotBools = {}
local slotIDs = {}
local its = 0 -- 附魔槽位ID(服务端附魔槽位对应不同数值)
-- 修复:后续判断统一用对应roll变量,原脚本错误用boolRoll2判断3/4槽位
local boolRoll1 = math.random(100)
if boolRoll1 >= 60 then
slotBools[1] = true
slotIDs[1] = RollEnchant(item)
else
slotBools[1] = false
end
local boolRoll2 = math.random(100)
if boolRoll2 >= 65 and slotBools[1] then
slotBools[2] = true
slotIDs[2] = RollEnchant(item)
else
slotBools[2] = false
end
local boolRoll3 = math.random(100)
if boolRoll3 >= 70 and slotBools[2] then -- 修复:用boolRoll3而非boolRoll2
slotBools[3] = true
slotIDs[3] = RollEnchant(item)
else
slotBools[3] = false
end
local boolRoll4 = math.random(100)
if boolRoll4 >= 75 and slotBools[3] then -- 修复:用boolRoll4而非boolRoll2
slotBools[4] = true
slotIDs[4] = RollEnchant(item)
else
slotBools[4] = false
end
-- 给物品添加附魔:仅武器/护甲生效,遍历有效槽位
if slotBools[1] and (item:GetClass() == 2 or item:GetClass() == 4) then