local ui = {}
local _V = function(...) return SL:GetMetaValue(...) end
local FUNCQUEUE = {}
local TAGOBJ = {}
function ui.init(parent, __data__, __update__)
if __update__ then return ui.update(__data__) end
-- Create Node_1
local Node_1 = GUI:Nod
🤖 回答引擎: 浮生梦专用2 |
🕒 时间: 2026-03-06 21:16:32 |
👁️ 阅读: 30
--前端开始]]
local npc = { } -- 类
npc.CONFIG = { -- 配置
MSG_ID = 9999, -- 修改你的通信协议号
UI_NAME = "修改你的export名字", -- UI界面名称
-- 转生配置
levels = {
[1] = {needlevel = 75, needNum = {10, 10000000}, att = {5, 5, 5}}, -- 1转
[2] = {needlevel = 1, needNum = {20, 20000000}, att = {5, 5, 5}}, -- 2转 (转生后等级重置为1,所以needlevel为1)
[3] = {needlevel = 1, needNum = {40, 30000000}, att = {5, 5, 5}},
[4] = {needlevel = 1, needNum = {80, 40000000}, att = {5, 5, 5}},
[5] = {needlevel = 1, needNum = {160, 50000000}, att = {5, 5, 5}},
[6] = {needlevel = 1, needNum = {320, 60000000}, att = {5, 5, 5}},
[7] = {needlevel = 1, needNum = {640, 70000000}, att = {5, 5, 5}},
[8] = {needlevel = 1, needNum = {1280, 80000000}, att = {5, 5, 5}},
[9] = {needlevel = 1, needNum = {2560, 90000000}, att = {5, 5, 5}},
[10] = {needlevel = 1, needNum = {5120, 100000000}, att = {5, 5, 5}},
},
needItems = {"法神之心", "金币"}, -- 对应ItemShow_fszx和itemshow_money
addAtt = {60, 26}, -- 生命加成, 伤害减免 (示例,可根据需要调整)
}
function npc:Lmain() -- 前端的入口处
local ui = GUI:npcUi(self.CONFIG.UI_NAME) -- 调用export
-- 为转生按钮添加点击事件和入场特效
GUI:onClick(ui.sendbtn, function()
-- 使用cocos2dx 3.1.5 lua版本添加按钮点击特效,例如缩放动画
local scaleAction = cc.ScaleTo:create(0.1, 1.2)
local scaleBack = cc.ScaleTo:create(0.1, 1.0)
local sequence = cc.Sequence:create(scaleAction, scaleBack)
ui.sendbtn:runAction(sequence)
-- 发送服务端协议
SL:toServer(self.CONFIG.MSG_ID, 1) -- p1=1 表示转生操作
end)
-- 关闭按钮事件
GUI:onClick(ui.close, function()
GUI:Close(ui.Node_1)
end)
end
--前端结束]]
function npc:Smain(actor,p1,p2,p3,str)
local player = class(actor) -- 面向对象获取人物对象
if not player then return end
-- 路由分发机制
local dis = {
[1] = self.func1, -- 方法1: 执行转生
}
local handler = dis[p1]
if handler then
handler(self, actor, player, p2, p3, str)
else
player:send("未知的操作请求! 错误码:" .. tostring(p1))
-- 下日志!
end
end
function npc:func1(actor, player, p2, p3, str) -- 转生方法
local relv = player.relevel or 0
-- 边界检查
if relv < 0 then
return player:send("转生等级异常")
end
if relv >= #self.CONFIG.levels then
return player:send("您已经达到最大转生等级!")
end
local nextInfo = self.CONFIG.levels[relv + 1]
if not nextInfo then
return player:send("转生配置错误!")
end
-- 检查等级
if player.lv < nextInfo.needlevel then
return player:send("您当前的等级还需要"..(nextInfo.needlevel - player.lv).."级!请继续努力!")
end
-- 检查法神之心
local hasCount = getbagitemcount(player.actor, self.CONFIG.needItems[1])
if hasCount < nextInfo.needNum[1] then
return player:send("请先去获取"..self.CONFIG.needItems[1]..",需要"..nextInfo.needNum[1].."个!")
end
-- 检查金币
if not player:checkmoney(self.CONFIG.needItems[2], nextInfo.needNum[2]) then
return player:send(self.CONFIG.needItems[2].."不足:"..nextInfo.needNum[2].."!")
end
-- 扣除物品和金币
player:decitem(self.CONFIG.needItems[1], nextInfo.needNum[1])
player:decmoney(self.CONFIG.needItems[2], nextInfo.needNum[2])
-- 执行转生:等级重置为1,增加转生等级
player:setlevel(1)
player:setrelevel(relv + 1)
-- 增加属性:攻魔道双防各加5,HP上限增加5%
-- 注意:这里需要根据实际属性字段进行调整,以下为示例
player:setdc(player.dc + nextInfo.att[1])
player:setmc(player.mc + nextInfo.att[2])
player:setsc(player.sc + nextInfo.att[3])
local curHp = player.maxhp
player:setmaxhp(math.floor(curHp * 1.05))
player:send("转生成功! 当前为" .. (relv + 1) .. "转,等级已重置为1,属性已提升。")
end
return npc
--前端开始]]
local npc = { } -- 类
npc.CONFIG = { -- 配置
MSG_ID = 9999, -- 修改你的通信协议号
UI_NAME = "修改你的export名字", -- UI界面名称
-- 转生配置
levels = {
[1] = {needlevel = 75, needNum = {10, 10000000}, att = {5, 5, 5}}, -- 1转
[2] = {needlevel = 1, needNum = {20, 20000000}, att = {5, 5, 5}}, -- 2转 (转生后等级重置为1,所以needlevel为1)
[3] = {needlevel = 1, needNum = {40, 30000000}, att = {5, 5, 5}},
[4] = {needlevel = 1, needNum = {80, 40000000}, att = {5, 5, 5}},
[5] = {needlevel = 1, needNum = {160, 50000000}, att = {5, 5, 5}},
[6] = {needlevel = 1, needNum = {320, 60000000}, att = {5, 5, 5}},
[7] = {needlevel = 1, needNum = {640, 70000000}, att = {5, 5, 5}},
[8] = {needlevel = 1, needNum = {1280, 80000000}, att = {5, 5, 5}},
[9] = {needlevel = 1, needNum = {2560, 90000000}, att = {5, 5, 5}},
[10] = {needlevel = 1, needNum = {5120, 100000000}, att = {5, 5, 5}},
},
needItems = {"法神之心", "金币"}, -- 对应ItemShow_fszx和itemshow_money
addAtt = {60, 26}, -- 生命加成, 伤害减免 (示例,可根据需要调整)
}
function npc:Lmain() -- 前端的入口处
local ui = GUI:npcUi(self.CONFIG.UI_NAME) -- 调用export
-- 为转生按钮添加点击事件和入场特效
GUI:onClick(ui.sendbtn, function()
-- 使用cocos2dx 3.1.5 lua版本添加按钮点击特效,例如缩放动画
local scaleAction = cc.ScaleTo:create(0.1, 1.2)
local scaleBack = cc.ScaleTo:create(0.1, 1.0)
local sequence = cc.Sequence:create(scaleAction, scaleBack)
ui.sendbtn:runAction(sequence)
-- 发送服务端协议
SL:toServer(self.CONFIG.MSG_ID, 1) -- p1=1 表示转生操作
end)
-- 关闭按钮事件
GUI:onClick(ui.close, function()
GUI:Close(ui.Node_1)
end)
end
--前端结束]]
function npc:Smain(actor,p1,p2,p3,str)
local player = class(actor) -- 面向对象获取人物对象
if not player then return end
-- 路由分发机制
local dis = {
[1] = self.func1, -- 方法1: 执行转生
}
local handler = dis[p1]
if handler then
handler(self, actor, player, p2, p3, str)
else
player:send("未知的操作请求! 错误码:" .. tostring(p1))
-- 下日志!
end
end
function npc:func1(actor, player, p2, p3, str) -- 转生方法
local relv = player.relevel or 0
-- 边界检查
if relv < 0 then
return player:send("转生等级异常")
end
if relv >= #self.CONFIG.levels then
return player:send("您已经达到最大转生等级!")
end
local nextInfo = self.CONFIG.levels[relv + 1]
if not nextInfo then
return player:send("转生配置错误!")
end
-- 检查等级
if player.lv < nextInfo.needlevel then
return player:send("您当前的等级还需要"..(nextInfo.needlevel - player.lv).."级!请继续努力!")
end
-- 检查法神之心
local hasCount = getbagitemcount(player.actor, self.CONFIG.needItems[1])
if hasCount < nextInfo.needNum[1] then
return player:send("请先去获取"..self.CONFIG.needItems[1]..",需要"..nextInfo.needNum[1].."个!")
end
-- 检查金币
if not player:checkmoney(self.CONFIG.needItems[2], nextInfo.needNum[2]) then
return player:send(self.CONFIG.needItems[2].."不足:"..nextInfo.needNum[2].."!")
end
-- 扣除物品和金币
player:decitem(self.CONFIG.needItems[1], nextInfo.needNum[1])
player:decmoney(self.CONFIG.needItems[2], nextInfo.needNum[2])
-- 执行转生:等级重置为1,增加转生等级
player:setlevel(1)
player:setrelevel(relv + 1)
-- 增加属性:攻魔道双防各加5,HP上限增加5%
-- 注意:这里需要根据实际属性字段进行调整,以下为示例
player:setdc(player.dc + nextInfo.att[1])
player:setmc(player.mc + nextInfo.att[2])
player:setsc(player.sc + nextInfo.att[3])
local curHp = player.maxhp
player:setmaxhp(math.floor(curHp * 1.05))
player:send("转生成功! 当前为" .. (relv + 1) .. "转,等级已重置为1,属性已提升。")
end
return npc
← 返回问答库