元素大师功能
require("Envir/Market_Def/NpcLua/zh.lua")
-- 升级条件
local shengxingdata = {
[0] = {pos = 0, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=20000, max_point=5},
[1] = {pos = 1, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=20000, max_point=5},
[13] = {pos = 1, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[2] = {pos = 1, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[4] = {pos = 4, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[3] = {pos = 3, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[5] = {pos = 5, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[6] = {pos = 6, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[7] = {pos = 7, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[8] = {pos = 8, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[10] = {pos = 10, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[11] = {pos = 11, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[15] = {pos = 15, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[14] = {pos = 14, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
[12] = {pos = 14, jinbi=5000000, cailiao={"混沌结晶", 3}, yb=10000, max_point=2},
}
-- 可升级装备分类,位置
local keshengxing = {{0, "盔甲"}, {1, "武器"}, {13,"斗笠"}, {4,"头盔"}, {3,"项链"}, {2,"勋章"}, {5,"手镯"},{6,"手镯"},{7,"戒指"},{8,"戒指"},{10,"腰带"},{11,"靴子"}, {15, "指环"}, {14, "印记"}, {12,"宝石"}} --可升星的装备
local attr_name = {
[0] = "重击几率",
[11] = "重击伤害",
[1] = "攻击伤害",
}
-- 物品唯一id, 显示开关
function show(actor, wyid, xianshi)
xianshi = tonumber(xianshi) or 0
-- --获取人物装备列表
local shengxing_t = {}
for i=1,#keshengxing do
local item = linkbodyitem(actor, keshengxing[i][1])
if item ~= "0" then
table.insert(shengxing_t,{item, keshengxing[i][2], keshengxing[i][1]}) ----{item,"头盔", 4}
end
end
-- 第一次点入,默认显示人物身上的第一个装备
if not wyid then
local item = shengxing_t[1][1]
local makeid = getiteminfo(actor,shengxing_t[1][1],1) --唯一id
wyid = makeid
end
wyid = tonumber(wyid)
local msg = [[
<Img|x=0|width=643|height=457|reset=0|bg=1|img=custom/zbsh/1.png|move=1|esc=1|show=4|layerid=9990>
<Button|x=639.5|y=1.5|nimg=public/1900000510.png|pimg=public/1900000511.png|link=@exit>
<Img|x=-23.5|y=-15.5|img=custom/zbsh/2.png|esc=0>
<Img|x=195.5|y=38.5|width=428|height=393|esc=0|img=custom/zbsh/41.png>
<Img|x=18.5|y=40.5|img=custom/zbsh/48.png|esc=0>
<Img|x=17.5|y=79.5|height=352|img=custom/zbsh/42.png|esc=0>
<Img|x=376.5|y=81.5|width=70|height=70|scale9t=30|scale9b=30|img=custom/zbsh/43.png|scale9r=30|scale9l=30|esc=0>
<Img|x=193.5|y=37.5|img=custom/zbsh/128.png|esc=0>
]]
msg=msg..'<Button|x=588.5|y=42.5|nimg=custom/zbsh/8.png|pimg=custom/zbsh/8.png|link=@show,'..wyid..',1>'
msg=msg..'<ListView|children={2000}|x=17.5|y=79.5|width=176|height=352>'
local ziids = ""
for i = 2002,2200 do
ziids = ziids .. i .. ","
end
local ziid = 2002
local ysxx = -2
local ysyy = -6
local gaodu = (math.floor((#shengxing_t-1)/1) + 1) * 66 + 3
msg = msg ..'<Layout|id=2000|children={2001}|height='.. gaodu ..'>' --设置底框宽 高
msg = msg ..'<Layout|id=2001|children={'.. ziids ..'}|height='.. gaodu ..'>' --设置底框宽 高
-- 循环显示人物身上装备
for i = 1, #shengxing_t do
local item = shengxing_t[i][1]
local makeid = getiteminfo(actor,shengxing_t[i][1],1) --唯一id
-- 生成左侧按钮
msg = msg ..'<Img|id='.. ziid ..'|x=1.0|y='.. 3 + (i-1)*66 ..'|img=custom/zbsh/44.png|esc=0|link=@show,'.. makeid ..'>'
ziid = ziid + 1
msg = msg ..'<Img|id='.. ziid ..'|x=1.0|y='.. 3 + (i-1)*66 ..'|img=custom/zbsh/40.png|esc=0>'
ziid = ziid + 1
msg = msg ..'<DBItemShow|id='.. ziid ..'|x=0.0|y='.. 1 + (i-1)*66 ..'|makeindex='..makeid..'|showtips=1|showstar=1>'
ziid = ziid + 1
msg = msg ..'<Text|ay=0.5|id='.. ziid ..'|x=65.0|y='.. 24 + (i-1)*66 ..'|color=255|size=16|text='.. getitemname(actor,shengxing_t[i][1],1) ..'>'
ziid = ziid + 1
msg = msg ..'<Text|ay=0.5|id='.. ziid ..'|x=65.0|y='.. 46 + (i-1)*66 ..'|color=7|size=16|text='..shengxing_t[i][2]..'>'
ziid = ziid + 1
-- 生成右侧升级条件
if wyid == makeid then
msg = msg ..'<Img|id='.. ziid ..'|x=0.0|y='.. 1 + (i-1)*66 ..'|img=custom/zbsh/45.png|esc=0>'
ziid = ziid + 1
msg = msg ..'<DBItemShow|x=380.0|y=84.0|makeindex='..makeid..'|showtips=1|bgtype=0|showstar=1>' --右边展示物品
local showpar = shengxing_t[i][3] --装备位置,通过位置取得升级条件
msg = msg ..'<Text|ax=0.5|ay=0.5|x=410|y=165.5|color=254|size=18|text=成功机率100%,最高'.. shengxingdata[showpar].max_point ..'点>'
msg = msg ..'<Img|x=326.0|y=184|height=130|scale9r=0|scale9t=40|esc=0|img=custom/zbsh/6.png|scale9b=0|scale9l=0>'
msg = msg ..'<Text|ay=0.5|x=365.0|y=199.5|color=250|size=18|text=需要材料>'
msg = msg ..'<RText|ay=0.5|x=345.0|y=233.5|color=116|size=18|simplenum=1|text=金币:<' .. jianhuanum(getbindgold(actor)) .."/FCOLOR=249>/".. jianhuanum(shengxingdata[showpar].jinbi) .. '>'
msg = msg ..'<RText|ay=0.5|x=345.0|y=263.5|color=116|size=18|simplenum=1|text=元宝:<' .. jianhuanum(getingot(actor)) .."/FCOLOR=249>/".. jianhuanum(shengxingdata[showpar].yb) .. '>'
msg = msg .."<Text|x=310|y=285|size=18|color=116|text=".. shengxingdata[showpar].cailiao[1] ..":>"
msg = msg .."<ItemShow|x=375.0|y=260|width=70|height=70|itemid="..getidbyname(shengxingdata[showpar].cailiao[1]).."|itemcount=1|showtips=1|bgtype=0|scale=0.7>"
msg = msg .."<RText|x=427.0|y=285|color=250|size=18|text=<".. itemcount(actor,shengxingdata[showpar].cailiao[1]) .."/FCOLOR=249>/"..shengxingdata[showpar].cailiao[2].."块>"
if showpar == 0 or showpar == 1 then
msg = msg ..'<Button|x=340.0|y=350.0|color=10051|size=18|width=150|height=40|nimg=custom/zbsh/13.png|text=重击机率+1%|link=@shengxing,'.. wyid ..',0,' .. showpar..'>'
else
msg = msg ..'<Button|x=260.0|y=350.0|color=10051|size=18|width=140|height=40|nimg=custom/zbsh/13.png|text=攻击伤害+1%|link=@shengxing,'.. wyid ..',1,' .. showpar..'>'
msg = msg ..'<Button|x=430.0|y=350.0|color=10051|size=18|width=140|height=40|nimg=custom/zbsh/13.png|text=重击伤害+1%|link=@shengxing,'.. wyid ..',11,' .. showpar..'>'
end
end
end
if xianshi == 1 then
msg = msg.. '<Layout|x=-999.0|y=-996.5|width=3000|height=3000|color=255>|link=@show,'..wyid..'>'
msg = msg..[[
<Img|ay=0.5|x=211.5|y=163.5|width=370|height=180|scale9t=10|scale9b=10|img=custom/zbsh/7.png|scale9r=10|esc=0|scale9l=10>
<RText|x=358.5|y=54.5|color=251|size=16|text=装备增伤介绍>
<RText|x=222.5|y=83.5|width=344|color=255|size=16|text=⒈剑甲最高可升至<5%重击几率/FCOLOR=253>>
<RText|x=222.5|y=133.5|width=344|color=255|size=16|text=⒉首饰可以升级攻击伤害或者重击伤害,最高<2%重击伤害/FCOLOR=253>>
<RText|x=222.5|y=183.5|width=344|color=255|size=16|text=⒊升级材料<3个混沌结晶+500万金币+1000元宝(剑甲2000)/FCOLOR=254>>
]]
end
say(actor,msg)
end
-- 装备唯一id, 属性id, 位置
-- 升级伤害属性
function shengxing(actor, wyid, attr_id, pos)
wyid = tonumber(wyid) or 0
attr_id = tonumber(attr_id)
pos = tonumber(pos)
if not pos then
sendmsg9(actor, "装备位置错误")
return
end
if not attr_id then
sendmsg9(actor,"请选择要升级的属性")
return
end
if wyid == 0 then
sendmsg9(actor,"请选择要升级的装备")
return
end
local item = getitembymakeindex(actor, wyid) --物品对象
if item == "0" then
sendmsg9(actor, "你没有这件装备")
return
end
local item_name = getitemname(actor, item)
--sendmsg6(actor,"物品对象"..tostring(item))
if not isinrole(actor, wyid) then
sendmsg9(actor,"物品已经不在身上")
return
end
local tj = shengxingdata[pos]
local cur_point = getnewitemaddvalue(item, attr_id) --获取装备伤害属性
if cur_point >= tj["max_point"] then
sendmsg9(actor,"此装备已经加了" .. cur_point .. "点" .. attr_name[attr_id])
return
end
if getbindgold(actor) < tj.jinbi then
sendmsg9(actor,"金币不足" .. tj.jinbi)
return
end
if getingot(actor) < tj.yb then
sendmsg9(actor,"元宝不足" .. tj.yb)
return
end
if itemcount(actor, tj.cailiao[1]) < tj.cailiao[2] then
sendmsg9(actor,"混沌结晶不足" .. tj.cailiao[2] .. "块")
return
end
if takeitem(actor, tj.cailiao[1], tj.cailiao[2], 0) then
if subbindgold(actor, tj.jinbi) and subingot(actor, tj.yb) then
setnewitemvalue(actor, pos, attr_id, "+", 1, item)
sendmsg9(actor, item_name .. "+1%" .. attr_name[attr_id] .. "属性成功")
sendmsg6(actor, item_name .. "+1%" .. attr_name[attr_id] .. "属性成功")
refreshitem(actor,item)
return show(actor, wyid)
else
sendmsg9(actor,"扣除元宝或者金币失败,无法升级!")
sendmsg6(actor,"扣除元宝或者金币失败,无法升级!")
return
end
else
sendmsg9(actor,"扣除混沌结晶失败,无法升级")
sendmsg6(actor,"扣除混沌结晶失败,无法升级")
return
end
end