require("Envir/Market_Def/NpcLua/zh.lua") --个人封装函数
local yj_cond_t = {
{{"金币", 500000}, {"混沌结晶", 0}, {"经验", 100}, {"完美度", 1000}, {"武魂印记Lv.2", "法圣印记Lv.2", "道尊印记Lv.2"}},
{{"金币", 1000000}, {"混沌结晶", 0}, {"经验", 100}, {"完美度", 1000}, {"武魂印记Lv.3", "法圣印记Lv.3", "道尊印记Lv.3"}},
{{"金币", 1500000}, {"混沌结晶", 5}, {"经验", 100}, {"完美度", 1000}, {"武魂印记Lv.4", "法圣印记Lv.4", "道尊印记Lv.4"}},
{{"金币", 3000000}, {"混沌结晶", 10}, {"经验", 100}, {"完美度", 1000}, {"武魂印记Lv.5", "法圣印记Lv.5", "道尊印记Lv.5"}},
{{"金币", 5000000}, {"混沌结晶", 20}, {"经验", 100}, {"完美度", 1000}, {"武魂印记Max", "法圣印记Max", "道尊印记Max"}},
}
function add_yj_exp(actor)
local item = linkbodyitem(actor, 14)
if item == "0" then
sendmsg9(actor,"你没有佩戴印记,无法升级")
return false
end
local yj_lv = getitem_yj_lv(actor, item) --当前等级
local yj_exp =getitem_yj_exp(actor, item)
local item_name = getitemname(actor, item)
local job = getjob(actor)
if yj_lv > 4 or string.find(item_name, "Max") then
sendmsg9(actor, "你的" .. item_name .. "已经满级了,无法升级")
return false
end
local number = tonumber(string.match(item_name, "%d+")) --取得印记名字中的数字
if number and number ~= yj_lv + 1 then --手动刷印记情况,没有lv值,通过名字来判断加上lv
yj_lv = number - 1
end
local sj_cond = yj_cond_t[yj_lv + 1]
-- sendmsg6(actor, "yj_lv=" .. yj_lv)
-- sendmsg6(actor, "yj_exp=" .. yj_exp)
-- sendmsg6(actor, "job=" .. job)
if getbindgold(actor) < sj_cond[1][2] then
sendmsg9(actor, "你没有" .. sj_cond[1][2] .. "金币无法升级")
return false
end
if sj_cond[2][2] ~= 0 and itemcount(actor, "混沌结晶") < sj_cond[2][2] then
sendmsg9(actor,"你没有" .. sj_cond[2][2] .. "块混沌结晶无法升级")
return false
end
if not subbindgold(actor, sj_cond[1][2]) then
sendmsg9(actor,"扣除" .. sj_cond[1][2] .. "金币失败,无法升级")
return false
end
if sj_cond[2][2] ~= 0 and not takeitemex(actor, sj_cond[2][1], sj_cond[2][2], "印记混沌结晶") then
sendmsg9(actor,"扣除" .. sj_cond[2][1] .. sj_cond[2][2] .. "失败,无法升级")
return false
end
local yj_cur_exp = yj_exp + sj_cond[3][2] --升级后的经验
local new_yj_cur_exp = 0 --真实加的经验
local new_yj_cur_lv = yj_lv --升级后的等级
if yj_cur_exp < sj_cond[4][2] then
new_yj_cur_exp = yj_cur_exp
setitem_yj_lv(actor, item, new_yj_cur_lv)
setitem_yj_exp(actor, item, new_yj_cur_exp)
update_progress_bar(actor, item, sj_cond[4][1], new_yj_cur_exp, sj_cond[4][2], new_yj_cur_lv)
else --下一级执行
new_yj_cur_exp = yj_cur_exp - sj_cond[4][2]
new_yj_cur_lv = yj_lv + 1
if delbodyitem(actor, 14) then --删除下级印记
-- sendmsg6(actor, "sj_cond[5][job+1]=" .. sj_cond[5][job+1])
if giveonitem(actor, 14, sj_cond[5][job+1], 1, 311) then --给下级印记
item = linkbodyitem(actor, 14)
item_name = getitemname(actor, item)
if not string.find(item_name, "Max") then --非满级
setitem_yj_lv(actor, item, new_yj_cur_lv)
setitem_yj_exp(actor, item, new_yj_cur_exp)
update_progress_bar(actor, item, sj_cond[4][1], new_yj_cur_exp, sj_cond[4][2], new_yj_cur_lv)
return true
else
setitem_yj_lv(actor, item, new_yj_cur_lv)
setitem_yj_exp(actor, item, new_yj_cur_exp)
sendmsg6(actor, "恭喜," .. item_name .. "已升到满级!")
return true
end
else
sendmsg6(actor, "升级给下级印记失败,联系客服反馈")
return false
end
else
sendmsg6(actor,"扣除" .. item_name .. "装备失败,无法升级")
return false
end
end
end
function update_progress_bar(actor, item, yj_lv_name, cur_exp, max_exp, yj_lev)
local t = {
open=1,
show=2,
name=yj_lv_name,
color=254,
imgcount=1,
cur=cur_exp,
max=max_exp,
level=yj_lev
}
setcustomitemprogressbar(actor, item, 0, tbl2json(t))
sendmsg9(actor, "升级成功")
refreshitem(actor, item)
end