|
|
-- EquipEnchant.lua 装备附魔洗练系统
local M = {}
-- 附魔词条库(高级/稀有/普通)
local ENCHANT_WORDS = {
{name="攻击+20", attr={20,0,0}},
{name="魔法+20", attr={0,20,0}},
{name="道术+20", attr={0,0,20}},
{name="生命+500", attr={0,0,0,500}},
{name="暴击率+5%", attr={0,0,0,0,5}},
}
-- 附魔主功能
function M.OnEnchant(player)
local equip = player:GetCurrentEquip()
if not equip then return player:SendMsg(0,"请选中装备") end
if equip:GetEnchantCount() >= 3 then return player:SendMsg(0,"已满3条附魔") end
if not player:CheckItem("附魔卷轴",1) then return player:SendMsg(0,"缺少附魔卷轴") end
player elItem("附魔卷轴",1)
-- 随机词条
local word = ENCHANT_WORDS[math.random(#ENCHANT_WORDS)]
equip:AddEnchant(word.name, word.attr) -- 新增附魔词条
player:SendMsg(1, string.format("附魔成功!获得词条:%s", word.name))
end
-- 洗练:替换指定词条
function M.OnResetEnchant(player, index)
local equip = player:GetCurrentEquip()
if not equip or not equip:GetEnchant(index) then return end
if not player:CheckItem("洗练石",2) then return player:SendMsg(0,"缺少洗练石") end
player elItem("洗练石",2)
local newWord = ENCHANT_WORDS[math.random(#ENCHANT_WORDS)]
equip:ResetEnchant(index, newWord.name, newWord.attr)
player:SendMsg(1, string.format("洗练成功!新词条:%s", newWord.name))
end
return M |
|