HeroLogic.lua 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079
  1. ---------------------------------------------------------------
  2. -- 英雄逻辑
  3. -- addHero 根据英雄id添加英雄
  4. -- addHeroByGrid 根据英雄grid添加英雄(注意grid没有被其它地方引用)
  5. -- delHeroByIndex 根据英雄下表删除英雄
  6. ---------------------------------------------------------------
  7. local HeroExcel = require("excel.hero")
  8. local UpNeedExcel = require("excel.upNeed")
  9. local TequanExcel = require("excel.qqTequan")
  10. local SkillExcel = require("excel.skill")
  11. local BufferExcel = require("excel.buffer")
  12. local SkinExcel = require("excel.skin")
  13. local EquipExcel = require("excel.equip")
  14. local Log = require("common.Log")
  15. local LogDefine = require("common.LogDefine")
  16. local Lang = require("common.Lang")
  17. local Util = require("common.Util")
  18. local Msg = require("core.Msg")
  19. local ObjHuman = require("core.ObjHuman")
  20. local Grid = require("bag.Grid")
  21. local BagLogic = require("bag.BagLogic")
  22. local ItemDefine = require("bag.ItemDefine")
  23. local Broadcast = require("broadcast.Broadcast")
  24. local BarTaskLogic = require("bar.BarTaskLogic")
  25. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  26. local RoleAttr = require("role.RoleAttr")
  27. local RoleDefine = require("role.RoleDefine")
  28. local RoleHeadLogic = require("role.RoleHeadLogic")
  29. local RoleDBLogic = require("role.RoleDBLogic")
  30. local HeroBook = require("hero.HeroBook")
  31. local HeroGrid = require("hero.HeroGrid")
  32. local HeroDefine = require("hero.HeroDefine")
  33. local HeroEquip = require("hero.HeroEquip")
  34. local CombatPosLogic = require("combat.CombatPosLogic")
  35. local CombatDefine = require("combat.CombatDefine")
  36. local SkinLogic = require("skin.SkinLogic")
  37. local FenjieLogic = require("hecheng.FenjieLogic")
  38. local MonthHecJuex = require("monthAct.MonthHecJuex")
  39. local JjcLogic = require("jjc.JjcLogic")
  40. local HechengLogic = require("hecheng.HechengLogic")
  41. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  42. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  43. local GuideLogic = require("guide.GuideLogic")
  44. local RoleLogic = require("role.RoleLogic")
  45. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  46. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  47. local TuiSongLiBao = require("present.TuiSongLiBao")
  48. local SuipianLogic = require("bag.SuipianLogic")
  49. local MoshouLogic = require("moshou.MoshouLogic")
  50. local LiLianLogic = require("dailyTask.LiLianLogic")
  51. local VipLogic = require("vip.VipLogic")
  52. local FuwenLogic = require("fuwen.FuwenLogic")
  53. local GlobalWorld = require("core.GlobalWorld")
  54. local SysParameter = require("common.SysParameter")
  55. local JibanLogic = require("combat.JibanLogic")
  56. local HeroLogic = require("hero.HeroLogic")
  57. local EquipLogic = require("equip.EquipLogic")
  58. local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
  59. local HeroGrowUp = require("absAct.HeroGrowUp")
  60. local MengxinLogic = require("present.MengxinLogic")
  61. local Config = require("Config")
  62. local HeroLogLogic = require("absAct.HeroLogLogic")
  63. local ExclusiveTaskLogic = require("absAct.ExclusiveTaskLogic")
  64. local BingshuLogic = require("fuwen.BingshuLogic")
  65. local YunYingLogic = require("yunying.YunYingLogic")
  66. local BingshuLogic = require("fuwen.BingshuLogic")
  67. local GiftLogic = require("topup.GiftLogic")
  68. HERO_MAX_STAR = 15 -- 目前英雄最大星级
  69. local HERO_RESET_FREECNT = 3 -- 每日重置次数
  70. local HERO_RESET_MAXSTAR = 9 -- 只能重置9星以下(包含9星)
  71. local CHONGSHENG_RETURN_STAR = 5 -- 重生返还x星本体碎片
  72. -- 用于弹窗礼包类型
  73. local Upgrade_HERO_EVENT = 3
  74. ----------------------------------- 结构体封装 --------------------------------------
  75. -- 获取技能信息
  76. function makeSkillNet(net, id)
  77. local skillConfig = SkillExcel.skill[id]
  78. if not skillConfig then return end
  79. net.id = id
  80. net.icon = skillConfig.icon
  81. net.name = skillConfig.name
  82. net.type = skillConfig.type
  83. net.desc = skillConfig.desc
  84. net.need = skillConfig.need or 0
  85. net.lv = skillConfig.skillLv or 0
  86. -- todo
  87. net.cd[0] = #skillConfig.cd
  88. if net.cd[0] ~= 0 then
  89. net.cd[1] = skillConfig.cd[1]
  90. net.cd[2] = skillConfig.cd[2]
  91. end
  92. local len = #skillConfig.buffers
  93. for i = 1,len do
  94. local buffId = skillConfig.buffers[i][1]
  95. local buffConfig = BufferExcel.buffer[buffId]
  96. net.buff[i].id = buffId
  97. net.buff[i].name = buffConfig.name
  98. net.buff[i].desc = buffConfig.desc
  99. end
  100. net.buff[0] = len
  101. net.lvUpDesc = skillConfig.lvUpDesc
  102. -- todo
  103. end
  104. -- 封装UpStarCond协议结构体
  105. function makeUpStarCond(net, cond)
  106. local ttype = cond[1]
  107. net.type = ttype
  108. if ttype == HechengLogic.COND_TYPE_HEROID then
  109. local heroID = cond[2]
  110. local heroConfig = HeroExcel.hero[heroID]
  111. local star = cond[4] or heroConfig.star
  112. net.id = heroID
  113. net.icon = heroConfig.head
  114. net.star = star
  115. net.camp = heroConfig.camp
  116. net.name = heroConfig.name
  117. net.grade = heroConfig.grade
  118. net.cnt = cond[3]
  119. elseif ttype == HechengLogic.COND_TYPE_CAMPSTAR then
  120. net.id = 0
  121. net.icon = 0
  122. net.name = ""
  123. net.grade = 0
  124. net.camp = cond[2]
  125. net.star = cond[3]
  126. net.cnt = cond[4]
  127. end
  128. end
  129. -------------------------------- 英雄属性计算 ------------------------------------------
  130. --等级加成
  131. local function lvAdd(lv, upAttrs, attrs)
  132. for _, upAttr in ipairs(upAttrs) do
  133. local key = upAttr[1]
  134. local value = upAttr[2]
  135. attrs[key] = attrs[key] + value * (lv - 1)
  136. end
  137. end
  138. --星級加成
  139. local function starAdd(star, atkStarRate, hpStarRate, attrs)
  140. attrs[RoleDefine.ATK] = attrs[RoleDefine.ATK] * (1 + atkStarRate/10000)
  141. attrs[RoleDefine.HP] = attrs[RoleDefine.HP] * (1 + hpStarRate/10000)
  142. end
  143. --阶数加成
  144. local function qualityAdd(heroConfig, quality, attrs)
  145. local qualityConfig = HeroExcel.quality[heroConfig.quality]
  146. local qualityEnd = quality + 1
  147. for i = 1, qualityEnd do
  148. for key, rateConfig in pairs(qualityConfig) do
  149. local rate = rateConfig[i]
  150. if rate then
  151. if key == RoleDefine.DEF or key == RoleDefine.SPEED then
  152. attrs[key] = attrs[key] + rate[1]
  153. else
  154. attrs[key] = attrs[key] * rate[1]
  155. end
  156. end
  157. end
  158. end
  159. end
  160. -- 伙伴基础
  161. function doCalcHero(grid, attrs)
  162. if not grid and attrs then return end
  163. local heroConfig = HeroExcel.hero[grid.id]
  164. local attrConfig = HeroDefine.getAttrConfig(grid.id, grid.star)
  165. if not attrConfig then
  166. assert(nil, "attrConfig is nil id "..grid.id.." star "..grid.star)
  167. end
  168. for _,v in ipairs(attrConfig.attrs) do
  169. RoleAttr.updateValue(v[1], v[2], attrs)
  170. end
  171. lvAdd(grid.lv, attrConfig.up, attrs)
  172. starAdd(grid.star, attrConfig.atkStarRate, attrConfig.hpStarRate, attrs)
  173. qualityAdd(heroConfig, grid.quality, attrs)
  174. end
  175. -- 时装
  176. function doCalcHeroSkin(skinID, attrs)
  177. --[[local skinConfig = SkinExcel.skin[skinID]
  178. for _, v in ipairs(skinConfig.attrs) do
  179. RoleAttr.updateValue(v[1], v[2], attrs)
  180. end]]
  181. end
  182. -------------------------------------------------------------------------------------
  183. -------------------------------------------------------------------------------------
  184. local function sortZhanli(a, b)
  185. return a[2] > b[2]
  186. end
  187. -- 下发英雄背包列表
  188. function sendHeroBagList(human)
  189. local msgRet = Msg.gc.GC_HERO_BAG_LIST
  190. local cnt = 0
  191. human.maxZDL = {}
  192. human.maxZDL.maxHero = {}
  193. human.maxZDL.heroCnt = 0
  194. human.maxZDL.zhandouli = 0
  195. local list = {}
  196. for index = 1, human.db.heroBag[0] do
  197. local heroGrid = human.db.heroBag[index]
  198. if heroGrid then
  199. cnt = cnt + 1
  200. HeroGrid.makeHeroSimple(msgRet.list[cnt], heroGrid, index, human)
  201. if cnt >= HeroDefine.PAGE_HERO_COUNT then
  202. msgRet.list[0] = cnt
  203. Msg.send(msgRet, human.fd)
  204. cnt = 0
  205. end
  206. list[#list + 1] = {heroGrid.uuid or "", heroGrid.zhandouli or 0}
  207. end
  208. end
  209. if cnt > 0 then
  210. msgRet.list[0] = cnt
  211. Msg.send(msgRet, human.fd)
  212. end
  213. if #list > 0 then
  214. table.sort( list , sortZhanli )
  215. local maxCnt = human.db.lv >= 100 and 6 or 5
  216. for i = 1 , maxCnt do
  217. local heroDb = list[i]
  218. if heroDb then
  219. human.maxZDL.heroCnt = human.maxZDL.heroCnt + 1
  220. human.maxZDL.maxHero[heroDb[1]] = heroDb[2]
  221. human.maxZDL.zhandouli = human.maxZDL.zhandouli + heroDb[2]
  222. end
  223. end
  224. end
  225. print(" human onLogin maxZDL is : ", human.maxZDL.zhandouli)
  226. end
  227. -- 修正 玩家最高战力
  228. function checkChangeMaxZDL(human, heroGrid)
  229. if human.maxZDL and heroGrid.uuid then
  230. if human.maxZDL.maxHero[heroGrid.uuid] then
  231. human.maxZDL.maxHero[heroGrid.uuid] = heroGrid.zhandouli
  232. human.maxZDL.zhandouli = 0
  233. for _, v in pairs(human.maxZDL.maxHero) do
  234. human.maxZDL.zhandouli = human.maxZDL.zhandouli + v
  235. end
  236. else
  237. local maxCnt = human.db.lv >= 100 and 6 or 5
  238. if human.maxZDL.heroCnt < maxCnt then
  239. human.maxZDL.maxHero[heroGrid.uuid] = heroGrid.zhandouli
  240. human.maxZDL.zhandouli = human.maxZDL.zhandouli + heroGrid.zhandouli
  241. human.maxZDL.heroCnt = human.maxZDL.heroCnt + 1
  242. else
  243. local minZDL = 0
  244. local minUuid
  245. for thisUuid, v in pairs(human.maxZDL.maxHero) do
  246. minUuid = minZDL == 0 and thisUuid or minUuid
  247. minZDL = minZDL == 0 and v or minZDL
  248. if minZDL > v then
  249. minZDL = v
  250. minUuid = thisUuid
  251. end
  252. end
  253. if minZDL < heroGrid.zhandouli then
  254. human.maxZDL.maxHero[minUuid] = nil
  255. human.maxZDL.maxHero[heroGrid.uuid] = heroGrid.zhandouli
  256. human.maxZDL.zhandouli = human.maxZDL.zhandouli - minZDL + heroGrid.zhandouli
  257. end
  258. end
  259. end
  260. print(" checkChangeMaxZDL ", human.maxZDL.zhandouli)
  261. end
  262. end
  263. -- 发送英雄详细信息:静态,只是1个英雄的
  264. function sendHeroBagStatic(human, id, tuJian)
  265. local heroConfig = HeroExcel.hero[id]
  266. if not heroConfig then return end
  267. local msgRet = Msg.gc.GC_HERO_BAG_STATIC
  268. HeroGrid.makeHeroStatic(msgRet.heroStatic, id, tuJian)
  269. Msg.send(msgRet, human.fd)
  270. end
  271. -- 玩家身上动态数据
  272. function sendHeroGridDynamic(human, heroGrid, index, isQuery)
  273. if not isQuery then sendHeroBagUpdate(human, index) end
  274. local msgRet = Msg.gc.GC_HERO_BAG_DYNAMIC
  275. msgRet.index = index or 0
  276. msgRet.canLv = isHeroLvDot(human, heroGrid) == true and 1 or 0
  277. msgRet.canUp = isHeroUpDot(human, heroGrid) == true and 1 or 0
  278. msgRet.canEquip = HeroEquip.isEquipDot(human, heroGrid) == true and 1 or 0
  279. msgRet.canFuwen = FuwenLogic.isFuwenDot(human, heroGrid) == true and 1 or 0
  280. msgRet.canJueXing = isHeroJuexingDot(human, index, heroGrid) == true and 1 or 0
  281. local bingShuState = BingshuLogic.isBingShuDot(human, heroGrid)
  282. if bingShuState == -1 then
  283. msgRet.canBingShu = -1
  284. else
  285. msgRet.canBingShu = bingShuState == true and 1 or 0
  286. end
  287. HeroGrid.makeHeroDynamic(msgRet.heroDynamic, heroGrid, index, human)
  288. Msg.send(msgRet, human.fd)
  289. end
  290. -- 配置数据
  291. function sendHeroBagDynamicByID(human, heroID, star)
  292. local msgRet = Msg.gc.GC_HERO_BAG_DYNAMIC_BY_ID
  293. HeroGrid.makeHeroDynamicByID(msgRet.heroDynamic, heroID, star)
  294. Msg.send(msgRet, human.fd)
  295. end
  296. -- 发送英雄详细信息
  297. function sendHeroBagDynamic(human, id, index, isQuery)
  298. local heroGrid = getHeroGrid(human, id, index)
  299. if not heroGrid then return end
  300. sendHeroGridDynamic(human, heroGrid, index, isQuery)
  301. end
  302. -- 发送英雄添加/变化
  303. function sendHeroBagUpdate(human, index)
  304. local heroGrid = human.db.heroBag[index]
  305. if type(heroGrid) ~= "table" then return end
  306. local msgRet = Msg.gc.GC_HERO_BAG_ADD
  307. HeroGrid.makeHeroSimple(msgRet.data, heroGrid, index, human)
  308. Msg.send(msgRet, human.fd)
  309. end
  310. -- 发送英雄删除
  311. function sendHeroBagDel(human, index)
  312. local msgRet = Msg.gc.GC_HERO_BAG_DELETE
  313. msgRet.index = index
  314. Msg.send(msgRet, human.fd)
  315. end
  316. -- 背包容量查询
  317. function sendHeroBagCap(human)
  318. calcHeroBagCap(human)
  319. local nowBuyCnt = human.db.buyCapCnt or 0
  320. local msgRet = Msg.gc.GC_HERO_CAP_QUERY
  321. msgRet.cap = human.db.heroBag[0]
  322. msgRet.buyZuanshi = (nowBuyCnt + 1) * 100
  323. if nowBuyCnt >= HeroDefine.BUY_CAP_CNT then
  324. msgRet.buyZuanshi = -1 --达到上限
  325. end
  326. Msg.send(msgRet, human.fd)
  327. end
  328. -----------------------------------------------------------------------------------------
  329. -- 锁定英雄
  330. function lockHero(human, isLock, heroID, heroIndex)
  331. local heroGrid = human.db.heroBag[heroIndex]
  332. if heroGrid == nil or heroGrid.id ~= heroID then
  333. return
  334. end
  335. if isLock == 1 then
  336. heroGrid.isLock = true
  337. elseif isLock == 0 then
  338. heroGrid.isLock = nil
  339. end
  340. local msgRet = Msg.gc.GC_HERO_BAG_LOCK
  341. msgRet.heroID = heroID
  342. msgRet.heroIndex = heroIndex
  343. msgRet.type = heroGrid.isLock and 1 or 0
  344. Msg.send(msgRet, human.fd)
  345. end
  346. -- 返回英雄背包空余格子数
  347. function getEmptyCnt(human)
  348. local emptyCnt = 0
  349. for i = 1, human.db.heroBag[0] do
  350. if human.db.heroBag[i] == nil then
  351. emptyCnt = emptyCnt + 1
  352. end
  353. end
  354. return emptyCnt
  355. end
  356. -- 获得英雄背包第一个空格子下标
  357. function getEmptyIndex(human)
  358. for index = 1, human.db.heroBag[0]do
  359. local grid = human.db.heroBag[index]
  360. if grid == nil then
  361. return index
  362. end
  363. end
  364. end
  365. -- 新增英雄
  366. function addHero(human, id, star, cnt, logType, noSend)
  367. if cnt < 1 then return end
  368. local heroConfig = HeroExcel.hero[id]
  369. if not heroConfig then return end
  370. -- 某些英雄自动分解
  371. local isFenjie, fenjieList = FenjieLogic.autoFenjie(human, id, cnt, logType)
  372. if isFenjie then
  373. return nil, fenjieList
  374. end
  375. -- 先判断英雄背包是否满
  376. if getEmptyCnt(human) < cnt then
  377. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  378. end
  379. local heroIndex, uuid = nil
  380. for i = 1, cnt do
  381. local heroGrid = HeroGrid.createHeroGrid(id,star)
  382. heroIndex = addHeroByGrid(human, heroGrid, logType, noSend)
  383. uuid = heroGrid.uuid
  384. end
  385. return heroIndex, uuid
  386. end
  387. -- 英雄添加日志
  388. function writeLogHeroAdd(human, logType, heroGrid)
  389. Log.write(Log.LOGID_OSS_HERO, human.db._id, human.db.account, human.db.name, human.db.lv,
  390. LogDefine.DEFINE[logType] + LogDefine.TYPE["hero"] , heroGrid.id, 1, heroGrid.uuid, heroGrid.star)
  391. end
  392. -- 英雄删除日志
  393. function writeLogHeroDel(human, logType, heroGrid)
  394. Log.write(Log.LOGID_OSS_HERO, human.db._id, human.db.account, human.db.name, human.db.lv,
  395. LogDefine.DEFINE[logType] + LogDefine.TYPE["hero"] , heroGrid.id, -1, heroGrid.uuid, heroGrid.star)
  396. end
  397. -- 新增英雄
  398. function addHeroByGrid(human, heroGrid, logType, noSend)
  399. if not LogDefine.DEFINE[logType] or not LogDefine.TYPE["hero"] then
  400. assert()
  401. end
  402. local heroConfig = HeroExcel.hero[heroGrid.id]
  403. if not heroConfig then return end
  404. -- 某些英雄自动分解
  405. local isFenjie, fenjieList = FenjieLogic.autoFenjie(human, heroGrid.id, 1, logType)
  406. if isFenjie then
  407. return nil, fenjieList
  408. end
  409. -- 先判断英雄背包是否满
  410. if getEmptyCnt(human) < 1 then
  411. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  412. end
  413. local emptyIndex = getEmptyIndex(human)
  414. if not emptyIndex then return end
  415. heroGrid.bagIndex = emptyIndex
  416. human.db.heroBag[emptyIndex] = heroGrid
  417. ObjHuman.doCalcHero(human, emptyIndex)
  418. if not noSend then
  419. sendHeroBagUpdate(human, emptyIndex)
  420. end
  421. onGetNewHero(human, heroGrid, logType, emptyIndex)
  422. writeLogHeroAdd(human, logType, heroGrid)
  423. checkChangeMaxZDL(human, heroGrid)
  424. return emptyIndex
  425. end
  426. local yunYingActParam = {}
  427. function onGetNewHero(human, heroGrid, logType, heroIndex)
  428. local heroConfig = HeroExcel.hero[heroGrid.id]
  429. local grade = heroConfig.grade
  430. HeroBook.onAddHero(human, heroGrid.id, heroGrid.star)
  431. RoleHeadLogic.onAddHero(human, heroGrid.id)
  432. -- 先知置换 和十星置换 不予计算活动
  433. if logType ~= "xianzhi_zhihuan" and logType ~= "tenStar_displace" then
  434. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_HERO)
  435. TuiSongLiBao.tuiSongLiBaoOnTask(human, TuiSongLiBao.TUISONGLIBAOTASK_STARS_HERO, heroConfig.star, nil)
  436. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE12, heroGrid.star)
  437. if grade == 4 then
  438. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_15,1)
  439. end
  440. end
  441. XingYaoGongMing.onAddHero(human,heroGrid,heroIndex)
  442. HeroLogLogic.finishTaskCB(human, HeroLogLogic.HERO_LOG_TYPE_7, 1, heroGrid.id)
  443. for i in ipairs(yunYingActParam) do
  444. yunYingActParam[i] = nil
  445. end
  446. yunYingActParam[1] = logType
  447. yunYingActParam[2] = heroGrid.id
  448. yunYingActParam[3] = 1
  449. YunYingLogic.onCallBack(human, "onGetNewHeroAct", yunYingActParam)
  450. for i in ipairs(yunYingActParam) do
  451. yunYingActParam[i] = nil
  452. end
  453. yunYingActParam[1] = heroGrid.id
  454. yunYingActParam[2] = heroGrid.star
  455. yunYingActParam[3] = 1
  456. YunYingLogic.onCallBack(human, "onHeroStarChange", yunYingActParam)
  457. end
  458. -- 根据下标删除英雄
  459. function delHeroByIndex(human, index, logType, noSend)
  460. if not LogDefine.DEFINE[logType] or not LogDefine.TYPE["hero"] then
  461. assert()
  462. end
  463. if human.db.heroBag[index] == nil then
  464. return
  465. end
  466. --SkinLogic.onDelHero(human, index)
  467. local heroGrid = human.db.heroBag[index]
  468. human.db.heroBag[index] = nil
  469. human.heroAttrs[index] = nil
  470. if not noSend then
  471. sendHeroBagDel(human, index)
  472. end
  473. -- 删除酒馆任务中的上战的英雄
  474. BarTaskLogic.heroIndexByDelForPos(human, index)
  475. -- 删除 默认出站队列中的 英雄
  476. CombatPosLogic.heroIndexByDelForPos(human, heroGrid.uuid)
  477. XingYaoGongMing.onDelHero(human,heroGrid,index)
  478. ObjHuman.doCalc(human)
  479. writeLogHeroDel(human, logType, heroGrid)
  480. end
  481. -- 英雄升级
  482. function heroLvUp(human, heroID, heroIndex)
  483. local heroGrid = human.db.heroBag[heroIndex]
  484. if heroGrid == nil or heroGrid.id ~= heroID then
  485. return
  486. end
  487. local heroConfig = HeroExcel.hero[heroID]
  488. if not heroConfig then return end
  489. if XingYaoGongMing.isGongMing(human,heroIndex,XingYaoGongMing.XYHERO_LV) then
  490. return
  491. end
  492. -- 判断等级上限
  493. local star = heroGrid.star
  494. local nowLv = heroGrid.lv
  495. local maxLv = HeroGrid.getMaxLv(star, heroGrid.quality)
  496. local upLv, needJinbi, needSoulCnt = HeroGrid.getLevelUpCnt(human, nowLv, maxLv)
  497. --print(" upLv, needJinbi, needSoulCnt", upLv, needJinbi, needSoulCnt)
  498. if upLv < 1 then return end
  499. -- 判断消耗材料
  500. if human.db.jinbi < needJinbi then
  501. return Broadcast.sendErr(human, Lang.COMMON_NO_JINBI)
  502. end
  503. if BagLogic.getItemCnt(human, ItemDefine.ITEM_GREEN_EXP_ID) < needSoulCnt then
  504. local strName = ItemDefine.getValue(ItemDefine.ITEM_GREEN_EXP_ID, "name")
  505. return Broadcast.sendErr(human, Util.format(Lang.COMMON_NO_ITEM, strName))
  506. end
  507. -- 扣道具
  508. ObjHuman.updateJinbi(human, -needJinbi, "hero_up")
  509. BagLogic.delItem(human, ItemDefine.ITEM_GREEN_EXP_ID, needSoulCnt, "hero_up")
  510. -- 改db
  511. heroGrid.lv = nowLv + upLv
  512. ObjHuman.doCalcHero(human, heroIndex)
  513. sendHeroBagDynamic(human, heroID, heroIndex)
  514. local msgRet = Msg.gc.GC_HERO_LEVEL_UP
  515. msgRet.id = heroID
  516. msgRet.index = heroIndex
  517. Msg.send(msgRet, human.fd)
  518. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_HEROUP)
  519. refreshDot(human, heroGrid.uuid)
  520. if nowLv < 50 and heroGrid.lv >= 50 then
  521. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_6,1)
  522. elseif nowLv < 100 and heroGrid.lv >= 100 then
  523. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_14,1)
  524. elseif nowLv < 200 and heroGrid.lv >= 200 then
  525. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_20,1)
  526. elseif nowLv < 145 and heroGrid.lv >= 145 then
  527. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_17,1)
  528. elseif nowLv < 185 and heroGrid.lv >= 185 then
  529. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_18,1)
  530. end
  531. XingYaoGongMing.onHeroLvUp(human,heroGrid,heroIndex)
  532. Log.write(Log.LOGID_OSS_HEROLVUP, human.db._id, human.db.account, human.db.name, heroGrid.uuid, nowLv, heroGrid.lv)
  533. checkChangeMaxZDL(human, heroGrid)
  534. end
  535. -- 英雄升阶查询
  536. function heroUpgradeQuery(human, heroID, heroIndex)
  537. local heroGrid = human.db.heroBag[heroIndex]
  538. if heroGrid == nil or heroGrid.id ~= heroID then
  539. return
  540. end
  541. local cf = HeroExcel.hero[heroID]
  542. if not cf then return end
  543. local star = cf.star
  544. local nextQuality = heroGrid.quality + 1
  545. local maxLv = HeroGrid.getMaxLv(heroGrid.star, nextQuality)
  546. local upcf = UpNeedExcel.upQuality[nextQuality]
  547. if not maxLv or not upcf then
  548. return Broadcast.sendErr(human, Lang.HERO_UPGRADE_ERR_FULL)
  549. end
  550. local nextHeroGrid = HeroGrid.getHeroGridCalcCache(heroGrid)
  551. nextHeroGrid.quality = nextQuality
  552. local nextAttrs = RoleAttr.calcHeroGrid(nextHeroGrid, heroIndex, human)
  553. local zhandouli = RoleAttr.calcZhandouli(nextAttrs)
  554. local msgRet = Msg.gc.GC_HERO_UPGRADE_QUERY
  555. msgRet.id = heroID
  556. msgRet.index = heroIndex
  557. local net = msgRet.data
  558. net.id = heroID
  559. net.maxLv = maxLv
  560. net.zhandouli = zhandouli
  561. net.attr[0] = 4
  562. net.attr[1].key = RoleDefine.ATK
  563. net.attr[1].value = nextAttrs[RoleDefine.ATK]
  564. net.attr[2].key = RoleDefine.HP
  565. net.attr[2].value = nextAttrs[RoleDefine.HP]
  566. net.attr[3].key = RoleDefine.SPEED
  567. net.attr[3].value = nextAttrs[RoleDefine.SPEED]
  568. net.attr[4].key = RoleDefine.DEF
  569. net.attr[4].value = nextAttrs[RoleDefine.DEF]
  570. net.needJinbi = upcf.money
  571. net.needItemCnt = upcf.jinjieshi
  572. --Msg.trace(msgRet)
  573. Msg.send(msgRet, human.fd)
  574. end
  575. -- 英雄升阶
  576. function heroUpgradeDo(human, heroID, heroIndex)
  577. local heroConfig = HeroExcel.hero[heroID]
  578. if not heroConfig then return end
  579. local heroGrid = human.db.heroBag[heroIndex]
  580. if heroGrid == nil or heroGrid.id ~= heroID then
  581. return
  582. end
  583. if XingYaoGongMing.isGongMing(human,heroIndex,XingYaoGongMing.XYHERO_LV) then
  584. return
  585. end
  586. local heroConfig = HeroExcel.hero[heroID]
  587. if not heroConfig then return end
  588. local star = heroGrid.star
  589. local maxQuality = HeroGrid.getMaxQuality(star)
  590. local nextQuality = heroGrid.quality + 1
  591. -- 判断阶数上限
  592. if heroGrid.quality >= maxQuality then
  593. return
  594. end
  595. local upcf = UpNeedExcel.upQuality[nextQuality]
  596. if not upcf then return end
  597. -- 判断消耗材料
  598. local needJinbi = upcf.money
  599. local needItemCnt = upcf.jinjieshi
  600. if human.db.jinbi < needJinbi then
  601. return Broadcast.sendErr(human, Lang.COMMON_NO_JINBI)
  602. end
  603. local nowItemCnt = BagLogic.getItemCnt(human, ItemDefine.ITEM_HERO_UPGRADE_ID)
  604. if nowItemCnt < needItemCnt then
  605. local strName = ItemDefine.getValue(ItemDefine.ITEM_HERO_UPGRADE_ID, "name")
  606. return Broadcast.sendErr(human, Util.format(Lang.COMMON_NO_ITEM, strName))
  607. end
  608. -- 扣材料
  609. ObjHuman.updateJinbi(human, -needJinbi, "hero_upgrade")
  610. BagLogic.delItem(human, ItemDefine.ITEM_HERO_UPGRADE_ID, needItemCnt, "hero_upgrade")
  611. -- 改db
  612. heroGrid.quality = nextQuality
  613. ObjHuman.doCalcHero(human, heroIndex)
  614. sendHeroBagDynamic(human, heroID, heroIndex)
  615. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_UPGRADE)
  616. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_25,1)
  617. local msgRet = Msg.gc.GC_HERO_UPGRADE_DO
  618. msgRet.id = heroID
  619. msgRet.index = heroIndex
  620. Msg.send(msgRet, human.fd)
  621. refreshDot(human, heroGrid.uuid)
  622. XingYaoGongMing.onHeroUpgrade(human,heroGrid,heroIndex)
  623. checkChangeMaxZDL(human, heroGrid)
  624. end
  625. -- 重算背包熔炼
  626. function calcHeroBagCap(human)
  627. local buyCnt = math.min(human.db.buyCapCnt or 0, HeroDefine.BUY_CAP_CNT)
  628. local heroBagCnt = HeroDefine.HERO_BAG_CNT
  629. heroBagCnt = heroBagCnt + (VipLogic.getPowerArgs(human, VipLogic.VIP_POWER12) or 0)
  630. heroBagCnt = heroBagCnt + HeroDefine.HERO_BAG_BUY_ADD_CNT * buyCnt -- 购买获得背包格子
  631. if human.db.blue ~= nil and human.db.blue.isAdd ~= nil then -- 特权
  632. local cnt = TequanExcel.tequan[2].privilege
  633. heroBagCnt = heroBagCnt + cnt
  634. end
  635. if human.db.yellow ~= nil and human.db.yellow.isAdd ~= nil then -- 特权
  636. local cnt = TequanExcel.tequan[1].privilege
  637. heroBagCnt = heroBagCnt + cnt
  638. end
  639. -- 封印之章特权
  640. local cjPrivilege = ChengjiuLogic.checkPrivilege(human,ChengjiuDefine.PRIVILEGE_TYPE_1)
  641. if cjPrivilege then
  642. heroBagCnt = heroBagCnt + cjPrivilege
  643. end
  644. -- 特殊服务器处理
  645. -- vip需求砍掉之后,导致有的玩家英雄数量超过背包数量
  646. -- 经策划确认,140001-140021 服务器所有玩家增加背包数量300
  647. if Config.SVR_INDEX >= 140001 and Config.SVR_INDEX <= 140021 then
  648. heroBagCnt = heroBagCnt + 300
  649. end
  650. human.db.heroBag[0] = heroBagCnt
  651. end
  652. -- 购买英雄背包容量
  653. function buyHeroCap(human)
  654. -- 上限判断
  655. local nowBuyCnt = human.db.buyCapCnt or 0
  656. if nowBuyCnt >= HeroDefine.BUY_CAP_CNT then
  657. return Broadcast.sendErr(human, Lang.HERO_BAG_BUY_CAP_NO_CNT)
  658. end
  659. -- 判断消耗
  660. local needZuanshi = (nowBuyCnt + 1) * 100
  661. if not ObjHuman.checkRMB(human, needZuanshi) then
  662. return
  663. end
  664. -- 扣消耗
  665. ObjHuman.decZuanshi(human, -needZuanshi, "buy_hero_cap")
  666. -- 改db
  667. human.db.buyCapCnt = nowBuyCnt + 1
  668. sendHeroBagCap(human)
  669. Broadcast.sendErr(human, Lang.ITEM_BUY_SUCCESS)
  670. end
  671. -- 最大觉醒
  672. function sendHeroJueXingMax(human, heroID, heroIndex)
  673. local heroConfig = HeroExcel.hero[heroID]
  674. if not heroConfig then return end
  675. local msgRet = Msg.gc.GC_HERO_JUEXING_QUERY_MAX
  676. msgRet.id = heroID
  677. msgRet.index = heroIndex
  678. Msg.send(msgRet, human.fd)
  679. end
  680. local JUEXING_SKILL_DIFF_LIST = {}
  681. function getSkillDiffList(cf1, cf2)
  682. local diffCnt = 0
  683. for i = 1, #cf2.skillList do
  684. local skillID1 = cf1.skillList[i]
  685. local skillID2 = cf2.skillList[i]
  686. if skillID1 ~= skillID2 then
  687. diffCnt = diffCnt + 1
  688. local tb = JUEXING_SKILL_DIFF_LIST[diffCnt] or {}
  689. JUEXING_SKILL_DIFF_LIST[diffCnt] = tb
  690. tb[1] = skillID1
  691. tb[2] = skillID2
  692. end
  693. end
  694. for i = 1, #cf2.beSkillList do
  695. local skillID1 = cf1.beSkillList[i]
  696. local skillID2 = cf2.beSkillList[i]
  697. if skillID1 ~= skillID2 then
  698. diffCnt = diffCnt + 1
  699. local tb = JUEXING_SKILL_DIFF_LIST[diffCnt] or {}
  700. JUEXING_SKILL_DIFF_LIST[diffCnt] = tb
  701. tb[1] = skillID1
  702. tb[2] = skillID2
  703. end
  704. end
  705. return diffCnt, JUEXING_SKILL_DIFF_LIST
  706. end
  707. -- 英雄觉醒预览
  708. local JUEXING_SPEED_UP = {[4]=10}
  709. local JUEXING_ATK_UP = {[5]=40,[6]=40,[7]=40,[8]=40,[9]=40,[10]=20,[11]=20,[12]=20}
  710. local JUEXING_HP_UP = {[5]=50,[6]=50,[7]=50,[8]=50,[9]=50,[10]=30,[11]=30,[12]=30}
  711. function heroJueXingQuery(human, heroID, heroIndex)
  712. local heroConfig = HeroExcel.hero[heroID]
  713. if not heroConfig then return end
  714. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  715. if not heroGrid then return end
  716. -- 判断是否达到开放等级
  717. local isFix, upStarNeedLv, upStarNeedWorldLv = isFixUpStarLv(human, heroGrid.star+1)
  718. if not isFix then
  719. if upStarNeedLv and upStarNeedWorldLv and upStarNeedWorldLv > 0 then
  720. return Broadcast.sendErr(human, Util.format(Lang.HERO_JUEXING_ERR_HEROLV, upStarNeedLv, upStarNeedWorldLv))
  721. elseif upStarNeedLv then
  722. return Broadcast.sendErr(human, Util.format(Lang.HERO_JUEXING_ERR_HEROLV2, upStarNeedLv))
  723. end
  724. return
  725. end
  726. local attrConfig = HeroDefine.getAttrConfig(heroID, heroGrid.star)
  727. if not attrConfig then return end
  728. local nextAttrConfig = HeroDefine.getNextAttrConfig(heroID, heroGrid.star)
  729. if not nextAttrConfig then
  730. return sendHeroJueXingMax(human, heroID, heroIndex)
  731. end
  732. local msgRet = Msg.gc.GC_HERO_JUEXING_QUERY
  733. local dataNet = msgRet.data
  734. local maxQuality = HeroGrid.getMaxQuality(attrConfig.star)
  735. local nextMaxQuality = HeroGrid.getMaxQuality(nextAttrConfig.star)
  736. -- 判断是否达到开放等级
  737. local isFix, upStarNeedLv, upStarNeedWorldLv = isFixUpStarLv(human, heroGrid.star+1)
  738. if not isFix then
  739. if upStarNeedLv and upStarNeedWorldLv and upStarNeedWorldLv > 0 then
  740. return Broadcast.sendErr(human, Util.format(Lang.HERO_JUEXING_ERR_HEROLV, upStarNeedLv, upStarNeedWorldLv))
  741. elseif upStarNeedLv then
  742. return Broadcast.sendErr(human, Util.format(Lang.HERO_JUEXING_ERR_HEROLV2, upStarNeedLv))
  743. end
  744. return
  745. end
  746. dataNet.id = heroID
  747. dataNet.index = heroIndex
  748. dataNet.star = heroGrid.star
  749. dataNet.nextStar = nextAttrConfig.star
  750. dataNet.maxLv = HeroGrid.getMaxLv(heroGrid.star, maxQuality)
  751. dataNet.nextMaxLv = HeroGrid.getMaxLv(nextAttrConfig.star, nextMaxQuality)
  752. -- 展示变化的技能
  753. local diffCnt, diffList = getSkillDiffList(attrConfig, nextAttrConfig)
  754. diffCnt = diffCnt > #dataNet.skillUp and #dataNet.skillUp or diffCnt
  755. dataNet.isAllSkillUp = (diffCnt > 1) and 1 or 0
  756. dataNet.skillUp[0] = diffCnt
  757. for i=1, diffCnt do
  758. makeSkillNet(dataNet.skillUp[i], diffList[i][2])
  759. end
  760. dataNet.speedUp = JUEXING_SPEED_UP[heroConfig.star] or 0
  761. dataNet.atkUpRate = JUEXING_ATK_UP[heroConfig.star] or 0
  762. dataNet.hpUpRate = JUEXING_HP_UP[heroConfig.star] or 0
  763. dataNet.needItems[0] = #attrConfig.needItems
  764. for i = 1, dataNet.needItems[0] do
  765. local itemID = attrConfig.needItems[i][1]
  766. local itemCnt = attrConfig.needItems[i][2]
  767. Grid.makeItem(dataNet.needItems[i], itemID, itemCnt)
  768. end
  769. dataNet.needHeros[0] = 0
  770. for i = 1, #attrConfig.cond do
  771. dataNet.needHeros[0] = dataNet.needHeros[0] + 1
  772. local condNet = dataNet.needHeros[dataNet.needHeros[0]]
  773. makeUpStarCond(condNet, attrConfig.cond[i])
  774. end
  775. dataNet.needItemCnt = attrConfig.jinjieshi
  776. --Msg.trace(msgRet)
  777. Msg.send(msgRet, human.fd)
  778. end
  779. function fontJueXingHeroNet(net, heroGrid, index, human)
  780. local attrs = ObjHuman.getHeroAttrs(human, index)
  781. HeroGrid.makeHeroDynamic(net.dynamicData, heroGrid, index, human)
  782. HeroGrid.makeHeroSimple(net.simpleData, heroGrid, index, human)
  783. net.zhandouli = attrs[RoleDefine.ZHANDOULI] or 0
  784. net.atk = attrs[RoleDefine.ATK] or 0
  785. net.hp = attrs[RoleDefine.HP] or 0
  786. net.def = attrs[RoleDefine.DEF] or 0
  787. net.speed = attrs[RoleDefine.SPEED] or 0
  788. end
  789. -- 检查世界等级或者玩家等级是否满足条件
  790. -- 检查达到角色等级或者世界等级
  791. function isFixUpStarLv(human, targetStar)
  792. local config = HeroExcel.star[targetStar]
  793. if not config then
  794. return false
  795. end
  796. if config.upStarNeedLv >= 0 and human.db.lv >= config.upStarNeedLv then
  797. return true, config.upStarNeedLv, config.upStarNeedWorldLv
  798. end
  799. if config.upStarNeedWorldLv >= 0 and GlobalWorld.getWorldLv() >= config.upStarNeedWorldLv then
  800. return true, config.upStarNeedLv, config.upStarNeedWorldLv
  801. end
  802. return false, config.upStarNeedLv, config.upStarNeedWorldLv
  803. end
  804. -- 英雄觉醒
  805. local yunYingActParam = {}
  806. function heroJueXingDo(human, heroID, heroIndex, inputIDList, inputIndexList)
  807. local heroConfig = HeroExcel.hero[heroID]
  808. if not heroConfig then return end
  809. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  810. if not heroGrid then return end
  811. local attrConfig = HeroDefine.getAttrConfig(heroID, heroGrid.star)
  812. if not attrConfig then return end
  813. local nextAttrConfig = HeroDefine.getNextAttrConfig(heroID, heroGrid.star)
  814. if not nextAttrConfig then return end
  815. -- 判断是否达到开放等级
  816. local isFix, upStarNeedLv, upStarNeedWorldLv = isFixUpStarLv(human, heroGrid.star+1)
  817. if not isFix then
  818. if upStarNeedLv and upStarNeedWorldLv and upStarNeedWorldLv > 0 then
  819. return Broadcast.sendErr(human, Util.format(Lang.HERO_JUEXING_ERR_HEROLV, upStarNeedLv, upStarNeedWorldLv))
  820. elseif upStarNeedLv then
  821. return Broadcast.sendErr(human, Util.format(Lang.HERO_JUEXING_ERR_HEROLV2, upStarNeedLv))
  822. end
  823. return
  824. end
  825. -- 判断消耗材料
  826. local needItemCnt = attrConfig.jinjieshi
  827. if not BagLogic.checkItemCnt(human, ItemDefine.ITEM_HERO_UPGRADE_ID, needItemCnt) then
  828. return
  829. end
  830. -- 额外材料
  831. for i = 1, #attrConfig.needItems do
  832. local itemID = attrConfig.needItems[i][1]
  833. local itemCnt = attrConfig.needItems[i][2]
  834. if not BagLogic.checkItemCnt(human, itemID, itemCnt) then
  835. return
  836. end
  837. end
  838. -- 英雄材料
  839. if not HechengLogic.checkCond(human, inputIDList, inputIndexList, attrConfig.cond) then
  840. return Broadcast.sendErr(human, Lang.HERO_JUEXING_CAILIAO_ERR)
  841. end
  842. -- 比较特别的情况。。
  843. for i = 1, inputIndexList[0] do
  844. if inputIndexList[i] == heroIndex then
  845. return -- 本体同时作为材料,骗分解材料
  846. end
  847. end
  848. -- 扣消耗
  849. BagLogic.delItem(human, ItemDefine.ITEM_HERO_UPGRADE_ID, needItemCnt, "hero_juexing")
  850. local fenjieList = FenjieLogic.fenjie(human, FenjieLogic.FENJIE_DO_JUEXING, inputIDList, inputIndexList)
  851. -- 额外材料
  852. for i = 1, #attrConfig.needItems do
  853. local itemID = attrConfig.needItems[i][1]
  854. local itemCnt = attrConfig.needItems[i][2]
  855. BagLogic.delItem(human, itemID, itemCnt, "hero_juexing")
  856. end
  857. local msgRet = Msg.gc.GC_HERO_JUEXING_DO
  858. msgRet.id = heroID
  859. msgRet.index = heroIndex
  860. msgRet.upStarNeedLv = upStarNeedLv
  861. msgRet.upStarNeedWorldLv = upStarNeedWorldLv
  862. fontJueXingHeroNet(msgRet.oldData, heroGrid, heroIndex, human)
  863. -- 继承英雄等级 阶数 装备 水晶
  864. writeLogHeroDel(human, "hero_juexing", heroGrid)
  865. heroGrid.star = nextAttrConfig.star
  866. onGetNewHero(human, heroGrid, "hero_juexing", heroIndex)
  867. ObjHuman.doCalcHero(human, heroIndex)
  868. sendHeroBagDynamic(human, heroGrid.id, heroIndex)
  869. writeLogHeroAdd(human, "hero_juexing", heroGrid)
  870. fontJueXingHeroNet(msgRet.newData, heroGrid, heroIndex, human)
  871. local diffCnt, diffList = getSkillDiffList(attrConfig, nextAttrConfig)
  872. diffCnt = diffCnt > #msgRet.skillUp and #msgRet.skillUp or diffCnt
  873. msgRet.isAllSkillUp = (diffCnt > 1) and 1 or 0
  874. msgRet.skillUp[0] = diffCnt
  875. for i=1, diffCnt do
  876. makeSkillNet(msgRet.skillUp[i], diffList[i][2])
  877. end
  878. msgRet.itemList[0] = 0
  879. if fenjieList then
  880. for itemID, itemCnt in pairs(fenjieList) do
  881. if msgRet.itemList[0] >= #msgRet.itemList then
  882. break
  883. end
  884. msgRet.itemList[0] = msgRet.itemList[0] + 1
  885. Grid.makeItem(msgRet.itemList[msgRet.itemList[0]], itemID, itemCnt)
  886. end
  887. end
  888. --Msg.trace(msgRet)
  889. Msg.send(msgRet, human.fd)
  890. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE12, nextAttrConfig.star,heroGrid.id)
  891. local newstar = nextAttrConfig.star or 0
  892. local newcamp = heroConfig.camp or 0
  893. LiLianLogic.onCallback(human,LiLianLogic.LILIAN_OUTID24,1,newcamp,newstar)
  894. if newstar == 5 then
  895. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_11,1)
  896. end
  897. if newstar >= 5 then
  898. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_13,1)
  899. end
  900. if newstar == 6 then
  901. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_16,1)
  902. JibanLogic.onCallback(human,2,newstar)
  903. end
  904. if newstar == 10 then
  905. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_23,1)
  906. end
  907. checkChangeMaxZDL(human, heroGrid)
  908. HeroLogLogic.finishTaskCB(human, HeroLogLogic.HERO_LOG_TYPE_8, 1, heroID, newstar)
  909. -- 弹窗礼包相关触发
  910. if human.db.heroLevelUpgrade < heroGrid.star then
  911. human.db.heroLevelUpgrade = heroGrid.star
  912. GiftLogic.trigger(human,Upgrade_HERO_EVENT,{star = heroGrid.star})
  913. end
  914. for i in ipairs(yunYingActParam) do
  915. yunYingActParam[i] = nil
  916. end
  917. yunYingActParam[1] = heroID
  918. yunYingActParam[2] = newstar
  919. yunYingActParam[3] = 1
  920. YunYingLogic.onCallBack(human, "onHeroStarChange", yunYingActParam)
  921. end
  922. -- 英雄重生预览
  923. function heroChongShengQuery(human, heroID, heroIndex)
  924. local heroConfig = HeroExcel.hero[heroID]
  925. if not heroConfig then return end
  926. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  927. if not heroGrid then return end
  928. if heroGrid.isLock then
  929. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_LOCK)
  930. end
  931. local chongShengConfig = UpNeedExcel.chongSheng[heroGrid.star]
  932. if not chongShengConfig then -- 只能重生7-9星
  933. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_ID)
  934. end
  935. -- 没有对应5星的存在
  936. local attrConfig = HeroDefine.getAttrConfig(heroID, CHONGSHENG_RETURN_STAR)
  937. if not attrConfig then
  938. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_ID)
  939. end
  940. local suipianID = SuipianLogic.getSuipianIDbyHeroID(heroID)
  941. if not suipianID then -- 没有对应的本体碎片
  942. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_SUIPIANID)
  943. end
  944. local otherSuipianID = chongShengConfig.suipianIDs[heroConfig.camp]
  945. if not otherSuipianID then -- 阵容不对
  946. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_ID)
  947. end
  948. local msgRet = Msg.gc.GC_HERO_CHONGSHENG_QUERY
  949. msgRet.id = heroID
  950. msgRet.index = heroIndex
  951. msgRet.needItemCnt = chongShengConfig.needItemCnt
  952. Grid.makeItem(msgRet.bentiSuipian, suipianID, chongShengConfig.bentiCnt)
  953. Grid.makeItem(msgRet.otherSuipian, otherSuipianID, chongShengConfig.suipianCnt)
  954. --Msg.trace(msgRet)
  955. Msg.send(msgRet, human.fd)
  956. end
  957. function getHeroMaxStarCtn(human)
  958. local heroBag = human.db.heroBag
  959. local maxStar = 0
  960. local starHeroCnt = 0
  961. for _,grid in ipairs(heroBag) do
  962. if grid.star > maxStar then
  963. maxStar = grid.star
  964. starHeroCnt = 1
  965. elseif grid.star == maxStar then
  966. starHeroCnt = starHeroCnt + 1
  967. end
  968. end
  969. return maxStar,starHeroCnt
  970. end
  971. -- 英雄重生
  972. function heroChongShengDo(human, heroID, heroIndex)
  973. local heroConfig = HeroExcel.hero[heroID]
  974. if not heroConfig then return end
  975. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  976. if not heroGrid then return end
  977. if heroGrid.isLock then
  978. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_LOCK)
  979. end
  980. local chongShengConfig = UpNeedExcel.chongSheng[heroGrid.star]
  981. if not chongShengConfig then -- 只能重生7-9星
  982. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_ID)
  983. end
  984. local attrConfig = HeroDefine.getAttrConfig(heroID, CHONGSHENG_RETURN_STAR)
  985. if not attrConfig then
  986. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_ID)
  987. end
  988. local suipianID = SuipianLogic.getSuipianIDbyHeroID(heroID)
  989. if not suipianID then -- 没有对应的本体碎片
  990. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_SUIPIANID)
  991. end
  992. local otherSuipianID = chongShengConfig.suipianIDs[heroConfig.camp]
  993. if not otherSuipianID then -- 阵营不对
  994. return Broadcast.sendErr(human, Lang.HERO_CHONGSHENG_ERR_ID)
  995. end
  996. local nowItemCnt = BagLogic.getItemCnt(human, ItemDefine.ITEM_HERO_CHONGSHENG_ID)
  997. local needItemCnt = chongShengConfig.needItemCnt
  998. if nowItemCnt < needItemCnt then
  999. local strName = ItemDefine.getValue(ItemDefine.ITEM_HERO_CHONGSHENG_ID, "name")
  1000. local strRet = Util.format(Lang.COMMON_NO_ITEM, strName)
  1001. return Broadcast.sendErr(human, strRet)
  1002. end
  1003. -- 删除材料
  1004. BagLogic.delItem(human, ItemDefine.ITEM_HERO_CHONGSHENG_ID, needItemCnt, "hero_chongsheng")
  1005. -- 重置到初始返还的材料
  1006. local upList = getResetReturnItems(heroGrid)
  1007. -- 先删除英雄
  1008. delHeroByIndex(human, heroIndex, "hero_chongsheng")
  1009. -- 返还装备
  1010. for i = 1, ItemDefine.EQUIP_MAX_CNT do
  1011. if i ~= ItemDefine.EQUIP_SUBTYPE_SHUIJIN and
  1012. heroGrid.equip and heroGrid.equip[i] then
  1013. local equipGrid = heroGrid.equip[i]
  1014. if equipGrid then
  1015. EquipLogic.addByEquipGrid(human, equipGrid, "hero_chongsheng")
  1016. end
  1017. end
  1018. end
  1019. -- 返还符文
  1020. for i = 1, 2 do
  1021. local fuwenGrid = heroGrid.fuwen and heroGrid.fuwen[i]
  1022. if fuwenGrid and fuwenGrid.id then
  1023. FuwenLogic.addByGrid(human, fuwenGrid, "hero_chongsheng")
  1024. end
  1025. end
  1026. -- 再给东西
  1027. BagLogic.addItem(human, suipianID, chongShengConfig.bentiCnt, "hero_chongsheng")
  1028. BagLogic.addItem(human, otherSuipianID, chongShengConfig.suipianCnt, "hero_chongsheng")
  1029. for itemID, itemCnt in pairs(upList) do
  1030. BagLogic.addItem(human, itemID, itemCnt, "hero_chongsheng")
  1031. end
  1032. -- 通知客户端
  1033. local msgRet = Msg.gc.GC_HERO_CHONGSHENG_DO
  1034. msgRet.list[0] = 2
  1035. Grid.makeItem(msgRet.list[1], suipianID, chongShengConfig.bentiCnt)
  1036. Grid.makeItem(msgRet.list[2], otherSuipianID, chongShengConfig.suipianCnt)
  1037. for itemID, itemCnt in pairs(upList) do
  1038. msgRet.list[0] = msgRet.list[0] + 1
  1039. Grid.makeItem(msgRet.list[msgRet.list[0]], itemID, itemCnt)
  1040. end
  1041. msgRet.list[0] = EquipLogic.makeEquipItem(human, msgRet.list, msgRet.list[0])
  1042. Msg.send(msgRet, human.fd)
  1043. checkChangeMaxZDL(human, heroGrid)
  1044. end
  1045. -- 回退
  1046. local HUITUI_HERO_LIST = {}
  1047. local HUITUI_ITEM_LIST = {}
  1048. function getHuituiReturns(heroGrid)
  1049. local heroConfig = HeroExcel.hero[heroGrid.id]
  1050. if not heroConfig then return end
  1051. local config = UpNeedExcel.huiTui[heroGrid.star]
  1052. if not config then return end
  1053. local targetID = heroGrid.id
  1054. if not targetID then return end
  1055. -- 13星无法升级,但可以回退
  1056. if heroGrid.star < 13 then
  1057. local upStarConfig = HeroDefine.getNextAttrConfig(heroGrid.id, heroGrid.star)
  1058. -- 不能升星的话也不能回退
  1059. if not upStarConfig then
  1060. return
  1061. end
  1062. end
  1063. Util.cleanTable(HUITUI_HERO_LIST)
  1064. Util.cleanTable(HUITUI_ITEM_LIST)
  1065. local maxLv = HeroGrid.getMaxLv(config.targetStar, heroGrid.quality)
  1066. local lv = heroGrid.lv
  1067. if heroGrid.oldLV then
  1068. lv = heroGrid.oldLV
  1069. end
  1070. local targetLv = math.min(lv, maxLv)
  1071. -- 升级 不将阶
  1072. for i = targetLv + 1, lv do
  1073. local upcf = UpNeedExcel.upLv[i]
  1074. if upcf then
  1075. HUITUI_ITEM_LIST[ItemDefine.ITEM_GREEN_EXP_ID] = (HUITUI_ITEM_LIST[ItemDefine.ITEM_GREEN_EXP_ID] or 0) + upcf.soul
  1076. HUITUI_ITEM_LIST[ItemDefine.ITEM_JINBI_ID] = (HUITUI_ITEM_LIST[ItemDefine.ITEM_JINBI_ID] or 0) + upcf.money
  1077. end
  1078. end
  1079. -- 圣星文书
  1080. HUITUI_ITEM_LIST[ItemDefine.ITEM_HERO_UPGRADE_BOOK] = (HUITUI_ITEM_LIST[ItemDefine.ITEM_HERO_UPGRADE_BOOK] or 0) + config.upBook
  1081. -- 进阶石
  1082. HUITUI_ITEM_LIST[ItemDefine.ITEM_HERO_UPGRADE_ID] = (HUITUI_ITEM_LIST[ItemDefine.ITEM_HERO_UPGRADE_ID] or 0) + config.jinjieshi
  1083. -- 5星本体碎片数量
  1084. local fiveBentiID = heroGrid.id
  1085. local fiveBentiSuipianID = SuipianLogic.getSuipianIDbyHeroID(fiveBentiID)
  1086. HUITUI_ITEM_LIST[fiveBentiSuipianID] = (HUITUI_ITEM_LIST[fiveBentiSuipianID] or 0) + config.fiveBentiCnt
  1087. -- 5星同系碎片数量
  1088. local materialConfig = UpNeedExcel.huiTuiMaterial[heroConfig.camp]
  1089. HUITUI_ITEM_LIST[materialConfig.fiveHeroSuipian] = (HUITUI_ITEM_LIST[materialConfig.fiveHeroSuipian] or 0) + config.fiveSuipianCnt
  1090. -- 9星傀儡数量
  1091. local nineHeroCnt = (HUITUI_HERO_LIST[9] and HUITUI_HERO_LIST[9][2] or 0) + config.nineHeroCnt
  1092. HUITUI_HERO_LIST[9] = {materialConfig.nineHero, nineHeroCnt}
  1093. -- 10星傀儡数量
  1094. local tenHeroCnt = (HUITUI_HERO_LIST[10] and HUITUI_HERO_LIST[10][2] or 0) + config.tenHeroCnt
  1095. HUITUI_HERO_LIST[10] = {materialConfig.tenHero, tenHeroCnt}
  1096. return config.targetStar, targetLv, config, HUITUI_ITEM_LIST, HUITUI_HERO_LIST
  1097. end
  1098. -- 回退查询
  1099. function sendHuituiQuery(human, heroID, heroIndex)
  1100. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  1101. if not heroGrid then return end
  1102. local star, targetLv, config, items, heros = getHuituiReturns(heroGrid)
  1103. if not star then
  1104. return Broadcast.sendErr(human, Lang.HERO_HUITUI_ERR_STAR)
  1105. end
  1106. local msgRet = Msg.gc.GC_HERO_HUITUI_QUERY
  1107. msgRet.heroID = heroID
  1108. msgRet.heroIndex = heroIndex
  1109. HeroGrid.makeHeroSimple(msgRet.oldSimple, heroGrid, heroIndex, human)
  1110. local others = HeroGrid.createOthers(targetLv, nil,nil, star)
  1111. HeroGrid.makeHeroSimpleByID(msgRet.newSimple, heroID, heroIndex, others, nil, true)
  1112. HeroGrid.makeHeroSimpleByGeneral(msgRet.newSimple, heroID)
  1113. Grid.makeItem(msgRet.needItem, ItemDefine.ITEM_HERO_HUITUI_ID, config.needItemCnt)
  1114. msgRet.returnItems[0] = 0
  1115. for itemID, itemCnt in pairs(items) do
  1116. if msgRet.returnItems[0] >= #msgRet.returnItems then
  1117. break
  1118. end
  1119. if itemCnt > 0 then
  1120. msgRet.returnItems[0] = msgRet.returnItems[0] + 1
  1121. Grid.makeItem(msgRet.returnItems[msgRet.returnItems[0]], itemID, itemCnt)
  1122. end
  1123. end
  1124. msgRet.returnHeros[0] = 0
  1125. for star, v in pairs(heros) do
  1126. local rHeroID = v[1]
  1127. local rHeroCnt = v[2]
  1128. for i = 1, rHeroCnt do
  1129. if msgRet.returnHeros[0] >= #msgRet.returnHeros then
  1130. break
  1131. end
  1132. local others = HeroGrid.createOthers(1, nil,nil, star)
  1133. msgRet.returnHeros[0] = msgRet.returnHeros[0] + 1
  1134. local heroNet = msgRet.returnHeros[msgRet.returnHeros[0]]
  1135. HeroGrid.makeHeroSimpleByID(heroNet, rHeroID, nil, others, human)
  1136. HeroGrid.makeHeroSimpleByGeneral(heroNet, rHeroID)
  1137. heroNet.star = star
  1138. end
  1139. end
  1140. --Msg.trace(msgRet)
  1141. Msg.send(msgRet, human.fd)
  1142. end
  1143. -- 回退操作
  1144. function huituiHero(human, heroID, heroIndex)
  1145. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  1146. if not heroGrid then return end
  1147. local star, targetLv, config, items, heros = getHuituiReturns(heroGrid)
  1148. if not star then
  1149. return Broadcast.sendErr(human, Lang.HERO_HUITUI_ERR_STAR)
  1150. end
  1151. if heroGrid.isLock then
  1152. return Broadcast.sendErr(human, Lang.HERO_HUITUI_ERR_LOCK)
  1153. end
  1154. local needHeroBagCnt = 0
  1155. for star, v in pairs(heros) do
  1156. local rHeroCnt = v[2]
  1157. needHeroBagCnt = needHeroBagCnt + rHeroCnt
  1158. end
  1159. -- 检查英雄背包空间
  1160. if getEmptyCnt(human) < needHeroBagCnt then
  1161. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  1162. end
  1163. if not BagLogic.checkItemCnt(human, ItemDefine.ITEM_HERO_HUITUI_ID, config.needItemCnt) then
  1164. return
  1165. end
  1166. BagLogic.delItem(human, ItemDefine.ITEM_HERO_HUITUI_ID, config.needItemCnt, "hero_huitui")
  1167. heroGrid.star = star
  1168. heroGrid.lv = targetLv
  1169. XingYaoGongMing.onDelHero(human,heroGrid,heroIndex)
  1170. ObjHuman.doCalcHero(human, heroIndex)
  1171. sendHeroBagDynamic(human, heroID, heroIndex)
  1172. writeLogHeroAdd(human, "hero_huitui", heroGrid)
  1173. for itemID, itemCnt in pairs(items) do
  1174. if itemCnt > 0 then
  1175. BagLogic.addItem(human, itemID, itemCnt, "hero_huitui")
  1176. end
  1177. end
  1178. for star,v in pairs(heros) do
  1179. local rHeroID = v[1]
  1180. local rHeroCnt = v[2]
  1181. if rHeroCnt > 0 then
  1182. addHero(human, rHeroID,star, rHeroCnt, "hero_huitui")
  1183. end
  1184. end
  1185. local msgRet = Msg.gc.GC_HERO_HUITUI
  1186. msgRet.heroID = heroID
  1187. msgRet.heroIndex = heroIndex
  1188. HeroGrid.makeHeroSimple(msgRet.newSimple, heroGrid, heroIndex, human)
  1189. msgRet.returnItems[0] = 0
  1190. for itemID, itemCnt in pairs(items) do
  1191. if msgRet.returnItems[0] >= #msgRet.returnItems then
  1192. break
  1193. end
  1194. if itemCnt > 0 then
  1195. msgRet.returnItems[0] = msgRet.returnItems[0] + 1
  1196. Grid.makeItem(msgRet.returnItems[msgRet.returnItems[0]], itemID, itemCnt)
  1197. end
  1198. end
  1199. msgRet.returnHeros[0] = 0
  1200. for star,v in pairs(heros) do
  1201. local rHeroID = v[1]
  1202. local rHeroCnt = v[2]
  1203. for i = 1, rHeroCnt do
  1204. if msgRet.returnHeros[0] >= #msgRet.returnHeros then
  1205. break
  1206. end
  1207. msgRet.returnHeros[0] = msgRet.returnHeros[0] + 1
  1208. local heroNet = msgRet.returnHeros[msgRet.returnHeros[0]]
  1209. HeroGrid.makeHeroSimpleByID(heroNet, rHeroID, nil, nil, human)
  1210. heroNet.star = star
  1211. end
  1212. end
  1213. --Msg.trace(msgRet)
  1214. Msg.send(msgRet, human.fd)
  1215. checkChangeMaxZDL(human, heroGrid)
  1216. end
  1217. function getHeroListById(human,heroId)
  1218. local heroDBBag = human.db.heroBag
  1219. local list = {}
  1220. for idx,grid in pairs(heroDBBag) do
  1221. if heroGrid.id ~= heroId then
  1222. list[#list+1] = idx
  1223. end
  1224. end
  1225. return list
  1226. end
  1227. function getHeroGrid(human, heroID, heroIndex)
  1228. if not heroID then return end
  1229. if not heroIndex then return end
  1230. local heroGrid = human.db.heroBag[heroIndex]
  1231. if type(heroGrid) ~= "table" or heroGrid.id ~= heroID then
  1232. return
  1233. end
  1234. return heroGrid
  1235. end
  1236. -- 根据uuid 获取heroGrid
  1237. function getHeroGridByUuid(human, uuid)
  1238. if not uuid or uuid == "" or uuid == "0" then return end
  1239. for index = 1, human.db.heroBag[0] do
  1240. local heroGrid = human.db.heroBag[index]
  1241. if heroGrid and type(heroGrid) == "table" then
  1242. if heroGrid.uuid == uuid then
  1243. return heroGrid
  1244. end
  1245. end
  1246. end
  1247. return nil
  1248. end
  1249. -- 获取下标英雄id
  1250. function getHeroIdByIndex(human, heroIndex)
  1251. if heroIndex <= 0 then
  1252. return
  1253. end
  1254. local heroGrid = human.db.heroBag[heroIndex]
  1255. if heroGrid == nil then
  1256. return
  1257. end
  1258. return heroGrid.id
  1259. end
  1260. function makeHeroShare(msg, heroGrid, bagIndex, human)
  1261. if type(heroGrid) ~= "table" then return end
  1262. local heroConfig = HeroExcel.hero[heroGrid.id]
  1263. if not heroConfig then return end
  1264. msg.uuid = human.db._id
  1265. msg.heroIndex = bagIndex
  1266. HeroGrid.makeHeroSimple(msg.heroSimple, heroGrid, bagIndex, human)
  1267. HeroGrid.makeHeroStatic(msg.heroStatic, heroGrid.id)
  1268. HeroGrid.makeHeroDynamic(msg.heroDynamic, heroGrid, bagIndex, human)
  1269. -- 装备信息
  1270. msg.equips[0] = 0
  1271. for i = 1, ItemDefine.EQUIP_MAX_CNT do
  1272. local equipGrid = heroGrid.equip and heroGrid.equip[i]
  1273. if equipGrid then
  1274. msg.equips[0] = msg.equips[0] + 1
  1275. local equipNet = msg.equips[msg.equips[0]]
  1276. Grid.makeItem(equipNet, equipGrid.id, 1, heroGrid.shuijingAttrID, equipGrid)
  1277. end
  1278. end
  1279. -- 符文
  1280. msg.fuWens[0] = 0
  1281. for i = 1, 2 do
  1282. local fuwenData = heroGrid.fuwen and heroGrid.fuwen[i]
  1283. if fuwenData and fuwenData.id then
  1284. msg.fuWens[0] = msg.fuWens[0] + 1
  1285. local fuwenNet = msg.fuWens[msg.fuWens[0]]
  1286. fuwenNet.pos = i
  1287. Grid.makeItem(fuwenNet.fuwen, fuwenData.id, 1, nil, fuwenData, i,0)
  1288. end
  1289. end
  1290. return true
  1291. end
  1292. function makeHeroShareMonster(msg, monsterID, mosnterLv)
  1293. local others = HeroGrid.createOthers(mosnterLv)
  1294. msg.uuid = ""
  1295. msg.heroIndex = 0
  1296. HeroGrid.makeHeroSimpleByMonsterID(msg.heroSimple, monsterID, others)
  1297. HeroGrid.makeHeroStatic(msg.heroStatic, monsterID)
  1298. HeroGrid.makeHeroDynamicByID(msg.heroDynamic, monsterID)
  1299. msg.equips[0] = 0
  1300. msg.fuWens[0] = 0
  1301. end
  1302. function getHeroShareGrid(uuid, heroIndex)
  1303. local fakeHuman = ObjHuman.onlineUuid[uuid]
  1304. if not fakeHuman then
  1305. local db = RoleDBLogic.getDb(uuid, RoleLogic.getCombatField())
  1306. if not db then
  1307. return
  1308. end
  1309. fakeHuman = {db = db}
  1310. end
  1311. local bagIndex = heroIndex
  1312. local heroGrid = bagIndex and fakeHuman.db.heroBag[bagIndex]
  1313. return heroGrid, bagIndex, fakeHuman
  1314. end
  1315. function shareData(human, uuid, heroIndex)
  1316. local msgRet = Msg.gc.GC_HERO_SHARE_DATA
  1317. local heroGrid, bagIndex, fakeHuman = getHeroShareGrid(uuid, heroIndex)
  1318. if heroGrid then
  1319. if not makeHeroShare(msgRet.data, heroGrid, bagIndex, fakeHuman) then
  1320. return
  1321. end
  1322. else
  1323. local monsterID, mosnterLv = JjcLogic.getHeroShareMonster(uuid, heroIndex)
  1324. if not monsterID then return end
  1325. makeHeroShareMonster(msgRet.data, monsterID, mosnterLv)
  1326. end
  1327. Msg.send(msgRet, human.fd)
  1328. end
  1329. -- 获取英雄背包中 最大等级的英雄
  1330. function getHeroBagMaxLev(human)
  1331. local maxLv = 1
  1332. for index,heroGrid in pairs(human.db.heroBag) do
  1333. if index ~= 0 and heroGrid.lv > maxLv then
  1334. maxLv = heroGrid.lv
  1335. end
  1336. end
  1337. return maxLv
  1338. end
  1339. -- 获取英雄背包中 最大星级的英雄
  1340. function getHeroBagMaxFuNeng(human)
  1341. local maxStar = 0
  1342. for index,heroGrid in pairs(human.db.heroBag) do
  1343. if index ~= 0 and heroGrid.id then
  1344. local heroConfig = HeroExcel.hero[heroGrid.id]
  1345. if heroConfig and heroConfig.star > 10 then
  1346. local star = heroConfig.star - 10
  1347. if star > maxStar then
  1348. maxStar = star
  1349. end
  1350. if maxStar >= HERO_MAX_STAR - 10 then
  1351. return maxStar
  1352. end
  1353. end
  1354. end
  1355. end
  1356. return maxStar
  1357. end
  1358. -- 战力最高的6个英雄战力和
  1359. local function sortCombat(a, b)
  1360. return a.zhandouli > b.zhandouli
  1361. end
  1362. local HeroSortTable = {}
  1363. function getHerosZDL(human)
  1364. Util.cleanTable(HeroSortTable)
  1365. local len = 0
  1366. for index,heroGrid in pairs(human.db.heroBag) do
  1367. if index ~= 0 then
  1368. len = len + 1
  1369. HeroSortTable[len] = heroGrid
  1370. end
  1371. end
  1372. if len > 1 then
  1373. table.sort(HeroSortTable, sortCombat)
  1374. end
  1375. local zhandouli = 0
  1376. for i = 1, 6 do
  1377. local grid = HeroSortTable[i]
  1378. zhandouli = zhandouli + (grid and grid.zhandouli or 0)
  1379. end
  1380. return zhandouli
  1381. end
  1382. --
  1383. function getHeroMaxZDL(human, camp)
  1384. local zhandouli = 0
  1385. local maxGrid = nil
  1386. for index,heroGrid in pairs(human.db.heroBag) do
  1387. if index ~= 0 then
  1388. local heroConfig = heroGrid and HeroExcel.hero[heroGrid.id]
  1389. if heroConfig and ((camp or 0) == 0 or heroConfig.camp == camp)
  1390. and heroGrid.zhandouli > zhandouli then
  1391. zhandouli = heroGrid.zhandouli
  1392. maxGrid = heroGrid
  1393. end
  1394. end
  1395. end
  1396. return zhandouli, maxGrid
  1397. end
  1398. -- 武将系统红点
  1399. function isDot(human)
  1400. if human.db.lv < 9 then
  1401. return false
  1402. end
  1403. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
  1404. if not combatHero then return end
  1405. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  1406. local uuid = combatHero[i]
  1407. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  1408. if heroGrid then
  1409. if isHeroDot(human, heroGrid) then
  1410. return true
  1411. end
  1412. if HeroBook.isDot(human) == 1 then
  1413. return true
  1414. end
  1415. end
  1416. end
  1417. end
  1418. -- 某个伙伴是否有红点
  1419. function isHeroDot(human, heroGrid)
  1420. if not heroGrid then return end
  1421. if human.db.lv < 9 then
  1422. return false
  1423. end
  1424. -- 装备
  1425. if HeroEquip.isEquipDot(human, heroGrid) then
  1426. return true
  1427. end
  1428. if FuwenLogic.isFuwenDot(human, heroGrid) then
  1429. return true
  1430. end
  1431. -- 升级/进阶
  1432. if isHeroLevelDot(human, heroGrid) and
  1433. not XingYaoGongMing.isGongMing(human,heroIndex) then
  1434. return true
  1435. end
  1436. --
  1437. if isHeroJuexingDot(human, heroGrid.bagIndex, heroGrid) then
  1438. return true
  1439. end
  1440. if BingshuLogic.isBingShuDot(human, heroGrid) then
  1441. return
  1442. end
  1443. end
  1444. -- 升级判定
  1445. function isHeroLvDot(human, heroGrid)
  1446. if human.db.lv < 9 then
  1447. return false
  1448. end
  1449. local heroConfig = HeroExcel.hero[heroGrid.id]
  1450. if not heroConfig then return end
  1451. local lv = heroGrid and heroGrid.lv or 1
  1452. local star = heroConfig and heroConfig.star or 0
  1453. local quality = heroGrid and heroGrid.quality or 0
  1454. local maxLv = HeroGrid.getMaxLv(heroGrid.star, quality)
  1455. if lv < maxLv then -- 升级
  1456. local conf = UpNeedExcel.upLv[lv + 1]
  1457. if not conf then return end
  1458. if human.db.jinbi < conf.money then return end
  1459. if BagLogic.getItemCnt(human, ItemDefine.ITEM_GREEN_EXP_ID) < conf.soul then
  1460. return
  1461. end
  1462. return true
  1463. end
  1464. end
  1465. -- 进阶判断
  1466. function isHeroUpDot(human, heroGrid)
  1467. if human.db.lv < 9 then
  1468. return false
  1469. end
  1470. local heroConfig = HeroExcel.hero[heroGrid.id]
  1471. if not heroConfig then return end
  1472. local lv = heroGrid and heroGrid.lv or 1
  1473. local star = heroGrid and heroGrid.star or 0
  1474. local quality = heroGrid and heroGrid.quality or 0
  1475. -- 进阶
  1476. local maxQuality = HeroGrid.getMaxQuality(star)
  1477. if quality >= maxQuality then
  1478. return
  1479. end
  1480. local maxLv = HeroGrid.getMaxLv(heroGrid.star, maxQuality)
  1481. if lv < maxLv then
  1482. return
  1483. end
  1484. local conf = UpNeedExcel.upQuality[quality + 1]
  1485. if not conf then return end
  1486. if human.db.jinbi < conf.money then return end
  1487. if BagLogic.getItemCnt(human, ItemDefine.ITEM_HERO_UPGRADE_ID) < conf.jinjieshi then
  1488. return
  1489. end
  1490. return true
  1491. end
  1492. -- 升级/进阶判断
  1493. function isHeroLevelDot(human, heroGrid)
  1494. if human.db.lv < 9 then
  1495. return false
  1496. end
  1497. if isHeroLvDot(human, heroGrid) then -- 升级
  1498. return true
  1499. end
  1500. if isHeroUpDot(human, heroGrid) then -- 进阶判断
  1501. return true
  1502. end
  1503. end
  1504. -- 升星/觉醒红点
  1505. function isHeroJuexingDot(human, heroIndex, heroGrid)
  1506. if human.db.lv < 9 then
  1507. return
  1508. end
  1509. local heroConfig = HeroExcel.hero[heroGrid.id]
  1510. if not heroConfig then return end
  1511. local attrConfig = HeroDefine.getAttrConfig(heroGrid.id, heroGrid.star)
  1512. if not attrConfig then return end
  1513. local nextAttrConfig = HeroDefine.getNextAttrConfig(heroGrid.id, heroGrid.star)
  1514. if not nextAttrConfig then
  1515. return sendHeroJueXingMax(human, heroGrid.id, heroIndex)
  1516. end
  1517. -- 角色等级/世界等级是否可以
  1518. local isFix = isFixUpStarLv(human, heroGrid.star+1)
  1519. if not isFix then return end
  1520. -- 判断消耗材料
  1521. local needItemCnt = attrConfig.jinjieshi
  1522. if BagLogic.getItemCnt(human, ItemDefine.ITEM_HERO_UPGRADE_ID) < needItemCnt then
  1523. return
  1524. end
  1525. -- 额外材料
  1526. for i = 1, #attrConfig.needItems do
  1527. local itemID = attrConfig.needItems[i][1]
  1528. local itemCnt = attrConfig.needItems[i][2]
  1529. if BagLogic.getItemCnt(human, itemID) < itemCnt then
  1530. return
  1531. end
  1532. end
  1533. local without = {}
  1534. without[heroIndex] = true
  1535. for _, cond in ipairs(attrConfig.cond) do
  1536. local ctype = cond[1]
  1537. local needCnt = cond[3]
  1538. if not needCnt then return end
  1539. if ctype == HechengLogic.COND_TYPE_CAMPSTAR then
  1540. needCnt = cond[4]
  1541. end
  1542. for i = 1, needCnt do
  1543. local index = selectJuexingGrid(human, ctype, cond, without)
  1544. if not index then return end
  1545. without[index] = true
  1546. end
  1547. end
  1548. return true
  1549. end
  1550. -- 查找升星材料
  1551. function selectJuexingGrid(human, ctype, cond, without)
  1552. for index,heroGrid in pairs(human.db.heroBag) do
  1553. if index ~= 0 and not without[index] and
  1554. isFixJuexingCond(heroGrid, ctype, cond) then
  1555. return index
  1556. end
  1557. end
  1558. end
  1559. -- 是否满足材料需求
  1560. function isFixJuexingCond(grid, ctype, cond)
  1561. local heroConfig = HeroExcel.hero[grid.id]
  1562. if not heroConfig then return end
  1563. if ctype == HechengLogic.COND_TYPE_HEROID then
  1564. local needConfig = HeroExcel.hero[cond[2]]
  1565. if not needConfig then return end
  1566. local needStar = cond[4] or needConfig.star
  1567. if grid.id == cond[2] and needStar == grid.star then
  1568. return true
  1569. end
  1570. elseif ctype == HechengLogic.COND_TYPE_CAMPSTAR then
  1571. if cond[2] ~= 0 and cond[2] ~= heroConfig.camp then
  1572. return
  1573. end
  1574. if cond[3] ~= grid.star then
  1575. return
  1576. end
  1577. return true
  1578. end
  1579. end
  1580. function sendBagDots(human)
  1581. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
  1582. local msgRet = Msg.gc.GC_HERO_BAG_DOTS
  1583. msgRet.list[0] = 0
  1584. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  1585. local uuid = combatHero and combatHero[i]
  1586. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  1587. if heroGrid then
  1588. msgRet.list[0] = msgRet.list[0] + 1
  1589. local net = msgRet.list[msgRet.list[0]]
  1590. net.bagIndex = heroGrid.bagIndex
  1591. net.isDot = isHeroDot(human, heroGrid) and 1 or 0
  1592. end
  1593. end
  1594. --Msg.trace(msgRet)
  1595. msgRet.bookDot = HeroBook.isDot(human)
  1596. Msg.send(msgRet, human.fd)
  1597. refreshDot(human)
  1598. end
  1599. function refreshDot(human, uuid)
  1600. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
  1601. if not combatHero then return end
  1602. local isFind = nil
  1603. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  1604. if uuid == nil or combatHero[i] == uuid then
  1605. isFind = true
  1606. break
  1607. end
  1608. end
  1609. if not isFind then return end
  1610. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_301)
  1611. end
  1612. -- 今日英雄重置剩余次数
  1613. function getResetLeftCnt(human)
  1614. local heroResetCnt = human.db.heroResetCnt or 0
  1615. return math.max(HERO_RESET_FREECNT - heroResetCnt, 0)
  1616. end
  1617. -- 重置返还材料
  1618. local RESET_RETURN_ITEMS = {}
  1619. function getResetReturnItems(heroGrid)
  1620. Util.cleanTable(RESET_RETURN_ITEMS)
  1621. -- 升级
  1622. local lv = heroGrid.lv
  1623. if heroGrid.oldLV then
  1624. lv = heroGrid.oldLV
  1625. end
  1626. for i = 2, lv do
  1627. local upcf = UpNeedExcel.upLv[i]
  1628. if upcf then
  1629. RESET_RETURN_ITEMS[ItemDefine.ITEM_GREEN_EXP_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_GREEN_EXP_ID] or 0) + upcf.soul
  1630. RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] or 0) + upcf.money
  1631. end
  1632. end
  1633. -- 升阶
  1634. local quality = heroGrid.quality
  1635. if heroGrid.oldQuality then
  1636. quality = heroGrid.oldQuality
  1637. end
  1638. -- 升阶
  1639. for i = 1, quality do
  1640. local upcf = UpNeedExcel.upQuality[i]
  1641. if upcf then
  1642. RESET_RETURN_ITEMS[ItemDefine.ITEM_HERO_UPGRADE_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_HERO_UPGRADE_ID] or 0) + upcf.jinjieshi
  1643. RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] or 0) + upcf.money
  1644. end
  1645. end
  1646. -- 升星材料
  1647. for i = 1,heroGrid.star do
  1648. local attrConfig = HeroDefine.getAttrConfig(heroGrid.id, i)
  1649. if attrConfig then
  1650. if attrConfig.jinjieshi > 0 then RESET_RETURN_ITEMS[ItemDefine.ITEM_HERO_UPGRADE_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_HERO_UPGRADE_ID] or 0) + attrConfig.jinjieshi end
  1651. for j = 1,#attrConfig.needItems do
  1652. RESET_RETURN_ITEMS[attrConfig.needItems[j][1]] = (RESET_RETURN_ITEMS[attrConfig.needItems[j][1]] or 0) + attrConfig.needItems[j][2]
  1653. end
  1654. end
  1655. end
  1656. -- 护符/水晶材料
  1657. local maxCnt = 100 -- 防止死循环
  1658. local equipID = heroGrid.equip and heroGrid.equip[ItemDefine.EQUIP_SUBTYPE_SHUIJIN]
  1659. while equipID do
  1660. maxCnt = maxCnt - 1
  1661. if maxCnt < 0 then
  1662. assert()
  1663. end
  1664. local eupcf = EquipExcel.shuijingUpNeed[equipID]
  1665. if not eupcf then break end
  1666. local preEquipID = eupcf.prevID
  1667. equipID = preEquipID
  1668. if preEquipID > 0 then
  1669. RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] or 0) + eupcf.money
  1670. RESET_RETURN_ITEMS[ItemDefine.ITEM_SHUIJING_UPLEVEL_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_SHUIJING_UPLEVEL_ID] or 0) + eupcf.jinghua
  1671. end
  1672. end
  1673. return RESET_RETURN_ITEMS
  1674. end
  1675. function getRealResetReturnItems(heroGrid)
  1676. Util.cleanTable(RESET_RETURN_ITEMS)
  1677. -- 升级
  1678. local lv = heroGrid.lv
  1679. if heroGrid.oldLV then
  1680. lv = heroGrid.oldLV
  1681. end
  1682. for i = 2, lv do
  1683. local upcf = UpNeedExcel.upLv[i]
  1684. if upcf then
  1685. RESET_RETURN_ITEMS[ItemDefine.ITEM_GREEN_EXP_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_GREEN_EXP_ID] or 0) + upcf.soul
  1686. RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] or 0) + upcf.money
  1687. end
  1688. end
  1689. -- 升阶
  1690. local quality = heroGrid.quality
  1691. if heroGrid.oldQuality then
  1692. quality = heroGrid.oldQuality
  1693. end
  1694. -- 升阶
  1695. for i = 1, quality do
  1696. local upcf = UpNeedExcel.upQuality[i]
  1697. if upcf then
  1698. RESET_RETURN_ITEMS[ItemDefine.ITEM_HERO_UPGRADE_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_HERO_UPGRADE_ID] or 0) + upcf.jinjieshi
  1699. RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] = (RESET_RETURN_ITEMS[ItemDefine.ITEM_JINBI_ID] or 0) + upcf.money
  1700. end
  1701. end
  1702. return RESET_RETURN_ITEMS
  1703. end
  1704. -- 重置花费
  1705. function getResetNeedZuanshi(lv)
  1706. if lv > 100 then
  1707. return 50
  1708. end
  1709. return 0
  1710. end
  1711. -- 重置查询
  1712. function resetHeroQuery(human, heroID, heroIndex)
  1713. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  1714. if not heroGrid then return end
  1715. if XingYaoGongMing.isGongMing(human,heroIndex,XingYaoGongMing.XYHERO_RESET) then
  1716. return
  1717. end
  1718. local heroConfig = HeroExcel.hero[heroGrid.id]
  1719. if not heroConfig then return end
  1720. if heroConfig.star > HERO_RESET_MAXSTAR then
  1721. return Broadcast.sendErr(human, Util.format(Lang.HERO_RESET_ERR_STAR, HERO_RESET_MAXSTAR + 1))
  1722. end
  1723. ObjHuman.updateDaily(human)
  1724. --[[if getResetLeftCnt(human) < 1 then
  1725. return Broadcast.sendErr(human, Lang.HERO_RESET_ERR_CNT)
  1726. end--]]
  1727. local list = getRealResetReturnItems(heroGrid)
  1728. local msgRet = Msg.gc.GC_HERO_RESET_QUERY
  1729. msgRet.heroID = heroID
  1730. msgRet.heroIndex = heroIndex
  1731. msgRet.needZuanshi = getResetNeedZuanshi(heroGrid.lv)
  1732. msgRet.maxFreeCnt = HERO_RESET_FREECNT
  1733. msgRet.leftFreeCnt = getResetLeftCnt(human)
  1734. msgRet.items[0] = 0
  1735. for itemID, itemCnt in pairs(list) do
  1736. if msgRet.items[0] >= #msgRet.items then
  1737. break
  1738. end
  1739. msgRet.items[0] = msgRet.items[0] + 1
  1740. Grid.makeItem(msgRet.items[msgRet.items[0]], itemID, itemCnt)
  1741. end
  1742. if msgRet.items[0] < 1 then
  1743. return Broadcast.sendErr(human, Lang.HERO_RESET_ERR_NONE)
  1744. end
  1745. -- Msg.trace(msgRet)
  1746. Msg.send(msgRet, human.fd)
  1747. end
  1748. -- 英雄重置
  1749. function resetHero(human, heroID, heroIndex)
  1750. local heroGrid = getHeroGrid(human, heroID, heroIndex)
  1751. if not heroGrid then return end
  1752. if XingYaoGongMing.isGongMing(human,heroIndex,XingYaoGongMing.XYHERO_RESET) then
  1753. return
  1754. end
  1755. local heroConfig = HeroExcel.hero[heroGrid.id]
  1756. if not heroConfig then return end
  1757. if heroConfig.star > HERO_RESET_MAXSTAR then
  1758. return Broadcast.sendErr(human, Util.format(Lang.HERO_RESET_ERR_STAR, HERO_RESET_MAXSTAR + 1))
  1759. end
  1760. local list = getRealResetReturnItems(heroGrid)
  1761. if not next(list) then
  1762. return Broadcast.sendErr(human, Lang.HERO_RESET_ERR_NONE)
  1763. end
  1764. if getResetLeftCnt(human) < 1 then
  1765. return Broadcast.sendErr(human, Lang.HERO_RESET_ERR_CNT)
  1766. end
  1767. local needZuanshi = getResetNeedZuanshi(heroGrid.lv)
  1768. if not ObjHuman.checkRMB(human, needZuanshi) then
  1769. return
  1770. end
  1771. ObjHuman.decZuanshi(human, -needZuanshi, "hero_reset")
  1772. human.db.heroResetCnt = (human.db.heroResetCnt or 0) + 1
  1773. heroGrid.lv = 1
  1774. heroGrid.quality = 0
  1775. if heroGrid.equip and heroGrid.equip[ItemDefine.EQUIP_SUBTYPE_SHUIJIN] then
  1776. heroGrid.equip[ItemDefine.EQUIP_SUBTYPE_SHUIJIN] = nil
  1777. heroGrid.shuijingAttrID = nil
  1778. end
  1779. for itemID, itemCnt in pairs(list) do
  1780. BagLogic.addItem(human, itemID, itemCnt, "hero_reset")
  1781. end
  1782. HeroEquip.putOffQuick(human, heroID, heroIndex, true)
  1783. FuwenLogic.putOffQuick(human, heroID, heroIndex, true)
  1784. XingYaoGongMing.onDelHero(human,heroGrid,heroIndex)
  1785. heroGrid.fuwen = nil
  1786. ObjHuman.doCalcHero(human,heroIndex)
  1787. sendHeroBagDynamic(human, heroID, heroIndex)
  1788. refreshDot(human, heroGrid.uuid)
  1789. local msgRet = Msg.gc.GC_HERO_RESET
  1790. msgRet.heroID = heroID
  1791. msgRet.heroIndex = heroIndex
  1792. msgRet.items[0] = 0
  1793. for itemID, itemCnt in pairs(list) do
  1794. if msgRet.items[0] >= #msgRet.items then
  1795. break
  1796. end
  1797. if not ItemDefine.isEquip(itemID) then
  1798. msgRet.items[0] = msgRet.items[0] + 1
  1799. Grid.makeItem(msgRet.items[msgRet.items[0]], itemID, itemCnt)
  1800. end
  1801. end
  1802. msgRet.items[0] = EquipLogic.makeEquipItem(human, msgRet.items, msgRet.items[0])
  1803. Msg.send(msgRet, human.fd)
  1804. checkChangeMaxZDL(human, heroGrid)
  1805. end