1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009 |
- --- 大天使装备
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by zhoutao.
- --- DateTime: 2024/11/8 17:54
- AngelMajorEquipment = {}
- local this = {}
- this.RedId = 102
- --- 发送大天使装备属性信息
- --- @param actor table 角色
- function AngelMajorEquipment.sendAngelEquipAttrInfo(actor)
- local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(attrInfo) then
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, {})
- return
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, attrInfo)
- end
- --- 获取指定大天使装备属性
- ---@param actor table 角色
- ---@param msgData table 消息数据
- function AngelMajorEquipment.getEquipAttrById(actor, msgData)
- if not this.isOpen(actor) then
- return
- end
- local itemConfigId = msgData["itemConfigId"]
- if not this.isAngelEquip(itemConfigId) then
- return
- end
- local itemId = msgData["itemId"]
- local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(attrInfo) then
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {})
- return
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {
- [itemId] = attrInfo[itemId]
- })
- end
- --- 穿戴大天使装备后增减对应的属性值
- ---@param actor table 角色
- ---@param oldItemId number 旧道具唯一id
- ---@param itemId number 新道具唯一id
- ---@param itemConfigId number 道具配置id
- function AngelMajorEquipment.afterPutOnAngelEquipment(actor, oldItemId, itemId, itemConfigId)
- if not this.isOpen(actor) then
- return
- end
- if this.isAngelEquip(itemConfigId) then
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- local basicAtt = ""
- if not table.isNullOrEmpty(equipAttr) then
- local attrInfo = equipAttr[itemId]
- if not table.isNullOrEmpty(attrInfo) then
- local level = attrInfo["level"]
- local groupId = ConfigDataManager.getTableValue("cfg_equip_angelGroup", "angelEquipGroup", "id", itemConfigId)
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", level)
- if table.isNullOrEmpty(tableValue) then
- gameDebug.print("getAngelEquipAttrTableValue is nil itemConfigId:" .. itemConfigId .. " itemLevel:" .. level)
- return
- end
- basicAtt = tableValue[1]["basicatt"]
- if string.isNullOrEmpty(basicAtt) then
- return
- end
- end
- end
- if oldItemId and oldItemId == 0 then
- -- 增加属性
- this.addAngelEquipAttr(actor, basicAtt, itemId)
- -- 增加圣杯词条属性
- if not table.isNullOrEmpty(equipAttr) then
- local attrInfo = equipAttr[itemId]
- if not table.isNullOrEmpty(attrInfo) then
- local grails = attrInfo["grails"]
- if not table.isNullOrEmpty(grails) then
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- for grailId, _ in pairs(grails) do
- AngelMajorGrail.grailAttrHandle(actor, grailInfo[grailId], grailId, true)
- end
- end
- end
- end
- else
- -- 将穿着的装备提升的属性移除
- local key = string.format(RoleAttrKey.ANGEL_MAJOR_EQUIPMENT, oldItemId)
- RoleAttr.clearRoleAttrAndDB(actor, key)
- -- 增加属性
- this.addAngelEquipAttr(actor, basicAtt, itemId)
- -- 减少并增加圣杯词条属性
- if not table.isNullOrEmpty(equipAttr) then
- local oldAttrInfo = equipAttr[oldItemId]
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if not table.isNullOrEmpty(oldAttrInfo) then
- local oldGrails = oldAttrInfo["grails"]
- if not table.isNullOrEmpty(oldGrails) then
- for grailId, _ in pairs(oldGrails) do
- AngelMajorGrail.grailAttrHandle(actor, grailInfo[grailId], grailId, false)
- end
- end
- end
- local newAttrInfo = equipAttr[itemId]
- if not table.isNullOrEmpty(newAttrInfo) then
- local newGrails = newAttrInfo["grails"]
- if not table.isNullOrEmpty(newGrails) then
- for grailId, _ in pairs(newGrails) do
- AngelMajorGrail.grailAttrHandle(actor, grailInfo[grailId], grailId, true)
- end
- end
- end
- end
- end
- -- 发送当前装备下圣杯词条信息
- this.SendOptEquipGrailInfo(actor, itemId, 1)
- -- 判断圣杯红点
- local result = AngelMajorGrail.checkEnter(actor)
- RedPoint.sendOneRedPoint(actor, this.RedId, result)
- -- 更新开服竞技排行数据
- local lv = AngelMajorEquipment.getLvSum(actor)
- OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
- -- 判断是否满足大天使圣杯套装并增加属性
- AngelMajorGrail.checkAngelGrailSuitCondition(actor)
- end
- end
- --- 脱下大天使装备后减对应的属性值
- ---@param actor table 角色
- ---@param itemId number 道具唯一id
- ---@param itemConfigId number 道具配置id
- function AngelMajorEquipment.afterTakeOffAngelEquipment(actor, itemId, itemConfigId)
- if not this.isOpen(actor) then
- return
- end
- if this.isAngelEquip(itemConfigId) then
- local key = string.format(RoleAttrKey.ANGEL_MAJOR_EQUIPMENT, itemId)
- RoleAttr.clearRoleAttrAndDB(actor, key)
- -- 去除圣杯词条属性
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if not table.isNullOrEmpty(equipInfo) then
- local attrInfo = equipInfo[itemId]
- if not table.isNullOrEmpty(attrInfo) then
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- if not table.isNullOrEmpty(attrInfo) then
- local grails = attrInfo["grails"]
- if not table.isNullOrEmpty(grails) then
- for grailId, _ in pairs(grails) do
- AngelMajorGrail.grailAttrHandle(actor, grailInfo[grailId], grailId, false)
- end
- end
- end
- end
- end
- -- 发送当前装备下圣杯词条信息
- this.SendOptEquipGrailInfo(actor, itemId, 2)
- -- 判断圣杯红点
- local result = AngelMajorGrail.checkEnter(actor)
- RedPoint.sendOneRedPoint(actor, this.RedId, result)
- -- 更新开服竞技排行数据
- local lv = AngelMajorEquipment.getLvSum(actor)
- OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
- -- 判断是否满足大天使圣杯套装并增加属性
- AngelMajorGrail.checkAngelGrailSuitCondition(actor)
- end
- end
- function this.SendOptEquipGrailInfo(actor, equipId, opt)
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipAttr) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.getEquipAllEntryInfo equipAttr is nil")
- return
- end
- local equipInfo = equipAttr[equipId]
- if table.isNullOrEmpty(equipInfo) then
- gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.getEquipAllEntryInfo equipInfo is nil")
- return
- end
- local grails = equipInfo["grails"]
- local res = {}
- if not table.isNullOrEmpty(grails) then
- local entryInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- for grailId, info in pairs(grails) do
- local temp = AngelMajorGrail.combineRes(grailId, info, entryInfo)
- local attrInfo = temp["attrInfo"]
- if attrInfo and AngelMajorGrail.isActiveGrail(actor, grailId) then
- attrInfo["active"] = true
- end
- res[grailId] = temp
- end
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_OPT_ENTRY_INFO, { opt = opt, res = res })
- end
- --- 初始化大天使装备成长属性
- ---@param actor table 角色
- ---@param itemId number 道具唯一id
- ---@param cfgId number 道具配置id
- function AngelMajorEquipment.initAngelEquipmentAttr(actor, itemId, cfgId)
- if this.isAngelEquip(cfgId) then
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- -- 初始化装备成长属性
- if not table.isNullOrEmpty(equipAttr) then
- local itemAttr = equipAttr[itemId]
- if table.isNullOrEmpty(itemAttr) then
- equipAttr[itemId] = {
- ["level"] = 0,
- ["exp"] = 0,
- ["rank"] = 1,
- ["grails"] = {}
- }
- end
- else
- equipAttr = {
- [itemId] = {
- ["level"] = 0,
- ["exp"] = 0,
- ["rank"] = 1,
- ["grails"] = {}
- }
- }
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {
- [itemId] = equipAttr[itemId]
- })
- end
- end
- --- 销毁大天使装备
- ---@param actor table 角色
- ---@param cfgId number 道具配置id
- ---@param itemId number 道具唯一id
- function AngelMajorEquipment.destroyAngelEquip(actor, cfgId, itemId)
- if not this.isOpen(actor) then
- return
- end
- if this.isAngelEquip(cfgId) then
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipAttr) then
- return
- end
- -- 清除圣杯词条数据
- local attrInfo = equipAttr[itemId]
- if not table.isNullOrEmpty(attrInfo) then
- local grails = attrInfo["grails"]
- if not table.isNullOrEmpty(grails) then
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- for grailId, _ in pairs(grails) do
- grailInfo[grailId] = nil
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
- end
- end
- equipAttr[itemId] = nil
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
- sendluamsg(actor, LuaMessageIdToClient.RES_DESTROY_ANGEL_EQUIPMENT, itemId)
- end
- end
- --- 突破大天使装备
- ---@param actor table 角色
- ---@param itemId number 道具唯一id
- function AngelMajorEquipment.breakEquipment(actor, msgData)
- if not this.isOpen(actor) then
- return
- end
- local itemConfigId = msgData["itemConfigId"]
- if not this.isAngelEquip(itemConfigId) then
- return
- end
- local itemId = msgData["itemId"]
- local groupId = msgData["groupId"]
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- local attrInfo = equipAttr[itemId]
- if table.isNullOrEmpty(attrInfo) then
- return
- end
- local level = attrInfo["level"]
- local rank = attrInfo["rank"]
- local grails = attrInfo["grails"]
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", level)
- if table.isNullOrEmpty(tableValue) then
- return
- end
- local breakMaterial = tableValue[1]["breakmaterial"]
- if string.isNullOrEmpty(breakMaterial) then
- return
- end
- -- 根据配置的道具信息消耗道具进行突破
- local items = string.split(breakMaterial, "|")
- local result = true
- for _, costItems in pairs(items) do
- local tmps = string.split(costItems, "#")
- local costItemId = tmps[1]
- local costItemCount = tmps[2]
- if not Bag.checkItem(actor, costItemId, costItemCount) then
- result = false
- break
- end
- end
- if result then
- for _, costItems in pairs(items) do
- local tmps = string.split(costItems, "#")
- local costItemId = tmps[1]
- local costItemCount = tmps[2]
- removeitemfrombag(actor, costItemId, costItemCount, 0, 9999, ItemAction.ANGEL_EQUIPMENT_BREAK_COST)
- end
- equipAttr[itemId] = {
- ["level"] = level + 1,
- ["exp"] = 0,
- ["rank"] = rank + 1,
- ["grails"] = grails,
- }
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
- -- 突破后增加对应的属性
- local basicAtt = tableValue[1]["basicatt"]
- if string.isNullOrEmpty(basicAtt) then
- return
- end
- this.addAngelEquipAttr(actor, basicAtt, itemId)
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {
- [itemId] = equipAttr[itemId]
- })
- -- 响应装备突破结果
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_BREAK_RESULT, result)
- else
- -- 响应装备突破结果
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_BREAK_RESULT, result)
- end
- -- 红点判断
- local checkEnter = AngelMajorGrail.checkEnter(actor)
- RedPoint.sendOneRedPoint(actor, this.RedId, checkEnter)
- end
- --- 攻击指定怪物增加大天使装备经验值
- ---@param actor table 角色
- ---@param fightData table 战斗数据
- function AngelMajorEquipment.attack(actor, fightData)
- if not this.isOpen(actor) then
- return
- end
- if isofflineplay(actor) then
- return
- end
- local targetType = fightData["targettype"]
- local targetConfigId = fightData["targetcfgid"]
- if targetType == 2 then
- local angelExp = ConfigDataManager.getTableValue("cfg_monster", "angelExp", "id", targetConfigId)
- angelExp = angelExp and tonumber(angelExp) or 0
- if angelExp == 0 then
- return
- end
- local equipmentData = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipmentData) then
- return
- end
- local isLevelUp = false
- local mark = false
- local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(attrInfo) then
- return
- end
- local equipId = {}
- for _, v in pairs(equipmentData) do
- local tempExp = angelExp
- -- 判断是否拥有大天使装备经验加成buff
- local expBoostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
- if not table.isNullOrEmpty(expBoostInfo) then
- local delayTime = expBoostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
- local value = expBoostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["value"]
- local now = getbaseinfo(actor, "now")
- if now <= delayTime then
- tempExp = math.round(tempExp + (tempExp * value / 100))
- end
- end
- mark, isLevelUp = this.addAngelEquipExp(actor, attrInfo, v, tempExp, isLevelUp)
- if not mark then
- break
- end
- table.insert(equipId, v["id"])
- end
- if isLevelUp then
- -- 更新开服竞技排行数据
- local lv = AngelMajorEquipment.getLvSum(actor)
- OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
- end
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- local res = {}
- for _, v in pairs(equipId) do
- res[v] = equipInfo[v]
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, res)
- end
- end
- --- 检查type=2的类型是否满足穿戴条件
- ---@param actor table 角色
- ---@param id number cfg_equip_angelSuit表id
- ---@return boolean, number 是否满足穿戴条件,增加的天赋点
- function AngelMajorEquipment.checkDressedConditionType2(actor, id)
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelSuit", "id", id, "career", getbaseinfo(actor, "getbasecareer"))
- if table.isNullOrEmpty(tableValue) then
- gameDebug.print("AngelMajorEquipment.checkDressedCondition cfg_equip_angelSuit表id不存在")
- return false, 0
- end
- local dressedEquip = getputonequipinfo(actor)
- if table.isNullOrEmpty(dressedEquip) then
- return false, 0
- end
- local dressedCount = 0
- for _, v in pairs(dressedEquip) do
- local itemConfigId = v["cfgid"]
- if this.isAngelEquip(itemConfigId) then
- dressedCount = dressedCount + 1
- end
- end
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- local wearingCount = tableValue[1]["wearingcount"]
- if dressedCount < tonumber(wearingCount) then
- return false, 0
- end
- -- 装备组#部件数量#等级|装备组#部件数量#等级
- local angelLv = tableValue[1]["angellv"]
- if string.isNullOrEmpty(angelLv) then
- return false, 0
- end
- local split = string.split(angelLv, "|")
- local result = true
- local temp = {}
- for _, v in pairs(split) do
- -- 判断条件是否满足
- local tmp_split = string.split(v, "#")
- local groupId = tmp_split[1]
- local count = tmp_split[2]
- local level = tmp_split[3]
- local sum = 0
- for _, equipInfo in pairs(dressedEquip) do
- local itemConfigId = equipInfo["cfgid"]
- if this.isAngelEquip(itemConfigId) then
- local itemId = tonumber(equipInfo["id"])
- if not table.contains(temp, itemId) then
- local equipGroupId = ConfigDataManager.getTableValue("cfg_equip_angelGroup", "angelEquipSuit", "id", itemConfigId)
- if tonumber(groupId) == tonumber(equipGroupId) then
- local attrInfo = equipAttr[itemId]
- local equipLevel = attrInfo["level"]
- if equipLevel >= tonumber(level) then
- sum = sum + 1
- if sum >= tonumber(count) then
- table.insert(temp, itemId)
- goto outer
- end
- end
- end
- end
- end
- end
- :: outer ::
- if sum < tonumber(count) then
- result = false
- end
- end
- return result, result and tableValue[1]["count"] or 0
- end
- --- 检查条件是否满足增加天赋点,满足直接被动增加
- ---@param actor table 角色
- function this.checkConditionIncrementTalentPoint(actor)
- -- 获取穿着的装备等级和
- local levelSum = AngelMajorEquipment.getLvSum(actor)
- if levelSum == 0 then
- return
- end
- local tableValues = ConfigDataManager.getTable("cfg_equip_angelSuit", "type", 1, "career", getbaseinfo(actor, "getbasecareer"))
- local alreadyIncrementId = getplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_ALREADY_INCREMENT_ID)
- alreadyIncrementId = alreadyIncrementId and tonumber(alreadyIncrementId) or 0
- for _, tableValue in pairs(tableValues) do
- local id = tonumber(tableValue["id"])
- if alreadyIncrementId >= id then
- goto continue
- end
- local angelLv = tableValue["angellv"]
- if levelSum >= tonumber(angelLv) then
- AngelMajorTalent.incrementTalentPoint(actor, tableValue["count"])
- setplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_ALREADY_INCREMENT_ID, id)
- end
- :: continue ::
- end
- end
- -- 获取大天使装备等级和
- function AngelMajorEquipment.getLvSum(actor)
- local dressedEquipment = getputonequipinfo(actor)
- if table.isNullOrEmpty(dressedEquipment) then
- return 0
- end
- local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA) or {}
- local levelSum = 0
- for _, v in pairs(dressedEquipment) do
- local itemId = v["id"]
- local itemConfigId = v["cfgid"]
- if this.isAngelEquip(itemConfigId) then
- local attr = equipAttr[itemId]
- levelSum = levelSum + tonumber(attr["level"])
- end
- end
- return levelSum
- end
- --- 使用大天使经验药水或经验加成药水
- ---@param actor table 角色对象
- ---@param itemConfigId number 道具配置id
- ---@param count number 使用数量
- function AngelMajorEquipment.useExperienceBoostItem(actor, itemConfigId, count)
- local tableValue = ConfigDataManager.getTable("cfg_item", "id", itemConfigId)
- if not tableValue then
- return
- end
- local type = tonumber(tableValue[1]["type"])
- local subType = tonumber(tableValue[1]["subtype"])
- -- 经验加成药水使用
- if type == ItemType.DRUG and subType == ItemSubType.ANGEL_EXP_BOOST then
- local useParam = tableValue[1]["useparam"]
- if string.isNullOrEmpty(useParam) then
- return
- end
- local param = string.split(useParam, "#")
- local buffId = tonumber(param[3])
- local buffInfo = ConfigDataManager.getTable("cfg_buff", "id", buffId)
- local totalTime = tonumber(buffInfo[1]["bufftotaltime"])
- local boostValue = tonumber(param[1])
- local boostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
- local now = getbaseinfo(actor, "now")
- for i = 1, count do
- if not table.isNullOrEmpty(boostInfo) then
- local time = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
- local value = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["value"]
- if time and time > now then
- boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {
- ["delayTime"] = time + totalTime,
- ["value"] = boostValue > value and boostValue or value
- }
- else
- local endTime = now + totalTime
- boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {
- ["delayTime"] = endTime,
- ["value"] = boostValue > value and boostValue or value
- }
- end
- else
- local endTime = now + totalTime
- boostInfo = {
- [tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {
- ["delayTime"] = endTime,
- ["value"] = boostValue
- }
- }
- end
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO, boostInfo)
- this.delayCloseExpBoostBuff(actor, boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"] - now)
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIP_EXP_BOOST_INFO, boostInfo)
- end
- -- 经验药水使用
- if type == ItemType.DRUG and subType == ItemSubType.ANGEL_EXP then
- local useParam = tableValue[1]["useparam"]
- if string.isNullOrEmpty(useParam) then
- return
- end
- local partAndExp = string.toStringStringMap(useParam, "#", "|")
- local putOnEquipInfo = getputonequipinfo(actor)
- if table.isNullOrEmpty(putOnEquipInfo) then
- return
- end
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- for i = 1, count do
- local isLevelUp = false
- for _, v in pairs(putOnEquipInfo) do
- local cfgId = v["cfgid"]
- if this.isAngelEquip(cfgId) then
- local part = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
- if string.contains(part, "#") then
- local partSplit = string.split(part, "#")
- local exp = 0
- for _, partItem in pairs(partSplit) do
- exp = partAndExp[partItem]
- end
- if exp then
- exp = tonumber(exp)
- _, isLevelUp = this.addAngelEquipExp(actor, equipInfo, v, exp, isLevelUp)
- end
- else
- if partAndExp[part] then
- local exp = tonumber(partAndExp[part])
- _, isLevelUp = this.addAngelEquipExp(actor, equipInfo, v, exp, isLevelUp)
- end
- end
- end
- end
- if isLevelUp then
- -- 更新开服竞技排行数据
- local lv = AngelMajorEquipment.getLvSum(actor)
- OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, equipInfo)
- end
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, equipInfo)
- end
- end
- --- 获取指定玩家的指定大天使装备成长属性
- ---@param actor table 角色对象
- ---@param msgData table 消息数据
- function AngelMajorEquipment.getPlayerAngelEquipInfo(actor, msgData)
- local rid = msgData["rid"]
- local hostId = msgData["hostId"]
- local serverId = getbaseinfo(actor, "serverid")
- local targetActor = getactor(actor, rid)
- -- 非本服玩家走异步接口拿数据
- if not string.isNullOrEmpty(hostId) and tonumber(hostId) ~= tonumber(serverId) then
- getplaydefasync(actor, targetActor:toString(), PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, actor:toString())
- else
- local equipInfo = getplaydef(targetActor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipInfo) then
- return
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_OTHER_ANGE_EQUIP_INFO, equipInfo)
- end
- end
- --- 发送对应玩家的大天使装备信息
- ---@param actor table 角色对象
- ---@param equipInfo table 大天使装备信息
- ---@param params table 参数
- function AngelMajorEquipment.sendPlayerAngelEquipInfo(actor, equipInfo, params)
- local player = getactor(params)
- sendluamsg(player, LuaMessageIdToClient.RES_OTHER_ANGE_EQUIP_INFO, equipInfo)
- end
- --- 添加大天使装备的圣杯等级
- ---@param actor table 角色对象
- ---@param grailId number 圣杯id
- ---@param grailLevel number 圣杯等级
- function AngelMajorEquipment.addGrailLevel(actor, grailId, grailLevel)
- local equipData = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if not table.isNullOrEmpty(equipData) then
- for _, v in pairs(equipData) do
- local grails = v["grails"]
- if not table.isNullOrEmpty(grails) and not table.isNullOrEmpty(grails[grailId]) then
- grails[grailId]["level"] = grailLevel
- end
- end
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipData)
- end
- --- 登录
- ---@param actor table 角色对象
- function AngelMajorEquipment.login(actor)
- -- 发送所有大天使装备信息
- AngelMajorEquipment.sendAngelEquipAttrInfo(actor)
- -- 大天使经验药水过期计算
- local boostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIP_EXP_BOOST_INFO, boostInfo and boostInfo or {})
- if not table.isNullOrEmpty(boostInfo) then
- local now = getbaseinfo(actor, "now")
- local delayTime = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
- this.delayCloseExpBoostBuff(actor, delayTime - now)
- end
- end
- --- 获取已穿戴的大天使装备id列表
- ---@param actor table 角色对象
- ---@return table 大天使装备id列表
- function AngelMajorEquipment.getPutOnEquipIds(actor)
- local putOnEquipIds = {}
- local equipInfo = getputonequipinfo(actor)
- if not table.isNullOrEmpty(equipInfo) then
- for _, v in pairs(equipInfo) do
- local cfgId = v["cfgid"]
- if this.isAngelEquip(cfgId) then
- table.insert(putOnEquipIds, v["id"])
- end
- end
- end
- return putOnEquipIds
- end
- --- 判断是否开启
- ---@param actor table 角色对象
- function this.isOpen(actor)
- -- 获取当前角色等级
- local level = getbaseinfo(actor, "level")
- -- 获取等级限制配置
- local levelLimit = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.ANGEL_EQUIPMENT_LEVEL_LIMIT)
- if string.isNullOrEmpty(levelLimit) then
- return false
- end
- -- 返回结果
- return level >= tonumber(levelLimit)
- end
- --- 判断是否为大天使装备
- ---@param itemConfigId number 道具配置id
- function this.isAngelEquip(itemConfigId)
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelGroup", "id", itemConfigId)
- return not table.isNullOrEmpty(tableValue)
- end
- --- 给角色添加大天使装备对应的属性
- ---@param actor table 角色对象
- ---@param basicAtt string 增加的属性
- ---@param itemId number 道具id
- function this.addAngelEquipAttr(actor, basicAtt, itemId)
- if string.isNullOrEmpty(basicAtt) then
- return
- end
- local attrTable = string.split(basicAtt, "|")
- local temp = {}
- for _, attr in pairs(attrTable) do
- local tmps = string.split(attr, "#")
- local attrId = tmps[1]
- local attrValue = tmps[2]
- if tonumber(attrValue) == 0 then
- goto continue
- end
- temp[tonumber(attrId)] = tonumber(attrValue)
- :: continue ::
- end
- -- 表里配的不是增长的属性值,所以此处先清空之前增加的属性值再做添加属性操作
- local attrKey = string.format(RoleAttrKey.ANGEL_MAJOR_EQUIPMENT, itemId)
- RoleAttr.clearRoleAttrAndDB(actor, attrKey)
- RoleAttr.addAndSaveRoleAttr(actor, attrKey, temp)
- this.checkConditionIncrementTalentPoint(actor)
- end
- --- 添加大天使装备经验
- ---@param actor table 角色对象
- ---@param attrInfo table 大天使装备属性信息
- ---@param equip table 装备信息
- ---@param tempExp number 临时经验值
- ---@param isLevelUp boolean 是否升级
- function this.addAngelEquipExp(actor, attrInfo, equip, tempExp, isLevelUp)
- local itemId = equip["id"]
- local itemConfigId = equip["cfgid"]
- if not this.isAngelEquip(itemConfigId) then
- return true, isLevelUp
- end
- if table.isNullOrEmpty(attrInfo) then
- return false, isLevelUp
- end
- local itemAttrInfo = attrInfo[itemId]
- if table.isNullOrEmpty(itemAttrInfo) then
- return false, isLevelUp
- end
- local itemLevel = itemAttrInfo["level"]
- local itemExp = itemAttrInfo["exp"]
- local rank = itemAttrInfo["rank"]
- local grails = itemAttrInfo["grails"]
- local groupId = ConfigDataManager.getTableValue("cfg_equip_angelGroup", "angelEquipGroup", "id", itemConfigId)
- local tableValue = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", itemLevel)
- if not tableValue then
- return true, isLevelUp
- end
- local levelUpNeedExp = tableValue[1]["lvdeplete"]
- -- 如果达到满级则直接返回
- if string.isNullOrEmpty(levelUpNeedExp) then
- return true, isLevelUp
- end
- local breakMaterial = tableValue[1]["breakmaterial"]
- if not string.isNullOrEmpty(breakMaterial) and itemExp == tonumber(levelUpNeedExp) then
- -- 此前已经达到突破等级后直接跳过此次循环
- return true, isLevelUp
- end
- if tempExp >= tonumber(levelUpNeedExp) then
- while tempExp >= tonumber(levelUpNeedExp) do
- tempExp = tempExp - tonumber(levelUpNeedExp)
- itemLevel = itemLevel + 1
- isLevelUp = true
- local angelAtt = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", itemLevel)
- breakMaterial = angelAtt[1]["breakmaterial"]
- levelUpNeedExp = angelAtt[1]["lvdeplete"]
- -- 突破材料判断,达到突破等级后
- if not string.isNullOrEmpty(breakMaterial) then
- attrInfo[itemId] = {
- ["level"] = itemLevel,
- ["exp"] = tonumber(levelUpNeedExp),
- ["rank"] = rank,
- ["grails"] = grails
- }
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
- -- 通知客户端可以突破
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_CAN_BREAK, itemId)
- this.addAngelEquipAttr(actor, angelAtt[1]["basicatt"], itemId)
- return true, isLevelUp
- else
- attrInfo[itemId] = {
- ["level"] = itemLevel,
- ["exp"] = 0,
- ["rank"] = rank,
- ["grails"] = grails
- }
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
- end
- end
- if isLevelUp then
- -- 升级后增加对应的属性
- local basicAtt = ConfigDataManager.getTableValue("cfg_equip_angelAtt", "basicAtt", "ornamentsGroup", groupId, "lv", itemLevel)
- if string.isNullOrEmpty(basicAtt) then
- return true, isLevelUp
- end
- this.addAngelEquipAttr(actor, basicAtt, itemId)
- end
- end
- local addExp = itemExp + tempExp
- if addExp >= tonumber(levelUpNeedExp) then
- -- 突破材料判断,达到突破等级后
- if not string.isNullOrEmpty(breakMaterial) then
- attrInfo[itemId] = {
- ["level"] = itemLevel,
- ["exp"] = tonumber(levelUpNeedExp),
- ["rank"] = rank,
- ["grails"] = grails
- }
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
- -- 通知客户端可以突破
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_CAN_BREAK, itemId)
- return true, isLevelUp
- else
- -- 没有达到突破等级,直接升级
- itemLevel = itemLevel + 1
- isLevelUp = true
- itemExp = addExp - tonumber(levelUpNeedExp)
- attrInfo[itemId] = {
- ["level"] = itemLevel,
- ["exp"] = itemExp,
- ["rank"] = rank,
- ["grails"] = grails
- }
- -- 升级后增加对应的属性
- local basicAtt = ConfigDataManager.getTableValue("cfg_equip_angelAtt", "basicAtt", "ornamentsGroup", groupId, "lv", itemLevel)
- if string.isNullOrEmpty(basicAtt) then
- return true, isLevelUp
- end
- this.addAngelEquipAttr(actor, basicAtt, itemId)
- end
- else
- attrInfo[itemId] = {
- ["level"] = itemLevel,
- ["exp"] = addExp,
- ["rank"] = rank,
- ["grails"] = grails
- }
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
- return true, isLevelUp
- end
- --- 延迟关闭天使装备经验加成buff
- ---@param actor table 角色对象
- ---@param delayTime number 延迟时间
- function this.delayCloseExpBoostBuff(actor, delayTime)
- intervalcalldelay(actor, delayTime, 1000, 1, "angelexpboostclear")
- end
- --- 天使装备经验加成buff延迟关闭
- function angelexpboostclear(actor)
- local boostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
- if not table.isNullOrEmpty(boostInfo) then
- local now = getbaseinfo(actor, "now")
- local delayTime = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
- if now >= delayTime then
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO, {})
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIP_EXP_BOOST_INFO, { [tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {} })
- end
- end
- end
- --- 根据条件发送已激活与可激活的天赋大师id信息
- ---@param actor table 角色
- --[[function this.sendActiveTalentInfo(actor)
- local career = getbaseinfo(actor, "getbasecareer")
- local tables = ConfigDataManager.getTable("cfg_equip_angelSuit", "type", 2, "career", career)
- local res = {}
- local activeIds = getplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_ACTIVE_ID)
- activeIds = activeIds and activeIds or {}
- local canActiveIds = getplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_CAN_ACTIVE_ID)
- canActiveIds = canActiveIds and canActiveIds or {}
- for _, v in pairs(tables) do
- local id = tonumber(v["id"])
- if table.contains(activeIds, id) then
- goto mark
- end
- local result, _ = AngelMajorEquipment.checkDressedConditionType2(actor, id)
- if result then
- if table.contains(canActiveIds, id) then
- goto mark
- else
- table.insert(canActiveIds, id)
- setplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_CAN_ACTIVE_ID, canActiveIds)
- end
- else
- if table.contains(canActiveIds, id) then
- table.removeByValue(canActiveIds, id)
- setplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_CAN_ACTIVE_ID, canActiveIds)
- else
- goto mark
- end
- end
- :: mark ::
- end
- res["activeIds"] = activeIds and activeIds or {}
- res["canActiveIds"] = canActiveIds and canActiveIds or {}
- sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_TALENT_ACTIVE_INFO, res)
- end]]
- --- 测试增加大天使装备经验
- ---@param actor table 角色对象
- ---@param exp number 经验值
- function addangelequipexp(actor, exp)
- local angelExp = tonumber(exp)
- local equipmentData = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipmentData) then
- return
- end
- local isLevelUp = false
- local mark = false
- local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- for _, v in pairs(equipmentData) do
- local tempExp = angelExp
- mark, isLevelUp = this.addAngelEquipExp(actor, attrInfo, v, tempExp, isLevelUp)
- if not mark then
- break
- end
- end
- if isLevelUp then
- -- 更新开服竞技排行数据
- local lv = AngelMajorEquipment.getLvSum(actor)
- OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, attrInfo)
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, attrInfo)
- end
- function AngelMajorEquipment.grailsDataHandle()
- local isHandle = getsysvar(SystemVarConst.GRAILS_DATA_IS_HANDLE)
- if not isHandle then
- jprint("================================>grailsDataHandle start")
- local allRole = getallrolesummaryinfos()
- if not table.isNullOrEmpty(allRole) then
- for _, role in pairs(allRole) do
- local actor = role["actor"]
- local equipData = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if not table.isNullOrEmpty(equipData) then
- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
- for _, v in pairs(equipData) do
- local grails = v["grails"]
- if not table.isNullOrEmpty(grails) then
- for grailId, data in pairs(grails) do
- local level = data["level"]
- if string.isNullOrEmpty(level) then
- local entryInfo = grailInfo[grailId]
- if not table.isNullOrEmpty(entryInfo) then
- grails[grailId]["level"] = entryInfo["level"]
- end
- end
- end
- end
- end
- end
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipData)
- end
- end
- setsysvar(SystemVarConst.GRAILS_DATA_IS_HANDLE, true)
- jprint("================================>grailsDataHandle end")
- end
- end
- --- 合服变量处理
- function AngelMajorEquipment.combine()
- local hosts = gethosts()
- for _, host in ipairs(hosts) do
- setsysvar(host, SystemVarConst.GRAILS_DATA_IS_HANDLE, false)
- end
- end
|