| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014 |
- 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 GiftLogic = require("topup.GiftLogic")
- local WarOrder = require("shop.WarOrder")
- 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 -- 可领
- local DIAMOND_COST_PER_HOUR = 20
- local HOUR_SEC = 60 * 60
- local DIAMOND_ADDITION = 1.5
- -- @mafei 是否需要集中定义一个define 枚举
- local PRINCIPAL_LINE_EVNET = 1
- local BATTLE_ORDER_TYPE = 1
- -- 挂机收益最多累计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)
- local idx = 1
-
- 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
- if len >= 10 then
- msgRet.items[0] = len
- msgRet.isEnd = 0
- msgRet.index = idx
- msgRet.maxTime = maxHangTime
- if maxHangTime >= outSec then
- msgRet.time = outSec
- else
- msgRet.time = maxHangTime
- end
- local minHour = math.floor(msgRet.time / HOUR_SEC)
- minHour = (minHour ~= 0) and minHour or 1
- msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
-
- msgRet.exp = nodeConfig.hangExp
- msgRet.jinbi = nodeConfig.hangJinbi
- msgRet.greenExp = nodeConfig.hangGreenExp
- msgRet.qingbao = nodeConfig.hangQingbao or 0
- Msg.send(msgRet, human.fd)
- len = 0
- idx = idx + 1
- msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
- end
- len = len + 1
- Grid.makeItem(msgRet.items[len], equipGrid.id, 1, nil, equipGrid)
- end
- end
- msgRet.isEnd = 1
- msgRet.index = idx
- msgRet.items[0] = len
- msgRet.maxTime = maxHangTime
- if maxHangTime >= outSec then
- msgRet.time = outSec
- else
- msgRet.time = maxHangTime
- end
- local minHour = math.floor(msgRet.time / HOUR_SEC)
- minHour = (minHour ~= 0) and minHour or 1
- msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
-
- 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,isDiamond)
- local now = os.time()
- initBattleOut(human, now)
- calcBattleExpOut(human, now)
-
- calcBattleItemOut(human, now)
- if isDiamond then -- 钻石消耗 所有产出翻1.5倍
- human.db.battleOut.exp = math.floor(human.db.battleOut.exp * DIAMOND_ADDITION)
- human.db.battleOut.jinbi = math.floor(human.db.battleOut.jinbi * DIAMOND_ADDITION)
- human.db.battleOut.greenExp = math.floor(human.db.battleOut.greenExp * DIAMOND_ADDITION)
- human.db.battleOut.qingbao = math.floor(human.db.battleOut.qingbao * DIAMOND_ADDITION)
- local items = human.db.battleOut.items or {}
- for id,cnt in pairs(items) do
- items[id] = math.floor(cnt * DIAMOND_ADDITION)
- end
- local equipList = human.db.battleOut.equip or {}
- local equipMap = {}
- for _,equip in ipairs(equipList) do
- equipMap[equip.id] = equipMap[equip.id] or 0
- equipMap[equip.id] = equipMap[equip.id] + 1
- end
- for id,cnt in pairs(equipMap) do
- local count = math.floor(cnt * DIAMOND_ADDITION)
- for i = cnt,count do
- local equipGrid = EquipLogic.makeEquip(id)
- equipList[#equipList + 1] = equipGrid
- end
- end
- end
- 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,isDiamond)
- 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
- local function hangExpGet(human,isDiamond)
- local needDiamond = 0
- -- 是否消耗钻石
- if isDiamond then
- local now = os.time()
- local outSec = now - human.db.battleOut.expTs1
- local maxHangTime = getHangMaxTime(human)
- outSec = outSec > maxHangTime and maxHangTime or outSec
- local minHour = math.floor(outSec / HOUR_SEC)
- minHour = (minHour ~= 0) and minHour or 1
- local diamondCnt = minHour * DIAMOND_COST_PER_HOUR
- if not ObjHuman.checkRMB(human,diamondCnt) then
- return
- end
- needDiamond = -diamondCnt
- end
- print("==================== needDiamond is ",needDiamond)
- calcBattleOut(human,isDiamond)
- 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
- if needDiamond < 0 then
- ObjHuman.decZuanshi(human,needDiamond,"battle")
- end
- return 0, items
- end
- -- 获取挂机收益
- function hangGet(human,isDiamond)
- local ret, items = hangExpGet(human,false)
- 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 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
- -- 触发事件
- --GiftLogic.trigger(human,PRINCIPAL_LINE_EVNET,{id = battleID})
- WarOrder.trigger(human,BATTLE_ORDER_TYPE)
- 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
|