EquipGem_1.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. EquipGem = {}
  2. function gemtest(actor, msgData)
  3. -- local a = {}
  4. -- a.schemepos = 1
  5. -- a.idxOfBag = 10102
  6. -- a.idxOfEquip = 65538
  7. -- EquipGem.schemeInfo(actor,msgData)
  8. -- EquipGem.putOnGemOrSlabstone(actor,a)
  9. -- EquipGem.takeOffGemOrSlabstone(actor,a)
  10. -- EquipGem.schemeSwitch(actor,a)
  11. end
  12. -- 萤石方案详情
  13. function EquipGem.schemeInfo(actor, msgData)
  14. local gemScheme = getGemscheme(actor)
  15. sendluamsg(actor, LuaMessageIdToClient.RES_GEM_SCHEME, gemScheme)
  16. end
  17. -- 萤石方案镶嵌宝石或者石板
  18. function EquipGem.putOnGemOrSlabstone(actor, msgData)
  19. local idx = msgData.idxOfBag
  20. local idxOfEquip = msgData.idxOfEquip
  21. local pos = idxOfEquip
  22. local wearBar = nil
  23. if idx < 10000 then
  24. tipinfo(actor, "找不到物品")
  25. return
  26. end
  27. local gem = getbagiteminfo(actor, idx)
  28. -- 判断镶嵌的是宝石还是石板 有wearBar的是宝石
  29. if tonumber(idxOfEquip) > 0xFFFF then
  30. wearBar = gameequip.wearBar(idxOfEquip)
  31. pos = gameequip.pos(idxOfEquip)
  32. end
  33. if not gem then
  34. tipinfo(actor, "找不到物品")
  35. return
  36. end
  37. local gemId = gem.cfgid
  38. if not cellVerify(actor, gemId, idxOfEquip) then
  39. return
  40. end
  41. if not removeitembyidxlist(actor, {[idx] = 1}, 9999, "荧石") then
  42. tipinfo(actor, "移除物品失败")
  43. return
  44. end
  45. local gemScheme = getGemscheme(actor)
  46. local schemepos = gemScheme.cur
  47. local schemeData = gemScheme.data[schemepos]
  48. local part = schemeData.scheme[pos]
  49. if part == nil then
  50. schemeData.scheme[pos] = {}
  51. part = schemeData.scheme[pos]
  52. part.active = true
  53. end
  54. -- 判断镶嵌的是宝石还是石板
  55. if wearBar ~= nil then
  56. if part.gems == nil then
  57. part.gems = {}
  58. end
  59. local filledGem = part.gems[wearBar]
  60. if filledGem then
  61. Bag.addItemToBag(actor, tonumber(filledGem), 1, 0, 9999, "荧石")
  62. end
  63. part.gems[wearBar] = gemId
  64. else
  65. if part.stone then
  66. Bag.addItemToBag(actor, tonumber(part.stone), 1, 0, 9999, "荧石")
  67. end
  68. part.stone = gemId
  69. end
  70. setplaydef(actor, "T$gemscheme", gemScheme)
  71. updateAttr(actor, gemScheme)
  72. sendluamsg(actor, LuaMessageIdToClient.RES_GEM_CURRENT_SCHEME, schemeData)
  73. -- 刷新任务进度
  74. EquipGem.flushGemTask(actor)
  75. end
  76. -- 萤石方案里卸载宝石或者石板
  77. function EquipGem.takeOffGemOrSlabstone(actor, msgData)
  78. local idxOfEquip = msgData.idxOfEquip
  79. local pos = idxOfEquip
  80. local wearBar = nil
  81. -- 判断镶嵌的是宝石还是石板 有wearBar的是宝石
  82. if idxOfEquip > 0xFFFF then
  83. wearBar = gameequip.wearBar(idxOfEquip)
  84. pos = gameequip.pos(idxOfEquip)
  85. end
  86. local gemScheme = getGemscheme(actor)
  87. local schemepos = gemScheme.cur
  88. local schemeData = gemScheme.data[schemepos]
  89. local part = schemeData.scheme[pos]
  90. if part == nil then
  91. schemeData.scheme[pos] = {}
  92. part = schemeData.scheme[pos]
  93. end
  94. -- 判断镶嵌的是宝石还是石板
  95. if wearBar ~= nil then
  96. if part.gems == nil then
  97. part.gems = {}
  98. end
  99. local filledGem = part.gems[wearBar]
  100. if filledGem then
  101. Bag.addItemToBag(actor, tonumber(filledGem), 1, 0, 9999, "荧石")
  102. else
  103. tipinfo(actor, "找不到物品")
  104. return
  105. end
  106. part.gems[wearBar] = nil
  107. else
  108. if part.stone then
  109. Bag.addItemToBag(actor, tonumber(part.stone), 1, 0, 9999, "荧石")
  110. else
  111. tipinfo(actor, "找不到物品")
  112. return
  113. end
  114. part.stone = nil
  115. end
  116. setplaydef(actor, "T$gemscheme", gemScheme)
  117. updateAttr(actor, gemScheme)
  118. sendluamsg(actor, LuaMessageIdToClient.RES_GEM_CURRENT_SCHEME, schemeData)
  119. EquipGem.flushGemTask(actor)
  120. end
  121. -- 萤石方案切换
  122. function EquipGem.schemeSwitch(actor, msgData)
  123. local schemepos = msgData.schemepos
  124. local gemScheme = getGemscheme(actor)
  125. local scheme = gemScheme.data[schemepos]
  126. if scheme == nil then
  127. tipinfo(actor, "找不到方案")
  128. return
  129. end
  130. local oldpos = gemScheme.cur
  131. local oldscheme = gemScheme.data[oldpos]
  132. if oldscheme == nil then
  133. tipinfo(actor, "找不到方案")
  134. return
  135. end
  136. if gemScheme.cur == schemepos then
  137. tipinfo(actor, "方案已激活")
  138. return
  139. end
  140. -- 老方案的宝石全部返回背包
  141. -- if oldscheme.scheme then
  142. -- for _,part in pairs(oldscheme.scheme) do
  143. -- if part.gems then
  144. -- for _, gemId in pairs(part.gems) do
  145. -- additemtobag(actor, tonumber(gemId), 1)
  146. -- end
  147. -- end
  148. -- if part.stone then
  149. -- additemtobag(actor, tonumber(part.stone), 1)
  150. -- end
  151. -- end
  152. -- end
  153. -- 新方案的宝石从背包里扣除 不够扣移除宝石
  154. -- if scheme.scheme then
  155. -- for _,part in pairs(scheme.scheme) do
  156. -- if part.gems then
  157. -- local removes = {}
  158. -- for key, gemId in pairs(part.gems) do
  159. -- if not removeitemfrombag(actor, tonumber(gemId), 1) then
  160. -- --记录宝石不足的遍历后移除
  161. -- table.insert(removes, gemId)
  162. -- end
  163. -- end
  164. -- for _, key in pairs(removes) do
  165. -- part.gems[key] = nil
  166. -- end
  167. -- end
  168. -- if part.stone then
  169. -- if not removeitemfrombag(actor, tonumber(part.stone), 1) then
  170. -- part.stone = nil
  171. -- end
  172. -- end
  173. -- end
  174. -- end
  175. oldscheme.active = false
  176. scheme.active = true
  177. gemScheme.cur = schemepos
  178. setplaydef(actor, "T$gemscheme", gemScheme)
  179. updateAttr(actor, gemScheme)
  180. sendluamsg(actor, LuaMessageIdToClient.RES_GEM_CURRENT_SCHEME, scheme)
  181. EquipGem.flushGemTask(actor)
  182. end
  183. -- 刷新镶嵌宝石任务进度
  184. function EquipGem.flushGemTask(actor)
  185. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.INLAID_GEMSTONES)
  186. end
  187. function EquipGem.getAllGemCount(actor)
  188. local final_count = 0
  189. local gem_info = getGemscheme(actor)
  190. local scheme_info = gem_info.data[gem_info.cur].scheme
  191. if table.isEmpty(scheme_info) then
  192. return final_count
  193. end
  194. for _, info in pairs(scheme_info) do
  195. if info.active then
  196. local value = table.isEmpty(info.gems) and 0 or #info.gems
  197. final_count = final_count + value
  198. end
  199. end
  200. return final_count
  201. end
  202. -- 装备是否生效影响 萤石方案属性 是否失效
  203. function EquipGem.schemeEffectByBoolean(actor, map, effect)
  204. local gemScheme = getGemscheme(actor)
  205. local cur = gemScheme.cur
  206. -- local scheme = gemScheme.data[gemScheme.cur]
  207. for schemeIndex, scheme in pairs(gemScheme.data) do
  208. local update = false
  209. for _, pos in pairs(map) do
  210. local data = scheme.scheme[pos]
  211. if data and data.active ~= effect then
  212. data.active = effect
  213. update = true
  214. end
  215. end
  216. -- 当前方案某装备激活,更新对应属性
  217. local isCur = (cur == schemeIndex)
  218. if update and isCur then
  219. updateAttr(actor, gemScheme)
  220. end
  221. setplaydef(actor, "T$gemscheme", gemScheme)
  222. -- 测试看数据 sendluamsg(actor,LuaMessageIdToClient.RES_GEM_SCHEME,gemScheme)
  223. end
  224. end
  225. function EquipGem.getOtherGemScheme(actor, msgData)
  226. local rid = msgData.rid
  227. if not rid then
  228. return
  229. end
  230. local player = getactor(actor, rid)
  231. if not player then
  232. return
  233. end
  234. local gemScheme = getGemscheme(player)
  235. if actor:toString() ~= player:toString() then
  236. gemScheme.rid = rid
  237. end
  238. sendluamsg(actor, LuaMessageIdToClient.RES_GEM_SCHEME, gemScheme)
  239. end
  240. -- 更新萤石方案属性
  241. function updateAttr(actor, gemScheme)
  242. local cur = gemScheme.cur
  243. local gemScheme = gemScheme.data[cur]
  244. local allattr = {}
  245. local suit = {}
  246. for _, data in pairs(gemScheme.scheme) do
  247. if data.active == true then
  248. local stoneId = data.stone
  249. local attrUp = nil
  250. if stoneId then
  251. -- 石板属性
  252. local stoneAtt =
  253. string.getAttrByStr(
  254. ConfigDataManager.getTableValue("cfg_equip_stoneBoard", "stoneAtt", "id", stoneId)
  255. )
  256. table.mergeAdd(allattr, stoneAtt)
  257. attrUp =
  258. string.getAttrByStr(
  259. ConfigDataManager.getTableValue("cfg_equip_stoneBoard", "stoneAtt2", "id", stoneId)
  260. )
  261. end
  262. -- 萤石属性
  263. if data.gems then
  264. for _, gemId in pairs(data.gems) do
  265. local gemAtt =
  266. string.getAttrByStr(ConfigDataManager.getTableValue("cfg_equip_gem", "gemAtt", "id", gemId))
  267. local lr = string.LR(ConfigDataManager.getTableValue("cfg_equip_gem", "gemBelong", "id", gemId))
  268. -- 萤石属性增强
  269. if (attrUp ~= nil and attrUp[lr.left] ~= nil) then
  270. gemAtt = attrUpByPc(gemAtt, attrUp[lr.left])
  271. end
  272. suit[lr.left] = (suit[lr.left] and suit[lr.left] or 0) + tonumber(lr.right)
  273. table.mergeAdd(allattr, gemAtt)
  274. end
  275. end
  276. end
  277. end
  278. -- 萤石套装属性
  279. local suitConfigs = ConfigDataManager.getList("cfg_equip_gemSuit")
  280. local suitAttr = {}
  281. local activeSuitConfig = {}
  282. for k, v in pairs(suit) do
  283. for _, config in pairs(suitConfigs) do
  284. local lr = string.LR(config.gemcondition)
  285. if k == lr.left and v >= tonumber(lr.right) then
  286. if
  287. activeSuitConfig[k] == nil or
  288. tonumber(lr.right) > tonumber(string.LR(activeSuitConfig[k].gemcondition).right)
  289. then
  290. activeSuitConfig[k] = config
  291. end
  292. end
  293. end
  294. end
  295. -- 学习套装技能
  296. -- for k, config in pairs(activeSuitConfig) do
  297. -- table.mergeAdd(suitAttr,string.getAttrByStr(config.suitatt)) 暂时无属性不加成套装属性
  298. -- local lr = string.LR(config.skill)
  299. -- levelupskill(actor,lr.left,lr.right)
  300. -- print("套装id:"..config.id.." 套装类型:"..k)
  301. -- print("学习技能id:"..lr.left.." 技能等级:"..lr.right)
  302. -- end
  303. table.mergeAdd(allattr, suitAttr)
  304. local activeIds = {}
  305. for _, config in pairs(activeSuitConfig) do
  306. table.insert(activeIds, config.id)
  307. end
  308. -- setplaydef(actor, "T$gemSuitConfig", activeSuitConfig)
  309. setplaydef(actor, "T$gemSuitConfig", activeIds)
  310. -- 测试看数据 sendluamsg(actor,LuaMessageIdToClient.RES_GEM_SCHEME,{["总属性"]= allattr})
  311. addrolekmlattributes(actor, "gemscheme", allattr)
  312. end
  313. function attrUpByPc(attr_map, attr_up)
  314. attr = {}
  315. for key, value in pairs(attr_map) do
  316. attr[key] = math.ceil(value * (1 + attr_up / 10000.0))
  317. end
  318. return attr
  319. end
  320. function cellVerify(actor, itemid, idxOfEquip)
  321. -- 判断镶嵌的是宝石还是石板
  322. if idxOfEquip > 0xFFFF then
  323. local reqWearBar = gameequip.wearBar(idxOfEquip)
  324. local reqPos = gameequip.pos(idxOfEquip)
  325. local configPos = ConfigDataManager.getTableValue("cfg_equip_gem", "wearbarPos", "id", itemid)
  326. local configWearbar = ConfigDataManager.getTableValue("cfg_equip_gem", "wearbar", "id", itemid)
  327. if not string.contains(configWearbar, reqWearBar) or not string.contains(configPos, reqPos) then
  328. tipinfo(actor, "该位置无法镶嵌")
  329. return false
  330. end
  331. else
  332. local reqPos = idxOfEquip
  333. local configPos = ConfigDataManager.getTableValue("cfg_equip_stoneBoard", "pos", "id", itemid)
  334. if not string.contains(configPos, reqPos) then
  335. tipinfo(actor, "该位置无法镶嵌")
  336. return false
  337. end
  338. end
  339. return true
  340. end
  341. function getGemscheme(actor)
  342. local playData = getplaydef(actor, "T$gemscheme")
  343. if playData == nil then
  344. playData = gemschemeInit(actor)
  345. end
  346. return playData
  347. end
  348. function gemschemeInit(actor)
  349. local gemScheme = {}
  350. gemScheme.data = {}
  351. for i = 1, 2, 1 do
  352. local scheme = {}
  353. scheme.pos = i
  354. scheme.scheme = {}
  355. if i == 1 then
  356. scheme.active = true
  357. gemScheme.cur = i
  358. else
  359. scheme.active = false
  360. end
  361. table.insert(gemScheme.data, scheme.pos, scheme)
  362. end
  363. setplaydef(actor, "T$gemscheme", gemScheme)
  364. return gemScheme
  365. end
  366. -- =======套装属性相关=======
  367. function EquipGem.getConfigByAttr(configs, attrName)
  368. for _, cfg in pairs(configs) do
  369. local value = cfg[string.lower(attrName)]
  370. if value and value ~= "" then
  371. -- lg(value)
  372. return cfg
  373. end
  374. end
  375. return nil
  376. end
  377. function EquipGem.getConfigByIdAndAttr(activeIds, attrName)
  378. if not activeIds then
  379. return nil
  380. end
  381. for _, id in ipairs(activeIds) do
  382. local config = ConfigDataManager.getById("cfg_equip_gemsuit", id)
  383. if not config then
  384. return nil
  385. end
  386. local value = config[string.lower(attrName)]
  387. if value ~= "" and value ~= nil then
  388. return config
  389. end
  390. end
  391. return nil
  392. end
  393. function EquipGem.dataAndType(actor, attrName)
  394. local data = getplaydef(actor, "T$gemSuitConfig") or {}
  395. if table.isNullOrEmpty(data) then
  396. return nil
  397. end
  398. local dataType = 0
  399. for _, v in pairs(data) do
  400. if type(v) == "string" then
  401. dataType = 2
  402. break
  403. elseif type(v) == "table" then
  404. dataType = 1
  405. break
  406. end
  407. end
  408. if dataType == 0 then
  409. return nil
  410. elseif dataType == 1 then
  411. data = EquipGem.getConfigByAttr(data, attrName)
  412. return data
  413. else
  414. data = EquipGem.getConfigByIdAndAttr(data, attrName)
  415. return data
  416. end
  417. end
  418. function EquipGem.updateAttrGroup(actor, groupName, attrName, value)
  419. updateattrgroup(actor, groupName, attrName, value)
  420. end
  421. function EquipGem.sendHpChangeMessage(actor, recovery, target)
  422. sendluamsg(
  423. actor,
  424. LuaMessageIdToClient.RES_GEM_RECOVERY_HP_INFO,
  425. {text = recovery, hurtType = 118, targetId = target:toString()}
  426. )
  427. end
  428. function EquipGem.selectRate(probability)
  429. local randomNum = math.random()
  430. return randomNum <= probability
  431. end
  432. function EquipGem.parseConfigValue(valueStr)
  433. local valueArr = string.splitByAll(valueStr, "#")
  434. local probability = tonumber(valueArr[1]) / 10000
  435. local ratio = tonumber(valueArr[2]) / 10000
  436. return probability, ratio
  437. end
  438. -- 检查时间
  439. function EquipGem.checkSpeedTime(actor, config)
  440. local timeInfo = getplaydef(actor, "@gemSpeedTimeInfo")
  441. if not timeInfo then
  442. return 0
  443. end
  444. local speedBonus = config["anispeedbonus"]
  445. local lastingtime = tonumber(string.splitByAll(speedBonus, "#")[3])
  446. local cd = tonumber(string.splitByAll(speedBonus, "#")[4])
  447. local nowSec = getbaseinfo(actor, "nowsec")
  448. local useTime = timeInfo["useTime"] or 0
  449. if nowSec - useTime <= lastingtime then
  450. return 1
  451. elseif nowSec - useTime > lastingtime and nowSec - useTime < lastingtime + cd then
  452. return 2
  453. else
  454. return 3
  455. end
  456. end
  457. function EquipGem.checkRecoveryHpTime(actor, config)
  458. local useTime = getplaydef(actor, "@gemHpRecoveryTime")
  459. if not useTime then
  460. return true
  461. end
  462. local beAttackRecover = config["beattackrecover"]
  463. local cd = tonumber(string.splitByAll(beAttackRecover, "#")[3])
  464. if not cd or cd == "" then
  465. return true
  466. end
  467. local nowSec = getbaseinfo(actor, "nowsec")
  468. if nowSec - useTime <= cd then
  469. return false
  470. end
  471. return true
  472. end
  473. function EquipGem.handleGemAttrs(caster, target, targetHurt, casterType, targetType)
  474. local hurt = EquipGem.setGemAttrs(caster, "damageRate", targetHurt)
  475. if casterType == MapObjectType.PLAYER and targetType == MapObjectType.PLAYER then
  476. hurt = EquipGem.setGemAttrs(target, "damageAbsorb", hurt)
  477. end
  478. return hurt
  479. end
  480. -- 设置宝石伤害增减
  481. function EquipGem.setGemAttrs(actor, attrName, hurt)
  482. local config = EquipGem.dataAndType(actor, attrName)
  483. -- lg("伤害增减:",attrName, config)
  484. if not config then
  485. return hurt
  486. end
  487. local probability, ratio = EquipGem.parseConfigValue(config[string.lower(attrName)])
  488. if EquipGem.selectRate(probability) then
  489. if attrName == "damageRate" then
  490. hurt = hurt * (1 + ratio)
  491. elseif attrName == "damageAbsorb" then
  492. hurt = hurt * (1 - ratio)
  493. end
  494. end
  495. return hurt
  496. end
  497. -- 设置宝石恢复
  498. function EquipGem.setGemRecovery(actor, fightParam)
  499. local hurt = fightParam["targethurt"]
  500. local casterType = fightParam["castertype"]
  501. local targetType = fightParam["targettype"]
  502. if casterType == MapObjectType.PLAYER and targetType == MapObjectType.PLAYER then
  503. local config = EquipGem.dataAndType(actor, "beattackrecover")
  504. -- lg("恢复:", config)
  505. if not config then
  506. return
  507. end
  508. if not EquipGem.checkRecoveryHpTime(actor, config) then
  509. return
  510. end
  511. local probability, ratio = EquipGem.parseConfigValue(config["beattackrecover"])
  512. if EquipGem.selectRate(probability) then
  513. local recovery = math.ceil(hurt * ratio)
  514. local currHp = getbaseinfo(actor, "hp")
  515. local fixHp = recovery + currHp
  516. sethp(actor, fixHp)
  517. -- local caster = fightParam["caster"]
  518. EquipGem.sendHpChangeMessage(actor, recovery, actor)
  519. -- local nearPlayers = getnarplayer(actor)
  520. -- for _, playInfo in ipairs(nearPlayers) do
  521. -- local play = playInfo["luaplayer"]
  522. -- if play:toString() ~= actor:toString() then
  523. -- EquipGem.sendHpChangeMessage(play, recovery, actor)
  524. -- end
  525. -- end
  526. setplaydef(actor, "@gemHpRecoveryTime", getbaseinfo(actor, "nowsec"))
  527. end
  528. end
  529. end
  530. -- 设置速度加成
  531. function EquipGem.setSpeedBonus(actor)
  532. local config = EquipGem.dataAndType(actor, "anispeedbonus")
  533. -- lg("速度:", config)
  534. local timeInfo = getplaydef(actor, "@gemSpeedTimeInfo")
  535. if not config and not timeInfo then
  536. return
  537. elseif not config and timeInfo then
  538. local configId = timeInfo["cfgId"]
  539. config = ConfigDataManager.getById("cfg_equip_gemSuit", configId)
  540. end
  541. if not config then
  542. return
  543. end
  544. local nowSec = getbaseinfo(actor, "nowsec")
  545. local configId = tonumber(config["id"])
  546. local probability, ratio = EquipGem.parseConfigValue(config["anispeedbonus"])
  547. local value = getattrinfo(actor, "AniSpeedBonus")
  548. local id = attrname2id("AniSpeedBonus")
  549. local remarks = tonumber(ConfigDataManager.getTableValue("cfg_att_info", "remarks", "id", id))
  550. -- lg(value)
  551. if timeInfo then
  552. local preCfgId = timeInfo["cfgId"]
  553. local preConfig = ConfigDataManager.getById("cfg_equip_gemSuit", preCfgId)
  554. local stage = EquipGem.checkSpeedTime(actor, preConfig)
  555. if stage == 1 then
  556. -- lg(1)
  557. return
  558. elseif stage == 2 then
  559. -- lg(2)
  560. EquipGem.updateAttrGroup(actor, "gemSuitAttr", "AniSpeedBonus", 0)
  561. elseif stage == 3 then
  562. -- lg(3)
  563. if EquipGem.selectRate(probability) then
  564. local num = value * ratio
  565. if remarks == 2 then
  566. num = num * 10000 < 0 and 0 or num * 10000
  567. end
  568. -- lg("攻击速度选中:", num)
  569. EquipGem.updateAttrGroup(actor, "gemSuitAttr", "AniSpeedBonus", num)
  570. setplaydef(actor, "@gemSpeedTimeInfo", {useTime = nowSec, cfgId = configId})
  571. end
  572. end
  573. else
  574. if EquipGem.selectRate(probability) then
  575. -- lg(0)
  576. local num = value * ratio
  577. if remarks == 2 then
  578. num = num * 10000 < 0 and 0 or num * 10000
  579. end
  580. EquipGem.updateAttrGroup(actor, "gemSuitAttr", "AniSpeedBonus", num)
  581. setplaydef(actor, "@gemSpeedTimeInfo", {useTime = nowSec, cfgId = configId})
  582. end
  583. end
  584. -- lg(getattrinfo(actor, "AniSpeedBonus"))
  585. -- lg("====================================")
  586. end
  587. function testgem(actor, hurt)
  588. hurt = EquipGem.setGemAttrs(actor, "damageRate", hurt)
  589. hurt = EquipGem.setGemAttrs(actor, "damageAbsorb", hurt)
  590. lg(hurt)
  591. end