CombatImpl.lua 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. local Msg = require("core.Msg")
  2. local Util = require("common.Util")
  3. local CombatObj = require("combat.CombatObj")
  4. local CombatDefine = require("combat.CombatDefine")
  5. local TargetMode = require("combat.TargetMode")
  6. local Skill = require("combat.Skill")
  7. local CombatBuff = require("combat.CombatBuff")
  8. local RoleAttr = require("role.RoleAttr")
  9. local RoleDefine = require("role.RoleDefine")
  10. local BeSkill = require("combat.BeSkill")
  11. local HeroExcel = require("excel.hero").hero
  12. local MonsterExcel = require("excel.monster").monster
  13. local BattleMonsterExcel = require("excel.battlemonster").monster
  14. local CombatExcel = require("excel.combat").combat
  15. local SkillExcel = require("excel.skill").skill
  16. -- local BufferExcel = require("excel.buffer").buffer
  17. -- local ProjectLogic = require("platform.ProjectLogic")
  18. objList = objList or {}
  19. helpList = helpList or {}
  20. elfList = elfList or {}
  21. attackOrder = attackOrder or {} -- 出手次序 [index]->pos
  22. round = round or 1 -- 当前回合
  23. attackIndex = attackIndex or 1 -- 当前进攻对象的index
  24. result = result or {} -- 计算结果
  25. sideAttrList = sideAttrList or {} -- 攻守双方人物属性
  26. skillUseList = skillUseList or {} -- 使用过的技能
  27. cmdUseList = cmdUseList or {} -- 使用过的额外作用setFightMode
  28. bufferUseList = bufferUseList or {} -- 使用过的buffer
  29. frameSkillList = frameSkillList or {} -- 当前小回合触发的被动技能
  30. frameBufferList = frameBufferList or {} -- 当前小回合触发的buffer
  31. mergeFrameBufferList = mergeFrameBufferList or {} --合并后的buffer
  32. frameSayList = frameSayList or {} -- 触发buffer的被动技能(需要喊话
  33. frameReviceList = frameReviceList or {} -- 复活列表
  34. fanjiList = fanjiList or {}
  35. beSkillUseList = beSkillUseList or {} -- 需要判断使用情况的技能
  36. isFanji = false
  37. comboType = 0
  38. isPVP = 0
  39. comboHurtRate = 0
  40. --[[
  41. commonArgs = {
  42. type -- 战斗类型
  43. hpLimit -- 血量上限,默认为角色HP,对应特定关卡
  44. }
  45. ]]
  46. commonArgs = commonArgs or {}
  47. comboList = comboList or {}
  48. beSkillPosUseList = beSkillPosUseList or {} --友军技能使用列表
  49. totalAtkCnt = 0 -- 总共攻击次数 reyes test
  50. maxRound = CombatDefine.COMBAT_ROUND_MAX
  51. petCD = CombatDefine.PET_CD
  52. nowAttacker = nowAttacker or nil
  53. firstAttack = {}
  54. fightMode = {0,0,0,0}
  55. initBackup = {0,0}
  56. comboPosList = {}
  57. totalHurt = 0
  58. useZhuijiObjList = {} --本场战斗使用过追击的英雄列表
  59. heroSpeedList = { -- 对战双方第一回合所有英雄的速度值列表
  60. --[CombatDefine.ATTACK_SIDE] = {},
  61. --[CombatDefine.DEFEND_SIDE] = {},
  62. }
  63. function init(type)
  64. Util.initTable(objList)
  65. Util.initTable(helpList)
  66. Util.initTable(elfList)
  67. Util.initTable(attackOrder)
  68. Util.initTable(result)
  69. Util.initTable(skillUseList)
  70. Util.initTable(cmdUseList)
  71. Util.initTable(bufferUseList)
  72. Util.initTable(frameSkillList)
  73. Util.initTable(frameBufferList)
  74. Util.initTable(frameSayList)
  75. Util.initTable(fanjiList)
  76. Util.initTable(beSkillUseList)
  77. Util.initTable(beSkillPosUseList)
  78. Util.initTable(commonArgs)
  79. Util.initTable(comboList)
  80. Util.initTable(initBackup)
  81. Util.initTable(frameReviceList)
  82. Util.initTable(useZhuijiObjList)
  83. Util.initTable(heroSpeedList)
  84. round = 0
  85. attackIndex = nil
  86. isFanji = false
  87. comboType = 0
  88. totalAtkCnt = 0
  89. totalHurt = 0
  90. commonArgs.type = type
  91. maxRound = CombatDefine.COMBAT_ROUND_MAX
  92. petCD = CombatDefine.PET_CD
  93. nowAttacker = nil
  94. local combatConfig = CombatExcel[type]
  95. if combatConfig and combatConfig.hpLimit == 1 then
  96. commonArgs.hpLimit = 1
  97. end
  98. isPVP = combatConfig.PVP
  99. end
  100. local function mergeFrameBuffer()
  101. Util.initTable(mergeFrameBufferList)
  102. mergeFrameBufferList = {[1] = {},[2] = {},[3] = {}}
  103. for k,v in ipairs(frameBufferList) do
  104. mergeFrameBufferList[v.op][v.id] = mergeFrameBufferList[v.op][v.id] or {}
  105. local obj = objList[v.pos]
  106. mergeFrameBufferList[v.op][v.id][v.pos] = mergeFrameBufferList[v.op][v.id][v.pos] or {id = v.id,cnt = 0,op = v.op,attrs = {},pos = v.pos,hpNow = obj.hp}
  107. local data = mergeFrameBufferList[v.op][v.id][v.pos]
  108. data.cnt = data.cnt + v.cnt
  109. if v.attrs then
  110. for k,v in pairs(v.attrs) do
  111. data.attrs[k] = data.attrs[k] or 0
  112. data.attrs[k] = data.attrs[k] + v
  113. end
  114. end
  115. end
  116. Util.initTable(frameBufferList)
  117. local len = 0
  118. for _,v in ipairs(mergeFrameBufferList) do
  119. for _,v1 in pairs(v) do
  120. for _,v2 in pairs(v1) do
  121. frameBufferList[#frameBufferList+1] = v2
  122. end
  123. end
  124. end
  125. end
  126. function setRoleAttr(side, attr)
  127. sideAttrList[side] = sideAttrList[side] or {}
  128. local sideAttr = sideAttrList[side]
  129. RoleAttr.initCombatAttr(sideAttr)
  130. if attr then
  131. for key, value in pairs(attr) do
  132. sideAttr[key] = value
  133. end
  134. end
  135. end
  136. function getValue(obj, key)
  137. if not obj then return 0 end
  138. if not obj.attr then return obj.pos end
  139. return obj.attr[key] or obj.pos
  140. end
  141. function setData(pos, hero)
  142. local obj = CombatObj.objs[pos]
  143. CombatObj.init(obj)
  144. --加入背包索引
  145. obj.bagIndex = hero.bagIndex or 0
  146. obj.uuid = hero.uuid
  147. obj.id = hero.id
  148. obj.job = hero.job
  149. obj.body = hero.body
  150. obj.head = hero.head
  151. obj.quality = hero.quality
  152. obj.star = hero.star
  153. obj.type = hero.type
  154. obj.lv = hero.lv
  155. obj.isGedangCnt = 0
  156. obj.camp = hero.camp
  157. obj.sex = hero.sex or 0
  158. obj.relic = hero.relic or {}
  159. obj.relic.relicID = hero.relic and hero.relic.relicID or 0
  160. obj.relic.star = hero.relic and hero.relic.star or 0
  161. obj.skillList = hero.skillList or {}
  162. obj.formationPos = hero.formationPos
  163. if CombatDefine.isBackup(obj) == CombatDefine.BACKUP_TYPE0 then
  164. obj.beSkillList = hero.beSkillList or {}
  165. else
  166. obj.beSkillList = {}
  167. obj.backUpSkillList = hero.beSkillList or {}
  168. end
  169. obj.normalTarget = nil
  170. obj.isBoss = hero.isBoss -- 仅显示用
  171. obj.isGongMing = hero.isGongMing or 0
  172. CombatObj.setInitAttr(obj, hero.attrs)
  173. obj.isSysAttrChange = nil
  174. obj.weaponEffectIdList = hero.weaponEffectIdList
  175. if hero.type == CombatDefine.COMBAT_OBJ_TYPE1 then
  176. obj.hurtType = HeroExcel[obj.id].hurtType
  177. else
  178. obj.hurtType = MonsterExcel[obj.id].hurtType
  179. if not obj.hurtType then
  180. if BattleMonsterExcel[obj.id] then
  181. obj.hurtType = BattleMonsterExcel[obj.id].hurtType or 0
  182. else
  183. obj.hurtType = 0
  184. end
  185. end
  186. end
  187. if pos == CombatDefine.BACKUP_POS[1] then
  188. initBackup[1] = obj.backupPos
  189. elseif pos == CombatDefine.BACKUP_POS[2] then
  190. initBackup[2] = obj.backupPos
  191. end
  192. objList[obj.pos] = obj
  193. end
  194. function setHelp(side,helpType,help)
  195. local pos = CombatDefine.getHelpPos(side,helpType)
  196. local obj = CombatObj.helps[pos]
  197. CombatObj.initHelp(obj)
  198. obj.id = help.id
  199. obj.lv = help.lv or 0
  200. obj.quality = help.quality or 0
  201. obj.head = help.head or 0
  202. obj.body = help.body or 0
  203. obj.icon = help.icon or 0
  204. obj.weight = help.weight or 0
  205. obj.height = help.height or 0
  206. obj.skillList = help.skillList or {}
  207. obj.beSkillList = help.beSkillList or {}
  208. obj.lvAttrsAdd = help.lvAttrsAdd or {}
  209. obj.zhuHun = help.zhuHun
  210. obj.jinglianLV = help.jinglianLV
  211. obj.skillLV = help.skillLV
  212. obj.hurt = help.hurt
  213. obj.args = help.args
  214. obj.buffers = help.buffers
  215. helpList[pos] = obj
  216. end
  217. function setElf(pos, elf)
  218. local elfObj = CombatObj.elfs[pos]
  219. CombatObj.initElf(elfObj)
  220. elfObj.id = elf.id
  221. elfObj.type = elf.type
  222. elfObj.body = elf.body or 0
  223. elfObj.head = elf.head or 0
  224. elfObj.quality = elf.quality or 1
  225. elfObj.skillList = elf.skillList or {}
  226. elfObj.beSkillList = elf.beSkillList or {}
  227. elfList[pos] = elfObj
  228. end
  229. function setMaxRound(value)
  230. maxRound = value
  231. end
  232. function setFightMode(data)
  233. for k in pairs(fightMode) do
  234. fightMode[k] = 0
  235. end
  236. if data then
  237. if data[1] == CombatDefine.FIGHT_MODE1 then
  238. fightMode = {data[1], data[2], data[3], 0}
  239. elseif data[1] == CombatDefine.FIGHT_MODE2 then
  240. fightMode = {data[1], data[2], data[3], data[4]}
  241. else
  242. fightMode = {data[1], data[2], data[3], 0}
  243. end
  244. end
  245. end
  246. local function cmp(a,b)
  247. if a.helpType ~= CombatDefine.HELP_TYPE0 or b.helpType ~= CombatDefine.HELP_TYPE0 then
  248. -- if a.helpType == CombatDefine.HELP_TYPE0 then
  249. -- return false
  250. -- elseif b.helpType == CombatDefine.HELP_TYPE0 then
  251. -- return true
  252. -- else
  253. -- local aSpeed = a.speed or 0
  254. -- local bSpeed = b.speed or 0
  255. -- if aSpeed > bSpeed then
  256. -- return true
  257. -- elseif aSpeed == bSpeed then
  258. -- return a.pos < b.pos
  259. -- else
  260. -- return false
  261. -- end
  262. -- end
  263. if a.helpType == CombatDefine.HELP_TYPE0 then
  264. return false
  265. elseif b.helpType == CombatDefine.HELP_TYPE0 then
  266. return true
  267. elseif a.helpType == CombatDefine.HELP_TYPE1 and b.helpType == CombatDefine.HELP_TYPE2 then
  268. return true
  269. elseif a.helpType == CombatDefine.HELP_TYPE2 and b.helpType == CombatDefine.HELP_TYPE1 then
  270. return false
  271. else
  272. local aSpeed = a.speed or 0
  273. local bSpeed = b.speed or 0
  274. if aSpeed > bSpeed then
  275. return true
  276. elseif aSpeed == bSpeed then
  277. return a.pos < b.pos
  278. else
  279. return false
  280. end
  281. end
  282. end
  283. local aSpeed = getValue(a, RoleDefine.SPEED)
  284. local bSpeed = getValue(b, RoleDefine.SPEED)
  285. if aSpeed > bSpeed then
  286. return true
  287. elseif aSpeed == bSpeed then
  288. return a.pos < b.pos
  289. else
  290. return false
  291. end
  292. end
  293. local function canAttack(obj)
  294. if not obj then
  295. return
  296. end
  297. if obj.helpType == CombatDefine.HELP_TYPE0 then
  298. local pos = obj.pos%CombatDefine.COMBAT_HERO_CNT
  299. if obj.hp > 0 and (pos > 0 or obj.backupPos) then
  300. -- 确定释放的技能是否带霸体
  301. local atkSkillID = getSkillID(obj)
  302. --local skillConfig = SkillExcel[atkSkillID]
  303. local skillConfig = Skill.GetSkillConfig(atkSkillID)
  304. if skillConfig and skillConfig.isBati == 1 then
  305. return true
  306. end
  307. if not CombatBuff.isStop(obj) then
  308. return true
  309. elseif CombatBuff.isStop(obj) then
  310. return false, "isStop"
  311. end
  312. end
  313. elseif obj.helpType == CombatDefine.HELP_TYPE1 then
  314. return petCD == 0
  315. elseif obj.helpType == CombatDefine.HELP_TYPE2 then
  316. for i = 1,#obj.skillList do
  317. local skill = obj.skillList[i]
  318. if (skill[3] == 0 or (skill[2] - round) % skill[3] == 0) and Skill.SkillCondCheck(obj, skill[1]) then
  319. return true
  320. end
  321. end
  322. return false
  323. elseif obj.helpType == CombatDefine.HELP_TYPE3 then
  324. elseif obj.helpType == CombatDefine.HELP_TYPE4 then
  325. end
  326. end
  327. function initAttackOrder()
  328. Util.initTable(attackOrder)
  329. -- 确定最高速度
  330. local atkSpeed = 0
  331. local atkSide = 0
  332. for i = 1, CombatDefine.COMBAT_HERO_ALL_CNT do
  333. local obj = objList[i]
  334. if canAttack(obj) then
  335. attackOrder[#attackOrder + 1] = obj
  336. local speed = getValue(obj, RoleDefine.SPEED)
  337. if speed > atkSpeed then
  338. atkSpeed = speed
  339. atkSide = obj.side
  340. end
  341. if round == 1 or not next(heroSpeedList) then
  342. heroSpeedList[obj.side] = heroSpeedList[obj.side] or {speedVal = 0, objCnt = 0, speedAvVal = 0}
  343. heroSpeedList[obj.side].speedVal = heroSpeedList[obj.side].speedVal + speed
  344. heroSpeedList[obj.side].objCnt = heroSpeedList[obj.side].objCnt + 1
  345. end
  346. end
  347. end
  348. for _,pos in ipairs(CombatDefine.SIDE2HELPPOS[0]) do
  349. local obj = helpList[pos]
  350. if obj and canAttack(obj) then
  351. attackOrder[#attackOrder + 1] = obj
  352. obj.speed = nil
  353. if obj.side == atkSide then
  354. obj.speed = atkSpeed
  355. end
  356. end
  357. end
  358. if round == 1 and heroSpeedList[CombatDefine.ATTACK_SIDE] and heroSpeedList[CombatDefine.DEFEND_SIDE] then
  359. local atkList = heroSpeedList[CombatDefine.ATTACK_SIDE]
  360. atkList.speedAvVal = math.floor(atkList.speedVal / atkList.objCnt)
  361. local defList = heroSpeedList[CombatDefine.DEFEND_SIDE]
  362. defList.speedAvVal = math.floor(defList.speedVal / defList.objCnt)
  363. end
  364. -- 精灵
  365. for _,pos in ipairs(CombatDefine.SIDE2ELFPOS[0]) do
  366. local elfObj = elfList[pos]
  367. if elfObj and canAttack(elfObj) then
  368. attackOrder[#attackOrder + 1] = elfObj
  369. -- if elfObj.side == atkSide then
  370. -- elfObj.speed = atkSpeed
  371. -- end
  372. elfObj.speed = heroSpeedList[elfObj.side] and heroSpeedList[elfObj.side].speedAvVal or 0
  373. end
  374. end
  375. table.sort(attackOrder,cmp)
  376. firstAttack = {true,true}
  377. end
  378. --用于战斗对象复活后插入出手列表的函数
  379. function InsertAttackOrder(pos)
  380. local targetObj = objList[pos]
  381. if not canAttack(targetObj) then
  382. return
  383. end
  384. local sameSideObjs = {}
  385. for i=1,#attackOrder do
  386. local obj = attackOrder[i]
  387. if obj.pos == pos then
  388. return
  389. end
  390. local res = canAttack(obj)
  391. if res and obj.side == targetObj.side then
  392. sameSideObjs[#sameSideObjs + 1] = obj
  393. end
  394. end
  395. sameSideObjs[#sameSideObjs + 1] = targetObj
  396. if #sameSideObjs > 1 then
  397. table.sort(sameSideObjs, cmp)
  398. --没过出手回合才加入
  399. if sameSideObjs[1].pos ~= pos then
  400. attackOrder[#attackOrder + 1] = targetObj
  401. end
  402. end
  403. end
  404. local tempList = {}
  405. function updateAttackOrder()
  406. for i = 1,#tempList do
  407. tempList[i] = nil
  408. end
  409. --当前不能出手, 但是下一轮可能可以出手的对象列表
  410. local maybeObjList = {}
  411. for i = 2,#attackOrder do
  412. local obj = attackOrder[i]
  413. -- if canAttack(obj) then
  414. -- tempList[#tempList + 1] = obj
  415. -- end
  416. local res1, tag = canAttack(obj)
  417. if res1 then
  418. tempList[#tempList + 1] = obj
  419. elseif tag == "isStop" then
  420. --那些被控制的英雄只有没过他的出手时机才加入列表中。可能会有给敌方驱散负面buff的技能, 所以不需要判断 tempList 里面是否有我方可出手英雄
  421. if #tempList > 0 then
  422. maybeObjList[#maybeObjList + 1] = obj
  423. end
  424. end
  425. end
  426. if #tempList > 1 then
  427. table.sort(tempList,cmp)
  428. end
  429. --只有当前轮有能出手的英雄, 才把 maybeObjList 中的对象加入到 tempList 中
  430. if #tempList >= 1 then
  431. for _, v in ipairs(maybeObjList) do
  432. tempList[#tempList + 1] = v
  433. end
  434. end
  435. for i = 1,#attackOrder do
  436. attackOrder[i] = tempList[i]
  437. end
  438. end
  439. local function clCombatResult()
  440. for i= 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  441. local obj = objList[i]
  442. if obj then
  443. obj.combatResult[1] = 0
  444. obj.combatResult[2] = 0
  445. for k in pairs(obj.combatResult[3]) do
  446. obj.combatResult[3][k] = nil
  447. end
  448. obj.combatResult[4] = 0
  449. for k in pairs(obj.combatResult[5]) do
  450. obj.combatResult[5][k] = nil
  451. end
  452. end
  453. end
  454. end
  455. local function beforeCombat()
  456. Util.initTable(frameSkillList)
  457. Util.initTable(frameBufferList)
  458. Util.initTable(frameSayList)
  459. Util.initTable(fanjiList)
  460. Util.initTable(beSkillUseList)
  461. Util.initTable(beSkillPosUseList)
  462. Util.initTable(comboList)
  463. clCombatResult()
  464. isFanji = false
  465. comboType = 0
  466. end
  467. -- 战斗回合开始前操作
  468. function onRoundBegin()
  469. round = round + 1
  470. -- 超出15回合
  471. if round > maxRound then
  472. return
  473. end
  474. petCD = petCD - 1
  475. if round == 1 or petCD < 0 then
  476. petCD = CombatDefine.PET_CD - 1
  477. end
  478. attackIndex = 1
  479. --正常buffer添加只会在小回合结束后添加。此处大回合开始时触发被动技能添加buffer需要特殊处理添加战斗帧操作
  480. beforeCombat()
  481. BeSkill.onRoundBegin(round)
  482. initAttackOrder()
  483. --每回合开始处理buff
  484. if #frameBufferList > 0 or #frameSayList > 0 then
  485. addFrame()
  486. mergeFrameBuffer()
  487. for k,v in ipairs(frameBufferList) do
  488. setBufferList(v)
  489. end
  490. for _,v in ipairs(frameSayList) do
  491. setSaySkill(v[1],v[2],v[3])
  492. end
  493. end
  494. if fightMode[1] == CombatDefine.FIGHT_MODE1 then
  495. if round > fightMode[2] then
  496. fightMode[4] = fightMode[4] + fightMode[3]
  497. end
  498. end
  499. end
  500. function getNormalSkill(obj)
  501. return obj.skillList[#obj.skillList][1]
  502. end
  503. function getSkillID(obj)
  504. local skillID
  505. if obj.helpType == CombatDefine.HELP_TYPE0 then
  506. for i = 1,#obj.skillList do
  507. local skill = obj.skillList[i]
  508. if (skill[3] == 0 or (skill[2] - round) % skill[3] == 0) and Skill.SkillCondCheck(obj, skill[1]) then
  509. skillID = skill[1]
  510. skill[2] = round + skill[3]
  511. break
  512. end
  513. if skill[3] > 0 and skill[2] < round then
  514. skill[2] = skill[2] + skill[3]
  515. end
  516. end
  517. if CombatBuff.isStatus(obj,{"hunluan"}) or CombatBuff.isChaofen(obj) or CombatBuff.IsCanNoUseSkill(obj) then
  518. skillID = obj.skillList[#obj.skillList][1]
  519. end
  520. if fightMode[1] == CombatDefine.FIGHT_MODE2 then
  521. -- 如果是援军 必定选择大招
  522. if obj.backupPos ~= nil then
  523. for i = 1,#obj.skillList do
  524. local skill = obj.skillList[i]
  525. local skillList = fightMode[2]
  526. for k, v in pairs(skillList) do
  527. if v == skill[1] then
  528. skillID = skill[1]
  529. break
  530. end
  531. end
  532. end
  533. else
  534. -- 如果是第一回合 且不是防守方 使用大招
  535. if round == 1 then
  536. if obj.side == CombatDefine.ATTACK_SIDE then
  537. for i = 1,#obj.skillList do
  538. local skill = obj.skillList[i]
  539. --local skillConfig = SkillExcel[skill[1]]
  540. local skillConfig = Skill.GetSkillConfig(skill[1])
  541. if skillConfig.cvSound == 8 then
  542. skillID = skill[1]
  543. break
  544. end
  545. end
  546. end
  547. end
  548. end
  549. end
  550. elseif obj.helpType == CombatDefine.HELP_TYPE1 then
  551. for i = 1,#obj.skillList do
  552. local skill = obj.skillList[i]
  553. if (skill[3] == 0 or (skill[2] - round) % skill[3] == 0) and Skill.SkillCondCheck(obj, skill[1]) then
  554. skillID = skill[1]
  555. skill[2] = round + skill[3]
  556. break
  557. end
  558. end
  559. elseif obj.helpType == CombatDefine.HELP_TYPE2 then -- 精灵
  560. for i = 1,#obj.skillList do
  561. local skill = obj.skillList[i]
  562. if (skill[3] == 0 or (skill[2] - round) % skill[3] == 0) and Skill.SkillCondCheck(obj, skill[1]) then
  563. skillID = skill[1]
  564. skill[2] = round + skill[3]
  565. break
  566. end
  567. end
  568. elseif obj.helpType == CombatDefine.HELP_TYPE3 then
  569. elseif obj.helpType == CombatDefine.HELP_TYPE4 then
  570. end
  571. skillID = BeSkill.onSkillID(obj,skillID)
  572. return skillID
  573. end
  574. function checkSideResult(pos)
  575. local cnt = 0
  576. local obj
  577. for i= 1,CombatDefine.COMBAT_HERO_CNT do
  578. if pos > CombatDefine.COMBAT_HERO_CNT then
  579. obj = objList[i]
  580. else
  581. obj = objList[i + CombatDefine.COMBAT_HERO_CNT]
  582. end
  583. if obj and obj.hp > 0 then
  584. cnt = cnt + 1
  585. end
  586. end
  587. if cnt == 0 then
  588. return true
  589. end
  590. end
  591. local function checkResult()
  592. local attackCnt = 0
  593. local defendCnt = 0
  594. local obj
  595. for i= 1,CombatDefine.COMBAT_HERO_CNT do
  596. obj = objList[i]
  597. if obj and obj.hp > 0 then
  598. attackCnt = attackCnt + 1
  599. end
  600. obj = objList[i + CombatDefine.COMBAT_HERO_CNT]
  601. if obj and obj.hp > 0 then
  602. defendCnt = defendCnt + 1
  603. end
  604. end
  605. result.attackCnt = attackCnt
  606. result.defendCnt = defendCnt
  607. if attackCnt > 0 and defendCnt == 0 then
  608. result.isWin = true
  609. end
  610. if attackCnt == 0 or defendCnt == 0 then
  611. return true
  612. end
  613. end
  614. -- 计算援军上阵附带属性比例
  615. local function calcBackUpSkill(obj, star)
  616. --local skillConfig = SkillExcel[CombatDefine.BACKUP_BUFF_SKILL[1]]
  617. local skillConfig = Skill.GetSkillConfig(CombatDefine.BACKUP_BUFF_SKILL[1])
  618. if not skillConfig then return end
  619. local buffers = CombatBuff.getSkillBuffers(skillConfig)
  620. if not buffers then return end
  621. for i = 1, #buffers do
  622. local bufferID = buffers[i][1]
  623. --local conf = BufferExcel[bufferID]
  624. local conf = CombatBuff.GetBuffConfig(bufferID)
  625. if conf then
  626. conf.attrRate = CombatDefine.BACKUP_BUFF_REATE[star]
  627. end
  628. end
  629. end
  630. local function checkBackup()
  631. for side = 1, 2 do
  632. local backupObj = objList[CombatDefine.BACKUP_POS[side]]
  633. if backupObj and not backupObj.backupPos then
  634. for index, pos in ipairs(CombatDefine.SIDE2POS[side]) do
  635. local obj = objList[pos]
  636. -- 剧情模式 强行把援军上阵到指定位置
  637. if fightMode[1] == CombatDefine.FIGHT_MODE2 then
  638. if not obj and round == fightMode[3] and index == fightMode[4] then
  639. backupObj.backupPos = pos
  640. local attrs = {}
  641. attrs[RoleDefine.BACKUP_COMBAT] = pos
  642. addFrame()
  643. setSkillID(backupObj,99999)
  644. setExtraHit(backupObj,nil,Skill.getCMD2ID("backup"),attrs)
  645. -- 使用上场技能 设定buffer的cmd 确定附加属性星级
  646. calcBackUpSkill(backupObj, backupObj.star)
  647. BeSkill.onBackupBegin(backupObj)
  648. -- 强制速度
  649. backupObj.attr[RoleDefine.SPEED] = 9999
  650. break
  651. end
  652. else
  653. if obj and obj.hp <= 0 and pos ~= CombatDefine.BACKUP_POS[side] then
  654. obj.beBackup = 1
  655. backupObj.backupPos = pos
  656. local attrs = {}
  657. attrs[RoleDefine.BACKUP_COMBAT] = pos
  658. addFrame()
  659. setSkillID(backupObj,99999)
  660. setExtraHit(backupObj,nil,Skill.getCMD2ID("backup"),attrs)
  661. -- 使用上场技能
  662. calcBackUpSkill(backupObj, backupObj.star)
  663. BeSkill.onBackupBegin(backupObj)
  664. break
  665. end
  666. end
  667. end
  668. end
  669. end
  670. end
  671. local function afterCombat(attacker,isRoundEnd)
  672. --回合结束处理被动技能时如果是最后一次攻击是反击,不会触发。
  673. if isRoundEnd then
  674. isFanji = false
  675. comboType = 0
  676. checkBackup()
  677. end
  678. --处理回合尾加只生效一轮的buffer,在大回合结束单独加一帧,大回合结束要删buffer。避免客户端出现先删后加的要求导致没有buffer可删。同时显示已经删掉的buffer
  679. if isRoundEnd and #frameBufferList > 0 then
  680. addFrame()
  681. mergeFrameBuffer()
  682. for k,v in ipairs(frameBufferList) do
  683. setBufferList(v)
  684. end
  685. for _,v in ipairs(frameSayList) do
  686. setSaySkill(v[1],v[2],v[3])
  687. end
  688. Util.initTable(frameBufferList)
  689. Util.initTable(frameSayList)
  690. end
  691. BeSkill.onRoundEnd(isRoundEnd, attacker)
  692. CombatBuff.onRoundEnd(attacker,isRoundEnd)
  693. if #frameBufferList > 0 or #frameSayList > 0 then
  694. addFrame()
  695. mergeFrameBuffer()
  696. for k,v in ipairs(frameBufferList) do
  697. setBufferList(v)
  698. end
  699. for _,v in ipairs(frameSayList) do
  700. setSaySkill(v[1],v[2],v[3])
  701. end
  702. Util.initTable(frameBufferList)
  703. Util.initTable(frameSayList)
  704. end
  705. afterRevice()
  706. if attacker and attacker.pos <= CombatDefine.COMBAT_HERO_ALL_CNT and firstAttack[attacker.side] then
  707. firstAttack[attacker.side] = false
  708. end
  709. end
  710. local function afterFanji()
  711. if #frameBufferList > 0 or #frameSayList > 0 then
  712. addFrame()
  713. mergeFrameBuffer()
  714. for k,v in ipairs(frameBufferList) do
  715. setBufferList(v)
  716. end
  717. for pos,v in ipairs(frameSayList) do
  718. setSaySkill(v[1],v[2],v[3])
  719. end
  720. Util.initTable(frameBufferList)
  721. Util.initTable(frameSayList)
  722. end
  723. isFanji = false
  724. end
  725. function afterBuff()
  726. if #frameBufferList > 0 or #frameSayList > 0 then
  727. mergeFrameBuffer()
  728. for k,v in ipairs(frameBufferList) do
  729. setBufferList(v)
  730. end
  731. for _,v in ipairs(frameSayList) do
  732. setSaySkill(v[1],v[2],v[3])
  733. end
  734. Util.initTable(frameBufferList)
  735. Util.initTable(frameSayList)
  736. end
  737. end
  738. local function afterCombo()
  739. if #frameBufferList > 0 or #frameSayList > 0 then
  740. addFrame()
  741. mergeFrameBuffer()
  742. for k,v in ipairs(frameBufferList) do
  743. setBufferList(v)
  744. end
  745. for _,v in ipairs(frameSayList) do
  746. setSaySkill(v[1],v[2],v[3])
  747. end
  748. Util.initTable(frameBufferList)
  749. Util.initTable(frameSayList)
  750. end
  751. comboType = 0
  752. end
  753. function calcFrame()
  754. -- 没有能出手的人,开始下一个回合
  755. if not attackOrder[1] then
  756. onRoundBegin()
  757. end
  758. -- 超出15回合
  759. if round > maxRound then
  760. return
  761. end
  762. if not attackOrder[1] then
  763. -- 此回合 双方都没有能出手的英雄
  764. -- 回合 Buff结算
  765. afterCombat(nil ,not attackOrder[1])
  766. if checkResult() then return end
  767. return true
  768. end
  769. beforeCombat()
  770. local attacker = attackOrder[1]
  771. if attacker then
  772. -- 目前mpAtkRate 永远为nil
  773. local skillID,mpAtkRate = getSkillID(attacker)
  774. -- buff作用效果
  775. --skillID = 10131
  776. if skillID then
  777. Skill.use(attacker,skillID,mpAtkRate)
  778. CombatBuff.BuffHandleAfterSkill(attacker)
  779. addObjResultOut(attacker,round)
  780. end
  781. end
  782. --技能buff
  783. afterBuff()
  784. CombatBuff.beforeFanji()
  785. --BeSkill.beforeFanji(attacker)
  786. fanji()
  787. afterFanji()
  788. combo()
  789. afterCombo()
  790. afterRevice()
  791. updateAttackOrder()
  792. afterCombat(attacker,not attackOrder[1])
  793. if checkResult() then return end
  794. return true
  795. end
  796. function addFrame()
  797. if not result.frames then
  798. result.frames = {}
  799. end
  800. local frame = {}
  801. frame.round = round
  802. frame.petCD = petCD
  803. frame.skillList = {}
  804. frame.bufferList = {}
  805. frame.sayList = {}
  806. result.frames[#result.frames + 1] = frame
  807. return frame
  808. end
  809. function setSkillID(obj,skillID)
  810. onUseSkill(skillID)
  811. local pos = obj.pos
  812. local frame = result.frames[#result.frames]
  813. local skillData = {}
  814. skillData.attackPos = pos
  815. skillData.skillID = skillID
  816. skillData.hitList = {}
  817. skillData.extraList = {}
  818. skillData.petList = {}
  819. frame.skillList[#frame.skillList+1] = skillData
  820. end
  821. function setSaySkill(pos,skillID,contentType)
  822. if contentType == 0 then
  823. return
  824. end
  825. --if pos > CombatDefine.COMBAT_HERO_ALL_CNT then
  826. -- return
  827. --end
  828. onUseSkill(skillID)
  829. local frame = result.frames[#result.frames]
  830. frame.sayList[pos] = frame.sayList[pos] or {}
  831. frame.sayList[pos][#frame.sayList[pos]+ 1] = skillID
  832. end
  833. function setSkillHit(target,hpValue,mpValue,flag,attacker,skillID)
  834. local frame = result.frames[#result.frames]
  835. local skillFrame = frame.skillList[#frame.skillList]
  836. if not (not target.isPet and skillFrame.skillID == skillID and skillFrame.attackPos and skillFrame.attackPos == attacker.pos) then
  837. addFrame()
  838. setSkillID(attacker,skillID)
  839. frame = result.frames[#result.frames]
  840. skillFrame = frame.skillList[#frame.skillList]
  841. end
  842. local pos = target.pos
  843. if not skillFrame.hitList[pos] then
  844. skillFrame.hitList[pos] = {}
  845. end
  846. if not skillFrame.hitList[pos].attrs then
  847. skillFrame.hitList[pos].attrs = {}
  848. end
  849. skillFrame.hitList[pos].flag = flag or 0
  850. skillFrame.hitList[pos].hpNow = target.hp
  851. local frameAttrs = skillFrame.hitList[pos].attrs
  852. if hpValue and hpValue ~= 0 then
  853. frameAttrs[#frameAttrs + 1] = {RoleDefine.HP_COMBAT,hpValue}
  854. if target.side == CombatDefine.DEFEND_SIDE and hpValue < 0 then
  855. frameAttrs[#frameAttrs + 1] = {RoleDefine.HURT_COMBAT_TOTAL,math.floor(totalHurt)}
  856. end
  857. end
  858. end
  859. function isSkillFrameEmpty()
  860. local frame = result.frames and result.frames[#result.frames]
  861. if not frame then
  862. return true
  863. end
  864. local skillFrame = frame.skillList[#frame.skillList]
  865. if not skillFrame then
  866. return true
  867. end
  868. end
  869. function setExtraHit(target,hpValue,cmd,attrs)
  870. local frame = result.frames[#result.frames]
  871. local skillFrame = frame.skillList[#frame.skillList]
  872. --处理下没有使用技能的情况
  873. if not skillFrame then
  874. print("======================没有使用技能====================")
  875. setSkillID({pos = 99}, 66666)
  876. skillFrame = frame.skillList[#frame.skillList]
  877. end
  878. local pos = target.pos
  879. if not skillFrame.extraList[pos] then
  880. skillFrame.extraList[pos] = {}
  881. end
  882. if not skillFrame.extraList[pos].attrs then
  883. skillFrame.extraList[pos].attrs = {}
  884. end
  885. skillFrame.extraList[pos].flag = 0
  886. if not skillFrame.extraList[pos].cmd then
  887. skillFrame.extraList[pos].cmd = cmd or 0
  888. end
  889. skillFrame.extraList[pos].hpNow = target.hp
  890. local frameAttrs = skillFrame.extraList[pos].attrs
  891. if hpValue and hpValue ~= 0 then
  892. frameAttrs[#frameAttrs + 1] = {RoleDefine.HP_COMBAT,hpValue}
  893. if target.side == CombatDefine.DEFEND_SIDE and hpValue < 0 then
  894. frameAttrs[#frameAttrs + 1] = {RoleDefine.HURT_COMBAT_TOTAL,math.floor(totalHurt)}
  895. end
  896. end
  897. if attrs then
  898. for k,v in pairs(attrs) do
  899. frameAttrs[#frameAttrs + 1] = {k,v}
  900. end
  901. end
  902. onUseCmd(cmd)
  903. end
  904. function setBufferList(data)
  905. if not data then
  906. return
  907. end
  908. local frame = result.frames[#result.frames]
  909. if not frame.bufferList[data.pos] then
  910. frame.bufferList[data.pos] = {}
  911. end
  912. local bufferList = frame.bufferList[data.pos]
  913. local frameBuffer = {}
  914. frameBuffer.id = data.id
  915. frameBuffer.cnt = data.cnt
  916. frameBuffer.round = data.round
  917. frameBuffer.op = data.op
  918. frameBuffer.hpNow = data.hpNow
  919. frameBuffer.attrs = {}
  920. if data.attrs then
  921. local hpValue = 0
  922. for k,v in pairs(data.attrs) do
  923. frameBuffer.attrs[#frameBuffer.attrs + 1] = {k,v}
  924. if data.pos > CombatDefine.COMBAT_HERO_CNT and k == RoleDefine.HP_COMBAT and v < 0 then
  925. hpValue = hpValue + v
  926. end
  927. end
  928. if hpValue < 0 then
  929. frameBuffer.attrs[#frameBuffer.attrs + 1] = {RoleDefine.HURT_COMBAT_TOTAL,math.floor(totalHurt)}
  930. end
  931. end
  932. bufferList[#bufferList + 1] = frameBuffer
  933. end
  934. function onUseSkill(skillID)
  935. skillUseList[skillID] = 1
  936. end
  937. function onUseCmd(cmd)
  938. if not cmd or cmd == 0 then return end
  939. cmdUseList[cmd] = 1
  940. end
  941. function onAddBuffer(bufferID)
  942. bufferUseList[bufferID] = 1
  943. end
  944. function addFrameSkill(pos,skillID)
  945. frameSkillList[#frameSkillList + 1] = {pos,skillID}
  946. end
  947. function addFrameBuffer(obj,buffer,op,bufferCnt)
  948. local data = {}
  949. data.id = buffer.id
  950. data.cnt = bufferCnt or 1
  951. data.round = buffer.round
  952. data.op = op
  953. data.attrs = {}
  954. if buffer.attrs then
  955. for k,v in pairs(buffer.attrs) do
  956. if v ~= 0 then
  957. data.attrs[k] = data.attrs[k] or 0
  958. data.attrs[k] = data.attrs[k] + v
  959. end
  960. end
  961. end
  962. data.pos = obj.pos
  963. data.hpNow = obj.hp
  964. frameBufferList[#frameBufferList + 1] = data
  965. end
  966. function addSaySkill(obj,skillConfig)
  967. if skillConfig.contentType == 0 then
  968. return
  969. end
  970. if obj.pos > CombatDefine.COMBAT_HERO_ALL_CNT then
  971. return
  972. end
  973. frameSayList[#frameSayList + 1] = {obj.pos,skillConfig.id,skillConfig.contentType}
  974. end
  975. function addRevice(attackPos, obj, bufferID, skillID)
  976. frameReviceList[#frameReviceList + 1] = {obj.pos, attackPos, bufferID, skillID}
  977. end
  978. function afterRevice()
  979. if #frameReviceList > 0 then
  980. for k, v in ipairs(frameReviceList) do
  981. local obj = objList[v[1]]
  982. if obj then
  983. addFrame()
  984. CombatBuff.reviceObj(v[2], obj, v[3], v[4])
  985. end
  986. end
  987. Util.initTable(frameReviceList)
  988. if #frameBufferList > 0 or #frameSayList > 0 then
  989. mergeFrameBuffer()
  990. for k,v in ipairs(frameBufferList) do
  991. setBufferList(v)
  992. end
  993. for _,v in ipairs(frameSayList) do
  994. setSaySkill(v[1],v[2],v[3])
  995. end
  996. Util.initTable(frameBufferList)
  997. Util.initTable(frameSayList)
  998. end
  999. end
  1000. end
  1001. function addBeSkillUse(obj,attackerPos,skillID)
  1002. beSkillUseList[obj.pos] = beSkillUseList[obj.pos] or {}
  1003. beSkillUseList[obj.pos][attackerPos] = beSkillUseList[obj.pos][attackerPos] or {}
  1004. beSkillUseList[obj.pos][attackerPos][skillID] = beSkillUseList[obj.pos][attackerPos][skillID] or 0
  1005. beSkillUseList[obj.pos][attackerPos][skillID] = beSkillUseList[obj.pos][attackerPos][skillID] + 1
  1006. end
  1007. function getBeSkillUse(obj,attackerPos,skillID)
  1008. return beSkillUseList[obj.pos] and beSkillUseList[obj.pos][attackerPos] and beSkillUseList[obj.pos][attackerPos][skillID] or 0
  1009. end
  1010. function addBeSkillPosUse(pos,skillID)
  1011. beSkillPosUseList[pos] = beSkillPosUseList[pos] or {}
  1012. beSkillPosUseList[pos][skillID] = beSkillPosUseList[pos][skillID] or 0
  1013. beSkillPosUseList[pos][skillID] = beSkillPosUseList[pos][skillID] + 1
  1014. end
  1015. function getBeSkillPosUse(pos,skillID)
  1016. return beSkillPosUseList[pos] and beSkillPosUseList[pos][skillID]
  1017. end
  1018. function getBeSkillSideUse(pos,skillID)
  1019. local side
  1020. if pos <= CombatDefine.COMBAT_HERO_CNT then
  1021. side = CombatDefine.ATTACK_SIDE
  1022. elseif pos <= CombatDefine.COMBAT_HERO_ALL_CNT then
  1023. side = CombatDefine.DEFEND_SIDE
  1024. else
  1025. return
  1026. end
  1027. local skillCnt = 0
  1028. for _,v in ipairs(CombatDefine.SIDE2POS[side]) do
  1029. if v ~= pos and beSkillPosUseList[v] and beSkillPosUseList[v][skillID] then
  1030. skillCnt = skillCnt + beSkillPosUseList[v][skillID]
  1031. end
  1032. end
  1033. return skillCnt
  1034. end
  1035. function setObjResult(pos,value)
  1036. local obj
  1037. if pos <= CombatDefine.COMBAT_HERO_ALL_CNT then
  1038. obj = objList[pos]
  1039. elseif pos == CombatDefine.PET_ATKPOS then
  1040. obj = helpList[pos]
  1041. elseif pos == CombatDefine.PET_DEFPOS then
  1042. obj = helpList[pos]
  1043. elseif CombatDefine.ELF_MIN_POS <= pos and CombatDefine.ELF_MAX_POS >= pos then
  1044. obj = elfList[pos]
  1045. end
  1046. if not obj then
  1047. return
  1048. end
  1049. if value > 0 then
  1050. obj.result[2] = obj.result[2] + value
  1051. elseif value < 0 then
  1052. obj.result[1] = obj.result[1] - value
  1053. if obj.side == CombatDefine.ATTACK_SIDE then
  1054. totalHurt = totalHurt - value
  1055. end
  1056. end
  1057. end
  1058. function fanji()
  1059. isFanji = true
  1060. for i = 1,#fanjiList do
  1061. local fanjiData = fanjiList[i]
  1062. if fanjiData[1].hp > 0 then
  1063. Skill.use(fanjiData[1],fanjiData[2],fanjiData[3])
  1064. end
  1065. end
  1066. end
  1067. function comboAgain(obj, type, hurtRate, comboSkillID, skip)
  1068. if not obj or obj.hp <=0 then return end
  1069. local stop = CombatBuff.isStop(obj)
  1070. --新增条件,如果控制buff只有chanrao也能继续执行
  1071. if stop and skip == nil and not CombatBuff.IsJustHaveChanraoBuff(obj) then return end
  1072. local skillID = comboSkillID or getSkillID(obj)
  1073. if skillID then
  1074. comboType = type
  1075. comboHurtRate = hurtRate
  1076. if type == 999 then --追击
  1077. local objPos = obj.pos
  1078. local objTag = obj.uuid or obj.id
  1079. useZhuijiObjList[objPos] = {}
  1080. useZhuijiObjList[objPos][objTag] = (useZhuijiObjList[objPos][objTag] or 0) + 1
  1081. end
  1082. Skill.use(obj, skillID)
  1083. comboType = 0
  1084. end
  1085. end
  1086. function combo()
  1087. local comboSkillID
  1088. for k,v in pairs(comboPosList) do
  1089. comboPosList[k] = nil
  1090. end
  1091. for k, v in ipairs(comboList) do
  1092. --for i = 1,#comboList do
  1093. local obj = v[1]
  1094. if obj.hp > 0 then
  1095. local type = v[2] or 0
  1096. local hurtRate = v[3] or 10000
  1097. comboSkillID = nil
  1098. local argSkill = v[4] or 0
  1099. if argSkill ~= 0 then
  1100. comboSkillID = argSkill
  1101. else
  1102. if type == 2 then
  1103. comboSkillID = getNormalSkill(obj)
  1104. end
  1105. end
  1106. local t = v[5] or 1
  1107. local skip = v[6]
  1108. if not (comboPosList[obj.pos] and comboPosList[obj.pos][t] and comboPosList[obj.pos][0] >= 3) then --避免组合技能触发多次连击,比如10813
  1109. comboAgain(obj, type, hurtRate, comboSkillID, skip)
  1110. comboPosList[obj.pos] = comboPosList[obj.pos] or {}
  1111. comboPosList[obj.pos][0] = comboPosList[obj.pos][0] or 0
  1112. comboPosList[obj.pos][0] = comboPosList[obj.pos][0] + 1
  1113. comboPosList[obj.pos][t] = 1
  1114. end
  1115. end
  1116. end
  1117. end
  1118. function setObjBearResult(obj, value)
  1119. if not obj then
  1120. return
  1121. end
  1122. if value < 0 then
  1123. obj.result[3] = obj.result[3] - value
  1124. end
  1125. end
  1126. function addObjResultOut(obj, round)
  1127. if not obj then
  1128. return
  1129. end
  1130. if obj.pos > CombatDefine.COMBAT_HERO_ALL_CNT then
  1131. obj.result[4] = obj.result[4] + 1
  1132. else
  1133. obj.result[4] = round
  1134. end
  1135. end
  1136. --即时添加buffer帧
  1137. function instantFrameBuffer(obj,skillID)
  1138. if #frameBufferList > 0 or #frameSayList > 0 then
  1139. addFrame()
  1140. if obj and skillID then
  1141. setSkillID(obj, skillID)
  1142. end
  1143. mergeFrameBuffer()
  1144. for k,v in ipairs(frameBufferList) do
  1145. setBufferList(v)
  1146. end
  1147. for _,v in ipairs(frameSayList) do
  1148. setSaySkill(v[1],v[2],v[3])
  1149. end
  1150. Util.initTable(frameBufferList)
  1151. Util.initTable(frameSayList)
  1152. end
  1153. end