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:59:06 |
👁️ 阅读: 10
--前端开始]]
local npc = { } -- 类
npc.CONFIG = { -- 配置
MSG_ID = 9999, -- 修改你的通信协议号
UI_NAME = "雷劫之地转生", -- UI界面名称
}
function npc:Lmain() -- 前端的入口处
local ui = GUI:npcUi(self.CONFIG.UI_NAME) -- 调用export
-- 入场特效
GUI:setScale(ui.Node_1, 0.5)
GUI:runAction(ui.Node_1, "scaleTo", 0.3, 1, 1)
-- 转生按钮事件
GUI:onClick(ui.sendbtn, function()
GUI:Button_setBright(ui.sendbtn, false)
GUI:setTouchEnabled(ui.sendbtn, false)
SL:ScheduleOnce(function()
GUI:Button_setBright(ui.sendbtn, true)
GUI:setTouchEnabled(ui.sendbtn, true)
SL:sendServer(self.CONFIG.MSG_ID, 1, 1, 0, "转生升级")
end, 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, -- 转生升级
[2] = self.func2, -- 属性加点
[3] = self.func3, -- 属性重置
}
local handler = dis[p1]
if handler then
handler(self, actor, player, p2, p3, str)
else
player:send("未知的操作请求! 错误码:" .. tostring(p1))
-- 下日志!
SL:print(string.format("协议异常警报: 玩家%s 协议%s 时间%s",
player.uid, p1, os.date()))
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 >= 10 then
return player:send("您已经达到最大转生等级!")
end
local config = {
{needNum = {10, 0, 10000000}},
{needNum = {20, 0, 20000000}},
{needNum = {40, 0, 30000000}},
{needNum = {80, 0, 40000000}},
{needNum = {160, 0, 50000000}},
{needNum = {320, 0, 60000000}},
{needNum = {640, 0, 70000000}},
{needNum = {1280, 0, 80000000}},
{needNum = {2560, 0, 90000000}},
{needNum = {5120, 0, 100000000}},
}
local nextInfo = config[relv + 1]
if not nextInfo then
return player:send("转生配置错误!")
end
-- 检查条件
if player.level < 75 then
return player:send("需要75级才能转生!")
end
-- 检查物品
local hasCount = player:getItemCount("法师之星")
if hasCount < nextInfo.needNum[1] then
return player:send("请先去获取法师之星,需要"..nextInfo.needNum[1].."个!")
end
-- 检查金币
if not player:checkmoney("金币", nextInfo.needNum[3]) then
return player:send("金币不足:"..nextInfo.needNum[3].."!")
end
-- 执行转生
player:take("法师之星", nextInfo.needNum[1])
:money("金币", "-", nextInfo.needNum[3])
player:addReLevel()
player:send("转生成功!当前转生等级:"..(relv + 1))
-- 属性加成
local rlv = getbaseinfo(actor,39)
if rlv <= 0 then
return
end
player:send("属性加成!!")
local att = string.format("3#4#%s|3#6#%s|3#8#%s",rlv*5,rlv*5,rlv*5)
player:attlist("转生属性加成",att)
end
function npc:func2(actor, player, p2, p3, str) -- 属性加点
local data = {
{1, "属性", player:getMainAttr()},
{2, "火焰", 101},
{3, "寒冰", 102},
{4, "雷电", 103},
{5, "狂风", 104},
{6, "神圣", 105},
{7, "暗黑", 106},
{8, "幻影", 107},
}
if not data[p2] then return end
if player:getvar(0, "属性点") <= 0 then
return player:send("属性点不足!")
end
local t = json2tbl(player:getvar(1, "元素属性")) or {}
local attname = data[p2][2]
if attname then
t[attname] = (t[attname] or 0) + 1
end
player:setVar(0, "属性点", "-", 1)
player:setVar(1, "元素属性", tbl2json(t))
player:send("属性分配成功!")
end
function npc:func3(actor, player, p2, p3, str) -- 属性重置
if not player:checkmoney("金币", 1000000) then
return player:send("金币不足100万!")
end
player:money("金币", "-", 1000000)
local attr = player.relevel * 10
player:setVar(0, "属性点", attr)
player:setVar(1, "元素属性", "")
player:send("属性点已重置!获得:"..attr)
end
return npc
--前端开始]]
local npc = { } -- 类
npc.CONFIG = { -- 配置
MSG_ID = 9999, -- 修改你的通信协议号
UI_NAME = "雷劫之地转生", -- UI界面名称
}
function npc:Lmain() -- 前端的入口处
local ui = GUI:npcUi(self.CONFIG.UI_NAME) -- 调用export
-- 入场特效
GUI:setScale(ui.Node_1, 0.5)
GUI:runAction(ui.Node_1, "scaleTo", 0.3, 1, 1)
-- 转生按钮事件
GUI:onClick(ui.sendbtn, function()
GUI:Button_setBright(ui.sendbtn, false)
GUI:setTouchEnabled(ui.sendbtn, false)
SL:ScheduleOnce(function()
GUI:Button_setBright(ui.sendbtn, true)
GUI:setTouchEnabled(ui.sendbtn, true)
SL:sendServer(self.CONFIG.MSG_ID, 1, 1, 0, "转生升级")
end, 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, -- 转生升级
[2] = self.func2, -- 属性加点
[3] = self.func3, -- 属性重置
}
local handler = dis[p1]
if handler then
handler(self, actor, player, p2, p3, str)
else
player:send("未知的操作请求! 错误码:" .. tostring(p1))
-- 下日志!
SL:print(string.format("协议异常警报: 玩家%s 协议%s 时间%s",
player.uid, p1, os.date()))
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 >= 10 then
return player:send("您已经达到最大转生等级!")
end
local config = {
{needNum = {10, 0, 10000000}},
{needNum = {20, 0, 20000000}},
{needNum = {40, 0, 30000000}},
{needNum = {80, 0, 40000000}},
{needNum = {160, 0, 50000000}},
{needNum = {320, 0, 60000000}},
{needNum = {640, 0, 70000000}},
{needNum = {1280, 0, 80000000}},
{needNum = {2560, 0, 90000000}},
{needNum = {5120, 0, 100000000}},
}
local nextInfo = config[relv + 1]
if not nextInfo then
return player:send("转生配置错误!")
end
-- 检查条件
if player.level < 75 then
return player:send("需要75级才能转生!")
end
-- 检查物品
local hasCount = player:getItemCount("法师之星")
if hasCount < nextInfo.needNum[1] then
return player:send("请先去获取法师之星,需要"..nextInfo.needNum[1].."个!")
end
-- 检查金币
if not player:checkmoney("金币", nextInfo.needNum[3]) then
return player:send("金币不足:"..nextInfo.needNum[3].."!")
end
-- 执行转生
player:take("法师之星", nextInfo.needNum[1])
:money("金币", "-", nextInfo.needNum[3])
player:addReLevel()
player:send("转生成功!当前转生等级:"..(relv + 1))
-- 属性加成
local rlv = getbaseinfo(actor,39)
if rlv <= 0 then
return
end
player:send("属性加成!!")
local att = string.format("3#4#%s|3#6#%s|3#8#%s",rlv*5,rlv*5,rlv*5)
player:attlist("转生属性加成",att)
end
function npc:func2(actor, player, p2, p3, str) -- 属性加点
local data = {
{1, "属性", player:getMainAttr()},
{2, "火焰", 101},
{3, "寒冰", 102},
{4, "雷电", 103},
{5, "狂风", 104},
{6, "神圣", 105},
{7, "暗黑", 106},
{8, "幻影", 107},
}
if not data[p2] then return end
if player:getvar(0, "属性点") <= 0 then
return player:send("属性点不足!")
end
local t = json2tbl(player:getvar(1, "元素属性")) or {}
local attname = data[p2][2]
if attname then
t[attname] = (t[attname] or 0) + 1
end
player:setVar(0, "属性点", "-", 1)
player:setVar(1, "元素属性", tbl2json(t))
player:send("属性分配成功!")
end
function npc:func3(actor, player, p2, p3, str) -- 属性重置
if not player:checkmoney("金币", 1000000) then
return player:send("金币不足100万!")
end
player:money("金币", "-", 1000000)
local attr = player.relevel * 10
player:setVar(0, "属性点", attr)
player:setVar(1, "元素属性", "")
player:send("属性点已重置!获得:"..attr)
end
return npc
← 返回问答库