require("Envir/Market_Def/zh.lua") --个人封装函数
local necklace_condition = { {20000, 5, 0}, {50000, 10, 50}, {100000, 20, 80} } --升级项链需要材料和机率
local allow_necklace = {"灯笼项链", "白色虎齿项链", "天龙神链", "天龙魔链", "天龙尊链", "铜域项链",
"木域项链", "土域项链", "水域项链", "武神项链", "海魂项链", "无极项链", "蚩尤项链", "炎帝项链", "轩辕项链", "龙皇项链"
}
function UpgradeLucky(actor, point)
local p = tonumber(point) or -1
if p == -1 then
return sendmsg9(actor, "项链升级点数错误!")
end
local item = linkbodyitem(actor, 3)
if item == "0" then
return sendmsg9(actor, "身上没有佩戴需要升级的项链")
end
local neck_name = getitemname(actor, item)
if not isexsit(allow_necklace, neck_name) then
return sendmsg9(actor, "当前身上项链不允许升级幸运!")
end
local lucky = getluck(actor, item)
if lucky > 2 then
return sendmsg9(actor, "此项链已经是最高幸运")
end
if lucky ~= p - 1 then
return sendmsg9(actor, "你升级的项链不是幸运" .. tostring(p-1) )
end
if getgold(actor) < necklace_condition[p][1] then
return sendmsg9(actor, "升级需要" .. necklace_condition[p][1] .. "金币")
end
if itemcount(actor, "幸运神石") < necklace_condition[p][2] then
return sendmsg9(actor, "升级需要" .. necklace_condition[p][2] .. "块幸运神石")
end
if not subgold(actor, necklace_condition[p][1], "幸运项链") then
return sendmsg9(actor,"扣除金币失败")
end
if not takeitemex(actor, "幸运神石", necklace_condition[p][2], 1, "扣除幸运神石") then
return sendmsg9(actor,"扣除幸运神石失败")
end
if math.random(1, 100) < necklace_condition[p][3] then
sendmsg9(actor,"不好意思,项链升级幸运失败")
return
end
setitemaddvalue(actor, item, 1, 5, getitemaddvalue(actor,item,1,5) + 1)
if lucky == 2 then
if getluck(actor, item) == 3 then
local baoji = 0
math.randomseed(os.time())
local randnum = math.random(1, 100)
if randnum < 30 then
baoji = 1
elseif randnum < 50 then
baoji = 2
elseif randnum < 70 then
baoji = 3
elseif randnum < 90 then
baoji = 4
else
baoji = 5
end
setitemaddvalue(actor, item, 1, 30, baoji)
refreshitem(actor, item)
return sendmsg9(actor,"恭喜你升级幸运成功,项链幸运+"..lucky+1 .. "重击+" .. baoji, "#00FF00")
end
end
refreshitem(actor, item)
return sendmsg9(actor,"恭喜你升级幸运成功,项链幸运+"..lucky+1,"#00FF00")
end