BattleLogic.lua 146 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861
  1. local Lang = require("common.Lang")
  2. local BattleExcel = require("excel.battle")
  3. local BattleExcel_Elite = require("excel.battle_elite")
  4. local BattleExcel_Hard = require("excel.battle_hard")
  5. local MonsterExcel = require("excel.monster")
  6. local DropExcel = require("excel.drop")
  7. local Msg = require("core.Msg")
  8. local ObjHuman = require("core.ObjHuman")
  9. local Grid = require("bag.Grid")
  10. local BagLogic = require("bag.BagLogic")
  11. local ItemDefine = require("bag.ItemDefine")
  12. local Broadcast = require("broadcast.Broadcast")
  13. local CombatDefine = require("combat.CombatDefine")
  14. local CombatPosLogic = require("combat.CombatPosLogic")
  15. local CombatLogic = require("combat.CombatLogic")
  16. local DailyTaskLogic = require("dailyTask.DailyTaskLogic")
  17. local RoleDefine = require("role.RoleDefine")
  18. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  19. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  20. local HeroExcel = require("excel.hero")
  21. local SkillExcel = require("excel.skill")
  22. local MonthactExcel = require("excel.monthAct")
  23. local Util = require("common.Util")
  24. local KingWorldLogic = require("present.KingWorldLogic")
  25. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  26. local BRoleLogic = require("billboard.BRoleLogic")
  27. local BillboardDefine = require("billboard.BillboardDefine")
  28. local SkinLogic = require("skin.SkinLogic")
  29. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  30. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  31. local GuideLogic = require("guide.GuideLogic")
  32. local PanelDefine = require("broadcast.PanelDefine")
  33. local HeroGrid = require("hero.HeroGrid")
  34. local TuiSongLiBao = require("present.TuiSongLiBao")
  35. local CombatVideo = require("combat.CombatVideo")
  36. local RoleLogic = require("role.RoleLogic")
  37. local BattleDBLogic = require("battle.BattleDBLogic")
  38. local ProjectLogic = require("platform.ProjectLogic")
  39. local LuaMongo = _G.lua_mongo
  40. local DB = require("common.DB")
  41. local VipLogic = require("vip.VipLogic")
  42. local MoshouLogic = require("moshou.MoshouLogic")
  43. local RoleExcel = require("excel.role")
  44. local TequanShopLogic = require("present.TequanShopLogic")
  45. local HeroDefine = require("hero.HeroDefine")
  46. local BarTaskLogic = require("bar.BarTaskLogic")
  47. local ItemExcel = require("excel.item").item
  48. local EquipExcel = require("excel.equip").equip
  49. local HeroLogic = require("hero.HeroLogic")
  50. local SuipianLogic = require("bag.SuipianLogic")
  51. local JibanLogic = require("combat.JibanLogic")
  52. local YunYingLogic = require("yunying.YunYingLogic")
  53. local PanelDefine = require("broadcast.PanelDefine")
  54. local YyHandler = require("yunying.Handler")
  55. local EquipLogic = require("equip.EquipLogic")
  56. local SysParameter = require("common.SysParameter")
  57. local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
  58. local AbsActLogic = require("absAct.AbsActLogic")
  59. local HeroLogLogic = require("absAct.HeroLogLogic")
  60. local DropExchangeLogic = require("absAct.DropExchangeLogic")
  61. local MengxinLogic = require("present.MengxinLogic")
  62. local GiftLogic = require("topup.GiftLogic")
  63. local WarOrder = require("shop.WarOrder")
  64. local Log = require("common.Log")
  65. local EliteDefine = require("battle.EliteDefine")
  66. local MaiDianDefine = require("MaiDian.MaiDianDefine")
  67. local MainDianLogic = require("MaiDian.MaiDianLogic")
  68. local TalismanLogic = require("talisman.TalismanLogic")
  69. BATTLE_HANG_EXP_OUT_PERIOD = 60 -- 经验产出时间间隔
  70. BATTLE_HANG_ITEM_OUT_PERIOD = 300 -- 战利品道具产出时间间隔
  71. BATTLE_HANG_ITEM_OUT_PERIOD_2 = 7200 -- 战利品道具产出时间间隔2小时掉落一次
  72. BATTLE_LOGIN_LEV_TIPS = 50 -- 登录检测挂机时间过久提示 最高等级
  73. BATTLE_LOGIN_TIME_TIPS = 10 * 60 -- 登录检测挂机超过多久提示
  74. BATTLE_MOPUP_CNT = 4
  75. BATTLE_MOPUP_CNT_VIP = 11
  76. BATTLE_MOPUP_FREE_CNT = 1
  77. BATTLE_MOPUP_FREE_CNT_VIP = 3
  78. BATTLE_LEVEL_PLAYER_LIST = { }
  79. local STATUS_NONE = 1 -- 不可领
  80. local STATUS_CANGET = 2 -- 可领
  81. local DIAMOND_COST_PER_HOUR = 20
  82. local HOUR_SEC = 60 * 60
  83. local DIAMOND_ADDITION = 1.5
  84. -- @mafei 是否需要集中定义一个define 枚举
  85. local PRINCIPAL_LINE_EVNET = 1
  86. local BATTLE_ORDER_TYPE = 1
  87. -- 挂机收益最多累计x秒
  88. function getHangMaxTime(human)
  89. local hour = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER10)
  90. local talismanAdd_HangHours = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_HANG_HOURS) or 0
  91. hour = hour + talismanAdd_HangHours
  92. return(hour or 0) * 3600
  93. end
  94. local function wrapHangFightNet(net, heroConfig, skillConfig)
  95. net.body = heroConfig.body
  96. net.height = heroConfig.height
  97. net.weight = heroConfig.width
  98. net.fireType = skillConfig and skillConfig.fireType or 0
  99. net.attackEffect = skillConfig and skillConfig.attackEffect or ""
  100. net.flyEffect = skillConfig and skillConfig.flyEffect or ""
  101. net.flyCoords = skillConfig and skillConfig.flyCoords or ""
  102. net.hitEffect = skillConfig and skillConfig.hitEffect or ""
  103. net.hitSound = skillConfig and skillConfig.hitSound or ""
  104. end
  105. local function fontBattleSkillNet(skillNet, skillID)
  106. local skillConfig = SkillExcel.skill[skillID]
  107. if not skillConfig then
  108. return
  109. end
  110. skillNet.skillID = skillID
  111. skillNet.fireType = skillConfig.fireType
  112. skillNet.readyAction = skillConfig.readyAction
  113. skillNet.attackPart = skillConfig.attackPart
  114. skillNet.attackAction = skillConfig.attackAction
  115. skillNet.readyEffect = skillConfig.readyEffect
  116. skillNet.attackEffect = skillConfig.attackEffect
  117. skillNet.hitEffect = skillConfig.hitEffect
  118. skillNet.flyEffect = skillConfig.flyEffect
  119. skillNet.flyCoords = skillConfig.flyCoords
  120. skillNet.hitBack = skillConfig.hitBack
  121. skillNet.effectTime = skillConfig.effectTime
  122. skillNet.contentType = skillConfig.contentType
  123. skillNet.content = skillConfig.content
  124. skillNet.movieEffect = skillConfig.movieEffect
  125. skillNet.quake = skillConfig.quake
  126. skillNet.flySound = skillConfig.flySound
  127. skillNet.fireSound = skillConfig.fireSound
  128. skillNet.hitSound = skillConfig.hitSound
  129. skillNet.cvSound = skillConfig.cvSound
  130. skillNet.screenMask = skillConfig.screenMask
  131. skillNet.screenCam = skillConfig.screenCam
  132. skillNet.largeEffect = skillConfig.largeEffect
  133. skillNet.lie = skillConfig.lie
  134. skillNet.cuoZhen = skillConfig.cuoZhen
  135. skillNet.skillDelay = skillConfig.skillDelay
  136. skillNet.isFraming = skillConfig.isFraming
  137. return true
  138. end
  139. -- 获取当前战役类型
  140. local function BattleLogic_GetBattleType(human)
  141. if not human then
  142. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleType human is null")
  143. return EliteDefine.COPY_ELITE_ERROR
  144. end
  145. return human.db.battleType
  146. end
  147. -- 设置当前战役类型
  148. local function BattleLogic_SetBattleType(human, nBattleType)
  149. if not human or EliteDefine.COPY_ELITE_NORMAL > nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  150. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleType 参数不正确!!!")
  151. return false
  152. end
  153. human.db.battleType = nBattleType
  154. print("[BattleLogic_SetBattleType] 玩家设置战役类型成功 id = "
  155. ..human.db._id.." nBattleType1 = "..nBattleType.." nBattleType2 = "..human.db.battleType)
  156. return true
  157. end
  158. -- 获取战役即将战斗id
  159. local function BattleLogic_GetBattleBattleID(human)
  160. if not human then
  161. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleBattleID] human is null")
  162. return -1
  163. end
  164. local nBattleType = BattleLogic_GetBattleType(human)
  165. --print("[BattleLogic_GetBattleBattleID] 获取到的战斗类型信息 id = "..human.db._id.." nBattleType = "..nBattleType)
  166. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  167. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleBattleID 获取到的战斗类型不正确 id = "
  168. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  169. return -1
  170. end
  171. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  172. return human.db.battleID
  173. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  174. return human.db.battleID_elite
  175. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  176. return human.db.battleID_hard
  177. else
  178. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleBattleID 未处理的战斗类型 id = "
  179. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  180. return -1
  181. end
  182. end
  183. -- 根据类型获取战斗ID
  184. local function BattleLogic_GetBattleIDByType(human, nBattleType)
  185. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  186. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleIDByType 传入的参数不正确 id = "
  187. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  188. return -1
  189. end
  190. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  191. return human.db.battleID
  192. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  193. return human.db.battleID_elite
  194. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  195. return human.db.battleID_hard
  196. end
  197. return -1
  198. end
  199. -- 设置 战役即将战斗id
  200. local function BattleLogic_SetBattleBattleID(human, nValue)
  201. if not human or 0 > nValue then
  202. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleBattleID 参数不正确")
  203. return false
  204. end
  205. local nBattleType = BattleLogic_GetBattleType(human)
  206. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  207. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleBattleID 获取到的战斗类型不正确 id = "
  208. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  209. return false
  210. end
  211. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  212. human.db.battleID = nValue
  213. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  214. human.db.battleID_elite = nValue
  215. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  216. human.db.battleID_hard = nValue
  217. else
  218. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  219. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  220. return false
  221. end
  222. return true
  223. end
  224. -- 获取当前战役 已通关关卡/挂机关卡
  225. local function BattleLogic_GetBattleGuaJiID(human)
  226. if not human then
  227. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID human is null")
  228. return -1
  229. end
  230. local nBattleType = BattleLogic_GetBattleType(human)
  231. print("[BattleLogic_GetBattleGuaJiID] 获取到的战斗类型信息 id = "..human.db._id.." nBattleType = "..nBattleType)
  232. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  233. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 获取到的战斗类型不正确 id = "
  234. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  235. return -1
  236. end
  237. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  238. return human.db.guajiID
  239. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  240. return human.db.guajiID_elite
  241. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  242. return human.db.guajiID_hard
  243. else
  244. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  245. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  246. return -1
  247. end
  248. end
  249. -- 通过战斗类型获取当前战役 已通关关卡/挂机关卡
  250. local function BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  251. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  252. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiIDByType 传入的参数不正确 id = "
  253. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  254. return -1
  255. end
  256. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  257. return human.db.guajiID
  258. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  259. return human.db.guajiID_elite
  260. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  261. return human.db.guajiID_hard
  262. else
  263. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiIDByType 未处理的战斗类型 id = "
  264. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  265. return -1
  266. end
  267. end
  268. -- 设置当前战役 已通关关卡/挂机关卡
  269. local function BattleLogic_SetBattleGuaJiID(human, nValue)
  270. if not human or 0 > nValue then
  271. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleGuaJiID 参数不正确")
  272. return false
  273. end
  274. local nBattleType = BattleLogic_GetBattleType(human)
  275. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  276. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleGuaJiID 获取到的战斗类型不正确 id = "
  277. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  278. return false
  279. end
  280. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  281. human.db.guajiID = nValue
  282. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  283. human.db.guajiID_elite = nValue
  284. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  285. human.db.guajiID_hard = nValue
  286. else
  287. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  288. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  289. return false
  290. end
  291. return true
  292. end
  293. -- 获取奖励信息
  294. local function BattleLogic_GetBattleRewards(human)
  295. if not human then
  296. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  297. return nil
  298. end
  299. local nBattleType = BattleLogic_GetBattleType(human)
  300. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  301. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 获取到的战斗类型不正确 id = "
  302. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  303. return nil
  304. end
  305. local tRewards = nil
  306. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  307. if not human.db.battleRewards then
  308. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家普通奖励未初始化进行初始化 id = "
  309. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  310. human.db.battleRewards = {}
  311. end
  312. tRewards = human.db.battleRewards
  313. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  314. if not human.db.battleRewards_elite then
  315. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家精英奖励未初始化进行初始化 id = "
  316. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  317. human.db.battleRewards_elite = {}
  318. end
  319. tRewards = human.db.battleRewards_elite
  320. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  321. if not human.db.battleRewards_hard then
  322. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家困难奖励未初始化进行初始化 id = "
  323. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  324. human.db.battleRewards_hard = {}
  325. end
  326. tRewards = human.db.battleRewards_hard
  327. else
  328. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 未处理的战斗类型 id = "
  329. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  330. end
  331. return tRewards
  332. end
  333. -- 根据类型获取奖励信息
  334. local function BattleLogic_GetBattleRewardsByType(human, nBattleType)
  335. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  336. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 参数不正确")
  337. return nil
  338. end
  339. local tRewards = nil
  340. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  341. if not human.db.battleRewards then
  342. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 玩家普通奖励未初始化进行初始化 id = "
  343. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  344. human.db.battleRewards = {}
  345. end
  346. --print("[BattleLogic_GetBattleRewardsByType] 返回普通奖励表")
  347. tRewards = human.db.battleRewards
  348. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  349. if not human.db.battleRewards_elite then
  350. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 玩家精英奖励未初始化进行初始化 id = "
  351. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  352. human.db.battleRewards_elite = {}
  353. end
  354. --print("[BattleLogic_GetBattleRewardsByType] 返回精英奖励表")
  355. tRewards = human.db.battleRewards_elite
  356. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  357. if not human.db.battleRewards_hard then
  358. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 玩家困难奖励未初始化进行初始化 id = "
  359. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  360. human.db.battleRewards_hard = {}
  361. end
  362. --print("[BattleLogic_GetBattleRewardsByType] 返回困难奖励表")
  363. tRewards = human.db.battleRewards_hard
  364. else
  365. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 未处理的战斗类型 id = "
  366. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  367. end
  368. return tRewards
  369. end
  370. local WeiLen = 30
  371. -- 设置奖励信息
  372. local function BattleLogic_SetBattleRewards(human, id)
  373. if not human or 0 >= id then
  374. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleRewards 参数不正确")
  375. return false
  376. end
  377. local tRewards = BattleLogic_GetBattleRewards(human)
  378. if not tRewards then
  379. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleRewards 获取到的奖励为空 id = "
  380. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  381. return false
  382. end
  383. local intIndex = math.ceil(id / WeiLen)
  384. local byteIndex = id % WeiLen
  385. tRewards[intIndex] = tRewards[intIndex] or 0
  386. tRewards[intIndex] = Util.setBit(tRewards[intIndex], byteIndex)
  387. return true
  388. end
  389. -- 获取挂机奖励表
  390. local function BattleLogic_GetBattleOut(human)
  391. if not human then
  392. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleOut 参数不正确")
  393. return nil
  394. end
  395. local nBattleType = BattleLogic_GetBattleType(human)
  396. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  397. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleOut 获取到的战斗类型不正确 id = "
  398. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  399. return nil
  400. end
  401. return human.db.battleOut
  402. -- if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  403. -- -- if not human.db.battleRewards then
  404. -- -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家普通奖励未初始化进行初始化 id = "
  405. -- -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  406. -- -- human.db.battleOut = {}
  407. -- -- end
  408. -- tRewards = human.db.battleOut
  409. -- elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  410. -- -- if not human.db.battleRewards_elite then
  411. -- -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家精英奖励未初始化进行初始化 id = "
  412. -- -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  413. -- -- human.db.battleRewards_elite = {}
  414. -- -- end
  415. -- tRewards = human.db.battleOut_elite
  416. -- elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  417. -- -- if not human.db.battleRewards_hard then
  418. -- -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家困难奖励未初始化进行初始化 id = "
  419. -- -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  420. -- -- human.db.battleRewards_hard = {}
  421. -- -- end
  422. -- tRewards = human.db.battleOut_hard
  423. -- else
  424. -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleOut 未处理的战斗类型 id = "
  425. -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  426. -- end
  427. end
  428. function BattleLogic_InitOneBattleOut(human, now)
  429. human.db.battleOut = { }
  430. human.db.battleOut.expTs1 = now
  431. -- 经验开始产出时间戳
  432. human.db.battleOut.expTs2 = now
  433. -- 经验产出结算时间戳
  434. human.db.battleOut.itemTs1 = now
  435. -- 道具产出时间戳
  436. human.db.battleOut.itemTs2 = now
  437. -- 道具产出结算时间戳
  438. human.db.battleOut.exp = 0
  439. human.db.battleOut.jinbi = 0
  440. human.db.battleOut.greenExp = 0
  441. human.db.battleOut.qingbao = 0
  442. human.db.battleOut.items = nil
  443. -- 产出的待收获的战利品
  444. human.db.battleOut.equip = nil
  445. -- 产出的待收获的装备
  446. return true
  447. end
  448. -- 初始化所有挂机奖励领取列表
  449. local function BattleLogic_InitAllBattleOut(human, now)
  450. if not human then
  451. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_InitAllBattleOut 参数不正确")
  452. return false
  453. end
  454. if not human.db.battleOut then
  455. BattleLogic_InitOneBattleOut(human, now)
  456. end
  457. -- if not human.db.battleOut_elite then
  458. -- human.db.battleOut_elite = {}
  459. -- BattleLogic_InitOneBattleOut(human.db.battleOut_elite, now)
  460. -- end
  461. -- if not human.db.battleOut_hard then
  462. -- human.db.battleOut_hard = {}
  463. -- BattleLogic_InitOneBattleOut(human.db.battleOut_hard, now)
  464. -- end
  465. return true
  466. end
  467. -- 获取配置信息
  468. local function BattleLogic_GetBattleConfig(human)
  469. if not human then
  470. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleConfig 参数不正确")
  471. return nil
  472. end
  473. local nBattleType = BattleLogic_GetBattleType(human)
  474. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  475. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleConfig 获取到的战斗类型不正确 id = "
  476. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  477. return nil
  478. end
  479. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  480. return BattleExcel
  481. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  482. return BattleExcel_Elite
  483. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  484. return BattleExcel_Hard
  485. else
  486. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  487. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  488. return nil
  489. end
  490. end
  491. -- 根据战斗类型获取配置
  492. local function BattleLogic_GetBattleConfigByType(nBattleType)
  493. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  494. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleConfigByType 参数不正确")
  495. return nil
  496. end
  497. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  498. return BattleExcel
  499. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  500. return BattleExcel_Elite
  501. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  502. return BattleExcel_Hard
  503. end
  504. return nil
  505. end
  506. -- 获取章节奖励
  507. local function BattleLogic_GetChapterReward(human)
  508. if not human then
  509. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetChapterReward 参数不正确")
  510. return nil
  511. end
  512. local nBattleType = BattleLogic_GetBattleType(human)
  513. print("[BattleLogic_GetChapterReward] nBattleType = "..nBattleType)
  514. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  515. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetChapterReward 获取到的战斗类型不正确 id = "
  516. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  517. return nil
  518. end
  519. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  520. if not human.db.chapterReward then
  521. human.db.chapterReward = {}
  522. end
  523. return human.db.chapterReward
  524. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  525. if not human.db.chapterReward_Elite then
  526. human.db.chapterReward_Elite = {}
  527. end
  528. return human.db.chapterReward_Elite
  529. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  530. if not human.db.chapterReward_Hard then
  531. human.db.chapterReward_Hard = {}
  532. end
  533. return human.db.chapterReward_Hard
  534. else
  535. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetChapterReward 未处理的战斗类型 id = "
  536. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  537. return nil
  538. end
  539. end
  540. -- 查询难度
  541. local function BattleLogic_QueryDifficulty(human)
  542. local nNowBattleType = BattleLogic_GetBattleType(human)
  543. if EliteDefine.COPY_ELITE_ERROR >= nNowBattleType then
  544. print("[BattleLogic_QueryDifficulty] 查询难度获取到的战斗ID数值、战斗类型不正确 id = "
  545. ..human.db._id.." nNowBattleType = "..nNowBattleType)
  546. return
  547. end
  548. local msgRet = Msg.gc.GC_ELITE_OPEN
  549. msgRet.curCopyType = nNowBattleType
  550. msgRet.copyOpenType[0]=0
  551. --精英副本开启, 普通关卡符合条件
  552. local nBattleID = human.db.battleID
  553. local nIndex = EliteDefine.COPY_LEVEL_ELITE - 1
  554. if human.db.lv >= EliteDefine.COPY_ELITE_ULEV and
  555. nBattleID > EliteDefine.COPY_ELITE_LEVEL then
  556. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  557. msgRet.copyOpenType[nIndex] = 1
  558. else
  559. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  560. msgRet.copyOpenType[nIndex] = 0
  561. end
  562. --困难副本开启,精英关卡符合条件
  563. local nBattleIDElite = human.db.battleID_elite
  564. nIndex = EliteDefine.COPY_ELITE_DIFFICULTY - 1
  565. if human.db.lv >= EliteDefine.COPY_ELITE_ULEV and
  566. nBattleIDElite > EliteDefine.COPY_ELITE_LEVEL then
  567. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  568. msgRet.copyOpenType[nIndex] = 1
  569. else
  570. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  571. msgRet.copyOpenType[nIndex] = 0
  572. end
  573. Msg.send(msgRet,human.fd)
  574. local info=Util.printTable(msgRet)
  575. print(info)
  576. end
  577. -- 设置战役通关标记
  578. local function BattleLogic_SetBattleAdopt(human, nBattleType, nValue)
  579. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  580. return
  581. end
  582. print("[BattleLogic_SetBattleAdopt] 玩家通过战役 nBattleType = "..nBattleType.." nValue = "..nValue)
  583. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  584. human.db.battleadopt = nValue
  585. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  586. human.db.battleadopt_elite = nValue
  587. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  588. human.db.battleadopt_haed = nValue
  589. end
  590. end
  591. -- 获取战役通关标记
  592. local function BattleLogic_GetBattleAdopt(human, nBattleType)
  593. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  594. return 0
  595. end
  596. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  597. return human.db.battleadopt
  598. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  599. return human.db.battleadopt_elite
  600. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  601. return human.db.battleadopt_haed
  602. end
  603. end
  604. -- 获取额外增加扫荡次数
  605. local function BattleLogic_GetAddFreeMopupNum(human)
  606. if not human then
  607. return -1
  608. end
  609. if not human.db.mopupAddFreeCnt then
  610. human.db.mopupAddFreeCnt = 0
  611. end
  612. return human.db.mopupAddFreeCnt
  613. end
  614. -- 设置额外增加扫荡次数
  615. local function BattleLogic_SetAddFreeMopupNum(human, nValue)
  616. if not human then
  617. return
  618. end
  619. print("[BattleLogic_SetAddFreeMopupNum] 消耗的额外次数 nValue = "..nValue)
  620. human.db.mopupAddFreeCnt = human.db.mopupAddFreeCnt + nValue
  621. -- if 0 > human.db.mopupAddFreeCnt then
  622. -- human.db.mopupAddFreeCnt = 0
  623. -- end
  624. end
  625. function getBattleRoleList(nBattleType, worldMapId)
  626. if not BATTLE_LEVEL_PLAYER_LIST then
  627. BATTLE_LEVEL_PLAYER_LIST = {}
  628. end
  629. if not BATTLE_LEVEL_PLAYER_LIST[nBattleType] then
  630. BATTLE_LEVEL_PLAYER_LIST[nBattleType] = {}
  631. end
  632. BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId] = BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId] or { }
  633. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  634. if not tBattleConfig then
  635. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getBattleRoleList] 获取不到对应的配置 nBattleType = "
  636. ..nBattleType.." worldMapId ="..worldMapId)
  637. print("[getBattleRoleList] 获取配置失败")
  638. return
  639. end
  640. -- local config = BattleExcel.map[worldMapId]
  641. local config = tBattleConfig.map[worldMapId]
  642. QueryRoleByNodeID = { guajiID = { ["$gte"] = config.minLevel, ["$lte"] = config.maxLevel }, nBattleType = nBattleType}
  643. local fields = { }
  644. RoleLogic.makeRoleBaseFields(fields)
  645. LuaMongo.find(DB.db_char, QueryRoleByNodeID, fields, 50)
  646. local len = 0
  647. while true do
  648. local charDb = { }
  649. if not LuaMongo.next(charDb) then
  650. break
  651. end
  652. len = len + 1
  653. BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId][charDb._id] = { }
  654. RoleLogic.makeRoleBase(charDb, BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId][charDb._id])
  655. if len >= 50 then
  656. return
  657. end
  658. end
  659. end
  660. function initAfterStart()
  661. local len = #BattleExcel.map
  662. for i = 1, len do
  663. getBattleRoleList(EliteDefine.COPY_ELITE_NORMAL, i)
  664. end
  665. len = #BattleExcel_Elite.map
  666. for i = 1, len do
  667. getBattleRoleList(EliteDefine.COPY_LEVEL_ELITE, i)
  668. end
  669. len = #BattleExcel_Hard.map
  670. for i = 1, len do
  671. getBattleRoleList(EliteDefine.COPY_ELITE_DIFFICULTY, i)
  672. end
  673. end
  674. function onLogin(human)
  675. --处理老号已经在小游戏玩法上线前已经推过图没有获得小游戏次数
  676. if not human.db.battleGameTimes then
  677. local gameTimes = 0
  678. local battleID = human.db.battleID
  679. local allCfg = BattleExcel.node
  680. for i=1, battleID-1 do
  681. local cfg = allCfg[i]
  682. if cfg and cfg and type(cfg.gameType) == "number" and cfg.gameType == 1 then
  683. gameTimes = gameTimes + 1
  684. end
  685. end
  686. human.db.battleGameTimes = gameTimes
  687. end
  688. if human.db.lv >= BATTLE_LOGIN_LEV_TIPS then
  689. return
  690. end
  691. calcBattleOut(human)
  692. local now = os.time()
  693. -- local expTime = now - human.db.battleOut.expTs1
  694. local tBattleOut = BattleLogic_GetBattleOut(human)
  695. if tBattleOut then
  696. local expTime = now - tBattleOut.expTs1
  697. if expTime >= BATTLE_LOGIN_TIME_TIPS then
  698. local msgRet = Msg.gc.GC_BATTLE_HANG_TIME_SPILL
  699. msgRet.time = expTime
  700. Msg.send(msgRet, human.fd)
  701. end
  702. else
  703. print("[BattleLogic_onLogin] 获取不到奖励数据 id = "
  704. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  705. end
  706. end
  707. -- 是否领取
  708. -- local WeiLen = 30
  709. function isGetReward(human, id)
  710. local flags = BattleLogic_GetBattleRewards(human)
  711. if not flags then
  712. return false
  713. end
  714. -- if not human.db.battleRewards then
  715. -- return
  716. -- end
  717. --local flags = human.db.battleRewards
  718. local intIndex = math.ceil(id / WeiLen)
  719. if not flags[intIndex] then
  720. return
  721. end
  722. local byteIndex = id % WeiLen
  723. if Util.getBit(flags[intIndex], byteIndex) > 0 then
  724. return true
  725. end
  726. end
  727. -- 通过类型获取奖励 判断是否领取
  728. function isGetRewardByType(human, id, nBattleType)
  729. local flags = BattleLogic_GetBattleRewardsByType(human, nBattleType)
  730. if not flags then
  731. print("[isGetRewardByType] 获取不到对应的奖励表 id = "..human.db._id .. " nBattleType = "..nBattleType)
  732. return false
  733. end
  734. local intIndex = math.ceil(id / WeiLen)
  735. if not flags[intIndex] then
  736. print("[isGetRewardByType] 没有对对应的ID领取奖励 intIndex id = "..id .. " nBattleType = "..nBattleType)
  737. return false
  738. end
  739. local byteIndex = id % WeiLen
  740. -- if Util.getBit(flags[intIndex], byteIndex) > 0 then
  741. -- return true
  742. -- end
  743. local nBit = Util.getBit(flags[intIndex], byteIndex)
  744. -- print("[isGetRewardByType] nBit = ".. nBit)
  745. return Util.getBit(flags[intIndex], byteIndex) > 0 and true or false
  746. end
  747. function getTongguanIndex(human)
  748. local tBattleRewards = BattleLogic_GetBattleRewards(human)
  749. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  750. if not tBattleRewards or not tBattleConfig then
  751. return 1
  752. end
  753. --local flags = human.db.battleRewards
  754. -- for id, v in ipairs(BattleExcel.node) do
  755. for id, v in ipairs(tBattleConfig.node) do
  756. if #v.tongguan ~= 0 then
  757. local intIndex = math.ceil(id / WeiLen)
  758. -- if not flags[intIndex] then
  759. if not tBattleRewards[intIndex] then
  760. return id
  761. end
  762. local byteIndex = id % WeiLen
  763. -- if Util.getBit(flags[intIndex], byteIndex) == 0 then
  764. if Util.getBit(tBattleRewards[intIndex], byteIndex) == 0 then
  765. return id
  766. end
  767. end
  768. end
  769. return
  770. end
  771. -- 设置领取
  772. function setGetReward(human, id)
  773. local tBattleRewards = BattleLogic_GetBattleRewards(human)
  774. if not tBattleRewards then
  775. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  776. print("[setGetReward] 不存在对应的 奖励配置")
  777. return
  778. end
  779. -- if not human.db.battleRewards then
  780. -- human.db.battleRewards = { }
  781. -- end
  782. -- local flags = human.db.battleRewards
  783. local intIndex = math.ceil(id / WeiLen)
  784. local byteIndex = id % WeiLen
  785. tBattleRewards[intIndex] = tBattleRewards[intIndex] or 0
  786. tBattleRewards[intIndex] = Util.setBit(tBattleRewards[intIndex], byteIndex)
  787. end
  788. -- 通过类型设置领取
  789. function setGetRewardByType(human, id, nBattleType)
  790. local tBattleRewards = BattleLogic_GetBattleRewardsByType(human, nBattleType)
  791. if not tBattleRewards then
  792. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  793. print("[setGetReward] 不存在对应的 奖励配置")
  794. return
  795. end
  796. local intIndex = math.ceil(id / WeiLen)
  797. local byteIndex = id % WeiLen
  798. tBattleRewards[intIndex] = tBattleRewards[intIndex] or 0
  799. tBattleRewards[intIndex] = Util.setBit(tBattleRewards[intIndex], byteIndex)
  800. end
  801. -- 是否有可领取的
  802. function hasCanGetReward(human)
  803. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  804. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  805. if not tBattleConfig or -1 >= nGuaJiID then
  806. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  807. print("[hasCanGetReward] 不存在对应的 奖励配置")
  808. return
  809. end
  810. for id, cf in ipairs(tBattleConfig.node) do
  811. if id > nGuaJiID then
  812. break
  813. end
  814. if #cf.tongguan > 0 and not isGetReward(human, id) then
  815. return true
  816. end
  817. end
  818. end
  819. local BATTLEID_2_NAME = nil
  820. function getBattleName(human, battleID)
  821. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  822. local nBattleType = BattleLogic_GetBattleType(human)
  823. if not tBattleConfig or EliteDefine.COPY_ELITE_ERROR >= nBattleType then
  824. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  825. print("[getBattleName] 不存在对应的 奖励配置")
  826. return
  827. end
  828. if not BATTLEID_2_NAME then
  829. BATTLEID_2_NAME = { }
  830. end
  831. if not BATTLEID_2_NAME[nBattleType] then
  832. BATTLEID_2_NAME[nBattleType] = {}
  833. for id, cf in ipairs(tBattleConfig.node) do
  834. -- BATTLEID_2_NAME[id] = cf.name
  835. BATTLEID_2_NAME[nBattleType][id] = cf.name
  836. end
  837. end
  838. local nodeConfig = tBattleConfig.node[battleID]
  839. local mapConfig = nodeConfig and tBattleConfig.map[nodeConfig.mapID]
  840. local mapName = mapConfig and mapConfig.name or ""
  841. return BATTLEID_2_NAME[nBattleType][battleID] or "", mapName
  842. end
  843. function getBattleNameByType(battleID, nBattleType)
  844. local tBattleConfig = BattleLogic_GetBattleConfigByType( nBattleType)
  845. if not tBattleConfig or EliteDefine.COPY_ELITE_ERROR >= nBattleType then
  846. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  847. print("[getBattleNameByType] 不存在对应的 奖励配置")
  848. return
  849. end
  850. if not BATTLEID_2_NAME then
  851. BATTLEID_2_NAME = { }
  852. end
  853. if not BATTLEID_2_NAME[nBattleType] then
  854. BATTLEID_2_NAME[nBattleType] = {}
  855. for id, cf in ipairs(tBattleConfig.node) do
  856. -- BATTLEID_2_NAME[id] = cf.name
  857. BATTLEID_2_NAME[nBattleType][id] = cf.name
  858. end
  859. end
  860. local nodeConfig = tBattleConfig.node[battleID]
  861. local mapConfig = nodeConfig and tBattleConfig.map[nodeConfig.mapID]
  862. local mapName = mapConfig and mapConfig.name or ""
  863. return BATTLEID_2_NAME[nBattleType][battleID] or "", mapName
  864. end
  865. function hangFightQuery(human)
  866. local nBattleID = BattleLogic_GetBattleBattleID(human)
  867. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  868. if -1 >= nBattleID or not tBattleExcel then
  869. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangFightQuery 参数不正确")
  870. print("[hangFightQuery] 不存在对应的 奖励配置 和战斗关卡ID id = "..human.db._id)
  871. return
  872. end
  873. -- local battleID = human.db.battleID > #BattleExcel.node and #BattleExcel.node or human.db.battleID
  874. local battleID = nBattleID > #tBattleExcel.node and #tBattleExcel.node or nBattleID
  875. local nowNodeConfig = tBattleExcel.node[battleID]
  876. local monsterOutID = nowNodeConfig.monsterOutID
  877. local monsterOutConfig = MonsterExcel.monsterOut[monsterOutID]
  878. local msgRet = Msg.gc.GC_BATTLE_HANG_FIGHT
  879. local len = 0
  880. for _, monster in ipairs(monsterOutConfig.member) do
  881. local monsterID = monster[1]
  882. len = len + 1
  883. local monsterConfig = MonsterExcel.monster[monsterID]
  884. local skillConfig = SkillExcel.skill[monsterConfig.normalAtkID]
  885. wrapHangFightNet(msgRet.monsterList[len], monsterConfig, skillConfig)
  886. end
  887. msgRet.monsterList[0] = len
  888. len = 0
  889. if human.db.combatHero[CombatDefine.COMBAT_TYPE1] then
  890. local tb = { }
  891. for i = 1, #human.db.combatHero[CombatDefine.COMBAT_TYPE1] do
  892. tb[#tb + 1] = human.db.combatHero[CombatDefine.COMBAT_TYPE1][i]
  893. end
  894. local tb2 = { }
  895. for i = 1, 3 do
  896. local r = math.ceil(math.random(0, #tb))
  897. r = r == 0 and 1 or r
  898. tb2[#tb2 + 1] = tb[r]
  899. tb[r] = tb[#tb]
  900. tb[#tb] = nil
  901. if not tb[1] then
  902. break
  903. end
  904. end
  905. for i = 1, #tb2 do
  906. len = len + 1
  907. local heroGrid = HeroLogic.getHeroGridByUuid(human, tb2[i])
  908. if heroGrid then
  909. local heroConfig = HeroExcel.hero[heroGrid.id]
  910. local _, skinSkillConf = SkinLogic.getHeroSkin(human, tb2[i])
  911. local skillConfig = SkillExcel.skill[heroConfig.normalAtkID]
  912. if skinSkillConf then
  913. skillConfig = SkillExcel.skill[skinSkillConf.normalAtkID]
  914. end
  915. wrapHangFightNet(msgRet.attackerList[i], heroConfig, skillConfig)
  916. local body, head = SkinLogic.getBody(human, tb2[i])
  917. if body then
  918. msgRet.attackerList[i].body = body
  919. end
  920. end
  921. end
  922. end
  923. msgRet.attackerList[0] = len
  924. -- Msg.trace(msgRet)
  925. Msg.send(msgRet, human.fd)
  926. end
  927. local function getExtraRewardID(human)
  928. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  929. if not tBattleExcel then
  930. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getExtraRewardID] 参数不正确")
  931. print("[getExtraRewardID] 不存在对应的 奖励配置 id = "..human.db._id)
  932. return nil, nil
  933. end
  934. local config = tBattleExcel.extraReward
  935. local battleExtraReward = human.db.battleExtraReward
  936. for id, data in ipairs(config) do
  937. if not battleExtraReward or not battleExtraReward[id] then
  938. return id, data
  939. end
  940. end
  941. end
  942. local function getExtraRewardState(human, extraRewardID)
  943. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  944. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  945. if not tBattleExcel or -1 >= nGuaJiID then
  946. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getExtraRewardState] 参数不正确")
  947. print("[getExtraRewardState] 不存在对应的 奖励配置 id = "..human.db._id)
  948. return 0
  949. end
  950. local config = tBattleExcel.extraReward[extraRewardID]
  951. if not config then
  952. return 0
  953. end
  954. if human.db.battleExtraReward and human.db.battleExtraReward[extraRewardID] then
  955. return 0
  956. end
  957. local guajiID = nGuaJiID
  958. if guajiID >= config.needBattleID then
  959. return 1
  960. end
  961. return 0
  962. end
  963. local function makeExtraRewardShow(human, net)
  964. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  965. if not tBattleExcel then
  966. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[makeExtraRewardShow] 参数不正确")
  967. print("[makeExtraRewardShow] 不存在对应的 奖励配置 id = "..human.db._id)
  968. return
  969. end
  970. local config = tBattleExcel.extraReward
  971. local extraID, data = getExtraRewardID(human)
  972. if not extraID or not data then
  973. return
  974. end
  975. net[0] = 1
  976. net[1].needBattleID = data.needBattleID
  977. net[1].descID = data.descID
  978. net[1].desc = data.desc or ""
  979. net[1].extraHero[0] = 0
  980. net[1].extraItem[0] = 0
  981. if data.extraHeroID > 0 then
  982. net[1].extraHero[0] = 1
  983. HeroGrid.makeHeroSimpleByID(net[1].extraHero[1], data.extraHeroID, nil, nil, human)
  984. HeroGrid.makeHeroSimpleByGeneral(net[1].extraHero[1], data.extraHeroID)
  985. else
  986. net[1].extraItem[0] = 1
  987. Grid.makeItem(net[1].extraItem[1], data.extraReward[1], data.extraReward[2])
  988. end
  989. net[1].state = getExtraRewardState(human, extraID)
  990. end
  991. -- 随机道具
  992. local function randItemOut(dropRule, weightSum)
  993. if weightSum < 1 then
  994. return
  995. end
  996. local r = math.random(1, weightSum)
  997. for i = 1, #dropRule do
  998. local itemID = dropRule[i][1]
  999. local itemCnt1 = dropRule[i][2]
  1000. local itemCnt2 = dropRule[i][3]
  1001. local weight = dropRule[i][4]
  1002. if r <= weight then
  1003. local itemCnt = math.random(itemCnt1, itemCnt2)
  1004. return itemID, itemCnt
  1005. end
  1006. r = r - weight
  1007. end
  1008. end
  1009. function fontExtraDataSSZH(net, mapID, nowBattleID, human)
  1010. local nodeCnt = 0
  1011. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  1012. if not tBattleExcel then
  1013. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[fontExtraDataSSZH] 参数不正确")
  1014. print("[fontExtraDataSSZH] 不存在对应的 奖励配置 id = "..human.db._id)
  1015. return
  1016. end
  1017. if ProjectLogic.isSszh() then
  1018. for i = 1, #tBattleExcel.node do
  1019. local nodeTempConfig = tBattleExcel.node[i]
  1020. if nodeTempConfig.mapID == mapID then
  1021. nodeCnt = nodeCnt + 1
  1022. local posNet = net.posList[nodeCnt]
  1023. local pos = nodeTempConfig.pos
  1024. posNet.battleID = i
  1025. posNet.posX = pos and pos[1] or 0
  1026. posNet.posY = pos and pos[2] or 0
  1027. posNet.nodeName = getBattleName(human, i)
  1028. posNet.roleBase[0] = 0
  1029. if i == nowBattleID then
  1030. local videoTb = BattleDBLogic.queryBattleDbByNodeID(i)
  1031. local sharkData = videoTb and videoTb.shark[2]
  1032. if sharkData then
  1033. posNet.roleBase[0] = 1
  1034. RoleLogic.makeRoleBase(videoTb.roleBase, posNet.roleBase[1])
  1035. end
  1036. end
  1037. posNet.isBig = nodeTempConfig.isBig or 0
  1038. end
  1039. end
  1040. end
  1041. net.posList[0] = nodeCnt
  1042. end
  1043. function fontVideoInfo(human, net, monsterConfig)
  1044. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
  1045. local len = #combatHero
  1046. -- 自己没队伍时,不显示
  1047. if len == 0 then
  1048. net.ownBody[0] = 0
  1049. net.enemyBody[0] = 0
  1050. else
  1051. -- 设置真实数据
  1052. local cnt = 0
  1053. for k, v in pairs(combatHero) do
  1054. -- body数据
  1055. if v ~= "0" then
  1056. local heroGird, bagIndex = HeroLogic.getHeroGridByUuid(human, v)
  1057. if heroGird ~= nil then
  1058. cnt = cnt + 1
  1059. local config = HeroExcel.hero[heroGird.id]
  1060. if config then
  1061. local attrConfig = HeroDefine.getAttrConfig(heroGird.id, config.star)
  1062. local normalAtkID = attrConfig.normalAtkID
  1063. local skill = attrConfig.battleSkill
  1064. local body, head = SkinLogic.getBody(human, bagIndex)
  1065. net.ownBody[cnt].body = body or config.body
  1066. fontBattleSkillNet(net.ownBody[cnt].atkId, normalAtkID)
  1067. fontBattleSkillNet(net.ownBody[cnt].skill, skill)
  1068. net.ownBody[cnt].pos = k
  1069. net.ownBody[cnt].atkType = SkillExcel.skill[normalAtkID].areaPara
  1070. local attrs = ObjHuman.getHeroAttrs(human, heroGird.bagIndex)
  1071. net.ownBody[cnt].hp = attrs[RoleDefine.HP]
  1072. end
  1073. end
  1074. end
  1075. end
  1076. net.ownBody[0] = cnt
  1077. cnt = 0
  1078. local memberConfig = monsterConfig.member
  1079. for k, v in pairs(memberConfig) do
  1080. -- body数据
  1081. cnt = cnt + 1
  1082. local config = MonsterExcel.monster[v[1]]
  1083. if config then
  1084. local normalAtkID = config.normalAtkID
  1085. net.enemyBody[cnt].body = config.body
  1086. fontBattleSkillNet(net.enemyBody[cnt].atkId, normalAtkID)
  1087. fontBattleSkillNet(net.enemyBody[cnt].skill, normalAtkID)
  1088. net.enemyBody[cnt].pos = k
  1089. net.enemyBody[cnt].atkType = SkillExcel.skill[normalAtkID].areaPara
  1090. local attrID = monsterConfig.attrID[k]
  1091. local attrConfig = MonsterExcel.monsterAttr[attrID].attrs
  1092. if not attrConfig then
  1093. print("[fontVideoInfo] 根据attrID获取到的 attrConfig 为空 k = "..k.. " attrID = "..attrID)
  1094. end
  1095. for _, value in pairs(attrConfig) do
  1096. if value[1] == RoleDefine.HP then
  1097. net.enemyBody[cnt].hp = value[2]
  1098. break
  1099. end
  1100. end
  1101. end
  1102. end
  1103. net.enemyBody[0] = cnt
  1104. end
  1105. end
  1106. -- 战役主界面查询
  1107. function query(human)
  1108. local msgRet = Msg.gc.GC_BATTLE_QUERY
  1109. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1110. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1111. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1112. local nBattleType = BattleLogic_GetBattleType(human)
  1113. if -1 >= nNowBattleID or not tBattleConfig or -1 >= nNowGuaJiID or -1 >= nBattleType then
  1114. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[query] 获取到的战斗ID或奖励配置不正确")
  1115. print("[query] 获取到的战斗ID或奖励配置不正确 id = "..human.db._id)
  1116. return
  1117. end
  1118. print("[BattleLogic query] nNowGuaJiID ="..nNowGuaJiID.." nNowBattleID ="..nNowBattleID)
  1119. msgRet.nowBattleID = nNowBattleID
  1120. local configNode = #tBattleConfig.node
  1121. if nNowBattleID > configNode then
  1122. print("[query] 玩家的战斗ID不正确,进行纠正 nNowBattleID = "..nNowBattleID.." 最大战斗ID = "..configNode)
  1123. nNowBattleID = configNode
  1124. BattleLogic_SetBattleBattleID(human, nNowBattleID)
  1125. end
  1126. if nNowGuaJiID > configNode then
  1127. print("[query] 玩家的挂机ID不正确,进行纠正 nNowGuaJiID = "..nNowGuaJiID.." 最大挂机ID = "..configNode)
  1128. nNowGuaJiID = configNode
  1129. BattleLogic_SetBattleGuaJiID(human, nNowGuaJiID)
  1130. end
  1131. local nBattleAdopt = BattleLogic_GetBattleAdopt(human, nBattleType)
  1132. if nBattleAdopt == 1 then
  1133. print("[query] nNowBattleID 为最大值 nNowBattleID = "
  1134. ..nNowBattleID.." nNowGuaJiID = "..nNowGuaJiID.." nBattleType = "..nBattleType)
  1135. msgRet.nowBattleID = configNode + 1
  1136. end
  1137. -- local nowBattleID = human.db.battleID > configNode and configNode or human.db.battleID
  1138. local nowNodeConfig = tBattleConfig.node[nNowBattleID]
  1139. if not nowNodeConfig then
  1140. print("[query] 不存在对应的当前战斗ID对应的配置 nNowBattleID = ", nNowBattleID)
  1141. return
  1142. end
  1143. local nowMapConfig = tBattleConfig.map[nowNodeConfig.mapID]
  1144. if not nowMapConfig then
  1145. print("[query] 不存在对应的当前地图对应的地图配置 nNowBattleID = "
  1146. ..nNowBattleID.." mapID ="..nowNodeConfig.mapID)
  1147. return
  1148. end
  1149. local nJudeNum = nNowGuaJiID
  1150. -- 已通关
  1151. if nBattleAdopt == 1 then
  1152. nJudeNum = configNode
  1153. else
  1154. nJudeNum = nNowBattleID - 1
  1155. end
  1156. msgRet.maxBattleID = configNode
  1157. msgRet.mapID = nowNodeConfig.mapID
  1158. msgRet.nodeID = nowNodeConfig.curLevel
  1159. msgRet.sceneID = nowNodeConfig.sceneID
  1160. msgRet.mapName = nowMapConfig.name
  1161. msgRet.nodeName = nowNodeConfig.name
  1162. msgRet.needLv = nowNodeConfig.needLv
  1163. msgRet.bg = nowMapConfig.bg
  1164. msgRet.canBattle = 0
  1165. msgRet.doubleCnt = 0
  1166. if nowNodeConfig.needLv > human.db.lv then
  1167. msgRet.canBattle = nowNodeConfig.needLv
  1168. end
  1169. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1104)
  1170. if
  1171. double and human.db.bar and human.db.bar.doubleCnt and
  1172. human.db.bar.doubleCnt <= BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
  1173. then
  1174. msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT - human.db.bar.doubleCnt
  1175. elseif double and not human.db.bar then
  1176. msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
  1177. end
  1178. msgRet.tongguan[0] = 0
  1179. local id = getTongguanIndex(human)
  1180. if id == nil then
  1181. msgRet.tongguan[0] = 0
  1182. else
  1183. msgRet.tongguan[0] = 1
  1184. local state = isGetReward(human, id)
  1185. local cf = tBattleConfig.node[id].tongguan
  1186. local net = msgRet.tongguan[1]
  1187. if state == true then
  1188. net.status = STATUS_NONE
  1189. else
  1190. net.status =(id > nJudeNum) and STATUS_CANGET or STATUS_NONE
  1191. end
  1192. net.levelName = getBattleName(human,id)
  1193. net.index = id
  1194. net.nowBattle = getBattleName(human,nJudeNum)
  1195. net.reward[0] = 0
  1196. net.heroReward[0] = 0
  1197. -- 是英雄
  1198. if cf[1][3] then
  1199. net.heroReward[0] = 1
  1200. local other = { }
  1201. other.star = cf[1][3]
  1202. HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
  1203. HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
  1204. else
  1205. net.reward[0] = 1
  1206. for i = 1, net.reward[0] do
  1207. local itemID = cf[i][1]
  1208. local itemCnt = cf[i][2]
  1209. Grid.makeItem(net.reward[i], itemID, itemCnt)
  1210. end
  1211. end
  1212. end
  1213. local outSec = 0
  1214. local tBattleOut = BattleLogic_GetBattleOut(human)
  1215. --if human.db.battleOut ~= nil then
  1216. if tBattleOut ~= nil then
  1217. local now = os.time()
  1218. outSec = now - tBattleOut.expTs1
  1219. end
  1220. local maxHangTime = getHangMaxTime(human)
  1221. msgRet.maxTime = maxHangTime
  1222. if maxHangTime >= outSec then
  1223. msgRet.time = outSec
  1224. else
  1225. msgRet.time = maxHangTime
  1226. end
  1227. -- 悬赏情报数量
  1228. msgRet.xushang = human.db.bar and human.db.bar.qingbao or 0
  1229. msgRet.xushangMax = RoleExcel.exp[human.db.lv].qingBaoMax
  1230. --秘宝对悬赏情报上限加成
  1231. local qingBaoAdd = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.XUANSHANG_QB_MAX) or 0
  1232. msgRet.xushangMax = msgRet.xushangMax + qingBaoAdd
  1233. -- 悬赏红点
  1234. msgRet.xsDot = 0
  1235. if BarTaskLogic.isDot(human) then
  1236. msgRet.xsDot = 1
  1237. end
  1238. msgRet.canMopup = 0
  1239. if TequanShopLogic.isActiveMopup(human) then
  1240. msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT_VIP and 1 or 0
  1241. else
  1242. msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT and 1 or 0
  1243. end
  1244. -- 判断额外增加的扫荡次数
  1245. --秘宝增加免费扫荡次数
  1246. local talismanAdd_dailyFeeCnt = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_SD_FREE_CNT) or 0
  1247. if 0 < (BattleLogic_GetAddFreeMopupNum(human) + talismanAdd_dailyFeeCnt) and 0 == msgRet.canMopup then
  1248. msgRet.canMopup = 1
  1249. end
  1250. local monsterOutId = nowNodeConfig.monsterOutID
  1251. if not monsterOutId then
  1252. print("[BattleLogic query] monsterOutId 为空")
  1253. return
  1254. end
  1255. local monsterConfig = MonsterExcel.monsterOut[monsterOutId]
  1256. if not monsterConfig then
  1257. print("[BattleLogic query] 获取到的 monsterConfig 为空 monsterOutId = "..monsterOutId)
  1258. return
  1259. end
  1260. fontVideoInfo(human, msgRet.videoInfo, monsterConfig)
  1261. fontExtraDataSSZH(msgRet.extraDataSSZH, nowNodeConfig.mapID, nNowBattleID, human)
  1262. msgRet.battleGameTimes = human.db.battleGameTimes or 0
  1263. -- Msg.trace(msgRet)
  1264. Msg.send(msgRet, human.fd)
  1265. hangFightQuery(human)
  1266. end
  1267. -- 获取当前地图ID
  1268. function getMapID(human, args)
  1269. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1270. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1271. if -1 >= nNowBattleID or not tBattleConfig then
  1272. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getMapID] 获取到的战斗ID或奖励配置不正确")
  1273. print("[getMapID] 获取到的战斗ID或奖励配置不正确 id = "..human.db._id)
  1274. return
  1275. end
  1276. -- local battleID = human.db.battleID
  1277. -- local config = BattleExcel.node[battleID]
  1278. local config = tBattleConfig.node[nNowBattleID]
  1279. if not config then
  1280. return
  1281. end
  1282. local mapConfig = tBattleConfig.map[config.mapID]
  1283. if not mapConfig then
  1284. return
  1285. end
  1286. return config.sceneID
  1287. end
  1288. -- 战役挂机界面查询
  1289. function onHookQuery(human)
  1290. local msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
  1291. calcBattleOut(human)
  1292. local tBattleOut = BattleLogic_GetBattleOut(human)
  1293. local tBattleConfig = BattleExcel
  1294. local nGuaJiID = human.db.guajiID
  1295. if not tBattleConfig or -1 >= nGuaJiID or not tBattleOut then
  1296. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[onHookQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1297. print("[onHookQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1298. return
  1299. end
  1300. -- local expAdd = human.db.battleOut.exp
  1301. -- local jinbiAdd = human.db.battleOut.jinbi
  1302. -- local greenExpAdd = human.db.battleOut.greenExp
  1303. -- local qingbaoAdd = human.db.battleOut.qingbao
  1304. local expAdd = tBattleOut.exp
  1305. local jinbiAdd = tBattleOut.jinbi
  1306. local greenExpAdd = tBattleOut.greenExp
  1307. local qingbaoAdd = tBattleOut.qingbao
  1308. local skip = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1309. if not skip then
  1310. expAdd = 1510
  1311. end
  1312. local items = { }
  1313. local len = #items
  1314. local tempTable = { }
  1315. if tBattleOut.items then
  1316. tempTable = Util.copyTable(tBattleOut.items)
  1317. end
  1318. tempTable[ItemDefine.ITEM_EXP_ID] = tempTable[ItemDefine.ITEM_EXP_ID] or 0
  1319. tempTable[ItemDefine.ITEM_EXP_ID] = expAdd
  1320. tempTable[ItemDefine.ITEM_JINBI_ID] = tempTable[ItemDefine.ITEM_JINBI_ID] or 0
  1321. tempTable[ItemDefine.ITEM_JINBI_ID] = jinbiAdd
  1322. tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = tempTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
  1323. tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = greenExpAdd
  1324. tempTable[ItemDefine.ITEM_QINGBAO_ID] = tempTable[ItemDefine.ITEM_QINGBAO_ID] or 0
  1325. tempTable[ItemDefine.ITEM_QINGBAO_ID] = qingbaoAdd
  1326. local list = DropExchangeLogic.getAbsCanDrop(human)
  1327. if list then
  1328. for k, v in pairs(list) do
  1329. if tempTable[k] and tempTable[k] > 0 then
  1330. len = len + 1
  1331. items[len] = { }
  1332. items[len].id = k
  1333. items[len].cnt = tempTable[k]
  1334. end
  1335. end
  1336. end
  1337. for k, v in pairs(tempTable) do
  1338. if not list or not list[k] then
  1339. len = len + 1
  1340. items[len] = { }
  1341. items[len].id = k
  1342. items[len].cnt = v
  1343. end
  1344. end
  1345. -- 发消息
  1346. local guajiID = nGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nGuaJiID
  1347. if guajiID == 0 then
  1348. return Broadcast.sendErr(human, Lang.BATTLE_GUAJI_ERR)
  1349. end
  1350. local nodeConfig = tBattleConfig.node[guajiID]
  1351. local now = os.time()
  1352. local outSec = now - human.db.battleOut.expTs1
  1353. local maxHangTime = getHangMaxTime(human)
  1354. local idx = 1
  1355. for i = 1, #items do
  1356. Grid.makeItem(msgRet.items[i], items[i].id, items[i].cnt)
  1357. end
  1358. local len = #items
  1359. if human.db.battleOut.equip then
  1360. for k, equipGrid in ipairs(tBattleOut.equip) do
  1361. if len >= 10 then
  1362. msgRet.items[0] = len
  1363. msgRet.isEnd = 0
  1364. msgRet.index = idx
  1365. msgRet.maxTime = maxHangTime
  1366. if maxHangTime >= outSec then
  1367. msgRet.time = outSec
  1368. else
  1369. msgRet.time = maxHangTime
  1370. end
  1371. local minHour = math.floor(msgRet.time / HOUR_SEC)
  1372. minHour = (minHour ~= 0) and minHour or 1
  1373. msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
  1374. msgRet.exp = nodeConfig.hangExp
  1375. msgRet.jinbi = nodeConfig.hangJinbi
  1376. msgRet.greenExp = nodeConfig.hangGreenExp
  1377. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1378. Msg.send(msgRet, human.fd)
  1379. len = 0
  1380. idx = idx + 1
  1381. msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
  1382. end
  1383. len = len + 1
  1384. Grid.makeItem(msgRet.items[len], equipGrid.id, 1, nil, equipGrid)
  1385. end
  1386. end
  1387. msgRet.isEnd = 1
  1388. msgRet.index = idx
  1389. msgRet.items[0] = len
  1390. msgRet.maxTime = maxHangTime
  1391. if maxHangTime >= outSec then
  1392. msgRet.time = outSec
  1393. else
  1394. msgRet.time = maxHangTime
  1395. end
  1396. local minHour = math.floor(msgRet.time / HOUR_SEC)
  1397. minHour = (minHour ~= 0) and minHour or 1
  1398. msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
  1399. msgRet.exp = nodeConfig.hangExp
  1400. msgRet.jinbi = nodeConfig.hangJinbi
  1401. msgRet.greenExp = nodeConfig.hangGreenExp
  1402. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1403. Msg.send(msgRet, human.fd)
  1404. end
  1405. local function isChapterDot(human, mapID)
  1406. local chapterReward = BattleLogic_GetChapterReward(human)
  1407. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1408. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1409. if not chapterReward or not tBattleConfig or -1 >= nBattleID or chapterReward[mapID] then
  1410. return false
  1411. end
  1412. local battleID = nBattleID
  1413. local battleNodeConfig = tBattleConfig.node[battleID]
  1414. if not battleNodeConfig then
  1415. if battleID == #tBattleConfig.node + 1 then
  1416. return true
  1417. else
  1418. return false
  1419. end
  1420. else
  1421. local roleMapId = battleNodeConfig.mapID
  1422. if roleMapId <= mapID then
  1423. return false
  1424. end
  1425. end
  1426. return true
  1427. end
  1428. function battleWorldMapQuery(human)
  1429. -- 先取配置
  1430. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1431. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1432. local nBattleType = BattleLogic_GetBattleType(human)
  1433. if not tBattleConfig or -1 >= nBattleID or -1 >= nBattleType then
  1434. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[battleWorldMapQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、战斗关卡ID不正确 id = "..human.db._id)
  1435. print("[battleWorldMapQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1436. return
  1437. end
  1438. local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_QUERY
  1439. local worldMapConfig = tBattleConfig.map
  1440. local battleID = nBattleID > #tBattleConfig.node and #tBattleConfig.node or nBattleID
  1441. local battleNodeConfig = tBattleConfig.node[battleID]
  1442. local len = #worldMapConfig
  1443. if not BATTLE_LEVEL_PLAYER_LIST[nBattleType] then
  1444. BATTLE_LEVEL_PLAYER_LIST[nBattleType] = {}
  1445. end
  1446. local tBattleLevelPlayerList = BATTLE_LEVEL_PLAYER_LIST[nBattleType]
  1447. for i = 1, len do
  1448. local v = worldMapConfig[i]
  1449. msgRet.worldMap[i].mapID = i
  1450. msgRet.worldMap[i].mapName = v.name or ""
  1451. msgRet.worldMap[i].mapBuild = v.build or 0
  1452. msgRet.worldMap[i].mapBg = v.bg or 0
  1453. msgRet.worldMap[i].mapPos[0] = 2
  1454. msgRet.worldMap[i].mapPos[1] = v.pos[1]
  1455. msgRet.worldMap[i].mapPos[2] = v.pos[2]
  1456. msgRet.worldMap[i].status =(battleNodeConfig.mapID >= i) and 1 or 0
  1457. msgRet.worldMap[i].story = v.des or ""
  1458. if battleNodeConfig.mapID == i then
  1459. msgRet.worldMap[i].maxLevel = battleNodeConfig.maxLevel
  1460. msgRet.worldMap[i].curLevel = battleNodeConfig.curLevel
  1461. else
  1462. msgRet.worldMap[i].maxLevel = 0
  1463. msgRet.worldMap[i].curLevel = 0
  1464. end
  1465. local reward = v.reward
  1466. local l = 0
  1467. msgRet.worldMap[i].chapterReward[0] = #reward
  1468. for _, rewardData in pairs(reward) do
  1469. l = l + 1
  1470. Grid.makeItem(msgRet.worldMap[i].chapterReward[l], rewardData[1], rewardData[2])
  1471. end
  1472. msgRet.worldMap[i].chapterDot = 0
  1473. if isChapterDot(human, i) then
  1474. msgRet.worldMap[i].chapterDot = 1
  1475. end
  1476. local cnt = 0
  1477. -- BATTLE_LEVEL_PLAYER_LIST[i] = BATTLE_LEVEL_PLAYER_LIST[i] or { }
  1478. tBattleLevelPlayerList[i] = tBattleLevelPlayerList[i] or { }
  1479. -- for s, t in pairs(BATTLE_LEVEL_PLAYER_LIST[i]) do
  1480. for s, t in pairs(tBattleLevelPlayerList[i]) do
  1481. cnt = cnt + 1
  1482. RoleLogic.makeRoleBase(t, msgRet.worldMap[i].roleList[cnt])
  1483. if cnt >= 3 then
  1484. break
  1485. end
  1486. end
  1487. msgRet.worldMap[i].roleList[0] = cnt
  1488. end
  1489. msgRet.worldMap[0] = len
  1490. Msg.send(msgRet, human.fd)
  1491. end
  1492. function battleNodeQuery(human, mapID)
  1493. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1494. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1495. if not tBattleConfig or -1 >= nBattleID then
  1496. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[battleNodeQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、战斗关卡ID不正确 id = "..human.db._id)
  1497. print("[battleNodeQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1498. return
  1499. end
  1500. local msgRet = Msg.gc.GC_BATTLE_NODE_QUERY
  1501. local nodeConfig = tBattleConfig.node
  1502. local lenConfig = #nodeConfig
  1503. local len = 0
  1504. msgRet.battleID = nBattleID or 0
  1505. for i = 1, lenConfig do
  1506. local v = nodeConfig[i]
  1507. if v.mapID == mapID then
  1508. len = len + 1
  1509. msgRet.nodeInfo[len].nodeName = v.name
  1510. msgRet.nodeInfo[len].battleID = i
  1511. msgRet.nodeInfo[len].needLv = v.needLv
  1512. msgRet.nodeInfo[len].needZDL = v.needZDL
  1513. msgRet.nodeInfo[len].hasSuipian = v.hasSuipian
  1514. end
  1515. end
  1516. msgRet.nodeInfo[0] = len
  1517. Msg.send(msgRet, human.fd)
  1518. end
  1519. function initBattleOut(human, now)
  1520. if human.db.battleOut then
  1521. return
  1522. end
  1523. if false == BattleLogic_InitAllBattleOut(human, now) then
  1524. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "initBattleOut 初始化挂机奖励表失败 id = "
  1525. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1526. return
  1527. end
  1528. -- human.db.battleOut = { }
  1529. -- human.db.battleOut.expTs1 = now
  1530. -- -- 经验开始产出时间戳
  1531. -- human.db.battleOut.expTs2 = now
  1532. -- -- 经验产出结算时间戳
  1533. -- human.db.battleOut.itemTs1 = now
  1534. -- -- 道具产出时间戳
  1535. -- human.db.battleOut.itemTs2 = now
  1536. -- -- 道具产出结算时间戳
  1537. -- human.db.battleOut.exp = 0
  1538. -- human.db.battleOut.jinbi = 0
  1539. -- human.db.battleOut.greenExp = 0
  1540. -- human.db.battleOut.qingbao = 0
  1541. -- human.db.battleOut.items = nil
  1542. -- -- 产出的待收获的战利品
  1543. -- human.db.battleOut.equip = nil
  1544. -- -- 产出的待收获的装备
  1545. end
  1546. function calcBattleOut(human,isDiamond)
  1547. local now = os.time()
  1548. initBattleOut(human, now)
  1549. calcBattleExpOut(human, now)
  1550. calcBattleItemOut(human, now)
  1551. if isDiamond then -- 钻石消耗 所有产出翻1.5倍
  1552. local tBattleOut = BattleLogic_GetBattleOut(human)
  1553. if not tBattleOut then
  1554. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleOut 获取挂机奖励列表失败 id = "
  1555. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1556. return
  1557. end
  1558. -- human.db.battleOut.exp = math.floor(human.db.battleOut.exp * DIAMOND_ADDITION)
  1559. -- human.db.battleOut.jinbi = math.floor(human.db.battleOut.jinbi * DIAMOND_ADDITION)
  1560. -- human.db.battleOut.greenExp = math.floor(human.db.battleOut.greenExp * DIAMOND_ADDITION)
  1561. -- human.db.battleOut.qingbao = math.floor(human.db.battleOut.qingbao * DIAMOND_ADDITION)
  1562. -- local items = human.db.battleOut.items or {}
  1563. tBattleOut.exp = math.floor(tBattleOut.exp * DIAMOND_ADDITION)
  1564. tBattleOut.jinbi = math.floor(tBattleOut.jinbi * DIAMOND_ADDITION)
  1565. tBattleOut.greenExp = math.floor(tBattleOut.greenExp * DIAMOND_ADDITION)
  1566. tBattleOut.qingbao = math.floor(tBattleOut.qingbao * DIAMOND_ADDITION)
  1567. local items = tBattleOut.items or {}
  1568. for id,cnt in pairs(items) do
  1569. items[id] = math.floor(cnt * DIAMOND_ADDITION)
  1570. end
  1571. -- local equipList = human.db.battleOut.equip or {}
  1572. local equipList = tBattleOut.equip or {}
  1573. local equipMap = {}
  1574. for _,equip in ipairs(equipList) do
  1575. equipMap[equip.id] = equipMap[equip.id] or 0
  1576. equipMap[equip.id] = equipMap[equip.id] + 1
  1577. end
  1578. for id,cnt in pairs(equipMap) do
  1579. local count = math.floor(cnt * DIAMOND_ADDITION)
  1580. for i = cnt,count do
  1581. local equipGrid = EquipLogic.makeEquip(id)
  1582. equipList[#equipList + 1] = equipGrid
  1583. end
  1584. end
  1585. end
  1586. end
  1587. -- 获取正确的剩余可收益的结算时间
  1588. function getSurMaxHangTime(maxHangTime, ts1, now)
  1589. if ts1 + maxHangTime > now then
  1590. return now
  1591. else
  1592. return ts1 + maxHangTime
  1593. end
  1594. end
  1595. -- function calcBattleExpOut(human, now)
  1596. -- local maxHangTime = getHangMaxTime(human)
  1597. -- if human.db.battleOut.expTs2 - human.db.battleOut.expTs1 >= maxHangTime then
  1598. -- return
  1599. -- end
  1600. -- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.expTs1, now)
  1601. -- local outSec = outTime - human.db.battleOut.expTs2
  1602. -- local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
  1603. -- if outCnt < 1 then
  1604. -- return
  1605. -- end
  1606. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  1607. -- if guajiID == 0 then
  1608. -- return
  1609. -- end
  1610. -- local nowNodeConfig = BattleExcel.node[guajiID]
  1611. -- human.db.battleOut.expTs2 = human.db.battleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
  1612. -- if now - human.db.battleOut.expTs1 >= maxHangTime then
  1613. -- human.db.battleOut.expTs2 = now
  1614. -- end
  1615. -- local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  1616. -- local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  1617. -- local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  1618. -- local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  1619. -- local exp = nowNodeConfig.hangExp
  1620. -- local jinbi = nowNodeConfig.hangJinbi
  1621. -- local greenExp = nowNodeConfig.hangGreenExp
  1622. -- local qingbao = nowNodeConfig.hangQingbao
  1623. -- human.db.battleOut.exp = human.db.battleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
  1624. -- human.db.battleOut.jinbi = human.db.battleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
  1625. -- human.db.battleOut.greenExp = human.db.battleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
  1626. -- human.db.battleOut.qingbao = human.db.battleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
  1627. -- end
  1628. function calcBattleExpOut(human, now)
  1629. local tBattleOut = BattleLogic_GetBattleOut(human)
  1630. if not tBattleOut then
  1631. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleExpOut 获取挂机奖励列表失败 id = "
  1632. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1633. return
  1634. end
  1635. local maxHangTime = getHangMaxTime(human)
  1636. if tBattleOut.expTs2 - tBattleOut.expTs1 >= maxHangTime then
  1637. return
  1638. end
  1639. local outTime = getSurMaxHangTime(maxHangTime, tBattleOut.expTs1, now)
  1640. local outSec = outTime - tBattleOut.expTs2
  1641. local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
  1642. if outCnt < 1 then
  1643. return
  1644. end
  1645. local tBattleNodeConfig = BattleExcel
  1646. local nGuaJiID = human.db.guajiID
  1647. if not tBattleNodeConfig or 0 > nGuaJiID then
  1648. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleExpOut 获取到的配置表不正确或挂机ID不正确 id = "
  1649. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1650. return
  1651. end
  1652. local guajiID = nGuaJiID > #tBattleNodeConfig.node and #tBattleNodeConfig.node or nGuaJiID
  1653. if guajiID == 0 then
  1654. return
  1655. end
  1656. local nowNodeConfig = tBattleNodeConfig.node[guajiID]
  1657. tBattleOut.expTs2 = tBattleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
  1658. if now - tBattleOut.expTs1 >= maxHangTime then
  1659. tBattleOut.expTs2 = now
  1660. end
  1661. local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  1662. local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  1663. local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  1664. local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  1665. --秘宝方面的加成
  1666. local talismanAdd_qb = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_QB) or 0) / 100
  1667. local talismanAdd_hero_exp = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_HERO_EXP) or 0) / 100
  1668. local exp = nowNodeConfig.hangExp
  1669. local jinbi = nowNodeConfig.hangJinbi
  1670. local greenExp = nowNodeConfig.hangGreenExp
  1671. local qingbao = nowNodeConfig.hangQingbao
  1672. tBattleOut.exp = tBattleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
  1673. tBattleOut.jinbi = tBattleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
  1674. tBattleOut.greenExp = tBattleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
  1675. tBattleOut.qingbao = tBattleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
  1676. tBattleOut.qingbao = tBattleOut.qingbao + math.ceil(tBattleOut.qingbao * talismanAdd_qb)
  1677. tBattleOut.greenExp = tBattleOut.greenExp + math.ceil(tBattleOut.greenExp * talismanAdd_hero_exp)
  1678. end
  1679. -- 根据时间计算道具产出
  1680. local ITEM_OUT_LIST = { }
  1681. function getItemOutsByTime(config, sec)
  1682. Util.cleanTable(ITEM_OUT_LIST)
  1683. local outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1684. if outCnt < 1 then
  1685. return ITEM_OUT_LIST
  1686. end
  1687. -- 普通掉落
  1688. local dropID = config.dropID
  1689. local dropConfig = DropExcel.dropBattle[dropID]
  1690. local weightSum = 0
  1691. for i = 1, #dropConfig.dropRule do
  1692. local tempConfig = dropConfig.dropRule[i]
  1693. weightSum = weightSum + tempConfig[4]
  1694. end
  1695. for i = 1, outCnt do
  1696. local itemID, itemCnt = randItemOut(dropConfig.dropRule, weightSum)
  1697. if itemID and itemCnt and itemCnt > 0 then
  1698. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1699. end
  1700. end
  1701. for i = 1, #dropConfig.dropRule2 do
  1702. local tempConfig = dropConfig.dropRule2[i]
  1703. local itemID = tempConfig[1]
  1704. local itemMin = tempConfig[2]
  1705. local itemMax = tempConfig[3]
  1706. local itemCnt = math.random(itemMin, itemMax) * outCnt
  1707. if itemCnt > 0 then
  1708. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1709. end
  1710. end
  1711. -- 三小时掉落
  1712. outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD_2)
  1713. if outCnt < 1 then
  1714. return ITEM_OUT_LIST
  1715. end
  1716. weightSum = 0
  1717. for i = 1, #dropConfig.dropRule3 do
  1718. local tempConfig = dropConfig.dropRule3[i]
  1719. weightSum = weightSum + tempConfig[4]
  1720. end
  1721. for i = 1, outCnt do
  1722. local itemID, itemCnt = randItemOut(dropConfig.dropRule3, weightSum)
  1723. if itemID and itemCnt and itemCnt > 0 then
  1724. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1725. end
  1726. end
  1727. return ITEM_OUT_LIST
  1728. end
  1729. -- function calcBattleItemOut(human, now,isDiamond)
  1730. -- local maxHangTime = getHangMaxTime(human)
  1731. -- if human.db.battleOut.itemTs2 - human.db.battleOut.itemTs1 >= maxHangTime then
  1732. -- return
  1733. -- end
  1734. -- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.itemTs1, now)
  1735. -- local outSec = outTime - human.db.battleOut.itemTs2
  1736. -- local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1737. -- if outCnt < 1 then
  1738. -- return
  1739. -- end
  1740. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  1741. -- if guajiID == 0 then
  1742. -- return
  1743. -- end
  1744. -- local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
  1745. -- human.db.battleOut.itemTs2 = human.db.battleOut.itemTs2 + sec
  1746. -- if now - human.db.battleOut.itemTs1 >= maxHangTime then
  1747. -- human.db.battleOut.itemTs2 = now
  1748. -- end
  1749. -- local nodeConfig = BattleExcel.node[guajiID]
  1750. -- local items = getItemOutsByTime(nodeConfig, sec)
  1751. -- for itemID, itemCnt in pairs(items) do
  1752. -- -- 判定是否是装备
  1753. -- if ItemDefine.isEquip(itemID) then
  1754. -- -- 生成装备
  1755. -- local equipGrid = EquipLogic.makeEquip(itemID)
  1756. -- if equipGrid then
  1757. -- human.db.battleOut.equip = human.db.battleOut.equip or { }
  1758. -- human.db.battleOut.equip[#human.db.battleOut.equip + 1] = equipGrid
  1759. -- end
  1760. -- else
  1761. -- human.db.battleOut.items = human.db.battleOut.items or { }
  1762. -- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] or 0
  1763. -- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] + itemCnt
  1764. -- end
  1765. -- end
  1766. -- DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, human.db.battleOut)
  1767. -- end
  1768. function calcBattleItemOut(human, now,isDiamond)
  1769. local tBattleOut = BattleLogic_GetBattleOut(human)
  1770. if not tBattleOut then
  1771. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleItemOut 获取挂机奖励列表失败 id = "
  1772. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1773. return
  1774. end
  1775. local maxHangTime = getHangMaxTime(human)
  1776. if tBattleOut.itemTs2 - tBattleOut.itemTs1 >= maxHangTime then
  1777. return
  1778. end
  1779. local outTime = getSurMaxHangTime(maxHangTime, tBattleOut.itemTs1, now)
  1780. local outSec = outTime - tBattleOut.itemTs2
  1781. local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1782. if outCnt < 1 then
  1783. return
  1784. end
  1785. local tBattleNodeConfig = BattleExcel
  1786. local nGuaJiID = human.db.guajiID
  1787. if not tBattleNodeConfig or 0 > nGuaJiID then
  1788. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleItemOut 获取到的配置表不正确或挂机ID不正确 id = "
  1789. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1790. return
  1791. end
  1792. local guajiID = nGuaJiID > #tBattleNodeConfig.node and #tBattleNodeConfig.node or nGuaJiID
  1793. if guajiID == 0 then
  1794. return
  1795. end
  1796. local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
  1797. tBattleOut.itemTs2 = tBattleOut.itemTs2 + sec
  1798. if now - tBattleOut.itemTs1 >= maxHangTime then
  1799. tBattleOut.itemTs2 = now
  1800. end
  1801. local talismanAdd_zs = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_ZS) or 0) / 100
  1802. local nodeConfig = tBattleNodeConfig.node[guajiID]
  1803. local items = getItemOutsByTime(nodeConfig, sec)
  1804. for itemID, itemCnt in pairs(items) do
  1805. -- 判定是否是装备
  1806. if ItemDefine.isEquip(itemID) then
  1807. -- 生成装备
  1808. local equipGrid = EquipLogic.makeEquip(itemID)
  1809. if equipGrid then
  1810. tBattleOut.equip = tBattleOut.equip or { }
  1811. tBattleOut.equip[#tBattleOut.equip + 1] = equipGrid
  1812. end
  1813. else
  1814. tBattleOut.items = tBattleOut.items or { }
  1815. tBattleOut.items[itemID] = tBattleOut.items[itemID] or 0
  1816. if itemID == ItemDefine.ITEM_ZUANSHI_ID and talismanAdd_zs > 0 then
  1817. itemCnt = itemCnt + math.ceil(itemCnt * talismanAdd_zs)
  1818. end
  1819. tBattleOut.items[itemID] = tBattleOut.items[itemID] + itemCnt
  1820. end
  1821. end
  1822. DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, tBattleOut)
  1823. end
  1824. local function hangExpGet(human,isDiamond)
  1825. local tBattleOut = BattleLogic_GetBattleOut(human)
  1826. if not tBattleOut then
  1827. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangExpGet 获取挂机奖励列表失败 id = "
  1828. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1829. return
  1830. end
  1831. local needDiamond = 0
  1832. -- 是否消耗钻石
  1833. if isDiamond then
  1834. local now = os.time()
  1835. local outSec = now - tBattleOut.expTs1
  1836. local maxHangTime = getHangMaxTime(human)
  1837. outSec = outSec > maxHangTime and maxHangTime or outSec
  1838. local minHour = math.floor(outSec / HOUR_SEC)
  1839. minHour = (minHour ~= 0) and minHour or 1
  1840. local diamondCnt = minHour * DIAMOND_COST_PER_HOUR
  1841. if not ObjHuman.checkRMB(human,diamondCnt) then
  1842. return
  1843. end
  1844. needDiamond = -diamondCnt
  1845. end
  1846. print("==================== needDiamond is ",needDiamond)
  1847. calcBattleOut(human,isDiamond)
  1848. if tBattleOut.exp == 0 then
  1849. return 1
  1850. end
  1851. local jinbiAdd = tBattleOut.jinbi
  1852. if not ObjHuman.canAddJinbi(human, jinbiAdd) then
  1853. return 2
  1854. end
  1855. -- 检测装备数量
  1856. if tBattleOut.equip then
  1857. local equipCnt = #tBattleOut.equip
  1858. if not EquipLogic.checkEmptyCnt(human, equipCnt) then
  1859. return
  1860. end
  1861. end
  1862. local items = { }
  1863. local len = #items
  1864. local maxHangTime = getHangMaxTime(human)
  1865. if tBattleOut.expTs2 - tBattleOut.expTs1 >= maxHangTime then
  1866. local now = os.time()
  1867. tBattleOut.expTs2 = now
  1868. end
  1869. if tBattleOut.itemTs2 - tBattleOut.itemTs1 >= maxHangTime then
  1870. local now = os.time()
  1871. tBattleOut.itemTs2 = now
  1872. end
  1873. tBattleOut.itemTs1 = tBattleOut.itemTs2
  1874. -- 改db
  1875. local tempTable = tBattleOut.items or { }
  1876. tBattleOut.items = nil
  1877. for k, v in pairs(tempTable) do
  1878. len = len + 1
  1879. items[len] = { }
  1880. items[len].id = k
  1881. items[len].cnt = v
  1882. end
  1883. tBattleOut.expTs1 = tBattleOut.expTs2
  1884. local expAdd = tBattleOut.exp
  1885. local greenExpAdd = tBattleOut.greenExp
  1886. local qingbaoAdd = tBattleOut.qingbao
  1887. -- 新手指引 强制经验
  1888. local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1889. if not flag then
  1890. expAdd = 1510
  1891. end
  1892. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1893. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_GUAJI)
  1894. tBattleOut.exp = 0
  1895. tBattleOut.jinbi = 0
  1896. tBattleOut.greenExp = 0
  1897. tBattleOut.qingbao = 0
  1898. len = len + 1
  1899. items[len] = { }
  1900. items[len].id = ItemDefine.ITEM_EXP_ID
  1901. items[len].cnt = expAdd
  1902. len = len + 1
  1903. items[len] = { }
  1904. items[len].id = ItemDefine.ITEM_JINBI_ID
  1905. items[len].cnt = jinbiAdd
  1906. len = len + 1
  1907. items[len] = { }
  1908. items[len].id = ItemDefine.ITEM_GREEN_EXP_ID
  1909. items[len].cnt = greenExpAdd
  1910. len = len + 1
  1911. items[len] = { }
  1912. items[len].id = ItemDefine.ITEM_QINGBAO_ID
  1913. items[len].cnt = qingbaoAdd
  1914. -- 给道具
  1915. for i = 1, #items do
  1916. local tempID = items[i].id
  1917. local tempCnt = items[i].cnt
  1918. BagLogic.addItem(human, tempID, tempCnt, "battle")
  1919. end
  1920. -- 给装备
  1921. if tBattleOut.equip then
  1922. for k, equipGrid in ipairs(tBattleOut.equip) do
  1923. EquipLogic.addByEquipGrid(human, equipGrid, "battle", true)
  1924. end
  1925. tBattleOut.equip = nil
  1926. end
  1927. if needDiamond < 0 then
  1928. ObjHuman.decZuanshi(human,needDiamond,"battle")
  1929. end
  1930. return 0, items
  1931. end
  1932. -- 获取挂机收益
  1933. function hangGet(human,isDiamond)
  1934. local ret, items = hangExpGet(human,false)
  1935. if ret == 1 then
  1936. return Broadcast.sendErr(human, Lang.BATTLE_HANG_GET_EXP_ERR_NONE)
  1937. elseif ret == 2 then
  1938. return Broadcast.sendErr(human, Lang.COMMON_ADD_JINBI_LIMIT)
  1939. elseif ret == 0 then
  1940. query(human)
  1941. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  1942. end
  1943. end
  1944. -- 挂机节点设置
  1945. function nodeSet(human, battleID)
  1946. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1947. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1948. if not tBattleConfig or -1 >= nNowBattleID then
  1949. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangExpGet 获取挂机奖励列表失败 id = "
  1950. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1951. print("[nodeSet] 获取不到战斗配置")
  1952. return
  1953. end
  1954. local nodeConfig = tBattleConfig.node[battleID]
  1955. if nodeConfig == nil then
  1956. return
  1957. end
  1958. -- 前置条件判断
  1959. if battleID > nNowBattleID then
  1960. return Broadcast.sendErr(human, Lang.BATTLE_ID_OVER)
  1961. end
  1962. -- 等级判断
  1963. if human.db.lv < nodeConfig.needLv then
  1964. return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, nodeConfig.needLv))
  1965. end
  1966. calcBattleOut(human)
  1967. print("[nodeSet] 玩家进行了挂机节点设置 battleID = ".. battleID)
  1968. BattleLogic_SetBattleGuaJiID(human ,battleID)
  1969. --human.db.guajiID = battleID
  1970. setBattleID(human, battleID)
  1971. Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
  1972. query(human)
  1973. end
  1974. -- 挂机节点详细信息查询
  1975. function nodeDetailQuery(human, battleID)
  1976. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1977. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1978. if not tBattleConfig or -1 >= nNowBattleID then
  1979. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "nodeDetailQuery 获取挂机奖励列表失败 id = "
  1980. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1981. print("[nodeDetailQuery] 获取不到战斗配置")
  1982. return
  1983. end
  1984. -- local nodeConfig = BattleExcel.node[battleID]
  1985. local nodeConfig = tBattleConfig.node[battleID]
  1986. if nodeConfig == nil then
  1987. return
  1988. end
  1989. local msgRet = Msg.gc.GC_BATTLE_NODE_DETAIL_QUERY
  1990. msgRet.battleID = battleID
  1991. msgRet.exp = nodeConfig.hangExp
  1992. msgRet.jinbi = nodeConfig.hangJinbi
  1993. msgRet.greenExp = nodeConfig.hangGreenExp
  1994. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1995. msgRet.nodeName = getBattleName(human, battleID)
  1996. local dropID = nodeConfig.dropID
  1997. local dropConfig = DropExcel.dropBattle[dropID]
  1998. local dropCnt = 0
  1999. local list = DropExchangeLogic.getAbsCanDrop(human)
  2000. if list then
  2001. for k, v in pairs(list) do
  2002. dropCnt = dropCnt + 1
  2003. Grid.makeItem(msgRet.items[dropCnt], k, v)
  2004. end
  2005. end
  2006. for i = 1, #dropConfig.dropRule do
  2007. local tempConfig = dropConfig.dropRule[i]
  2008. local itemID = tempConfig[1]
  2009. local itemCnt = tempConfig[3]
  2010. local itemRate = tempConfig[4]
  2011. if itemCnt > 0 and itemRate > 0 then
  2012. dropCnt = dropCnt + 1
  2013. Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
  2014. end
  2015. end
  2016. for i = 1, #dropConfig.dropRule3 do
  2017. local tempConfig = dropConfig.dropRule3[i]
  2018. local itemID = tempConfig[1]
  2019. local itemCnt = tempConfig[3]
  2020. local itemRate = tempConfig[4]
  2021. if itemCnt > 0 and itemRate > 0 then
  2022. dropCnt = dropCnt + 1
  2023. Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
  2024. end
  2025. end
  2026. msgRet.items[0] = dropCnt
  2027. Msg.send(msgRet, human.fd)
  2028. end
  2029. -- 挑战当前挂机节点
  2030. function fight(human)
  2031. local battleID = BattleLogic_GetBattleBattleID(human)
  2032. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2033. if not tBattleConfig or -1 >= battleID then
  2034. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "nodeDetailQuery 获取挂机奖励列表失败 id = "
  2035. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2036. print("[nodeDetailQuery] 获取不到战斗配置")
  2037. return
  2038. end
  2039. -- local battleID = human.db.battleID
  2040. -- if BattleExcel.node[human.db.battleID] == nil then
  2041. if tBattleConfig.node[battleID] == nil then
  2042. local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
  2043. msgRet.panelIDs[0] = 1
  2044. msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
  2045. Msg.send(msgRet, human.fd)
  2046. return Broadcast.sendErr(human, Lang.BATTLE_MAX_LEVEL)
  2047. end
  2048. -- if human.db.lv < BattleExcel.node[human.db.battleID].needLv then
  2049. if human.db.lv < tBattleConfig.node[battleID].needLv then
  2050. local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
  2051. msgRet.panelIDs[0] = 1
  2052. msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
  2053. Msg.send(msgRet, human.fd)
  2054. return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, tBattleConfig.node[battleID].needLv))
  2055. end
  2056. local config = tBattleConfig.node[battleID]
  2057. local mapConfig = tBattleConfig.map[config.mapID]
  2058. local monsterOutID = config.monsterOutID
  2059. local mapID = mapConfig.bg
  2060. CombatLogic.combatBegin(human, config.sceneID, monsterOutID, CombatDefine.COMBAT_TYPE1, battleID)
  2061. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE)
  2062. end
  2063. function onFightEnd(human, result, fightTypeID, param1, combatInfo)
  2064. -- 设置一些战斗结算信息
  2065. combatInfo.defender.name = Util.format(Lang.COMBAT_BATTLE_DEFEND_NAME, param1)
  2066. if CombatDefine.RESULT_WIN ~= result then
  2067. return
  2068. end
  2069. local nBattleType = BattleLogic_GetBattleType(human)
  2070. local guajiID = BattleLogic_GetBattleGuaJiID(human)
  2071. local battleID = BattleLogic_GetBattleBattleID(human)
  2072. if EliteDefine.COPY_ELITE_ERROR == nBattleType or -1 >= guajiID or -1 >= battleID then
  2073. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "onFightEnd 获取战斗类型、挂机ID、战斗关卡ID失败 id = "
  2074. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2075. print("[onFightEnd] 获取战斗类型、挂机ID、战斗关卡ID失败")
  2076. return
  2077. end
  2078. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2079. if not tBattleConfig then
  2080. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "onFightEnd 获取战斗配置失败 id = "
  2081. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2082. print("[onFightEnd] 获取战斗配置失败")
  2083. return
  2084. end
  2085. -- local guajiID = human.db.guajiID
  2086. -- local battleID = human.db.battleID
  2087. if battleID ~= param1 then
  2088. return
  2089. end
  2090. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  2091. MainDianLogic.MaiDian_Begin(human, MaiDianDefine.MAIDIAN_TYPE_BATTLE, {nValue = battleID})
  2092. end
  2093. local nAllFightLen = #tBattleConfig.node
  2094. local nextGuajiID = (guajiID + 1) > nAllFightLen and nAllFightLen or guajiID + 1
  2095. local nextBattleID = (battleID + 1) > nAllFightLen and nAllFightLen or battleID + 1
  2096. -- local nextBattleConfig = BattleExcel.node[nextBattleID]
  2097. -- local config = BattleExcel.node[battleID]
  2098. if (battleID + 1) > nAllFightLen then
  2099. BattleLogic_SetBattleAdopt(human, nBattleType, 1)
  2100. end
  2101. local nextBattleConfig = tBattleConfig.node[nextBattleID]
  2102. local config = tBattleConfig.node[battleID]
  2103. if not BATTLE_LEVEL_PLAYER_LIST[nBattleType] then
  2104. BATTLE_LEVEL_PLAYER_LIST[nBattleType] = {}
  2105. end
  2106. local tBattleLevelPlayerList = BATTLE_LEVEL_PLAYER_LIST[nBattleType]
  2107. -- 如果过大关卡
  2108. if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2109. -- 清除记录
  2110. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2111. tBattleLevelPlayerList[config.mapID][human.db._id] = nil
  2112. -- 增加新纪录
  2113. tBattleLevelPlayerList[nextBattleConfig.mapID] = tBattleLevelPlayerList[nextBattleConfig.mapID] or { }
  2114. tBattleLevelPlayerList[nextBattleConfig.mapID][human.db._id] = { }
  2115. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[nextBattleConfig.mapID][human.db._id])
  2116. else
  2117. if config.mapID == 1 then
  2118. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2119. if tBattleLevelPlayerList[config.mapID][human.db._id] == nil then
  2120. -- 增加新纪录
  2121. tBattleLevelPlayerList[config.mapID][human.db._id] = { }
  2122. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[config.mapID][human.db._id])
  2123. end
  2124. else
  2125. if not tBattleLevelPlayerList[config.mapID] or not tBattleLevelPlayerList[config.mapID][human.db._id] then
  2126. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2127. tBattleLevelPlayerList[config.mapID][human.db._id] = { }
  2128. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[config.mapID][human.db._id])
  2129. end
  2130. end
  2131. end
  2132. -- -- 如果过大关卡
  2133. -- if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2134. -- -- 清除记录
  2135. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2136. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = nil
  2137. -- -- 增加新纪录
  2138. -- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] = BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] or { }
  2139. -- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id] = { }
  2140. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id])
  2141. -- else
  2142. -- if config.mapID == 1 then
  2143. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2144. -- if BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] == nil then
  2145. -- -- 增加新纪录
  2146. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
  2147. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
  2148. -- end
  2149. -- else
  2150. -- if not BATTLE_LEVEL_PLAYER_LIST[config.mapID] or not BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] then
  2151. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2152. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
  2153. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
  2154. -- end
  2155. -- end
  2156. -- end
  2157. BattleLogic_SetBattleBattleID(human, nextBattleID)
  2158. --增加小游戏次数
  2159. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  2160. if config and type(config.gameType) == "number" and config.gameType == 1 then
  2161. human.db.battleGameTimes = (human.db.battleGameTimes or 0) + 1
  2162. end
  2163. end
  2164. -- human.db.battleID = battleID + 1
  2165. -- 通过第10关,默认开启二倍速
  2166. if nextBattleID == 10 and EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  2167. human.db.combatSpeed = 2
  2168. end
  2169. combatInfo.attacker.oldLv = human.db.lv
  2170. -- 给奖励
  2171. combatInfo.rewardItem = { }
  2172. for i = 1, #config.winReward do
  2173. local itemID = config.winReward[i][1]
  2174. local itemCnt = config.winReward[i][2]
  2175. -- 装备不在这显示
  2176. combatInfo.rewardItem[i] = combatInfo.rewardItem[i] or { }
  2177. combatInfo.rewardItem[i] = { itemID, itemCnt }
  2178. BagLogic.addItem(human, itemID, itemCnt, "battle_win")
  2179. end
  2180. combatInfo.attacker.lv = human.db.lv
  2181. combatInfo.getEquip = human.getEquip
  2182. human.getEquip = nil
  2183. -- TODO:记录主线关卡
  2184. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, human.db._id, human.db.account, human.db.name, human.db.battleID)
  2185. if nBattleType == EliteDefine.COPY_ELITE_NORMAL then
  2186. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2187. GuideLogic.onCallback(human)
  2188. JibanLogic.onCallback(human, 1, battleID)
  2189. TuiSongLiBao.tuiSongLiBaoOnTask(
  2190. human,
  2191. TuiSongLiBao.TUISONGLIBAOTASK_ZHENGZHAN,
  2192. -- human.db.guajiID - 1,
  2193. -- human.db.guajiID - 2
  2194. guajiID - 1,
  2195. guajiID - 2
  2196. )
  2197. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_1, nextGuajiID)
  2198. MengxinLogic.onCallBack(human, MengxinLogic.MX_TASK_TYPE_1, nextGuajiID)
  2199. for k, v in pairs(KingWorldLogic.funcID) do
  2200. YunYingLogic.updateIcon(KingWorldLogic.YYInfo[k], human)
  2201. break
  2202. end
  2203. end
  2204. -- 存储战斗记录
  2205. local videoUuid = CombatVideo.saveBattleVideo(human.db._id, combatInfo)
  2206. human.db.battleVideoUuid = videoUuid
  2207. BattleDBLogic.updateBattleDB(combatInfo.attacker, battleID, combatInfo, videoUuid, nBattleType)
  2208. if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2209. -- 新的地图
  2210. -- 通知客户端
  2211. Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
  2212. end
  2213. BattleLogic_SetBattleGuaJiID(human, nextGuajiID)
  2214. --human.db.guajiID = nextGuajiID
  2215. if nextBattleConfig then
  2216. setBattleID(human, nextGuajiID)
  2217. end
  2218. local showNext = 1
  2219. -- if BattleExcel.node[human.db.battleID] and human.db.lv < BattleExcel.node[human.db.battleID].needLv then
  2220. if tBattleConfig.node[nextBattleID] and human.db.lv < tBattleConfig.node[nextBattleID].needLv then
  2221. showNext = 2
  2222. end
  2223. if human.db.lv < 5 then
  2224. showNext = 0
  2225. end
  2226. -- nextBattleConfig = BattleExcel.node[human.db.battleID]
  2227. nextBattleConfig = tBattleConfig.node[nextBattleID]
  2228. if not nextBattleConfig then
  2229. showNext = 0
  2230. end
  2231. if battleID == 3 then
  2232. showNext = 0
  2233. end
  2234. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2235. -- 额外奖励
  2236. local needLevel, itemName = getNextRewardName(human)
  2237. if needLevel ~= nil then
  2238. local tb = { needLevel, Lang.BATTLE_FIGHT_GUAN, "|", itemName, "|", showNext }
  2239. local str = table.concat(tb)
  2240. combatInfo.endParam = str
  2241. else
  2242. local tb = { showNext }
  2243. local str = table.concat(tb)
  2244. combatInfo.endParam = str
  2245. end
  2246. -- 触发事件
  2247. GiftLogic.trigger(human,PRINCIPAL_LINE_EVNET,{id = battleID})
  2248. WarOrder.trigger(human,BATTLE_ORDER_TYPE)
  2249. end
  2250. function setBattleID(human, guajiID)
  2251. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2252. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2253. if -1 >= nNowGuaJiID or not tBattleConfig then
  2254. return
  2255. end
  2256. -- if guajiID > human.db.guajiID and human.db.guajiID ~= 0 then
  2257. if guajiID > nNowGuaJiID and nNowGuaJiID ~= 0 then
  2258. -- 下发挂机收益升级提示
  2259. local msgRet = Msg.gc.GC_BATTLE_REWARD_UP
  2260. Grid.makeItem(msgRet.itemExp, ItemDefine.ITEM_EXP_ID, 1)
  2261. Grid.makeItem(msgRet.itemJinbi, ItemDefine.ITEM_JINBI_ID, 1)
  2262. Grid.makeItem(msgRet.itemGreenExp, ItemDefine.ITEM_GREEN_EXP_ID, 1)
  2263. Grid.makeItem(msgRet.itemQingbao, ItemDefine.ITEM_QINGBAO_ID, 1)
  2264. -- local oldConfig = BattleExcel.node[human.db.guajiID]
  2265. -- local newConfig = BattleExcel.node[guajiID]
  2266. local oldConfig = tBattleConfig.node[human.db.guajiID]
  2267. local newConfig = tBattleConfig.node[guajiID]
  2268. msgRet.expOld = oldConfig.hangExp
  2269. msgRet.expNew = newConfig.hangExp
  2270. msgRet.jinbiOld = oldConfig.hangJinbi
  2271. msgRet.jinbiNew = newConfig.hangJinbi
  2272. msgRet.greenExpOld = oldConfig.hangGreenExp
  2273. msgRet.greenExpNew = newConfig.hangGreenExp
  2274. msgRet.qingbaoOld = oldConfig.hangQingbao
  2275. msgRet.qingbaoNew = newConfig.hangQingbao
  2276. Msg.send(msgRet, human.fd)
  2277. end
  2278. -- 刷新排行榜
  2279. human.db.maxBattleTime = os.time()
  2280. BRoleLogic.updateData(BillboardDefine.TYPE_BATTLE, human.db)
  2281. end
  2282. -- GM
  2283. function setBattleByGm(human, val, maxBattleID)
  2284. val = tonumber(val)
  2285. if not val or val <= 1 then
  2286. return
  2287. end
  2288. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2289. if not tBattleConfig then
  2290. return
  2291. end
  2292. local nodeConfig = tBattleConfig.node[val]
  2293. if not nodeConfig then
  2294. return
  2295. end
  2296. if maxBattleID then
  2297. maxBattleID = tonumber(maxBattleID)
  2298. else
  2299. maxBattleID = val
  2300. end
  2301. local nBattleType = BattleLogic_GetBattleType(human)
  2302. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  2303. local gameTimes = 0
  2304. local battleID = BattleLogic_GetBattleGuaJiID(human)
  2305. local allCfg = BattleExcel.node
  2306. for i=battleID, val-1 do
  2307. local singleCfg = allCfg[i]
  2308. if singleCfg and type(singleCfg.gameType) == "number" and singleCfg.gameType == 1 then
  2309. gameTimes = gameTimes + 1
  2310. end
  2311. end
  2312. human.db.battleGameTimes = (human.db.battleGameTimes or 0) + gameTimes
  2313. end
  2314. BattleLogic_SetBattleBattleID(human, val)
  2315. BattleLogic_SetBattleGuaJiID(human, val)
  2316. setBattleID(human, val)
  2317. --human.db.battleID = val
  2318. BattleLogic_QueryDifficulty(human)
  2319. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2320. end
  2321. --GM命令, 增加挂机时间,hourVal单位为:h
  2322. --如果超过最大可挂机时间,那么就增加最大挂机时间
  2323. function gmSetHangTime(human, hourVal)
  2324. local tBattleOut = BattleLogic_GetBattleOut(human)
  2325. if not tBattleOut then
  2326. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "gmSetHangTime func calcBattleExpOut 获取挂机奖励列表失败 id = "
  2327. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2328. return
  2329. end
  2330. if not hourVal then
  2331. return
  2332. end
  2333. local setHandTime = hourVal * 3600
  2334. local maxHangTime = getHangMaxTime(human)
  2335. if setHandTime > maxHangTime then
  2336. setHandTime = maxHangTime
  2337. end
  2338. tBattleOut.expTs1 = tBattleOut.expTs1 - setHandTime
  2339. tBattleOut.expTs2 = tBattleOut.expTs2 - setHandTime
  2340. tBattleOut.itemTs1 = tBattleOut.itemTs1 - setHandTime
  2341. tBattleOut.itemTs2 = tBattleOut.itemTs2 - setHandTime
  2342. end
  2343. function mopupQuery(human)
  2344. ObjHuman.updateDaily(human)
  2345. local nNowGuaJiID = human.db.guajiID
  2346. local tBattleConfig = BattleExcel
  2347. if -1 >= nNowGuaJiID or not tBattleConfig then
  2348. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "mopupQuery 获取战斗配置、挂机ID 失败 id = "
  2349. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2350. print("[mopupQuery] 获取战斗配置、挂机ID 失败")
  2351. return
  2352. end
  2353. local msgRet = Msg.gc.GC_BATTLE_MOPUP_QUERY
  2354. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2355. local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
  2356. if guajiID == 0 then
  2357. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
  2358. end
  2359. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2360. local nextDoCnt = human.db.mopupDoCnt + 1
  2361. nextDoCnt = nextDoCnt >= EliteDefine.BATTLE_MOPUP_MAX_LEN and EliteDefine.BATTLE_MOPUP_MAX_LEN or nextDoCnt
  2362. -- local nodeConfig = BattleExcel.node[guajiID]
  2363. local nodeConfig = tBattleConfig.node[guajiID]
  2364. local dropID = nodeConfig.dropID
  2365. local dropConfig = DropExcel.dropBattle[dropID]
  2366. local dropCnt = 0
  2367. --秘宝加成
  2368. local talismanAdd_qb = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_QB) or 0) / 100
  2369. local talismanAdd_hero_exp = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_HERO_EXP) or 0) / 100
  2370. local talismanAdd_zs = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_ZS) or 0) / 100
  2371. local talismanAdd_dailyFeeCnt = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_SD_FREE_CNT) or 0
  2372. -- ABS掉落活动显示到第一个
  2373. dropCnt = DropExchangeLogic.getDropItemSaoQuery(human, msgRet, dropCnt)
  2374. for i = 1, #dropConfig.dropRule do
  2375. if dropCnt >= #msgRet.item then
  2376. break
  2377. end
  2378. dropCnt = dropCnt + 1
  2379. local tempConfig = dropConfig.dropRule[i]
  2380. local itemID = tempConfig[1]
  2381. local itemCnt = 1
  2382. if itemID == ItemDefine.ITEM_ZUANSHI_ID and talismanAdd_zs > 0 then
  2383. itemCnt = itemCnt + math.ceil(itemCnt * talismanAdd_zs)
  2384. end
  2385. Grid.makeItem(msgRet.item[dropCnt], itemID, itemCnt)
  2386. end
  2387. for i = 1, #dropConfig.dropRule3 do
  2388. if dropCnt >= #msgRet.item then
  2389. break
  2390. end
  2391. dropCnt = dropCnt + 1
  2392. local tempConfig = dropConfig.dropRule3[i]
  2393. local itemID = tempConfig[1]
  2394. local itemCnt = 1
  2395. if itemID == ItemDefine.ITEM_ZUANSHI_ID and talismanAdd_zs > 0 then
  2396. itemCnt = itemCnt + math.ceil(itemCnt * talismanAdd_zs)
  2397. end
  2398. Grid.makeItem(msgRet.item[dropCnt], itemID, itemCnt)
  2399. end
  2400. -- local mapConfig = BattleExcel.map[nodeConfig.mapID]
  2401. local mapConfig = tBattleConfig.map[nodeConfig.mapID]
  2402. msgRet.name = mapConfig.name
  2403. msgRet.item[0] = dropCnt
  2404. local nNowAddFreeCnt = BattleLogic_GetAddFreeMopupNum(human)
  2405. nNowAddFreeCnt = nNowAddFreeCnt + talismanAdd_dailyFeeCnt
  2406. if TequanShopLogic.isActiveMopup(human) then
  2407. msgRet.leftCnt = BATTLE_MOPUP_CNT_VIP - human.db.mopupDoCnt
  2408. else
  2409. msgRet.leftCnt = BATTLE_MOPUP_CNT - human.db.mopupDoCnt
  2410. end
  2411. -- 剩余次数小于0则为0,再加额外的
  2412. msgRet.leftCnt = msgRet.leftCnt < 0 and 0 or msgRet.leftCnt
  2413. -- 增加额外次数
  2414. msgRet.leftCnt = msgRet.leftCnt + nNowAddFreeCnt
  2415. msgRet.leftCnt = math.max(msgRet.leftCnt, 0)
  2416. -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
  2417. local mupopExcel = tBattleConfig.mupop[nextDoCnt]
  2418. if mupopExcel then
  2419. if not TequanShopLogic.isActiveMopup(human) then
  2420. msgRet.need = mupopExcel.cost
  2421. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
  2422. msgRet.need = 0
  2423. end
  2424. else
  2425. msgRet.need = mupopExcel.vipCost
  2426. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
  2427. msgRet.need = 0
  2428. end
  2429. end
  2430. else
  2431. msgRet.need = 0
  2432. end
  2433. -- 如果有额外增加次数则需要为0
  2434. if 0 < nNowAddFreeCnt then
  2435. msgRet.need = 0
  2436. end
  2437. msgRet.vip = TequanShopLogic.isActiveMopup(human) and 1 or 0
  2438. msgRet.nowCnt = human.db.mopupDoCnt
  2439. msgRet.exp = nodeConfig.hangExp
  2440. msgRet.jinbi = nodeConfig.hangJinbi
  2441. --msgRet.greenExp = nodeConfig.hangGreenExp
  2442. msgRet.greenExp = nodeConfig.hangGreenExp + math.ceil(nodeConfig.hangGreenExp * talismanAdd_hero_exp)
  2443. msgRet.qingbao = nodeConfig.hangQingbao + math.ceil(nodeConfig.hangQingbao * talismanAdd_qb)
  2444. print("[mopupQuery] nowCnt = "..msgRet.nowCnt.." leftCnt = "..msgRet.leftCnt.." nNowAddFreeCnt = "..nNowAddFreeCnt)
  2445. Msg.send(msgRet, human.fd)
  2446. end
  2447. function mopupFight(human)
  2448. -- 等级判断
  2449. ObjHuman.updateDaily(human)
  2450. local nNowGuaJiID = human.db.guajiID
  2451. local tBattleConfig = BattleExcel
  2452. if -1 >= nNowGuaJiID or not tBattleConfig then
  2453. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "mopupFight 获取战斗配置、挂机ID 失败 id = "
  2454. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2455. print("[mopupFight] 获取战斗配置、挂机ID 失败")
  2456. return
  2457. end
  2458. local need = 0
  2459. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2460. human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
  2461. local nextDoCnt = human.db.mopupDoCnt + 1
  2462. nextDoCnt = nextDoCnt >= EliteDefine.BATTLE_MOPUP_MAX_LEN and EliteDefine.BATTLE_MOPUP_MAX_LEN or nextDoCnt
  2463. -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
  2464. local mupopExcel = tBattleConfig.mupop[nextDoCnt]
  2465. local talismanAdd_dailyFeeCnt = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_SD_FREE_CNT) or 0
  2466. local nNowAddFreeCnt = BattleLogic_GetAddFreeMopupNum(human)
  2467. nNowAddFreeCnt = nNowAddFreeCnt + talismanAdd_dailyFeeCnt
  2468. if not mupopExcel then
  2469. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2470. end
  2471. local bUseFree = false
  2472. if not TequanShopLogic.isActiveMopup(human) then
  2473. if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT and 0 >= nNowAddFreeCnt then
  2474. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2475. end
  2476. need = mupopExcel.cost
  2477. -- 如果免费次数小于1次,则按免费算
  2478. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
  2479. bUseFree = true
  2480. need = 0
  2481. end
  2482. else
  2483. if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT_VIP and 0 >= nNowAddFreeCnt then
  2484. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2485. end
  2486. need = mupopExcel.vipCost
  2487. -- 如果免费次数小于3次,则按免费算
  2488. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
  2489. bUseFree = true
  2490. need = 0
  2491. end
  2492. end
  2493. local bUseAddFree = false
  2494. if need <= 0 and bUseFree == true then
  2495. human.db.mopupFreeCnt = human.db.mopupFreeCnt + 1
  2496. else
  2497. if nNowAddFreeCnt > 0 then
  2498. need = 0
  2499. BattleLogic_SetAddFreeMopupNum(human, -1)
  2500. bUseAddFree = true
  2501. end
  2502. end
  2503. if need > 0 then
  2504. if not ObjHuman.checkRMB(human, need) then
  2505. return
  2506. end
  2507. ObjHuman.decZuanshi(human, - need, "battleMopup")
  2508. end
  2509. human.db.mopupDoCnt = bUseAddFree == true and human.db.mopupDoCnt or human.db.mopupDoCnt + 1
  2510. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2511. local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
  2512. if guajiID == 0 then
  2513. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
  2514. end
  2515. -- local config = BattleExcel.node[guajiID]
  2516. local config = tBattleConfig.node[guajiID]
  2517. local msgRet = Msg.gc.GC_BATTLE_MOPUP_FIGHT
  2518. local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  2519. local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  2520. local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  2521. local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  2522. --秘宝加成
  2523. local talismanAdd_qb = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_QB) or 0) / 100
  2524. local talismanAdd_hero_exp = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_HERO_EXP) or 0) / 100
  2525. local talismanAdd_zs = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.GJ_ZS) or 0) / 100
  2526. local exp = config.hangExp * 120
  2527. local jinbi = config.hangJinbi * 120
  2528. local greenExp = config.hangGreenExp * 120
  2529. local qingbao = config.hangQingbao * 120
  2530. local addExp = math.floor(exp *(1 + vipExpAdd))
  2531. local addJinbi = math.floor(jinbi *(1 + vipJinAdd))
  2532. local addGreenExp = math.floor(greenExp *(1 + vipGreenExpAdd))
  2533. local addQingbao = math.floor(qingbao *(1 + vipQingbaoAdd))
  2534. addQingbao = addQingbao + math.ceil(addQingbao * talismanAdd_qb)
  2535. addGreenExp = addGreenExp + math.ceil(addGreenExp * talismanAdd_hero_exp)
  2536. local time = 7200
  2537. local itemTable = getItemOutsByTime(config, time)
  2538. -- 掉落活动
  2539. DropExchangeLogic.getDropItemSao(human, time, itemTable)
  2540. local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
  2541. if not flag then
  2542. local equipID = SysParameter.getSysParameter(SysParameter.PARAMETER_10)
  2543. itemTable[equipID] = 1
  2544. end
  2545. itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] or 0
  2546. itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] or 0
  2547. itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
  2548. itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] or 0
  2549. itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] + addJinbi
  2550. itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] + addExp
  2551. itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] + addGreenExp
  2552. itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] + addQingbao
  2553. msgRet.item[0] = 0
  2554. -- 双倍日
  2555. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2556. local rewardCnt = double and 2 or 1
  2557. for itemID, itemCnt in pairs(itemTable) do
  2558. itemCnt = itemCnt * rewardCnt
  2559. if itemID == ItemDefine.ITEM_ZUANSHI_ID and talismanAdd_zs > 0 then
  2560. itemCnt = itemCnt + math.ceil(itemCnt * talismanAdd_zs)
  2561. end
  2562. if not ItemDefine.isEquip(itemID) then
  2563. msgRet.item[0] = msgRet.item[0] + 1
  2564. Grid.makeItem(msgRet.item[msgRet.item[0]], itemID, itemCnt)
  2565. end
  2566. BagLogic.addItem(human, itemID, itemCnt, "battle")
  2567. end
  2568. msgRet.item[0] = EquipLogic.makeEquipItem(human, msgRet.item, msgRet.item[0])
  2569. msgRet.double = double and 1 or 0
  2570. msgRet.exp = itemTable[ItemDefine.ITEM_EXP_ID] * rewardCnt
  2571. msgRet.jinbi = itemTable[ItemDefine.ITEM_JINBI_ID] * rewardCnt
  2572. msgRet.greenExp = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] * rewardCnt
  2573. msgRet.qingbao = itemTable[ItemDefine.ITEM_QINGBAO_ID] * rewardCnt
  2574. Msg.send(msgRet, human.fd)
  2575. mopupQuery(human)
  2576. query(human)
  2577. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2578. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
  2579. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_12, 1)
  2580. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_3, 1)
  2581. HeroLogLogic.finishTaskCB(human, HeroLogLogic.HERO_LOG_TYPE_3, 1)
  2582. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2001)
  2583. YunYingLogic.onCallBack(human, "onMopup", 1)
  2584. end
  2585. function updateDaily(human)
  2586. human.db.mopupFreeCnt = 0
  2587. human.db.mopupDoCnt = 0
  2588. human.db.mopupAddFreeCnt = 0
  2589. end
  2590. function getTongGuanReward(human, id)
  2591. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2592. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2593. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2594. if not tBattleConfig or -1 >= nNowGuaJiID or -1 >= nBattleID then
  2595. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getTongGuanReward] 获取战斗配置、挂机ID、战斗节点ID 失败 id = "
  2596. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2597. print("[getTongGuanReward] 获取战斗配置、挂机ID 失败")
  2598. return
  2599. end
  2600. local cf = tBattleConfig.node[id]
  2601. if not cf then
  2602. return
  2603. end
  2604. if #cf.tongguan < 1 then
  2605. return
  2606. end
  2607. print("[getTongGuanReward] 玩家请求领取奖励 当前的节点信息 id = "
  2608. ..id.." nNowGuaJiID = "..nNowGuaJiID.." nBattleID = "..nBattleID)
  2609. if nBattleID < id then
  2610. return
  2611. end
  2612. if isGetReward(human, id) then
  2613. return
  2614. end
  2615. if #cf.tongguan == 1 and cf.tongguan[1][3] then
  2616. -- 英雄
  2617. if HeroLogic.getEmptyCnt(human) < 1 then
  2618. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  2619. end
  2620. local heroID = cf.tongguan[1][1]
  2621. local cnt = cf.tongguan[1][2]
  2622. local star = cf.tongguan[1][3]
  2623. if cnt <= 0 then
  2624. return
  2625. end
  2626. setGetReward(human, id)
  2627. local msg = Msg.gc.GC_SUIPIAN_SUMMON
  2628. for i = 1, cnt do
  2629. local heroGrid = HeroGrid.createHeroGrid(heroID, star)
  2630. HeroLogic.addHeroByGrid(human, heroGrid, "battle_extra_reward")
  2631. SuipianLogic.makeResultItemData(msg.heroList[i], heroID, 1, 1)
  2632. end
  2633. msg.isHero = 1
  2634. msg.list[0] = 0
  2635. msg.heroList[0] = cnt
  2636. msg.fenJieList[0] = 0
  2637. Msg.send(msg, human.fd)
  2638. else
  2639. setGetReward(human, id)
  2640. BagLogic.addItemList(human, cf.tongguan, "tongguan")
  2641. end
  2642. -- 触发国王君临奖励
  2643. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE5, id)
  2644. query(human)
  2645. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2646. if id == 80 then
  2647. KingWorldLogic.setState(human, 1)
  2648. end
  2649. end
  2650. function isDot(human)
  2651. -- 通过大关卡奖励
  2652. local chapterReward = BattleLogic_GetChapterReward(human)
  2653. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2654. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2655. if -1 >= nBattleID or not tBattleExcel or not chapterReward then
  2656. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[isDot] 获取不到对应的大关卡奖励表 或配置表、战斗ID")
  2657. print("[isDot] 获取不到对应的大关卡奖励表 或配置表、战斗ID id = "..human.db._id)
  2658. return
  2659. end
  2660. -- local chapterReward = human.db.chapterReward or { }
  2661. -- local battleID = human.db.battleID
  2662. -- local battleNodeConfig = BattleExcel.node[battleID]
  2663. local battleID = nBattleID
  2664. local battleNodeConfig = tBattleExcel.node[battleID]
  2665. if not battleNodeConfig then
  2666. local nodeCnt = #tBattleExcel.node
  2667. local mapCnt = #tBattleExcel.map
  2668. if battleID == nodeCnt + 1 and not chapterReward[mapCnt] then
  2669. return true
  2670. else
  2671. return false
  2672. end
  2673. else
  2674. local mapID = battleNodeConfig.mapID
  2675. for i = mapID - 1, 1, -1 do
  2676. if not chapterReward[i] then
  2677. return true
  2678. end
  2679. end
  2680. end
  2681. return false
  2682. -- if human.db.lv < 9 then
  2683. -- return false
  2684. -- end
  2685. -- -- 有免费扫荡次数的时候有红点
  2686. -- human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
  2687. -- if TequanShopLogic.isActiveMopup(human) then
  2688. -- if human.db.mopupFreeCnt < 3 then
  2689. -- return true
  2690. -- end
  2691. -- else
  2692. -- if human.db.mopupFreeCnt < 1 then
  2693. -- return true
  2694. -- end
  2695. -- end
  2696. -- -- 有通关奖励可领取的时候有红点
  2697. -- if hasCanGetReward(human) then
  2698. -- return true
  2699. -- end
  2700. -- -- 战役挂机时间超过1小时的时候有红点
  2701. -- if human.db.battleOut ~= nil then
  2702. -- local now = os.time()
  2703. -- local outSec = now - human.db.battleOut.expTs1
  2704. -- if outSec >= 3600 then
  2705. -- return true
  2706. -- end
  2707. -- end
  2708. -- return false
  2709. end
  2710. function clacItemTwoHours(human)
  2711. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2712. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2713. if not tBattleConfig or -1 >= nGuaJiID then
  2714. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[clacItemTwoHours] 获取到的挂机ID、战斗配置不正确 id = "..human.db._id)
  2715. print("[clacItemTwoHours] 获取到的挂机ID、战斗配置不正确 id = "..human.db._id)
  2716. return
  2717. end
  2718. local items = { }
  2719. local outCnt = math.floor(7200 / BATTLE_HANG_ITEM_OUT_PERIOD)
  2720. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2721. local guajiID = nGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nGuaJiID
  2722. if guajiID == 0 then
  2723. return items
  2724. end
  2725. -- local nodeConfig = BattleExcel.node[guajiID]
  2726. local nodeConfig = tBattleConfig.node[guajiID]
  2727. local dropID = nodeConfig.dropID
  2728. local dropConfig = DropExcel.dropBattle[dropID]
  2729. local totalWeight = 0
  2730. for i = 1, #dropConfig.dropRule do
  2731. local tempConfig = dropConfig.dropRule[i]
  2732. totalWeight = totalWeight + tempConfig[4]
  2733. end
  2734. for j = 1, outCnt do
  2735. local randomNum = math.random(1, totalWeight)
  2736. for i = 1, #dropConfig.dropRule do
  2737. local tempConfig = dropConfig.dropRule[i]
  2738. local itemID = tempConfig[1]
  2739. local itemCnt1 = tempConfig[2]
  2740. local itemCnt2 = tempConfig[3]
  2741. local itemRate = tempConfig[4]
  2742. if randomNum <= itemRate then
  2743. local realAdd = math.random(itemCnt1, itemCnt2)
  2744. items[itemID] = realAdd
  2745. break
  2746. end
  2747. randomNum = randomNum - itemRate
  2748. end
  2749. end
  2750. return items
  2751. end
  2752. local MailManager = require("mail.MailManager")
  2753. function clacItemCntGM(human, cnt, guajiID)
  2754. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2755. if not tBattleConfig then
  2756. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[clacItemCntGM] 获取到战斗配置不正确 id = "..human.db._id)
  2757. print("[clacItemTwoHours] 获取到的战斗配置不正确 id = "..human.db._id)
  2758. return
  2759. end
  2760. local items = { }
  2761. local outCnt = cnt
  2762. local nodeConfig = tBattleConfig.node[guajiID]
  2763. local dropID = nodeConfig.dropID
  2764. local dropConfig = DropExcel.dropBattle[dropID]
  2765. local totalWeight = 0
  2766. for i = 1, #dropConfig.dropRule do
  2767. local tempConfig = dropConfig.dropRule[i]
  2768. totalWeight = totalWeight + tempConfig[4]
  2769. end
  2770. for j = 1, outCnt do
  2771. local randomNum = math.random(1, totalWeight)
  2772. for i = 1, #dropConfig.dropRule do
  2773. local tempConfig = dropConfig.dropRule[i]
  2774. local itemID = tempConfig[1]
  2775. local itemCnt1 = tempConfig[2]
  2776. local itemCnt2 = tempConfig[3]
  2777. local itemRate = tempConfig[4]
  2778. if randomNum <= itemRate then
  2779. local realAdd = math.random(itemCnt1, itemCnt2)
  2780. items[itemID] = items[itemID] or 0
  2781. items[itemID] = items[itemID] + realAdd
  2782. break
  2783. end
  2784. randomNum = randomNum - itemRate
  2785. end
  2786. end
  2787. local item = { }
  2788. local index = 0
  2789. for k, v in pairs(items) do
  2790. index = index + 1
  2791. item[index] = { k, v }
  2792. end
  2793. MailManager.add(MailManager.SYSTEM, human.db._id, "", "", item, "")
  2794. end
  2795. function getBattleID(human)
  2796. local num = 0
  2797. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2798. if -1 < nGuaJiID then
  2799. num = nGuaJiID
  2800. end
  2801. -- if human.db.guajiID then
  2802. -- num = human.db.guajiID or 0
  2803. -- end
  2804. return num
  2805. end
  2806. --------------------------------------------- combat ----------------------------------------------
  2807. function getCombatMonsterOutID(human, side)
  2808. if side ~= CombatDefine.DEFEND_SIDE then
  2809. return
  2810. end
  2811. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2812. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2813. if not tBattleExcel or -1 >= nBattleID then
  2814. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getCombatMonsterOutID] 获取到的战斗配置、或战斗ID不正确 id = "..human.db._id)
  2815. print("[getCombatMonsterOutID] 获取到的战斗配置、或战斗ID不正确 id = "..human.db._id)
  2816. return
  2817. end
  2818. -- local config = BattleExcel.node[human.db.battleID]
  2819. local config = tBattleExcel.node[nBattleID]
  2820. if not config then
  2821. return
  2822. end
  2823. return config.monsterOutID
  2824. end
  2825. function getCombatName(human)
  2826. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2827. if -1 >= nBattleID then
  2828. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getCombatMonsterOutID] 获取到的战斗ID不正确 id = "..human.db._id)
  2829. print("[getCombatMonsterOutID] 获取到的战斗ID不正确 id = "..human.db._id)
  2830. return ""
  2831. end
  2832. local name = getBattleName(human, nBattleID)
  2833. return Util.format(Lang.COMBAT_BATTLE_EXNAME, name)
  2834. end
  2835. -------------------------------------------combat end--------------------
  2836. function battleSharkQuery(human, nodeID)
  2837. local msgRet = Msg.gc.GC_BATTLE_SHARK_QUERY
  2838. local videoTb = BattleDBLogic.queryBattleDbByNodeID(nodeID)
  2839. if videoTb == nil then
  2840. msgRet.battleShark[0] = 0
  2841. else
  2842. local len = #videoTb.shark
  2843. for i = 1, len do
  2844. local v = videoTb.shark[i]
  2845. RoleLogic.makeRoleBase(v.roleBase, msgRet.battleShark[i].roleBase)
  2846. msgRet.battleShark[i].type = i
  2847. msgRet.battleShark[i].videoUuid = v.videoUuid
  2848. msgRet.battleShark[i].param = v.param or 0
  2849. end
  2850. msgRet.battleShark[0] = len
  2851. end
  2852. -- Msg.trace(msgRet)
  2853. Msg.send(msgRet, human.fd)
  2854. end
  2855. local QueryRoleByNodeID = { }
  2856. function worldMapRoleListQuery(human, worldMapId)
  2857. -- if worldMapId == 1 then return end
  2858. local nNowBattleType = BattleLogic_GetBattleType(human)
  2859. if EliteDefine.COPY_ELITE_ERROR >= nNowBattleType then
  2860. nNowBattleType = EliteDefine.COPY_ELITE_NORMAL
  2861. end
  2862. local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_ROLELIST_QUERY
  2863. local len = 0
  2864. for k, v in pairs(BATTLE_LEVEL_PLAYER_LIST[nNowBattleType][worldMapId]) do
  2865. len = len + 1
  2866. RoleLogic.makeRoleBase(v, msgRet.roleList[len])
  2867. if len >= 50 then
  2868. break
  2869. end
  2870. end
  2871. msgRet.roleList[0] = len
  2872. Msg.send(msgRet, human.fd)
  2873. end
  2874. -- 章节(地图)掉落列表
  2875. function sendMapDroItemsList(human)
  2876. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2877. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2878. if not tBattleExcel then
  2879. print("[sendMapDroItemsList] 获取当前战斗配置失败 id = "..human.db._id)
  2880. return
  2881. end
  2882. local battleID = 1
  2883. if -1 < nBattleID then
  2884. battleID = nBattleID
  2885. end
  2886. local maxBattleConfig = tBattleExcel.node[battleID]
  2887. local maxMapID = maxBattleConfig and maxBattleConfig.mapID or(#tBattleExcel.node + 1)
  2888. local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_LIST
  2889. msgRet.list[0] = 0
  2890. for mapID, mapConfig in ipairs(tBattleExcel.map) do
  2891. msgRet.list[0] = msgRet.list[0] + 1
  2892. local net = msgRet.list[msgRet.list[0]]
  2893. net.mapID = mapID
  2894. net.mapName = mapConfig.name
  2895. net.isOpen =(mapID <= maxMapID) and 1 or 0
  2896. end
  2897. -- Msg.trace(msgRet)
  2898. Msg.send(msgRet, human.fd)
  2899. end
  2900. -- 章节(地图)掉落详情
  2901. function sendMapDroItemsDetail(human, mapID)
  2902. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2903. if not tBattleExcel then
  2904. print("[sendMapDroItemsDetail] 获取当前战斗配置失败 id = "..human.db._id)
  2905. return
  2906. end
  2907. local mapConfig = tBattleExcel.map[mapID]
  2908. if not mapConfig then
  2909. return
  2910. end
  2911. local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_DETAIL
  2912. msgRet.mapID = mapID
  2913. msgRet.items[0] = math.min(#mapConfig.dropItemsShow, #msgRet.items)
  2914. for i = 1, msgRet.items[0] do
  2915. local itemID = mapConfig.dropItemsShow[i][1]
  2916. local itemCnt = mapConfig.dropItemsShow[i][2]
  2917. Grid.makeItem(msgRet.items[i], itemID, itemCnt)
  2918. end
  2919. -- Msg.trace(msgRet)
  2920. Msg.send(msgRet, human.fd)
  2921. end
  2922. -- 获取当前战役的 怪物ID
  2923. function getBattleMonsterOutID(human)
  2924. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2925. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2926. if -1 >= nBattleID or not tBattleExcel then
  2927. print("[getBattleMonsterOutID] 获取当前战斗ID、配置失败 id = "..human.db._id)
  2928. return 0
  2929. end
  2930. -- local battleID = human.db.battleID
  2931. -- local config = BattleExcel.node[battleID]
  2932. local config = tBattleExcel.node[nBattleID]
  2933. return config.monsterOutID
  2934. end
  2935. function onUpdatePos(human)
  2936. BRoleLogic.updateData(BillboardDefine.TYPE_ZHANDOULI, human.db)
  2937. end
  2938. function getNextRewardName(human)
  2939. local guajiID = BattleLogic_GetBattleGuaJiID(human)
  2940. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2941. if not tBattleConfig or -1 >= guajiID then
  2942. return nil, nil
  2943. end
  2944. -- for i = human.db.guajiID + 1, #BattleExcel.node do
  2945. for i = guajiID + 1, #tBattleConfig.node do
  2946. if #tBattleConfig.node[i].tongguan > 0 then
  2947. local itemID = tBattleConfig.node[i].tongguan[1][1]
  2948. local itemConfig = ItemDefine.getConfig(itemID)
  2949. if itemConfig == nil then
  2950. return
  2951. else
  2952. return i - guajiID, itemConfig.name
  2953. end
  2954. end
  2955. end
  2956. end
  2957. --[[
  2958. 通关章节后领取奖励
  2959. ]]
  2960. function battleChapterReward(human, mapID)
  2961. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2962. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2963. local tChapterReward = BattleLogic_GetChapterReward(human)
  2964. if not tBattleConfig or -1 >= nBattleID or not tChapterReward then
  2965. print("[battleChapterReward] 获取到的战斗ID、配置、通关章节奖励表 不正确 id = "..human.db._id)
  2966. return
  2967. end
  2968. local mapConf = tBattleConfig.map[mapID]
  2969. if not mapConf then
  2970. return
  2971. end
  2972. -- 没有通过当前大关卡
  2973. local battleID = nBattleID
  2974. local battleNodeConfig = tBattleConfig.node[battleID]
  2975. local roleMapId
  2976. if not battleNodeConfig then
  2977. if battleID ~= #tBattleConfig.node + 1 then
  2978. return
  2979. else
  2980. roleMapId = #tBattleConfig.map
  2981. end
  2982. else
  2983. roleMapId = battleNodeConfig.mapID
  2984. end
  2985. if mapID > roleMapId then
  2986. return
  2987. end
  2988. -- if not human.db.chapterReward then
  2989. -- human.db.chapterReward = { }
  2990. -- end
  2991. -- 判断是否已经领取了当前大关卡的奖励
  2992. -- local chapterReward = human.db.chapterReward
  2993. local chapterReward = tChapterReward
  2994. if chapterReward[mapID] then
  2995. return Broadcast.sendErr(human, Lang.FRIEND_HEART_GET_HAD)
  2996. end
  2997. chapterReward[mapID] = true
  2998. ObjHuman.save(human)
  2999. local reward = mapConf.reward
  3000. BagLogic.addItemList(human, reward, "chapterReward")
  3001. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  3002. local msgRet = Msg.gc.GC_BATTLE_CHAPTER_REWARD
  3003. msgRet.mapID = mapID
  3004. Msg.send(msgRet, human.fd)
  3005. end
  3006. -- 判断难度是否解锁
  3007. local function BattleLogic_CheckDiffIsOK(human, nSelectDiff)
  3008. -- 默认难度直接通过
  3009. if EliteDefine.COPY_ELITE_NORMAL == nSelectDiff then
  3010. return EliteDefine.COPY_SELECT_SUCC
  3011. end
  3012. -- 等级不够
  3013. if human.db.lv < EliteDefine.COPY_ELITE_ULEV then
  3014. return EliteDefine.COPY_SELECT_LEV
  3015. end
  3016. local nChoseBattleID = (EliteDefine.COPY_LEVEL_ELITE == nSelectDiff) and human.db.battleID or human.db.battleID_elite
  3017. return nChoseBattleID > EliteDefine.COPY_ELITE_LEVEL and EliteDefine.COPY_SELECT_SUCC or EliteDefine.COPY_SELECT_MAIN
  3018. end
  3019. -- 获取未领取奖励
  3020. local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
  3021. --print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
  3022. local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
  3023. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  3024. local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  3025. if -1 >= nBattleID or not tBattleConfig or -1 >= nGuaJiID then
  3026. print("[BattleLogic_GetNorewardReceived] 获取配置失败")
  3027. return
  3028. end
  3029. local msgRet = Msg.gc.GC_BATTLE_QUERY_ALL
  3030. msgRet.index = nBattleType
  3031. msgRet.list[0] = 0
  3032. msgRet.isEnd = 0
  3033. msgRet.curIndex = 0
  3034. local curIndex = 1
  3035. -- human.db.battleID = human.db.battleID or 1
  3036. -- if human.db.battleID == 0 then
  3037. -- human.db.battleID = 1
  3038. -- end
  3039. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  3040. local curBattleNumber = cIndex
  3041. local curTotalNumber = 0
  3042. local battleNumber = #tBattleConfig.node
  3043. -- local nGuajiID = human.db.guajiID or 0
  3044. --print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID.. " nBattleID = "..nBattleID)
  3045. -- 判断ID得用战斗ID-1, 因为挂机ID可以设置
  3046. local nJudeNum = nGuaJiID
  3047. local nBattleAdopt = BattleLogic_GetBattleAdopt(human, nBattleType)
  3048. -- 已通过
  3049. if nBattleAdopt == 1 then
  3050. nJudeNum = battleNumber
  3051. else
  3052. nJudeNum = nBattleID - 1
  3053. end
  3054. --print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
  3055. for k,v in ipairs(tBattleConfig.node) do
  3056. if #v.tongguan ~= 0 then
  3057. -- 领取状态
  3058. local state = false
  3059. if k <= nJudeNum then
  3060. state = isGetRewardByType(human, k, nBattleType)
  3061. end
  3062. if not (state == true) then
  3063. local r = STATUS_CANGET
  3064. --(k > nGuaJiID) and STATUS_CANGET or STATUS_NONE
  3065. --未领取
  3066. if r == STATUS_CANGET then
  3067. curTotalNumber = curTotalNumber + 1
  3068. if curTotalNumber > curBattleNumber then
  3069. --构造
  3070. local cf = tBattleConfig.node[k].tongguan
  3071. local net = msgRet.list[curIndex]
  3072. net.status = k <= nJudeNum and STATUS_CANGET or STATUS_NONE
  3073. net.levelName = getBattleNameByType(k, nBattleType)
  3074. net.index = k
  3075. net.nowBattle = getBattleNameByType(nJudeNum, nBattleType)
  3076. net.reward[0] = 0
  3077. net.heroReward[0] = 0
  3078. if cf[1][3] then
  3079. net.heroReward[0] = 1
  3080. local other = { }
  3081. other.star = cf[1][3]
  3082. HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
  3083. HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
  3084. -- local tHeroInfo = Util.printTable(net.heroReward)
  3085. -- print("[BattleLogic_GetNorewardReceived] 英雄数据 k = "..k.." 获取的数据 = "..tHeroInfo)
  3086. else
  3087. net.reward[0] = 1
  3088. for i = 1, net.reward[0] do
  3089. local itemID = cf[i][1]
  3090. local itemCnt = cf[i][2]
  3091. Grid.makeItem(net.reward[i], itemID, itemCnt)
  3092. end
  3093. end
  3094. curIndex = curIndex + 1
  3095. msgRet.list[0] = msgRet.list[0] + 1
  3096. if msgRet.list[0] >= 15 then
  3097. local ret = 0
  3098. if k < battleNumber then
  3099. for kk, vv in ipairs(tBattleConfig.node) do
  3100. if kk > k then
  3101. if v.tongguan ~= 0 then
  3102. local nNextstate = isGetRewardByType(human,kk, nBattleType)
  3103. if not (nNextstate == true) then
  3104. local rr =(kk > nGuaJiID) and STATUS_CANGET or STATUS_NONE
  3105. --未领取
  3106. if rr == STATUS_CANGET then
  3107. ret = 1
  3108. break
  3109. end
  3110. end
  3111. end
  3112. end
  3113. end
  3114. end
  3115. if ret == 1 then
  3116. --没有结束
  3117. msgRet.isEnd = 0
  3118. else
  3119. msgRet.isEnd = 1
  3120. end
  3121. msgRet.curIndex=curTotalNumber
  3122. -- curIndex = 1
  3123. Msg.send(msgRet, human.fd)
  3124. --local info=Util.printTable(msgRet)
  3125. --print("getNorewardReceived0->>:"..info)
  3126. return
  3127. end
  3128. end
  3129. end
  3130. else
  3131. print("[BattleLogic_GetNorewardReceived] 奖励已领取:"..k)
  3132. end
  3133. end
  3134. end
  3135. --结束
  3136. msgRet.isEnd = 1
  3137. msgRet.curIndex=0
  3138. Msg.send(msgRet, human.fd)
  3139. end
  3140. -- 客户端请求查询难度
  3141. function CG_ELITE_OPEN(human)
  3142. BattleLogic_QueryDifficulty(human)
  3143. end
  3144. -- 客户端请求切换难度
  3145. function CG_ELITE_SELECT(human, nSelectDiff)
  3146. if EliteDefine.COPY_ELITE_NORMAL > nSelectDiff or EliteDefine.COPY_ELITE_DIFFICULTY < nSelectDiff then
  3147. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[CG_ELITE_SELECT] 客户端传入的参数不正确 id = "..human.db._id .. "nSelectDiff = "..nSelectDiff)
  3148. print("[CG_ELITE_SELECT] 客户端选择难度,上传的难度不正确 id = "..human.db._id .. "nSelectDiff = "..nSelectDiff)
  3149. return
  3150. end
  3151. local nStatus = BattleLogic_CheckDiffIsOK(human, nSelectDiff)
  3152. print("[CG_ELITE_SELECT] nStatus = "..nStatus.. " 选择的难度 nSelectDiff = "..nSelectDiff)
  3153. -- 设置类型
  3154. if EliteDefine.COPY_SELECT_SUCC == nStatus then
  3155. BattleLogic_SetBattleType(human,nSelectDiff)
  3156. end
  3157. local msgRet = Msg.gc.GC_ELITE_SELECT
  3158. msgRet.status = nStatus
  3159. Msg.send(msgRet,human.fd)
  3160. end
  3161. -- 客户端请求领取奖励
  3162. function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human, nBattleType)
  3163. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  3164. local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  3165. local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
  3166. if not tBattleConfig or -1 >= nGuaJiID or -1 >= nBattleID then
  3167. return
  3168. end
  3169. local tMsgRet = Msg.gc.GC_BATTLE_TONGGUAN_REWARD_GET_COPY
  3170. local nAdopt = BattleLogic_GetBattleAdopt(human, nBattleType)
  3171. local nChoseLen = nBattleID - 1
  3172. local nConfigLen = #tBattleConfig.node
  3173. if 1 == nAdopt then
  3174. nChoseLen = nBattleID
  3175. else
  3176. if 0 >= nChoseLen or nChoseLen > nConfigLen then
  3177. tMsgRet.status = 0
  3178. Msg.send(tMsgRet, human.fd)
  3179. return
  3180. end
  3181. end
  3182. print("[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] nChoseLen = "..nChoseLen.. " nBattleID = "..nBattleID)
  3183. tMsgRet.status = 1
  3184. local tItemList = {}
  3185. for id = 1, nChoseLen, 1 do
  3186. local tNodeCofig = tBattleConfig.node[id]
  3187. if tNodeCofig and #tNodeCofig.tongguan >= 1 then
  3188. -- 未领取
  3189. if false == isGetRewardByType(human, id, nBattleType) then
  3190. print("[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] 未领取的 id = "..id)
  3191. if #tNodeCofig.tongguan == 1 and tNodeCofig.tongguan[1][3] then
  3192. -- 英雄
  3193. if HeroLogic.getEmptyCnt(human) < 1 then
  3194. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  3195. end
  3196. local heroID = tNodeCofig.tongguan[1][1]
  3197. local cnt = tNodeCofig.tongguan[1][2]
  3198. local star = tNodeCofig.tongguan[1][3]
  3199. if cnt > 0 then
  3200. -- 设置已领取
  3201. setGetRewardByType(human, id, nBattleType)
  3202. local msg = Msg.gc.GC_SUIPIAN_SUMMON
  3203. for i = 1, cnt do
  3204. local heroGrid = HeroGrid.createHeroGrid(heroID, star)
  3205. HeroLogic.addHeroByGrid(human, heroGrid, "battle_extra_reward")
  3206. SuipianLogic.makeResultItemData(msg.heroList[i], heroID, 1, 1)
  3207. end
  3208. msg.isHero = 1
  3209. msg.list[0] = 0
  3210. msg.heroList[0] = cnt
  3211. msg.fenJieList[0] = 0
  3212. Msg.send(msg, human.fd)
  3213. else
  3214. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] 领取奖励配置的英雄cnt为<= 0 id = "..human.db.name)
  3215. print("[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] 不正确的 英雄碎片数量")
  3216. end
  3217. else
  3218. setGetRewardByType(human, id, nBattleType)
  3219. for k, v in ipairs(tNodeCofig.tongguan) do
  3220. local nItemID = v[1]
  3221. local nItemNum = v[2]
  3222. tItemList[nItemID] = tItemList[nItemID] or 0
  3223. tItemList[nItemID] = tItemList[nItemID] + nItemNum
  3224. end
  3225. --BagLogic.addItemList(human, tNodeCofig.tongguan, "tongguan")
  3226. end
  3227. -- 触发国王君临奖励
  3228. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE5, id)
  3229. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  3230. if id == 80 then
  3231. KingWorldLogic.setState(human, 1)
  3232. end
  3233. end
  3234. end
  3235. end
  3236. if nil ~= _G.next(tItemList) then
  3237. local tPrize = {}
  3238. for k, v in pairs(tItemList) do
  3239. table.insert(tPrize, {k,v})
  3240. end
  3241. BagLogic.addItemList(human, tPrize, "tongguan")
  3242. end
  3243. query(human)
  3244. Msg.send(tMsgRet, human.fd)
  3245. end
  3246. -- 客户端请求查询所有未领取奖励
  3247. function CG_BATTLE_QUERY_ALL(human, nBattleType, curIndex)
  3248. if EliteDefine.COPY_ELITE_NORMAL > nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  3249. print("[CG_BATTLE_QUERY_ALL] 客户端请求的战斗类型不正确 id = "..human.db._id.." nType = "..nBattleType)
  3250. return
  3251. end
  3252. BattleLogic_GetNorewardReceived(human, nBattleType, curIndex)
  3253. end
  3254. -- 判断是否是最后一关
  3255. function BattleLogic_IsLastLevels(human, nBattleType)
  3256. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  3257. local nBattleType = BattleLogic_GetBattleType(human)
  3258. if not tBattleConfig or -1 >= nBattleType then
  3259. return false
  3260. end
  3261. local nValue = BattleLogic_GetBattleAdopt(human, nBattleType)
  3262. return nValue == 1
  3263. end
  3264. -- 增加扫荡次数
  3265. function BattleLogic_AddMopup(human, nGoodsID, nGoodsNum)
  3266. if not human or 0 >= nGoodsID or 0 >= nGoodsNum then
  3267. return
  3268. end
  3269. if EliteDefine.BATTLE_ADD_MOPUP_GOODID ~= nGoodsID then
  3270. return
  3271. end
  3272. -- -- 检测数量
  3273. -- if false == BagLogic.checkItemCnt(human, nGoodsID, nGoodsNum) then
  3274. -- return
  3275. -- end
  3276. -- -- 消耗物品
  3277. -- BagLogic.delItem(human, nGoodsID, nGoodsNum, "battle")
  3278. -- 增加次数
  3279. BattleLogic_SetAddFreeMopupNum(human, nGoodsNum)
  3280. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_AddMopup] 增加扫荡次数 name = "
  3281. ..human.db.name.." nAddNum ="..nGoodsNum)
  3282. print("[BattleLogic_AddMopup] 玩家增加扫荡次数 name = "
  3283. ..human.db.name.." nAddNum ="..nGoodsNum)
  3284. end
  3285. --获取小游戏奖励
  3286. function GetGameReward(human, indexStr)
  3287. local battleGameTimes = human.db.battleGameTimes
  3288. if not battleGameTimes or battleGameTimes <= 0 then
  3289. return Broadcast.sendErr(human, Lang.JINBI_EXCHANGE_ERR_CNT)
  3290. end
  3291. local indexVec = Util.split(indexStr, "|")
  3292. if #indexVec <= 0 or #indexVec > 3 then
  3293. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  3294. end
  3295. local maxTimes = 1
  3296. local maxTimesIdx
  3297. local sumIndexTbl = {}
  3298. for _, idx in ipairs(indexVec) do
  3299. idx = tonumber(idx)
  3300. if not sumIndexTbl[idx] then
  3301. sumIndexTbl[idx] = 1
  3302. else
  3303. sumIndexTbl[idx] = sumIndexTbl[idx] + 1
  3304. maxTimes = sumIndexTbl[idx]
  3305. maxTimesIdx = idx
  3306. end
  3307. end
  3308. local itemId, itemCnt = 0,0
  3309. local configs = BattleExcel.gameReward
  3310. if maxTimes <= 1 then
  3311. local randIndex = math.random(1, #indexVec)
  3312. maxTimesIdx = tonumber(indexVec[randIndex])
  3313. end
  3314. for _, v in ipairs(configs) do
  3315. if v.itemID == maxTimesIdx then
  3316. itemId = v.itemID
  3317. if maxTimes <= 1 then
  3318. itemCnt = v.itemCnt
  3319. else
  3320. itemCnt = v["itemCnt"..maxTimes]
  3321. end
  3322. break
  3323. end
  3324. end
  3325. if not itemId or not itemCnt then
  3326. return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
  3327. end
  3328. battleGameTimes = battleGameTimes - 1
  3329. human.db.battleGameTimes = battleGameTimes
  3330. BagLogic.addItemList(human, { {itemId, itemCnt} }, "battle")
  3331. local msgRet = Msg.gc.GC_BATTLE_GETGAMEREWARD
  3332. msgRet.battleGameTimes = battleGameTimes
  3333. Msg.send(msgRet, human.fd)
  3334. end