CombatImpl.lua 36 KB

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