| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929 |
- local Lang = require("common.Lang")
- local BattleExcel = require("excel.battle")
- local MonsterExcel = require("excel.monster")
- local DropExcel = require("excel.drop")
- local Msg = require("core.Msg")
- local ObjHuman = require("core.ObjHuman")
- local Grid = require("bag.Grid")
- local BagLogic = require("bag.BagLogic")
- local ItemDefine = require("bag.ItemDefine")
- local Broadcast = require("broadcast.Broadcast")
- local CombatDefine = require("combat.CombatDefine")
- local CombatPosLogic = require("combat.CombatPosLogic")
- local CombatLogic = require("combat.CombatLogic")
- local DailyTaskLogic = require("dailyTask.DailyTaskLogic")
- local RoleDefine = require("role.RoleDefine")
- local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
- local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
- local HeroExcel = require("excel.hero")
- local SkillExcel = require("excel.skill")
- local MonthactExcel = require("excel.monthAct")
- local Util = require("common.Util")
- local KingWorldLogic = require("present.KingWorldLogic")
- local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
- local BRoleLogic = require("billboard.BRoleLogic")
- local BillboardDefine = require("billboard.BillboardDefine")
- local SkinLogic = require("skin.SkinLogic")
- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
- local GuideLogic = require("guide.GuideLogic")
- local PanelDefine = require("broadcast.PanelDefine")
- local HeroGrid = require("hero.HeroGrid")
- local TuiSongLiBao = require("present.TuiSongLiBao")
- local CombatVideo = require("combat.CombatVideo")
- local RoleLogic = require("role.RoleLogic")
- local BattleDBLogic = require("battle.BattleDBLogic")
- local ProjectLogic = require("platform.ProjectLogic")
- local LuaMongo = _G.lua_mongo
- local DB = require("common.DB")
- local VipLogic = require("vip.VipLogic")
- local MoshouLogic = require("moshou.MoshouLogic")
- local RoleExcel = require("excel.role")
- local TequanShopLogic = require("present.TequanShopLogic")
- local HeroDefine = require("hero.HeroDefine")
- local BarTaskLogic = require("bar.BarTaskLogic")
- local ItemExcel = require("excel.item").item
- local EquipExcel = require("excel.equip").equip
- local HeroLogic = require("hero.HeroLogic")
- local SuipianLogic = require("bag.SuipianLogic")
- local JibanLogic = require("combat.JibanLogic")
- local YunYingLogic = require("yunying.YunYingLogic")
- local PanelDefine = require("broadcast.PanelDefine")
- local YyHandler = require("yunying.Handler")
- local EquipLogic = require("equip.EquipLogic")
- local SysParameter = require("common.SysParameter")
- local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
- local AbsActLogic = require("absAct.AbsActLogic")
- local HeroLogLogic = require("absAct.HeroLogLogic")
- local DropExchangeLogic = require("absAct.DropExchangeLogic")
- local MengxinLogic = require("present.MengxinLogic")
- local Log = require("common.Log")
- BATTLE_HANG_EXP_OUT_PERIOD = 60 -- 经验产出时间间隔
- BATTLE_HANG_ITEM_OUT_PERIOD = 300 -- 战利品道具产出时间间隔
- BATTLE_HANG_ITEM_OUT_PERIOD_2 = 7200 -- 战利品道具产出时间间隔2小时掉落一次
- BATTLE_LOGIN_LEV_TIPS = 50 -- 登录检测挂机时间过久提示 最高等级
- BATTLE_LOGIN_TIME_TIPS = 10 * 60 -- 登录检测挂机超过多久提示
- BATTLE_MOPUP_CNT = 4
- BATTLE_MOPUP_CNT_VIP = 11
- BATTLE_MOPUP_FREE_CNT = 1
- BATTLE_MOPUP_FREE_CNT_VIP = 3
- BATTLE_LEVEL_PLAYER_LIST = { }
- local STATUS_NONE = 1 -- 不可领
- local STATUS_CANGET = 2 -- 可领
- -- 挂机收益最多累计x秒
- function getHangMaxTime(human)
- local hour = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER10)
- return(hour or 0) * 3600
- end
- local function wrapHangFightNet(net, heroConfig, skillConfig)
- net.body = heroConfig.body
- net.height = heroConfig.height
- net.weight = heroConfig.width
- net.fireType = skillConfig and skillConfig.fireType or 0
- net.attackEffect = skillConfig and skillConfig.attackEffect or ""
- net.flyEffect = skillConfig and skillConfig.flyEffect or ""
- net.flyCoords = skillConfig and skillConfig.flyCoords or ""
- net.hitEffect = skillConfig and skillConfig.hitEffect or ""
- net.hitSound = skillConfig and skillConfig.hitSound or ""
- end
- local function fontBattleSkillNet(skillNet, skillID)
- local skillConfig = SkillExcel.skill[skillID]
- if not skillConfig then
- return
- end
- skillNet.skillID = skillID
- skillNet.fireType = skillConfig.fireType
- skillNet.readyAction = skillConfig.readyAction
- skillNet.attackPart = skillConfig.attackPart
- skillNet.attackAction = skillConfig.attackAction
- skillNet.readyEffect = skillConfig.readyEffect
- skillNet.attackEffect = skillConfig.attackEffect
- skillNet.hitEffect = skillConfig.hitEffect
- skillNet.flyEffect = skillConfig.flyEffect
- skillNet.flyCoords = skillConfig.flyCoords
- skillNet.hitBack = skillConfig.hitBack
- skillNet.effectTime = skillConfig.effectTime
- skillNet.contentType = skillConfig.contentType
- skillNet.content = skillConfig.content
- skillNet.movieEffect = skillConfig.movieEffect
- skillNet.quake = skillConfig.quake
- skillNet.flySound = skillConfig.flySound
- skillNet.fireSound = skillConfig.fireSound
- skillNet.hitSound = skillConfig.hitSound
- skillNet.cvSound = skillConfig.cvSound
- skillNet.screenMask = skillConfig.screenMask
- skillNet.screenCam = skillConfig.screenCam
- skillNet.largeEffect = skillConfig.largeEffect
- skillNet.lie = skillConfig.lie
- skillNet.cuoZhen = skillConfig.cuoZhen
- skillNet.skillDelay = skillConfig.skillDelay
- skillNet.isFraming = skillConfig.isFraming
- return true
- end
- function getBattleRoleList(worldMapId)
- BATTLE_LEVEL_PLAYER_LIST[worldMapId] = BATTLE_LEVEL_PLAYER_LIST[worldMapId] or { }
- local config = BattleExcel.map[worldMapId]
- QueryRoleByNodeID = { guajiID = { ["$gte"] = config.minLevel, ["$lte"] = config.maxLevel } }
- local fields = { }
- RoleLogic.makeRoleBaseFields(fields)
- LuaMongo.find(DB.db_char, QueryRoleByNodeID, fields, 50)
- local len = 0
- while true do
- local charDb = { }
- if not LuaMongo.next(charDb) then
- break
- end
- len = len + 1
- BATTLE_LEVEL_PLAYER_LIST[worldMapId][charDb._id] = { }
- RoleLogic.makeRoleBase(charDb, BATTLE_LEVEL_PLAYER_LIST[worldMapId][charDb._id])
- if len >= 50 then
- return
- end
- end
- end
- function initAfterStart()
- local len = #BattleExcel.map
- for i = 1, len do
- getBattleRoleList(i)
- end
- end
- function onLogin(human)
- if human.db.lv >= BATTLE_LOGIN_LEV_TIPS then
- return
- end
- calcBattleOut(human)
- local now = os.time()
- local expTime = now - human.db.battleOut.expTs1
- if expTime >= BATTLE_LOGIN_TIME_TIPS then
- local msgRet = Msg.gc.GC_BATTLE_HANG_TIME_SPILL
- msgRet.time = expTime
- Msg.send(msgRet, human.fd)
- end
- end
- -- 是否领取
- local WeiLen = 30
- function isGetReward(human, id)
- if not human.db.battleRewards then
- return
- end
- local flags = human.db.battleRewards
- local intIndex = math.ceil(id / WeiLen)
- if not flags[intIndex] then
- return
- end
- local byteIndex = id % WeiLen
- if Util.getBit(flags[intIndex], byteIndex) > 0 then
- return true
- end
- end
- function getTongguanIndex(human)
- if not human.db.battleRewards then
- return 1
- end
- local flags = human.db.battleRewards
- for id, v in ipairs(BattleExcel.node) do
- if #v.tongguan ~= 0 then
- local intIndex = math.ceil(id / WeiLen)
- if not flags[intIndex] then
- return id
- end
- local byteIndex = id % WeiLen
- if Util.getBit(flags[intIndex], byteIndex) == 0 then
- return id
- end
- end
- end
- return
- end
- -- 设置领取
- function setGetReward(human, id)
- if not human.db.battleRewards then
- human.db.battleRewards = { }
- end
- local flags = human.db.battleRewards
- local intIndex = math.ceil(id / WeiLen)
- local byteIndex = id % WeiLen
- flags[intIndex] = flags[intIndex] or 0
- flags[intIndex] = Util.setBit(flags[intIndex], byteIndex)
- end
- -- 是否有可领取的
- function hasCanGetReward(human)
- for id, cf in ipairs(BattleExcel.node) do
- if id > human.db.guajiID then
- break
- end
- if #cf.tongguan > 0 and not isGetReward(human, id) then
- return true
- end
- end
- end
- local BATTLEID_2_NAME = nil
- function getBattleName(battleID)
- if not BATTLEID_2_NAME then
- BATTLEID_2_NAME = { }
- for id, cf in ipairs(BattleExcel.node) do
- BATTLEID_2_NAME[id] = cf.name
- end
- end
- local nodeConfig = BattleExcel.node[battleID]
- local mapConfig = nodeConfig and BattleExcel.map[nodeConfig.mapID]
- local mapName = mapConfig and mapConfig.name or ""
- return BATTLEID_2_NAME[battleID] or "", mapName
- end
- function hangFightQuery(human)
- local battleID = human.db.battleID > #BattleExcel.node and #BattleExcel.node or human.db.battleID
- local nowNodeConfig = BattleExcel.node[battleID]
- local monsterOutID = nowNodeConfig.monsterOutID
- local monsterOutConfig = MonsterExcel.monsterOut[monsterOutID]
- local msgRet = Msg.gc.GC_BATTLE_HANG_FIGHT
- local len = 0
- for _, monster in ipairs(monsterOutConfig.member) do
- local monsterID = monster[1]
- len = len + 1
- local monsterConfig = MonsterExcel.monster[monsterID]
- local skillConfig = SkillExcel.skill[monsterConfig.normalAtkID]
- wrapHangFightNet(msgRet.monsterList[len], monsterConfig, skillConfig)
- end
- msgRet.monsterList[0] = len
- len = 0
- if human.db.combatHero[CombatDefine.COMBAT_TYPE1] then
- local tb = { }
- for i = 1, #human.db.combatHero[CombatDefine.COMBAT_TYPE1] do
- tb[#tb + 1] = human.db.combatHero[CombatDefine.COMBAT_TYPE1][i]
- end
- local tb2 = { }
- for i = 1, 3 do
- local r = math.ceil(math.random(0, #tb))
- r = r == 0 and 1 or r
- tb2[#tb2 + 1] = tb[r]
- tb[r] = tb[#tb]
- tb[#tb] = nil
- if not tb[1] then
- break
- end
- end
- for i = 1, #tb2 do
- len = len + 1
- local heroGrid = HeroLogic.getHeroGridByUuid(human, tb2[i])
- if heroGrid then
- local heroConfig = HeroExcel.hero[heroGrid.id]
- local _, skinSkillConf = SkinLogic.getHeroSkin(human, tb2[i])
- local skillConfig = SkillExcel.skill[heroConfig.normalAtkID]
- if skinSkillConf then
- skillConfig = SkillExcel.skill[skinSkillConf.normalAtkID]
- end
- wrapHangFightNet(msgRet.attackerList[i], heroConfig, skillConfig)
- local body, head = SkinLogic.getBody(human, tb2[i])
- if body then
- msgRet.attackerList[i].body = body
- end
- end
- end
- end
- msgRet.attackerList[0] = len
- -- Msg.trace(msgRet)
- Msg.send(msgRet, human.fd)
- end
- local function getExtraRewardID(human)
- local config = BattleExcel.extraReward
- local battleExtraReward = human.db.battleExtraReward
- for id, data in ipairs(config) do
- if not battleExtraReward or not battleExtraReward[id] then
- return id, data
- end
- end
- end
- local function getExtraRewardState(human, extraRewardID)
- local config = BattleExcel.extraReward[extraRewardID]
- if not config then
- return 0
- end
- if human.db.battleExtraReward and human.db.battleExtraReward[extraRewardID] then
- return 0
- end
- local guajiID = human.db.guajiID
- if guajiID >= config.needBattleID then
- return 1
- end
- return 0
- end
- local function makeExtraRewardShow(human, net)
- local config = BattleExcel.extraReward
- local extraID, data = getExtraRewardID(human)
- if not extraID then
- return
- end
- net[0] = 1
- net[1].needBattleID = data.needBattleID
- net[1].descID = data.descID
- net[1].desc = data.desc or ""
- net[1].extraHero[0] = 0
- net[1].extraItem[0] = 0
- if data.extraHeroID > 0 then
- net[1].extraHero[0] = 1
- HeroGrid.makeHeroSimpleByID(net[1].extraHero[1], data.extraHeroID, nil, nil, human)
- HeroGrid.makeHeroSimpleByGeneral(net[1].extraHero[1], data.extraHeroID)
- else
- net[1].extraItem[0] = 1
- Grid.makeItem(net[1].extraItem[1], data.extraReward[1], data.extraReward[2])
- end
- net[1].state = getExtraRewardState(human, extraID)
- end
- -- 随机道具
- local function randItemOut(dropRule, weightSum)
- if weightSum < 1 then
- return
- end
- local r = math.random(1, weightSum)
- for i = 1, #dropRule do
- local itemID = dropRule[i][1]
- local itemCnt1 = dropRule[i][2]
- local itemCnt2 = dropRule[i][3]
- local weight = dropRule[i][4]
- if r <= weight then
- local itemCnt = math.random(itemCnt1, itemCnt2)
- return itemID, itemCnt
- end
- r = r - weight
- end
- end
- function fontExtraDataSSZH(net, mapID, nowBattleID)
- local nodeCnt = 0
- if ProjectLogic.isSszh() then
- for i = 1, #BattleExcel.node do
- local nodeTempConfig = BattleExcel.node[i]
- if nodeTempConfig.mapID == mapID then
- nodeCnt = nodeCnt + 1
- local posNet = net.posList[nodeCnt]
- local pos = nodeTempConfig.pos
- posNet.battleID = i
- posNet.posX = pos and pos[1] or 0
- posNet.posY = pos and pos[2] or 0
- posNet.nodeName = getBattleName(i)
- posNet.roleBase[0] = 0
- if i == nowBattleID then
- local videoTb = BattleDBLogic.queryBattleDbByNodeID(i)
- local sharkData = videoTb and videoTb.shark[2]
- if sharkData then
- posNet.roleBase[0] = 1
- RoleLogic.makeRoleBase(videoTb.roleBase, posNet.roleBase[1])
- end
- end
- posNet.isBig = nodeTempConfig.isBig or 0
- end
- end
- end
- net.posList[0] = nodeCnt
- end
- function fontVideoInfo(human, net, monsterConfig)
- local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
- local len = #combatHero
- -- 自己没队伍时,不显示
- if len == 0 then
- net.ownBody[0] = 0
- net.enemyBody[0] = 0
- else
- -- 设置真实数据
- local cnt = 0
- for k, v in pairs(combatHero) do
- -- body数据
- if v ~= "0" then
- local heroGird, bagIndex = HeroLogic.getHeroGridByUuid(human, v)
- if heroGird ~= nil then
- cnt = cnt + 1
- local config = HeroExcel.hero[heroGird.id]
- if config then
- local attrConfig = HeroDefine.getAttrConfig(heroGird.id, config.star)
- local normalAtkID = attrConfig.normalAtkID
- local skill = attrConfig.battleSkill
- local body, head = SkinLogic.getBody(human, bagIndex)
- net.ownBody[cnt].body = body or config.body
- fontBattleSkillNet(net.ownBody[cnt].atkId, normalAtkID)
- fontBattleSkillNet(net.ownBody[cnt].skill, skill)
- net.ownBody[cnt].pos = k
- net.ownBody[cnt].atkType = SkillExcel.skill[normalAtkID].areaPara
- local attrs = ObjHuman.getHeroAttrs(human, heroGird.bagIndex)
- net.ownBody[cnt].hp = attrs[RoleDefine.HP]
- end
- end
- end
- end
- net.ownBody[0] = cnt
- cnt = 0
- local memberConfig = monsterConfig.member
- for k, v in pairs(memberConfig) do
- -- body数据
- cnt = cnt + 1
- local config = MonsterExcel.monster[v[1]]
- if config then
- local normalAtkID = config.normalAtkID
- net.enemyBody[cnt].body = config.body
- fontBattleSkillNet(net.enemyBody[cnt].atkId, normalAtkID)
- fontBattleSkillNet(net.enemyBody[cnt].skill, normalAtkID)
- net.enemyBody[cnt].pos = k
- net.enemyBody[cnt].atkType = SkillExcel.skill[normalAtkID].areaPara
- local attrID = monsterConfig.attrID[k]
- local attrConfig = MonsterExcel.monsterAttr[attrID].attrs
- for _, value in pairs(attrConfig) do
- if value[1] == RoleDefine.HP then
- net.enemyBody[cnt].hp = value[2]
- break
- end
- end
- end
- end
- net.enemyBody[0] = cnt
- end
- end
- -- 战役主界面查询
- function query(human)
- local msgRet = Msg.gc.GC_BATTLE_QUERY
- msgRet.nowBattleID = human.db.battleID
- local configNode = #BattleExcel.node
- local nowBattleID = human.db.battleID > configNode and configNode or human.db.battleID
- local nowNodeConfig = BattleExcel.node[nowBattleID]
- msgRet.maxBattleID = configNode
- msgRet.mapID = nowNodeConfig.mapID
- msgRet.nodeID = nowNodeConfig.curLevel
- msgRet.sceneID = nowNodeConfig.sceneID
- local nowMapConfig = BattleExcel.map[nowNodeConfig.mapID]
- msgRet.mapName = nowMapConfig.name
- msgRet.nodeName = nowNodeConfig.name
- msgRet.needLv = nowNodeConfig.needLv
- msgRet.bg = nowMapConfig.bg
- msgRet.canBattle = 0
- msgRet.doubleCnt = 0
- if nowNodeConfig.needLv > human.db.lv then
- msgRet.canBattle = nowNodeConfig.needLv
- end
- local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1104)
- if
- double and human.db.bar and human.db.bar.doubleCnt and
- human.db.bar.doubleCnt <= BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
- then
- msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT - human.db.bar.doubleCnt
- elseif double and not human.db.bar then
- msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
- end
- msgRet.tongguan[0] = 0
- local id = getTongguanIndex(human)
- if id == nil then
- msgRet.tongguan[0] = 0
- else
- msgRet.tongguan[0] = 1
- local state = isGetReward(human, id)
- local cf = BattleExcel.node[id].tongguan
- local net = msgRet.tongguan[1]
- if state == true then
- net.status = STATUS_NONE
- else
- net.status =(id > human.db.guajiID) and STATUS_CANGET or STATUS_NONE
- end
- net.levelName = getBattleName(id)
- net.index = id
- net.nowBattle = getBattleName(human.db.guajiID)
- net.reward[0] = 0
- net.heroReward[0] = 0
- -- 是英雄
- if cf[1][3] then
- net.heroReward[0] = 1
- local other = { }
- other.star = cf[1][3]
- HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
- HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
- else
- net.reward[0] = 1
- for i = 1, net.reward[0] do
- local itemID = cf[i][1]
- local itemCnt = cf[i][2]
- Grid.makeItem(net.reward[i], itemID, itemCnt)
- end
- end
- end
- local outSec = 0
- if human.db.battleOut ~= nil then
- local now = os.time()
- outSec = now - human.db.battleOut.expTs1
- end
- local maxHangTime = getHangMaxTime(human)
- msgRet.maxTime = maxHangTime
- if maxHangTime >= outSec then
- msgRet.time = outSec
- else
- msgRet.time = maxHangTime
- end
- -- 悬赏情报数量
- msgRet.xushang = human.db.bar and human.db.bar.qingbao or 0
- msgRet.xushangMax = RoleExcel.exp[human.db.lv].qingBaoMax
- -- 悬赏红点
- msgRet.xsDot = 0
- if BarTaskLogic.isDot(human) then
- msgRet.xsDot = 1
- end
- msgRet.canMopup = 0
- if TequanShopLogic.isActiveMopup(human) then
- msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT_VIP and 1 or 0
- else
- msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT and 1 or 0
- end
- local monsterOutId = nowNodeConfig.monsterOutID
- local monsterConfig = MonsterExcel.monsterOut[monsterOutId]
- fontVideoInfo(human, msgRet.videoInfo, monsterConfig)
- fontExtraDataSSZH(msgRet.extraDataSSZH, nowNodeConfig.mapID, nowBattleID)
- -- Msg.trace(msgRet)
- Msg.send(msgRet, human.fd)
- hangFightQuery(human)
- end
- -- 获取当前地图ID
- function getMapID(human, args)
- local battleID = human.db.battleID
- local config = BattleExcel.node[battleID]
- if not config then
- return
- end
- local mapConfig = BattleExcel.map[config.mapID]
- if not config then
- return
- end
- local mapID = config.sceneID
- return mapID
- end
- -- 战役挂机界面查询
- function onHookQuery(human)
- local msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
- calcBattleOut(human)
- local expAdd = human.db.battleOut.exp
- local jinbiAdd = human.db.battleOut.jinbi
- local greenExpAdd = human.db.battleOut.greenExp
- local qingbaoAdd = human.db.battleOut.qingbao
- local skip = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
- if not skip then
- expAdd = 1510
- end
- local items = { }
- local len = #items
- local tempTable = { }
- if human.db.battleOut.items then
- tempTable = Util.copyTable(human.db.battleOut.items)
- end
- tempTable[ItemDefine.ITEM_EXP_ID] = tempTable[ItemDefine.ITEM_EXP_ID] or 0
- tempTable[ItemDefine.ITEM_EXP_ID] = expAdd
- tempTable[ItemDefine.ITEM_JINBI_ID] = tempTable[ItemDefine.ITEM_JINBI_ID] or 0
- tempTable[ItemDefine.ITEM_JINBI_ID] = jinbiAdd
- tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = tempTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
- tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = greenExpAdd
- tempTable[ItemDefine.ITEM_QINGBAO_ID] = tempTable[ItemDefine.ITEM_QINGBAO_ID] or 0
- tempTable[ItemDefine.ITEM_QINGBAO_ID] = qingbaoAdd
- local list = DropExchangeLogic.getAbsCanDrop(human)
- if list then
- for k, v in pairs(list) do
- if tempTable[k] and tempTable[k] > 0 then
- len = len + 1
- items[len] = { }
- items[len].id = k
- items[len].cnt = tempTable[k]
- end
- end
- end
- for k, v in pairs(tempTable) do
- if not list or not list[k] then
- len = len + 1
- items[len] = { }
- items[len].id = k
- items[len].cnt = v
- end
- end
- -- 发消息
- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
- if guajiID == 0 then
- return Broadcast.sendErr(human, Lang.BATTLE_GUAJI_ERR)
- end
- local nodeConfig = BattleExcel.node[guajiID]
- local now = os.time()
- local outSec = now - human.db.battleOut.expTs1
- local maxHangTime = getHangMaxTime(human)
- msgRet.maxTime = maxHangTime
- if maxHangTime >= outSec then
- msgRet.time = outSec
- else
- msgRet.time = maxHangTime
- end
- for i = 1, #items do
- Grid.makeItem(msgRet.items[i], items[i].id, items[i].cnt)
- end
- local len = #items
- if human.db.battleOut.equip then
- for k, equipGrid in ipairs(human.db.battleOut.equip) do
- len = len + 1
- Grid.makeItem(msgRet.items[len], equipGrid.id, 1, nil, equipGrid)
- end
- end
- msgRet.items[0] = len
- msgRet.exp = nodeConfig.hangExp
- msgRet.jinbi = nodeConfig.hangJinbi
- msgRet.greenExp = nodeConfig.hangGreenExp
- msgRet.qingbao = nodeConfig.hangQingbao or 0
- Msg.send(msgRet, human.fd)
- end
- local function isChapterDot(human, mapID)
- local chapterReward = human.db.chapterReward or { }
- if chapterReward[mapID] then
- return false
- end
- local battleID = human.db.battleID
- local battleNodeConfig = BattleExcel.node[battleID]
- if not battleNodeConfig then
- if battleID == #BattleExcel.node + 1 then
- return true
- else
- return false
- end
- else
- local roleMapId = battleNodeConfig.mapID
- if roleMapId <= mapID then
- return false
- end
- end
- return true
- end
- function battleWorldMapQuery(human)
- local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_QUERY
- local worldMapConfig = BattleExcel.map
- local battleID = human.db.battleID > #BattleExcel.node and #BattleExcel.node or human.db.battleID
- local battleNodeConfig = BattleExcel.node[battleID]
- local len = #worldMapConfig
- for i = 1, len do
- local v = worldMapConfig[i]
- msgRet.worldMap[i].mapID = i
- msgRet.worldMap[i].mapName = v.name or ""
- msgRet.worldMap[i].mapBuild = v.build or 0
- msgRet.worldMap[i].mapBg = v.bg or 0
- msgRet.worldMap[i].mapPos[0] = 2
- msgRet.worldMap[i].mapPos[1] = v.pos[1]
- msgRet.worldMap[i].mapPos[2] = v.pos[2]
- msgRet.worldMap[i].status =(battleNodeConfig.mapID >= i) and 1 or 0
- msgRet.worldMap[i].story = v.des or ""
- if battleNodeConfig.mapID == i then
- msgRet.worldMap[i].maxLevel = battleNodeConfig.maxLevel
- msgRet.worldMap[i].curLevel = battleNodeConfig.curLevel
- else
- msgRet.worldMap[i].maxLevel = 0
- msgRet.worldMap[i].curLevel = 0
- end
- local reward = v.reward
- local l = 0
- msgRet.worldMap[i].chapterReward[0] = #reward
- for _, rewardData in pairs(reward) do
- l = l + 1
- Grid.makeItem(msgRet.worldMap[i].chapterReward[l], rewardData[1], rewardData[2])
- end
- msgRet.worldMap[i].chapterDot = 0
- if isChapterDot(human, i) then
- msgRet.worldMap[i].chapterDot = 1
- end
- local cnt = 0
- BATTLE_LEVEL_PLAYER_LIST[i] = BATTLE_LEVEL_PLAYER_LIST[i] or { }
- for s, t in pairs(BATTLE_LEVEL_PLAYER_LIST[i]) do
- cnt = cnt + 1
- RoleLogic.makeRoleBase(t, msgRet.worldMap[i].roleList[cnt])
- if cnt >= 3 then
- break
- end
- end
- msgRet.worldMap[i].roleList[0] = cnt
- end
- msgRet.worldMap[0] = len
- Msg.send(msgRet, human.fd)
- end
- function battleNodeQuery(human, mapID)
- local msgRet = Msg.gc.GC_BATTLE_NODE_QUERY
- local nodeConfig = BattleExcel.node
- local lenConfig = #nodeConfig
- local len = 0
- msgRet.battleID = human.db.battleID or 0
- for i = 1, lenConfig do
- local v = nodeConfig[i]
- if v.mapID == mapID then
- len = len + 1
- msgRet.nodeInfo[len].nodeName = v.name
- msgRet.nodeInfo[len].battleID = i
- msgRet.nodeInfo[len].needLv = v.needLv
- msgRet.nodeInfo[len].needZDL = v.needZDL
- msgRet.nodeInfo[len].hasSuipian = v.hasSuipian
- end
- end
- msgRet.nodeInfo[0] = len
- Msg.send(msgRet, human.fd)
- end
- function initBattleOut(human, now)
- if human.db.battleOut then
- return
- end
- human.db.battleOut = { }
- human.db.battleOut.expTs1 = now
- -- 经验开始产出时间戳
- human.db.battleOut.expTs2 = now
- -- 经验产出结算时间戳
- human.db.battleOut.itemTs1 = now
- -- 道具产出时间戳
- human.db.battleOut.itemTs2 = now
- -- 道具产出结算时间戳
- human.db.battleOut.exp = 0
- human.db.battleOut.jinbi = 0
- human.db.battleOut.greenExp = 0
- human.db.battleOut.qingbao = 0
- human.db.battleOut.items = nil
- -- 产出的待收获的战利品
- human.db.battleOut.equip = nil
- -- 产出的待收获的装备
- end
- function calcBattleOut(human)
- local now = os.time()
- initBattleOut(human, now)
- calcBattleExpOut(human, now)
- calcBattleItemOut(human, now)
- end
- -- 获取正确的剩余可收益的结算时间
- function getSurMaxHangTime(maxHangTime, ts1, now)
- if ts1 + maxHangTime > now then
- return now
- else
- return ts1 + maxHangTime
- end
- end
- function calcBattleExpOut(human, now)
- local maxHangTime = getHangMaxTime(human)
- if human.db.battleOut.expTs2 - human.db.battleOut.expTs1 >= maxHangTime then
- return
- end
- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.expTs1, now)
- local outSec = outTime - human.db.battleOut.expTs2
- local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
- if outCnt < 1 then
- return
- end
- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
- if guajiID == 0 then
- return
- end
- local nowNodeConfig = BattleExcel.node[guajiID]
- human.db.battleOut.expTs2 = human.db.battleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
- if now - human.db.battleOut.expTs1 >= maxHangTime then
- human.db.battleOut.expTs2 = now
- end
- local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
- local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
- local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
- local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
- local exp = nowNodeConfig.hangExp
- local jinbi = nowNodeConfig.hangJinbi
- local greenExp = nowNodeConfig.hangGreenExp
- local qingbao = nowNodeConfig.hangQingbao
- human.db.battleOut.exp = human.db.battleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
- human.db.battleOut.jinbi = human.db.battleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
- human.db.battleOut.greenExp = human.db.battleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
- human.db.battleOut.qingbao = human.db.battleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
- end
- -- 根据时间计算道具产出
- local ITEM_OUT_LIST = { }
- function getItemOutsByTime(config, sec)
- Util.cleanTable(ITEM_OUT_LIST)
- local outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD)
- if outCnt < 1 then
- return ITEM_OUT_LIST
- end
- -- 普通掉落
- local dropID = config.dropID
- local dropConfig = DropExcel.dropBattle[dropID]
- local weightSum = 0
- for i = 1, #dropConfig.dropRule do
- local tempConfig = dropConfig.dropRule[i]
- weightSum = weightSum + tempConfig[4]
- end
- for i = 1, outCnt do
- local itemID, itemCnt = randItemOut(dropConfig.dropRule, weightSum)
- if itemCnt and itemCnt > 0 then
- ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
- end
- end
- for i = 1, #dropConfig.dropRule2 do
- local tempConfig = dropConfig.dropRule2[i]
- local itemID = tempConfig[1]
- local itemMin = tempConfig[2]
- local itemMax = tempConfig[3]
- local itemCnt = math.random(itemMin, itemMax) * outCnt
- if itemCnt > 0 then
- ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
- end
- end
- -- 三小时掉落
- outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD_2)
- if outCnt < 1 then
- return ITEM_OUT_LIST
- end
- weightSum = 0
- for i = 1, #dropConfig.dropRule3 do
- local tempConfig = dropConfig.dropRule3[i]
- weightSum = weightSum + tempConfig[4]
- end
- for i = 1, outCnt do
- local itemID, itemCnt = randItemOut(dropConfig.dropRule3, weightSum)
- if itemCnt and itemCnt > 0 then
- ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
- end
- end
- return ITEM_OUT_LIST
- end
- function calcBattleItemOut(human, now)
- local maxHangTime = getHangMaxTime(human)
- if human.db.battleOut.itemTs2 - human.db.battleOut.itemTs1 >= maxHangTime then
- return
- end
- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.itemTs1, now)
- local outSec = outTime - human.db.battleOut.itemTs2
- local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
- if outCnt < 1 then
- return
- end
- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
- if guajiID == 0 then
- return
- end
- local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
- human.db.battleOut.itemTs2 = human.db.battleOut.itemTs2 + sec
- if now - human.db.battleOut.itemTs1 >= maxHangTime then
- human.db.battleOut.itemTs2 = now
- end
- local nodeConfig = BattleExcel.node[guajiID]
- local items = getItemOutsByTime(nodeConfig, sec)
- for itemID, itemCnt in pairs(items) do
- -- 判定是否是装备
- if ItemDefine.isEquip(itemID) then
- -- 生成装备
- local equipGrid = EquipLogic.makeEquip(itemID)
- if equipGrid then
- human.db.battleOut.equip = human.db.battleOut.equip or { }
- human.db.battleOut.equip[#human.db.battleOut.equip + 1] = equipGrid
- end
- else
- human.db.battleOut.items = human.db.battleOut.items or { }
- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] or 0
- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] + itemCnt
- end
- end
- DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, human.db.battleOut)
- end
- -- 获取挂机收益
- function hangGet(human)
- local ret, items = hangExpGet(human)
- if ret == 1 then
- return Broadcast.sendErr(human, Lang.BATTLE_HANG_GET_EXP_ERR_NONE)
- elseif ret == 2 then
- return Broadcast.sendErr(human, Lang.COMMON_ADD_JINBI_LIMIT)
- elseif ret == 0 then
- query(human)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
- end
- end
- function hangExpGet(human)
- calcBattleOut(human)
- if human.db.battleOut.exp == 0 then
- return 1
- end
- local jinbiAdd = human.db.battleOut.jinbi
- if not ObjHuman.canAddJinbi(human, jinbiAdd) then
- return 2
- end
- -- 检测装备数量
- if human.db.battleOut.equip then
- local equipCnt = #human.db.battleOut.equip
- if not EquipLogic.checkEmptyCnt(human, equipCnt) then
- return
- end
- end
- local items = { }
- local len = #items
- local maxHangTime = getHangMaxTime(human)
- if human.db.battleOut.expTs2 - human.db.battleOut.expTs1 >= maxHangTime then
- local now = os.time()
- human.db.battleOut.expTs2 = now
- end
- if human.db.battleOut.itemTs2 - human.db.battleOut.itemTs1 >= maxHangTime then
- local now = os.time()
- human.db.battleOut.itemTs2 = now
- end
- human.db.battleOut.itemTs1 = human.db.battleOut.itemTs2
- -- 改db
- local tempTable = human.db.battleOut.items or { }
- human.db.battleOut.items = nil
- for k, v in pairs(tempTable) do
- len = len + 1
- items[len] = { }
- items[len].id = k
- items[len].cnt = v
- end
- human.db.battleOut.expTs1 = human.db.battleOut.expTs2
- local expAdd = human.db.battleOut.exp
- local greenExpAdd = human.db.battleOut.greenExp
- local qingbaoAdd = human.db.battleOut.qingbao
- -- 新手指引 强制经验
- local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
- if not flag then
- expAdd = 1510
- end
- GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
- GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_GUAJI)
- human.db.battleOut.exp = 0
- human.db.battleOut.jinbi = 0
- human.db.battleOut.greenExp = 0
- human.db.battleOut.qingbao = 0
- len = len + 1
- items[len] = { }
- items[len].id = ItemDefine.ITEM_EXP_ID
- items[len].cnt = expAdd
- len = len + 1
- items[len] = { }
- items[len].id = ItemDefine.ITEM_JINBI_ID
- items[len].cnt = jinbiAdd
- len = len + 1
- items[len] = { }
- items[len].id = ItemDefine.ITEM_GREEN_EXP_ID
- items[len].cnt = greenExpAdd
- len = len + 1
- items[len] = { }
- items[len].id = ItemDefine.ITEM_QINGBAO_ID
- items[len].cnt = qingbaoAdd
- -- 给道具
- for i = 1, #items do
- local tempID = items[i].id
- local tempCnt = items[i].cnt
- BagLogic.addItem(human, tempID, tempCnt, "battle")
- end
- -- 给装备
- if human.db.battleOut.equip then
- for k, equipGrid in ipairs(human.db.battleOut.equip) do
- EquipLogic.addByEquipGrid(human, equipGrid, "battle", true)
- end
- human.db.battleOut.equip = nil
- end
- return 0, items
- end
- -- 挂机节点设置
- function nodeSet(human, battleID)
- local nodeConfig = BattleExcel.node[battleID]
- if nodeConfig == nil then
- return
- end
- -- 前置条件判断
- if battleID > human.db.battleID then
- return Broadcast.sendErr(human, Lang.BATTLE_ID_OVER)
- end
- -- 等级判断
- if human.db.lv < nodeConfig.needLv then
- return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, nodeConfig.needLv))
- end
- calcBattleOut(human)
- human.db.guajiID = battleID
- setBattleID(human, battleID)
- Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
- query(human)
- end
- -- 挂机节点详细信息查询
- function nodeDetailQuery(human, battleID)
- local nodeConfig = BattleExcel.node[battleID]
- if nodeConfig == nil then
- return
- end
- local msgRet = Msg.gc.GC_BATTLE_NODE_DETAIL_QUERY
- msgRet.battleID = battleID
- msgRet.exp = nodeConfig.hangExp
- msgRet.jinbi = nodeConfig.hangJinbi
- msgRet.greenExp = nodeConfig.hangGreenExp
- msgRet.qingbao = nodeConfig.hangQingbao or 0
- msgRet.nodeName = getBattleName(battleID)
- local dropID = nodeConfig.dropID
- local dropConfig = DropExcel.dropBattle[dropID]
- local dropCnt = 0
- local list = DropExchangeLogic.getAbsCanDrop(human)
- if list then
- for k, v in pairs(list) do
- dropCnt = dropCnt + 1
- Grid.makeItem(msgRet.items[dropCnt], k, v)
- end
- end
- for i = 1, #dropConfig.dropRule do
- local tempConfig = dropConfig.dropRule[i]
- local itemID = tempConfig[1]
- local itemCnt = tempConfig[3]
- local itemRate = tempConfig[4]
- if itemCnt > 0 and itemRate > 0 then
- dropCnt = dropCnt + 1
- Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
- end
- end
- for i = 1, #dropConfig.dropRule3 do
- local tempConfig = dropConfig.dropRule3[i]
- local itemID = tempConfig[1]
- local itemCnt = tempConfig[3]
- local itemRate = tempConfig[4]
- if itemCnt > 0 and itemRate > 0 then
- dropCnt = dropCnt + 1
- Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
- end
- end
- msgRet.items[0] = dropCnt
- Msg.send(msgRet, human.fd)
- end
- -- 挑战当前挂机节点
- function fight(human)
- local battleID = human.db.battleID
- if BattleExcel.node[human.db.battleID] == nil then
- local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
- msgRet.panelIDs[0] = 1
- msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
- Msg.send(msgRet, human.fd)
- return Broadcast.sendErr(human, Lang.BATTLE_MAX_LEVEL)
- end
- if human.db.lv < BattleExcel.node[human.db.battleID].needLv then
- local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
- msgRet.panelIDs[0] = 1
- msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
- Msg.send(msgRet, human.fd)
- return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, BattleExcel.node[human.db.battleID].needLv))
- end
- local config = BattleExcel.node[battleID]
- local mapConfig = BattleExcel.map[config.mapID]
- local monsterOutID = config.monsterOutID
- local mapID = mapConfig.bg
- CombatLogic.combatBegin(human, config.sceneID, monsterOutID, CombatDefine.COMBAT_TYPE1, battleID)
- GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE)
- end
- function onFightEnd(human, result, fightTypeID, param1, combatInfo)
- -- 设置一些战斗结算信息
- combatInfo.defender.name = Util.format(Lang.COMBAT_BATTLE_DEFEND_NAME, param1)
- if CombatDefine.RESULT_WIN ~= result then
- return
- end
- local guajiID = human.db.guajiID
- local battleID = human.db.battleID
- if battleID ~= param1 then
- return
- end
- local oldGuajiID = guajiID
- local nextGuajiID = guajiID + 1
- local nextBattleID = battleID + 1
- local nextBattleConfig = BattleExcel.node[nextBattleID]
- local config = BattleExcel.node[battleID]
- -- 如果过大关卡
- if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
- -- 清除记录
- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = nil
- -- 增加新纪录
- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] = BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] or { }
- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id] = { }
- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id])
- else
- if config.mapID == 1 then
- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
- if BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] == nil then
- -- 增加新纪录
- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
- end
- else
- if not BATTLE_LEVEL_PLAYER_LIST[config.mapID] or not BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] then
- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
- end
- end
- end
- human.db.battleID = battleID + 1
- -- 通过第10关,默认开启二倍速
- if human.db.battleID == 10 then
- human.db.combatSpeed = 2
- end
- combatInfo.attacker.oldLv = human.db.lv
- -- 给奖励
- combatInfo.rewardItem = { }
- for i = 1, #config.winReward do
- local itemID = config.winReward[i][1]
- local itemCnt = config.winReward[i][2]
- -- 装备不在这显示
- combatInfo.rewardItem[i] = combatInfo.rewardItem[i] or { }
- combatInfo.rewardItem[i] = { itemID, itemCnt }
- BagLogic.addItem(human, itemID, itemCnt, "battle_win")
- end
- combatInfo.attacker.lv = human.db.lv
- combatInfo.getEquip = human.getEquip
- human.getEquip = nil
- -- TODO:记录主线关卡
- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, human.db._id, human.db.account, human.db.name, human.db.battleID)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
- GuideLogic.onCallback(human)
- JibanLogic.onCallback(human, 1, battleID)
- TuiSongLiBao.tuiSongLiBaoOnTask(
- human,
- TuiSongLiBao.TUISONGLIBAOTASK_ZHENGZHAN,
- human.db.guajiID - 1,
- human.db.guajiID - 2
- )
- ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_1, nextGuajiID)
- MengxinLogic.onCallBack(human, MengxinLogic.MX_TASK_TYPE_1, nextGuajiID)
- for k, v in pairs(KingWorldLogic.funcID) do
- YunYingLogic.updateIcon(KingWorldLogic.YYInfo[k], human)
- break
- end
- -- 存储战斗记录
- local videoUuid = CombatVideo.saveBattleVideo(human.db._id, combatInfo)
- human.db.battleVideoUuid = videoUuid
- BattleDBLogic.updateBattleDB(combatInfo.attacker, battleID, combatInfo, videoUuid)
- if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
- -- 新的地图
- -- 通知客户端
- Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
- end
- human.db.guajiID = nextGuajiID
- if nextBattleConfig then
- setBattleID(human, nextGuajiID)
- end
- local showNext = 1
- if BattleExcel.node[human.db.battleID] and human.db.lv < BattleExcel.node[human.db.battleID].needLv then
- showNext = 2
- end
- if human.db.lv < 5 then
- showNext = 0
- end
- nextBattleConfig = BattleExcel.node[human.db.battleID]
- if not nextBattleConfig then
- showNext = 0
- end
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
- -- 额外奖励
- local needLevel, itemName = getNextRewardName(human)
- if needLevel ~= nil then
- local tb = { needLevel, Lang.BATTLE_FIGHT_GUAN, "|", itemName, "|", showNext }
- local str = table.concat(tb)
- combatInfo.endParam = str
- else
- local tb = { showNext }
- local str = table.concat(tb)
- combatInfo.endParam = str
- end
- end
- function setBattleID(human, guajiID)
- if guajiID > human.db.guajiID and human.db.guajiID ~= 0 then
- -- 下发挂机收益升级提示
- local msgRet = Msg.gc.GC_BATTLE_REWARD_UP
- Grid.makeItem(msgRet.itemExp, ItemDefine.ITEM_EXP_ID, 1)
- Grid.makeItem(msgRet.itemJinbi, ItemDefine.ITEM_JINBI_ID, 1)
- Grid.makeItem(msgRet.itemGreenExp, ItemDefine.ITEM_GREEN_EXP_ID, 1)
- Grid.makeItem(msgRet.itemQingbao, ItemDefine.ITEM_QINGBAO_ID, 1)
- local oldConfig = BattleExcel.node[human.db.guajiID]
- local newConfig = BattleExcel.node[guajiID]
- msgRet.expOld = oldConfig.hangExp
- msgRet.expNew = newConfig.hangExp
- msgRet.jinbiOld = oldConfig.hangJinbi
- msgRet.jinbiNew = newConfig.hangJinbi
- msgRet.greenExpOld = oldConfig.hangGreenExp
- msgRet.greenExpNew = newConfig.hangGreenExp
- msgRet.qingbaoOld = oldConfig.hangQingbao
- msgRet.qingbaoNew = newConfig.hangQingbao
- Msg.send(msgRet, human.fd)
- end
- -- 刷新排行榜
- BRoleLogic.updateData(BillboardDefine.TYPE_BATTLE, human.db)
- end
- -- GM
- function setBattleByGm(human, val, maxBattleID)
- val = tonumber(val)
- if not val or val <= 1 then
- return
- end
- local nodeConfig = BattleExcel.node[val]
- if not nodeConfig then
- return
- end
- if maxBattleID then
- maxBattleID = tonumber(maxBattleID)
- else
- maxBattleID = val
- end
- setBattleID(human, val)
- human.db.battleID = val
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
- end
- function mopupQuery(human)
- ObjHuman.updateDaily(human)
- local msgRet = Msg.gc.GC_BATTLE_MOPUP_QUERY
- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
- if guajiID == 0 then
- return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
- end
- human.db.mopupDoCnt = human.db.mopupDoCnt or 0
- local nextDoCnt = human.db.mopupDoCnt + 1
- local nodeConfig = BattleExcel.node[guajiID]
- local dropID = nodeConfig.dropID
- local dropConfig = DropExcel.dropBattle[dropID]
- local dropCnt = 0
- -- ABS掉落活动显示到第一个
- dropCnt = DropExchangeLogic.getDropItemSaoQuery(human, msgRet, dropCnt)
- for i = 1, #dropConfig.dropRule do
- if dropCnt >= #msgRet.item then
- break
- end
- dropCnt = dropCnt + 1
- local tempConfig = dropConfig.dropRule[i]
- local itemID = tempConfig[1]
- Grid.makeItem(msgRet.item[dropCnt], itemID, 1)
- end
- for i = 1, #dropConfig.dropRule3 do
- if dropCnt >= #msgRet.item then
- break
- end
- dropCnt = dropCnt + 1
- local tempConfig = dropConfig.dropRule3[i]
- local itemID = tempConfig[1]
- Grid.makeItem(msgRet.item[dropCnt], itemID, 1)
- end
- local mapConfig = BattleExcel.map[nodeConfig.mapID]
- msgRet.name = mapConfig.name
- msgRet.item[0] = dropCnt
- if TequanShopLogic.isActiveMopup(human) then
- msgRet.leftCnt = BATTLE_MOPUP_CNT_VIP - human.db.mopupDoCnt
- else
- msgRet.leftCnt = BATTLE_MOPUP_CNT - human.db.mopupDoCnt
- end
- local mupopExcel = BattleExcel.mupop[nextDoCnt]
- if mupopExcel then
- if not TequanShopLogic.isActiveMopup(human) then
- msgRet.need = mupopExcel.cost
- if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
- msgRet.need = 0
- end
- else
- msgRet.need = mupopExcel.vipCost
- if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
- msgRet.need = 0
- end
- end
- else
- msgRet.need = 0
- end
- msgRet.vip = TequanShopLogic.isActiveMopup(human) and 1 or 0
- msgRet.nowCnt = human.db.mopupDoCnt
- msgRet.exp = nodeConfig.hangExp
- msgRet.jinbi = nodeConfig.hangJinbi
- msgRet.greenExp = nodeConfig.hangGreenExp
- msgRet.qingbao = nodeConfig.hangQingbao
- Msg.send(msgRet, human.fd)
- end
- function mopupFight(human)
- -- 等级判断
- ObjHuman.updateDaily(human)
- local need = 0
- human.db.mopupDoCnt = human.db.mopupDoCnt or 0
- human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
- local nextDoCnt = human.db.mopupDoCnt + 1
- local mupopExcel = BattleExcel.mupop[nextDoCnt]
- if not mupopExcel then
- return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
- end
- if not TequanShopLogic.isActiveMopup(human) then
- if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT then
- return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
- end
- need = mupopExcel.cost
- -- 如果免费次数小于1次,则按免费算
- if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
- need = 0
- end
- else
- if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT_VIP then
- return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
- end
- need = mupopExcel.vipCost
- -- 如果免费次数小于3次,则按免费算
- if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
- need = 0
- end
- end
- if not ObjHuman.checkRMB(human, need) then
- return
- end
- if need <= 0 then
- human.db.mopupFreeCnt = human.db.mopupFreeCnt + 1
- end
- ObjHuman.decZuanshi(human, - need, "battleMopup")
- local len = #BattleExcel.node
- human.db.mopupDoCnt = human.db.mopupDoCnt + 1
- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
- if guajiID == 0 then
- return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
- end
- local config = BattleExcel.node[guajiID]
- local msgRet = Msg.gc.GC_BATTLE_MOPUP_FIGHT
- local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
- local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
- local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
- local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
- local exp = config.hangExp * 120
- local jinbi = config.hangJinbi * 120
- local greenExp = config.hangGreenExp * 120
- local qingbao = config.hangQingbao * 120
- local addExp = math.floor(exp *(1 + vipExpAdd))
- local addJinbi = math.floor(jinbi *(1 + vipJinAdd))
- local addGreenExp = math.floor(greenExp *(1 + vipGreenExpAdd))
- local addQingbao = math.floor(qingbao *(1 + vipQingbaoAdd))
- local time = 7200
- local itemTable = getItemOutsByTime(config, time)
- -- 掉落活动
- DropExchangeLogic.getDropItemSao(human, time, itemTable)
- local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
- if not flag then
- local equipID = SysParameter.getSysParameter(SysParameter.PARAMETER_10)
- itemTable[equipID] = 1
- end
- itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] or 0
- itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] or 0
- itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
- itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] or 0
- itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] + addJinbi
- itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] + addExp
- itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] + addGreenExp
- itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] + addQingbao
- msgRet.item[0] = 0
- -- 双倍日
- local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1101)
- local rewardCnt = double and 2 or 1
- for itemID, itemCnt in pairs(itemTable) do
- itemCnt = itemCnt * rewardCnt
- if not ItemDefine.isEquip(itemID) then
- msgRet.item[0] = msgRet.item[0] + 1
- Grid.makeItem(msgRet.item[msgRet.item[0]], itemID, itemCnt)
- end
- BagLogic.addItem(human, itemID, itemCnt, "battle")
- end
- msgRet.item[0] = EquipLogic.makeEquipItem(human, msgRet.item, msgRet.item[0])
- msgRet.double = double and 1 or 0
- msgRet.exp = itemTable[ItemDefine.ITEM_EXP_ID] * rewardCnt
- msgRet.jinbi = itemTable[ItemDefine.ITEM_JINBI_ID] * rewardCnt
- msgRet.greenExp = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] * rewardCnt
- msgRet.qingbao = itemTable[ItemDefine.ITEM_QINGBAO_ID] * rewardCnt
- Msg.send(msgRet, human.fd)
- mopupQuery(human)
- query(human)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
- GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
- DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_12, 1)
- ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_3, 1)
- HeroLogLogic.finishTaskCB(human, HeroLogLogic.HERO_LOG_TYPE_3, 1)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2001)
- YunYingLogic.onCallBack(human, "onMopup", 1)
- end
- function updateDaily(human)
- human.db.mopupFreeCnt = 0
- human.db.mopupDoCnt = 0
- end
- function getTongGuanReward(human, id)
- local cf = BattleExcel.node[id]
- if not cf then
- return
- end
- if #cf.tongguan < 1 then
- return
- end
- print("human.db.guajiID,id", human.db.guajiID, id)
- if human.db.guajiID < id then
- return
- end
- if isGetReward(human, id) then
- return
- end
- if #cf.tongguan == 1 and cf.tongguan[1][3] then
- -- 英雄
- if HeroLogic.getEmptyCnt(human) < 1 then
- return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
- end
- local heroID = cf.tongguan[1][1]
- local cnt = cf.tongguan[1][2]
- local star = cf.tongguan[1][3]
- if cnt <= 0 then
- return
- end
- setGetReward(human, id)
- local msg = Msg.gc.GC_SUIPIAN_SUMMON
- for i = 1, cnt do
- local heroGrid = HeroGrid.createHeroGrid(heroID, star)
- HeroLogic.addHeroByGrid(human, heroGrid, "battle_extra_reward")
- SuipianLogic.makeResultItemData(msg.heroList[i], heroID, 1, 1)
- end
- msg.isHero = 1
- msg.list[0] = 0
- msg.heroList[0] = cnt
- msg.fenJieList[0] = 0
- Msg.send(msg, human.fd)
- else
- setGetReward(human, id)
- BagLogic.addItemList(human, cf.tongguan, "tongguan")
- end
- -- 触发国王君临奖励
- ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE5, id)
- query(human)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
- if id == 80 then
- KingWorldLogic.setState(human, 1)
- end
- end
- function isDot(human)
- -- 通过大关卡奖励
- local chapterReward = human.db.chapterReward or { }
- local battleID = human.db.battleID
- local battleNodeConfig = BattleExcel.node[battleID]
- if not battleNodeConfig then
- local nodeCnt = #BattleExcel.node
- local mapCnt = #BattleExcel.map
- if battleID == nodeCnt + 1 and not chapterReward[mapCnt] then
- return true
- else
- return false
- end
- else
- local mapID = battleNodeConfig.mapID
- for i = mapID - 1, 1, -1 do
- if not chapterReward[i] then
- return true
- end
- end
- end
- return false
- -- if human.db.lv < 9 then
- -- return false
- -- end
- -- -- 有免费扫荡次数的时候有红点
- -- human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
- -- if TequanShopLogic.isActiveMopup(human) then
- -- if human.db.mopupFreeCnt < 3 then
- -- return true
- -- end
- -- else
- -- if human.db.mopupFreeCnt < 1 then
- -- return true
- -- end
- -- end
- -- -- 有通关奖励可领取的时候有红点
- -- if hasCanGetReward(human) then
- -- return true
- -- end
- -- -- 战役挂机时间超过1小时的时候有红点
- -- if human.db.battleOut ~= nil then
- -- local now = os.time()
- -- local outSec = now - human.db.battleOut.expTs1
- -- if outSec >= 3600 then
- -- return true
- -- end
- -- end
- -- return false
- end
- function clacItemTwoHours(human)
- local items = { }
- local outCnt = math.floor(7200 / BATTLE_HANG_ITEM_OUT_PERIOD)
- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
- if guajiID == 0 then
- return items
- end
- local nodeConfig = BattleExcel.node[guajiID]
- local dropID = nodeConfig.dropID
- local dropConfig = DropExcel.dropBattle[dropID]
- local totalWeight = 0
- for i = 1, #dropConfig.dropRule do
- local tempConfig = dropConfig.dropRule[i]
- totalWeight = totalWeight + tempConfig[4]
- end
- for j = 1, outCnt do
- local randomNum = math.random(1, totalWeight)
- for i = 1, #dropConfig.dropRule do
- local tempConfig = dropConfig.dropRule[i]
- local itemID = tempConfig[1]
- local itemCnt1 = tempConfig[2]
- local itemCnt2 = tempConfig[3]
- local itemRate = tempConfig[4]
- if randomNum <= itemRate then
- local realAdd = math.random(itemCnt1, itemCnt2)
- items[itemID] = realAdd
- break
- end
- randomNum = randomNum - itemRate
- end
- end
- return items
- end
- local MailManager = require("mail.MailManager")
- function clacItemCntGM(human, cnt, guajiID)
- local items = { }
- local outCnt = cnt
- local nodeConfig = BattleExcel.node[guajiID]
- local dropID = nodeConfig.dropID
- local dropConfig = DropExcel.dropBattle[dropID]
- local totalWeight = 0
- for i = 1, #dropConfig.dropRule do
- local tempConfig = dropConfig.dropRule[i]
- totalWeight = totalWeight + tempConfig[4]
- end
- for j = 1, outCnt do
- local randomNum = math.random(1, totalWeight)
- for i = 1, #dropConfig.dropRule do
- local tempConfig = dropConfig.dropRule[i]
- local itemID = tempConfig[1]
- local itemCnt1 = tempConfig[2]
- local itemCnt2 = tempConfig[3]
- local itemRate = tempConfig[4]
- if randomNum <= itemRate then
- local realAdd = math.random(itemCnt1, itemCnt2)
- items[itemID] = items[itemID] or 0
- items[itemID] = items[itemID] + realAdd
- break
- end
- randomNum = randomNum - itemRate
- end
- end
- local item = { }
- local index = 0
- for k, v in pairs(items) do
- index = index + 1
- item[index] = { k, v }
- end
- MailManager.add(MailManager.SYSTEM, human.db._id, "", "", item, "")
- end
- function getBattleID(human)
- local num = 0
- if human.db.guajiID then
- num = human.db.guajiID or 0
- end
- return num
- end
- --------------------------------------------- combat ----------------------------------------------
- function getCombatMonsterOutID(human, side)
- if side ~= CombatDefine.DEFEND_SIDE then
- return
- end
- local config = BattleExcel.node[human.db.battleID]
- if not config then
- return
- end
- return config.monsterOutID
- end
- function getCombatName(human)
- local name = getBattleName(human.db.battleID)
- return Util.format(Lang.COMBAT_BATTLE_EXNAME, name)
- end
- -------------------------------------------combat end--------------------
- function battleSharkQuery(human, nodeID)
- local msgRet = Msg.gc.GC_BATTLE_SHARK_QUERY
- local videoTb = BattleDBLogic.queryBattleDbByNodeID(nodeID)
- if videoTb == nil then
- msgRet.battleShark[0] = 0
- else
- local len = #videoTb.shark
- for i = 1, len do
- local v = videoTb.shark[i]
- RoleLogic.makeRoleBase(v.roleBase, msgRet.battleShark[i].roleBase)
- msgRet.battleShark[i].type = i
- msgRet.battleShark[i].videoUuid = v.videoUuid
- msgRet.battleShark[i].param = v.param or 0
- end
- msgRet.battleShark[0] = len
- end
- -- Msg.trace(msgRet)
- Msg.send(msgRet, human.fd)
- end
- local QueryRoleByNodeID = { }
- function worldMapRoleListQuery(human, worldMapId)
- -- if worldMapId == 1 then return end
- local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_ROLELIST_QUERY
- local len = 0
- for k, v in pairs(BATTLE_LEVEL_PLAYER_LIST[worldMapId]) do
- len = len + 1
- RoleLogic.makeRoleBase(v, msgRet.roleList[len])
- if len >= 50 then
- break
- end
- end
- msgRet.roleList[0] = len
- Msg.send(msgRet, human.fd)
- end
- -- 章节(地图)掉落列表
- function sendMapDroItemsList(human)
- local battleID = human.db.battleID or 1
- local maxBattleConfig = BattleExcel.node[battleID]
- local maxMapID = maxBattleConfig and maxBattleConfig.mapID or(#BattleExcel.node + 1)
- local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_LIST
- msgRet.list[0] = 0
- for mapID, mapConfig in ipairs(BattleExcel.map) do
- msgRet.list[0] = msgRet.list[0] + 1
- local net = msgRet.list[msgRet.list[0]]
- net.mapID = mapID
- net.mapName = mapConfig.name
- net.isOpen =(mapID <= maxMapID) and 1 or 0
- end
- -- Msg.trace(msgRet)
- Msg.send(msgRet, human.fd)
- end
- -- 章节(地图)掉落详情
- function sendMapDroItemsDetail(human, mapID)
- local mapConfig = BattleExcel.map[mapID]
- if not mapConfig then
- return
- end
- local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_DETAIL
- msgRet.mapID = mapID
- msgRet.items[0] = math.min(#mapConfig.dropItemsShow, #msgRet.items)
- for i = 1, msgRet.items[0] do
- local itemID = mapConfig.dropItemsShow[i][1]
- local itemCnt = mapConfig.dropItemsShow[i][2]
- Grid.makeItem(msgRet.items[i], itemID, itemCnt)
- end
- -- Msg.trace(msgRet)
- Msg.send(msgRet, human.fd)
- end
- -- 获取当前战役的 怪物ID
- function getBattleMonsterOutID(human)
- local battleID = human.db.battleID
- local config = BattleExcel.node[battleID]
- return config.monsterOutID
- end
- function onUpdatePos(human)
- BRoleLogic.updateData(BillboardDefine.TYPE_ZHANDOULI, human.db)
- end
- function getNextRewardName(human)
- for i = human.db.guajiID + 1, #BattleExcel.node do
- if #BattleExcel.node[i].tongguan > 0 then
- local itemID = BattleExcel.node[i].tongguan[1][1]
- local itemConfig = ItemDefine.getConfig(itemID)
- if itemConfig == nil then
- return
- else
- return i - human.db.guajiID, itemConfig.name
- end
- end
- end
- end
- --[[
- 通关章节后领取奖励
- ]]
- function battleChapterReward(human, mapID)
- local mapConf = BattleExcel.map[mapID]
- if not mapConf then
- return
- end
- -- 没有通过当前大关卡
- local battleID = human.db.battleID
- local battleNodeConfig = BattleExcel.node[battleID]
- local roleMapId
- if not battleNodeConfig then
- if battleID ~= #BattleExcel.node + 1 then
- return
- else
- roleMapId = #BattleExcel.map
- end
- else
- roleMapId = battleNodeConfig.mapID
- end
- if mapID > roleMapId then
- return
- end
- if not human.db.chapterReward then
- human.db.chapterReward = { }
- end
- -- 判断是否已经领取了当前大关卡的奖励
- local chapterReward = human.db.chapterReward
- if chapterReward[mapID] then
- return Broadcast.sendErr(human, Lang.FRIEND_HEART_GET_HAD)
- end
- human.db.chapterReward[mapID] = true
- ObjHuman.save(human)
- local reward = mapConf.reward
- BagLogic.addItemList(human, reward, "chapterReward")
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
- local msgRet = Msg.gc.GC_BATTLE_CHAPTER_REWARD
- msgRet.mapID = mapID
- Msg.send(msgRet, human.fd)
- end
|