EquipAndAppear.lua 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262
  1. EquipAndAppear = {}
  2. local this = {}
  3. ---玩家装备信息记录
  4. local ROLE_EQUIP_INFO_RECORDE = "T$role_equip_info_recorde"
  5. local ROLE_EQUIP_STRENGTH_TIMES = "T$role_equip_strength_times"
  6. EquipAndAppear.RecordeType = {
  7. ---全身最大强化等级
  8. MAX_STRENGTH_LEVEL = 1,
  9. ---全身最大追加等级
  10. MAX_APPEND_LEVEL = 2,
  11. ---全身最大卓越词条数量
  12. MAX_ENTRY_COUNT = 3,
  13. ---全身最大首饰等级
  14. MAX_JEWELRY_LEVEL = 4
  15. }
  16. ---装备信息记录数据结构
  17. function this.GetNewEquipInfoRecorde()
  18. local recorde = {
  19. ---全身最大强化等级
  20. max_strength_level = 0,
  21. ---全身最大追加等级
  22. max_append_level = 0,
  23. ---全身最大卓越词条数量
  24. max_entry_count = 0,
  25. ---全身最大首饰等级
  26. max_jewelry_level = 0
  27. }
  28. return recorde
  29. end
  30. ---装备bind数据修复
  31. local EQUIP_BIND_DATA_REPAIR = "T$equipbinddatarepair"
  32. local EQUIP_UP_DATA_REPAIR = "T$equipssupdatarepair"
  33. function EquipAndAppear.login(actor)
  34. RepairRoleData.action(actor, EQUIP_BIND_DATA_REPAIR, 202503192016, EquipAndAppear.repairEquipBindData2025_03_19,actor)
  35. RepairRoleData.action(actor, EQUIP_UP_DATA_REPAIR, 202503241400, EquipAndAppear.repairEquipSsupData2025_03_24,actor)
  36. end
  37. function EquipAndAppear.repairEquipBindData2025_03_19(actor)
  38. local allData = EquipAndAppear.getLuaItemExtData(actor)
  39. local infos = getallequipinfo(actor)
  40. for _, equip in pairs(infos) do
  41. if this.checkEquipData(actor,allData,equip.id) then
  42. changeitembindstate(actor,equip.id,1)
  43. end
  44. end
  45. info(actor,"修复bind数据成功")
  46. end
  47. ---装备首饰升级数据修复
  48. function EquipAndAppear.repairEquipSsupData2025_03_24(actor)
  49. local allData = EquipAndAppear.getLuaItemExtData(actor)
  50. local infos = getallequipinfo(actor)
  51. for _, equip in pairs(infos) do
  52. local cfgId = equip.cfgid
  53. local itemId = tonumber(equip.id)
  54. local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
  55. if group ~= nil and group ~= "" then
  56. local equipext = allData[itemId]
  57. if equipext then
  58. local ssUpLv = equipext.ssuplv or 0
  59. local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", ssUpLv)
  60. if (ornaments == nil) and ssUpLv > 0 then
  61. --修复数据
  62. for i = ssUpLv - 1,1,-1 do
  63. local newNaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv",i)
  64. if newNaments and table.count(newNaments) > 0 then
  65. equipext.ssuplv = i
  66. local att = newNaments[1].basicatt
  67. local attr = splitbyshuxianandjinghao2(att)
  68. equipext.ssupattr = attr
  69. EquipAndAppear.SetItemExtData(actor, itemId, equipext)
  70. allData[itemId] = equipext
  71. setplaydef(actor, "T$luaitemextdata", allData)
  72. break
  73. end
  74. end
  75. end
  76. end
  77. end
  78. end
  79. info(actor,"修复首饰升级数据成功")
  80. end
  81. function this.checkEquipData(actor,allData,itemId)
  82. local equipData = allData[tonumber(itemId)]
  83. if not equipData then
  84. return false
  85. end
  86. if equipData.strengthlv ~= 0 then
  87. return true
  88. end
  89. if equipData.appendlv ~= 0 then
  90. return true
  91. end
  92. local equip = getequipinfo(actor, itemId, 1)
  93. if table.count(equip.entries) > 2 then
  94. return true
  95. end
  96. return false
  97. end
  98. function EquipAndAppear.GetEquipInfoRecorde(actor)
  99. local equipInfoRecorde = getplaydef(actor, ROLE_EQUIP_INFO_RECORDE)
  100. if equipInfoRecorde == nil then
  101. equipInfoRecorde = this.GetNewEquipInfoRecorde()
  102. end
  103. return equipInfoRecorde
  104. end
  105. function this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
  106. setplaydef(actor, ROLE_EQUIP_INFO_RECORDE, equipInfoRecorde)
  107. end
  108. -- 保存角色外观(幻化也走这个方法)
  109. function EquipAndAppear.settingequipappear(actor, msgData)
  110. local equipappear = msgData["equipindex"]
  111. local data = {}
  112. for _, value in pairs(equipappear) do
  113. local pos = tonumber(value["slot"])
  114. local cfgId = tonumber(value["cfgId"])
  115. if pos ~= nil then
  116. data[pos] = cfgId
  117. end
  118. end
  119. setitemappeardata(actor, data)
  120. sendluamsg(actor, LuaMessageIdToClient.RES_SETTING_EQUIP_APPEAR, data)
  121. end
  122. -- 初始化角色外观
  123. function initequipppear(actor)
  124. local equipappear = {}
  125. setplaydef(actor, "T$equipappear", equipappear)
  126. end
  127. --获取角色外观
  128. function EquipAndAppear.getequipappear(actor, msgId)
  129. local data = getrolefield(actor, "role.roleappear.appear")
  130. if data == nil then
  131. return
  132. end
  133. local result = {}
  134. for key, value in pairs(data) do
  135. local appear = {}
  136. appear["slot"] = key
  137. appear["cfgId"] = value
  138. table.insert(result, appear)
  139. end
  140. --发送lua消息到客户端
  141. if LuaMessageIdToSever.GET_EQUIP_APPEAR == msgId then
  142. sendluamsg(actor, LuaMessageIdToClient.GET_EQUIP_APPEAR, result)
  143. end
  144. return result
  145. end
  146. -- 外观幻化激活
  147. function EquipAndAppear.equipfashion(actor, msgData)
  148. local cfgIds = msgData["cfgIds"]
  149. local equipFashion = getplaydef(actor, "T$equipfashion")
  150. if equipFashion == nil then
  151. equipFashion = {}
  152. end
  153. for _, cfgId in pairs(cfgIds) do
  154. local isExist = table.contains(equipFashion, cfgId)
  155. if isExist then
  156. --存在已激活的
  157. return
  158. end
  159. end
  160. --计算所有消耗
  161. local allData = getAllEquipAppearCost(cfgIds, 4)
  162. if allData == nil then
  163. return
  164. end
  165. --检查背包是否道具充足
  166. local enough = Bag.checkItemEnough(actor, allData)
  167. if enough == false then
  168. return
  169. end
  170. --扣材料
  171. for _, v in ipairs(allData) do
  172. local cId = v["cfgid"]
  173. local count = v["count"]
  174. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  175. end
  176. --保存幻化
  177. for _, v in pairs(cfgIds) do
  178. table.insert(equipFashion, v)
  179. end
  180. setplaydef(actor, "T$equipfashion", equipFashion)
  181. sendluamsg(actor, LuaMessageIdToClient.RES_ACT_EQUIP_FASHION, equipFashion)
  182. end
  183. --获取已激活外观
  184. function EquipAndAppear.getallequipfashion(actor)
  185. local equipFashion = getplaydef(actor, "T$equipfashion")
  186. sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_FASHION, equipFashion)
  187. end
  188. --激活染色
  189. function EquipAndAppear.actquipcolor(actor, msgData)
  190. local cfgIds = msgData["cfgIds"]
  191. local color = msgData["color"]
  192. --计算消耗材料
  193. local allCost = getAllEquipAppearCost(cfgIds, 5)
  194. if allCost == nil then
  195. return
  196. end
  197. --检查背包是否道具充足
  198. local enough = Bag.checkItemEnough(actor, allCost)
  199. if enough == false then
  200. return
  201. end
  202. --扣材料
  203. for _, v in ipairs(allCost) do
  204. local cId = v["cfgid"]
  205. local count = v["count"]
  206. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  207. end
  208. --染色
  209. local equipcolor = EquipAndAppear.getequipcolor(actor, 0)
  210. for i, v in ipairs(cfgIds) do
  211. local num = 0
  212. for _, val in pairs(equipcolor) do
  213. if val["cfgid"] == v then
  214. table.insert(val["color"], color)
  215. num = num + 1
  216. break
  217. end
  218. end
  219. if num == 0 then
  220. local dt = {}
  221. dt["cfgid"] = v
  222. dt["color"] = {}
  223. table.insert(dt["color"], color)
  224. table.insert(equipcolor, dt)
  225. end
  226. end
  227. setplaydef(actor, "actequipcolor", equipcolor)
  228. end
  229. -- 保存染色
  230. function EquipAndAppear.settingequipcolor(actor, msgData)
  231. local cfgId = msgData["cfgid"]
  232. local color = msgData["color"]
  233. --先校验是否激活该颜色
  234. local actequipcolor = getplaydef(actor, "T$actequipcolor")
  235. local bool = false
  236. for _, v in pairs(actequipcolor) do
  237. local cId = v["cfgid"]
  238. if cId == cfgId then
  239. bool = table.contains(v["color"], color)
  240. break
  241. end
  242. end
  243. if bool ~= true then
  244. return
  245. end
  246. local equipcolor = EquipAndAppear.getequipcolor(actor, 0)
  247. for _, v in ipairs(equipcolor) do
  248. if v["cfgid"] == cfgId then
  249. v["color"] = color
  250. break
  251. end
  252. end
  253. setplaydef(actor, "T$equipcolor", equipcolor)
  254. end
  255. --获取角色染色数据
  256. function EquipAndAppear.getequipcolor(actor, msgId)
  257. local equipcolor = getplaydef(actor, "T$equipcolor")
  258. if equipcolor == nil then
  259. equipcolor = {}
  260. setplaydef(actor, "T$equipcolor", equipcolor)
  261. end
  262. local data = getplaydef(actor, "T$equipcolor")
  263. --发送lua消息到客户端
  264. if msgId == LuaMessageIdToClient.GET_EQUIP_COLOR then
  265. sendluamsg(actor, msgId, data)
  266. end
  267. return data
  268. end
  269. --计算所有消耗
  270. function getAllEquipAppearCost(cfgIds, type)
  271. local allData = {}
  272. for _, cfgId in pairs(cfgIds) do
  273. local cost = ConfigDataManager.getTableValue("cfg_fashion", "deplete", "id", cfgId, "type", type)
  274. if cost == nil then
  275. return nil
  276. end
  277. local data = splitbyshuxianandjinghao(cost)
  278. for _1, v in pairs(data) do
  279. local id = v["cfgid"]
  280. local count = v["count"]
  281. local num = 0
  282. for _2, val in pairs(allData) do
  283. if val["cfgid"] == id then
  284. val["count"] = val["count"] + count
  285. num = num + 1
  286. break
  287. end
  288. end
  289. if num == 0 then
  290. local element = {}
  291. element["cfgid"] = id
  292. element["count"] = count
  293. table.insert(allData, element)
  294. end
  295. end
  296. end
  297. return allData
  298. end
  299. function EquipAndAppear.playerequipview(actor, otherActor)
  300. if otherActor == nil then
  301. return
  302. end
  303. --发送幻化染色数据
  304. local appear = EquipAndAppear.getequipappear(otherActor, 0)
  305. local title = EquipAndAppear.gettitleinfo(otherActor, 0)
  306. local alldata = {}
  307. alldata["appear"] = appear
  308. alldata["ring"] = EquipAndAppear.getnowwearshapering(otherActor)
  309. local curTitle = 0
  310. if not title.hidden then
  311. curTitle = title.curEquipTitle
  312. end
  313. alldata["title"] = curTitle
  314. local rid = getbaseinfo(otherActor, "rid")
  315. alldata["rid"] = rid
  316. sendluamsg(actor, LuaMessageIdToClient.OTHER_ROLE_APPEAR, alldata)
  317. end
  318. --玩家进入视野时发送玩家装备的强化信息
  319. function EquipAndAppear.playerequipstrength(actor, otherActor)
  320. if otherActor == 0 then
  321. otherActor = actor
  322. end
  323. local alldata = getplaydef(otherActor, "T$luaitemextdata")
  324. local equiplist = getputonequipinfo(otherActor)
  325. local result = {}
  326. local info = {}
  327. for _, equipinfo in pairs(equiplist) do
  328. local itemId = equipinfo.id
  329. local data = alldata[itemId]
  330. local equip = {}
  331. equip.itemid = itemId
  332. if data ~= nil then
  333. if data.strengthlv ~= nil then
  334. equip.strengthlv = data.strengthlv
  335. else
  336. equip.strengthlv = 0
  337. end
  338. else
  339. equip.strengthlv = 0
  340. end
  341. table.insert(info, equip)
  342. end
  343. result.rid = getbaseinfo(otherActor, "rid")
  344. result.equip = info
  345. result = table.valueConvertToString(result)
  346. sendrefluamsg(actor, LuaMessageIdToClient.RES_PLAYER_EQUIP_STRENGTHLV, result)
  347. end
  348. --检查表是否包含某个元素
  349. -- function table.contains(table, element)
  350. -- for _, value in pairs(table) do
  351. -- if value == element then
  352. -- return true
  353. -- end
  354. -- end
  355. -- return false
  356. -- end
  357. -- 分割字符串
  358. function splitbyshuxianandjinghao(str)
  359. local dt = {}
  360. local data = string.split(str, "|")
  361. for _, v in ipairs(data) do
  362. local data2 = string.split(v, "#")
  363. local v2 = {}
  364. v2["cfgid"] = data2[1]
  365. v2["count"] = data2[2]
  366. table.insert(dt, v2)
  367. end
  368. return dt
  369. end
  370. --称号入包
  371. function EquipAndAppear.titleenterbag(actor, configId)
  372. local itemList = ConfigDataManager.getTable("cfg_item", "id", configId)
  373. if itemList == nil then
  374. return
  375. end
  376. local item = itemList[1]
  377. if tonumber(item.type) ~= 2 or tonumber(item.subtype) ~= 15 then
  378. return
  379. end
  380. --计算时间
  381. local fashionList = ConfigDataManager.getTable("cfg_fashion", "id", configId)
  382. if fashionList == nil then
  383. return
  384. end
  385. if table.count(fashionList) == 0 then
  386. return
  387. end
  388. local fashion = fashionList[1]
  389. local titledata = EquipAndAppear.gettitleinfo(actor, 0)
  390. local titles = titledata.title
  391. --不限时
  392. local flag = true
  393. local time = 0
  394. local type = 0
  395. local timeType = tonumber(fashion.timetype)
  396. local nowTime = math.ceil(getbaseinfo("now") / 1000)
  397. if timeType == 1 then
  398. type = 1
  399. for _, value in pairs(titles) do
  400. if value.confId == configId then
  401. value.obtainTime = nowTime --获得时间
  402. value.expiresTime = -1 --到期时间
  403. flag = false
  404. end
  405. end
  406. time = -1
  407. end
  408. --限时
  409. if timeType == 2 then
  410. type = 2
  411. --获取称号的有效期
  412. local times = fashion.time
  413. local timestr = string.split(times, "#")
  414. --总时间
  415. time = tonumber(timestr[1]) * 60 * 60 + tonumber(timestr[2]) * 60 + tonumber(timestr[3])
  416. for _, value in pairs(titles) do
  417. if value.confId == configId then
  418. value.obtainTime = nowTime --获得时间
  419. value.expiresTime = value.obtainTime + time --到期时间
  420. flag = false
  421. end
  422. end
  423. end
  424. --活动限时
  425. if timeType == 3 then
  426. type = 3
  427. --todo 获取称号的有效期
  428. local actId = fashion.time
  429. local actdata = getactivityinfo(actor, actId)
  430. time = math.ceil(actdata.nextopentime / 1000)
  431. for _, value in pairs(titles) do
  432. if value.confId == configId then
  433. value.obtainTime = nowTime --获得时间
  434. value.expiresTime = time --到期时间
  435. flag = false
  436. end
  437. end
  438. end
  439. if flag then
  440. local tt = {}
  441. tt.obtainTime = math.ceil(getbaseinfo("now") / 1000)
  442. if type == 1 or type == 3 then
  443. tt.expiresTime = time
  444. else
  445. tt.expiresTime = tt.obtainTime + time
  446. end
  447. tt.confId = configId
  448. table.insert(titles, tt)
  449. end
  450. setplaydef(actor, "T$titledata", titledata)
  451. --更新称号属性
  452. EquipAndAppear.updatetitleattr(actor)
  453. end
  454. --更新称号属性信息
  455. function EquipAndAppear.updatetitleattr(actor)
  456. local data = getplaydef(actor, "T$titledata")
  457. local titles = data.title
  458. local titleattr = {}
  459. local nowTime = math.ceil(getbaseinfo("now") / 1000)
  460. for _, value in pairs(titles) do
  461. --先校验是否过期
  462. if value.expiresTime == -1 or value.expiresTime > nowTime then
  463. --计算属性
  464. local fashion = ConfigDataManager.getTable("cfg_fashion", "id", value.confId)
  465. local attr = fashion[1].att
  466. local str = string.split(attr, "|")
  467. for _, value in pairs(str) do
  468. local str2 = string.split(value, "#")
  469. local num = titleattr[str2[1]]
  470. local nowNum = str2[2]
  471. if num == nil then
  472. titleattr[str2[1]] = tonumber(nowNum)
  473. else
  474. titleattr[str2[1]] = tonumber(nowNum) + tonumber(num)
  475. end
  476. end
  477. end
  478. end
  479. --更新称号属性
  480. addrolekmlattributes(actor, "titleattr", titleattr)
  481. end
  482. --获取称号详细信息
  483. function EquipAndAppear.gettitleinfo(actor, msgId)
  484. local data = getplaydef(actor, "T$titledata")
  485. if data == nil then
  486. data = EquipAndAppear.inittitledata(actor)
  487. end
  488. if msgId == LuaMessageIdToSever.GET_TITLE then
  489. sendluamsg(actor, LuaMessageIdToClient.GET_TITLE, data)
  490. end
  491. return data
  492. end
  493. --保存称号外观
  494. function EquipAndAppear.settingtitleappear(actor, msgId, msgData)
  495. local data = getplaydef(actor, "T$titledata")
  496. local titleappear = msgData["title"]
  497. data.curEquipTitle = titleappear
  498. setplaydef(actor, "T$titledata", data)
  499. if msgId == LuaMessageIdToSever.SET_TITLE then
  500. sendluamsg(actor, LuaMessageIdToClient.SETTING_TITLE_APPEAR, titleappear)
  501. local result = {}
  502. result.rid = getbaseinfo(actor, "rid")
  503. result.curEquipTitle = titleappear
  504. sendrefluamsg(actor, LuaMessageIdToClient.RES_TITLE_CHANGE_UPDATE, result)
  505. end
  506. end
  507. --初始化数据
  508. function EquipAndAppear.inittitledata(actor)
  509. local data = {}
  510. data.title = {}
  511. data.hidden = false
  512. data.curEquipTitle = 0
  513. setplaydef(actor, "T$titledata", data)
  514. return data
  515. end
  516. --校验称号的过期时间
  517. function EquipAndAppear.checktitleovertime(actor)
  518. local data = getplaydef(actor, "T$titledata")
  519. if table.count(data) == 0 then
  520. data = EquipAndAppear.inittitledata(actor)
  521. end
  522. local titles = data.title
  523. if table.count(titles) == 0 then
  524. return
  525. end
  526. local curTitle = data.curEquipTitle
  527. local flag = false
  528. local nowTime = math.ceil(getbaseinfo("now") / 1000)
  529. for key, value in pairs(titles) do
  530. --先校验是否过期
  531. --jprint("检查称号过期0",value.expiresTime > nowTime, value.expiresTime, nowTime)
  532. if value.expiresTime ~= -1 and value.expiresTime < nowTime then
  533. table.remove(titles, key)
  534. flag = true
  535. if curTitle == value.confId then
  536. data.curEquipTitle = 0
  537. end
  538. end
  539. end
  540. if flag then
  541. data.title = titles
  542. setplaydef(actor, "T$titledata", data)
  543. EquipAndAppear.updatetitleattr(actor)
  544. --发送消息
  545. sendluamsg(actor, LuaMessageIdToClient.SETTING_TITLE_APPEAR, 0)
  546. end
  547. end
  548. --获取守护外观
  549. function EquipAndAppear.getguardappear(actor, msgId)
  550. local data = getrolefield(actor, "role.roleEquip.guardAppear")
  551. if data == nil then
  552. sendluamsg(actor, LuaMessageIdToClient.RES_GUARD_APPEAR, {})
  553. return {}
  554. end
  555. local result = {}
  556. for key, value in pairs(data) do
  557. local mm = {}
  558. mm.att = value.attr
  559. mm.getTime = math.floor(value.getTime / 1000)
  560. mm.itemId = key
  561. if value.time ~= -1 then
  562. mm.time = mm.getTime + math.floor(value.time / 1000)
  563. else
  564. mm.time = -1
  565. end
  566. table.insert(result, mm)
  567. end
  568. if msgId == LuaMessageIdToSever.GET_GUARD_APPEAR then
  569. sendluamsg(actor, LuaMessageIdToClient.RES_GUARD_APPEAR, result)
  570. end
  571. return data
  572. end
  573. --获取变身戒指数据
  574. function EquipAndAppear.getshapering(actor, msgId)
  575. local data = getrolefield(actor, "role.roleEquip.shapeRing")
  576. if data == nil then
  577. return {}
  578. end
  579. local nowwear = EquipAndAppear.getnowwearshapering(actor)
  580. local rd = {}
  581. local result = {}
  582. rd.curWearRing = nowwear
  583. for key, value in pairs(data) do
  584. local mm = {}
  585. mm.monsterId = tonumber(key)
  586. mm.ringAttr = value.ringAttr
  587. mm.getTime = math.floor(value.getTime / 1000)
  588. mm.itemId = value.itemId
  589. if value.time ~= -1 then
  590. mm.time = math.floor(value.time / 1000)
  591. else
  592. mm.time = -1
  593. end
  594. table.insert(result, mm)
  595. end
  596. rd.title = result
  597. if msgId == LuaMessageIdToSever.GET_SHAPE_RING then
  598. sendluamsg(actor, LuaMessageIdToClient.GET_SHAPE_RING, rd)
  599. end
  600. return data
  601. end
  602. --穿戴变身戒指
  603. function EquipAndAppear.wearshapering(actor, msgData)
  604. local monsterId = msgData["monsterId"]
  605. setplaydef(actor, "T$wearshapering", monsterId)
  606. setshaperingdata(actor, monsterId)
  607. sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, monsterId)
  608. local result = {}
  609. result.rid = getbaseinfo(actor, "rid")
  610. result.curEquipRing = monsterId
  611. sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
  612. end
  613. --获取当前穿戴的变身戒指
  614. function EquipAndAppear.getnowwearshapering(actor)
  615. local data = getplaydef(actor, "T$wearshapering")
  616. if data == nil then
  617. return 0
  618. end
  619. return data
  620. end
  621. --校验变身戒指过期时间
  622. function EquipAndAppear.checkringovertime(actor)
  623. local data = EquipAndAppear.getshapering(actor)
  624. local ringId = EquipAndAppear.getnowwearshapering(actor)
  625. if ringId == 0 then
  626. return
  627. end
  628. local monsterId = ConfigDataManager.getTableValue("cfg_item", "useParam", "id", ringId)
  629. if not monsterId then
  630. return
  631. end
  632. if not data[tostring(monsterId)] then
  633. setplaydef(actor, "T$wearshapering", 0)
  634. sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, 0)
  635. local result = {}
  636. result.rid = getbaseinfo(actor, "rid")
  637. result.curEquipRing = 0
  638. sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
  639. end
  640. -- local nowTime = math.ceil(getbaseinfo("now") / 1000)
  641. -- for index, ring in pairs(data) do
  642. -- if ring ~= -1 then
  643. -- --检查
  644. -- if nowTime > math.floor(ring.time / 1000) then
  645. -- --删除穿戴外观
  646. -- local ringId = EquipAndAppear.getnowwearshapering(actor)
  647. -- if ringId == ring then
  648. -- setplaydef(actor, "T$wearshapering", 0)
  649. -- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, 0)
  650. -- local result = {}
  651. -- result.rid = getbaseinfo(actor, "rid")
  652. -- result.curEquipRing = 0
  653. -- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
  654. -- end
  655. -- table.remove(data, index)
  656. -- end
  657. -- end
  658. -- end
  659. end
  660. function EquipAndAppear.initequipluaextdata(alldata, itemid)
  661. local equipdata = {}
  662. equipdata.strengthlv = 0
  663. equipdata.appendlv = 0
  664. equipdata.strengthattr = {}
  665. equipdata.appendattr = {}
  666. alldata[itemid] = equipdata
  667. end
  668. --装备强化
  669. function EquipAndAppear.luastrengthequip(actor, msgData)
  670. local itemid = msgData.itemId
  671. local equip = getequipinfo(actor, itemid, 1)
  672. if equip == nil then
  673. return
  674. end
  675. local alldata = EquipAndAppear.getLuaItemExtData(actor)
  676. local equipdata = alldata[itemid]
  677. if equipdata == nil then
  678. EquipAndAppear.initequipluaextdata(alldata, itemid)
  679. equipdata = alldata[itemid]
  680. end
  681. if equipdata.strengthlv == nil then
  682. equipdata.strengthlv = 0
  683. equipdata.strengthattr = {}
  684. end
  685. local lv = equipdata.strengthlv + 1
  686. local cfgId = equip.cfgid
  687. --首饰的强化等级特殊处理
  688. local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
  689. if group ~= nil and group ~= "" then
  690. local strengthenmaxLevel =
  691. ConfigDataManager.getTableValue(
  692. "cfg_equip_ornaments",
  693. "strengthenmaxLevel",
  694. "ornamentsGroup",
  695. group,
  696. "lv",
  697. equipdata.ssuplv or 0
  698. )
  699. if tonumber(strengthenmaxLevel) < lv then
  700. sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已强化到最大等级")
  701. return
  702. end
  703. else
  704. local maxLevel = ConfigDataManager.getTableValue("cfg_equip_strengthen", "maxLevel", "id", cfgId)
  705. if tonumber(maxLevel) < lv then
  706. sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已强化到最大等级")
  707. return
  708. end
  709. end
  710. local costId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "costId", "id", cfgId)
  711. local groupId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "groupId", "id", cfgId)
  712. --获取消耗
  713. local coststr =
  714. ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "cost", "costGroupId", costId, "level", lv)
  715. if coststr == nil then
  716. return
  717. end
  718. local cost = splitbyshuxianandjinghao(coststr)
  719. --校验道具是否足够
  720. local enough = Bag.checkItemEnough(actor, cost)
  721. if enough == false then
  722. TimeLimitGift.checkSpecial2Condition(actor)
  723. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  724. return
  725. end
  726. --扣材料
  727. for _, v in ipairs(cost) do
  728. local cId = v["cfgid"]
  729. local count = v["count"]
  730. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  731. end
  732. TimeLimitGift.checkSpecial2Count(actor)
  733. --获取成功率
  734. local rate = ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "rate", "costGroupId", costId, "level", lv)
  735. local randomNumber = math.random(1, 10000)
  736. rate = tonumber(rate)
  737. if rate < randomNumber then
  738. --失败,校验是否等级回退
  739. local failLevel =
  740. ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "failLevel", "costGroupId", costId, "level", lv)
  741. failLevel = tonumber(failLevel)
  742. if not equip.isbind then
  743. changeitembindstate(actor,itemid,1)
  744. local res = {itemId = itemid,bindId = true}
  745. sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
  746. end
  747. if failLevel == equipdata.strengthlv then
  748. --给客户端发强化结果
  749. local dddd = {}
  750. dddd.itemId = itemid
  751. dddd.strengthlv = tonumber(failLevel)
  752. dddd.issuccess = false
  753. sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
  754. return
  755. end
  756. local att =
  757. ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", failLevel)
  758. local attr = splitbyshuxianandjinghao2(att)
  759. equipdata.strengthlv = failLevel
  760. equipdata.strengthattr = attr
  761. EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
  762. setplaydef(actor, "T$luaitemextdata", alldata)
  763. --更新强化追加等属性
  764. EquipAndAppear.updateluaextattr(actor)
  765. info(actor, "玩家", actor, "强化装备至" .. lv .. "级失败,失败后等级" .. failLevel, "道具id" .. itemid, "cfgId:" .. cfgId)
  766. --给客户端发强化结果
  767. local dddd = {}
  768. dddd.itemId = itemid
  769. dddd.strengthlv = tonumber(failLevel)
  770. dddd.issuccess = false
  771. sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
  772. EquipMaster.strengthMaster(actor)
  773. --装备强化之后发送装备强化信息
  774. EquipAndAppear.updateequipgmext(actor, itemid, dddd.strengthlv)
  775. return
  776. end
  777. --获取属性加成
  778. local att = ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", lv)
  779. local attr = splitbyshuxianandjinghao2(att)
  780. equipdata.strengthlv = lv
  781. equipdata.strengthattr = attr
  782. EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
  783. setplaydef(actor, "T$luaitemextdata", alldata)
  784. --更新强化追加等属性
  785. EquipAndAppear.updateluaextattr(actor)
  786. local firstRate =
  787. ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "firstRate", "costGroupId", costId, "level", lv)
  788. firstRate = tonumber(firstRate)
  789. if firstRate == 1 then
  790. --发送跑马灯
  791. local name = getrolefield(actor, "role.basic.name")
  792. local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  793. local content = "恭喜" .. name .. "将" .. equipName .. "强化至" .. lv .. "级"
  794. local horseled = {}
  795. horseled.content = content
  796. horseled.cfgId = 109 -- 109是直接写死的
  797. sendluamsg(actor, LuaMessageIdToClient.HORSE_LAMP, horseled)
  798. end
  799. info(actor, "玩家", actor, "强化装备至" .. lv .. "级成功", "道具id" .. itemid, "cfgId:" .. cfgId)
  800. if not equip.isbind then
  801. changeitembindstate(actor,itemid,1)
  802. local res = {itemId = itemid,bindId = true}
  803. sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
  804. end
  805. --给客户端发强化结果
  806. local dddd = {}
  807. dddd.itemId = itemid
  808. dddd.strengthlv = tonumber(lv)
  809. dddd.issuccess = true
  810. sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
  811. EquipMaster.strengthMaster(actor)
  812. --记录强化次数
  813. local oldCount = EquipAndAppear.GetEquipStrengthCount(actor)
  814. setplaydef(actor, ROLE_EQUIP_STRENGTH_TIMES, oldCount + 1)
  815. ---触发装备强化任务
  816. local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
  817. local taskParam = {
  818. part = strPart,
  819. level = lv
  820. }
  821. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.PARTS_STRENGTHEN_LV, taskParam)
  822. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_STRENGTHEN_TIMES, lv)
  823. this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL)
  824. --装备强化之后发送装备强化信息
  825. EquipAndAppear.updateequipgmext(actor, itemid, dddd.strengthlv)
  826. LogManager.RoleStrenthenEquip(actor)
  827. end
  828. ---获取玩家装备累计强化次数
  829. function EquipAndAppear.GetEquipStrengthCount(actor)
  830. local totalCount = getplaydef(actor, ROLE_EQUIP_STRENGTH_TIMES)
  831. if totalCount == nil then
  832. totalCount = 0
  833. end
  834. return totalCount
  835. end
  836. function EquipAndAppear.updateequipgmext(actor, itemid, strengthlv)
  837. -- local gmext = getequipgmext(actor,itemid)
  838. -- if gmext == nil or gmext == "null" then
  839. -- gmext = {}
  840. -- end
  841. local gmext = {}
  842. gmext.strengthlv = strengthlv
  843. setequipgmext(actor, itemid, gmext)
  844. end
  845. function splitbyshuxianandjinghao2(str)
  846. local dt = {}
  847. local data = string.split(str, "|")
  848. for _, v in ipairs(data) do
  849. local data2 = string.split(v, "#")
  850. dt[data2[1]] = data2[2]
  851. end
  852. return dt
  853. end
  854. --装备追加
  855. function EquipAndAppear.luaappendequip(actor, msgData)
  856. local itemid = msgData.itemId
  857. local equip = getequipinfo(actor, itemid, 1)
  858. if equip == nil then
  859. return
  860. end
  861. local alldata = EquipAndAppear.getLuaItemExtData(actor)
  862. local equipdata = alldata[itemid]
  863. if equipdata == nil then
  864. EquipAndAppear.initequipluaextdata(alldata, itemid)
  865. equipdata = alldata[itemid]
  866. end
  867. if equipdata.appendlv == nil then
  868. equipdata.appendlv = 0
  869. equipdata.appendattr = {}
  870. end
  871. local lv = equipdata.appendlv + 1
  872. local cfgId = equip.cfgid
  873. --首饰的强化等级特殊处理
  874. local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
  875. if group ~= nil and group ~= "" then
  876. local appendsmaxLevel =
  877. ConfigDataManager.getTableValue(
  878. "cfg_equip_ornaments",
  879. "appendsmaxLevel",
  880. "ornamentsGroup",
  881. group,
  882. "lv",
  883. equipdata.ssuplv or 0
  884. )
  885. if tonumber(appendsmaxLevel) < lv then
  886. sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已追加到最大等级")
  887. return
  888. end
  889. else
  890. local maxLevel = ConfigDataManager.getTableValue("cfg_equip_appends", "maxLevel", "id", cfgId)
  891. if tonumber(maxLevel) < lv then
  892. sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已追加到最大等级")
  893. return
  894. end
  895. end
  896. local costId = ConfigDataManager.getTableValue("cfg_equip_appends", "costId", "id", cfgId)
  897. local groupId = ConfigDataManager.getTableValue("cfg_equip_appends", "groupId", "id", cfgId)
  898. --获取消耗
  899. local coststr = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "cost", "costGroupId", costId, "level", lv)
  900. if coststr == nil then
  901. return
  902. end
  903. local cost = splitbyshuxianandjinghao(coststr)
  904. --校验道具是否足够
  905. local enough = Bag.checkItemEnough(actor, cost)
  906. if enough == false then
  907. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  908. return
  909. end
  910. --扣材料
  911. for _, v in ipairs(cost) do
  912. local cId = v["cfgid"]
  913. local count = v["count"]
  914. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  915. end
  916. --获取成功率
  917. local rate = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "rate", "costGroupId", costId, "level", lv)
  918. local randomNumber = math.random(1, 10000)
  919. rate = tonumber(rate)
  920. if rate < randomNumber then
  921. --失败,校验是否等级回退
  922. local failLevel =
  923. ConfigDataManager.getTableValue("cfg_equip_appendsCost", "failLevel", "costGroupId", costId, "level", lv)
  924. failLevel = tonumber(failLevel)
  925. if not equip.isbind then
  926. changeitembindstate(actor,itemid,1)
  927. local res = {itemId = itemid,bindId = true}
  928. sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
  929. end
  930. if failLevel == equipdata.appendlv then
  931. --给客户端发强化结果
  932. local dddd = {}
  933. dddd.itemId = itemid
  934. dddd.appendlv = tonumber(failLevel)
  935. dddd.issuccess = false
  936. sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
  937. return
  938. end
  939. local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", failLevel)
  940. local attr = splitbyshuxianandjinghao2(att)
  941. equipdata.appendlv = failLevel
  942. equipdata.appendattr = attr
  943. EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
  944. setplaydef(actor, "T$luaitemextdata", alldata)
  945. info(actor, "玩家", actor, "追加装备至" .. lv .. "级失败,失败后等级" .. failLevel, "道具id" .. itemid, "cfgId:" .. cfgId)
  946. --给客户端发强化结果
  947. local dddd = {}
  948. dddd.itemId = itemid
  949. dddd.appendlv = tonumber(failLevel)
  950. dddd.issuccess = false
  951. sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
  952. EquipMaster.appendMaster(actor)
  953. return
  954. end
  955. --获取属性加成
  956. local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", lv)
  957. local attr = splitbyshuxianandjinghao2(att)
  958. equipdata.appendlv = lv
  959. equipdata.appendattr = attr
  960. EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
  961. setplaydef(actor, "T$luaitemextdata", alldata)
  962. --更新强化追加等属性
  963. EquipAndAppear.updateluaextattr(actor)
  964. local firstRate =
  965. ConfigDataManager.getTableValue("cfg_equip_appendsCost", "firstRate", "costGroupId", costId, "level", lv)
  966. firstRate = tonumber(firstRate)
  967. if firstRate == 1 then
  968. --发送跑马灯
  969. local name = getrolefield(actor, "role.basic.name")
  970. local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  971. local content = "恭喜" .. name .. "将" .. equipName .. "追加至" .. lv .. "级"
  972. local horseled = {}
  973. horseled.cfgId = 115
  974. horseled.content = content
  975. sendluamsg(actor, LuaMessageIdToClient.HORSE_LAMP, horseled)
  976. end
  977. --给客户端发强化结果
  978. local dddd = {}
  979. dddd.itemId = itemid
  980. dddd.appendlv = tonumber(lv)
  981. dddd.issuccess = true
  982. sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
  983. info(actor, "玩家", actor, "追加装备至" .. lv .. "级成功", "道具id" .. itemid, "cfgId:" .. cfgId)
  984. if not equip.isbind then
  985. changeitembindstate(actor,itemid,1)
  986. local res = {itemId = itemid,bindId = true}
  987. sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
  988. end
  989. EquipMaster.appendMaster(actor)
  990. this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_APPEND_LEVEL)
  991. -- 刷新任务进度
  992. local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
  993. local taskParam = {
  994. part = strPart,
  995. level = lv
  996. }
  997. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_APPEND, taskParam)
  998. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_APPEND_TOTAL_LV)
  999. LogManager.RoleAppendEquip(actor)
  1000. end
  1001. --- 获取所有装备数据
  1002. function EquipAndAppear.getLuaItemExtData(actor)
  1003. local alldata = getplaydef(actor, "T$luaitemextdata")
  1004. if alldata == nil then
  1005. --说明还没有进行过锻造
  1006. setplaydef(actor, "T$luaitemextdata", {})
  1007. alldata = getplaydef(actor, "T$luaitemextdata")
  1008. end
  1009. return alldata
  1010. end
  1011. --装备属性转移
  1012. function EquipAndAppear.luatransferequip(actor, msgData)
  1013. local firstId = msgData.firstItem
  1014. local secId = msgData.secondItem
  1015. local equip1 = getequipinfo(actor, firstId, 1)
  1016. if equip1 == nil then
  1017. return
  1018. end
  1019. local equip2 = getequipinfo(actor, secId, 1)
  1020. if equip2 == nil then
  1021. return
  1022. end
  1023. local id1 = equip1.cfgid
  1024. local id2 = equip2.cfgid
  1025. local data1 = ConfigDataManager.getTable("cfg_equip_transfer", "id", id1)
  1026. local data2 = ConfigDataManager.getTable("cfg_equip_transfer", "id", id2)
  1027. if
  1028. (data1 == nil) or (data2 == nil) or (data1.transferGroup ~= data2.transferGroup) or
  1029. (data1.transfer ~= data2.transfer)
  1030. then
  1031. return
  1032. end
  1033. local ts = msgData.transferStrength -- bool类型
  1034. local ta = msgData.transferAppend
  1035. local tr = msgData.transferRegeneration
  1036. if not ts and not ta and not tr then
  1037. return
  1038. end
  1039. --扩展数据
  1040. local extdata = getplaydef(actor, "T$luaitemextdata")
  1041. local ext1 = extdata[firstId]
  1042. local ext2 = extdata[secId]
  1043. if ext2 == nil then
  1044. ext2 = {}
  1045. ext2.appendattr = {}
  1046. ext2.strengthattr = {}
  1047. ext2.appendlv = 0
  1048. ext2.strengthlv = 0
  1049. end
  1050. --转移前强化追加
  1051. info(
  1052. actor,
  1053. "转移前强化追加等级,rid:",
  1054. actor,
  1055. "强化等级:",
  1056. ext1.strengthlv,
  1057. ext2.strengthlv,
  1058. "追加等级:",
  1059. ext1.appendlv,
  1060. ext2.appendlv,
  1061. "主装备id:" .. firstId .. "主装备cfgId:" .. id1,
  1062. "副装备id:" .. secId .. "副装备cfgId:" .. id2
  1063. )
  1064. local allCost = {}
  1065. --强化消耗
  1066. if ts then
  1067. local lv1 = ext1.strengthlv
  1068. local lv2 = ext2.strengthlv
  1069. if lv2 ~= 0 then
  1070. return
  1071. end
  1072. local costItem = data1[1].strengthencost
  1073. local cost = splittransfercoststr(costItem)
  1074. local realLv = 0
  1075. local realCost = {}
  1076. for key, value in pairs(cost) do
  1077. if key > realLv and key <= lv1 then
  1078. realLv = key
  1079. realCost = value
  1080. end
  1081. end
  1082. table.insert(allCost, realCost)
  1083. end
  1084. if table.count(allCost[1]) == 0 then
  1085. allCost[1] = {}
  1086. end
  1087. --追加消耗
  1088. if ta then
  1089. local lv1 = ext1.appendlv
  1090. local lv2 = ext2.appendlv
  1091. if lv2 ~= 0 then
  1092. return
  1093. end
  1094. local costItem = data1[1].appendscost
  1095. local cost = splittransfercoststr(costItem)
  1096. local realLv = 0
  1097. local realCost = {}
  1098. for key, value in pairs(cost) do
  1099. if key > realLv and key <= lv1 then
  1100. realLv = key
  1101. realCost = value
  1102. end
  1103. end
  1104. for _, value in pairs(realCost) do
  1105. local cId = value["cfgid"]
  1106. local num = value["count"]
  1107. local n = 0
  1108. for _1, v in pairs(allCost[1]) do
  1109. if v["cfgid"] == cId then
  1110. v["count"] = v["count"] + num
  1111. n = n + 1
  1112. end
  1113. end
  1114. if n == 0 then
  1115. table.insert(allCost[1], value)
  1116. end
  1117. end
  1118. end
  1119. --再生消耗
  1120. if tr then
  1121. local lv1 = ext1.regenerationlv
  1122. local lv2 = ext2.regenerationlv
  1123. if lv2 == nil then
  1124. ext2.regenerationlv = 0
  1125. lv2 = 0
  1126. end
  1127. if lv2 ~= 0 then
  1128. return
  1129. end
  1130. local costItem = data1[1].regenerationcost
  1131. local cost = splittransfercoststr(costItem)
  1132. local realLv = 0
  1133. local realCost = {}
  1134. for key, value in pairs(cost) do
  1135. if key > realLv and key <= lv1 then
  1136. realLv = key
  1137. realCost = value
  1138. end
  1139. end
  1140. for _, value in pairs(realCost) do
  1141. local cId = value["cfgid"]
  1142. local num = value["count"]
  1143. local n = 0
  1144. for _1, v in pairs(allCost[1]) do
  1145. if v["cfgid"] == cId then
  1146. v["count"] = v["count"] + num
  1147. n = n + 1
  1148. end
  1149. end
  1150. if n == 0 then
  1151. table.insert(allCost[1], value)
  1152. end
  1153. end
  1154. end
  1155. --检查道具是否足够
  1156. local enough = Bag.checkItemEnough(actor, allCost[1])
  1157. if not enough then
  1158. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  1159. return
  1160. end
  1161. --扣道具
  1162. for _, v in ipairs(allCost[1]) do
  1163. local cId = v["cfgid"]
  1164. local count = v["count"]
  1165. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  1166. end
  1167. --转移强化
  1168. if ts then
  1169. local slv1 = ext1.strengthlv
  1170. ext2.strengthlv = slv1
  1171. ext1.strengthlv = 0
  1172. ext1.strengthattr = {}
  1173. --赋值属性
  1174. local maxLv = ConfigDataManager.getTableValue("cfg_equip_strengthen", "maxLevel", "id", equip2.cfgid)
  1175. local groupId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "groupId", "id", equip2.cfgid)
  1176. if ext2.strengthlv > tonumber(maxLv) then
  1177. ext2.strengthlv = tonumber(maxLv)
  1178. end
  1179. local att =
  1180. ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", ext2.strengthlv)
  1181. local attr = splitbyshuxianandjinghao2(att)
  1182. ext2.strengthattr = attr
  1183. EquipAndAppear.updateequipgmext(actor, firstId, 0)
  1184. EquipAndAppear.updateequipgmext(actor, secId, ext2.strengthlv)
  1185. end
  1186. --转移追加
  1187. if ta then
  1188. local slv1 = ext1.appendlv
  1189. ext2.appendlv = slv1
  1190. ext1.appendlv = 0
  1191. ext1.appendattr = {}
  1192. --赋值属性
  1193. local maxLv = ConfigDataManager.getTableValue("cfg_equip_appends", "maxLevel", "id", equip2.cfgid)
  1194. local groupId = ConfigDataManager.getTableValue("cfg_equip_appends", "groupId", "id", equip2.cfgid)
  1195. if ext2.appendlv > tonumber(maxLv) then
  1196. ext2.appendlv = tonumber(maxLv)
  1197. end
  1198. local att =
  1199. ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", ext2.appendlv)
  1200. local attr = splitbyshuxianandjinghao2(att)
  1201. ext2.appendattr = attr
  1202. end
  1203. --转移再生
  1204. if tr then
  1205. local relv = ext1.regenerationlv
  1206. ext2.regenerationlv = relv
  1207. ext1.regenerationlv = 0
  1208. ext2.regenerationattr = {}
  1209. --赋值属性
  1210. local maxLv = ConfigDataManager.getTableValue("cfg_equip_regeneration", "levelMax", "id", equip2.cfgid)
  1211. local groupId = ConfigDataManager.getTableValue("cfg_equip_regeneration", "Group", "id", equip2.cfgid)
  1212. if ext2.regenerationlv > tonumber(maxLv) then
  1213. ext2.regenerationlv = tonumber(maxLv)
  1214. end
  1215. local regeattr = ext1.regenerationattr
  1216. for _, value in pairs(regeattr) do
  1217. local id = value.id
  1218. local regenerationgroup = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
  1219. if table.count(regenerationgroup) ~= 0 then
  1220. local sequence = regenerationgroup[1].sequence
  1221. --找对应的表
  1222. local nexttable =
  1223. ConfigDataManager.getTable(
  1224. "cfg_equip_regenerationGroup",
  1225. "group",
  1226. groupId,
  1227. "sequence",
  1228. sequence,
  1229. "level",
  1230. ext2.regenerationlv
  1231. )
  1232. if table.count(nexttable) ~= 0 then
  1233. local att = nexttable[1].att
  1234. local str = string.split(att, "#")
  1235. local dd = {}
  1236. dd[str[1]] = tonumber(str[2])
  1237. dd.id = tonumber(nexttable[1].id)
  1238. ext2.regenerationattr[tostring(table.count(ext2.regenerationattr) + 1)] = dd
  1239. end
  1240. end
  1241. end
  1242. ext1.regenerationattr = {}
  1243. end
  1244. --更新数据
  1245. extdata[firstId] = ext1
  1246. extdata[secId] = ext2
  1247. EquipAndAppear.SetItemExtData(actor, firstId, ext1)
  1248. EquipAndAppear.SetItemExtData(actor, secId, ext2)
  1249. setplaydef(actor, "T$luaitemextdata", extdata)
  1250. EquipAndAppear.updateluaextattr(actor)
  1251. --转移后强化追加
  1252. info(
  1253. actor,
  1254. "转移后强化追加等级,rid:",
  1255. actor,
  1256. "强化等级:",
  1257. ext1.strengthlv,
  1258. ext2.strengthlv,
  1259. "追加等级:",
  1260. ext1.appendlv,
  1261. ext2.appendlv,
  1262. "主装备id:" .. firstId .. "主装备cfgId:" .. id1,
  1263. "副装备id:" .. secId .. "副装备cfgId:" .. id2
  1264. )
  1265. if not equip2.isbind then
  1266. changeitembindstate(actor,secId,1)
  1267. local res = {itemId = secId,bindId = true}
  1268. sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
  1269. end
  1270. --检查主装备是否还有强化追加属性
  1271. if this.checkEquipStrengthAndAppend(actor,firstId) then
  1272. --变为非绑定
  1273. changeitembindstate(actor,firstId,0)
  1274. local res = {itemId = firstId,bindId = false}
  1275. sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
  1276. end
  1277. EquipMaster.transferTrigger(actor, equip1, equip2, ts, ta)
  1278. --发送lua消息到客户端
  1279. local data = {}
  1280. data.oldItem = firstId
  1281. data.newItem = secId
  1282. data.issuccess = true
  1283. sendluamsg(actor, LuaMessageIdToClient.RES_TRANSFER_EQUIP, data)
  1284. end
  1285. function this.checkEquipStrengthAndAppend(actor,itemId)
  1286. local allData = EquipAndAppear.getLuaItemExtData(actor)
  1287. local equipData = allData[tonumber(itemId)]
  1288. if not equipData then
  1289. return true
  1290. end
  1291. local strengthlv = equipData.strengthlv
  1292. local appendlv = equipData.appendlv
  1293. if (strengthlv == 0) and (appendlv == 0) then
  1294. return true
  1295. end
  1296. return false
  1297. end
  1298. function EquipAndAppear.checkCanTransfer(actor, firstId, secId)
  1299. if firstId == 0 then
  1300. return
  1301. end
  1302. local data = {}
  1303. data.oldItem = firstId
  1304. data.newItem = secId
  1305. sendluamsg(actor, LuaMessageIdToClient.RES_CAN_TRANSFER, data)
  1306. end
  1307. function splittransfercoststr(str)
  1308. local s = string.split(str, "|")
  1309. local data = {}
  1310. for _, value in pairs(s) do
  1311. local x = string.split(value, "#")
  1312. local len = #x
  1313. local itemList = {}
  1314. if len == 3 then
  1315. local item = {}
  1316. item["cfgid"] = x[2]
  1317. item["count"] = x[3]
  1318. table.insert(itemList, item)
  1319. else
  1320. if len > 3 then
  1321. for i = 1, len do
  1322. local item = {}
  1323. if i == 1 then
  1324. item["cfgid"] = x[i + 1]
  1325. item["count"] = x[i + 2]
  1326. i = i + 3
  1327. else
  1328. item["cfgid"] = x[i]
  1329. item["count"] = x[i + 1]
  1330. i = i + 2
  1331. end
  1332. table.insert(itemList, item)
  1333. end
  1334. end
  1335. end
  1336. data[tonumber(x[1])] = itemList
  1337. end
  1338. return data
  1339. end
  1340. function EquipAndAppear.updateluaextattr(actor)
  1341. local alldata = getplaydef(actor, "T$luaitemextdata")
  1342. local equiplist = getputonequipinfo(actor)
  1343. local allattr = {}
  1344. for _, equipinfo in pairs(equiplist) do
  1345. local itemId = equipinfo.id
  1346. local data = alldata[itemId]
  1347. if data ~= nil then
  1348. --将该装备的属性加到角色身上
  1349. if data.strengthlv ~= nil then
  1350. local strengthattr = data.strengthattr
  1351. table.mergeAdd(allattr, strengthattr)
  1352. end
  1353. if data.appendlv ~= nil then
  1354. local appendattr = data.appendattr
  1355. table.mergeAdd(allattr, appendattr)
  1356. end
  1357. if data.ssuplv ~= nil then
  1358. local ssupattr = data.ssupattr
  1359. local ssactattr = data.ssactattr
  1360. table.mergeAdd(allattr, ssupattr)
  1361. table.mergeAdd(allattr, ssactattr)
  1362. end
  1363. if data.regenerationlv ~= nil then
  1364. local reattr = data.regenerationattr
  1365. local regenerationattr = {}
  1366. for _, att in pairs(reattr) do
  1367. for key, value in pairs(att) do
  1368. if key ~= "id" then
  1369. local num = regenerationattr[key]
  1370. if num == nil then
  1371. num = 0
  1372. end
  1373. regenerationattr[key] = num + value
  1374. end
  1375. end
  1376. end
  1377. table.mergeAdd(allattr, regenerationattr)
  1378. end
  1379. end
  1380. end
  1381. --更新装备记录
  1382. this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_ENTRY_COUNT)
  1383. --记录强化追加等属性
  1384. if table.count(allattr) == 0 then
  1385. addrolekmlattributes(actor, "luaextdataforever", {})
  1386. return
  1387. end
  1388. addrolekmlattributes(actor, "luaextdataforever", allattr)
  1389. end
  1390. --首饰升级
  1391. function EquipAndAppear.ssupdate(actor, msgData)
  1392. local itemId = msgData["itemId"]
  1393. local allequip = getplaydef(actor, "T$luaitemextdata")
  1394. local equipext = allequip[itemId]
  1395. if equipext == nil then
  1396. equipext = {}
  1397. end
  1398. if equipext.ssuplv == nil then
  1399. equipext.ssupattr = {}
  1400. equipext.ssuplv = 0
  1401. equipext.ssactlv = {}
  1402. equipext.ssactattr = {}
  1403. end
  1404. local equip = getequipinfo(actor, itemId, 1)
  1405. local cfgId = equip.cfgid
  1406. local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
  1407. if group == nil then
  1408. return
  1409. end
  1410. local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", equipext.ssuplv)
  1411. if ornaments == nil or table.count(ornaments) == 0 then
  1412. return
  1413. end
  1414. local ornaments2 = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", (equipext.ssuplv or 0) + 1)
  1415. if ornaments2 == nil or table.count(ornaments2) == 0 then
  1416. sendluamsg(actor, LuaMessageIdToClient.TIPS, "已经是最大等级!")
  1417. return
  1418. end
  1419. local data = ornaments2[1]
  1420. local cost = ornaments[1].lvdeplete
  1421. local costItem = splitbyshuxianandjinghao(cost)
  1422. --检查背包是否道具充足
  1423. local enough = Bag.checkItemEnough(actor, costItem)
  1424. if enough == false then
  1425. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  1426. return
  1427. end
  1428. --扣材料
  1429. for _, v in ipairs(costItem) do
  1430. local cId = v["cfgid"]
  1431. local count = v["count"]
  1432. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  1433. end
  1434. --升级,加属性
  1435. equipext.ssuplv = tonumber(data.lv)
  1436. local att = data.basicatt
  1437. local attr = splitbyshuxianandjinghao2(att)
  1438. equipext.ssupattr = attr
  1439. allequip[itemId] = equipext
  1440. EquipAndAppear.SetItemExtData(actor, itemId, equipext)
  1441. setplaydef(actor, "T$luaitemextdata", allequip)
  1442. --升级成功 回包给客户端
  1443. local result = {}
  1444. result.ssupattr = equipext.ssupattr
  1445. result.ssuplv = tostring(equipext.ssuplv)
  1446. result.ssactlv = equipext.ssactlv
  1447. result.ssactattr = equipext.ssactattr
  1448. result.itemId = itemId
  1449. sendluamsg(actor, LuaMessageIdToClient.RES_UPDATE_EQUIP_ORNAMENTS, result)
  1450. --更新属性
  1451. EquipAndAppear.updateluaextattr(actor)
  1452. --更新等级记录
  1453. this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL)
  1454. -- 刷新任务进度
  1455. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.JEWELRY_LV_UP)
  1456. end
  1457. --首饰等级属性激活
  1458. function EquipAndAppear.actssattr(actor, msgData)
  1459. local itemId = msgData["itemId"]
  1460. local lv = msgData["lv"]
  1461. local allequip = getplaydef(actor, "T$luaitemextdata")
  1462. local equipext = allequip[itemId]
  1463. if equipext.ssuplv == nil then
  1464. return
  1465. end
  1466. local equip = getequipinfo(actor, itemId, 1)
  1467. local cfgId = equip.cfgid
  1468. local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
  1469. local ssuplv = equipext.ssuplv
  1470. if ssuplv < lv then
  1471. return
  1472. end
  1473. if table.contains(equipext.ssactlv, lv) then
  1474. return
  1475. end
  1476. local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", lv)
  1477. if table.count(ornaments) == 0 then
  1478. return
  1479. end
  1480. if ornaments[1].unlockdeplete == nil then
  1481. return
  1482. end
  1483. local unlockDeplete = ornaments[1].unlockdeplete
  1484. if unlockDeplete == nil then
  1485. return
  1486. end
  1487. local costItem = splitbyshuxianandjinghao(unlockDeplete)
  1488. --检查背包是否道具充足
  1489. local enough = Bag.checkItemEnough(actor, costItem)
  1490. if enough == false then
  1491. return
  1492. end
  1493. --扣材料
  1494. for _, v in ipairs(costItem) do
  1495. local cId = v["cfgid"]
  1496. local count = v["count"]
  1497. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  1498. end
  1499. equipext.ssactlv[tostring(lv)] = lv
  1500. local att = ornaments[1].excellenceatt
  1501. local attr = splitbyshuxianandjinghao2(att)
  1502. table.mergeAdd(equipext.ssactattr, attr)
  1503. allequip[itemId] = equipext
  1504. EquipAndAppear.SetItemExtData(actor, itemId, equipext)
  1505. setplaydef(actor, "T$luaitemextdata", allequip)
  1506. --发送回包给客户端
  1507. local result = {}
  1508. result.ssupattr = equipext.ssupattr
  1509. result.ssuplv = equipext.ssuplv
  1510. result.ssactlv = equipext.ssactlv
  1511. result.ssactattr = equipext.ssactattr
  1512. result.itemId = itemId
  1513. sendluamsg(actor, LuaMessageIdToClient.RES_ACT_EQUIP_ORNAMENTS, result)
  1514. --更新属性
  1515. EquipAndAppear.updateluaextattr(actor)
  1516. end
  1517. function EquipAndAppear.allequipstrengthlv(actor)
  1518. local alldata = getplaydef(actor, "T$luaitemextdata")
  1519. local equiplist = getputonequipinfo(actor)
  1520. local allequipstrengthlv = 0
  1521. for _, equipinfo in pairs(equiplist) do
  1522. local itemId = equipinfo.id
  1523. local data = alldata[itemId]
  1524. if data ~= nil then
  1525. if data.strengthlv ~= nil then
  1526. allequipstrengthlv = allequipstrengthlv + data.strengthlv
  1527. end
  1528. end
  1529. end
  1530. return allequipstrengthlv
  1531. end
  1532. function EquipAndAppear.allequipappendlv(actor)
  1533. local alldata = getplaydef(actor, "T$luaitemextdata")
  1534. local equiplist = getputonequipinfo(actor)
  1535. local allequipstrengthlv = 0
  1536. for _, equipinfo in pairs(equiplist) do
  1537. local itemId = equipinfo.id
  1538. local data = alldata[itemId]
  1539. if data ~= nil then
  1540. if data.appendlv ~= nil then
  1541. allequipstrengthlv = allequipstrengthlv + data.appendlv
  1542. end
  1543. end
  1544. end
  1545. return allequipstrengthlv
  1546. end
  1547. --再生
  1548. function EquipAndAppear.regeneration(actor, msgData)
  1549. local itemId = msgData["itemId"]
  1550. local equip = getequipinfo(actor, itemId, 1)
  1551. local allequip = getplaydef(actor, "T$luaitemextdata")
  1552. local ext = allequip[itemId]
  1553. if ext == nil then
  1554. ext = {}
  1555. ext.regenerationlv = 0
  1556. ext.regenerationattr = {}
  1557. end
  1558. if ext.regenerationlv == nil then
  1559. ext.regenerationlv = 0
  1560. ext.regenerationattr = {}
  1561. end
  1562. local lv = ext.regenerationlv
  1563. local tabledata = ConfigDataManager.getTable("cfg_equip_regeneration", "id", equip.cfgid)
  1564. if table.count(tabledata) == 0 then
  1565. return
  1566. end
  1567. local group = tabledata[1].group
  1568. --获取消耗
  1569. local lockattr = msgData["lockattrpos"]
  1570. local startcost = {}
  1571. local type = 0
  1572. if table.count(ext.regenerationattr) == 0 then
  1573. startcost = tabledata[1].start
  1574. type = 1
  1575. else
  1576. if table.count(lockattr) == 0 then
  1577. startcost = tabledata[1].again
  1578. type = 2
  1579. else
  1580. startcost = tabledata[1].lock
  1581. type = 3
  1582. end
  1583. end
  1584. local cost = getlockcost(startcost, lockattr)
  1585. --校验道具是否足够
  1586. local enough = Bag.checkItemEnough(actor, cost)
  1587. if enough == false then
  1588. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  1589. return
  1590. end
  1591. --扣道具
  1592. for _, v in ipairs(cost) do
  1593. local cId = v["cfgid"]
  1594. local count = v["count"]
  1595. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  1596. end
  1597. --随机词条数量
  1598. local attrNum = {}
  1599. if type == 1 then
  1600. attrNum = tabledata[1].startnum
  1601. else
  1602. if type == 2 then
  1603. attrNum = tabledata[1].againnum
  1604. else
  1605. if type == 3 then
  1606. attrNum = tabledata[1].locknum
  1607. end
  1608. end
  1609. end
  1610. local result = random_weighted(attrNum, 1)
  1611. if lv == 0 then
  1612. lv = 1
  1613. end
  1614. --校验词条数是否超过最大值
  1615. local maxAttrNum = tabledata[1].count
  1616. local realNum = result[1] + table.count(lockattr)
  1617. if realNum >= tonumber(maxAttrNum) then
  1618. realNum = tonumber(maxAttrNum) - table.count(lockattr)
  1619. else
  1620. realNum = result[1]
  1621. end
  1622. local attdata = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "group", group, "level", lv)
  1623. local entrytable = build_weight_attr(attdata, ext.regenerationattr, lockattr)
  1624. local entryattr = random_weighted(entrytable, realNum)
  1625. --把这次结果临时存一下
  1626. local xilianattr = {}
  1627. for _, key in pairs(lockattr) do
  1628. xilianattr[tostring(table.count(xilianattr) + 1)] = tonumber(key)
  1629. end
  1630. for _, key in pairs(entryattr) do
  1631. xilianattr[tostring(table.count(xilianattr) + 1)] = tonumber(key)
  1632. end
  1633. local allequiprecord = getplaydef(actor, "T$regeneration")
  1634. if allequiprecord == nil then
  1635. allequiprecord = {}
  1636. end
  1637. local regenerationresult = {}
  1638. regenerationresult.entryAttr = xilianattr
  1639. regenerationresult.itemId = itemId
  1640. allequiprecord[itemId] = regenerationresult
  1641. setplaydef(actor, "T$regeneration", allequiprecord)
  1642. allequip[itemId] = ext
  1643. setplaydef(actor, "T$luaitemextdata", allequip)
  1644. --告诉客户端本次洗练结果
  1645. sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_REGENERATION, xilianattr)
  1646. end
  1647. function EquipAndAppear.getupregenerationattr(actor, msgData)
  1648. local itemId = msgData.itemId
  1649. local data = getplaydef(actor, "T$regeneration")
  1650. if data == nil then
  1651. sendluamsg(actor, LuaMessageIdToClient.RES_UP_REGENERATION_ATTR, {})
  1652. return
  1653. end
  1654. local result = data[itemId]
  1655. if result == nil then
  1656. result = {}
  1657. end
  1658. sendluamsg(actor, LuaMessageIdToClient.RES_UP_REGENERATION_ATTR, result)
  1659. end
  1660. --确认替换词条
  1661. function EquipAndAppear.confirmreplaceentry(actor, msgData)
  1662. -- local lockattr = msgData.lockattrpos
  1663. local itemId = msgData.itemId
  1664. local alldata = getplaydef(actor, "T$regeneration")
  1665. if alldata == nil then
  1666. sendluamsg(actor, LuaMessageIdToClient.TIPS, "洗练后再进行替换!")
  1667. return
  1668. end
  1669. local data = alldata[itemId]
  1670. if data == nil then
  1671. sendluamsg(actor, LuaMessageIdToClient.TIPS, "洗练后再进行替换!")
  1672. return
  1673. end
  1674. if data.itemId ~= itemId then
  1675. sendluamsg(actor, LuaMessageIdToClient.TIPS, "两次itemId不一致!")
  1676. return
  1677. end
  1678. local allequip = getplaydef(actor, "T$luaitemextdata")
  1679. local ext = allequip[itemId]
  1680. ext.regenerationattr = {}
  1681. for _, id in pairs(data.entryAttr) do
  1682. local td = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
  1683. if table.count(td) ~= 0 then
  1684. local attr = td[1].att
  1685. local str = string.split(attr, "#")
  1686. local dd = {}
  1687. dd[str[1]] = tonumber(str[2])
  1688. dd.id = id
  1689. ext.regenerationattr[tostring(table.count(ext.regenerationattr) + 1)] = dd
  1690. ext.regenerationlv = tonumber(td[1].level)
  1691. end
  1692. end
  1693. allequip[itemId] = ext
  1694. EquipAndAppear.SetItemExtData(actor, itemId, ext)
  1695. setplaydef(actor, "T$luaitemextdata", allequip)
  1696. alldata[itemId] = {}
  1697. setplaydef(actor, "T$regeneration", alldata)
  1698. --给客户端发替换结果
  1699. sendluamsg(actor, LuaMessageIdToClient.RES_REPLACE_REGENERATION_ATTR, true)
  1700. --更新强化追加等属性
  1701. EquipAndAppear.updateluaextattr(actor)
  1702. end
  1703. --词条强化
  1704. function EquipAndAppear.strengthregenerationattr(actor, msgData)
  1705. local itemId = msgData.itemId
  1706. local allequip = getplaydef(actor, "T$luaitemextdata")
  1707. local ext = allequip[itemId]
  1708. local equip = getequipinfo(actor, itemId, 1)
  1709. local group = ConfigDataManager.getTableValue("cfg_equip_regeneration", "group", "id", equip.cfgid)
  1710. local lv = ext.regenerationlv
  1711. local data = ConfigDataManager.getTable("cfg_equip_regenerationCost", "group", group, "level", lv)
  1712. if table.count(data) == 0 then
  1713. sendluamsg(actor, LuaMessageIdToClient.TIPS, "当前装备词条不能强化!")
  1714. return
  1715. end
  1716. local maxLevel = ConfigDataManager.getTableValue("cfg_equip_regeneration", "levelMax", "id", equip.cfgid)
  1717. if tonumber(maxLevel) < lv + 1 then
  1718. sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已再生到最大等级")
  1719. return
  1720. end
  1721. local str = data[1].cost
  1722. local cost = splitbyshuxianandjinghao(str)
  1723. --检查材料
  1724. local enough = Bag.checkItemEnough(actor, cost)
  1725. if enough == false then
  1726. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  1727. return
  1728. end
  1729. --扣道具
  1730. for _, v in ipairs(cost) do
  1731. local cId = v["cfgid"]
  1732. local count = v["count"]
  1733. removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
  1734. end
  1735. --计算成功率
  1736. local rate = data[1].rate
  1737. local randomNum = math.random(1, 10000)
  1738. if randomNum > tonumber(rate) then
  1739. --强化失败
  1740. sendluamsg(actor, LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR, false)
  1741. return
  1742. end
  1743. --强化成功增加属性
  1744. local regenerationattr = ext.regenerationattr
  1745. for i, value in pairs(regenerationattr) do
  1746. local key = value.id
  1747. local data = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", key)
  1748. if table.count(data) ~= 0 then
  1749. local sequence = data[1].sequence
  1750. --查找下一级属性
  1751. local nextdata =
  1752. ConfigDataManager.getTable(
  1753. "cfg_equip_regenerationGroup",
  1754. "group",
  1755. group,
  1756. "sequence",
  1757. sequence,
  1758. "level",
  1759. lv + 1
  1760. )
  1761. if table.count(nextdata) ~= 0 then
  1762. local att = nextdata[1].att
  1763. local attr = string.split(att, "#")
  1764. local dd = {}
  1765. dd[attr[1]] = tonumber(attr[2])
  1766. dd.id = tonumber(nextdata[1].id)
  1767. ext.regenerationattr[i] = dd
  1768. -- table.remove(ext.regenerationattr,key)
  1769. end
  1770. end
  1771. end
  1772. ext.regenerationlv = lv + 1
  1773. allequip[itemId] = ext
  1774. EquipAndAppear.SetItemExtData(actor, itemId, ext)
  1775. setplaydef(actor, "T$luaitemextdata", allequip)
  1776. --给客户端发消息
  1777. sendluamsg(actor, LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR, true)
  1778. --更新强化追加等属性
  1779. EquipAndAppear.updateluaextattr(actor)
  1780. --更新洗练未替换的数据
  1781. updateregenoreplaceattr(actor, itemId, ext.regenerationlv, group)
  1782. end
  1783. function updateregenoreplaceattr(actor, itemId, lv, group)
  1784. local alldata = getplaydef(actor, "T$regeneration")
  1785. if alldata == nil then
  1786. return
  1787. end
  1788. local data = alldata[itemId]
  1789. if data == nil then
  1790. return
  1791. end
  1792. local attrs = data.entryAttr
  1793. if attrs == nil then
  1794. return
  1795. end
  1796. for i, id in pairs(data.entryAttr) do
  1797. local td = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
  1798. if table.count(td) ~= 0 then
  1799. local sequence = td[1].sequence
  1800. --查找对应等级属性
  1801. local nextdata =
  1802. ConfigDataManager.getTable(
  1803. "cfg_equip_regenerationGroup",
  1804. "group",
  1805. group,
  1806. "sequence",
  1807. sequence,
  1808. "level",
  1809. lv
  1810. )
  1811. if table.count(nextdata) ~= 0 then
  1812. attrs[i] = tonumber(nextdata[1].id)
  1813. end
  1814. end
  1815. end
  1816. data.entryAttr = attrs
  1817. alldata[itemId] = data
  1818. setplaydef(actor, "T$regeneration", alldata)
  1819. end
  1820. function mergeitemcost(cost, lockcost)
  1821. for _, item in pairs(lockcost) do
  1822. local flag = true
  1823. for _, value in pairs(cost) do
  1824. if item.cfgid == value.cfgid then
  1825. value.count = value.count + item.count
  1826. flag = false
  1827. end
  1828. end
  1829. if flag then
  1830. table.insert(cost, item)
  1831. end
  1832. end
  1833. return cost
  1834. end
  1835. function getlockcost(cost, lockattr)
  1836. local result = {}
  1837. local locknum = table.count(lockattr)
  1838. local lc = string.split(cost, "|")
  1839. local str = {}
  1840. if locknum ~= 0 then
  1841. str = string.split(lc[locknum], "&")
  1842. for _, value in pairs(str) do
  1843. local item = string.split(value, "#")
  1844. local i = {}
  1845. i.cfgid = item[1]
  1846. i.count = item[2]
  1847. table.insert(result, i)
  1848. end
  1849. else
  1850. result = splitbyshuxianandjinghao(cost)
  1851. end
  1852. return result
  1853. end
  1854. --根据权重随机词条数量
  1855. function random_weighted(weight_str, count)
  1856. local result = {}
  1857. if count <= 0 then
  1858. return result
  1859. end
  1860. local num = string.split(weight_str, "&")
  1861. local weight_total = 0
  1862. for _, value in pairs(num) do
  1863. local sum = string.split(value, "#")
  1864. weight_total = weight_total + tonumber(sum[2])
  1865. end
  1866. local random_weight = math.random(1, weight_total)
  1867. local cumulative_weight = 0
  1868. for _, value in pairs(num) do
  1869. local sum = string.split(value, "#")
  1870. local weight = tonumber(sum[2])
  1871. cumulative_weight = cumulative_weight + weight
  1872. if cumulative_weight >= random_weight then
  1873. table.insert(result, tonumber(sum[1]))
  1874. if table.count(result) == count then
  1875. return result
  1876. end
  1877. end
  1878. end
  1879. end
  1880. --构造随机词条权重库
  1881. function build_weight_attr(attdata, regenenrationattr, lockattr)
  1882. local entrystr = ""
  1883. for i, value in pairs(attdata) do
  1884. local len = #entrystr
  1885. local id = value.id
  1886. local flag = true
  1887. for _, k in pairs(lockattr) do
  1888. if k == id then
  1889. table.remove(attdata, i)
  1890. flag = false
  1891. end
  1892. end
  1893. if flag then
  1894. local weight = 0
  1895. for key, v in pairs(regenenrationattr) do
  1896. if key == id then
  1897. weight = value.weightdown
  1898. end
  1899. end
  1900. if weight == 0 then
  1901. weight = value.weight
  1902. end
  1903. if len == 0 then
  1904. entrystr = id .. "#" .. weight
  1905. else
  1906. entrystr = entrystr .. "&" .. id .. "#" .. weight
  1907. end
  1908. end
  1909. end
  1910. return entrystr
  1911. end
  1912. function getequipssumstrengthlvtest(actor)
  1913. this.GetSumJewelryLv(actor)
  1914. end
  1915. ---获取角色全身装备强化等级
  1916. function EquipAndAppear.GetEquipsSumStrengthLv(actor)
  1917. return this.GetSumLvByType(actor, EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL)
  1918. end
  1919. ---获取角色全身装备追加等级
  1920. function EquipAndAppear.GetEquipsSumAppendLv(actor)
  1921. return this.GetSumLvByType(actor, EquipAndAppear.RecordeType.MAX_APPEND_LEVEL)
  1922. end
  1923. ---获取角色全身装备卓越词条数量(不包含再生词条)
  1924. function EquipAndAppear.GetEquipsSumExcellentEntryCount(actor)
  1925. return this.GetEquipsSumExcellentEntryCount(actor)
  1926. end
  1927. ---获取角色全身装备卓越词条数量(不包含再生词条)
  1928. function this.GetEquipsSumExcellentEntryCount(actor)
  1929. local allEquip = getputonequipinfo(actor)
  1930. if table.isNullOrEmpty(allEquip) then
  1931. return 0
  1932. end
  1933. local sumCount = 0
  1934. for _, equip in pairs(allEquip) do
  1935. local entryAttrMap = equip.entries
  1936. if not table.isNullOrEmpty(entryAttrMap) then
  1937. sumCount = sumCount + table.count(entryAttrMap)
  1938. end
  1939. end
  1940. return sumCount
  1941. end
  1942. ---获取全身首饰等级
  1943. function this.GetSumJewelryLv(actor)
  1944. return this.GetSumLvByType(actor, EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL)
  1945. end
  1946. function this.GetSumLvByType(actor, lvType)
  1947. local equipList = getputonequipinfo(actor)
  1948. if table.isNullOrEmpty(equipList) then
  1949. return 0
  1950. end
  1951. local allEquip = EquipAndAppear.getLuaItemExtData(actor)
  1952. if table.isNullOrEmpty(allEquip) then
  1953. return 0
  1954. end
  1955. local sumLv = 0
  1956. for _, equipInfo in pairs(equipList) do
  1957. local itemId = equipInfo.id
  1958. local equip = allEquip[itemId]
  1959. local lv = this.GetEquipLvByType(equip, lvType)
  1960. if lv ~= 0 then
  1961. sumLv = sumLv + lv
  1962. end
  1963. end
  1964. return sumLv
  1965. end
  1966. function this.GetEquipLvByType(equip, lvType)
  1967. if table.isNullOrEmpty(equip) then
  1968. return 0
  1969. end
  1970. local lv = 0
  1971. if lvType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
  1972. lv = equip.strengthlv
  1973. elseif lvType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
  1974. lv = equip.appendlv
  1975. elseif lvType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
  1976. lv = equip.ssuplv
  1977. end
  1978. if lv == nil then
  1979. return 0
  1980. end
  1981. return tonumber(lv)
  1982. end
  1983. ---更新装备信息记录
  1984. function EquipAndAppear.TryUpdateEquipInfoRecorde(actor, recordeType)
  1985. this.TryUpdateEquipInfoRecorde(actor, recordeType)
  1986. end
  1987. ---更新装备信息记录
  1988. function this.TryUpdateEquipInfoRecorde(actor, recordeType)
  1989. local equipInfoRecorde = EquipAndAppear.GetEquipInfoRecorde(actor)
  1990. if recordeType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
  1991. local oldLv = equipInfoRecorde.max_strength_level
  1992. local newLv = EquipAndAppear.GetEquipsSumStrengthLv(actor)
  1993. if newLv > oldLv then
  1994. equipInfoRecorde.max_strength_level = newLv
  1995. this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
  1996. end
  1997. OpenServerAct.UpdateRankValue(actor, OpenServerAct.StageRank.EQUIP_MAX_STRENGTHEN_LV, newLv)
  1998. OpenServerCompetition.updateRankData(actor, CompetitionType.STRENGTHEN, newLv)
  1999. elseif recordeType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
  2000. local oldLv = equipInfoRecorde.max_append_level
  2001. local newLv = EquipAndAppear.GetEquipsSumAppendLv(actor)
  2002. if newLv > oldLv then
  2003. equipInfoRecorde.max_append_level = newLv
  2004. this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
  2005. end
  2006. OpenServerAct.UpdateRankValue(actor, OpenServerAct.StageRank.EQUIP_MAX_APPEND_LV, newLv)
  2007. OpenServerCompetition.updateRankData(actor, CompetitionType.APPEND, newLv)
  2008. elseif recordeType == EquipAndAppear.RecordeType.MAX_ENTRY_COUNT then
  2009. local oldCount = equipInfoRecorde.max_entry_count
  2010. local newCount = this.GetEquipsSumExcellentEntryCount(actor)
  2011. if newCount > oldCount then
  2012. equipInfoRecorde.max_entry_count = newCount
  2013. this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
  2014. OpenServerAct.UpdateRankValue(actor, OpenServerAct.RealTimeRank.SUPERIOR_ENTRY_COUNT, newCount)
  2015. end
  2016. elseif recordeType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
  2017. local oldLv = equipInfoRecorde.max_jewelry_level
  2018. local newLv = this.GetSumJewelryLv(actor)
  2019. if newLv > oldLv then
  2020. equipInfoRecorde.max_jewelry_level = newLv
  2021. this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
  2022. end
  2023. OpenServerAct.UpdateRankValue(actor, OpenServerAct.RealTimeRank.JEWELRY_LEVEL, newLv)
  2024. end
  2025. end
  2026. function EquipAndAppear.GetEquipInfoRecordeValue(actor, recordeType)
  2027. local equipInfoRecorde = EquipAndAppear.GetEquipInfoRecorde(actor)
  2028. if recordeType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
  2029. return equipInfoRecorde.max_strength_level
  2030. elseif recordeType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
  2031. return equipInfoRecorde.max_append_level
  2032. elseif recordeType == EquipAndAppear.RecordeType.MAX_ENTRY_COUNT then
  2033. return equipInfoRecorde.max_entry_count
  2034. elseif recordeType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
  2035. return equipInfoRecorde.max_jewelry_level
  2036. end
  2037. return 0
  2038. end
  2039. function EquipAndAppear.CheckPartEquipStrengthLv(actor, part, goalLv)
  2040. local equipList = getputonequipinfo(actor)
  2041. if table.isNullOrEmpty(equipList) then
  2042. return false
  2043. end
  2044. local allData = EquipAndAppear.getLuaItemExtData(actor)
  2045. if table.isNullOrEmpty(allData) then
  2046. return false
  2047. end
  2048. for _, equipInfo in pairs(equipList) do
  2049. local itemId = equipInfo.id
  2050. local cfgId = equipInfo.cfgid
  2051. local equipData = allData[itemId]
  2052. if not table.isNullOrEmpty(equipData) then
  2053. local strengthLv = equipData.strengthlv
  2054. if part == nil and strengthLv >= goalLv then
  2055. return true
  2056. end
  2057. if part ~= nil then
  2058. local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
  2059. if tonumber(strPart) == part and strengthLv >= goalLv then
  2060. return true
  2061. end
  2062. end
  2063. end
  2064. end
  2065. return false
  2066. end
  2067. function checkspecificstageequipcounttest(actor)
  2068. EquipAndAppear.CheckSpecificStageEquipCount(actor, stageLimit, equipType)
  2069. end
  2070. ---检查阶段装备数量
  2071. function EquipAndAppear.CheckSpecificStageEquipCount(actor, stageLimit, ratingLimit)
  2072. local allEquip = getputonequipinfo(actor)
  2073. if table.isNullOrEmpty(allEquip) then
  2074. return 0
  2075. end
  2076. local sumCount = 0
  2077. for _, equip in pairs(allEquip) do
  2078. local cfgId = equip.cfgid
  2079. local armor = this.IsArmor(cfgId)
  2080. if armor then
  2081. local stage = tonumber(ConfigDataManager.getTableValue("cfg_item", "rank", "id", cfgId))
  2082. if stage ~= nil and (stageLimit == nil or stage >= stageLimit) then
  2083. local rating = EquipAndAppear.GetEquipRating(cfgId)
  2084. if table.isNullOrEmpty(ratingLimit) or ratingLimit == rating or table.contains(ratingLimit, rating) then
  2085. sumCount = sumCount + 1
  2086. end
  2087. end
  2088. end
  2089. end
  2090. return sumCount
  2091. end
  2092. ---获取装备评级
  2093. function EquipAndAppear.GetEquipRating(itemCfgId)
  2094. local ratingScore =
  2095. tonumber(ConfigDataManager.getTableValue("cfg_equip_entrylib", "initialrating", "id", itemCfgId))
  2096. if ratingScore == nil then
  2097. return 0
  2098. end
  2099. local equipQualityCfgList = ConfigDataManager.getTable("cfg_equip_quality")
  2100. if table.isNullOrEmpty(equipQualityCfgList) then
  2101. return 0
  2102. end
  2103. for rating, equipQualityCfg in pairs(equipQualityCfgList) do
  2104. local stageParam = string.split(equipQualityCfg["stage"], "#")
  2105. if ratingScore >= tonumber(stageParam[1]) and ratingScore <= tonumber(stageParam[2]) then
  2106. return tonumber(rating)
  2107. end
  2108. end
  2109. return 0
  2110. end
  2111. ---是否防具
  2112. function this.IsArmor(cfgId)
  2113. --策划要求代码写死
  2114. local strPart = tonumber(ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId))
  2115. if strPart == nil then
  2116. return false
  2117. end
  2118. if strPart == 4 or strPart == 5 or strPart == 6 or strPart == 7 or strPart == 8 then
  2119. return true
  2120. end
  2121. return false
  2122. end
  2123. function EquipAndAppear.SetItemExtData(actor, itemId, equipData)
  2124. local result = setitemextdata(actor, itemId, equipData)
  2125. if result == nil or result == false then
  2126. gameDebug.assertPrintTrace(false, actor, "setitemextdata失败!", itemId, equipData)
  2127. end
  2128. end
  2129. --
  2130. --
  2131. --function EquipAndAppear.CheckPartEquipStrengthLv(actor, part,goalLv)
  2132. -- EquipAndAppear.CheckPartEquipInfo(actor, part, goalLv, "strengthlv")
  2133. --end
  2134. --
  2135. --function EquipAndAppear.CheckPartEquipAppendLv(actor, part, goalLv)
  2136. --
  2137. --end
  2138. --
  2139. --function EquipAndAppear.CheckPartEquipInfo(actor, part, goalLv, param)
  2140. -- jprint("--------------1", part, goalLv, param)
  2141. -- local allData = EquipAndAppear.getLuaItemExtData(actor)
  2142. -- if table.isNullOrEmpty(allData) then
  2143. -- return false
  2144. -- end
  2145. -- for itemId, equipData in pairs(allData) do
  2146. -- gameDebug.print("---- equip ----", itemId, equipData)
  2147. -- local strengthLv = equipData[param]
  2148. -- if part == nil and strengthLv >= goalLv then
  2149. -- return true
  2150. -- end
  2151. -- if part ~= nil then
  2152. -- local equip = getequipinfo(actor, itemId,1)
  2153. -- if not table.isNullOrEmpty(equip) then
  2154. -- local cfgId = equip.cfgid
  2155. -- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
  2156. -- if tonumber(strPart) == part and strengthLv >= goalLv then
  2157. -- return true
  2158. -- end
  2159. -- end
  2160. -- end
  2161. -- end
  2162. -- return false
  2163. --end
  2164. -- 新道具入包
  2165. function EquipAndAppear.ItemAdd(actor, itemId, itemCfgId)
  2166. -- 必须是装备
  2167. local type = ConfigDataManager.getTableValue("cfg_item", "type", "id", itemCfgId)
  2168. if tonumber(type) ~= ItemType.EQUIP then
  2169. return
  2170. end
  2171. local itemExtData = getitemextdata(actor, itemId)
  2172. if itemExtData == nil then
  2173. return
  2174. end
  2175. local allequip = getplaydef(actor, "T$luaitemextdata")
  2176. allequip[itemId] = itemExtData
  2177. setplaydef(actor, "T$luaitemextdata", allequip)
  2178. end