CombatImpl.lua 37 KB

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