HeroLogic.lua 65 KB

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