require("Envir/Market_Def/NpcLua/zh.lua")
local zsdata = {
[1] = {lv = 40, yb = 8000, title = "一重转生", items = {["七彩结晶"] = 10, ["魔魂内丹"] = 5}, attr = "攻击力倍数1.02", powerrate = "2"},
[2] = {lv = 42, yb = 12000, title = "二重转生", items = {["七彩结晶"] = 20, ["魔魂内丹"] = 10}, attr = "攻击力倍数1.04", powerrate = "4"},
[3] = {lv = 45, yb = 16000, title = "三重转生", items = {["七彩结晶"] = 30, ["魔魂内丹"] = 15}, attr = "攻击力倍数1.06", powerrate = "6"},
[4] = {lv = 48, yb = 20000, title = "四重转生", items = {["七彩结晶"] = 40, ["魔魂内丹"] = 20}, attr = "攻击力倍数1.08", powerrate = "8"},
[5] = {lv = 52, yb = 24000, title = "五重转生", items = {["七彩结晶"] = 50, ["魔魂内丹"] = 25}, attr = "攻击力倍数1.10", powerrate = "10"},
[6] = {lv = 56, yb = 32000, title = "六重转生", items = {["七彩结晶"] = 60, ["魔魂内丹"] = 30}, attr = "生攻击力倍数1.12", powerrate = "12"},
[7] = {lv = 60, yb = 40000, title = "七重转生", items = {["七彩结晶"] = 80, ["魔魂内丹"] = 40}, attr = "攻击力倍数1.14", powerrate = "15"},
[8] = {lv = 62, yb = 60000, title = "八重转生", items = {["七彩结晶"] = 100, ["魔魂内丹"] = 50}, attr = "攻击力倍数1.16", powerrate = "20"},
--[9] = {lv = 66, yb = 80000, title = "九重转生", items = {["七彩结晶"] = 90, ["魔魂内丹"] = 18}, attr = "攻击力倍数1.18", powerrate = "18"},
--[10] = {lv = 70, yb = 100000, title = "十重转生", items = {["七彩结晶"] = 100, ["魔魂内丹"] = 20}, attr = "攻击力倍数1.20", powerrate = "20"}
}
-- 检查是否满足转生条件
local function check_requirements(actor, req)
local checks = {
level = function() return getlevel(actor) >= req.lv end,
yb = function() return getyb(actor) >= req.yb end,
items = function()
for itemName, count in pairs(req.items) do
if itemcount(actor, itemName) < count then
return false, itemName, count
end
end
return true
end
}
-- Check each requirement and send appropriate message if failed
for key, check in pairs(checks) do
local success, itemName, itemCount = check()
if not success then
if key == 'items' then
sendmsg9(actor, string.format("<font color='#f0b42a'>系统提示:</font><font color='#ff0000'>需要%s%d个</font>", itemName, itemCount))
else
sendmsg9(actor, string.format("<font color='#f0b42a'>系统提示:</font><font color='#ff0000'>%s不足%d</font>", key == 'yb' and "元宝" or "等级", key == 'yb' and req.yb or req.lv))
end
return false
end
end
return true
end
function zhuanzheng(actor)
local zslv = getbaseinfo(actor, 39) -- 获取当前转生等级
if zslv >= #zsdata then
sendmsg9(actor, "你已达到最高转生级别,无法继续转生了!", "#ff0000")
return
end
local next_zs = zsdata[zslv + 1]
if not next_zs then
sendmsg9(actor, "系统故障,请联系管理员!", "#ff0000")
return false
end
-- 检查是否满足转生条件
if not check_requirements(actor, next_zs) then
return false
end
-- 扣除元宝和物品
if not (subyb(actor, next_zs.yb, "NPC转生服务消耗元宝") and
takeitemex(actor, "七彩结晶", next_zs.items["七彩结晶"], 0, "转生七彩结晶") and
takeitemex(actor, "魔魂内丹", next_zs.items["魔魂内丹"], 0, "转生魔魂内丹")) then
sendmsg9(actor, "扣除材料失败,无法转生!", "#ff0000")
return false
end
-- 更新角色信息
if zslv > 0 then deprivetitle(actor, zsdata[zslv].title) end
-- local n = getsysvar("A81") == getname(actor) and 110 or 100 -- 天下第一加的倍攻
-- n = n + next_zs.powerrate
-- sendmsg6(actor, string.format("当前攻击力倍数:%.2f", n/100 ) )
-- powerrate(actor, n, 84600)
setbaseinfo(actor, 39, zslv + 1)
confertitle(actor, next_zs.title)
callscript(actor, '../QuestDiary/游戏登陆/封号刷新', '@封号分类')
-- 发送成功消息
sendmsg9(actor, "恭喜你已转生成功!", "#00ff00")
sendmsg0(actor, string.format("恭喜【%s】进行了%d次转生,获得:%s", getname(actor), zslv + 1, next_zs.attr), 251, 249)
return true
end