EquipFunc.lua 24 KB

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