ItemSynthesis.lua 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. ItemSynthesis = {}
  2. local this = {}
  3. SYS_ITEM_SYNTHESIS_FAIL_COUNT = "T$item_synthesis_fail_count"
  4. local SYNTHESIS_CFG_TYPE = {
  5. normal = 1,
  6. special = 2
  7. }
  8. function testsynthesis(actor)
  9. local msgData = {30001}
  10. ItemSynthesis.synthesis(actor, msgData)
  11. end
  12. function ItemSynthesis.string2table(str)
  13. local result = {}
  14. local pairs = string.split(str, "|")
  15. for _, pairStr in ipairs(pairs) do
  16. local values = string.split(pairStr, "#")
  17. table.insert(result, values)
  18. end
  19. return result
  20. end
  21. -- 道具合成
  22. function ItemSynthesis.synthesis(actor, msgData)
  23. -- local info = APIGetTable(actor, SYS_TRANSACTIONS) or {}
  24. -- 合成ID 合成数量 合成消耗
  25. local synthesisCfgId = msgData.cfgid -- 合成ID
  26. local count = msgData.count -- 合成数量
  27. local tCost = msgData.costs[1] -- 必要合成消耗
  28. local tCostEx = msgData.costs[2] -- 附加合成消耗
  29. local useluck = msgData.useluck
  30. local useprotect = msgData.useprotect
  31. -- local info = APIGetTable(actor, SYS_TRANSACTIONS) or {}
  32. local cfg_synthesis = ConfigDataManager.getTable("cfg_synthesis", "id", synthesisCfgId)[1]
  33. -- 检测合成配方所需等级
  34. local needLevel = tonumber(cfg_synthesis.level) or 0
  35. local currentLevel = getbaseinfo(actor, "level")
  36. -- info(cfg_synthesis,"cfg_synthesis","合成数据")
  37. if tonumber(needLevel) > tonumber(currentLevel) then
  38. noticeTip.noticeinfo(actor, StringIdConst.TEXT353)
  39. return
  40. end
  41. -- 检测合成配方所需职业
  42. -- 检测合成消耗
  43. local tCostItem1 = {} -- 装备消耗
  44. local tCostItem2 = {} -- 材料
  45. local consumeItem = cfg_synthesis.consumeitem1
  46. info(consumeItem, "consumeItem", "合成数据")
  47. local consumeitem2 = cfg_synthesis.consumeitem2
  48. local tConsumeItem = ItemSynthesis.string2table(consumeItem)
  49. local tConsumeItem2 = ItemSynthesis.string2table(consumeitem2)
  50. info(tConsumeItem, "tConsumeItem", "合成数据")
  51. -- 检测必选消耗
  52. -- if not tConsumeItem or next(tConsumeItem) then
  53. -- messagebox(actor,"尚未放入必选材料001!")
  54. -- return
  55. -- end
  56. local addRate = 0
  57. local luckRate = 0
  58. local isCostLuck = false
  59. if useluck and not string.isNullOrEmpty(cfg_synthesis.useluck) then
  60. local cfgId = tonumber(cfg_synthesis.useluck)
  61. local allitems = getallbagiteminfo(actor)
  62. local kk, vv =
  63. table.findByCondi(
  64. allitems,
  65. function(a)
  66. return a.cfgid == cfgId
  67. end
  68. )
  69. if kk ~= nil then
  70. isCostLuck = true
  71. luckRate = luckRate + EquipFunc.getEquipSynValue(actor, vv.id) / 20000
  72. end
  73. end
  74. local isCostProtect = false
  75. if useprotect and not string.isNullOrEmpty(cfg_synthesis.useprotect) then
  76. local cfgId = tonumber(cfg_synthesis.useprotect)
  77. local allitems = getallbagiteminfo(actor)
  78. local kk, vv =
  79. table.findByCondi(
  80. allitems,
  81. function(a)
  82. return a.cfgid == cfgId
  83. end
  84. )
  85. if kk ~= nil then
  86. isCostProtect = true
  87. end
  88. end
  89. local costIndex = 1
  90. for index, v in pairs(tConsumeItem) do
  91. local costType = tonumber(v[1])
  92. if costType == 1 then
  93. local cfgId = tonumber(v[2])
  94. local count = tonumber(v[3])
  95. local num = getbagitemcountbyid(actor, cfgId) or 0
  96. local itemName = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1].name
  97. if num < count then
  98. messagebox(actor, itemName .. "数量不足" .. count .. "个!")
  99. return
  100. end
  101. -- table.insert(tCostItem2,{costType = costType, [cfgId]=count,})
  102. tCostItem2[cfgId] = count
  103. elseif costType == 2 then
  104. -- 检查是否有对应的装备材料放入
  105. local foundItem = nil
  106. if tCost then
  107. for i, v in ipairs(tCost) do
  108. if v and v.id and i == costIndex then
  109. foundItem = v
  110. break
  111. end
  112. end
  113. costIndex = costIndex + 1
  114. end
  115. if not foundItem then
  116. messagebox(actor, "尚未放入必选材料!")
  117. return
  118. end
  119. local itemId = foundItem.id
  120. local cfgId = foundItem.cfgId
  121. -- local item = getequipinfo(actor, itemId, 1)
  122. local itemInfo = getbagiteminfo(actor, itemId, 1)
  123. local bagIndex = itemInfo.bagindex
  124. local strenthLv = tonumber(v[2])
  125. local appendLevel = tonumber(v[3])
  126. local pz = tonumber(v[4])
  127. local itemType = tonumber(v[5])
  128. local itemCfgId = v[6] or 0
  129. -- info("itemCfgId",itemCfgId,type(itemCfgId))
  130. if itemCfgId and itemCfgId ~= 0 and itemCfgId ~= "0" then
  131. local tab = string.split(itemCfgId, "_")
  132. local idx = false
  133. -- info("tab",tab)
  134. for i = 1, #tab do
  135. if tonumber(tab[i]) ~= 0 then
  136. if cfgId == tonumber(tab[i]) then
  137. idx = true
  138. end
  139. end
  140. end
  141. if not idx then
  142. messagebox(actor, "尚未放入必选材料")
  143. return ""
  144. end
  145. end
  146. if strenthLv > 0 then
  147. if EquipFunc.getEquipStrengthLevel(actor, itemId) < strenthLv then
  148. messagebox(actor, "强化等级不符")
  149. return ""
  150. end
  151. end
  152. if appendLevel > 0 then
  153. if EquipFunc.getEquipAppendLevel(actor, itemId) < appendLevel then
  154. messagebox(actor, "追加等级不符")
  155. return ""
  156. end
  157. end
  158. if pz > 0 then
  159. if pz ~= 99 then
  160. local Outstanding = ConfigDataManager.getTableValue("cfg_item", "Outstanding", "id", cfgId)
  161. Outstanding = tonumber(Outstanding) or 0
  162. if pz ~= Outstanding then
  163. messagebox(actor, "品质不符")
  164. return ""
  165. end
  166. end
  167. end
  168. if itemType == 1 then
  169. if not EquipFunc.getEquipIsSpecial(cfgId) then
  170. messagebox(actor, "装备类型不符")
  171. return ""
  172. end
  173. -- local useLevelLimit = ConfigDataManager.getTableValue("cfg_item", "useLevelLimit", "id", cfgId)
  174. -- useLevelLimit = tonumber(useLevelLimit)
  175. -- if useLevelLimit < 380 then
  176. -- messagebox(actor,"装备类型不符")
  177. -- return ""
  178. -- end
  179. end
  180. -- info(bagIndex,"bagIndex","合成数据")
  181. table.insert(
  182. tCostItem1,
  183. {
  184. costType = costType,
  185. bagIndex = bagIndex,
  186. cfgid = cfgId,
  187. isMain = costIndex == 2,
  188. cantDestroy = isCostProtect == true and costIndex == 2 -- 因为上面自增了.所以这里是2
  189. }
  190. )
  191. elseif costType == 3 then
  192. -- local cfgId = index
  193. -- if not tCost[cfgId] then
  194. -- messagebox(actor,"道具ID不符")
  195. -- return ""
  196. -- end
  197. -- tCostItem2[cfgId] = 1
  198. -- table.insert(tCostItem2,{costType = costType, [cfgId]=1,})
  199. local cfgId = index
  200. if tCost[cfgId] then
  201. if tCostItem2[cfgId] == nil then
  202. tCostItem2[cfgId] = 1
  203. else
  204. tCostItem2[cfgId] = tCostItem2[cfgId] + 1
  205. end
  206. end
  207. elseif costType == 4 then
  208. -- 检查是否有对应的装备材料放入
  209. local foundItem = nil
  210. if tCost then
  211. for _, costData in pairs(tCost) do
  212. if costData and costData.id then
  213. foundItem = costData
  214. break
  215. end
  216. end
  217. end
  218. if not foundItem then
  219. messagebox(actor, "尚未放入必选材料!")
  220. return
  221. end
  222. local itemId = foundItem.id
  223. local cfgId = foundItem.cfgId
  224. local itemCfg = ConfigDataManager.getById("cfg_item", cfgId)
  225. local itemInfo = getbagiteminfo(actor, itemId, 1)
  226. local bagIndex = itemInfo.bagindex
  227. local entrys = itemInfo.entries
  228. local count = table.count(v)
  229. local needEnyrys = {}
  230. for i = 3, count, 2 do
  231. table.insert(
  232. needEnyrys,
  233. {
  234. type = tonumber(v[i]),
  235. value = tonumber(v[i + 1])
  236. }
  237. )
  238. end
  239. local matchNum = 0
  240. local needNum = table.count(needEnyrys)
  241. for k, v in pairs(needEnyrys) do
  242. local tk, tv =
  243. table.findByCondi(
  244. entrys,
  245. function(a)
  246. return a.attrid == v.type and a.value == v.value
  247. end
  248. )
  249. if tk ~= nil then
  250. matchNum = matchNum + 1
  251. end
  252. end
  253. if matchNum < needNum then
  254. messagebox(actor, "材料不符!")
  255. return
  256. end
  257. table.insert(
  258. tCostItem1,
  259. {
  260. costType = costType,
  261. bagIndex = bagIndex,
  262. cfgid = itemInfo.cfgid,
  263. cantDestroy = itemCfg ~= nil and itemCfg.outstanding == "4"
  264. }
  265. )
  266. end
  267. end
  268. -- 额外材料附加概率
  269. -- 真实合成概率
  270. local successRateReal = ConfigDataManager.getTableValue("cfg_synthesis", "successRateReal", "id", synthesisCfgId)
  271. successRateReal = tonumber(successRateReal) / 100
  272. -- 最大合成概率
  273. local successRateMax = ConfigDataManager.getTableValue("cfg_synthesis", "successRateMax", "id", synthesisCfgId)
  274. successRateMax = tonumber(successRateMax) / 100
  275. info(tConsumeItem2, "tConsumeItem2", "合成数据")
  276. local costItemIds = {}
  277. for index, v in pairs(tConsumeItem2) do
  278. costItemIds[tonumber(v[2])] = v
  279. end
  280. if tCost and next(tCost) then
  281. for key, value in pairs(tCost) do
  282. local itemId = value.id
  283. local cfgId = value.cfgId
  284. -- local itemInfo = getbagiteminfo(actor, itemId, 1)
  285. local jiazhi = EquipFunc.getEquipSynValue(actor, itemId)
  286. addRate = addRate + math.floor(jiazhi / 20000)
  287. local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  288. if name == "合成幸运符" then
  289. luckRate = luckRate + EquipFunc.getEquipSynValue(actor, itemId) / 20000
  290. end
  291. end
  292. end
  293. if tConsumeItem2 and next(tConsumeItem2) then
  294. if tCostEx and next(tCostEx) then
  295. for key, value in pairs(tCostEx) do
  296. local costItemIdData = costItemIds[value.cfgId]
  297. if costItemIdData ~= nil then
  298. local costType = tonumber(costItemIdData[1])
  299. local itemId = value.id
  300. local cfgId = value.cfgId
  301. local itemInfo = getbagiteminfo(actor, itemId, 1)
  302. local jiazhi = EquipFunc.getEquipSynValue(actor, itemId)
  303. addRate = addRate + math.floor(jiazhi / 20000)
  304. -- local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  305. -- if name == "合成幸运符" then
  306. -- luckRate = luckRate + EquipFunc.getEquipSynValue(actor, itemId) / 20000
  307. -- end
  308. if costType == 2 then
  309. local bagIndex = itemInfo.bagindex
  310. table.insert(
  311. tCostItem1,
  312. {
  313. costType = costType,
  314. bagIndex = bagIndex
  315. }
  316. )
  317. elseif costType == 3 then
  318. if tCostItem2[cfgId] == nil then
  319. tCostItem2[cfgId] = 1
  320. else
  321. tCostItem2[cfgId] = tCostItem2[cfgId] + 1
  322. end
  323. -- table.insert(tCostItem2,{costType = costType, [cfgId]=1,})
  324. end
  325. end
  326. end
  327. end
  328. -- for index, v in pairs(tConsumeItem2) do
  329. -- if tCostEx and tCostEx[index] and tCostEx[index].id then
  330. -- local costType = tonumber(v[1])
  331. -- local itemId = tCostEx[index].id
  332. -- local cfgId = tCostEx[index].cfgId
  333. -- -- local item = getequipinfo(actor,itemId,1)
  334. -- local itemInfo = getbagiteminfo(actor,itemId,1)
  335. -- local jiazhi = EquipFunc.getEquipJiaZhi(actor,itemId)
  336. -- addRate = addRate + math.floor( jiazhi / 20000)
  337. -- local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  338. -- if name == "合成幸运符" then
  339. -- luckRate = luckRate + EquipFunc.getEquipJiaZhi(actor, itemId)
  340. -- end
  341. -- if costType == 2 then
  342. -- local bagIndex = itemInfo.bagindex
  343. -- table.insert(tCostItem1,{costType = costType, bagIndex=bagIndex})
  344. -- elseif costType == 3 then
  345. -- tCostItem2[cfgId] = 1
  346. -- -- table.insert(tCostItem2,{costType = costType, [cfgId]=1,})
  347. -- end
  348. -- end
  349. -- end
  350. end
  351. local _, itemMain =
  352. table.findByCondi(
  353. tCostItem1,
  354. function(a)
  355. return a.isMain == true
  356. end
  357. )
  358. -- 发放奖励 local productId = cfg_synthesis.productid --合成后的道具id字段 21310011#33|21310021#33|21310031#33
  359. local realProductIds = {}
  360. local tProductId = ItemSynthesis.string2table(cfg_synthesis.productid)
  361. for i = 1, #tProductId do
  362. -- 只能合成相同部位
  363. if cfg_synthesis.producttype == "1" and itemMain ~= nil then
  364. local strpart1 = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", itemMain.cfgid)
  365. local strpart2 = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", tonumber(tProductId[i][1]))
  366. strpart1 = not string.isNullOrEmpty(strpart1) and string.split(strpart1, "#") or {}
  367. strpart2 = not string.isNullOrEmpty(strpart2) and string.split(strpart2, "#") or {}
  368. local isFind = false
  369. for i, v in ipairs(strpart1) do
  370. local findIndex, _ =
  371. table.findByCondi(
  372. strpart2,
  373. function(a)
  374. return a == v
  375. end
  376. )
  377. if findIndex ~= nil then
  378. isFind = true
  379. break
  380. end
  381. end
  382. if isFind == true then
  383. tProductId[i].qz = tProductId[i][2]
  384. table.insert(realProductIds, tProductId[i])
  385. end
  386. else
  387. tProductId[i].qz = tProductId[i][2]
  388. table.insert(realProductIds, tProductId[i])
  389. end
  390. end
  391. local qz = API.GetQZ(realProductIds)
  392. local productId = realProductIds[qz][1]
  393. local extraRate = 0
  394. successRateReal = successRateReal + addRate + extraRate + luckRate
  395. successRateMax = successRateMax + luckRate
  396. if successRateReal > successRateMax then
  397. successRateReal = successRateMax
  398. end
  399. info(tCostItem1, "tCostItem1", "合成数据")
  400. local isMarkEquip = false
  401. local equipStrengthlv = nil
  402. local equipAppendLv = nil
  403. local equipEntrys = {}
  404. local luckEntrys = {}
  405. for i = 1, #tCostItem1 do
  406. local bagIndex = tCostItem1[i].bagIndex
  407. if isMarkEquip == false then
  408. isMarkEquip = true
  409. local itemInfo = getbagiteminfo(actor, bagIndex, 0)
  410. local cfgItem = nil
  411. if itemInfo ~= nil then
  412. cfgItem = ConfigDataManager.getById("cfg_item", itemInfo.cfgid)
  413. end
  414. if cfgItem ~= nil and cfgItem.type == "2" then
  415. equipStrengthlv = EquipFunc.getEquipStrengthLevel(actor, itemInfo.id)
  416. equipAppendLv = EquipFunc.getEquipAppendLevel(actor, itemInfo.id)
  417. local tmpentrys = API.TableDeepcopy(itemInfo.entries)
  418. for i, v in ipairs(tmpentrys) do
  419. if EquipRandom.Config.ATTR_VALUES[v.attrid] then
  420. table.insert(
  421. luckEntrys,
  422. {
  423. value = v.value,
  424. entryid = tostring(v.entryid),
  425. attrid = tostring(v.attrid)
  426. }
  427. )
  428. else
  429. table.insert(
  430. equipEntrys,
  431. {
  432. value = v.value,
  433. entryid = tostring(v.entryid),
  434. attrid = tostring(v.attrid)
  435. }
  436. )
  437. end
  438. end
  439. end
  440. end
  441. if tCostItem1[i].cantDestroy == nil or tCostItem1[i].cantDestroy ~= true then
  442. destroyitemafter(actor, bagIndex, "道具合成")
  443. end
  444. end
  445. info(tCostItem2, "tCostItem2", "合成数据")
  446. if isCostLuck then
  447. Bag.costMap(
  448. actor,
  449. {
  450. [tonumber(cfg_synthesis.useluck)] = 1
  451. },
  452. "合成扣除材料消耗"
  453. )
  454. end
  455. if isCostProtect then
  456. Bag.costMap(
  457. actor,
  458. {
  459. [tonumber(cfg_synthesis.useprotect)] = 1
  460. },
  461. "合成扣除材料消耗"
  462. )
  463. end
  464. Bag.costMap(actor, tCostItem2, "合成扣除材料消耗")
  465. local cfgId = tonumber(cfg_synthesis.id)
  466. local failDatas = APIGetTable(actor, SYS_ITEM_SYNTHESIS_FAIL_COUNT) or {}
  467. local failCount = failDatas[cfgId] ~= nil and failDatas[cfgId] or 0
  468. local addRate = 0
  469. if not string.isNullOrEmpty(cfg_synthesis.guarantees) then
  470. local guarantees = string.split(cfg_synthesis.guarantees, "|")
  471. for i, v in ipairs(guarantees) do
  472. local datas = string.split(v, "#")
  473. if table.count(datas) >= 2 then
  474. local count = tonumber(datas[1])
  475. local rate = tonumber(datas[2])
  476. if count ~= nil and rate ~= nil and failCount >= count then
  477. addRate = rate / 100
  478. end
  479. end
  480. end
  481. end
  482. -- 检测概率 successRateReal
  483. local successRate = math.random(1, 100)
  484. if successRate > (successRateReal + addRate) then
  485. sendluamsg(actor, LuaMessageIdToClient.RES_ITEM_SYNTHESIS, {})
  486. messagebox(actor, "合成失败")
  487. failDatas[cfgId] = failCount + 1
  488. APISetTable(actor, SYS_ITEM_SYNTHESIS_FAIL_COUNT, failDatas)
  489. return
  490. end
  491. failDatas[cfgId] = nil
  492. APISetTable(actor, SYS_ITEM_SYNTHESIS_FAIL_COUNT, failDatas)
  493. for i = 1, #tCostItem1 do
  494. local bagIndex = tCostItem1[i].bagIndex
  495. if tCostItem1[i].cantDestroy ~= nil and tCostItem1[i].cantDestroy == true then
  496. destroyitemafter(actor, bagIndex, "道具合成")
  497. end
  498. end
  499. local itemId = ItemSynthesis.addItemToBag(actor, productId, 1, 1, 9999, "合成")
  500. -- local itemId = additemtobag(actor, productId, 1, 1, 9999, "合成")
  501. if extraRate > 0 then
  502. local itemList = MaYaJiYuan_Data.PetRevelryCfg.extraRewardList
  503. for k, v in pairs(itemList) do
  504. local itemId = CommonUtil.GetItemIdByItemName(v[1])
  505. local itemCount = v[2]
  506. ItemSynthesis.addItemToBag(actor, itemId, itemCount, 1, 9999, "玛雅纪元宠物狂欢合成额外获得")
  507. end
  508. end
  509. if not string.isNullOrEmpty(cfg_synthesis.entry) then
  510. local strEntrys = string.split(cfg_synthesis.entry, "|")
  511. local entrys = {}
  512. for i, v in ipairs(strEntrys) do
  513. local ev = string.split(v, "#")
  514. table.insert(
  515. entrys,
  516. {
  517. entryid = table.count(entrys) + 1,
  518. attrid = ev[1],
  519. value = tonumber(ev[2])
  520. }
  521. )
  522. end
  523. resetequipentry(actor, itemId, entrys)
  524. if cfg_synthesis.type == "11" then
  525. local cfg_item = ConfigDataManager.getById("cfg_item", tonumber(productId))
  526. local itemName = cfg_item ~= nil and cfg_item.name or ""
  527. local playerName = getbaseinfo(actor, "rolename")
  528. noticeTip.noticeinfo(actor, StringIdConst.text35009, playerName, itemName)
  529. end
  530. end
  531. if not string.isNullOrEmpty(cfg_synthesis.fastionlevel) then
  532. local lv = tonumber(cfg_synthesis.fastionlevel)
  533. -- 刷新装备
  534. API.SetItemData(actor, itemId, "strengthlv", lv)
  535. -- 刷新流光
  536. API.refreshLiuGuang(actor, itemId)
  537. Equip_QiangHua.RefreshLevel(actor, itemId, tonumber(productId))
  538. end
  539. local transfers = cfg_synthesis.transfer
  540. if
  541. not string.isNullOrEmpty(transfers) and
  542. ConfigDataManager.getTableValue("cfg_item", "type", "id", productId) == "2"
  543. then
  544. local ss = string.split(transfers, "#")
  545. local resultEntrys = {}
  546. for i, v in ipairs(ss) do
  547. local type = tonumber(v)
  548. if
  549. type == 1 and equipStrengthlv ~= nil and equipStrengthlv > 0 and
  550. Equip_QiangHua.canQiangHua(actor, nil, itemId)
  551. then
  552. local lv = equipStrengthlv
  553. -- 刷新装备
  554. API.SetItemData(actor, itemId, "strengthlv", lv)
  555. -- 刷新流光
  556. API.refreshLiuGuang(actor, itemId)
  557. Equip_QiangHua.RefreshLevel(actor, itemId, tonumber(productId))
  558. elseif
  559. type == 2 and equipAppendLv ~= nil and equipAppendLv > 0 and
  560. ConfigDataManager.getById("cfg_equip_appends", productId) ~= nil
  561. then
  562. EquipAndAppear.setAppendLv(actor, itemId, equipAppendLv)
  563. elseif type == 3 and table.count(luckEntrys) > 0 then
  564. for i, v in ipairs(luckEntrys) do
  565. table.insert(resultEntrys, v)
  566. end
  567. elseif type == 4 and table.count(equipEntrys) > 0 then
  568. for i, v in ipairs(equipEntrys) do
  569. table.insert(resultEntrys, v)
  570. end
  571. end
  572. end
  573. if table.count(resultEntrys) > 0 then
  574. resetequipentry(actor, itemId, resultEntrys)
  575. end
  576. end
  577. -- info(tConsumeItem,"tConsumeItem","合成数据")
  578. -- local name = getrolefield(actor, "role.basic.name")
  579. -- local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", itemId)
  580. -- noticeTip.noticeinfo(actor, StringIdConst.TEXT503, name, itemName)
  581. sendluamsg(actor, LuaMessageIdToClient.RES_ITEM_SYNTHESIS, {})
  582. sendluamsg(
  583. actor,
  584. LuaMessageIdToClient.COMMON_REWARD_PANEL,
  585. {
  586. {
  587. id = itemId,
  588. cfgId = productId,
  589. count = 1
  590. }
  591. }
  592. )
  593. -- ---触发合成任务
  594. local taskParam = {
  595. synthesisid = synthesisCfgId,
  596. num = count
  597. }
  598. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.SYNTHESIS, taskParam)
  599. -- HeChengQiangHuaTiaoZhan.CheckTaskIsFinish(actor, { { itemId = itemId, itemCfgId = productId, count = 1 } })
  600. -- DaKaHuoDong.CheckTaskIsFinish(actor, DaKaHuoDong.taskType.forging, 1)
  601. end
  602. function ItemSynthesis.addItemToBag(actor, itemCfgId, num, bind, type, desc)
  603. local itemId = Bag.addItemToBag(actor, itemCfgId, num, bind, type, desc)
  604. local item = getbagiteminfo(actor, itemId, 1)
  605. local cfgEquip = ConfigDataManager.getById("cfg_equip_entryLib", itemCfgId)
  606. if item ~= nil and cfgEquip ~= nil and cfgEquip.skillgemprobability ~= nil and cfgEquip.skillgemprobability ~= "" then
  607. local skillGems = string.split(cfgEquip.skillgemprobability, "#")
  608. if table.count(skillGems) == 3 then
  609. local skillId = tonumber(skillGems[1])
  610. local level = tonumber(skillGems[2])
  611. local probability = tonumber(skillGems[3])
  612. local skills = {}
  613. if math.random(1, 10000) <= probability then
  614. -- -- 添加装备技能
  615. -- local info = getbagiteminfo(actor, itemId, 1)
  616. -- if table.count(info.skill) == 0 then
  617. -- setequipskillbyid(actor, itemId, skillId, level)
  618. -- end3
  619. table.insert(
  620. skills,
  621. {
  622. skillid = skillId,
  623. skilllevel = level
  624. }
  625. )
  626. end
  627. if table.count(skills) > 0 then
  628. API.SetItemData(actor, itemId, "skillinfo", skills)
  629. end
  630. end
  631. end
  632. -- 装备添加物品来源
  633. if cfgEquip ~= nil then
  634. local playerName = getbaseinfo(actor, "rolename")
  635. API.SetItemData(actor, itemId, "formt", 2)
  636. API.SetItemData(actor, itemId, "form1", "")
  637. API.SetItemData(actor, itemId, "form2", playerName)
  638. API.SetItemData(actor, itemId, "form3", getbaseinfo("now"))
  639. end
  640. return itemId
  641. end
  642. -- 合成装备增加追加属性
  643. function ItemSynthesis.changeItemAtt(actor, itemId, changeItemId)
  644. local allequip = getplaydef(actor, "T$luaitemextdata")
  645. if not allequip then
  646. return
  647. end
  648. local equipext = allequip[changeItemId]
  649. if equipext == nil then
  650. return
  651. end
  652. allequip[itemId] = equipext
  653. EquipAndAppear.SetItemExtData(actor, itemId, equipext)
  654. allequip[changeItemId] = {}
  655. setplaydef(actor, "T$luaitemextdata", allequip)
  656. end
  657. -- 前后交互
  658. GameEvent.add(
  659. EventCfg.onHandlereQuest,
  660. function(actor, msgid, sMsg)
  661. if msgid == LuaMessageIdToSever.REQ_ITEM_SYNTHESIS then
  662. ItemSynthesis.synthesis(actor, sMsg)
  663. return true
  664. end
  665. end,
  666. this.filename
  667. )
  668. -- end