151 lines
3.7 KiB
Lua
151 lines
3.7 KiB
Lua
JiuMiZhuOBJ = Up_BaseClass:new()
|
|
|
|
|
|
JiuMiZhuOBJ._name = "JiuMiZhuOBJ"
|
|
-- NPCID
|
|
|
|
JiuMiZhuOBJ.id = { 190 }
|
|
|
|
for i, v in ipairs(JiuMiZhuOBJ.id or {}) do
|
|
Npc.clicknpcCfg[v] = JiuMiZhuOBJ
|
|
end
|
|
|
|
-- 配置文件
|
|
JiuMiZhuOBJ.cfg = {
|
|
synthesis = {
|
|
check = {
|
|
{ "临字珠", 1, 0 },
|
|
{ "兵字珠", 1, 0 },
|
|
{ "者字珠", 1, 0 },
|
|
{ "阵字珠", 1, 0 },
|
|
{ "斗字珠", 1, 0 },
|
|
{ "皆字珠", 1, 0 },
|
|
{ "行字珠", 1, 0 },
|
|
{ "前字珠", 1, 0 },
|
|
{ "组字珠", 1, 0 },
|
|
},
|
|
give = "九秘珠",
|
|
gem = 5000,
|
|
},
|
|
attributeSet = {
|
|
{ name = "临字珠", Attribute = "3#13#5" },
|
|
{ name = "兵字珠", Attribute = "3#82#300" },
|
|
{ name = "者字珠", Attribute = "3#83#500" },
|
|
{ name = "阵字珠", Attribute = "3#36#500" },
|
|
{ name = "斗字珠", Attribute = "3#73#300" },
|
|
{ name = "皆字珠", Attribute = "3#75#500" },
|
|
{ name = "行字珠", Attribute = "3#214#3" },
|
|
{ name = "前字珠", Attribute = "3#60#500" },
|
|
{ name = "组字珠", Attribute = "3#219#5" },
|
|
},
|
|
reset = {
|
|
{ "千年玄石", 2000, 0 },
|
|
},
|
|
}
|
|
|
|
|
|
|
|
|
|
---* 加入上线同步数据
|
|
Player.sycCfg[JiuMiZhuOBJ._name] = JiuMiZhuOBJ.cfg
|
|
|
|
|
|
JiuMiZhuOBJ.CaChe = {}
|
|
|
|
---* 允许前端调用的函数
|
|
JiuMiZhuOBJ.allowFunc = { "main", "hecheng", "reset" }
|
|
|
|
|
|
function JiuMiZhuOBJ:hecheng(actor, p1, p2, p3, data)
|
|
if not Npc.CheckNPCRange(actor, 190) then
|
|
return
|
|
end
|
|
|
|
|
|
|
|
local cfg = self.cfg.synthesis
|
|
|
|
|
|
local xh = table.Copy(cfg.check)
|
|
table.insert(xh, { "千年玄石", cfg.gem, 0 })
|
|
|
|
if Func.batchcheckitem(actor, xh, true, true) then
|
|
local itemobj = giveitem(actor, cfg.give, 1)
|
|
Func.sendmsg9(actor, "[九秘珠]:#70|恭喜您合成成功!#250")
|
|
JiuMiZhuOBJ:settingAttr(actor, itemobj)
|
|
end
|
|
end
|
|
|
|
function JiuMiZhuOBJ:settingAttr(actor, itemobj)
|
|
if not itemobj then
|
|
return
|
|
end
|
|
|
|
|
|
delitemattr(actor, itemobj, 6, 0)
|
|
|
|
local attr = self.cfg.attributeSet or {}
|
|
if #attr <= 0 then
|
|
return
|
|
end
|
|
|
|
local randomStr = {}
|
|
for i, v in ipairs(attr or {}) do
|
|
table.insert(randomStr, string.format("%d#1", i))
|
|
end
|
|
|
|
local function addAttribute(get_att, Attribute)
|
|
if type(Attribute) ~= "string" then
|
|
return
|
|
end
|
|
for attrGroup, attrId, value in string.gmatch(Attribute, "(%d+)#(%d+)#(%d+)") do
|
|
attrId = tonumber(attrId)
|
|
value = tonumber(value)
|
|
if attrId and value and value > 0 then
|
|
get_att[attrId] = (get_att[attrId] or 0) + value
|
|
end
|
|
end
|
|
end
|
|
|
|
local remaining = nil
|
|
local get_att = {}
|
|
local count = math.min(5, #attr)
|
|
for i = 1, count, 1 do
|
|
local result1, result2 = ransjstr(remaining and remaining or table.concat(randomStr, "|"), 1, 3)
|
|
remaining = result2
|
|
local cfg = attr[tonumber(result1)]
|
|
if cfg then
|
|
LOGDump(cfg.Attribute)
|
|
addAttribute(get_att, cfg.Attribute)
|
|
end
|
|
end
|
|
additemattrEX(actor, itemobj, 6, 3, get_att)
|
|
end
|
|
|
|
function JiuMiZhuOBJ:reset(actor)
|
|
if not Npc.CheckNPCRange(actor, 190) then
|
|
return
|
|
end
|
|
|
|
local itemobj = GetItemByPos(actor, 12)
|
|
|
|
if itemobj == "0" then
|
|
Func.sendmsg9(actor, "[九秘珠]:#70|请将九秘珠穿戴至角色身上!#250")
|
|
return
|
|
end
|
|
|
|
local itemName = getiteminfo(actor, itemobj, 7)
|
|
if itemName ~= "九秘珠" then
|
|
Func.sendmsg9(actor, "[九秘珠]:#70|请将九秘珠穿戴至角色身上!#250")
|
|
return
|
|
end
|
|
|
|
|
|
if Func.batchcheckitem(actor, self.cfg.reset, true, true) then
|
|
JiuMiZhuOBJ:settingAttr(actor, itemobj)
|
|
Func.sendmsg9(actor, "[九秘珠]:#70|恭喜您重置成功!#250")
|
|
end
|
|
-- body
|
|
end
|
|
|
|
return JiuMiZhuOBJ
|