HeroLogic.lua 65 KB

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