12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058 |
- --- 大天使装备
- --- 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
- for grailId, _ in pairs(grails) do
- AngelMajorGrail.grailAttrHandle(actor, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, 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]
- 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, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, 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, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, 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
- 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, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, 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
- for grailId, info in pairs(grails) do
- local temp = AngelMajorGrail.combineRes(grailId, info, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, grailId))
- local attrInfo = temp["attrInfo"]
- if opt == 2 then
- attrInfo["active"] = false
- else
- if attrInfo and AngelMajorGrail.isActiveGrail(actor, grailId) then
- attrInfo["active"] = true
- end
- 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)
- else
- break
- 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
- function AngelMajorEquipment.isAngelEquip(itemConfigId)
- return this.isAngelEquip(itemConfigId)
- 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
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
- this.addAngelEquipAttr(actor, basicAtt, itemId)
- end
- else
- attrInfo[itemId] = {
- ["level"] = itemLevel,
- ["exp"] = addExp,
- ["rank"] = rank,
- ["grails"] = grails
- }
- setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
- end
- 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
- --- 获取大天使装备总阶数与总等级
- --- @param actor table 角色对象
- --- @return number rank, number level 阶数,等级
- function AngelMajorEquipment.getTotalInfo(actor)
- local equipmentData = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipmentData) then
- return 0, 0
- end
- local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
- if table.isNullOrEmpty(equipInfo) then
- return 0, 0
- end
- local rank = 0
- local level = 0
- local count = 0
- for _, v in pairs(equipmentData) do
- local itemId = v["id"]
- local itemConfigId = v["cfgid"]
- if this.isAngelEquip(itemConfigId) then
- local attrInfo = equipInfo[itemId]
- if not table.isNullOrEmpty(attrInfo) then
- rank = rank + attrInfo["rank"]
- level = level + attrInfo["level"]
- count = count + 1
- end
- end
- end
- return rank, level
- end
|