212 lines
5.2 KiB
Lua
212 lines
5.2 KiB
Lua
ZhuangBeiLianHuaOBJ = Up_BaseClass:new()
|
|
|
|
|
|
ZhuangBeiLianHuaOBJ._name = "ZhuangBeiLianHuaOBJ"
|
|
|
|
-- NPCID
|
|
ZhuangBeiLianHuaOBJ.id = { 7 }
|
|
|
|
for i, v in ipairs(ZhuangBeiLianHuaOBJ.id or {}) do
|
|
Npc.clicknpcCfg[v] = ZhuangBeiLianHuaOBJ
|
|
end
|
|
|
|
-- 配置文件
|
|
ZhuangBeiLianHuaOBJ.cfg = {
|
|
xh = {
|
|
{ "炼化石", 5, 0 },
|
|
{ "金币", 20000, 1 },
|
|
{ "灵符", 1, 0 },
|
|
},
|
|
}
|
|
|
|
---* 加入上线同步数据
|
|
Player.sycCfg[ZhuangBeiLianHuaOBJ._name] = ZhuangBeiLianHuaOBJ.cfg
|
|
|
|
|
|
ZhuangBeiLianHuaOBJ.att = Func.require("cfg_装备炼化属性表")
|
|
|
|
local function ZhuangBeiLianHuaOBJ_for()
|
|
local tbl = {}
|
|
for i, v in ipairs(ZhuangBeiLianHuaOBJ.att or {}) do
|
|
table.insert(tbl, string.format("%d#%d", i, v.qz))
|
|
end
|
|
return tbl
|
|
end
|
|
|
|
ZhuangBeiLianHuaOBJ.attStr = ZhuangBeiLianHuaOBJ_for()
|
|
|
|
|
|
ZhuangBeiLianHuaOBJ.attNum_str = {
|
|
[0] = "1#90|2#9|3#1",
|
|
[1] = "1#100|2#10",
|
|
[2] = "1#100",
|
|
}
|
|
|
|
ZhuangBeiLianHuaOBJ.onwhere = {
|
|
[0] = true,
|
|
[1] = true,
|
|
[2] = true,
|
|
[3] = true,
|
|
[4] = true,
|
|
[5] = true,
|
|
[6] = true,
|
|
[7] = true,
|
|
[8] = true,
|
|
[10] = true,
|
|
[11] = true,
|
|
[14] = true,
|
|
}
|
|
|
|
-- 基类_主窗体
|
|
function ZhuangBeiLianHuaOBJ:main(actor, ...)
|
|
if getbaseinfo(actor, ConstCfg.gbase.renew_level) < 6 then
|
|
Func.sendmsg9(actor, "[装备炼化]:#70|人物6转后开放!")
|
|
return
|
|
end
|
|
|
|
local info = { ... }
|
|
local data = {}
|
|
data.cfg = self.cfg
|
|
Message:SubLink(actor, self._name .. "_main", data)
|
|
end
|
|
|
|
|
|
function ZhuangBeiLianHuaOBJ:up(actor, p1, p2, p3, data)
|
|
if not data or not data[1].w then
|
|
return
|
|
end
|
|
|
|
local where = data[1].w
|
|
local itemmakeid = GetItemByPos(actor, where)
|
|
if itemmakeid == "0" then
|
|
Func.sendmsg9(actor, string.format("[装备炼化]:#70|:请先穿戴好[%s]!", ConstCfg.common_equip_posName[where]))
|
|
return
|
|
end
|
|
|
|
if not self:checkwhere(actor, itemmakeid) then
|
|
Func.sendmsg9(actor, "此装备不可炼化!")
|
|
return
|
|
end
|
|
|
|
|
|
|
|
local _lock = 0
|
|
for i, v in ipairs(data[1].lock or {}) do
|
|
if v then
|
|
_lock = _lock + 1
|
|
end
|
|
end
|
|
|
|
if _lock > 2 then
|
|
Func.sendmsg9(actor, "[装备炼化]:#70|:请至少保留一条炼化属性!")
|
|
return
|
|
end
|
|
|
|
local xh = table.Copy(self.cfg.xh)
|
|
if _lock > 0 then
|
|
table.insert(xh, { "元宝", _lock * 50, 1 })
|
|
end
|
|
|
|
if Func.takeitmes(actor, xh, true, true) then
|
|
setflagstatus(actor, VarCfg.Falg_fangshua, 1)
|
|
self:start_lianhua(actor, itemmakeid, data[1].lock, _lock)
|
|
end
|
|
end
|
|
|
|
----* 开始炼化
|
|
function ZhuangBeiLianHuaOBJ:start_lianhua(actor, itemmakeid, lockTbl, _lock)
|
|
--* 防刷标识
|
|
if getflagstatus(actor, VarCfg.Falg_fangshua) == 0 then
|
|
return
|
|
end
|
|
|
|
if not itemmakeid then
|
|
return
|
|
end
|
|
|
|
if not lockTbl then
|
|
lockTbl = { false, false, false }
|
|
end
|
|
_lock = _lock or 0
|
|
|
|
|
|
local result1, result2 = ransjstr(self.attNum_str[_lock], 1, 3)
|
|
local attNum = tonumber(result1)
|
|
|
|
local value_w = {}
|
|
for att_w, lock in ipairs(lockTbl) do
|
|
if not lock then
|
|
table.insert(value_w, att_w)
|
|
delitemattr(actor, itemmakeid, att_w, 0)
|
|
end
|
|
end
|
|
|
|
for i = 1, attNum, 1 do
|
|
local random_attId, Over_attId = ransjstr(table.concat(self.attStr, "|"), 1, 3)
|
|
local RandomAttId = tonumber(random_attId)
|
|
local cfg = self.att[RandomAttId]
|
|
if cfg then
|
|
local value = 0
|
|
if type(cfg.value) == "table" then
|
|
value = math.random(cfg.value[1], cfg.value[2])
|
|
else
|
|
value = cfg.value
|
|
end
|
|
|
|
local setattTab = {}
|
|
if type(cfg.id) == "table" then
|
|
for _, setId in ipairs(cfg.id) do
|
|
setattTab[setId] = self:getattValue(actor, setId, value)
|
|
end
|
|
else
|
|
setattTab[cfg.id] = self:getattValue(actor, cfg.id, value)
|
|
end
|
|
delitemattr(actor, itemmakeid, value_w[i], 0)
|
|
additemattrEX(actor, itemmakeid, value_w[i], 3, setattTab)
|
|
end
|
|
end
|
|
--* 防刷标识
|
|
setflagstatus(actor, VarCfg.Falg_fangshua, 0)
|
|
end
|
|
|
|
---* 检测物品分类是否可炼化
|
|
function ZhuangBeiLianHuaOBJ:checkwhere(actor, itemmakeid)
|
|
if not itemmakeid then
|
|
return false
|
|
end
|
|
local _name = getiteminfo(actor, itemmakeid, ConstCfg.iteminfo.name)
|
|
local _stdmode = getstditeminfo(_name, ConstCfg.stditeminfo.stdmode)
|
|
local where = getposbystdmode(_stdmode)
|
|
-- 武器1 衣服0 项链3 头4 腰带10 靴子11 手5/6 戒指7/8 勋章2 军鼓14
|
|
return self.onwhere[where]
|
|
end
|
|
|
|
|
|
---* 进背包触发 炼化一次
|
|
local function ZhuangBeiLianHuaOBJ_lianhua(actor, itemMakeIndex, itemIndex)
|
|
local lianhua = Item.getint(itemMakeIndex, VarCfg.item.int["拾取炼化"])
|
|
|
|
if lianhua > 0 then
|
|
return
|
|
end
|
|
|
|
if Func.random(1) then
|
|
if not ZhuangBeiLianHuaOBJ:checkwhere(actor, itemMakeIndex) then
|
|
return
|
|
end
|
|
|
|
setflagstatus(actor, VarCfg.Falg_fangshua, 1)
|
|
ZhuangBeiLianHuaOBJ:start_lianhua(actor, itemMakeIndex)
|
|
Item.setint(actor, itemMakeIndex, VarCfg.item.int["拾取炼化"], 1)
|
|
end
|
|
end
|
|
GameEvent.add(EventCfg.onAddBag, ZhuangBeiLianHuaOBJ_lianhua, ZhuangBeiLianHuaOBJ)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZhuangBeiLianHuaOBJ.allowFunc = {"up"}
|
|
return ZhuangBeiLianHuaOBJ
|