EquipLuck.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --涉及到的相关属性在属性表配置
  2. EquipLuck = {}
  3. local this = EquipLuck;
  4. local filename = "EquipLuck";
  5. local luckAttrs = {
  6. 305012, -- 幸运一击伤害加成
  7. 900 -- 幸运(灵魂宝石成功率)
  8. }
  9. function EquipLuck.lualuckequip(actor, msgData)
  10. local itemid = msgData.itemId
  11. local equip = getequipinfo(actor, itemid, 1)
  12. if equip == nil then
  13. return
  14. end
  15. local isLuck = EquipFunc.GetEquipIsLuck(equip)
  16. if isLuck then
  17. sendluamsg(actor, LuaMessageIdToClient.TIPS, "幸运装备无法进行此操作")
  18. return
  19. end
  20. local cfgRefined = ConfigDataManager.getTable("cfg_equip_luck", "id", 1)
  21. if #cfgRefined > 0 then
  22. cfgRefined = cfgRefined[1]
  23. else
  24. return
  25. end
  26. local costs = cfgRefined.costs
  27. local cost_map = {}
  28. if not string.isNullOrEmpty(costs) then
  29. string.putIntIntMap(cost_map, costs, "#", "|")
  30. end
  31. --校验道具是否足够
  32. local enough = API.CheckItemMap(actor, cost_map)
  33. if enough == false then
  34. sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
  35. return
  36. end
  37. local isSucc = math.random(1, 100) > 50
  38. if not isSucc then
  39. API.TakeItemMap(actor, cost_map, "幸运消耗")
  40. sendluamsg(actor, LuaMessageIdToClient.LUCK_EQUIP_RESULT, { itemid = itemid, isSucc = false})
  41. return
  42. end
  43. local entries = equip.entries
  44. table.insert(entries, {
  45. attrid = 900,
  46. grade = 0,
  47. value = 2500,
  48. entryid = 1
  49. })
  50. table.insert(entries, {
  51. attrid = 305012,
  52. grade = 0,
  53. value = 500,
  54. entryid = 1
  55. })
  56. local result = resetequipentry(actor, itemid, entries)
  57. if not result then
  58. sendluamsg(actor, LuaMessageIdToClient.TIPS, "幸运失败")
  59. return
  60. end
  61. API.TakeItemMap(actor, cost_map, "幸运消耗")
  62. -- 发送成功消息
  63. sendluamsg(actor, LuaMessageIdToClient.LUCK_EQUIP_RESULT, { itemid = itemid, isSucc = true})
  64. end