AttributeFunction.lua 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. -- 服务器道具属性变更,在这里变更服务器属性为前端需要的属性
  2. function ChangeItemServersSendDatas(item)
  3. if not item or not next(item) then
  4. print("=======================================")
  5. print("item data error")
  6. print("=======================================")
  7. end
  8. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  9. local itemconfigO = ItemConfigProxy:GetItemDataByIndex(item.Index)
  10. if not itemconfigO or next(itemconfigO) == nil then
  11. print("=======================================")
  12. print("no this item: my index is " .. item.Index)
  13. print("=======================================")
  14. end
  15. local itemconfig = {}
  16. setmetatable(itemconfig,{
  17. __index = function( t,key )
  18. local Index = t.Index
  19. if not Index then
  20. return
  21. end
  22. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  23. local config = ItemConfigProxy:GetItemDataByIndex(Index) or {}
  24. rawset( t, key, config[key])
  25. return config[key]
  26. end
  27. })
  28. local itemCount = item.overlap and item.overlap or 1
  29. itemconfig.Index = item.Index
  30. itemconfig.MakeIndex = item.makeindex or 0
  31. itemconfig.Dura = item.dura or 0
  32. itemconfig.DuraMax = item.duramax or 0
  33. itemconfig.Values = item.values or {}
  34. itemconfig.Where = item.where
  35. itemconfig.OverLap = itemCount > 0 and itemCount or 1
  36. itemconfig.Price = item.price
  37. itemconfig.Type = item.Type
  38. itemconfig.BindInfo = item.BindInfo or nil
  39. itemconfig.Star = nil
  40. itemconfig.Bind = nil
  41. itemconfig.ExtendInfo = {}
  42. local cjson = require("cjson")
  43. if item.ExtendInfo and string.len(item.ExtendInfo) > 0 then
  44. itemconfig.ExtendInfo = cjson.decode(item.ExtendInfo)
  45. end
  46. itemconfig.AddValues = item.AddValues or {}
  47. if next(itemconfig.AddValues) then
  48. for k, v in pairs(itemconfig.AddValues) do
  49. if v.Id == 0 then
  50. itemconfig.getServerTime = GetServerTime() --记录获取时的时间戳
  51. v.Value = v.Value + GetServerTime()
  52. elseif v.Id == 1 then
  53. itemconfig.Bind = v.Value
  54. elseif v.Id == 2 and v.Value and v.Value > 0 then
  55. itemconfig.Color = v.Value
  56. elseif v.Id == 3 then
  57. itemconfig.Star = v.Value
  58. end
  59. end
  60. end
  61. if item.ExAbil and string.len(item.ExAbil) > 0 then
  62. local exAbilJsonData = cjson.decode(item.ExAbil)
  63. itemconfig.ExAbil = exAbilJsonData
  64. if exAbilJsonData.name and string.len(exAbilJsonData.name) > 0 then
  65. if not itemconfig.originName then
  66. itemconfig.originName = itemconfig.Name
  67. end
  68. itemconfig.Name = exAbilJsonData.name
  69. end
  70. end
  71. local newLooks, newEffect, newSEffect = ItemConfigProxy:GetChangeItemLook(itemconfig.MakeIndex)
  72. local newEffectZ = nil
  73. local newSEffectZ = nil
  74. if next(itemconfig.Values) then
  75. --Value[48] 低位是Looks 高位是Effect
  76. --Value[47] 低位是内观Effect
  77. for k, v in pairs(itemconfig.Values) do
  78. if (v.Id == 48 or v.Id == 47) and v.Value then
  79. local looks = L16Bit(v.Value)
  80. local effect = H16Bit(v.Value)
  81. if v.Id == 47 then
  82. newSEffect = looks > 0 and looks or newSEffect
  83. elseif v.Id == 48 then
  84. newLooks = looks > 0 and looks or newLooks
  85. newEffect = effect > 0 and effect or newEffect
  86. end
  87. elseif v.Id == 45 then --物品投保次数
  88. itemconfig.touBaoTimes = v.Value
  89. elseif v.Id == 33 then --特定的装备是否显示属性
  90. itemconfig.TipsShowAttr = v.Value
  91. elseif v.Id == 39 then --特效层级
  92. newEffectZ = L16Bit(v.Value)
  93. newSEffectZ = H16Bit(v.Value)
  94. end
  95. end
  96. end
  97. if newLooks and newLooks > 0 then
  98. itemconfig.Looks = newLooks
  99. end
  100. local bEffect = nil
  101. local sEffect = nil
  102. if newEffect and newEffect > 0 then
  103. bEffect = newEffect
  104. end
  105. if newSEffect and newSEffect > 0 then
  106. sEffect = newSEffect
  107. end
  108. if bEffect then
  109. local iBEffect = global.ConstantConfig.showOrinalEffec == 1 and (itemconfig.bEffect or "") .. "|" or "0"
  110. itemconfig.bEffect = string.format("%s%s", iBEffect, bEffect)
  111. end
  112. if sEffect then
  113. local iSEffect = global.ConstantConfig.showOrinalEffec == 1 and (itemconfig.sEffect or "") .. "|" or "0"
  114. itemconfig.sEffect = string.format("%s%s", iSEffect, sEffect)
  115. end
  116. if newEffectZ and newEffectZ >= 0 then
  117. itemconfig.bEffect = (itemconfig.bEffect or "0") .. "#" .. newEffectZ
  118. end
  119. if newSEffectZ and newSEffectZ >= 0 then
  120. itemconfig.sEffect = (itemconfig.sEffect or "0") .. "#" .. newSEffectZ
  121. end
  122. return itemconfig
  123. --[[ if not item or not next(item) then
  124. print("=======================================")
  125. print("item data error")
  126. print("=======================================")
  127. return {}
  128. end
  129. local itemCount = item.overlap and item.overlap or 1
  130. item.MakeIndex = item.makeindex or 0
  131. item.Dura = item.dura or 0
  132. item.DuraMax = item.duramax or 0
  133. item.Values = item.values or {}
  134. item.Where = item.where
  135. item.OverLap = itemCount > 0 and itemCount or 1
  136. item.Source = item.source and item.source or 0
  137. item.Luck = item.luck and item.luck or 0
  138. item.Need = item.need and item.need or 0
  139. item.NeedLevel = item.needlevel and item.needlevel or 0
  140. item.StdMode = item.stdmode or 0
  141. item.Shape = item.shape or 0
  142. item.Looks = item.looks or 0
  143. item.nBindIdx = item.bind or 0
  144. item.Name = item.name or 0
  145. item.Weight = item.weight or 0
  146. item.Price = item.price or 0
  147. item.Reserved = item.reserved or 0
  148. item.sEffect = item.effectparam or ""
  149. item.makeindex = nil
  150. item.dura = nil
  151. item.duramax = nil
  152. item.values = nil
  153. item.where = nil
  154. item.overlap = nil
  155. item.price = nil
  156. item.source = nil
  157. item.luck = nil
  158. item.need = nil
  159. item.needlevel = nil
  160. item.stdmode = nil
  161. item.shape = nil
  162. item.looks = nil
  163. item.bind = nil
  164. item.name = nil
  165. item.weight = nil
  166. item.reserved = nil
  167. item.effectparam = nil
  168. return item
  169. ]]
  170. end
  171. function GetItemPowerValue(item, param)
  172. if not item or not next(item) then
  173. return 0
  174. end
  175. param = param or {}
  176. -- 基础属性
  177. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  178. local attributeCfg = ItemConfigProxy:GetItemDataByIndex(item.Index)
  179. local attList = {}
  180. local attrArray = string.split(attributeCfg.attribute or "", "|")
  181. for i, v in ipairs(attrArray) do
  182. if v and v ~= "" and string.len(v) > 0 then
  183. local vArray = string.split(v or "", "#")
  184. table.insert(attList, {
  185. id = tonumber(vArray[2]) or 3,
  186. value = tonumber(vArray[3]) or 0
  187. })
  188. end
  189. end
  190. local powerValue, powerSortIndex = CalculateAttPowerValue(attList, param.jobPower, param.powerSortIndex)
  191. local comparison1, job1 = ItemConfigProxy:GetItemComparison(item.Index)
  192. local contrast = param.contrastV or 0 -- 选中装备 战力属性值
  193. local comparison = param.comparisonV or comparison1 -- 选中装备 优先级
  194. if comparison1 > comparison or (param.powerSortIndex and powerSortIndex > param.powerSortIndex) then --优先级
  195. powerValue = math.abs(powerValue) + contrast + 1 -- 比选中装备战力高
  196. elseif comparison1 < comparison then
  197. powerValue = math.min(math.abs(powerValue), contrast - 1) -- 比选中装备战力低
  198. end
  199. return powerValue, powerSortIndex
  200. end
  201. function GetItemPowerValue_Hero(item, param)
  202. if not item or next(item) == nil then
  203. return 0
  204. end
  205. param = param or {}
  206. local HeroPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  207. local myJob = HeroPropertyProxy:GetRoleJob() or 3
  208. -- 基础属性
  209. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  210. local attributeCfg = ItemConfigProxy:GetItemDataByIndex(item.Index)
  211. local attList = {}
  212. local attrArray = string.split(attributeCfg.attribute or "", "|")
  213. for i, v in ipairs(attrArray) do
  214. if v and v ~= "" and string.len(v) > 0 then
  215. local vArray = string.split(v or "", "#")
  216. table.insert(attList, {
  217. id = tonumber(vArray[2]) or 3,
  218. value = tonumber(vArray[3]) or 0
  219. })
  220. end
  221. end
  222. local powerValue, powerSortIndex = CalculateAttPowerValue_Hero(attList, param.jobPower, param.powerSortIndex)
  223. local comparison1, job1 = ItemConfigProxy:GetItemComparison(item.Index)
  224. local contrast = param.contrastV or 0 --比对装备的属性值
  225. local comparison = param.comparisonV or comparison1 --比对装备的优先级
  226. if comparison1 > comparison or (param.powerSortIndex and powerSortIndex > param.powerSortIndex) then --优先级
  227. powerValue = math.abs(powerValue) + contrast + 1 --自身战力 + 对比装备的战力( > 对比装备的战力 ) 1(避免等于0的情况)
  228. elseif comparison1 < comparison then
  229. powerValue = math.min(math.abs(powerValue), contrast - 1) --对比装备的战力 + > 自身战力( < 对比装备的战力 )1(避免等于0的情况)
  230. end
  231. return powerValue, powerSortIndex
  232. end
  233. -- attList: 属性 isJobPower: 是否是只要对比 sortIndex:对比的属性下标(按照职业 按照属性 先比较匹配的属性 再比较物防 最后比较魔防 都是上限属性)
  234. function CalculateAttPowerValue(attList, isJobPower, sortIndex)
  235. local PShowAttType = GUIFunction:PShowAttType()
  236. local power = -1
  237. local AttrConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.AttrConfigProxy)
  238. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  239. local myJob = PlayerPropertyProxy:GetRoleJob() or 0
  240. local jobPowerAttIds = {
  241. [PShowAttType.Max_DEF] = 2,
  242. [PShowAttType.Max_MDF] = 1
  243. }
  244. --[[ 按照职业 按照属性 先比较匹配的属性 再比较物防 最后比较魔防 都是上限属性
  245. 战士=攻击
  246. 法师=魔法
  247. 道士=道术
  248. ]]
  249. if isJobPower then
  250. if myJob == 0 then --战士
  251. jobPowerAttIds[PShowAttType.Max_ATK] = 3
  252. elseif myJob == 1 then --法师
  253. jobPowerAttIds[PShowAttType.Max_MAT] = 3
  254. elseif myJob == 2 then --道士
  255. jobPowerAttIds[PShowAttType.Max_Daoshu] = 3
  256. end
  257. end
  258. local powers = {}
  259. local powerSortIndex = 0
  260. for k, v in pairs(attList) do
  261. if jobPowerAttIds[v.id] then
  262. local score = v.value
  263. powers[jobPowerAttIds[v.id]] = score
  264. if jobPowerAttIds[v.id] > powerSortIndex and score > 0 then
  265. powerSortIndex = jobPowerAttIds[v.id]
  266. end
  267. end
  268. end
  269. if sortIndex and powerSortIndex <= sortIndex then
  270. powerSortIndex = sortIndex
  271. end
  272. power = powers[powerSortIndex] or -1
  273. return power, powerSortIndex
  274. end
  275. -- attList: 属性 isJobPower: 是否是只要对比 sortIndex:对比的属性下标(按照职业 按照属性 先比较匹配的属性 再比较物防 最后比较魔防 都是上限属性)
  276. function CalculateAttPowerValue_Hero(attList, isJobPower, sortIndex)
  277. local PShowAttType = GUIFunction:PShowAttType()
  278. local power = -1
  279. local AttrConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.AttrConfigProxy)
  280. local HeroPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  281. local myJob = HeroPropertyProxy:GetRoleJob() or 0
  282. local jobPowerAttIds = {
  283. [PShowAttType.Max_DEF] = 2,
  284. [PShowAttType.Max_MDF] = 1
  285. }
  286. --[[ 按照职业 按照属性 先比较匹配的属性 再比较物防 最后比较魔防 都是上限属性
  287. 战士=攻击
  288. 法师=魔法
  289. 道士=道术
  290. ]]
  291. if isJobPower then
  292. if myJob == 0 then --战士
  293. jobPowerAttIds[PShowAttType.Max_ATK] = 3
  294. elseif myJob == 1 then --法师
  295. jobPowerAttIds[PShowAttType.Max_MAT] = 3
  296. elseif myJob == 2 then --道士
  297. jobPowerAttIds[PShowAttType.Max_Daoshu] = 3
  298. end
  299. end
  300. local powers = {}
  301. local powerSortIndex = 0
  302. for k, v in pairs(attList) do
  303. if jobPowerAttIds[v.id] then
  304. local score = v.value
  305. powers[jobPowerAttIds[v.id]] = score
  306. if jobPowerAttIds[v.id] > powerSortIndex and score > 0 then
  307. powerSortIndex = jobPowerAttIds[v.id]
  308. end
  309. end
  310. end
  311. if sortIndex and powerSortIndex <= sortIndex then
  312. powerSortIndex = sortIndex
  313. end
  314. power = powers[powerSortIndex] or -1
  315. return power, powerSortIndex
  316. end
  317. local GET_CEHCK_VALUE = {
  318. --等级
  319. [0] = function( isHero )
  320. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  321. local proxy = global.Facade:retrieveProxy(proxyTable)
  322. return proxy:GetRoleLevel()
  323. end,
  324. --属性:攻击
  325. [1] = function( isHero )
  326. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  327. local proxy = global.Facade:retrieveProxy(proxyTable)
  328. return proxy:GetRoleAttByAttType( GUIFunction:PShowAttType().Max_ATK )
  329. end,
  330. --属性: 魔法
  331. [2] = function( isHero )
  332. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  333. local proxy = global.Facade:retrieveProxy(proxyTable)
  334. return proxy:GetRoleAttByAttType( GUIFunction:PShowAttType().Max_MAT )
  335. end,
  336. --属性: 道术
  337. [3] = function( isHero )
  338. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  339. local proxy = global.Facade:retrieveProxy(proxyTable)
  340. return proxy:GetRoleAttByAttType( GUIFunction:PShowAttType().Max_Daoshu )
  341. end,
  342. -- 转生等级
  343. [4] = function(isHero)
  344. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  345. local proxy = global.Facade:retrieveProxy(proxyTable)
  346. return proxy:GetRoleReinLv()
  347. end,
  348. -- 声望值
  349. [5] = function( isHero )
  350. local proxy = global.Facade:retrieveProxy(global.ProxyTable.PayProxy)
  351. return proxy:GetItemCount(15,true)
  352. end,
  353. -- 是否加入行会
  354. [6] = function ( isHero )
  355. local proxy = global.Facade:retrieveProxy(global.ProxyTable.GuildPlayerProxy)
  356. return proxy:IsJoinGuild()
  357. end,
  358. -- 是否是沙城成员
  359. [7] = function( isHero )
  360. local proxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  361. return proxy:IsShabakeMember()
  362. end,
  363. -- 是否是行会会长
  364. [8] = function( isHero )
  365. local proxy = global.Facade:retrieveProxy(global.ProxyTable.GuildPlayerProxy)
  366. return proxy:IsMaster()
  367. end,
  368. -- 是否是沙城会长
  369. [9] = function( isHero )
  370. local proxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  371. return proxy:IsShabakeAdmin()
  372. end,
  373. -- 获取职业
  374. [10] = function( isHero )
  375. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  376. local proxy = global.Facade:retrieveProxy(proxyTable)
  377. return proxy:GetRoleJob()
  378. end,
  379. -- 获取货币
  380. [11] = function(costID)
  381. if not costID then
  382. return 0
  383. end
  384. local PayProxy = global.Facade:retrieveProxy(global.ProxyTable.PayProxy)
  385. return PayProxy:GetItemCount(costID)
  386. end,
  387. -- 获取属性值
  388. [12] = function(attrID, isHero)
  389. if not attrID then
  390. return
  391. end
  392. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  393. local proxy = global.Facade:retrieveProxy(proxyTable)
  394. return proxy:GetRoleAttByAttType(attrID)
  395. end,
  396. -- 刺术 刺客属性
  397. [13] = function(isHero)
  398. local proxyTable = isHero and global.ProxyTable.HeroPropertyProxy or global.ProxyTable.PlayerProperty
  399. local proxy = global.Facade:retrieveProxy(proxyTable)
  400. return proxy:GetRoleAttByAttType(GUIFunction:PShowAttType().Max_Prick)
  401. end,
  402. }
  403. local CHECK_USE_NEED = {}
  404. local M_CHECK_USE_NEED = {
  405. -- 等级 聚灵珠客户端不判断等级
  406. [0] = function( param, isHero )
  407. local level = param.value or 0
  408. if param.StdMode == 49 or level <= 0 then
  409. return true,{}
  410. end
  411. local gValue = GET_CEHCK_VALUE[0]( isHero )
  412. local canUse = gValue >= level
  413. return canUse, { {str=string.format(GET_STRING(80010000), level), can = canUse} }
  414. end,
  415. -- 攻
  416. [1] = function( param,isHero )
  417. local dc = param.value or 0
  418. local gValue = GET_CEHCK_VALUE[1]( isHero )
  419. local canUse = gValue >= dc
  420. return canUse, { {str=string.format(GET_STRING(80010001),dc), can = canUse} }
  421. end,
  422. -- 魔
  423. [2] = function( param,isHero )
  424. local mc = param.value or 0
  425. local gValue = GET_CEHCK_VALUE[2]( isHero )
  426. local canUse = gValue >= mc
  427. return canUse, { {str=string.format(GET_STRING(80010002),mc), can = canUse} }
  428. end,
  429. -- 道
  430. [3] = function( param,isHero )
  431. local sc = param.value or 0
  432. local gValue = GET_CEHCK_VALUE[3]( isHero )
  433. local canUse = gValue >= sc
  434. return canUse, { {str=string.format(GET_STRING(80010003),sc), can = canUse} }
  435. end,
  436. -- 转生
  437. [4] = function( param,isHero )
  438. local value = param.value or 0
  439. local gValue = GET_CEHCK_VALUE[4]( isHero )
  440. local canUse = gValue >= value
  441. return canUse, { {str=string.format(GET_STRING(80010004),value), can = canUse} }
  442. end,
  443. --需要指定声望点
  444. [5] = function( param,isHero )
  445. local value = param.value or 0
  446. local gValue = GET_CEHCK_VALUE[5]( isHero )
  447. local canUse = gValue >= value
  448. return canUse, { {str=string.format(GET_STRING(80010005),value), can = canUse} }
  449. end,
  450. -- 是否加入行会
  451. [6] = function( param,isHero )
  452. local canUse = GET_CEHCK_VALUE[6]( isHero )
  453. return canUse, { {str=GET_STRING(80010006), can = canUse} }
  454. end,
  455. -- 沙城成员 不做检测 默认满足
  456. [7] = function( param,isHero )
  457. return true, { {str=GET_STRING(80010007), can = true} }
  458. end,
  459. -- 指定职业和等级
  460. [10] = function( param,isHero )
  461. if param.StdMode == 49 then
  462. return true,{}
  463. end
  464. local value = param.value or 0
  465. local job = L16Bit(value)
  466. local canUse = job == 99
  467. local conditions= {}
  468. if not canUse then
  469. local combJob = {[0] = 0, [1] = 1, [2] = 2} -- 人物、英雄通用
  470. local heroJob = {[3] = 3, [4] = 4, [5] = 5}
  471. local playerJob = {[6] = 6, [7] = 7, [8] = 8}
  472. if combJob[job] then
  473. canUse = job == GET_CEHCK_VALUE[10](isHero)
  474. conditions[1] = {str = string.format(GET_STRING(80010083), GET_STRING(50000324 + job)), can = canUse}
  475. elseif heroJob[job] then
  476. canUse = job == GET_CEHCK_VALUE[10](true)
  477. conditions[1] = {str = string.format(GET_STRING(80010086), GET_STRING(50000324 + job - 3)), can = canUse}
  478. elseif playerJob[job] then
  479. local job = job - 6
  480. canUse = job == GET_CEHCK_VALUE[10]()
  481. conditions[1] = {str = string.format(GET_STRING(80010085), GET_STRING(50000324 + job)), can = canUse}
  482. end
  483. end
  484. local levelCanUse,condition = CHECK_USE_NEED[0]( {
  485. StdMode = param.StdMode,
  486. value = H16Bit(value),
  487. }, isHero )
  488. conditions[2] = condition[1]
  489. return canUse and levelCanUse,conditions
  490. end,
  491. -- 指定职业和攻击力
  492. [11] = function( param,isHero )
  493. if param.StdMode == 49 then
  494. return true,{}
  495. end
  496. local value = param.value or 0
  497. local job = L16Bit(value)
  498. local canUse = job == 99
  499. local conditions= {}
  500. if not canUse then
  501. local combJob = {[0] = 0, [1] = 1, [2] = 2} -- 人物、英雄通用
  502. local heroJob = {[3] = 3, [4] = 4, [5] = 5}
  503. local playerJob = {[6] = 6, [7] = 7, [8] = 8}
  504. if combJob[job] then
  505. canUse = job == GET_CEHCK_VALUE[10](isHero)
  506. conditions[1] = {str = string.format(GET_STRING(80010083), GET_STRING(50000324 + job)), can = canUse}
  507. elseif heroJob[job] then
  508. canUse = job == GET_CEHCK_VALUE[10](true)
  509. conditions[1] = {str = string.format(GET_STRING(80010086), GET_STRING(50000324 + job - 3)), can = canUse}
  510. elseif playerJob[job] then
  511. local job = job - 6
  512. canUse = job == GET_CEHCK_VALUE[10]()
  513. conditions[1] = {str = string.format(GET_STRING(80010085), GET_STRING(50000324 + job)), can = canUse}
  514. end
  515. end
  516. local dcCanUse,condition = CHECK_USE_NEED[1]( {
  517. StdMode = param.StdMode,
  518. value = H16Bit(value),
  519. }, isHero )
  520. conditions[2] = condition[1]
  521. return canUse and dcCanUse,conditions
  522. end,
  523. -- 12:指定职业和魔法力
  524. [12] = function( param,isHero )
  525. if param.StdMode == 49 then
  526. return true,{}
  527. end
  528. local value = param.value or 0
  529. local job = L16Bit(value)
  530. local canUse = job == 99
  531. local conditions= {}
  532. if not canUse then
  533. local combJob = {[0] = 0, [1] = 1, [2] = 2} -- 人物、英雄通用
  534. local heroJob = {[3] = 3, [4] = 4, [5] = 5}
  535. local playerJob = {[6] = 6, [7] = 7, [8] = 8}
  536. if combJob[job] then
  537. canUse = job == GET_CEHCK_VALUE[10](isHero)
  538. conditions[1] = {str = string.format(GET_STRING(80010083), GET_STRING(50000324 + job)), can = canUse}
  539. elseif heroJob[job] then
  540. canUse = job == GET_CEHCK_VALUE[10](true)
  541. conditions[1] = {str = string.format(GET_STRING(80010086), GET_STRING(50000324 + job - 3)), can = canUse}
  542. elseif playerJob[job] then
  543. local job = job - 6
  544. canUse = job == GET_CEHCK_VALUE[10]()
  545. conditions[1] = {str = string.format(GET_STRING(80010085), GET_STRING(50000324 + job)), can = canUse}
  546. end
  547. end
  548. local mcCanUse,condition = CHECK_USE_NEED[2]( {
  549. StdMode = param.StdMode,
  550. value = H16Bit(value),
  551. }, isHero )
  552. conditions[2] = condition[1]
  553. return canUse and mcCanUse,conditions
  554. end,
  555. -- 13:指定职业和道术
  556. [13] = function( param,isHero )
  557. if param.StdMode == 49 then
  558. return true,{}
  559. end
  560. local value = param.value or 0
  561. local job = L16Bit(value)
  562. local canUse = job == 99
  563. local conditions= {}
  564. if not canUse then
  565. local combJob = {[0] = 0, [1] = 1, [2] = 2} -- 人物、英雄通用
  566. local heroJob = {[3] = 3, [4] = 4, [5] = 5}
  567. local playerJob = {[6] = 6, [7] = 7, [8] = 8}
  568. if combJob[job] then
  569. canUse = job == GET_CEHCK_VALUE[10](isHero)
  570. conditions[1] = {str = string.format(GET_STRING(80010083), GET_STRING(50000324 + job)), can = canUse}
  571. elseif heroJob[job] then
  572. canUse = job == GET_CEHCK_VALUE[10](true)
  573. conditions[1] = {str = string.format(GET_STRING(80010086), GET_STRING(50000324 + job - 3)), can = canUse}
  574. elseif playerJob[job] then
  575. local job = job - 6
  576. canUse = job == GET_CEHCK_VALUE[10]()
  577. conditions[1] = {str = string.format(GET_STRING(80010085), GET_STRING(50000324 + job)), can = canUse}
  578. end
  579. end
  580. local scCanUse,condition = CHECK_USE_NEED[3]( {
  581. StdMode = param.StdMode,
  582. value = H16Bit(value),
  583. }, isHero )
  584. conditions[2] = condition[1]
  585. return canUse and scCanUse,conditions
  586. end,
  587. --指定等级
  588. [14] = function( param,isHero )
  589. local level = param.value or 0
  590. local gValue = GET_CEHCK_VALUE[0]( isHero )
  591. local canUse = gValue == level
  592. return canUse, { {str=string.format(GET_STRING(80010084), level), can = canUse} }
  593. end,
  594. -- 等级 及转生
  595. [40] = function( param,isHero )
  596. local value = param.value or 0
  597. local checkParam = {
  598. StdMode = param.StdMode,
  599. value = H16Bit(value)
  600. }
  601. local levelCanUse,condition1 = CHECK_USE_NEED[0]( checkParam,isHero )
  602. checkParam.value = L16Bit(value)
  603. local reinLVCanUse,condition2 = CHECK_USE_NEED[4]( checkParam,isHero )
  604. return levelCanUse and reinLVCanUse, { condition1[1], condition2[1] }
  605. end,
  606. -- 攻 及转生
  607. [41] = function( param,isHero )
  608. local value = param.value or 0
  609. local checkParam = {
  610. StdMode = param.StdMode,
  611. value = H16Bit(value)
  612. }
  613. local levelCanUse,condition1 = CHECK_USE_NEED[1]( checkParam,isHero )
  614. checkParam.value = L16Bit(value)
  615. local reinLVCanUse,condition2 = CHECK_USE_NEED[4]( checkParam,isHero )
  616. return levelCanUse and reinLVCanUse, { condition2[1], condition1[1] }
  617. end,
  618. -- 魔 及转生
  619. [42] = function( param,isHero )
  620. local value = param.value or 0
  621. local checkParam = {
  622. StdMode = param.StdMode,
  623. value = H16Bit(value)
  624. }
  625. local levelCanUse,condition1 = CHECK_USE_NEED[2]( checkParam,isHero )
  626. checkParam.value = L16Bit(value)
  627. local reinLVCanUse,condition2 = CHECK_USE_NEED[4]( checkParam,isHero )
  628. return levelCanUse and reinLVCanUse, { condition2[1], condition1[1] }
  629. end,
  630. -- 道 及转生
  631. [43] = function( param,isHero )
  632. local value = param.value or 0
  633. local checkParam = {
  634. StdMode = param.StdMode,
  635. value = H16Bit(value)
  636. }
  637. local levelCanUse,condition1 = CHECK_USE_NEED[3]( checkParam,isHero )
  638. checkParam.value = L16Bit(value)
  639. local reinLVCanUse,condition2 = CHECK_USE_NEED[4]( checkParam,isHero )
  640. return levelCanUse and reinLVCanUse, { condition2[1], condition1[1] }
  641. end,
  642. --声望等级 指定声望点
  643. [44] = function( param,isHero )
  644. local value = param.value or 0
  645. local checkParam = {
  646. StdMode = param.StdMode,
  647. value = H16Bit(value)
  648. }
  649. local levelCanUse,condition1 = CHECK_USE_NEED[5]( checkParam,isHero )
  650. checkParam.value = L16Bit(value)
  651. local reinLVCanUse,condition2 = CHECK_USE_NEED[4]( checkParam,isHero )
  652. return levelCanUse and reinLVCanUse, { condition2[1], condition1[1] }
  653. end,
  654. -- 指定职业和转生等级
  655. [45] = function( param,isHero )
  656. if param.StdMode == 49 then
  657. return true,{}
  658. end
  659. local value = param.value or 0
  660. local job = H16Bit(value)
  661. local canUse = job == 99
  662. local conditions= {}
  663. if not canUse then
  664. local combJob = {[0] = 0, [1] = 1, [2] = 2} -- 人物、英雄通用
  665. local heroJob = {[3] = 3, [4] = 4, [5] = 5}
  666. local playerJob = {[6] = 6, [7] = 7, [8] = 8}
  667. if combJob[job] then
  668. canUse = job == GET_CEHCK_VALUE[10](isHero)
  669. conditions[1] = {str = string.format(GET_STRING(80010083), GET_STRING(50000324 + job)), can = canUse}
  670. elseif heroJob[job] then
  671. canUse = job == GET_CEHCK_VALUE[10](true)
  672. conditions[1] = {str = string.format(GET_STRING(80010086), GET_STRING(50000324 + job - 3)), can = canUse}
  673. elseif playerJob[job] then
  674. local job = job - 6
  675. canUse = job == GET_CEHCK_VALUE[10]()
  676. conditions[1] = {str = string.format(GET_STRING(80010085), GET_STRING(50000324 + job)), can = canUse}
  677. end
  678. end
  679. local reinLVCanUse,condition = CHECK_USE_NEED[4]( {
  680. StdMode = param.StdMode,
  681. value = L16Bit(value),
  682. },isHero )
  683. conditions[2] = condition[1]
  684. return canUse and reinLVCanUse,conditions
  685. end,
  686. -- 是否是行会会长
  687. [60] = function( param,isHero )
  688. local value = param.value or 0
  689. local canUse = GET_CEHCK_VALUE[8]( isHero )
  690. return canUse,{ {str=GET_STRING(80010060), can = canUse} }
  691. end,
  692. -- 沙城会长 不做检测 默认满足
  693. [70] = function( param, isHero )
  694. return true,{ {str=GET_STRING(80010070), can = true} }
  695. end,
  696. -- 110 - 120 新增 [职业判断无额外设定]
  697. -- 指定职业和等级
  698. [110] = function (param, isHero)
  699. local job = param.value or 99
  700. local value2 = param.value2 or 0
  701. local canUse = job == 99
  702. local conditions= {}
  703. if not canUse then
  704. canUse = job == GET_CEHCK_VALUE[10](isHero)
  705. conditions[1] = {str = string.format(GET_STRING(80010083), GetJobName(job)), can = canUse}
  706. end
  707. local levelCanUse, condition = CHECK_USE_NEED[0]({
  708. StdMode = param.StdMode,
  709. value = value2,
  710. }, isHero)
  711. conditions[2] = condition[1]
  712. return canUse and levelCanUse, conditions
  713. end,
  714. -- 指定职业和攻击力
  715. [111] = function(param, isHero)
  716. if param.StdMode == 49 then
  717. return true, {}
  718. end
  719. local job = param.value or 99
  720. local value2 = param.value2 or 0
  721. local canUse = job == 99
  722. local conditions= {}
  723. if not canUse then
  724. canUse = job == GET_CEHCK_VALUE[10](isHero)
  725. conditions[1] = {str = string.format(GET_STRING(80010083), GetJobName(job)), can = canUse}
  726. end
  727. local dcCanUse, condition = CHECK_USE_NEED[1]({
  728. StdMode = param.StdMode,
  729. value = value2,
  730. }, isHero)
  731. conditions[2] = condition[1]
  732. return canUse and dcCanUse, conditions
  733. end,
  734. -- 112:指定职业和魔法力
  735. [112] = function(param, isHero)
  736. if param.StdMode == 49 then
  737. return true, {}
  738. end
  739. local job = param.value or 99
  740. local value2 = param.value2 or 0
  741. local canUse = job == 99
  742. local conditions= {}
  743. if not canUse then
  744. canUse = job == GET_CEHCK_VALUE[10](isHero)
  745. conditions[1] = {str = string.format(GET_STRING(80010083), GetJobName(job)), can = canUse}
  746. end
  747. local mcCanUse,condition = CHECK_USE_NEED[2]({
  748. StdMode = param.StdMode,
  749. value = value2,
  750. }, isHero)
  751. conditions[2] = condition[1]
  752. return canUse and mcCanUse, conditions
  753. end,
  754. -- 113:指定职业和道术
  755. [113] = function(param, isHero)
  756. if param.StdMode == 49 then
  757. return true,{}
  758. end
  759. local job = param.value or 99
  760. local value2 = param.value2 or 0
  761. local canUse = job == 99
  762. local conditions= {}
  763. if not canUse then
  764. canUse = job == GET_CEHCK_VALUE[10](isHero)
  765. conditions[1] = {str = string.format(GET_STRING(80010083), GetJobName(job)), can = canUse}
  766. end
  767. local scCanUse,condition = CHECK_USE_NEED[3]({
  768. StdMode = param.StdMode,
  769. value = value2,
  770. }, isHero)
  771. conditions[2] = condition[1]
  772. return canUse and scCanUse, conditions
  773. end,
  774. -- 114: 指定货币
  775. [114] = function(param)
  776. local costID = param.value or 0
  777. if costID == 0 then
  778. return true, {}
  779. end
  780. -- 货币数量
  781. local value2 = param.value2 or 0
  782. if value2 <= 0 then
  783. return true, {}
  784. end
  785. local hasValue = GET_CEHCK_VALUE[11](costID)
  786. local MoneyProxy = global.Facade:retrieveProxy(global.ProxyTable.MoneyProxy)
  787. local costName = MoneyProxy:GetMoneyNameById(costID) or "无效货币"
  788. local canUse = hasValue >= value2
  789. return canUse, {{str=string.format(GET_STRING(80010100), costName, value2), can = canUse}}
  790. end,
  791. -- 115: 指定转生等级和等级
  792. [115] = function(param, isHero)
  793. local reLevel = param.value or 0
  794. local level = param.value2 or 0
  795. local checkParam = {
  796. StdMode = param.StdMode,
  797. value = reLevel
  798. }
  799. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  800. checkParam.value = level
  801. local levelCanUse, condition2 = CHECK_USE_NEED[0](checkParam, isHero)
  802. return reinLVCanUse and levelCanUse, {condition1[1], condition2[1]}
  803. end,
  804. -- 116: 指定转生等级和攻击力
  805. [116] = function(param, isHero)
  806. local reLevel = param.value or 0
  807. local value2 = param.value2 or 0
  808. local checkParam = {
  809. StdMode = param.StdMode,
  810. value = reLevel
  811. }
  812. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  813. checkParam.value = value2
  814. local canUse, condition2 = CHECK_USE_NEED[1](checkParam, isHero)
  815. return reinLVCanUse and canUse, {condition1[1], condition2[1]}
  816. end,
  817. -- 117: 指定转生等级和魔法力
  818. [117] = function(param, isHero)
  819. local reLevel = param.value or 0
  820. local value2 = param.value2 or 0
  821. local checkParam = {
  822. StdMode = param.StdMode,
  823. value = reLevel
  824. }
  825. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  826. checkParam.value = value2
  827. local canUse, condition2 = CHECK_USE_NEED[2](checkParam, isHero)
  828. return reinLVCanUse and canUse, {condition1[1], condition2[1]}
  829. end,
  830. -- 118: 指定转生等级和道术
  831. [118] = function(param, isHero)
  832. local reLevel = param.value or 0
  833. local value2 = param.value2 or 0
  834. local checkParam = {
  835. StdMode = param.StdMode,
  836. value = reLevel
  837. }
  838. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  839. checkParam.value = value2
  840. local canUse, condition2 = CHECK_USE_NEED[3](checkParam, isHero)
  841. return reinLVCanUse and canUse, {condition1[1], condition2[1]}
  842. end,
  843. -- 119: 指定转生等级和声望点
  844. [119] = function(param, isHero)
  845. local reLevel = param.value or 0
  846. local value2 = param.value2 or 0
  847. local checkParam = {
  848. StdMode = param.StdMode,
  849. value = reLevel
  850. }
  851. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  852. checkParam.value = value2
  853. local canUse, condition2 = CHECK_USE_NEED[5](checkParam, isHero)
  854. return reinLVCanUse and canUse, {condition1[1], condition2[1]}
  855. end,
  856. -- 120: 指定转生等级和职业
  857. [120] = function(param, isHero)
  858. if param.StdMode == 49 then
  859. return true, {}
  860. end
  861. local value = param.value or 0
  862. local job = param.value2 or 99
  863. local canUse = job == 99
  864. local conditions= {}
  865. local reinLVCanUse, condition = CHECK_USE_NEED[4]({
  866. StdMode = param.StdMode,
  867. value = value,
  868. }, isHero)
  869. conditions[1] = condition[1]
  870. if not canUse then
  871. canUse = job == GET_CEHCK_VALUE[10](isHero)
  872. conditions[2] = {str = string.format(GET_STRING(80010083), GetJobName(job)), can = canUse}
  873. end
  874. return canUse and reinLVCanUse, conditions
  875. end,
  876. -- 121: 指定职业和职业对应核心属性值以上
  877. [121] = function(param, isHero)
  878. if param.StdMode == 49 then
  879. return true, {}
  880. end
  881. local job = param.value or 99
  882. local value2 = param.value2 or 0
  883. local canUse = job == 99
  884. local conditions= {}
  885. if not canUse then
  886. canUse = job == GET_CEHCK_VALUE[10](isHero)
  887. conditions[1] = {str = string.format(GET_STRING(80010083), GetJobName(job)), can = canUse}
  888. end
  889. local attrCanUse = nil
  890. if job >= 5 and job <= 15 then
  891. local attId = GUIFunction:PShowAttType()["Max_CustJobAttr_" .. job]
  892. local attrValue = GET_CEHCK_VALUE[12](attId, isHero) or 0
  893. attrCanUse = attrValue >= value2
  894. local config = SL:GetMetaValue("ATTR_CONFIG", attId) or {}
  895. conditions[2] = {str = string.format(GET_STRING(80010100), config.name or string.format("职业%s核心属性", job), value2), can = attrCanUse}
  896. else
  897. local aCanUse, condition = CHECK_USE_NEED[job + 1]({
  898. StdMode = param.StdMode,
  899. value = value2,
  900. }, isHero)
  901. attrCanUse = aCanUse
  902. conditions[2] = condition[1]
  903. end
  904. return canUse and attrCanUse, conditions
  905. end,
  906. -- 122: 指定转生等级和刺客属性上限值
  907. [122] = function(param, isHero)
  908. local reLevel = param.value or 0
  909. local value2 = param.value2 or 0
  910. local conditions = {}
  911. local checkParam = {
  912. StdMode = param.StdMode,
  913. value = reLevel
  914. }
  915. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  916. conditions[1] = condition1[1]
  917. local attrValue = GET_CEHCK_VALUE[13](isHero) or 0
  918. local attrCanUse = attrValue >= value2
  919. local config = SL:GetMetaValue("ATTR_CONFIG", GUIFunction:PShowAttType().Max_Prick) or {}
  920. conditions[2] = {str = string.format(GET_STRING(80010100), config.name or "刺客核心属性", value2), can = attrCanUse}
  921. return reinLVCanUse and attrCanUse, conditions
  922. end,
  923. -- 123: 指定转生等级和职业5属性上限值
  924. -- 123 - 134 :职业5 - 15
  925. [123] = function(param, isHero)
  926. local reLevel = param.value or 0
  927. local value2 = param.value2 or 0
  928. local jobIdx = param.jobIdx or 0
  929. local conditions = {}
  930. local checkParam = {
  931. StdMode = param.StdMode,
  932. value = reLevel
  933. }
  934. local reinLVCanUse, condition1 = CHECK_USE_NEED[4](checkParam, isHero)
  935. conditions[1] = condition1[1]
  936. local job = 5 + jobIdx
  937. local attId = GUIFunction:PShowAttType()["Max_CustJobAttr_" .. job]
  938. local attrValue = GET_CEHCK_VALUE[12](attId, isHero) or 0
  939. local attrCanUse = attrValue >= value2
  940. local config = SL:GetMetaValue("ATTR_CONFIG", attId) or {}
  941. conditions[2] = {str = string.format(GET_STRING(80010100), config.name or string.format("职业%s核心属性", job), value2), can = attrCanUse}
  942. return reinLVCanUse and attrCanUse, conditions
  943. end,
  944. }
  945. CHECK_USE_NEED = M_CHECK_USE_NEED
  946. local COMMON_FUNC_IDX = 123
  947. local COMMON_FUNC_IDX_MAX = 134
  948. local function checkComFunc(needType)
  949. if needType >= COMMON_FUNC_IDX and needType <= COMMON_FUNC_IDX_MAX then
  950. local index = needType - COMMON_FUNC_IDX
  951. return COMMON_FUNC_IDX, index
  952. end
  953. end
  954. -- 服务器翻过来 用于前端检测道具使用
  955. function CheckItemUseNeed(item)
  956. local needType = item.Need
  957. local needLevel = item.NeedLevel
  958. local notCheckUse = true --不检测是否满足使用条件
  959. if not needType or not needLevel then
  960. return true,{},notCheckUse
  961. end
  962. local commonType, jobIdx = checkComFunc(needType)
  963. if not CHECK_USE_NEED[commonType or needType] then
  964. return true, {}, notCheckUse
  965. end
  966. local param = {
  967. StdMode = item.StdMode,
  968. value = needLevel,
  969. value2 = item.NeedLevelParam or 0,
  970. jobIdx = jobIdx
  971. }
  972. -- 聚灵珠不用判断显示
  973. if item.StdMode == 49 then
  974. return true, {}, notCheckUse
  975. end
  976. local canUse, conditionStr = CHECK_USE_NEED[commonType or needType](param)
  977. return canUse, conditionStr, notCheckUse
  978. end
  979. function CheckItemUseNeed_Hero(item)
  980. local needType = item.Need
  981. local needLevel = item.NeedLevel
  982. local notCheckUse = true --不检测是否满足使用条件
  983. if not needType or not needLevel then
  984. return true,{},notCheckUse
  985. end
  986. if not CHECK_USE_NEED[needType] then
  987. return true,{},notCheckUse
  988. end
  989. local param = {
  990. StdMode = item.StdMode,
  991. value = needLevel,
  992. value2 = item.NeedLevelParam or 0,
  993. }
  994. local canUse,conditionStr = CHECK_USE_NEED[needType](param,true)
  995. return canUse,conditionStr,notCheckUse
  996. end