123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262 |
- EquipAndAppear = {}
- local this = {}
- ---玩家装备信息记录
- local ROLE_EQUIP_INFO_RECORDE = "T$role_equip_info_recorde"
- local ROLE_EQUIP_STRENGTH_TIMES = "T$role_equip_strength_times"
- EquipAndAppear.RecordeType = {
- ---全身最大强化等级
- MAX_STRENGTH_LEVEL = 1,
- ---全身最大追加等级
- MAX_APPEND_LEVEL = 2,
- ---全身最大卓越词条数量
- MAX_ENTRY_COUNT = 3,
- ---全身最大首饰等级
- MAX_JEWELRY_LEVEL = 4
- }
- ---装备信息记录数据结构
- function this.GetNewEquipInfoRecorde()
- local recorde = {
- ---全身最大强化等级
- max_strength_level = 0,
- ---全身最大追加等级
- max_append_level = 0,
- ---全身最大卓越词条数量
- max_entry_count = 0,
- ---全身最大首饰等级
- max_jewelry_level = 0
- }
- return recorde
- end
- ---装备bind数据修复
- local EQUIP_BIND_DATA_REPAIR = "T$equipbinddatarepair"
- local EQUIP_UP_DATA_REPAIR = "T$equipssupdatarepair"
- function EquipAndAppear.login(actor)
- RepairRoleData.action(actor, EQUIP_BIND_DATA_REPAIR, 202503192016, EquipAndAppear.repairEquipBindData2025_03_19,actor)
- RepairRoleData.action(actor, EQUIP_UP_DATA_REPAIR, 202503241400, EquipAndAppear.repairEquipSsupData2025_03_24,actor)
- end
- function EquipAndAppear.repairEquipBindData2025_03_19(actor)
- local allData = EquipAndAppear.getLuaItemExtData(actor)
- local infos = getallequipinfo(actor)
- for _, equip in pairs(infos) do
- if this.checkEquipData(actor,allData,equip.id) then
- changeitembindstate(actor,equip.id,1)
- end
- end
- info(actor,"修复bind数据成功")
- end
- ---装备首饰升级数据修复
- function EquipAndAppear.repairEquipSsupData2025_03_24(actor)
- local allData = EquipAndAppear.getLuaItemExtData(actor)
- local infos = getallequipinfo(actor)
- for _, equip in pairs(infos) do
- local cfgId = equip.cfgid
- local itemId = tonumber(equip.id)
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group ~= nil and group ~= "" then
- local equipext = allData[itemId]
- if equipext then
- local ssUpLv = equipext.ssuplv or 0
- local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", ssUpLv)
- if (ornaments == nil) and ssUpLv > 0 then
- --修复数据
- for i = ssUpLv - 1,1,-1 do
- local newNaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv",i)
- if newNaments and table.count(newNaments) > 0 then
- equipext.ssuplv = i
- local att = newNaments[1].basicatt
- local attr = splitbyshuxianandjinghao2(att)
- equipext.ssupattr = attr
- EquipAndAppear.SetItemExtData(actor, itemId, equipext)
- allData[itemId] = equipext
- setplaydef(actor, "T$luaitemextdata", allData)
- break
- end
- end
- end
- end
- end
- end
- info(actor,"修复首饰升级数据成功")
- end
- function this.checkEquipData(actor,allData,itemId)
- local equipData = allData[tonumber(itemId)]
- if not equipData then
- return false
- end
- if equipData.strengthlv ~= 0 then
- return true
- end
- if equipData.appendlv ~= 0 then
- return true
- end
- local equip = getequipinfo(actor, itemId, 1)
- if table.count(equip.entries) > 2 then
- return true
- end
- return false
- end
- function EquipAndAppear.GetEquipInfoRecorde(actor)
- local equipInfoRecorde = getplaydef(actor, ROLE_EQUIP_INFO_RECORDE)
- if equipInfoRecorde == nil then
- equipInfoRecorde = this.GetNewEquipInfoRecorde()
- end
- return equipInfoRecorde
- end
- function this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- setplaydef(actor, ROLE_EQUIP_INFO_RECORDE, equipInfoRecorde)
- end
- -- 保存角色外观(幻化也走这个方法)
- function EquipAndAppear.settingequipappear(actor, msgData)
- local equipappear = msgData["equipindex"]
- local data = {}
- for _, value in pairs(equipappear) do
- local pos = tonumber(value["slot"])
- local cfgId = tonumber(value["cfgId"])
- if pos ~= nil then
- data[pos] = cfgId
- end
- end
- setitemappeardata(actor, data)
- sendluamsg(actor, LuaMessageIdToClient.RES_SETTING_EQUIP_APPEAR, data)
- end
- -- 初始化角色外观
- function initequipppear(actor)
- local equipappear = {}
- setplaydef(actor, "T$equipappear", equipappear)
- end
- --获取角色外观
- function EquipAndAppear.getequipappear(actor, msgId)
- local data = getrolefield(actor, "role.roleappear.appear")
- if data == nil then
- return
- end
- local result = {}
- for key, value in pairs(data) do
- local appear = {}
- appear["slot"] = key
- appear["cfgId"] = value
- table.insert(result, appear)
- end
- --发送lua消息到客户端
- if LuaMessageIdToSever.GET_EQUIP_APPEAR == msgId then
- sendluamsg(actor, LuaMessageIdToClient.GET_EQUIP_APPEAR, result)
- end
- return result
- end
- -- 外观幻化激活
- function EquipAndAppear.equipfashion(actor, msgData)
- local cfgIds = msgData["cfgIds"]
- local equipFashion = getplaydef(actor, "T$equipfashion")
- if equipFashion == nil then
- equipFashion = {}
- end
- for _, cfgId in pairs(cfgIds) do
- local isExist = table.contains(equipFashion, cfgId)
- if isExist then
- --存在已激活的
- return
- end
- end
- --计算所有消耗
- local allData = getAllEquipAppearCost(cfgIds, 4)
- if allData == nil then
- return
- end
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, allData)
- if enough == false then
- return
- end
- --扣材料
- for _, v in ipairs(allData) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --保存幻化
- for _, v in pairs(cfgIds) do
- table.insert(equipFashion, v)
- end
- setplaydef(actor, "T$equipfashion", equipFashion)
- sendluamsg(actor, LuaMessageIdToClient.RES_ACT_EQUIP_FASHION, equipFashion)
- end
- --获取已激活外观
- function EquipAndAppear.getallequipfashion(actor)
- local equipFashion = getplaydef(actor, "T$equipfashion")
- sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_FASHION, equipFashion)
- end
- --激活染色
- function EquipAndAppear.actquipcolor(actor, msgData)
- local cfgIds = msgData["cfgIds"]
- local color = msgData["color"]
- --计算消耗材料
- local allCost = getAllEquipAppearCost(cfgIds, 5)
- if allCost == nil then
- return
- end
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, allCost)
- if enough == false then
- return
- end
- --扣材料
- for _, v in ipairs(allCost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --染色
- local equipcolor = EquipAndAppear.getequipcolor(actor, 0)
- for i, v in ipairs(cfgIds) do
- local num = 0
- for _, val in pairs(equipcolor) do
- if val["cfgid"] == v then
- table.insert(val["color"], color)
- num = num + 1
- break
- end
- end
- if num == 0 then
- local dt = {}
- dt["cfgid"] = v
- dt["color"] = {}
- table.insert(dt["color"], color)
- table.insert(equipcolor, dt)
- end
- end
- setplaydef(actor, "actequipcolor", equipcolor)
- end
- -- 保存染色
- function EquipAndAppear.settingequipcolor(actor, msgData)
- local cfgId = msgData["cfgid"]
- local color = msgData["color"]
- --先校验是否激活该颜色
- local actequipcolor = getplaydef(actor, "T$actequipcolor")
- local bool = false
- for _, v in pairs(actequipcolor) do
- local cId = v["cfgid"]
- if cId == cfgId then
- bool = table.contains(v["color"], color)
- break
- end
- end
- if bool ~= true then
- return
- end
- local equipcolor = EquipAndAppear.getequipcolor(actor, 0)
- for _, v in ipairs(equipcolor) do
- if v["cfgid"] == cfgId then
- v["color"] = color
- break
- end
- end
- setplaydef(actor, "T$equipcolor", equipcolor)
- end
- --获取角色染色数据
- function EquipAndAppear.getequipcolor(actor, msgId)
- local equipcolor = getplaydef(actor, "T$equipcolor")
- if equipcolor == nil then
- equipcolor = {}
- setplaydef(actor, "T$equipcolor", equipcolor)
- end
- local data = getplaydef(actor, "T$equipcolor")
- --发送lua消息到客户端
- if msgId == LuaMessageIdToClient.GET_EQUIP_COLOR then
- sendluamsg(actor, msgId, data)
- end
- return data
- end
- --计算所有消耗
- function getAllEquipAppearCost(cfgIds, type)
- local allData = {}
- for _, cfgId in pairs(cfgIds) do
- local cost = ConfigDataManager.getTableValue("cfg_fashion", "deplete", "id", cfgId, "type", type)
- if cost == nil then
- return nil
- end
- local data = splitbyshuxianandjinghao(cost)
- for _1, v in pairs(data) do
- local id = v["cfgid"]
- local count = v["count"]
- local num = 0
- for _2, val in pairs(allData) do
- if val["cfgid"] == id then
- val["count"] = val["count"] + count
- num = num + 1
- break
- end
- end
- if num == 0 then
- local element = {}
- element["cfgid"] = id
- element["count"] = count
- table.insert(allData, element)
- end
- end
- end
- return allData
- end
- function EquipAndAppear.playerequipview(actor, otherActor)
- if otherActor == nil then
- return
- end
- --发送幻化染色数据
- local appear = EquipAndAppear.getequipappear(otherActor, 0)
- local title = EquipAndAppear.gettitleinfo(otherActor, 0)
- local alldata = {}
- alldata["appear"] = appear
- alldata["ring"] = EquipAndAppear.getnowwearshapering(otherActor)
- local curTitle = 0
- if not title.hidden then
- curTitle = title.curEquipTitle
- end
- alldata["title"] = curTitle
- local rid = getbaseinfo(otherActor, "rid")
- alldata["rid"] = rid
- sendluamsg(actor, LuaMessageIdToClient.OTHER_ROLE_APPEAR, alldata)
- end
- --玩家进入视野时发送玩家装备的强化信息
- function EquipAndAppear.playerequipstrength(actor, otherActor)
- if otherActor == 0 then
- otherActor = actor
- end
- local alldata = getplaydef(otherActor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(otherActor)
- local result = {}
- local info = {}
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- local equip = {}
- equip.itemid = itemId
- if data ~= nil then
- if data.strengthlv ~= nil then
- equip.strengthlv = data.strengthlv
- else
- equip.strengthlv = 0
- end
- else
- equip.strengthlv = 0
- end
- table.insert(info, equip)
- end
- result.rid = getbaseinfo(otherActor, "rid")
- result.equip = info
- result = table.valueConvertToString(result)
- sendrefluamsg(actor, LuaMessageIdToClient.RES_PLAYER_EQUIP_STRENGTHLV, result)
- end
- --检查表是否包含某个元素
- -- function table.contains(table, element)
- -- for _, value in pairs(table) do
- -- if value == element then
- -- return true
- -- end
- -- end
- -- return false
- -- end
- -- 分割字符串
- function splitbyshuxianandjinghao(str)
- local dt = {}
- local data = string.split(str, "|")
- for _, v in ipairs(data) do
- local data2 = string.split(v, "#")
- local v2 = {}
- v2["cfgid"] = data2[1]
- v2["count"] = data2[2]
- table.insert(dt, v2)
- end
- return dt
- end
- --称号入包
- function EquipAndAppear.titleenterbag(actor, configId)
- local itemList = ConfigDataManager.getTable("cfg_item", "id", configId)
- if itemList == nil then
- return
- end
- local item = itemList[1]
- if tonumber(item.type) ~= 2 or tonumber(item.subtype) ~= 15 then
- return
- end
- --计算时间
- local fashionList = ConfigDataManager.getTable("cfg_fashion", "id", configId)
- if fashionList == nil then
- return
- end
- if table.count(fashionList) == 0 then
- return
- end
- local fashion = fashionList[1]
- local titledata = EquipAndAppear.gettitleinfo(actor, 0)
- local titles = titledata.title
- --不限时
- local flag = true
- local time = 0
- local type = 0
- local timeType = tonumber(fashion.timetype)
- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- if timeType == 1 then
- type = 1
- for _, value in pairs(titles) do
- if value.confId == configId then
- value.obtainTime = nowTime --获得时间
- value.expiresTime = -1 --到期时间
- flag = false
- end
- end
- time = -1
- end
- --限时
- if timeType == 2 then
- type = 2
- --获取称号的有效期
- local times = fashion.time
- local timestr = string.split(times, "#")
- --总时间
- time = tonumber(timestr[1]) * 60 * 60 + tonumber(timestr[2]) * 60 + tonumber(timestr[3])
- for _, value in pairs(titles) do
- if value.confId == configId then
- value.obtainTime = nowTime --获得时间
- value.expiresTime = value.obtainTime + time --到期时间
- flag = false
- end
- end
- end
- --活动限时
- if timeType == 3 then
- type = 3
- --todo 获取称号的有效期
- local actId = fashion.time
- local actdata = getactivityinfo(actor, actId)
- time = math.ceil(actdata.nextopentime / 1000)
- for _, value in pairs(titles) do
- if value.confId == configId then
- value.obtainTime = nowTime --获得时间
- value.expiresTime = time --到期时间
- flag = false
- end
- end
- end
- if flag then
- local tt = {}
- tt.obtainTime = math.ceil(getbaseinfo("now") / 1000)
- if type == 1 or type == 3 then
- tt.expiresTime = time
- else
- tt.expiresTime = tt.obtainTime + time
- end
- tt.confId = configId
- table.insert(titles, tt)
- end
- setplaydef(actor, "T$titledata", titledata)
- --更新称号属性
- EquipAndAppear.updatetitleattr(actor)
- end
- --更新称号属性信息
- function EquipAndAppear.updatetitleattr(actor)
- local data = getplaydef(actor, "T$titledata")
- local titles = data.title
- local titleattr = {}
- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- for _, value in pairs(titles) do
- --先校验是否过期
- if value.expiresTime == -1 or value.expiresTime > nowTime then
- --计算属性
- local fashion = ConfigDataManager.getTable("cfg_fashion", "id", value.confId)
- local attr = fashion[1].att
- local str = string.split(attr, "|")
- for _, value in pairs(str) do
- local str2 = string.split(value, "#")
- local num = titleattr[str2[1]]
- local nowNum = str2[2]
- if num == nil then
- titleattr[str2[1]] = tonumber(nowNum)
- else
- titleattr[str2[1]] = tonumber(nowNum) + tonumber(num)
- end
- end
- end
- end
- --更新称号属性
- addrolekmlattributes(actor, "titleattr", titleattr)
- end
- --获取称号详细信息
- function EquipAndAppear.gettitleinfo(actor, msgId)
- local data = getplaydef(actor, "T$titledata")
- if data == nil then
- data = EquipAndAppear.inittitledata(actor)
- end
- if msgId == LuaMessageIdToSever.GET_TITLE then
- sendluamsg(actor, LuaMessageIdToClient.GET_TITLE, data)
- end
- return data
- end
- --保存称号外观
- function EquipAndAppear.settingtitleappear(actor, msgId, msgData)
- local data = getplaydef(actor, "T$titledata")
- local titleappear = msgData["title"]
- data.curEquipTitle = titleappear
- setplaydef(actor, "T$titledata", data)
- if msgId == LuaMessageIdToSever.SET_TITLE then
- sendluamsg(actor, LuaMessageIdToClient.SETTING_TITLE_APPEAR, titleappear)
- local result = {}
- result.rid = getbaseinfo(actor, "rid")
- result.curEquipTitle = titleappear
- sendrefluamsg(actor, LuaMessageIdToClient.RES_TITLE_CHANGE_UPDATE, result)
- end
- end
- --初始化数据
- function EquipAndAppear.inittitledata(actor)
- local data = {}
- data.title = {}
- data.hidden = false
- data.curEquipTitle = 0
- setplaydef(actor, "T$titledata", data)
- return data
- end
- --校验称号的过期时间
- function EquipAndAppear.checktitleovertime(actor)
- local data = getplaydef(actor, "T$titledata")
- if table.count(data) == 0 then
- data = EquipAndAppear.inittitledata(actor)
- end
- local titles = data.title
- if table.count(titles) == 0 then
- return
- end
- local curTitle = data.curEquipTitle
- local flag = false
- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- for key, value in pairs(titles) do
- --先校验是否过期
- --jprint("检查称号过期0",value.expiresTime > nowTime, value.expiresTime, nowTime)
- if value.expiresTime ~= -1 and value.expiresTime < nowTime then
- table.remove(titles, key)
- flag = true
- if curTitle == value.confId then
- data.curEquipTitle = 0
- end
- end
- end
- if flag then
- data.title = titles
- setplaydef(actor, "T$titledata", data)
- EquipAndAppear.updatetitleattr(actor)
- --发送消息
- sendluamsg(actor, LuaMessageIdToClient.SETTING_TITLE_APPEAR, 0)
- end
- end
- --获取守护外观
- function EquipAndAppear.getguardappear(actor, msgId)
- local data = getrolefield(actor, "role.roleEquip.guardAppear")
- if data == nil then
- sendluamsg(actor, LuaMessageIdToClient.RES_GUARD_APPEAR, {})
- return {}
- end
- local result = {}
- for key, value in pairs(data) do
- local mm = {}
- mm.att = value.attr
- mm.getTime = math.floor(value.getTime / 1000)
- mm.itemId = key
- if value.time ~= -1 then
- mm.time = mm.getTime + math.floor(value.time / 1000)
- else
- mm.time = -1
- end
- table.insert(result, mm)
- end
- if msgId == LuaMessageIdToSever.GET_GUARD_APPEAR then
- sendluamsg(actor, LuaMessageIdToClient.RES_GUARD_APPEAR, result)
- end
- return data
- end
- --获取变身戒指数据
- function EquipAndAppear.getshapering(actor, msgId)
- local data = getrolefield(actor, "role.roleEquip.shapeRing")
- if data == nil then
- return {}
- end
- local nowwear = EquipAndAppear.getnowwearshapering(actor)
- local rd = {}
- local result = {}
- rd.curWearRing = nowwear
- for key, value in pairs(data) do
- local mm = {}
- mm.monsterId = tonumber(key)
- mm.ringAttr = value.ringAttr
- mm.getTime = math.floor(value.getTime / 1000)
- mm.itemId = value.itemId
- if value.time ~= -1 then
- mm.time = math.floor(value.time / 1000)
- else
- mm.time = -1
- end
- table.insert(result, mm)
- end
- rd.title = result
- if msgId == LuaMessageIdToSever.GET_SHAPE_RING then
- sendluamsg(actor, LuaMessageIdToClient.GET_SHAPE_RING, rd)
- end
- return data
- end
- --穿戴变身戒指
- function EquipAndAppear.wearshapering(actor, msgData)
- local monsterId = msgData["monsterId"]
- setplaydef(actor, "T$wearshapering", monsterId)
- setshaperingdata(actor, monsterId)
- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, monsterId)
- local result = {}
- result.rid = getbaseinfo(actor, "rid")
- result.curEquipRing = monsterId
- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
- end
- --获取当前穿戴的变身戒指
- function EquipAndAppear.getnowwearshapering(actor)
- local data = getplaydef(actor, "T$wearshapering")
- if data == nil then
- return 0
- end
- return data
- end
- --校验变身戒指过期时间
- function EquipAndAppear.checkringovertime(actor)
- local data = EquipAndAppear.getshapering(actor)
- local ringId = EquipAndAppear.getnowwearshapering(actor)
- if ringId == 0 then
- return
- end
- local monsterId = ConfigDataManager.getTableValue("cfg_item", "useParam", "id", ringId)
- if not monsterId then
- return
- end
- if not data[tostring(monsterId)] then
- setplaydef(actor, "T$wearshapering", 0)
- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, 0)
- local result = {}
- result.rid = getbaseinfo(actor, "rid")
- result.curEquipRing = 0
- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
- end
- -- local nowTime = math.ceil(getbaseinfo("now") / 1000)
- -- for index, ring in pairs(data) do
- -- if ring ~= -1 then
- -- --检查
- -- if nowTime > math.floor(ring.time / 1000) then
- -- --删除穿戴外观
- -- local ringId = EquipAndAppear.getnowwearshapering(actor)
- -- if ringId == ring then
- -- setplaydef(actor, "T$wearshapering", 0)
- -- sendluamsg(actor, LuaMessageIdToClient.RES_PUTOON_RING, 0)
- -- local result = {}
- -- result.rid = getbaseinfo(actor, "rid")
- -- result.curEquipRing = 0
- -- sendrefluamsg(actor, LuaMessageIdToClient.RES_RING_CHANGE_UPDATE, result)
- -- end
- -- table.remove(data, index)
- -- end
- -- end
- -- end
- end
- function EquipAndAppear.initequipluaextdata(alldata, itemid)
- local equipdata = {}
- equipdata.strengthlv = 0
- equipdata.appendlv = 0
- equipdata.strengthattr = {}
- equipdata.appendattr = {}
- alldata[itemid] = equipdata
- end
- --装备强化
- function EquipAndAppear.luastrengthequip(actor, msgData)
- local itemid = msgData.itemId
- local equip = getequipinfo(actor, itemid, 1)
- if equip == nil then
- return
- end
- 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 = 0
- equipdata.strengthattr = {}
- end
- local lv = equipdata.strengthlv + 1
- local cfgId = equip.cfgid
- --首饰的强化等级特殊处理
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group ~= nil and group ~= "" then
- local strengthenmaxLevel =
- ConfigDataManager.getTableValue(
- "cfg_equip_ornaments",
- "strengthenmaxLevel",
- "ornamentsGroup",
- group,
- "lv",
- equipdata.ssuplv or 0
- )
- if tonumber(strengthenmaxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已强化到最大等级")
- return
- end
- else
- local maxLevel = ConfigDataManager.getTableValue("cfg_equip_strengthen", "maxLevel", "id", cfgId)
- if tonumber(maxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已强化到最大等级")
- return
- end
- end
- local costId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "costId", "id", cfgId)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "groupId", "id", cfgId)
- --获取消耗
- local coststr =
- ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "cost", "costGroupId", costId, "level", lv)
- if coststr == nil then
- return
- end
- local cost = splitbyshuxianandjinghao(coststr)
- --校验道具是否足够
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- TimeLimitGift.checkSpecial2Condition(actor)
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣材料
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- TimeLimitGift.checkSpecial2Count(actor)
- --获取成功率
- local rate = ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "rate", "costGroupId", costId, "level", lv)
- local randomNumber = math.random(1, 10000)
- rate = tonumber(rate)
- if rate < randomNumber then
- --失败,校验是否等级回退
- local failLevel =
- ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "failLevel", "costGroupId", costId, "level", lv)
- failLevel = tonumber(failLevel)
- if not equip.isbind then
- changeitembindstate(actor,itemid,1)
- local res = {itemId = itemid,bindId = true}
- sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
- end
- if failLevel == equipdata.strengthlv then
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.strengthlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
- return
- end
- local att =
- ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", failLevel)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.strengthlv = failLevel
- equipdata.strengthattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- info(actor, "玩家", actor, "强化装备至" .. lv .. "级失败,失败后等级" .. failLevel, "道具id" .. itemid, "cfgId:" .. cfgId)
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.strengthlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
- EquipMaster.strengthMaster(actor)
- --装备强化之后发送装备强化信息
- EquipAndAppear.updateequipgmext(actor, itemid, dddd.strengthlv)
- return
- end
- --获取属性加成
- local att = ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", lv)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.strengthlv = lv
- equipdata.strengthattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- local firstRate =
- ConfigDataManager.getTableValue("cfg_equip_strengthenCost", "firstRate", "costGroupId", costId, "level", lv)
- firstRate = tonumber(firstRate)
- if firstRate == 1 then
- --发送跑马灯
- local name = getrolefield(actor, "role.basic.name")
- local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- local content = "恭喜" .. name .. "将" .. equipName .. "强化至" .. lv .. "级"
- local horseled = {}
- horseled.content = content
- horseled.cfgId = 109 -- 109是直接写死的
- sendluamsg(actor, LuaMessageIdToClient.HORSE_LAMP, horseled)
- end
- info(actor, "玩家", actor, "强化装备至" .. lv .. "级成功", "道具id" .. itemid, "cfgId:" .. cfgId)
- if not equip.isbind then
- changeitembindstate(actor,itemid,1)
- local res = {itemId = itemid,bindId = true}
- sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
- end
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.strengthlv = tonumber(lv)
- dddd.issuccess = true
- sendluamsg(actor, LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, dddd)
- EquipMaster.strengthMaster(actor)
- --记录强化次数
- local oldCount = EquipAndAppear.GetEquipStrengthCount(actor)
- setplaydef(actor, ROLE_EQUIP_STRENGTH_TIMES, oldCount + 1)
- ---触发装备强化任务
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- local taskParam = {
- part = strPart,
- level = lv
- }
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.PARTS_STRENGTHEN_LV, taskParam)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_STRENGTHEN_TIMES, lv)
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL)
- --装备强化之后发送装备强化信息
- EquipAndAppear.updateequipgmext(actor, itemid, dddd.strengthlv)
- LogManager.RoleStrenthenEquip(actor)
- end
- ---获取玩家装备累计强化次数
- function EquipAndAppear.GetEquipStrengthCount(actor)
- local totalCount = getplaydef(actor, ROLE_EQUIP_STRENGTH_TIMES)
- if totalCount == nil then
- totalCount = 0
- end
- return totalCount
- end
- function EquipAndAppear.updateequipgmext(actor, itemid, strengthlv)
- -- local gmext = getequipgmext(actor,itemid)
- -- if gmext == nil or gmext == "null" then
- -- gmext = {}
- -- end
- local gmext = {}
- gmext.strengthlv = strengthlv
- setequipgmext(actor, itemid, gmext)
- end
- function splitbyshuxianandjinghao2(str)
- local dt = {}
- local data = string.split(str, "|")
- for _, v in ipairs(data) do
- local data2 = string.split(v, "#")
- dt[data2[1]] = data2[2]
- end
- return dt
- end
- --装备追加
- function EquipAndAppear.luaappendequip(actor, msgData)
- local itemid = msgData.itemId
- local equip = getequipinfo(actor, itemid, 1)
- if equip == nil then
- return
- end
- local alldata = EquipAndAppear.getLuaItemExtData(actor)
- local equipdata = alldata[itemid]
- if equipdata == nil then
- EquipAndAppear.initequipluaextdata(alldata, itemid)
- equipdata = alldata[itemid]
- end
- if equipdata.appendlv == nil then
- equipdata.appendlv = 0
- equipdata.appendattr = {}
- end
- local lv = equipdata.appendlv + 1
- local cfgId = equip.cfgid
- --首饰的强化等级特殊处理
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group ~= nil and group ~= "" then
- local appendsmaxLevel =
- ConfigDataManager.getTableValue(
- "cfg_equip_ornaments",
- "appendsmaxLevel",
- "ornamentsGroup",
- group,
- "lv",
- equipdata.ssuplv or 0
- )
- if tonumber(appendsmaxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已追加到最大等级")
- return
- end
- else
- local maxLevel = ConfigDataManager.getTableValue("cfg_equip_appends", "maxLevel", "id", cfgId)
- if tonumber(maxLevel) < lv then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已追加到最大等级")
- return
- end
- end
- local costId = ConfigDataManager.getTableValue("cfg_equip_appends", "costId", "id", cfgId)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_appends", "groupId", "id", cfgId)
- --获取消耗
- local coststr = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "cost", "costGroupId", costId, "level", lv)
- if coststr == nil then
- return
- end
- local cost = splitbyshuxianandjinghao(coststr)
- --校验道具是否足够
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣材料
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --获取成功率
- local rate = ConfigDataManager.getTableValue("cfg_equip_appendsCost", "rate", "costGroupId", costId, "level", lv)
- local randomNumber = math.random(1, 10000)
- rate = tonumber(rate)
- if rate < randomNumber then
- --失败,校验是否等级回退
- local failLevel =
- ConfigDataManager.getTableValue("cfg_equip_appendsCost", "failLevel", "costGroupId", costId, "level", lv)
- failLevel = tonumber(failLevel)
- if not equip.isbind then
- changeitembindstate(actor,itemid,1)
- local res = {itemId = itemid,bindId = true}
- sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
- end
- if failLevel == equipdata.appendlv then
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.appendlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
- return
- end
- local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", failLevel)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.appendlv = failLevel
- equipdata.appendattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- info(actor, "玩家", actor, "追加装备至" .. lv .. "级失败,失败后等级" .. failLevel, "道具id" .. itemid, "cfgId:" .. cfgId)
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.appendlv = tonumber(failLevel)
- dddd.issuccess = false
- sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
- EquipMaster.appendMaster(actor)
- return
- end
- --获取属性加成
- local att = ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", lv)
- local attr = splitbyshuxianandjinghao2(att)
- equipdata.appendlv = lv
- equipdata.appendattr = attr
- EquipAndAppear.SetItemExtData(actor, itemid, equipdata)
- setplaydef(actor, "T$luaitemextdata", alldata)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- local firstRate =
- ConfigDataManager.getTableValue("cfg_equip_appendsCost", "firstRate", "costGroupId", costId, "level", lv)
- firstRate = tonumber(firstRate)
- if firstRate == 1 then
- --发送跑马灯
- local name = getrolefield(actor, "role.basic.name")
- local equipName = ConfigDataManager.getTableValue("cfg_item", "name", "id", cfgId)
- local content = "恭喜" .. name .. "将" .. equipName .. "追加至" .. lv .. "级"
- local horseled = {}
- horseled.cfgId = 115
- horseled.content = content
- sendluamsg(actor, LuaMessageIdToClient.HORSE_LAMP, horseled)
- end
- --给客户端发强化结果
- local dddd = {}
- dddd.itemId = itemid
- dddd.appendlv = tonumber(lv)
- dddd.issuccess = true
- sendluamsg(actor, LuaMessageIdToClient.APPEND_EQUIP_RESULT, dddd)
- info(actor, "玩家", actor, "追加装备至" .. lv .. "级成功", "道具id" .. itemid, "cfgId:" .. cfgId)
- if not equip.isbind then
- changeitembindstate(actor,itemid,1)
- local res = {itemId = itemid,bindId = true}
- sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
- end
-
- EquipMaster.appendMaster(actor)
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_APPEND_LEVEL)
- -- 刷新任务进度
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- local taskParam = {
- part = strPart,
- level = lv
- }
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_APPEND, taskParam)
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.EQUIP_APPEND_TOTAL_LV)
- LogManager.RoleAppendEquip(actor)
- end
- --- 获取所有装备数据
- function EquipAndAppear.getLuaItemExtData(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- if alldata == nil then
- --说明还没有进行过锻造
- setplaydef(actor, "T$luaitemextdata", {})
- alldata = getplaydef(actor, "T$luaitemextdata")
- end
- return alldata
- end
- --装备属性转移
- function EquipAndAppear.luatransferequip(actor, msgData)
- local firstId = msgData.firstItem
- local secId = msgData.secondItem
- local equip1 = getequipinfo(actor, firstId, 1)
- if equip1 == nil then
- return
- end
- local equip2 = getequipinfo(actor, secId, 1)
- if equip2 == nil then
- return
- end
- local id1 = equip1.cfgid
- local id2 = equip2.cfgid
- local data1 = ConfigDataManager.getTable("cfg_equip_transfer", "id", id1)
- local data2 = ConfigDataManager.getTable("cfg_equip_transfer", "id", id2)
- if
- (data1 == nil) or (data2 == nil) or (data1.transferGroup ~= data2.transferGroup) or
- (data1.transfer ~= data2.transfer)
- then
- return
- end
- local ts = msgData.transferStrength -- bool类型
- local ta = msgData.transferAppend
- local tr = msgData.transferRegeneration
- if not ts and not ta and not tr then
- return
- end
- --扩展数据
- local extdata = getplaydef(actor, "T$luaitemextdata")
- local ext1 = extdata[firstId]
- local ext2 = extdata[secId]
- if ext2 == nil then
- ext2 = {}
- ext2.appendattr = {}
- ext2.strengthattr = {}
- ext2.appendlv = 0
- ext2.strengthlv = 0
- end
- --转移前强化追加
- info(
- actor,
- "转移前强化追加等级,rid:",
- actor,
- "强化等级:",
- ext1.strengthlv,
- ext2.strengthlv,
- "追加等级:",
- ext1.appendlv,
- ext2.appendlv,
- "主装备id:" .. firstId .. "主装备cfgId:" .. id1,
- "副装备id:" .. secId .. "副装备cfgId:" .. id2
- )
- local allCost = {}
- --强化消耗
- if ts then
- local lv1 = ext1.strengthlv
- local lv2 = ext2.strengthlv
- if lv2 ~= 0 then
- return
- end
- local costItem = data1[1].strengthencost
- local cost = splittransfercoststr(costItem)
- local realLv = 0
- local realCost = {}
- for key, value in pairs(cost) do
- if key > realLv and key <= lv1 then
- realLv = key
- realCost = value
- end
- end
- table.insert(allCost, realCost)
- end
- if table.count(allCost[1]) == 0 then
- allCost[1] = {}
- end
- --追加消耗
- if ta then
- local lv1 = ext1.appendlv
- local lv2 = ext2.appendlv
- if lv2 ~= 0 then
- return
- end
- local costItem = data1[1].appendscost
- local cost = splittransfercoststr(costItem)
- local realLv = 0
- local realCost = {}
- for key, value in pairs(cost) do
- if key > realLv and key <= lv1 then
- realLv = key
- realCost = value
- end
- end
- for _, value in pairs(realCost) do
- local cId = value["cfgid"]
- local num = value["count"]
- local n = 0
- for _1, v in pairs(allCost[1]) do
- if v["cfgid"] == cId then
- v["count"] = v["count"] + num
- n = n + 1
- end
- end
- if n == 0 then
- table.insert(allCost[1], value)
- end
- end
- end
- --再生消耗
- if tr then
- local lv1 = ext1.regenerationlv
- local lv2 = ext2.regenerationlv
- if lv2 == nil then
- ext2.regenerationlv = 0
- lv2 = 0
- end
- if lv2 ~= 0 then
- return
- end
- local costItem = data1[1].regenerationcost
- local cost = splittransfercoststr(costItem)
- local realLv = 0
- local realCost = {}
- for key, value in pairs(cost) do
- if key > realLv and key <= lv1 then
- realLv = key
- realCost = value
- end
- end
- for _, value in pairs(realCost) do
- local cId = value["cfgid"]
- local num = value["count"]
- local n = 0
- for _1, v in pairs(allCost[1]) do
- if v["cfgid"] == cId then
- v["count"] = v["count"] + num
- n = n + 1
- end
- end
- if n == 0 then
- table.insert(allCost[1], value)
- end
- end
- end
- --检查道具是否足够
- local enough = Bag.checkItemEnough(actor, allCost[1])
- if not enough then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣道具
- for _, v in ipairs(allCost[1]) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --转移强化
- if ts then
- local slv1 = ext1.strengthlv
- ext2.strengthlv = slv1
- ext1.strengthlv = 0
- ext1.strengthattr = {}
- --赋值属性
- local maxLv = ConfigDataManager.getTableValue("cfg_equip_strengthen", "maxLevel", "id", equip2.cfgid)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_strengthen", "groupId", "id", equip2.cfgid)
- if ext2.strengthlv > tonumber(maxLv) then
- ext2.strengthlv = tonumber(maxLv)
- end
- local att =
- ConfigDataManager.getTableValue("cfg_equip_strengthenGroup", "att", "group", groupId, "lv", ext2.strengthlv)
- local attr = splitbyshuxianandjinghao2(att)
- ext2.strengthattr = attr
- EquipAndAppear.updateequipgmext(actor, firstId, 0)
- EquipAndAppear.updateequipgmext(actor, secId, ext2.strengthlv)
- end
- --转移追加
- if ta then
- local slv1 = ext1.appendlv
- ext2.appendlv = slv1
- ext1.appendlv = 0
- ext1.appendattr = {}
- --赋值属性
- local maxLv = ConfigDataManager.getTableValue("cfg_equip_appends", "maxLevel", "id", equip2.cfgid)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_appends", "groupId", "id", equip2.cfgid)
- if ext2.appendlv > tonumber(maxLv) then
- ext2.appendlv = tonumber(maxLv)
- end
- local att =
- ConfigDataManager.getTableValue("cfg_equip_appendsGroup", "att", "group", groupId, "lv", ext2.appendlv)
- local attr = splitbyshuxianandjinghao2(att)
- ext2.appendattr = attr
- end
- --转移再生
- if tr then
- local relv = ext1.regenerationlv
- ext2.regenerationlv = relv
- ext1.regenerationlv = 0
- ext2.regenerationattr = {}
- --赋值属性
- local maxLv = ConfigDataManager.getTableValue("cfg_equip_regeneration", "levelMax", "id", equip2.cfgid)
- local groupId = ConfigDataManager.getTableValue("cfg_equip_regeneration", "Group", "id", equip2.cfgid)
- if ext2.regenerationlv > tonumber(maxLv) then
- ext2.regenerationlv = tonumber(maxLv)
- end
- local regeattr = ext1.regenerationattr
- for _, value in pairs(regeattr) do
- local id = value.id
- local regenerationgroup = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
- if table.count(regenerationgroup) ~= 0 then
- local sequence = regenerationgroup[1].sequence
- --找对应的表
- local nexttable =
- ConfigDataManager.getTable(
- "cfg_equip_regenerationGroup",
- "group",
- groupId,
- "sequence",
- sequence,
- "level",
- ext2.regenerationlv
- )
- if table.count(nexttable) ~= 0 then
- local att = nexttable[1].att
- local str = string.split(att, "#")
- local dd = {}
- dd[str[1]] = tonumber(str[2])
- dd.id = tonumber(nexttable[1].id)
- ext2.regenerationattr[tostring(table.count(ext2.regenerationattr) + 1)] = dd
- end
- end
- end
- ext1.regenerationattr = {}
- end
- --更新数据
- extdata[firstId] = ext1
- extdata[secId] = ext2
- EquipAndAppear.SetItemExtData(actor, firstId, ext1)
- EquipAndAppear.SetItemExtData(actor, secId, ext2)
- setplaydef(actor, "T$luaitemextdata", extdata)
- EquipAndAppear.updateluaextattr(actor)
- --转移后强化追加
- info(
- actor,
- "转移后强化追加等级,rid:",
- actor,
- "强化等级:",
- ext1.strengthlv,
- ext2.strengthlv,
- "追加等级:",
- ext1.appendlv,
- ext2.appendlv,
- "主装备id:" .. firstId .. "主装备cfgId:" .. id1,
- "副装备id:" .. secId .. "副装备cfgId:" .. id2
- )
- if not equip2.isbind then
- changeitembindstate(actor,secId,1)
- local res = {itemId = secId,bindId = true}
- sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
- end
- --检查主装备是否还有强化追加属性
- if this.checkEquipStrengthAndAppend(actor,firstId) then
- --变为非绑定
- changeitembindstate(actor,firstId,0)
- local res = {itemId = firstId,bindId = false}
- sendluamsg(actor,LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE,res)
- end
- EquipMaster.transferTrigger(actor, equip1, equip2, ts, ta)
- --发送lua消息到客户端
- local data = {}
- data.oldItem = firstId
- data.newItem = secId
- data.issuccess = true
- sendluamsg(actor, LuaMessageIdToClient.RES_TRANSFER_EQUIP, data)
- end
- function this.checkEquipStrengthAndAppend(actor,itemId)
- local allData = EquipAndAppear.getLuaItemExtData(actor)
- local equipData = allData[tonumber(itemId)]
- if not equipData then
- return true
- end
- local strengthlv = equipData.strengthlv
- local appendlv = equipData.appendlv
- if (strengthlv == 0) and (appendlv == 0) then
- return true
- end
- return false
- end
- function EquipAndAppear.checkCanTransfer(actor, firstId, secId)
- if firstId == 0 then
- return
- end
- local data = {}
- data.oldItem = firstId
- data.newItem = secId
- sendluamsg(actor, LuaMessageIdToClient.RES_CAN_TRANSFER, data)
- end
- function splittransfercoststr(str)
- local s = string.split(str, "|")
- local data = {}
- for _, value in pairs(s) do
- local x = string.split(value, "#")
- local len = #x
- local itemList = {}
- if len == 3 then
- local item = {}
- item["cfgid"] = x[2]
- item["count"] = x[3]
- table.insert(itemList, item)
- else
- if len > 3 then
- for i = 1, len do
- local item = {}
- if i == 1 then
- item["cfgid"] = x[i + 1]
- item["count"] = x[i + 2]
- i = i + 3
- else
- item["cfgid"] = x[i]
- item["count"] = x[i + 1]
- i = i + 2
- end
- table.insert(itemList, item)
- end
- end
- end
- data[tonumber(x[1])] = itemList
- end
- return data
- end
- function EquipAndAppear.updateluaextattr(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(actor)
- local allattr = {}
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- if data ~= nil then
- --将该装备的属性加到角色身上
- if data.strengthlv ~= nil then
- local strengthattr = data.strengthattr
- table.mergeAdd(allattr, strengthattr)
- end
- if data.appendlv ~= nil then
- local appendattr = data.appendattr
- table.mergeAdd(allattr, appendattr)
- end
- if data.ssuplv ~= nil then
- local ssupattr = data.ssupattr
- local ssactattr = data.ssactattr
- table.mergeAdd(allattr, ssupattr)
- table.mergeAdd(allattr, ssactattr)
- end
- if data.regenerationlv ~= nil then
- local reattr = data.regenerationattr
- local regenerationattr = {}
- for _, att in pairs(reattr) do
- for key, value in pairs(att) do
- if key ~= "id" then
- local num = regenerationattr[key]
- if num == nil then
- num = 0
- end
- regenerationattr[key] = num + value
- end
- end
- end
- table.mergeAdd(allattr, regenerationattr)
- end
- end
- end
- --更新装备记录
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_ENTRY_COUNT)
- --记录强化追加等属性
- if table.count(allattr) == 0 then
- addrolekmlattributes(actor, "luaextdataforever", {})
- return
- end
- addrolekmlattributes(actor, "luaextdataforever", allattr)
- end
- --首饰升级
- function EquipAndAppear.ssupdate(actor, msgData)
- local itemId = msgData["itemId"]
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local equipext = allequip[itemId]
- if equipext == nil then
- equipext = {}
- end
- if equipext.ssuplv == nil then
- equipext.ssupattr = {}
- equipext.ssuplv = 0
- equipext.ssactlv = {}
- equipext.ssactattr = {}
- end
- local equip = getequipinfo(actor, itemId, 1)
- local cfgId = equip.cfgid
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- if group == nil then
- return
- end
- local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", equipext.ssuplv)
- if ornaments == nil or table.count(ornaments) == 0 then
- return
- end
- local ornaments2 = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", (equipext.ssuplv or 0) + 1)
- if ornaments2 == nil or table.count(ornaments2) == 0 then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "已经是最大等级!")
- return
- end
- local data = ornaments2[1]
- local cost = ornaments[1].lvdeplete
- local costItem = splitbyshuxianandjinghao(cost)
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, costItem)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣材料
- for _, v in ipairs(costItem) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --升级,加属性
- equipext.ssuplv = tonumber(data.lv)
- local att = data.basicatt
- local attr = splitbyshuxianandjinghao2(att)
- equipext.ssupattr = attr
- allequip[itemId] = equipext
- EquipAndAppear.SetItemExtData(actor, itemId, equipext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- --升级成功 回包给客户端
- local result = {}
- result.ssupattr = equipext.ssupattr
- result.ssuplv = tostring(equipext.ssuplv)
- result.ssactlv = equipext.ssactlv
- result.ssactattr = equipext.ssactattr
- result.itemId = itemId
- sendluamsg(actor, LuaMessageIdToClient.RES_UPDATE_EQUIP_ORNAMENTS, result)
- --更新属性
- EquipAndAppear.updateluaextattr(actor)
- --更新等级记录
- this.TryUpdateEquipInfoRecorde(actor, EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL)
- -- 刷新任务进度
- TaskHandler.TriggerTaskGoal(actor, TaskTargetType.JEWELRY_LV_UP)
- end
- --首饰等级属性激活
- function EquipAndAppear.actssattr(actor, msgData)
- local itemId = msgData["itemId"]
- local lv = msgData["lv"]
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local equipext = allequip[itemId]
- if equipext.ssuplv == nil then
- return
- end
- local equip = getequipinfo(actor, itemId, 1)
- local cfgId = equip.cfgid
- local group = ConfigDataManager.getTableValue("cfg_equip_ornamentsMain", "ornamentsGroup", "id", cfgId)
- local ssuplv = equipext.ssuplv
- if ssuplv < lv then
- return
- end
- if table.contains(equipext.ssactlv, lv) then
- return
- end
- local ornaments = ConfigDataManager.getTable("cfg_equip_ornaments", "ornamentsGroup", group, "lv", lv)
- if table.count(ornaments) == 0 then
- return
- end
- if ornaments[1].unlockdeplete == nil then
- return
- end
- local unlockDeplete = ornaments[1].unlockdeplete
- if unlockDeplete == nil then
- return
- end
- local costItem = splitbyshuxianandjinghao(unlockDeplete)
- --检查背包是否道具充足
- local enough = Bag.checkItemEnough(actor, costItem)
- if enough == false then
- return
- end
- --扣材料
- for _, v in ipairs(costItem) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- equipext.ssactlv[tostring(lv)] = lv
- local att = ornaments[1].excellenceatt
- local attr = splitbyshuxianandjinghao2(att)
- table.mergeAdd(equipext.ssactattr, attr)
- allequip[itemId] = equipext
- EquipAndAppear.SetItemExtData(actor, itemId, equipext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- --发送回包给客户端
- local result = {}
- result.ssupattr = equipext.ssupattr
- result.ssuplv = equipext.ssuplv
- result.ssactlv = equipext.ssactlv
- result.ssactattr = equipext.ssactattr
- result.itemId = itemId
- sendluamsg(actor, LuaMessageIdToClient.RES_ACT_EQUIP_ORNAMENTS, result)
- --更新属性
- EquipAndAppear.updateluaextattr(actor)
- end
- function EquipAndAppear.allequipstrengthlv(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(actor)
- local allequipstrengthlv = 0
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- if data ~= nil then
- if data.strengthlv ~= nil then
- allequipstrengthlv = allequipstrengthlv + data.strengthlv
- end
- end
- end
- return allequipstrengthlv
- end
- function EquipAndAppear.allequipappendlv(actor)
- local alldata = getplaydef(actor, "T$luaitemextdata")
- local equiplist = getputonequipinfo(actor)
- local allequipstrengthlv = 0
- for _, equipinfo in pairs(equiplist) do
- local itemId = equipinfo.id
- local data = alldata[itemId]
- if data ~= nil then
- if data.appendlv ~= nil then
- allequipstrengthlv = allequipstrengthlv + data.appendlv
- end
- end
- end
- return allequipstrengthlv
- end
- --再生
- function EquipAndAppear.regeneration(actor, msgData)
- local itemId = msgData["itemId"]
- local equip = getequipinfo(actor, itemId, 1)
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local ext = allequip[itemId]
- if ext == nil then
- ext = {}
- ext.regenerationlv = 0
- ext.regenerationattr = {}
- end
- if ext.regenerationlv == nil then
- ext.regenerationlv = 0
- ext.regenerationattr = {}
- end
- local lv = ext.regenerationlv
- local tabledata = ConfigDataManager.getTable("cfg_equip_regeneration", "id", equip.cfgid)
- if table.count(tabledata) == 0 then
- return
- end
- local group = tabledata[1].group
- --获取消耗
- local lockattr = msgData["lockattrpos"]
- local startcost = {}
- local type = 0
- if table.count(ext.regenerationattr) == 0 then
- startcost = tabledata[1].start
- type = 1
- else
- if table.count(lockattr) == 0 then
- startcost = tabledata[1].again
- type = 2
- else
- startcost = tabledata[1].lock
- type = 3
- end
- end
- local cost = getlockcost(startcost, lockattr)
- --校验道具是否足够
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣道具
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --随机词条数量
- local attrNum = {}
- if type == 1 then
- attrNum = tabledata[1].startnum
- else
- if type == 2 then
- attrNum = tabledata[1].againnum
- else
- if type == 3 then
- attrNum = tabledata[1].locknum
- end
- end
- end
- local result = random_weighted(attrNum, 1)
- if lv == 0 then
- lv = 1
- end
- --校验词条数是否超过最大值
- local maxAttrNum = tabledata[1].count
- local realNum = result[1] + table.count(lockattr)
- if realNum >= tonumber(maxAttrNum) then
- realNum = tonumber(maxAttrNum) - table.count(lockattr)
- else
- realNum = result[1]
- end
- local attdata = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "group", group, "level", lv)
- local entrytable = build_weight_attr(attdata, ext.regenerationattr, lockattr)
- local entryattr = random_weighted(entrytable, realNum)
- --把这次结果临时存一下
- local xilianattr = {}
- for _, key in pairs(lockattr) do
- xilianattr[tostring(table.count(xilianattr) + 1)] = tonumber(key)
- end
- for _, key in pairs(entryattr) do
- xilianattr[tostring(table.count(xilianattr) + 1)] = tonumber(key)
- end
- local allequiprecord = getplaydef(actor, "T$regeneration")
- if allequiprecord == nil then
- allequiprecord = {}
- end
- local regenerationresult = {}
- regenerationresult.entryAttr = xilianattr
- regenerationresult.itemId = itemId
- allequiprecord[itemId] = regenerationresult
- setplaydef(actor, "T$regeneration", allequiprecord)
- allequip[itemId] = ext
- setplaydef(actor, "T$luaitemextdata", allequip)
- --告诉客户端本次洗练结果
- sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_REGENERATION, xilianattr)
- end
- function EquipAndAppear.getupregenerationattr(actor, msgData)
- local itemId = msgData.itemId
- local data = getplaydef(actor, "T$regeneration")
- if data == nil then
- sendluamsg(actor, LuaMessageIdToClient.RES_UP_REGENERATION_ATTR, {})
- return
- end
- local result = data[itemId]
- if result == nil then
- result = {}
- end
- sendluamsg(actor, LuaMessageIdToClient.RES_UP_REGENERATION_ATTR, result)
- end
- --确认替换词条
- function EquipAndAppear.confirmreplaceentry(actor, msgData)
- -- local lockattr = msgData.lockattrpos
- local itemId = msgData.itemId
- local alldata = getplaydef(actor, "T$regeneration")
- if alldata == nil then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "洗练后再进行替换!")
- return
- end
- local data = alldata[itemId]
- if data == nil then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "洗练后再进行替换!")
- return
- end
- if data.itemId ~= itemId then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "两次itemId不一致!")
- return
- end
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local ext = allequip[itemId]
- ext.regenerationattr = {}
- for _, id in pairs(data.entryAttr) do
- local td = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
- if table.count(td) ~= 0 then
- local attr = td[1].att
- local str = string.split(attr, "#")
- local dd = {}
- dd[str[1]] = tonumber(str[2])
- dd.id = id
- ext.regenerationattr[tostring(table.count(ext.regenerationattr) + 1)] = dd
- ext.regenerationlv = tonumber(td[1].level)
- end
- end
- allequip[itemId] = ext
- EquipAndAppear.SetItemExtData(actor, itemId, ext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- alldata[itemId] = {}
- setplaydef(actor, "T$regeneration", alldata)
- --给客户端发替换结果
- sendluamsg(actor, LuaMessageIdToClient.RES_REPLACE_REGENERATION_ATTR, true)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- end
- --词条强化
- function EquipAndAppear.strengthregenerationattr(actor, msgData)
- local itemId = msgData.itemId
- local allequip = getplaydef(actor, "T$luaitemextdata")
- local ext = allequip[itemId]
- local equip = getequipinfo(actor, itemId, 1)
- local group = ConfigDataManager.getTableValue("cfg_equip_regeneration", "group", "id", equip.cfgid)
- local lv = ext.regenerationlv
- local data = ConfigDataManager.getTable("cfg_equip_regenerationCost", "group", group, "level", lv)
- if table.count(data) == 0 then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "当前装备词条不能强化!")
- return
- end
- local maxLevel = ConfigDataManager.getTableValue("cfg_equip_regeneration", "levelMax", "id", equip.cfgid)
- if tonumber(maxLevel) < lv + 1 then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "该装备已再生到最大等级")
- return
- end
- local str = data[1].cost
- local cost = splitbyshuxianandjinghao(str)
- --检查材料
- local enough = Bag.checkItemEnough(actor, cost)
- if enough == false then
- sendluamsg(actor, LuaMessageIdToClient.TIPS, "道具不足")
- return
- end
- --扣道具
- for _, v in ipairs(cost) do
- local cId = v["cfgid"]
- local count = v["count"]
- removeitemfrombag(actor, cId, count, 0, 9999, "装备外观")
- end
- --计算成功率
- local rate = data[1].rate
- local randomNum = math.random(1, 10000)
- if randomNum > tonumber(rate) then
- --强化失败
- sendluamsg(actor, LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR, false)
- return
- end
- --强化成功增加属性
- local regenerationattr = ext.regenerationattr
- for i, value in pairs(regenerationattr) do
- local key = value.id
- local data = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", key)
- if table.count(data) ~= 0 then
- local sequence = data[1].sequence
- --查找下一级属性
- local nextdata =
- ConfigDataManager.getTable(
- "cfg_equip_regenerationGroup",
- "group",
- group,
- "sequence",
- sequence,
- "level",
- lv + 1
- )
- if table.count(nextdata) ~= 0 then
- local att = nextdata[1].att
- local attr = string.split(att, "#")
- local dd = {}
- dd[attr[1]] = tonumber(attr[2])
- dd.id = tonumber(nextdata[1].id)
- ext.regenerationattr[i] = dd
- -- table.remove(ext.regenerationattr,key)
- end
- end
- end
- ext.regenerationlv = lv + 1
- allequip[itemId] = ext
- EquipAndAppear.SetItemExtData(actor, itemId, ext)
- setplaydef(actor, "T$luaitemextdata", allequip)
- --给客户端发消息
- sendluamsg(actor, LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR, true)
- --更新强化追加等属性
- EquipAndAppear.updateluaextattr(actor)
- --更新洗练未替换的数据
- updateregenoreplaceattr(actor, itemId, ext.regenerationlv, group)
- end
- function updateregenoreplaceattr(actor, itemId, lv, group)
- local alldata = getplaydef(actor, "T$regeneration")
- if alldata == nil then
- return
- end
- local data = alldata[itemId]
- if data == nil then
- return
- end
- local attrs = data.entryAttr
- if attrs == nil then
- return
- end
- for i, id in pairs(data.entryAttr) do
- local td = ConfigDataManager.getTable("cfg_equip_regenerationGroup", "id", id)
- if table.count(td) ~= 0 then
- local sequence = td[1].sequence
- --查找对应等级属性
- local nextdata =
- ConfigDataManager.getTable(
- "cfg_equip_regenerationGroup",
- "group",
- group,
- "sequence",
- sequence,
- "level",
- lv
- )
- if table.count(nextdata) ~= 0 then
- attrs[i] = tonumber(nextdata[1].id)
- end
- end
- end
- data.entryAttr = attrs
- alldata[itemId] = data
- setplaydef(actor, "T$regeneration", alldata)
- end
- function mergeitemcost(cost, lockcost)
- for _, item in pairs(lockcost) do
- local flag = true
- for _, value in pairs(cost) do
- if item.cfgid == value.cfgid then
- value.count = value.count + item.count
- flag = false
- end
- end
- if flag then
- table.insert(cost, item)
- end
- end
- return cost
- end
- function getlockcost(cost, lockattr)
- local result = {}
- local locknum = table.count(lockattr)
- local lc = string.split(cost, "|")
- local str = {}
- if locknum ~= 0 then
- str = string.split(lc[locknum], "&")
- for _, value in pairs(str) do
- local item = string.split(value, "#")
- local i = {}
- i.cfgid = item[1]
- i.count = item[2]
- table.insert(result, i)
- end
- else
- result = splitbyshuxianandjinghao(cost)
- end
- return result
- end
- --根据权重随机词条数量
- function random_weighted(weight_str, count)
- local result = {}
- if count <= 0 then
- return result
- end
- local num = string.split(weight_str, "&")
- local weight_total = 0
- for _, value in pairs(num) do
- local sum = string.split(value, "#")
- weight_total = weight_total + tonumber(sum[2])
- end
- local random_weight = math.random(1, weight_total)
- local cumulative_weight = 0
- for _, value in pairs(num) do
- local sum = string.split(value, "#")
- local weight = tonumber(sum[2])
- cumulative_weight = cumulative_weight + weight
- if cumulative_weight >= random_weight then
- table.insert(result, tonumber(sum[1]))
- if table.count(result) == count then
- return result
- end
- end
- end
- end
- --构造随机词条权重库
- function build_weight_attr(attdata, regenenrationattr, lockattr)
- local entrystr = ""
- for i, value in pairs(attdata) do
- local len = #entrystr
- local id = value.id
- local flag = true
- for _, k in pairs(lockattr) do
- if k == id then
- table.remove(attdata, i)
- flag = false
- end
- end
- if flag then
- local weight = 0
- for key, v in pairs(regenenrationattr) do
- if key == id then
- weight = value.weightdown
- end
- end
- if weight == 0 then
- weight = value.weight
- end
- if len == 0 then
- entrystr = id .. "#" .. weight
- else
- entrystr = entrystr .. "&" .. id .. "#" .. weight
- end
- end
- end
- return entrystr
- end
- function getequipssumstrengthlvtest(actor)
- this.GetSumJewelryLv(actor)
- end
- ---获取角色全身装备强化等级
- function EquipAndAppear.GetEquipsSumStrengthLv(actor)
- return this.GetSumLvByType(actor, EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL)
- end
- ---获取角色全身装备追加等级
- function EquipAndAppear.GetEquipsSumAppendLv(actor)
- return this.GetSumLvByType(actor, EquipAndAppear.RecordeType.MAX_APPEND_LEVEL)
- end
- ---获取角色全身装备卓越词条数量(不包含再生词条)
- function EquipAndAppear.GetEquipsSumExcellentEntryCount(actor)
- return this.GetEquipsSumExcellentEntryCount(actor)
- end
- ---获取角色全身装备卓越词条数量(不包含再生词条)
- function this.GetEquipsSumExcellentEntryCount(actor)
- local allEquip = getputonequipinfo(actor)
- if table.isNullOrEmpty(allEquip) then
- return 0
- end
- local sumCount = 0
- for _, equip in pairs(allEquip) do
- local entryAttrMap = equip.entries
- if not table.isNullOrEmpty(entryAttrMap) then
- sumCount = sumCount + table.count(entryAttrMap)
- end
- end
- return sumCount
- end
- ---获取全身首饰等级
- function this.GetSumJewelryLv(actor)
- return this.GetSumLvByType(actor, EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL)
- end
- function this.GetSumLvByType(actor, lvType)
- local equipList = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipList) then
- return 0
- end
- local allEquip = EquipAndAppear.getLuaItemExtData(actor)
- if table.isNullOrEmpty(allEquip) then
- return 0
- end
- local sumLv = 0
- for _, equipInfo in pairs(equipList) do
- local itemId = equipInfo.id
- local equip = allEquip[itemId]
- local lv = this.GetEquipLvByType(equip, lvType)
- if lv ~= 0 then
- sumLv = sumLv + lv
- end
- end
- return sumLv
- end
- function this.GetEquipLvByType(equip, lvType)
- if table.isNullOrEmpty(equip) then
- return 0
- end
- local lv = 0
- if lvType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
- lv = equip.strengthlv
- elseif lvType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
- lv = equip.appendlv
- elseif lvType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
- lv = equip.ssuplv
- end
- if lv == nil then
- return 0
- end
- return tonumber(lv)
- end
- ---更新装备信息记录
- function EquipAndAppear.TryUpdateEquipInfoRecorde(actor, recordeType)
- this.TryUpdateEquipInfoRecorde(actor, recordeType)
- end
- ---更新装备信息记录
- function this.TryUpdateEquipInfoRecorde(actor, recordeType)
- local equipInfoRecorde = EquipAndAppear.GetEquipInfoRecorde(actor)
- if recordeType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
- local oldLv = equipInfoRecorde.max_strength_level
- local newLv = EquipAndAppear.GetEquipsSumStrengthLv(actor)
- if newLv > oldLv then
- equipInfoRecorde.max_strength_level = newLv
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- end
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.StageRank.EQUIP_MAX_STRENGTHEN_LV, newLv)
- OpenServerCompetition.updateRankData(actor, CompetitionType.STRENGTHEN, newLv)
- elseif recordeType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
- local oldLv = equipInfoRecorde.max_append_level
- local newLv = EquipAndAppear.GetEquipsSumAppendLv(actor)
- if newLv > oldLv then
- equipInfoRecorde.max_append_level = newLv
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- end
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.StageRank.EQUIP_MAX_APPEND_LV, newLv)
- OpenServerCompetition.updateRankData(actor, CompetitionType.APPEND, newLv)
- elseif recordeType == EquipAndAppear.RecordeType.MAX_ENTRY_COUNT then
- local oldCount = equipInfoRecorde.max_entry_count
- local newCount = this.GetEquipsSumExcellentEntryCount(actor)
- if newCount > oldCount then
- equipInfoRecorde.max_entry_count = newCount
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.RealTimeRank.SUPERIOR_ENTRY_COUNT, newCount)
- end
- elseif recordeType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
- local oldLv = equipInfoRecorde.max_jewelry_level
- local newLv = this.GetSumJewelryLv(actor)
- if newLv > oldLv then
- equipInfoRecorde.max_jewelry_level = newLv
- this.SaveEquipInfoRecorde(actor, equipInfoRecorde)
- end
- OpenServerAct.UpdateRankValue(actor, OpenServerAct.RealTimeRank.JEWELRY_LEVEL, newLv)
- end
- end
- function EquipAndAppear.GetEquipInfoRecordeValue(actor, recordeType)
- local equipInfoRecorde = EquipAndAppear.GetEquipInfoRecorde(actor)
- if recordeType == EquipAndAppear.RecordeType.MAX_STRENGTH_LEVEL then
- return equipInfoRecorde.max_strength_level
- elseif recordeType == EquipAndAppear.RecordeType.MAX_APPEND_LEVEL then
- return equipInfoRecorde.max_append_level
- elseif recordeType == EquipAndAppear.RecordeType.MAX_ENTRY_COUNT then
- return equipInfoRecorde.max_entry_count
- elseif recordeType == EquipAndAppear.RecordeType.MAX_JEWELRY_LEVEL then
- return equipInfoRecorde.max_jewelry_level
- end
- return 0
- end
- function EquipAndAppear.CheckPartEquipStrengthLv(actor, part, goalLv)
- local equipList = getputonequipinfo(actor)
- if table.isNullOrEmpty(equipList) then
- return false
- end
- local allData = EquipAndAppear.getLuaItemExtData(actor)
- if table.isNullOrEmpty(allData) then
- return false
- end
- for _, equipInfo in pairs(equipList) do
- local itemId = equipInfo.id
- local cfgId = equipInfo.cfgid
- local equipData = allData[itemId]
- if not table.isNullOrEmpty(equipData) then
- local strengthLv = equipData.strengthlv
- if part == nil and strengthLv >= goalLv then
- return true
- end
- if part ~= nil then
- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- if tonumber(strPart) == part and strengthLv >= goalLv then
- return true
- end
- end
- end
- end
- return false
- end
- function checkspecificstageequipcounttest(actor)
- EquipAndAppear.CheckSpecificStageEquipCount(actor, stageLimit, equipType)
- end
- ---检查阶段装备数量
- function EquipAndAppear.CheckSpecificStageEquipCount(actor, stageLimit, ratingLimit)
- local allEquip = getputonequipinfo(actor)
- if table.isNullOrEmpty(allEquip) then
- return 0
- end
- local sumCount = 0
- for _, equip in pairs(allEquip) do
- local cfgId = equip.cfgid
- local armor = this.IsArmor(cfgId)
- if armor then
- local stage = tonumber(ConfigDataManager.getTableValue("cfg_item", "rank", "id", cfgId))
- if stage ~= nil and (stageLimit == nil or stage >= stageLimit) then
- local rating = EquipAndAppear.GetEquipRating(cfgId)
- if table.isNullOrEmpty(ratingLimit) or ratingLimit == rating or table.contains(ratingLimit, rating) then
- sumCount = sumCount + 1
- end
- end
- end
- end
- return sumCount
- end
- ---获取装备评级
- function EquipAndAppear.GetEquipRating(itemCfgId)
- local ratingScore =
- tonumber(ConfigDataManager.getTableValue("cfg_equip_entrylib", "initialrating", "id", itemCfgId))
- if ratingScore == nil then
- return 0
- end
- local equipQualityCfgList = ConfigDataManager.getTable("cfg_equip_quality")
- if table.isNullOrEmpty(equipQualityCfgList) then
- return 0
- end
- for rating, equipQualityCfg in pairs(equipQualityCfgList) do
- local stageParam = string.split(equipQualityCfg["stage"], "#")
- if ratingScore >= tonumber(stageParam[1]) and ratingScore <= tonumber(stageParam[2]) then
- return tonumber(rating)
- end
- end
- return 0
- end
- ---是否防具
- function this.IsArmor(cfgId)
- --策划要求代码写死
- local strPart = tonumber(ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId))
- if strPart == nil then
- return false
- end
- if strPart == 4 or strPart == 5 or strPart == 6 or strPart == 7 or strPart == 8 then
- return true
- end
- return false
- end
- function EquipAndAppear.SetItemExtData(actor, itemId, equipData)
- local result = setitemextdata(actor, itemId, equipData)
- if result == nil or result == false then
- gameDebug.assertPrintTrace(false, actor, "setitemextdata失败!", itemId, equipData)
- end
- end
- --
- --
- --function EquipAndAppear.CheckPartEquipStrengthLv(actor, part,goalLv)
- -- EquipAndAppear.CheckPartEquipInfo(actor, part, goalLv, "strengthlv")
- --end
- --
- --function EquipAndAppear.CheckPartEquipAppendLv(actor, part, goalLv)
- --
- --end
- --
- --function EquipAndAppear.CheckPartEquipInfo(actor, part, goalLv, param)
- -- jprint("--------------1", part, goalLv, param)
- -- local allData = EquipAndAppear.getLuaItemExtData(actor)
- -- if table.isNullOrEmpty(allData) then
- -- return false
- -- end
- -- for itemId, equipData in pairs(allData) do
- -- gameDebug.print("---- equip ----", itemId, equipData)
- -- local strengthLv = equipData[param]
- -- if part == nil and strengthLv >= goalLv then
- -- return true
- -- end
- -- if part ~= nil then
- -- local equip = getequipinfo(actor, itemId,1)
- -- if not table.isNullOrEmpty(equip) then
- -- local cfgId = equip.cfgid
- -- local strPart = ConfigDataManager.getTableValue("cfg_item", "strpart", "id", cfgId)
- -- if tonumber(strPart) == part and strengthLv >= goalLv then
- -- return true
- -- end
- -- end
- -- end
- -- end
- -- return false
- --end
- -- 新道具入包
- function EquipAndAppear.ItemAdd(actor, itemId, itemCfgId)
- -- 必须是装备
- local type = ConfigDataManager.getTableValue("cfg_item", "type", "id", itemCfgId)
- if tonumber(type) ~= ItemType.EQUIP then
- return
- end
- local itemExtData = getitemextdata(actor, itemId)
- if itemExtData == nil then
- return
- end
- local allequip = getplaydef(actor, "T$luaitemextdata")
- allequip[itemId] = itemExtData
- setplaydef(actor, "T$luaitemextdata", allequip)
- end
|