ItemSynthesis_1.lua 24 KB

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