HeroLogic.lua 64 KB

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