CombatImpl.lua 37 KB

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