HeroLogic.lua 65 KB

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