| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- Equip_QiangHua = {}
- local this = Equip_QiangHua
- local filename = "Equip_QiangHua"
- this.msgID = LuaNetMsg.Equip_QiangHua_MsgID
- function this.getData(actor)
- local tab = {}
- local data = this.tData
- return tab
- end
- -- function this.main(actor)
- -- local data = this.tData
- -- sendluamsg(actor,this.msgID,{sendType=1,tData = data})
- -- -- this.SendData(actor)
- -- end
- -- function this.SendData(actor)
- -- -- messagebox(actor,"发送更新前")
- -- local data = this.getData(actor)
- -- sendluamsg(actor,this.msgID,{sendType=2,data = data})
- -- end
- -- function this.sendDataToClient(actor)
- -- local data = {
- -- sendType = 999,
- -- tData = this.tData,
- -- data = this.getData(actor),
- -- }
- -- sendluamsg(actor,this.msgID,data)
- -- end
- function this.RefreshLevel(actor, itemId, cfgId)
- local alldata = EquipAndAppear.getLuaItemExtData(actor)
- local equipdata = alldata[itemId]
- if equipdata == nil then
- EquipAndAppear.initequipluaextdata(alldata, itemId)
- equipdata = alldata[itemId]
- end
- if equipdata.strengthlv == nil then
- equipdata.strengthlv = API.GetItemData(actor, itemId, "strengthlv") or 0
- equipdata.strengthattr = {}
- end
- setplaydef(actor, "T$luaitemextdata", alldata)
- local data = {
- sendType = 10,
- itemId = itemId,
- cfgId = cfgId
- }
- sendluamsg(actor, this.msgID, data)
- -- 推送红点
- sendluamsg(actor, LuaNetMsg.Equip_DuanZao_MsgID, {})
- info("RefreshLevel2")
- end
- function this.Click(actor, msgData)
- local mainPage = msgData.mainPage
- local subPage = msgData.subPage
- local par = msgData.par
- if mainPage == 1 then
- this.QiangHua(actor, msgData)
- elseif mainPage == 2 then
- end
- end
- function this.canQiangHua(actor, equipInfo, itemId)
- local wearBar = 1
- if equipInfo == nil and itemId == nil then
- return false
- end
- if equipInfo == nil then
- equipInfo = getbagiteminfo(actor, itemId, 1)
- end
- if equipInfo == nil then
- return false
- end
- local cfgId = equipInfo.cfgid
- local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
- local strPart = tonumber(string.split(itemData.strpart, "#")[1])
- local wearBar = 1
- local equipPos = strPart
- local subType = itemData.subtype
- if not Equip_QiangHua_Data.tEquipWearBarAndPos[wearBar] then
- return false
- end
- -- cfg_item中subType字段
- if Equip_QiangHua_Data.tItemWearPos[subType] == nil then
- messagebox(actor, "该装备无法强化")
- return false
- end
- return true
- end
- function this.QiangHua(actor, msgData)
- local itemId = msgData.itemId
- local equipInfo = nil;
- if msgData.equipPos ~= 0 then
- equipInfo = getequipinfo(actor, itemId, 1)
- else
- equipInfo = getbagiteminfo(actor, itemId, 1)
- end
- local cfgId = equipInfo.cfgid
- local itemData = ConfigDataManager.getTable("cfg_item", "id", cfgId)[1]
- local strPart = tonumber(string.split(itemData.strpart, "#")[1])
- local subType = itemData.subtype
- local wearBar = 1
- local equipPos = strPart
- -- local wearBar = msgData.wearBar
- -- local equipPos = msgData.equipPos
- -- local costType = msgData.costType
- -- local equipIndex = gameequip.index(wearBar, equipPos)
- -- local equipInfo = getequipinfo(actor,equipIndex,0) --没有则返回空表
- -- local itemId = equipInfo.id
- local lv = API.GetItemData(actor, itemId, "strengthlv") or 0
- lv = lv + 1
- if not Equip_QiangHua_Data.tEquipWearBarAndPos[wearBar] then
- messagebox(actor, "不可强化的装备栏")
- return
- end
- -- cfg_item中subType字段
- if Equip_QiangHua_Data.tItemWearPos[subType] == nil then
- messagebox(actor, "该装备无法强化")
- return
- end
- local costGroup = Equip_QiangHua_Data.tEquipWearBarAndPos[wearBar][equipPos].costGroup
- if not Equip_QiangHua_Data.tCostGroup[costGroup][lv] then
- messagebox(actor, "已强化至最高级!")
- return
- end
- -- 消耗
- local group = Equip_QiangHua_Data.tCostGroup[costGroup]
- local tCost = Equip_QiangHua_Data.tCostGroup[costGroup][lv]
- local tCoseReal = API.TableDeepcopy(tCost)
- -- 概率
- -- 基础概率
- local gailv = tCost.gailv
- if tCost.sChoice == true then
- local item = group[msgData.costName]
- if item ~= nil then
- local addgailv = item.addgailv and item.addgailv or 0
- gailv = gailv + addgailv
- local tmpCoseReal = {}
- for index, value in ipairs(tCoseReal) do
- if tCoseReal[index][1] == msgData.costName then
- table.insert(tmpCoseReal, tCoseReal[index]);
- break
- end
- end
- -- 星际宝石逻辑
- if msgData.costName == "星际宝石" and item.setLevel ~= nil then
- table.insert(tmpCoseReal, {"星际宝石", 1});
- lv = item.setLevel
- end
- tCoseReal = tmpCoseReal;
- else
- messagebox(actor, "请选择所需材料")
- return
- end
- end
- for index, value in ipairs(tCoseReal) do
- local item = group[tCoseReal[index][1]]
- if item ~= nil and item.name ~= nil then
- tCoseReal[index][1] = item.name
- end
- end
- if #tCoseReal <= 0 then
- messagebox(actor, "材料错误!")
- return
- end
- if not API.CheckItem(actor, tCoseReal) then
- messagebox(actor, "材料不足!")
- return
- end
- if not API.takeItem(actor, tCoseReal, "装备强化") then
- messagebox(actor, "材料不足!")
- return
- end
- -- 计算幸运属性概率
- if API.GetItemLuck(actor, itemId) then
- gailv = gailv + 25
- end
- -- 计算幸运道具概率
- local XingYunNum = msgData.XingYunNum and math.min(msgData.XingYunNum, 1) or 0
- if XingYunNum > 0 then
- local tcl = {{"合成幸运符", XingYunNum}}
- if not API.CheckItem(actor, tcl) then
- messagebox(actor, "材料不足!")
- return
- end
- if not API.takeItem(actor, tcl, "装备强化") then
- messagebox(actor, "材料不足!")
- return
- end
- gailv = gailv + (XingYunNum * 10)
- end
- local xiaohui = true
- local BaoHuNum = msgData.BaoHuNum and math.min(msgData.BaoHuNum, 1) or 0
- if BaoHuNum > 0 then
- local tcl = {{"合成保护符咒", BaoHuNum}}
- if API.CheckItem(actor, tcl) then
- if API.takeItem(actor, tcl, "装备强化") then
- xiaohui = false
- end
- end
- end
- if math.random(1, 100) > gailv then
- if tCost.failAddLevel ~= nil then
- lv = lv + tCost.failAddLevel - 1
- -- 刷新装备
- API.SetItemData(actor, itemId, "strengthlv", lv)
- -- 刷新流光
- API.refreshLiuGuang(actor, itemId)
- -- 通知客户端更新
- this.RefreshLevel(actor, itemId, cfgId)
- elseif tCost.failLevel ~= nil then
- if tCost.failLevel == -1 then
- -- local xiaohui = true
- -- local BaoHuNum = msgData.BaoHuNum or 0
- -- if BaoHuNum > 0 then
- -- local tcl = {{"合成保护符咒", BaoHuNum}}
- -- if API.CheckItem(actor, tcl) then
- -- if API.takeItem(actor, tcl) then
- -- xiaohui = false
- -- end
- -- end
- -- end
- if xiaohui then
- if equipInfo.equipindex ~= 0 then
- local itemId = equipInfo.id
- takeofftheequip(actor, equipInfo.equipindex)
- local bagIndex = gainbagidxbyitemid(actor, itemId)
- destroyitemafter(actor, bagIndex, "装备强化")
- local data = {
- sendType = 11
- }
- sendluamsg(actor, this.msgID, data)
- elseif equipInfo.bagindex ~= 0 then
- destroyitemafter(actor, equipInfo.bagindex, "装备强化")
- local data = {
- sendType = 11
- }
- sendluamsg(actor, this.msgID, data)
- return
- end
- end
- lv = 0
- -- 刷新装备
- API.SetItemData(actor, itemId, "strengthlv", lv)
- -- 刷新流光
- API.refreshLiuGuang(actor, itemId)
- -- 通知客户端更新
- this.RefreshLevel(actor, itemId, cfgId)
- return
- end
- lv = tCost.failLevel
- -- 刷新装备
- API.SetItemData(actor, itemId, "strengthlv", lv)
- -- 刷新流光
- API.refreshLiuGuang(actor, itemId)
- -- 通知客户端更新
- this.RefreshLevel(actor, itemId, cfgId)
- end
- -- --失败销毁装备机制
- -- if lv > 10 then
- -- local xiaohui = true
- -- local BaoHuNum = msgData.BaoHuNum or 0
- -- if BaoHuNum > 0 then
- -- local tcl = {{"合成保护符咒",BaoHuNum}}
- -- if API.CheckItem(actor,tcl) then
- -- if API.takeItem(actor,tCost) then
- -- xiaohui = false
- -- end
- -- end
- -- end
- -- if xiaohui then
- -- if equipInfo.equipindex ~= 0 then
- -- local itemId = equipInfo.id
- -- takeofftheequip(actor,equipInfo.equipindex)
- -- local bagIndex = gainbagidxbyitemid(actor,itemId)
- -- destroyitemafter(actor,bagIndex)
- -- messagebox(actor,"强化失败,装备销毁!")
- -- local data = {
- -- sendType = 11,
- -- }
- -- sendluamsg(actor,this.msgID,data)
- -- elseif equipInfo.bagindex ~= 0 then
- -- destroyitemafter(actor,equipInfo.bagindex)
- -- messagebox(actor,"强化失败,装备销毁!")
- -- return
- -- end
- -- end
- -- elseif lv > 7 then
- -- lv = 0
- -- end
- return
- end
- API.SetItemData(actor, itemId, "strengthlv", lv)
- -- info("刷新流光")
- -- 刷新流光
- API.refreshLiuGuang(actor, itemId)
- if tonumber(lv) >= 10 then
- local name = getrolefield(actor, "role.basic.name")
- local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- -- 发送跑马灯
- noticeTip.noticeinfo(actor, StringIdConst.STRENGTHEN_ALL_SERVER, name, equipName, lv)
- -- 发送世界聊天提示
- -- noticeTip.noticeinfo(actor, StringIdConst.TEXT503, name, equipName, lv)
- end
- local equipItemInfo = getequipinfo(actor, itemId, 1)
- local result = {{
- itemId = equipItemInfo.id,
- itemCfgId = equipItemInfo.cfgid
- }}
- -- HeChengQiangHuaTiaoZhan.CheckTaskIsFinish(actor,result)
- -- DaKaHuoDong.CheckTaskIsFinish(actor,DaKaHuoDong.taskType.forging,1)
- -- 检测穿戴条件 条件不足脱装备并且调用客户端刷新
- if msgData.equipPos ~= 0 then
- -- 刷新强化装备属性
- this.sendAttr(actor, itemId)
- if not this.checkTakeOnNeed(actor, itemId) then
- local equipIndex = gameequip.index(wearBar, equipPos)
- takeofftheequip(actor, equipIndex)
- local data = {
- sendType = 11
- }
- sendluamsg(actor, this.msgID, data)
- return
- end
- end
- -- 通知客户端更新
- this.RefreshLevel(actor, itemId, cfgId)
- EquipDurability.refreshDurability(actor, itemId)
- end
- -- 检测穿戴条件 条件不足脱装备并且调用客户端刷新
- function this.checkTakeOnNeed(actor, itemId)
- local tNeed = EquipFunc.getEquipStrengthNeed(actor, itemId)
- for i = 1, #tNeed do
- local attId = tNeed[i][1]
- local need = tNeed[i][2]
- local attName = attrid2name(actor, attId)
- if getattrinfo(actor, attName) < need then
- return false
- end
- end
- return true
- end
- -- 刷新强化装备属性
- function this.sendAttr(actor, itemId)
- local wearBar, equipPos = API.ItemId2WearBarAndPos(actor, itemId)
- local lv = API.GetItemData(actor, itemId, "strengthlv") or 0
- -- if lv <= 0 then
- -- addrolekmlattributes(actor,"装备强化属性"..wearBar.."#"..equipPos, {})
- -- return
- -- end
- if not Equip_QiangHua_Data.tEquipWearBarAndPos[wearBar] then
- return
- end
- if not Equip_QiangHua_Data.tEquipWearBarAndPos[wearBar][equipPos] then
- return
- end
- -- info("进入强化属性","强化属性")
- local equipInfo = getequipinfo(actor, itemId, 1)
- local equipindex = equipInfo.equipindex
- local durabilityAttPct = getequipdurability(actor, equipindex, 0) or 100
- local attPct = math.floor(durabilityAttPct / 100)
- local tAttr = EquipFunc.getEquipAllStrengthAttr(actor, itemId)
- -- info(tAttr,"tAttr","装备强化")
- local tab = {}
- for k, v in pairs(tAttr) do
- local attId = v[1]
- local val = v[2]
- if tab[attId] then
- tab[attId] = tab[attId] + val
- else
- tab[attId] = val * attPct
- end
- end
- addrolekmlattributes(actor, "装备强化属性" .. wearBar .. "#" .. equipPos, tab)
- end
- function this.takeOffEquip(actor, pos, itemId, itemCfgId)
- local wearBar = 1
- addrolekmlattributes(actor, "装备强化属性" .. wearBar .. "#" .. pos, {})
- end
- -- 穿戴装备后
- GameEvent.add(EventCfg.onTakeOnEquip, function(actor, pos, oldItemId, itemId, itemCfgId)
- this.sendAttr(actor, itemId)
- end, filename)
- -- 脱装备后
- GameEvent.add(EventCfg.onTakeOffEquip, function(actor, pos, itemId, itemCfgId)
- -- local wearBar,equipPos = API.ItemId2WearBarAndPos(actor,itemId)
- local wearBar = 1
- addrolekmlattributes(actor, "装备强化属性" .. wearBar .. "#" .. pos, {})
- end, filename)
- -- 重载配置
- -- GameEvent.add(EventCfg.onReloadScript,function(actor)
- -- this.sendDataToClient(actor)
- -- end,filename)
- -- 登录
- -- GameEvent.add(EventCfg.onLoginEnd,function(actor)
- -- this.sendDataToClient(actor)
- -- end,filename)
- function this.questQiangHua(actor, msgData)
- info(actor, "msgID111=" .. this.msgID)
- info(actor, "msgData.sendType=" .. msgData.sendType)
- info(actor, "msgData.sendType=" .. type(msgData.sendType))
- if msgData.sendType == 1 then
- this.main(actor)
- elseif msgData.sendType == 2 then
- this.SendData(actor)
- elseif msgData.sendType == 3 then
- this.Click(actor, msgData)
- end
- end
- -- GameEvent.add(EventCfg.onHandlereQuest,
- -- function(actor, msgID, msgData)
- -- info(actor,"msgID111="..this.msgID)
- -- info(actor,"msgData.sendType="..msgData.sendType)
- -- info(actor,"msgData.sendType="..type(msgData.sendType))
- -- if this.msgID ~= msgID then
- -- return
- -- end
- -- if msgData.sendType == 1 then
- -- this.main(actor)
- -- elseif msgData.sendType == 2 then
- -- this.SendData(actor)
- -- elseif msgData.sendType == 3 then
- -- this.Click(actor,msgData)
- -- end
- -- return true
- -- end
- -- , filename)
- -- 玩家进入视野
- GameEvent.add(EventCfg.onPlayerEnterView, function(actor, targetPlayer)
- end, this.filename)
|