查看: 36|回复: 2

[Lua] 装备随机附魔 + 洗练替换 + 词条养成

[复制链接]

16

主题

13

回帖

555

积分

高级会员

积分
555
发表于 4 天前 | 显示全部楼层 |阅读模式
-- 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

    playerelItem("附魔卷轴",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

    playerelItem("洗练石",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

4

主题

7

回帖

284

积分

中级会员

积分
284
发表于 12 小时前 | 显示全部楼层
用AI生成LUA脚本,用来灌水,确实是个好方法!

1

主题

39

回帖

6638

积分

论坛元老

积分
6638
发表于 6 小时前 | 显示全部楼层

谢谢楼主分享!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表