HeroLogic.lua 71 KB

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