| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- --涉及到的相关属性在属性表配置
- EquipLuck = {}
- local this = EquipLuck;
- local filename = "EquipLuck";
- local luckAttrs = {
- 305012, -- 幸运一击伤害加成
- 900 -- 幸运(灵魂宝石成功率)
- }
- function EquipLuck.lualuckequip(actor, msgData)
- local itemid = msgData.itemId
- local equip = getequipinfo(actor, itemid, 1)
- if equip == nil then
- return
- end
- local isLuck = EquipFunc.GetEquipIsLuck(equip)
- if isLuck then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "幸运装备无法进行此操作")
- return
- end
- local cfgRefined = ConfigDataManager.getTable("cfg_equip_luck", "id", 1)
- if #cfgRefined > 0 then
- cfgRefined = cfgRefined[1]
- else
- return
- end
- local costs = cfgRefined.costs
- local cost_map = {}
- if not string.isNullOrEmpty(costs) then
- string.putIntIntMap(cost_map, costs, "#", "|")
- end
- --校验道具是否足够
- local enough = API.CheckItemMap(actor, cost_map)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- local isSucc = math.random(1, 100) > 50
- if not isSucc then
- API.TakeItemMap(actor, cost_map, "幸运消耗")
- sendluamsg(actor, LuaMessageIdToClient.LUCK_EQUIP_RESULT, { itemid = itemid, isSucc = false})
- return
- end
- local entries = equip.entries
- table.insert(entries, {
- attrid = 900,
- grade = 0,
- value = 2500,
- entryid = 1
- })
- table.insert(entries, {
- attrid = 305012,
- grade = 0,
- value = 500,
- entryid = 1
- })
- local result = resetequipentry(actor, itemid, entries)
- if not result then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "幸运失败")
- return
- end
- API.TakeItemMap(actor, cost_map, "幸运消耗")
- -- 发送成功消息
- sendluamsg(actor, LuaMessageIdToClient.LUCK_EQUIP_RESULT, { itemid = itemid, isSucc = true})
- end
|