EquipFunc.lua 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. EquipFunc = {}
  2. local filename = "EquipFunc"
  3. function EquipFunc.getEquipIsSpecial(cfgId)
  4. local isSpecial = ConfigDataManager.getTableValue("cfg_item", "isSpecial", "id", cfgId)
  5. isSpecial = tonumber(isSpecial) or 0
  6. return isSpecial == 1
  7. end
  8. -- 获取装备等级(道具表字段 只参与价值计算)
  9. function EquipFunc.getItemCalculatelevel(actor, itemId)
  10. local equipInfo = getequipinfo(actor, itemId, 1)
  11. local cfgId = equipInfo.cfgid
  12. local Calculatelevel = ConfigDataManager.getTableValue("cfg_item", "calculatelevel", "id", cfgId)
  13. return tonumber(Calculatelevel) or 0
  14. end
  15. -- 获取装备强化等级
  16. function EquipFunc.getEquipStrengthLevel(actor, itemId)
  17. return API.GetItemData(actor, itemId, "strengthlv") or 0
  18. end
  19. -- 获取全身装备强化等级
  20. function EquipFunc.GetAllStrengthLevel(actor)
  21. local allEquip = getallequipinfo(actor)
  22. local allStrengthLevel = 0
  23. for i, v in pairs(allEquip) do
  24. allStrengthLevel = allStrengthLevel + EquipFunc.getEquipStrengthLevel(actor, v.id)
  25. end
  26. return allStrengthLevel
  27. end
  28. -- 获取装备强化类型 1=武器类型 2=防具和翅膀首饰除外 3盾牌
  29. function EquipFunc.getEquipStrengthType(actor, itemId)
  30. local equipType = 0
  31. local equipInfo = getequipinfo(actor, itemId, 1)
  32. local cfgId = equipInfo.cfgid
  33. local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
  34. local mainType = tonumber(itemData.type)
  35. local subType = tonumber(itemData.subtype)
  36. local name = itemData.name
  37. if mainType == 2 then
  38. if subType == 1 or subType == 2 or subType == 3 then
  39. equipType = 1
  40. if string.find(name, "盾") ~= nil then
  41. equipType = 3
  42. end
  43. elseif subType == 4 or subType == 5 or subType == 6 or subType == 7 or subType == 8 or subType == 9 then
  44. equipType = 2
  45. elseif subType == 10001 then
  46. equipType = 4
  47. elseif subType == 10002 then
  48. equipType = 5
  49. elseif subType == 12 then
  50. equipType = 2
  51. end
  52. end
  53. return equipType
  54. end
  55. -- 获取装备Power
  56. function EquipFunc.getEquipPower(actor, itemId)
  57. local equipInfo = getequipinfo(actor, itemId, 1)
  58. local cfgId = equipInfo.cfgid
  59. local Power = ConfigDataManager.getTableValue("cfg_item", "Power", "id", cfgId) or 0
  60. return Power
  61. end
  62. -- 整合所有强化属性
  63. function EquipFunc.getEquipAllStrengthAttr(actor, itemId)
  64. local tAttr = {}
  65. local tBaseAttr = EquipFunc.getEquipStrengthBaseAttr(actor, itemId) -- 获取装备强化基础属性
  66. if next(tBaseAttr) then
  67. table.concatTable(tAttr, tBaseAttr)
  68. end
  69. local tStrengthAttr = EquipFunc.getEquipStrengthAttr(actor, itemId) -- 获取装备强化属性
  70. if next(tStrengthAttr) then
  71. table.concatTable(tAttr, tStrengthAttr)
  72. end
  73. return tAttr
  74. end
  75. -- 获取装备强化基础属性
  76. function EquipFunc.getEquipStrengthBaseAttr(actor, itemId)
  77. local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
  78. local tAttr = {}
  79. local equipInfo = getequipinfo(actor, itemId, 1)
  80. local basicattr = equipInfo.basicattr
  81. local equipType = EquipFunc.getEquipStrengthType(actor, itemId)
  82. for i = 1, #basicattr do
  83. local attId = basicattr[i].attrid
  84. local val = basicattr[i].value
  85. if equipType == 1 then
  86. if attId == 200011 or attId == 200021 then -- 最小/最大 攻击/魔法
  87. local val1 = lv * 3
  88. if lv > 9 then
  89. val1 = val1 + (lv - 9) * (lv - 8) / 2
  90. end
  91. table.insert(tAttr, {attId, val1})
  92. end
  93. elseif equipType == 2 then
  94. if attId == 206011 then -- 防御
  95. local val1 = lv * 3
  96. if lv > 9 then
  97. val1 = val1 + (lv - 9) * (lv - 8) / 2
  98. end
  99. table.insert(tAttr, {attId, val1})
  100. end
  101. elseif equipType == 3 then
  102. if attId == 206011 then -- 防御
  103. local val1 = lv
  104. table.insert(tAttr, {attId, val1})
  105. end
  106. if attId == 211011 then -- 防御率
  107. local val1 = lv * 3
  108. if lv > 9 then
  109. val1 = val1 + (lv - 9) * (lv - 8) / 2
  110. end
  111. table.insert(tAttr, {attId, val1})
  112. end
  113. elseif equipType == 4 then
  114. table.insert(tAttr, {attId, val})
  115. elseif equipType == 5 then
  116. local val1 = lv * 3
  117. if lv > 9 then
  118. val1 = val1 + (lv - 9) * (lv - 8) / 2
  119. end
  120. table.insert(tAttr, {attId, val + val1})
  121. end
  122. end
  123. return tAttr
  124. end
  125. function EquipFunc.getEquipStrengthWearAddAttr(actor, itemId)
  126. local equipInfo = getequipinfo(actor, itemId, 1)
  127. local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
  128. local curAttr = EquipFunc.getEquipStrengthAllAttr(equipInfo, lv)
  129. local baseAttr = EquipFunc.getEquipStrengthAllAttr(equipInfo, 0)
  130. for index, value in ipairs(curAttr) do
  131. local k, v = table.findByCondi(baseAttr, function(a)
  132. return a[1] == value[1];
  133. end)
  134. if k ~= nil then
  135. value[2] = value[2] - v[2]
  136. end
  137. end
  138. local realAttr = {}
  139. for index, value in ipairs(curAttr) do
  140. realAttr[tostring(value[1])] = tostring(value[2])
  141. end
  142. -- 强化属性转换一下
  143. local css = {}
  144. for k, v in pairs(realAttr) do
  145. local convs = EquipFunc.getStrengthenConversion(k, v)
  146. if table.count(convs) > 0 then
  147. for kk, vv in pairs(convs) do
  148. if css[tostring(kk)] == nil then
  149. css[tostring(kk)] = tostring(0)
  150. end
  151. css[tostring(kk)] = tostring(tonumber(css[tostring(kk)]) + tonumber(vv))
  152. end
  153. end
  154. end
  155. for k, v in pairs(css) do
  156. if realAttr[tostring(k)] == nil then
  157. realAttr[tostring(k)] = tostring(0)
  158. end
  159. realAttr[tostring(k)] = tostring(tonumber(realAttr[tostring(k)]) + tonumber(v))
  160. end
  161. return realAttr;
  162. end
  163. function EquipFunc.getStrengthenConversion(attrid, lv)
  164. attrid = tonumber(attrid)
  165. lv = tonumber(lv)
  166. local cfg = ConfigDataManager.getById("cfg_att_info", tonumber(attrid))
  167. if cfg == nil or string.isNullOrEmpty(cfg.strengthenconversion) then
  168. return {}
  169. end
  170. local results = {}
  171. local ss = string.split(cfg.strengthenconversion, "&")
  172. local baseAttr = ss[1]
  173. local convAttr = ss[2]
  174. baseAttr = string.split(baseAttr, "|")
  175. for i, v in ipairs(baseAttr) do
  176. local vv = string.split(v, "#")
  177. local aid = vv[1]
  178. local value = vv[2]
  179. if results[aid] == nil then
  180. results[aid] = "0"
  181. end
  182. results[aid] = tostring(tonumber(results[aid]) + tonumber(value))
  183. end
  184. convAttr = string.split(convAttr, "|")
  185. for i, v in ipairs(convAttr) do
  186. local vv = string.split(v, "#")
  187. local aid = vv[1]
  188. local value = vv[2]
  189. if results[aid] == nil then
  190. results[aid] = "0"
  191. end
  192. results[aid] = tostring(tonumber(results[aid]) + tonumber(value) * lv)
  193. end
  194. return results
  195. end
  196. -- 获取装备强化属性
  197. function EquipFunc.getEquipStrengthAttr(actor, itemId)
  198. local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
  199. local equipInfo = getequipinfo(actor, itemId, 1)
  200. return EquipFunc.getEquipStrengthAllAttr(equipInfo, lv)
  201. end
  202. function EquipFunc.getEquipStrengthAllAttr(equipInfo, lv)
  203. local basicattr = equipInfo.basicattr
  204. local entries = equipInfo.entries
  205. local tAttr = {}
  206. local tAttId1 = {
  207. [202021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  208. [202011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  209. [201011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  210. [201021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  211. [206011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  212. [205051] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  213. [202041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  214. [201041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  215. [200043] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  216. [200011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  217. [200021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  218. [203041] = {200, 100, 200, 100, 200, 100, 200, 100, 200, 200, 200, 300, 400, 400, 400},
  219. [311012] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
  220. [313012] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
  221. [100017] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
  222. [100018] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
  223. [202052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
  224. [205052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
  225. [304012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}
  226. }
  227. local tAttId2 = {
  228. [202021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  229. [202011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  230. [201011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  231. [201021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  232. [206011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  233. [205051] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  234. [202041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  235. [201041] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  236. [200043] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  237. [200011] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  238. [200021] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
  239. [203041] = {200, 100, 200, 100, 200, 100, 200, 100, 200, 200, 200, 300, 400, 400, 400},
  240. [311012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100},
  241. [313012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100},
  242. [100017] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100},
  243. [100018] = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
  244. [202052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
  245. [205052] = {350, 350, 350, 350, 350, 350, 350, 350, 350, 400, 400, 500, 600, 600, 600},
  246. [304012] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}
  247. }
  248. local zhuoyueAttId = {
  249. [100035] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  250. [100036] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  251. }
  252. local sequips = {
  253. [21320011] = tAttId2,
  254. [21320011] = tAttId2,
  255. [21320021] = tAttId2,
  256. [21320031] = tAttId2,
  257. [21320041] = tAttId2,
  258. [21320051] = tAttId2
  259. }
  260. local tAttId = sequips[equipInfo.cfgid] ~= nil and sequips[equipInfo.cfgid] or tAttId1
  261. for i = 1, #basicattr do
  262. local attId = basicattr[i].attrid
  263. local val = basicattr[i].value
  264. local values = tAttId[attId];
  265. if values then
  266. local val1 = 0
  267. for index, value in ipairs(values) do
  268. if index > lv then
  269. break
  270. end
  271. val1 = val1 + values[index]
  272. end
  273. val1 = math.floor(val1)
  274. -- if lv <= 9 then
  275. -- val1 = math.floor(lv * 3)
  276. -- -- if isZhuoYue then
  277. -- -- val1 = math.floor(Power + (25*Power/itemLevel+5)) / 2 + lv * 3.5
  278. -- -- else
  279. -- -- val1 = math.floor(Power + 0) / 2 + lv * 3.5
  280. -- -- end
  281. -- else
  282. -- local num = lv - 9
  283. -- local beginVal = 4;
  284. -- local endVal = 4 + num - 1
  285. -- val1 = math.floor(9 * 3) + (beginVal + endVal) * num / 2
  286. -- -- if isZhuoYue then
  287. -- -- val1 = math.floor(Power + (25*Power/itemLevel+5)) / 2 + lv * 3.5 + (lv-9) * (lv-8)/2
  288. -- -- else
  289. -- -- val1 = math.floor(Power + 0) / 2 + lv * 3.5 /2
  290. -- -- end
  291. -- end
  292. table.insert(tAttr, {attId, val + val1})
  293. end
  294. end
  295. for i = 1, #entries do
  296. local attId = entries[i].attrid
  297. local val = entries[i].value
  298. local values = zhuoyueAttId[attId]
  299. if values then
  300. local val1 = 0
  301. for index, value in ipairs(values) do
  302. if index > lv then
  303. break
  304. end
  305. val1 = val1 + values[index]
  306. end
  307. val1 = math.floor(val1)
  308. table.insert(tAttr, {attId, val + val1})
  309. end
  310. end
  311. return tAttr
  312. end
  313. -- 获取装备强化佩戴条件
  314. function EquipFunc.getEquipStrengthNeed(actor, itemId)
  315. local item = getequipinfo(actor, itemId, 1)
  316. local cfgId = item.cfgid
  317. local lv = EquipFunc.getEquipStrengthLevel(actor, itemId)
  318. local tAttr = {}
  319. local itemLevel = EquipFunc.getItemCalculatelevel(actor, itemId)
  320. local isZhuoYue = EquipFunc.IsZhuoYueEquip(cfgId)
  321. local tNeedAtt = {
  322. [10001] = 1,
  323. [10002] = 1,
  324. [10003] = 1,
  325. [10004] = 1,
  326. [10005] = 1
  327. }
  328. local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
  329. local useAttLimit = ConfigDataManager.getTableValue("cfg_equip_entryLib", "useAttLimit", "id", cfgId) or {}
  330. useAttLimit = string.getAttrByStr(useAttLimit) -- string.split(useAttLimit,"#")
  331. for attId, _ in pairs(useAttLimit) do
  332. local need = 0
  333. attId = tonumber(attId)
  334. if attId == 10001 then
  335. need = itemData.qianghuall
  336. elseif attId == 10002 then
  337. need = itemData.qianghuamj
  338. elseif attId == 10003 then
  339. need = itemData.qianghuazl
  340. elseif attId == 10004 then
  341. need = itemData.qianghuatl
  342. elseif attId == 10005 then
  343. need = itemData.qianghuallts
  344. end
  345. need = tonumber(need)
  346. need = need or 0
  347. if tNeedAtt[attId] then
  348. if isZhuoYue then
  349. need = math.floor(3 * (3 * lv + itemLevel + 25) * (need / 100) + 20)
  350. else
  351. need = math.floor(3 * (3 * lv + itemLevel) * (need / 100) + 20)
  352. end
  353. end
  354. need = math.floor(need)
  355. table.insert(tAttr, {attId, need})
  356. end
  357. return tAttr
  358. end
  359. -- 每日最大回收次数
  360. function EquipFunc.getMaxHuiShouNum(actor)
  361. return 600
  362. end
  363. -- 是否是卓越装备
  364. function EquipFunc.IsZhuoYueEquip(cfgId)
  365. local Outstanding = ConfigDataManager.getTableValue("cfg_item", "Outstanding", "id", cfgId) or 0
  366. return Outstanding == "1" or Outstanding == "2" or Outstanding == "3", tonumber(Outstanding)
  367. end
  368. -- 获取卓越属性数量
  369. function EquipFunc.getZhuoYueEquipNum(actor, itemId)
  370. local tZhuoYueAttIndex = API.GetItemData(actor, itemId, "tZhuoYueAttIndex") or {}
  371. return table.count(tZhuoYueAttIndex)
  372. end
  373. -- 获取装备追加等级
  374. function EquipFunc.getEquipAppendLevel(actor, itemId)
  375. return API.GetItemData(actor, itemId, "appendlv") or 0
  376. end
  377. -- 获取全身装备追加等级
  378. function EquipFunc.GetAllAppendLevel(actor)
  379. local allEquip = getallequipinfo(actor)
  380. local allAppendLevel = 0
  381. for i, v in pairs(allEquip) do
  382. allAppendLevel = allAppendLevel + EquipFunc.getEquipAppendLevel(actor, v.id)
  383. end
  384. return allAppendLevel
  385. end
  386. -- 获取装备是否激活幸运
  387. function EquipFunc.getEquipIsXingYun(actor, itemId)
  388. return API.GetItemData(actor, itemId, "IsLuck") == 1
  389. end
  390. function EquipFunc.GetEquipIsLuck(item)
  391. local IsLuck = false
  392. if item and item.entries ~= nil then
  393. for index, value in ipairs(item.entries) do
  394. if value.attrid == 900 then
  395. IsLuck = true
  396. break
  397. end
  398. end
  399. end
  400. return IsLuck
  401. end
  402. -- 获取装备是否激活技能
  403. function EquipFunc.getEquipIsSkill(actor, itemId)
  404. return API.GetItemData(actor, itemId, "skillName") or nil
  405. end
  406. -- 获取装备价值
  407. function EquipFunc.getEquipJiaZhi(actor, itemId)
  408. -- 强化系数
  409. local tQiangHuaXiShu = {
  410. [5] = 4,
  411. [6] = 10,
  412. [7] = 25,
  413. [8] = 45,
  414. [9] = 65,
  415. [10] = 95,
  416. [11] = 135,
  417. [12] = 185,
  418. [13] = 245,
  419. [14] = 305,
  420. [15] = 365
  421. }
  422. local equipInfo = getequipinfo(actor, itemId, 1)
  423. local cfgId = equipInfo.cfgid
  424. local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  425. if name == "祝福宝石" then
  426. return 60000
  427. elseif name == "灵魂宝石" then
  428. return 20000
  429. elseif name == "玛雅之石" then
  430. return 40000
  431. elseif name == "创造宝石" then
  432. return 450000
  433. elseif name == "生命宝石" then
  434. return 450000
  435. elseif name == "合成幸运符" then
  436. return 200000
  437. end
  438. local type = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
  439. type = tonumber(type)
  440. if not type or type ~= 2 then
  441. return 0
  442. end
  443. -- local value = ConfigDataManager.getTableValue("cfg_item", "value", "id", cfgId)
  444. -- value = tonumber(value)
  445. -- if value and value > 0 then
  446. -- return value
  447. -- end
  448. -- 装备等级(道具表字段 只参与价值计算)
  449. local level = EquipFunc.getItemCalculatelevel(actor, itemId)
  450. -- 强化等级
  451. local strengthLevel = EquipFunc.getEquipStrengthLevel(actor, itemId)
  452. -- 装备系数
  453. local equipXiShu = level + strengthLevel * 3
  454. if tQiangHuaXiShu[strengthLevel] then
  455. equipXiShu = equipXiShu + tQiangHuaXiShu[strengthLevel]
  456. end
  457. -- 装备价值
  458. local equipCost = 0
  459. local tmpXiShu = equipXiShu
  460. -- 是否是卓越装备
  461. if EquipFunc.IsZhuoYueEquip(cfgId) then
  462. tmpXiShu = equipXiShu + 25
  463. end
  464. equipCost = math.ceil(((tmpXiShu + 40) * tmpXiShu * tmpXiShu / 8 + 100) / 100) * 100
  465. -- local mainType = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
  466. local subType = ConfigDataManager.getTableValue("cfg_item", "subType", "id", cfgId)
  467. -- 翅膀
  468. if subType == 13 then
  469. equipCost = math.ceil((equipXiShu + 40) * equipXiShu * equipXiShu * 11) + 40000000
  470. end
  471. -- 单手武器衰减
  472. local strPart = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
  473. if strPart == 1 or strPart == 2 then
  474. equipCost = equipCost * 80 / 100
  475. end
  476. ---装备价值不能超出
  477. if equipCost > 3000000000 then
  478. equipCost = 3000000000
  479. end
  480. return math.floor(equipCost)
  481. end
  482. -- 获取合成时装备价值
  483. function EquipFunc.getEquipSynValue(actor, itemId)
  484. -- 强化系数
  485. local tQiangHuaXiShu = {
  486. [4] = 40,
  487. [5] = 45,
  488. [6] = 55,
  489. [7] = 65,
  490. [8] = 75,
  491. [9] = 85,
  492. [10] = 95,
  493. [11] = 135,
  494. [12] = 185,
  495. [13] = 245,
  496. [14] = 305,
  497. [15] = 365
  498. }
  499. local equipInfo = getequipinfo(actor, itemId, 1)
  500. local cfgId = equipInfo.cfgid
  501. local name = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
  502. if name == "祝福宝石" then
  503. return 60000
  504. elseif name == "灵魂宝石" then
  505. return 20000
  506. elseif name == "玛雅之石" then
  507. return 40000
  508. elseif name == "创造宝石" then
  509. return 450000
  510. elseif name == "生命宝石" then
  511. return 450000
  512. elseif name == "合成幸运符" then
  513. return 200000
  514. end
  515. local type = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
  516. type = tonumber(type)
  517. if not type or type ~= 2 then
  518. return 0
  519. end
  520. -- local value = ConfigDataManager.getTableValue("cfg_item", "value", "id", cfgId)
  521. -- value = tonumber(value)
  522. -- if value and value > 0 then
  523. -- return value
  524. -- end
  525. -- 装备等级(道具表字段 只参与价值计算)
  526. local level = EquipFunc.getItemCalculatelevel(actor, itemId)
  527. -- 强化等级
  528. local strengthLevel = EquipFunc.getEquipStrengthLevel(actor, itemId)
  529. -- 追加等级
  530. local appendLevel = EquipFunc.getEquipAppendLevel(actor, itemId)
  531. -- 是否有幸运属性
  532. local equipInfo = getequipinfo(actor, itemId, 1)
  533. local isLuck = false
  534. if equipInfo ~= nil then
  535. isLuck = EquipFunc.GetEquipIsLuck(equipInfo)
  536. end
  537. -- 装备系数
  538. local equipXiShu = level + strengthLevel * 3
  539. if tQiangHuaXiShu[strengthLevel] then
  540. equipXiShu = equipXiShu + tQiangHuaXiShu[strengthLevel]
  541. end
  542. if appendLevel > 0 then
  543. equipXiShu = equipXiShu + (appendLevel - 1) * 10
  544. end
  545. -- 幸运属性加成
  546. if isLuck then
  547. equipXiShu = equipXiShu + 10
  548. end
  549. -- 装备价值
  550. local equipCost = 0
  551. local tmpXiShu = equipXiShu
  552. -- 是否是卓越装备
  553. if EquipFunc.IsZhuoYueEquip(cfgId) then
  554. tmpXiShu = equipXiShu + 25
  555. end
  556. equipCost = math.ceil(((tmpXiShu + 40) * tmpXiShu * tmpXiShu / 8 + 100) / 100) * 100
  557. -- local mainType = ConfigDataManager.getTableValue("cfg_item", "type", "id", cfgId)
  558. -- local subType = ConfigDataManager.getTableValue("cfg_item", "subType", "id", cfgId)
  559. -- 翅膀
  560. -- if subType == 13 then
  561. -- equipCost = math.ceil((equipXiShu + 40) * equipXiShu * equipXiShu * 11) + 40000000
  562. -- end
  563. -- 单手武器衰减
  564. local strPart = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
  565. if strPart == 1 or strPart == 2 then
  566. equipCost = equipCost * 80 / 100
  567. end
  568. ---装备价值不能超出
  569. if equipCost > 3000000000 then
  570. equipCost = 3000000000
  571. end
  572. return math.floor(equipCost)
  573. end
  574. -- 获取可回收物品列表
  575. function EquipFunc.getRescoverItemList(actor)
  576. local allItemInfo = getallbagiteminfo(actor)
  577. local tRecoverItem = {}
  578. if not next(allItemInfo) then
  579. return tRecoverItem
  580. end
  581. for _, item in pairs(allItemInfo) do
  582. local cfgId = item.cfgid
  583. local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
  584. local recoveryGroup = itemData.recoverygroup or 0
  585. if recoveryGroup ~= 0 then
  586. table.insert(tRecoverItem, item)
  587. end
  588. end
  589. return tRecoverItem
  590. end
  591. -- 获取回收价格
  592. function EquipFunc.getEquipRecoverCost(actor, itemId)
  593. local equipInfo = getequipinfo(actor, itemId, 1)
  594. local cfgId = equipInfo.cfgid
  595. local value = ConfigDataManager.getTableValue("cfg_item", "value", "id", cfgId)
  596. if tonumber(value) then
  597. return tonumber(value)
  598. end
  599. -- if value ~= "" then
  600. -- return tonumber(value)
  601. -- end
  602. local equipCost = EquipFunc.getEquipJiaZhi(actor, itemId)
  603. -- 出售价格
  604. local sellPrice = 0
  605. -- 是否卓越装备
  606. local isZhuoYue = EquipFunc.IsZhuoYueEquip(cfgId)
  607. -- 卓越条数
  608. local ZhuoYueEquipNum = EquipFunc.getZhuoYueEquipNum(actor, itemId)
  609. -- 追加等级
  610. local appendLevel = EquipFunc.getEquipAppendLevel(actor, itemId)
  611. -- 幸运
  612. local IsXingYun = EquipFunc.getEquipIsXingYun(actor, itemId)
  613. -- 技能
  614. local IsSkill = EquipFunc.getEquipIsSkill(actor, itemId)
  615. if not sellPrice or sellPrice == 0 then
  616. if IsSkill then
  617. sellPrice = equipCost + equipCost * 2.5
  618. end
  619. if IsXingYun then
  620. sellPrice = equipCost + equipCost * 1.25
  621. end
  622. if appendLevel > 0 then
  623. if appendLevel == 1 then
  624. sellPrice = equipCost + equipCost * 1.6
  625. elseif appendLevel == 2 then
  626. sellPrice = equipCost + equipCost * 2.4
  627. elseif appendLevel == 3 then
  628. sellPrice = equipCost + equipCost * 3.8
  629. elseif appendLevel == 4 then
  630. sellPrice = equipCost + equipCost * 6.6
  631. end
  632. end
  633. if isZhuoYue then
  634. sellPrice = equipCost + equipCost * 2 * ZhuoYueEquipNum
  635. end
  636. -- 道具表 useLevelLimit 字段
  637. if EquipFunc.getEquipIsSpecial(cfgId) then
  638. sellPrice = equipCost + equipCost * 1.16
  639. end
  640. -- local useLevelLimit = ConfigDataManager.getTableValue("cfg_item", "useLevelLimit", "id", cfgId)
  641. -- useLevelLimit = tonumber(useLevelLimit)
  642. -- if useLevelLimit >= 380 then
  643. -- sellPrice = equipCost + equipCost *1.16
  644. -- end
  645. sellPrice = math.ceil(equipCost / 4) ---向上取整
  646. end
  647. return math.floor(sellPrice)
  648. end
  649. function EquipFunc.getEquipExchangeCost(equip)
  650. local attrNum = #equip.entries
  651. if EquipFunc.GetEquipIsLuck(equip) then
  652. attrNum = attrNum - 3
  653. else
  654. attrNum = attrNum - 1
  655. end
  656. attrNum = math.max(attrNum, 0)
  657. local ISZY, ZyType = EquipFunc.IsZhuoYueEquip(equip.cfgid)
  658. local num = 0
  659. if ZyType == 1 then -- 卓越准备
  660. num = 20
  661. elseif ZyType == 3 then -- 卓越套装
  662. num = 100
  663. end
  664. return attrNum * num
  665. end
  666. -- 装备修理费用
  667. function EquipFunc.getXiuLiPrice(actor, itemId, equipInfo2)
  668. local equipInfo = nil
  669. if equipInfo2 ~= nil then
  670. equipInfo = equipInfo2
  671. else
  672. equipInfo = getequipinfo(actor, itemId, 1)
  673. end
  674. local cfgId = equipInfo.cfgid
  675. local equipCost = EquipFunc.getEquipJiaZhi(actor, itemId) / 3
  676. -- 修理系数
  677. local XiuLiXiShu = math.ceil(equipCost / 100) * 100
  678. local nowDurabilityPct = EquipDurability.getNowDurabilityPct(actor, itemId)
  679. local DurabilityXiShu = 1 - nowDurabilityPct / 100
  680. local X = math.sqrt(XiuLiXiShu)
  681. local Y = math.sqrt(X)
  682. -- 修理费用
  683. local xiuliPrice = 0
  684. -- 是否卓越装备
  685. local isZhuoYue = EquipFunc.IsZhuoYueEquip(cfgId)
  686. if isZhuoYue then
  687. xiuliPrice = (((3 * X * Y) * DurabilityXiShu) + 1) * 0.85
  688. else
  689. xiuliPrice = (3 * X * Y) * DurabilityXiShu + 1
  690. end
  691. -- 是否自动修理
  692. local autoXiuLi = false
  693. -- 是否远程修理
  694. local yuanchengXiuLi = false
  695. if autoXiuLi or yuanchengXiuLi then
  696. xiuliPrice = xiuliPrice * 2
  697. end
  698. return math.ceil(xiuliPrice)
  699. end
  700. -- 缓存时装表
  701. EquipFunc.tSuitList = {}
  702. function EquipFunc.setSuitIdList()
  703. -- local itemData = ConfigDataManager.getTable("cfg_equip_suit")
  704. local cfg_equip_suit = ConfigDataManager.getList("cfg_equip_suit")
  705. info("时装表开始缓存")
  706. for i = 1, #cfg_equip_suit do
  707. local id = cfg_equip_suit[i].id
  708. local tSuitItemId = string.split(cfg_equip_suit[i].suitItemId, "#")
  709. for j = 1, #tSuitItemId do
  710. local itemId = tSuitItemId[j]
  711. EquipFunc.tSuitList[itemId] = id
  712. end
  713. end
  714. info("时装表缓存结束")
  715. end
  716. -- 根据道具cfgId获取时装id
  717. function EquipFunc.getSuitId(cfgId)
  718. return EquipFunc.tSuitList[cfgId] or 0
  719. end
  720. -- 登录
  721. GameEvent.add(EventCfg.onLoginEnd, function(actor)
  722. -- 推送红点
  723. sendluamsg(actor, LuaNetMsg.Equip_DuanZao_MsgID, {
  724. sendType = 10
  725. })
  726. end, filename)
  727. -- 重载配置
  728. GameEvent.add(EventCfg.onReloadScript, function(actor)
  729. EquipFunc.setSuitIdList()
  730. -- 推送红点
  731. sendluamsg(actor, LuaNetMsg.Equip_DuanZao_MsgID, {
  732. sendType = 10
  733. })
  734. end, filename)