CombatBuff.lua 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870
  1. local Util = require("common.Util")
  2. local RoleAttr = require("role.RoleAttr")
  3. local CombatDefine = require("combat.CombatDefine")
  4. local CombatObj = require("combat.CombatObj")
  5. local CombatImpl = require("combat.CombatImpl")
  6. local TargetMode = require("combat.TargetMode")
  7. local CombatCalc = require("combat.CombatCalc")
  8. local RoleDefine = require("role.RoleDefine")
  9. local BeSkill = require("combat.BeSkill")
  10. local BufferExcel = require("excel.buffer")
  11. local Skill = require("combat.Skill")
  12. local SkillExcel = require("excel.skill").skill
  13. local HeroExcel = require("excel.hero").hero
  14. local FuwenExcel = require("excel.fuwen")
  15. local ProjectLogic = require("platform.ProjectLogic")
  16. --和血量相关的作用
  17. local function isHpCmd(cmd)
  18. if cmd == "hp" or cmd == "hurt" or cmd == "hurt1" or cmd == "liuxue" or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "ranshao" or cmd == "ranshao1" or cmd == "huiheYinji" then
  19. return true
  20. end
  21. return false
  22. end
  23. --控制类buff
  24. function isControlCmd(cmd)
  25. if cmd == "xuanyun" or cmd == "shihua" or cmd == "bingdong" or cmd == "chanrao" then
  26. return true
  27. end
  28. end
  29. --跳过行动回合
  30. function isStop(obj)
  31. if obj == nil then
  32. return
  33. end
  34. local bufferCmd = obj.bufferCmd
  35. local ret
  36. if bufferCmd["xuanyun"] or bufferCmd["shihua"] or bufferCmd["bingdong"] or bufferCmd["chanrao"] then
  37. ret = 1
  38. elseif bufferCmd["xuanyun"] then
  39. ret = 2
  40. end
  41. return ret
  42. end
  43. --使用主动技能
  44. function isJingji(obj)
  45. if obj.bufferCmd["jinmo"] then
  46. return true
  47. end
  48. end
  49. --是否缠绕
  50. function isChanRao(obj)
  51. for j = obj.buffer[0], 1, -1 do
  52. local buffer = obj.buffer[j]
  53. local conf = BufferExcel.buffer[buffer.id]
  54. local cmd = conf.cmd
  55. if cmd == "chanrao" then
  56. return true
  57. end
  58. end
  59. end
  60. --是否被嘲讽
  61. function isChaofen(obj)
  62. if obj and obj.buffer then
  63. for j = obj.buffer[0], 1, -1 do
  64. local buffer = obj.buffer[j]
  65. local conf = BufferExcel.buffer[buffer.id]
  66. local cmd = conf.cmd
  67. if cmd == "chaofeng" then
  68. local attackPos = buffer.attackPos
  69. local attacker = CombatImpl.objList[attackPos]
  70. if attacker and attacker.pos ~= obj.pos then
  71. return true,attackPos
  72. end
  73. end
  74. end
  75. end
  76. return false,0
  77. end
  78. --是否被控制
  79. function isAtControl(obj)
  80. if obj and obj.buffer then
  81. for j = obj.buffer[0], 1, -1 do
  82. local buffer = obj.buffer[j]
  83. local conf = BufferExcel.buffer[buffer.id]
  84. local cmd = conf.cmd
  85. if isControlCmd(cmd) then
  86. return true
  87. end
  88. end
  89. end
  90. end
  91. -- 检查能否复活
  92. function canRevive(obj)
  93. if obj then
  94. if obj.hp > 0 then
  95. return
  96. end
  97. if obj.beBackup then
  98. return
  99. end
  100. if obj.dieSkill then
  101. local skillConf = SkillExcel[obj.dieSkill]
  102. if skillConf.otherArgs.noRevive == 1 then
  103. return false
  104. end
  105. end
  106. if obj.bufferCmd and obj.bufferCmd["noRevive"] then
  107. return false
  108. end
  109. for k,v in ipairs(CombatImpl.frameReviceList) do
  110. if v[1] == obj.pos then
  111. return false
  112. end
  113. end
  114. return true
  115. end
  116. end
  117. --是否对某种状态免疫
  118. CMD2KEY = {
  119. ["xuanyun"] = RoleDefine.STATUS_MIANYI_RATE1,
  120. ["shihua"] = RoleDefine.STATUS_MIANYI_RATE2,
  121. ["bingdong"] = RoleDefine.STATUS_MIANYI_RATE3,
  122. ["jinmo"] = RoleDefine.STATUS_MIANYI_RATE4,
  123. ["ranshao"] = RoleDefine.STATUS_MIANYI_RATE5,
  124. ["ranshao1"] = RoleDefine.STATUS_MIANYI_RATE5,
  125. ["liuxue"] = RoleDefine.STATUS_MIANYI_RATE6,
  126. ["liuxue2"] = RoleDefine.STATUS_MIANYI_RATE6,
  127. ["zhongdu"] = RoleDefine.STATUS_MIANYI_RATE7,
  128. ["hunluan"] = RoleDefine.STATUS_MIANYI_RATE9,
  129. }
  130. function isMianyi(obj,cmd)
  131. local key = CMD2KEY[cmd]
  132. local r = math.random(0,10000)
  133. if key and obj.attr[key] >= r then
  134. return true
  135. end
  136. initCombatBufferType()
  137. -- 免疫所有负面状态
  138. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == 1 then
  139. local r = math.random(0,10000)
  140. if obj.attr[RoleDefine.STATUS_MIANYI_RATE8] >= r then
  141. return true
  142. end
  143. end
  144. end
  145. local function isMiankong(obj, cmd, attacker, skillKongRate)
  146. if not isControlCmd(cmd) then return end
  147. if not attacker then return end
  148. if not skillKongRate then return end
  149. -- 新手剧情 100%控制
  150. if CombatImpl.fightMode[1] == CombatDefine.FIGHT_MODE2 then
  151. return false
  152. end
  153. local kongRate = attacker.attr[RoleDefine.KONG_RATE]
  154. -- 附带技能控制率
  155. kongRate = kongRate + skillKongRate
  156. local mianKongRate = obj.attr[RoleDefine.MIANKONG_RATE]
  157. kongRate = kongRate * (1 - mianKongRate/10000)
  158. kongRate = kongRate < 0 and 0 or kongRate
  159. -- 连击模式 控制概率
  160. if CombatImpl.comboType > 0 then
  161. kongRate = kongRate * CombatImpl.comboHurtRate / 10000
  162. end
  163. local r = math.random(1,10000)
  164. if r >= kongRate then
  165. return true
  166. end
  167. end
  168. function getStatus(obj)
  169. return obj.bufferCmd or {}
  170. end
  171. function isStatus(obj,status)
  172. local bufferCmd = obj.bufferCmd
  173. if not bufferCmd then return end
  174. for j = 1,#status do
  175. if bufferCmd[status[j]] then
  176. return true,status[j],bufferCmd[status[j]][1]
  177. end
  178. end
  179. end
  180. function isJob(obj,jobs)
  181. local job = obj.job
  182. for i = 1,#jobs do
  183. if job == jobs[i] then
  184. return true
  185. end
  186. end
  187. end
  188. function isCamp(obj,camps)
  189. local camp = obj.camp
  190. for i = 1,#camps do
  191. if camp == camps[i] then
  192. return true
  193. end
  194. end
  195. end
  196. function isSide(obj,sides, attacker)
  197. if not attacker then return end
  198. local side = obj.side
  199. -- 只能对敌方
  200. if sides == 1 then
  201. if side == attacker.side then
  202. return true
  203. end
  204. -- 只能对友方
  205. elseif sides == 2 then
  206. if side ~= attacker.side then
  207. return true
  208. end
  209. end
  210. end
  211. local function isPos(obj,posList)
  212. local pos = obj.pos
  213. for i = 1,#posList do
  214. if pos == posList[i] then
  215. return true
  216. end
  217. end
  218. end
  219. function getBuffer(obj)
  220. return obj.buffer
  221. end
  222. function onBufferChange(obj)
  223. local bufferAttr = obj.bufferAttr
  224. RoleAttr.initCombatAttr(bufferAttr)
  225. local bufferCmd = obj.bufferCmd
  226. for k,v in pairs(bufferCmd) do
  227. bufferCmd[k] = nil
  228. end
  229. local changeList = {}
  230. for i = 1, obj.buffer[0] do
  231. local buffer = obj.buffer[i]
  232. local conf = BufferExcel.buffer[buffer.id]
  233. if conf.cmd == "stealattr" or
  234. conf.cmd == "handleattr" or
  235. conf.cmd == "attr" or
  236. conf.cmd == "attrdne" or
  237. conf.cmd == "attr1" or
  238. conf.cmd == "pojia" or
  239. conf.cmd == "jiansu" or
  240. conf.cmd == "defRate" or
  241. conf.cmd == "defRate2" or
  242. conf.cmd == "attrQusan" then
  243. if type(buffer.arg) == "table" then
  244. for j = 1,#buffer.arg do
  245. local attrData = buffer.arg[j]
  246. local key = attrData[1]
  247. local value = 0
  248. if not conf.attrRate then
  249. value = attrData[2]
  250. else
  251. value = conf.attrRate
  252. end
  253. RoleAttr.updateValue(key,value,bufferAttr,true)
  254. end
  255. else
  256. for j = 1,#conf.args do
  257. local attrData = conf.args[j]
  258. local key = attrData[1]
  259. local value = 0
  260. if not conf.attrRate then
  261. value = attrData[2]
  262. else
  263. value = conf.attrRate
  264. end
  265. RoleAttr.updateValue(key,buffer.arg or (value * buffer.cnt),bufferAttr,true)
  266. end
  267. end
  268. end
  269. if conf.cmd == "xuruo" then
  270. RoleAttr.updateValue(RoleDefine.XURUO,buffer.arg or conf.args[1],bufferAttr,true)
  271. end
  272. if conf.cmd == "fansheZhuangjia" then
  273. RoleAttr.updateValue(RoleDefine.FANSHE_ZHUANGJIA,conf.args[1],bufferAttr,true)
  274. end
  275. if conf.cmd == "hudun" then
  276. RoleAttr.updateValue(RoleDefine.HUDUN_COMBAT, buffer.arg, bufferAttr,true)
  277. end
  278. --标识,给其他英雄加属性的buff
  279. if conf.cmd == "biaoshi" then
  280. local attacker = buffer.attackPos and CombatImpl.objList[buffer.attackPos]
  281. if attacker then
  282. if not changeList[attacker.pos] then
  283. changeList[attacker.pos] = 1
  284. attacker.bufferAttr2[obj.pos] = {}
  285. RoleAttr.initCombatAttr(attacker.bufferAttr2[obj.pos])
  286. end
  287. for j = 1,#conf.args do
  288. local attrData = conf.args[j]
  289. local key = attrData[1]
  290. local value = attrData[2]
  291. RoleAttr.updateValue(key,buffer.arg or (value * buffer.cnt),attacker.bufferAttr2[obj.pos],true)
  292. end
  293. end
  294. end
  295. bufferCmd[conf.cmd] = bufferCmd[conf.cmd] or {}
  296. bufferCmd[conf.cmd][#bufferCmd[conf.cmd] + 1] = i
  297. end
  298. CombatObj.calcAttr(obj)
  299. for pos in pairs(changeList) do
  300. CombatObj.calcAttr(CombatImpl.objList[pos])
  301. end
  302. end
  303. local function canAdd(obj, id, random, attacker, skillConfig)
  304. local conf = BufferExcel.buffer[id]
  305. if not conf then
  306. return
  307. end
  308. -- 非控制buff 走随机
  309. if not isControlCmd(conf.cmd) then
  310. -- 新手剧情 100%控制
  311. if CombatImpl.fightMode[1] == CombatDefine.FIGHT_MODE2 then
  312. random = 10000
  313. end
  314. if random and not Util.checkRandom(random) then
  315. return
  316. end
  317. end
  318. if obj.pos > CombatDefine.COMBAT_HERO_ALL_CNT then
  319. return
  320. end
  321. if obj.hp <= 0 then
  322. if conf.cmd == "revive" then
  323. return true
  324. else
  325. if conf.cmd == "noRevive" then
  326. return true
  327. end
  328. end
  329. return
  330. end
  331. if conf.cmd == "fixPos" then
  332. return true
  333. end
  334. if #conf.jobs > 0 and not isJob(obj,conf.jobs) then
  335. return
  336. end
  337. if conf.camp and #conf.camp > 0 and not isCamp(obj,conf.camp) then
  338. return
  339. end
  340. -- 只能给友方或者敌对方加
  341. if conf.side and conf.side > 0 and isSide(obj, conf.side, attacker) then
  342. return
  343. end
  344. if #conf.status > 0 and not isStatus(obj,conf.status) then
  345. return
  346. end
  347. if #conf.pos > 0 and not isPos(obj,conf.pos) then
  348. return
  349. end
  350. if isMianyi(obj,conf.cmd) then
  351. return
  352. end
  353. if isMiankong(obj,conf.cmd, attacker, random) then
  354. return
  355. end
  356. --连击 BUFF率为 本来的一半
  357. if CombatImpl.comboType > 0 then
  358. local random = math.random(1, 10000)
  359. if random < 5000 then
  360. return
  361. end
  362. end
  363. return true
  364. end
  365. --根据cmd删除buff
  366. local function delBufferByCmd(obj,cmd,cnt)
  367. local delCnt = 0
  368. for j = obj.buffer[0], 1, -1 do
  369. local buffer = obj.buffer[j]
  370. local conf = BufferExcel.buffer[buffer.id]
  371. local bufferCmd = conf.cmd
  372. if bufferCmd == cmd then
  373. local bufferCnt = delBuffer(obj, j)
  374. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  375. delCnt = delCnt + 1
  376. if delCnt == cnt then
  377. return
  378. end
  379. end
  380. end
  381. end
  382. --删除所有buff
  383. local function delAllBuff(obj)
  384. for i = 1, obj.buffer[0] do
  385. obj.buffer[i] = nil
  386. end
  387. obj.buffer[0] = 0
  388. end
  389. --判断是否抵消buff
  390. local function cancelBuffer(obj,conf)
  391. local cancelCmd = conf.cancelCmd[1]
  392. local cnt = conf.cancelCmd[2]
  393. if not (cancelCmd and cnt) then
  394. return
  395. end
  396. local nowCnt = getBuffCnt(obj,cancelCmd)
  397. if cnt < 0 then --全删抵消buff
  398. if nowCnt > 0 then
  399. delBufferByCmd(obj,cancelCmd,cnt)
  400. return true
  401. end
  402. elseif cnt == 0 then--不删抵消buff
  403. if nowCnt > 0 then
  404. return true
  405. end
  406. elseif cnt > 0 then--删指定数量抵消buff
  407. if nowCnt >= cnt then
  408. delBufferByCmd(obj,cancelCmd,cnt)
  409. return true
  410. end
  411. end
  412. end
  413. DELAY_BUFF_OP = false
  414. DELAY_LIST = nil
  415. --不可以延迟加的buffcmd(加的时候可能会触发删除其他buff的cmd)
  416. NO_DELAY_BUFFCMD = {
  417. ["convert"] = 1
  418. }
  419. local function delayBegin()
  420. if DELAY_BUFF_OP then
  421. return
  422. end
  423. DELAY_BUFF_OP = true
  424. DELAY_LIST = {del = {},add = {}}
  425. end
  426. local function delayEnd()
  427. if not DELAY_BUFF_OP then
  428. return
  429. end
  430. table.sort(DELAY_LIST.del,function(a,b)
  431. return a[2] > b[2]
  432. end)
  433. DELAY_BUFF_OP = false
  434. local delRecord = {}
  435. for k,v in ipairs(DELAY_LIST.del) do
  436. delRecord[v[1]] =delRecord[v[1]] or {}
  437. if not delRecord[v[1]][v[2]] then
  438. delBuffer(v[1], v[2])
  439. delRecord[v[1]][v[2]] = 1
  440. end
  441. end
  442. for k,v in ipairs(DELAY_LIST.add) do
  443. addBuffer(v[1],v[2], v[3], v[4],v[5],v[6])
  444. end
  445. DELAY_LIST = {del = {},add = {}}
  446. end
  447. local function beforeAddBuffer(attackPos,obj, id, skillID,arg,parentConf)
  448. local conf = BufferExcel.buffer[id]
  449. local bufferCmd = conf.cmd
  450. if bufferCmd == "fixPos" then
  451. elseif cancelBuffer(obj,conf) then
  452. return true
  453. elseif bufferCmd == "shengling" then
  454. elseif conf.holdOnDie ~= 1 and obj.hp <= 0 then
  455. return true
  456. elseif conf.roundOne == 1 then
  457. for j = obj.buffer[0], 1, -1 do
  458. local buffer = obj.buffer[j]
  459. if buffer.id == id and buffer.attackPos == attackPos and buffer.round == conf.round then
  460. return true
  461. end
  462. end
  463. end
  464. if conf.type == CombatDefine.BUFFER_TYPE4 then
  465. if handler[bufferCmd] then
  466. local attacker = CombatImpl.objList[attackPos]
  467. handler[bufferCmd](attacker,obj,conf)
  468. end
  469. return true
  470. end
  471. if bufferCmd == "convert" then
  472. local bufferList = {}
  473. for j = obj.buffer[0], 1, -1 do
  474. local buffer = obj.buffer[j]
  475. if buffer.id == id then
  476. bufferList[#bufferList + 1] = j
  477. end
  478. end
  479. local needCnt = conf.args[1]
  480. if #bufferList + 1 < needCnt then
  481. return
  482. end
  483. for _,v in ipairs(bufferList) do
  484. local buffer = obj.buffer[v]
  485. local bufferCnt = delBuffer(obj, v)
  486. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  487. end
  488. addBuffer(attackPos,obj, conf.args[2], skillID,arg,parentConf)
  489. return true
  490. end
  491. end
  492. -- 添加到复活列表
  493. local function checkRevive(attackPos,obj,bufferID,skillID)
  494. local conf = BufferExcel.buffer[bufferID]
  495. if conf.cmd ~= "revive" then
  496. return
  497. end
  498. if not canRevive(obj) then
  499. return true
  500. end
  501. CombatImpl.addRevice(attackPos, obj, bufferID, skillID)
  502. return true
  503. end
  504. -- 复活对象
  505. function reviceObj(attackPos, obj, bufferID, skillID)
  506. local conf = BufferExcel.buffer[bufferID]
  507. if not conf then return end
  508. local skillConf = skillID and SkillExcel[skillID]
  509. if not skillConf then return end
  510. local attacker = CombatImpl.objList[attackPos]
  511. local hpRevive = CombatCalc.calcHp(attacker, obj, conf.args[1], conf.args[2], true)
  512. local hpAddRate = CombatObj.getValue(attacker,RoleDefine.ZAOCHENG_HP_ADD_RATE) / 10000
  513. hpRevive = hpRevive * (1 + hpAddRate)
  514. hpRevive = hpRevive < 0 and 1 or hpRevive
  515. local d = CombatObj.updateHp(obj, hpRevive, true, nil, nil, CombatObj.EXTRA_HP_TYPE)
  516. local attrs = {}
  517. attrs[RoleDefine.REVIVE_COMBAT] = attackPos
  518. CombatImpl.setSkillID(attacker, skillID)
  519. CombatImpl.setSkillHit(obj,0, nil, nil, attacker, skillID)
  520. CombatImpl.setSaySkill(attacker.pos,skillConf.id,skillConf.contentType)
  521. CombatImpl.setExtraHit(obj,d,Skill.getCMD2ID("revive"),attrs)
  522. if skillConf and skillConf.type == 0 then
  523. onExtraCombatRecord(attackPos, 1, "reviveBeUse")
  524. else
  525. onExtraCombatRecord(attackPos, 1, "revive")
  526. end
  527. if skillConf.cmd == "revive" then
  528. local buffers = skillConf.args
  529. local addBufferID = buffers[1]
  530. if addBufferID then
  531. local targetMode = buffers[2]
  532. local random = buffers[3]
  533. local targets = TargetMode.getTargets(obj, targetMode)
  534. if #targets > 0 then
  535. for _,target in ipairs(targets) do
  536. if canAdd(target, addBufferID, random, obj, skillConf) then
  537. addBuffer(obj.pos, target, addBufferID, skillConf.id, arg)
  538. end
  539. end
  540. end
  541. end
  542. end
  543. BeSkill.onAddBuffer(obj,{id = bufferID})
  544. end
  545. function addBuffer(attackPos,obj, id, skillID,arg,parentConf)
  546. local conf = BufferExcel.buffer[id]
  547. local bufferCmd = conf.cmd
  548. if DELAY_BUFF_OP then
  549. if not NO_DELAY_BUFFCMD[bufferCmd] then
  550. DELAY_LIST.add[#DELAY_LIST.add + 1] = {attackPos,obj, id, skillID,arg,parentConf}
  551. end
  552. return
  553. end
  554. if checkRevive(attackPos,obj, id, skillID) then
  555. return
  556. end
  557. if beforeAddBuffer(attackPos,obj, id, skillID,arg,parentConf) then
  558. return
  559. end
  560. local bufferCnt = 1
  561. local index
  562. local buffer
  563. local bufferCmdInd
  564. local bufferInd
  565. local tround = 0
  566. local index = 0
  567. local groupCnt = 0
  568. local group = conf.group[1]
  569. for i = 1, obj.buffer[0] do
  570. buffer = obj.buffer[i]
  571. if buffer.id == id then
  572. bufferCnt = bufferCnt + 1
  573. bufferInd = i
  574. if tround > buffer.round or tround == 0 then
  575. tround = buffer.round
  576. index = i
  577. end
  578. end
  579. local nowBuffConf = BufferExcel.buffer[buffer.id]
  580. if nowBuffConf.cmd == bufferCmd then
  581. bufferCmdInd = i
  582. end
  583. if group and group == nowBuffConf.group[1] then
  584. groupCnt = groupCnt + 1
  585. end
  586. end
  587. local groupCmd = conf.group[2]
  588. if groupCmd and groupCnt > 0 and groupCnt >= groupCmd then
  589. return
  590. end
  591. if bufferCnt > 100 then
  592. return
  593. end
  594. local canAppend = parentConf and parentConf.canAppend or conf.canAppend
  595. local round = parentConf and parentConf.round or conf.round
  596. round = round == 0 and 1 or round
  597. if canAppend == 1 then
  598. local appendCnt = conf.appendCnt or 0
  599. if appendCnt > 0 and bufferCnt > conf.appendCnt then
  600. if conf.type == CombatDefine.BUFFER_TYPE2 then
  601. buffer = obj.buffer[index]
  602. buffer.round = round
  603. --bingdong清除buffer参数
  604. if conf.cmd == "bingdong" then
  605. buffer.arg = nil
  606. end
  607. CombatImpl.onAddBuffer(id)
  608. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_ADD,0)
  609. return
  610. end
  611. return
  612. end
  613. else
  614. if bufferCnt > 1 then
  615. if conf.type == CombatDefine.BUFFER_TYPE2 then
  616. buffer = obj.buffer[bufferInd]
  617. buffer.round = round
  618. --bingdong清除buffer参数
  619. if conf.cmd == "bingdong" then
  620. buffer.arg = nil
  621. end
  622. CombatImpl.onAddBuffer(id)
  623. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_ADD,0)
  624. return
  625. end
  626. return
  627. end
  628. end
  629. if isControlCmd(bufferCmd) and bufferCmdInd then
  630. buffer = obj.buffer[bufferCmdInd]
  631. if buffer.round < round then
  632. buffer.round = round
  633. end
  634. if conf.cmd == "bingdong" then
  635. buffer.arg = nil
  636. end
  637. return
  638. end
  639. obj.buffer[0] = obj.buffer[0] + 1
  640. index = obj.buffer[0]
  641. buffer = obj.buffer[index]
  642. if not buffer then
  643. obj.buffer[index] = {}
  644. buffer = obj.buffer[index]
  645. end
  646. buffer.id = id
  647. buffer.round = nil -- 剩余回合
  648. buffer.attrs = nil
  649. buffer.attackPos = nil
  650. buffer.skillID = nil
  651. buffer.cnt = 1
  652. buffer.arg = nil
  653. if round then
  654. buffer.round = round
  655. elseif conf.type == CombatDefine.BUFFER_TYPE1 then
  656. buffer.round = 1
  657. elseif conf.type == CombatDefine.BUFFER_TYPE2 then
  658. buffer.round = round
  659. elseif conf.type == CombatDefine.BUFFER_TYPE3 then
  660. buffer.round = nil
  661. else
  662. assert()
  663. end
  664. local attacker
  665. if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
  666. attacker = CombatImpl.helpList[attackPos]
  667. else
  668. attacker = CombatImpl.objList[attackPos]
  669. end
  670. if arg then
  671. buffer.arg = arg
  672. elseif isHpCmd(conf.cmd) then
  673. local isAddHp = conf.cmd == "hp"
  674. buffer.arg = CombatCalc.calcBufferHp(attacker,obj,id,isAddHp)
  675. end
  676. buffer.attackPos = attackPos
  677. buffer.skillID = skillID
  678. buffer.attrs = {}
  679. if bufferCmd == "shengling" then
  680. buffer.arg = conf.args[3]
  681. elseif bufferCmd == "hudun" then
  682. local attackerHp = CombatCalc.calcHp(attacker, obj, conf.args[1], conf.args[2], true)
  683. local hudunValue = math.floor(conf.args[2] * attackerHp / 10000)
  684. buffer.arg = hudunValue
  685. end
  686. onBufferChange(obj)
  687. if conf.isAddCmd == 1 and handler[conf.cmd] then
  688. handler[conf.cmd](obj,buffer,conf)
  689. HANDLER_ONCE[conf.cmd] = nil
  690. end
  691. if conf.type ~= CombatDefine.BUFFER_TYPE1 then
  692. CombatImpl.onAddBuffer(id)
  693. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_ADD)
  694. end
  695. BeSkill.onAddBuffer(obj,buffer)
  696. onExtraCombatRecord(attackPos,1,bufferCmd)
  697. return buffer
  698. end
  699. local function delBufferByTotem(obj,totemId)
  700. for j = obj.buffer[0], 1, -1 do
  701. local buffer = obj.buffer[j]
  702. local conf = BufferExcel.buffer[buffer.id]
  703. if bufferCmd ~= "totem" and buffer.totem == totemId then
  704. delBuffer(obj,j)
  705. end
  706. end
  707. end
  708. local function beforeDelBuffer(obj, buffer)
  709. local conf = BufferExcel.buffer[buffer.id]
  710. if conf.cmd == "fentan" and buffer.round < 1 then
  711. local hurt = CombatCalc.calcHp(obj, obj, conf.args[1], conf.args[2])
  712. if hurt > 0 then
  713. local d = CombatObj.updateHp(obj, hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  714. CombatImpl.setExtraHit(obj, hurt)
  715. CombatObj.onHpCB(obj, d, obj.pos)
  716. end
  717. end
  718. end
  719. function delBuffer(obj, ind)
  720. if not obj.buffer[ind] then
  721. return
  722. end
  723. if DELAY_BUFF_OP then
  724. for k,v in ipairs(DELAY_LIST.del) do
  725. if v[2] == ind then
  726. return
  727. end
  728. end
  729. DELAY_LIST.del[#DELAY_LIST.del + 1] = {obj, ind}
  730. return
  731. end
  732. local id = obj.buffer[ind].id
  733. beforeDelBuffer(obj,obj.buffer[ind])
  734. obj.buffer[ind] = obj.buffer[obj.buffer[0]]
  735. obj.buffer[obj.buffer[0]] = nil
  736. obj.buffer[0] = obj.buffer[0] - 1
  737. onBufferChange(obj)
  738. local bufferCnt = 0
  739. for i = 1, obj.buffer[0] do
  740. local buffer = obj.buffer[i]
  741. if buffer.id == id then
  742. bufferCnt = bufferCnt + 1
  743. end
  744. end
  745. return bufferCnt
  746. end
  747. -- 战斗回合开始时添加buffer
  748. function beforeCombat()
  749. end
  750. function getSkillBuffers(skillConfig)
  751. local randBuffCnt = skillConfig.otherArgs.randBuffCnt
  752. if not randBuffCnt then
  753. return skillConfig.buffers
  754. end
  755. local ret = {}
  756. local c = #skillConfig.buffers
  757. if randBuffCnt >= c then
  758. return skillConfig.buffers
  759. end
  760. for i = 1,c do
  761. ret[i] = skillConfig.buffers[i]
  762. end
  763. for i = 1,c do
  764. if i <= randBuffCnt then
  765. local r = math.random(i,c)
  766. ret[i],ret[r] = ret[r],ret[i]
  767. else
  768. ret[i] = nil
  769. end
  770. end
  771. return ret
  772. end
  773. -- 战斗回合中触发buffer
  774. function onHit(attacker, skillTargets, skillConfig, cmdTargets, otherArgs)
  775. -- 处理施法者身上的buff
  776. if skillConfig.type == CombatDefine.SKILL_TYPE2 and
  777. attacker.buffer ~= nil then
  778. delayBegin()
  779. for j = attacker.buffer[0], 1, -1 do
  780. local buffer = attacker.buffer[j]
  781. local conf = BufferExcel.buffer[buffer.id]
  782. buffer.attrs = { }
  783. if attacker.hp > 0 and handlerEx[conf.cmd] then
  784. if handlerEx[conf.cmd](attacker, buffer, conf) then
  785. CombatImpl.addFrameBuffer(attacker, buffer, CombatDefine.BUFFER_OP_HOLD)
  786. end
  787. end
  788. end
  789. delayEnd()
  790. end
  791. for k, v in ipairs(skillTargets) do
  792. if attacker.helpType == 0 and attacker.side ~= v.side then
  793. local fantanBufferInd = v.bufferCmd["fantan"] and v.bufferCmd["fantan"][1]
  794. local fantanBuffer = v.buffer[fantanBufferInd]
  795. if fantanBuffer then
  796. local conf = BufferExcel.buffer[fantanBuffer.id]
  797. -- 是否限制技能类型
  798. local bHit = false
  799. if conf.args[3] then
  800. if conf.args[3] == skillConfig.type then
  801. bHit = true
  802. end
  803. else
  804. bHit = true
  805. end
  806. if bHit then
  807. local hurt = CombatCalc.calcHp(attacker, v, conf.args[1], conf.args[2])
  808. local d = CombatObj.updateHp(attacker, - hurt, nil, nil, v.pos, CombatObj.BUFFER_HP_TYPE)
  809. CombatImpl.setExtraHit(attacker, d)
  810. CombatObj.onHpCB(attacker, d, v.pos)
  811. end
  812. end
  813. end
  814. -- 只能敌方攻击触发降低冰冻
  815. if not(otherArgs and otherArgs.noFirst) and skillConfig.hurtRate[1] then
  816. local bufferCmd = v.bufferCmd["bingdong"]
  817. if bufferCmd then
  818. local delList = { }
  819. for i = #bufferCmd, 1, -1 do
  820. local bingdongBuffer = v.buffer[bufferCmd[i]]
  821. local conf = BufferExcel.buffer[bingdongBuffer.id]
  822. bingdongBuffer.arg = bingdongBuffer.arg or 0
  823. bingdongBuffer.arg = bingdongBuffer.arg + 1
  824. if bingdongBuffer.arg >=(conf.args[1] or 0) then
  825. delList[#delList + 1] = bufferCmd[i]
  826. end
  827. end
  828. --冰冻buffer被打碎
  829. if #delList > 0 then
  830. local delBuffer = v.buffer[delList[1]]
  831. BeSkill.onDelBingDongBuffer(v, delBuffer)
  832. end
  833. for k1, v1 in ipairs(delList) do
  834. local buffer = v.buffer[v1]
  835. local bufferCnt = delBuffer(v, v1)
  836. CombatImpl.addFrameBuffer(v, buffer, CombatDefine.BUFFER_OP_DEL)
  837. end
  838. end
  839. end
  840. end
  841. local buffers = getSkillBuffers(skillConfig)
  842. local statusBuffRate = skillConfig.otherArgs.statusBuffRate
  843. for i = 1, #buffers do
  844. local bufferID = buffers[i][1]
  845. if type(bufferID) == "table" then
  846. local r = math.random(1, #bufferID)
  847. bufferID = bufferID[r]
  848. end
  849. local targetMode = buffers[i][2]
  850. local random = buffers[i][3]
  851. local bufferEx = buffers[i][4]
  852. local delayRound = buffers[i][5]
  853. if attacker.isPet and #skillConfig.bufferGrow > 0 then
  854. local growRate = 0
  855. local bufLv = attacker.lv
  856. if attacker.quality > 1 then
  857. bufLv = attacker.lv -(attacker.quality - 1) * 30
  858. end
  859. if skillConfig.bufferGrow and skillConfig.bufferGrow[i] then
  860. local gorwRat = skillConfig.bufferGrow[i][1]
  861. local growLv = skillConfig.bufferGrow[i][2]
  862. growRate = math.floor(bufLv / growLv) * gorwRat
  863. end
  864. random = random + growRate
  865. end
  866. local targets = TargetMode.getTargets(attacker, targetMode, skillTargets, cmdTargets, nil, nil, skillConfig.id)
  867. if #targets > 0 then
  868. local bufferConf = BufferExcel.buffer[bufferID]
  869. for _, target in ipairs(targets) do
  870. local r = random
  871. if statusBuffRate and bufferConf.cmd == statusBuffRate[1] and isStatus(target, statusBuffRate[2]) then
  872. r = r + statusBuffRate[3]
  873. end
  874. if canAdd(target, bufferID, r, attacker, skillConfig) then
  875. local arg
  876. if bufferConf.cmd == "zuzhou" then
  877. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker, bufferID, bufferConf.cmd)
  878. arg = { CombatCalc.calcHp(attacker, target, bufferConf.args[1], rate) }
  879. end
  880. if bufferConf.cmd == "stealattr" then
  881. local value = CombatCalc.calcValue(attacker, target, bufferConf.args[1], bufferConf.args[2])
  882. arg = { { bufferConf.args[3], value } }
  883. end
  884. if bufferConf.cmd == "handleattr" then
  885. arg = { }
  886. if attacker.handleAttr then
  887. local value = attacker.handleAttr[2] *(bufferConf.args[1] / 10000)
  888. if target.side == attacker.side then
  889. arg = { { attacker.handleAttr[1], value * bufferConf.args[2] } }
  890. else
  891. arg = { { attacker.handleAttr[1], - value } }
  892. end
  893. end
  894. end
  895. if delayRound and delayRound > 0 then
  896. target.delayAddBuffer = target.delayAddBuffer or { }
  897. target.delayAddBuffer[#target.delayAddBuffer + 1] = { delayRound, attacker.pos, bufferID, skillConfig.id, arg }
  898. else
  899. addBuffer(attacker.pos, target, bufferID, skillConfig.id, arg)
  900. end
  901. if bufferEx then
  902. local bufferID = bufferEx[1]
  903. local random = bufferEx[2]
  904. local delayRound = bufferEx[3]
  905. local bufferConf = BufferExcel.buffer[bufferID]
  906. for _, target in ipairs(targets) do
  907. local r = random
  908. if canAdd(target, bufferID, r, attacker, skillConfig) then
  909. local arg
  910. if bufferConf.cmd == "zuzhou" then
  911. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker, bufferID, bufferConf.cmd)
  912. arg = { CombatCalc.calcHp(attacker, target, bufferConf.args[1], rate) }
  913. end
  914. if bufferConf.cmd == "stealattr" then
  915. local value = CombatCalc.calcValue(attacker, target, bufferConf.args[1], bufferConf.args[2])
  916. arg = { { bufferConf.args[3], value } }
  917. end
  918. if bufferConf.cmd == "handleattr" then
  919. arg = { }
  920. if attacker.handleAttr then
  921. local value = attacker.handleAttr[2] *(bufferConf.args[1] / 10000)
  922. if target.side == attacker.side then
  923. arg = { { attacker.handleAttr[1], value * bufferConf.args[2] } }
  924. else
  925. arg = { { attacker.handleAttr[1], - value } }
  926. end
  927. end
  928. end
  929. if delayRound and delayRound > 0 then
  930. target.delayAddBuffer = target.delayAddBuffer or { }
  931. target.delayAddBuffer[#target.delayAddBuffer + 1] = { delayRound, attacker.pos, bufferID, skillConfig.id, arg }
  932. else
  933. addBuffer(attacker.pos, target, bufferID, skillConfig.id, arg)
  934. end
  935. end
  936. end
  937. end
  938. end
  939. end
  940. end
  941. end
  942. end
  943. local function getBeskillBuffers(attacker,skillConfig)
  944. if skillConfig.otherArgs.buffer then
  945. local checkArg = skillConfig.otherArgs.buffer
  946. local checkValue
  947. if checkArg.cmd == "hurtRate" then
  948. checkValue = -attacker.combatResult[1]
  949. elseif checkArg.cmd == "hpRate" then
  950. checkValue = attacker.combatResult[2]
  951. end
  952. if checkValue and checkValue > 0 then
  953. local hpMax = attacker.attr[RoleDefine.HP]
  954. local rate = (10000 * checkValue)/(hpMax * checkArg.param[1])
  955. if rate > 1 then
  956. local retArg = {}
  957. for k,v in ipairs(checkArg.param[2]) do
  958. retArg[#retArg + 1] = {v[1],math.floor(v[2] * rate)}
  959. end
  960. return skillConfig.buffers,retArg
  961. end
  962. end
  963. else
  964. return skillConfig.buffers
  965. end
  966. end
  967. function onUseBeSkill(attacker,skillConfig,objs,cmdTargets, arg)--attacker是被动技能释放者,objs是attacker的对立方(attacker是攻击者的话,objs是被攻击者,attacker是被攻击者的话,objs是攻击者),cmdTargets是额外作用对象
  968. local buffers,bufferArg = getBeskillBuffers(attacker,skillConfig)
  969. if not buffers then
  970. return
  971. end
  972. bufferArg = bufferArg or arg
  973. local isAddSkillFrame
  974. local bufferArg1
  975. for i = 1, #buffers do
  976. local bufferID = buffers[i][1]
  977. local bufferConf = BufferExcel.buffer[bufferID]
  978. local targetMode = buffers[i][2]
  979. local targets
  980. bufferArg1 = nil
  981. if targetMode[1] == 13 then
  982. targets = objs
  983. else
  984. targets = TargetMode.getTargets(attacker, targetMode,objs,cmdTargets)
  985. end
  986. if #targets > 0 then
  987. if bufferConf.cmd == "zuzhou" then
  988. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker,bufferID)
  989. bufferArg1 = {CombatCalc.calcHp(attacker,targets[1],bufferConf.args[1],rate)}
  990. end
  991. local attackPos = attacker.pos
  992. if bufferConf.roundOne == 1 and objs and objs[1] then
  993. attackPos = objs[1].pos
  994. end
  995. for _,target in ipairs(targets) do
  996. if canAdd(target,bufferID,buffers[i][3], attacker, skillConfig) then
  997. isAddSkillFrame = true
  998. addBuffer(attackPos,target, bufferID,skillConfig.id,bufferArg1 or bufferArg)
  999. end
  1000. end
  1001. end
  1002. end
  1003. return isAddSkillFrame
  1004. end
  1005. --战斗回合结束时处理buffer效果。删除失效buffer
  1006. --只执行一次的cmd,比如持续加血。
  1007. HANDLER_ONCE = HANDLER_ONCE or {}
  1008. function onRoundEnd(attacker,isRoundEnd)
  1009. --处理施法者身上的buff
  1010. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1011. local obj = CombatImpl.objList[i]
  1012. if obj then
  1013. for k,v in pairs(HANDLER_ONCE) do
  1014. HANDLER_ONCE[k] = nil
  1015. end
  1016. delayBegin()
  1017. for j = obj.buffer[0], 1, -1 do
  1018. local buffer = obj.buffer[j]
  1019. local conf = BufferExcel.buffer[buffer.id]
  1020. if conf.type == CombatDefine.BUFFER_TYPE1 or isRoundEnd then
  1021. buffer.attrs = {}
  1022. local setFrame = false
  1023. if conf.type ~= CombatDefine.BUFFER_TYPE4 and handler[conf.cmd] then
  1024. if obj.hp > 0 or conf.cmd == "totem" then
  1025. if conf.cmd == "zuzhou" then
  1026. -- 最后一回合生效
  1027. if buffer.round == 1 then
  1028. handler[conf.cmd](obj, buffer,conf)
  1029. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1030. end
  1031. else
  1032. handler[conf.cmd](obj, buffer,conf)
  1033. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1034. end
  1035. end
  1036. end
  1037. if buffer.round then
  1038. local cmd = conf.cmd
  1039. buffer.round = buffer.round - 1
  1040. if buffer.round < 1 then
  1041. local bufferCnt = delBuffer(obj, j)
  1042. if (conf.type ~= CombatDefine.BUFFER_TYPE1 and obj.hp > 0) or conf.cmd == "fixPos" or conf.holdOnDie == 1 then
  1043. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1044. end
  1045. end
  1046. end
  1047. end
  1048. end
  1049. if isRoundEnd and obj.delayAddBuffer then
  1050. --{delayRound,attacker.pos,bufferID,skillConfig.id,arg}
  1051. for k,v in ipairs(obj.delayAddBuffer) do
  1052. v[1] = v[1] - 1
  1053. end
  1054. local temp = {}
  1055. for i = 1,#obj.delayAddBuffer do
  1056. local data = obj.delayAddBuffer[i]
  1057. if data[1] > 0 then
  1058. temp[#temp + 1] = data
  1059. else
  1060. addBuffer(data[2],obj,data[3],data[4],data[5])
  1061. end
  1062. end
  1063. if #temp > 0 then
  1064. obj.delayAddBuffer = temp
  1065. else
  1066. obj.delayAddBuffer = nil
  1067. end
  1068. end
  1069. delayEnd()
  1070. end
  1071. end
  1072. for k,v in pairs(HANDLER_ONCE) do
  1073. HANDLER_ONCE[k] = nil
  1074. end
  1075. end
  1076. --攻击结束后,反击前,整合buffer前处理buffer效果
  1077. function beforeFanji()
  1078. local isFanshe = false
  1079. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1080. local obj = CombatImpl.objList[i]
  1081. if obj then
  1082. for k,v in pairs(obj.combatResult[3]) do
  1083. if k ~= i and v[1] and v[1] < 0 then
  1084. local target = CombatImpl.objList[k]
  1085. if target and target.hp > 0 then
  1086. local d = CombatObj.updateHp(target, v[1], nil, nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1087. CombatImpl.setExtraHit(target,d)
  1088. CombatObj.onHpCB(target,d, obj.pos)
  1089. isFanshe = true
  1090. end
  1091. end
  1092. end
  1093. if isFanshe then
  1094. delBufferByCmd(obj,"fansheZhuangjia",1)
  1095. end
  1096. end
  1097. end
  1098. end
  1099. function getExtraHurtRate(attacker,target,skillConfig)
  1100. local skillID = skillConfig.id
  1101. local isBaoji = target.isBaoji
  1102. local baojiHurtRate = 0
  1103. local guanxinzheHurtRate = 0
  1104. local huiheHurtRate = 0
  1105. local shandianHurtRate = 0
  1106. local attackerHurtRat = 0
  1107. local biaoshiHurtRate = 0
  1108. local biaoshiCnt = 0
  1109. local moweiHurtRate = 0
  1110. local biaoshiCntLimit
  1111. if skillConfig.otherArgs.biaoshiHurtRate then
  1112. biaoshiCntLimit = skillConfig.otherArgs.biaoshiHurtRate[1]
  1113. end
  1114. for j = target.buffer[0], 1, -1 do
  1115. local obj = target
  1116. local buffer = obj.buffer[j]
  1117. local conf = BufferExcel.buffer[buffer.id]
  1118. if conf.cmd == "guanxinzheYinji" then --观星者印记
  1119. guanxinzheHurtRate = guanxinzheHurtRate + conf.args[2]
  1120. elseif conf.cmd == "shandianYinji" then --闪电印记
  1121. for _,v in ipairs(conf.args[2]) do
  1122. if skillID == v then
  1123. shandianHurtRate = shandianHurtRate + conf.args[3]
  1124. break
  1125. end
  1126. end
  1127. elseif conf.cmd == "biaoshi" then
  1128. biaoshiCnt = biaoshiCnt + 1
  1129. end
  1130. end
  1131. --攻击者
  1132. for j = attacker.buffer[0], 1, -1 do
  1133. local obj = attacker
  1134. local buffer = obj.buffer[j]
  1135. local conf = BufferExcel.buffer[buffer.id]
  1136. if conf.cmd == "mowei" then --魔威
  1137. local nowHp = attacker.hp
  1138. local hpMax = CombatObj.getHpMax(attacker)
  1139. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1140. if percent >= 1 then
  1141. --moweiHurtRate = moweiHurtRate + (percent * conf.args[1])
  1142. moweiHurtRate = percent * conf.args[1]
  1143. break
  1144. end
  1145. end
  1146. end
  1147. guanxinzheHurtRate = guanxinzheHurtRate > 30000 and 30000 or guanxinzheHurtRate --300%限制
  1148. if biaoshiCntLimit and biaoshiCnt >= biaoshiCntLimit then
  1149. biaoshiHurtRate = skillConfig.otherArgs.biaoshiHurtRate[2]
  1150. end
  1151. local extraHurtRate = baojiHurtRate + guanxinzheHurtRate + huiheHurtRate + shandianHurtRate + attackerHurtRat + biaoshiHurtRate + moweiHurtRate
  1152. return extraHurtRate
  1153. end
  1154. function getExtraHurt(attacker, target, skillConfig)
  1155. local extraHurt = 0
  1156. for j = target.buffer[0], 1, -1 do
  1157. local obj = target
  1158. local buffer = obj.buffer[j]
  1159. local conf = BufferExcel.buffer[buffer.id]
  1160. if conf.cmd == "shenhuo" then
  1161. local hurt = CombatCalc.calcHp(attacker, target, conf.args[1], conf.args[2], true)
  1162. extraHurt = extraHurt + hurt
  1163. end
  1164. end
  1165. return extraHurt
  1166. end
  1167. --处理器
  1168. local function chixuHurtDel(target,buffer)
  1169. local hurt = buffer.arg
  1170. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1171. --持续类buff 伤害加成
  1172. local attacker = CombatImpl.objList[buffer.attackPos]
  1173. local conf = BufferExcel.buffer[buffer.id]
  1174. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1175. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1176. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1177. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1178. end
  1179. return hurt
  1180. end
  1181. --处理器, 实时计算伤害
  1182. local function chixuHurtDel2(target,buffer)
  1183. local id = buffer.id
  1184. local conf = BufferExcel.buffer[id]
  1185. local attackPos = buffer.attackPos
  1186. local attacker
  1187. if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
  1188. attacker = CombatImpl.helpList[attackPos]
  1189. else
  1190. attacker = CombatImpl.objList[attackPos]
  1191. end
  1192. local isAddHp = conf.cmd == "hp"
  1193. buffer.arg = CombatCalc.calcBufferHp(attacker,target,id,isAddHp)
  1194. local hurt = buffer.arg
  1195. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1196. --持续类buff 伤害加成
  1197. -- local attacker = CombatImpl.objList[buffer.attackPos]
  1198. -- local conf = BufferExcel.buffer[buffer.id]
  1199. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1200. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1201. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1202. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1203. end
  1204. return hurt
  1205. end
  1206. handler = {}
  1207. --持续伤害
  1208. function handler.hurt(target, buffer,conf)
  1209. local hurt = chixuHurtDel(target,buffer)
  1210. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1211. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1212. end
  1213. --燃烧
  1214. function handler.hurt1(target, buffer,conf)
  1215. local hurt = chixuHurtDel(target,buffer)
  1216. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1217. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1218. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1219. -- 删除attr1 buffer
  1220. local attacker = CombatImpl.objList[buffer.attackPos]
  1221. if attacker and attacker.bufferCmd["attr1"] then
  1222. for i = #attacker.bufferCmd["attr1"],1,-1 do
  1223. local ind = attacker.bufferCmd["attr1"][i]
  1224. local buff = attacker.buffer[ind]
  1225. local conf = BufferExcel.buffer[buff.id]
  1226. local bufferCnt = delBuffer(attacker, ind)
  1227. CombatImpl.addFrameBuffer(attacker, buff, CombatDefine.BUFFER_OP_DEL)
  1228. end
  1229. end
  1230. end
  1231. --持续治疗
  1232. function handler.hp(target, buffer,conf)
  1233. if target.bufferCmd["noHp"] then
  1234. return
  1235. end
  1236. if HANDLER_ONCE["hp"] == target.pos then
  1237. return
  1238. end
  1239. local hp = buffer.arg
  1240. local attacker = CombatImpl.objList[buffer.attackPos]
  1241. if attacker and attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1242. local hpAddRate = attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] / 10000
  1243. hp = hp * (1 + hpAddRate)
  1244. end
  1245. local calcType = conf and conf.args[1] or 0
  1246. if CombatCalc.NO_EXCALC_LIST[calcType] and target.attr[RoleDefine.HP_ADD_RATE] then
  1247. local hpAddRate = target.attr[RoleDefine.HP_ADD_RATE] / 10000
  1248. hp = hp * (1 + hpAddRate)
  1249. end
  1250. hp = hp < 0 and 1 or hp
  1251. if target.side == CombatDefine.DEFEND_SIDE then
  1252. hp = CombatImpl.commonArgs.hpLimit or hp
  1253. end
  1254. local d = CombatObj.updateHp(target, hp, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1255. buffer.attrs[RoleDefine.HP_COMBAT] = hp
  1256. HANDLER_ONCE["hp"] = target.pos
  1257. end
  1258. --流血
  1259. function handler.liuxue(target, buffer,conf)
  1260. local hurt = chixuHurtDel(target,buffer)
  1261. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1262. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1263. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1264. end
  1265. --流血2
  1266. function handler.liuxue2(target, buffer,conf)
  1267. local hurt = chixuHurtDel2(target,buffer)
  1268. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1269. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1270. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1271. end
  1272. --中毒
  1273. function handler.zhongdu(target, buffer,conf)
  1274. local hurt = chixuHurtDel(target,buffer)
  1275. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1276. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1277. onExtraCombatRecord(buffer.attackPos,hurt,"zhongdu")
  1278. end
  1279. --燃烧
  1280. function handler.ranshao(target, buffer,conf)
  1281. local hurt = chixuHurtDel(target,buffer)
  1282. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1283. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1284. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1285. end
  1286. --燃烧
  1287. function handler.ranshao1(target, buffer,conf)
  1288. local hurt = chixuHurtDel(target,buffer)
  1289. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1290. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1291. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1292. end
  1293. --回合印记
  1294. function handler.huiheYinji(target, buffer,conf)
  1295. if buffer.round > 1 then return end --最后一回合才生效
  1296. local hurt = chixuHurtDel(target,buffer)
  1297. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1298. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1299. end
  1300. --种子
  1301. function handler.zhongzi(target, buffer, conf)
  1302. if buffer.round > 1 then return end --最后一回合才生效
  1303. local cnt = #conf.args
  1304. for i= 1, cnt do
  1305. local bufferID = conf.args[i]
  1306. if canAdd(target,bufferID) then
  1307. addBuffer(buffer.attackPos, target, bufferID)
  1308. end
  1309. end
  1310. end
  1311. --buffer包处理器
  1312. --偷取护甲
  1313. function handler.touquhujia(attacker,target,conf)
  1314. local arg = conf.args[1]/10000
  1315. local targetBufferID = conf.args[2]
  1316. local attackerBufferID = conf.args[3]
  1317. local def = CombatObj.getValue(target,RoleDefine.DEF)
  1318. --local rate = CombatObj.getValue(target,RoleDefine.DEF_RATE)/10000
  1319. --def = def * (1 + rate)
  1320. def = def > 0 and def or 0
  1321. local arg = def * arg
  1322. if arg > 0 then
  1323. if canAdd(attacker,attackerBufferID) then
  1324. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1325. end
  1326. if canAdd(target,targetBufferID) then
  1327. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1328. end
  1329. end
  1330. end
  1331. --偷取攻击
  1332. function handler.touqugongji(attacker,target,conf)
  1333. local arg = conf.args[1]/10000
  1334. local targetBufferID = conf.args[2]
  1335. local attackerBufferID = conf.args[3]
  1336. local atk = CombatObj.getValue(target,RoleDefine.ATK)
  1337. --local rate = CombatObj.getValue(target,RoleDefine.ATK_RATE)/10000
  1338. --def = def * (1 + rate)
  1339. atk = atk > 0 and atk or 0
  1340. local arg = atk * arg
  1341. if arg > 0 then
  1342. if canAdd(attacker,attackerBufferID) then
  1343. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1344. end
  1345. if canAdd(target,targetBufferID) then
  1346. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1347. end
  1348. end
  1349. end
  1350. function handler.totem(obj,buffer,conf)
  1351. --图腾逻辑
  1352. local buffers = conf.args
  1353. for i = 1, #buffers do
  1354. local bufferID = buffers[i][1]
  1355. if type(bufferID) == "table" then
  1356. local r = math.random(1,#bufferID)
  1357. bufferID = bufferID[r]
  1358. end
  1359. local targetMode = buffers[i][2]
  1360. local random = buffers[i][3]
  1361. local targets = TargetMode.getTargets(obj, targetMode,{})
  1362. if #targets > 0 then
  1363. for _,target in ipairs(targets) do
  1364. if canAdd(target,bufferID,random) then
  1365. addBuffer(obj.pos,target, bufferID)
  1366. end
  1367. end
  1368. end
  1369. end
  1370. end
  1371. function handler.groupbuffer(attacker,target,conf)
  1372. for _,bufferID in ipairs(conf.args) do
  1373. if canAdd(target,bufferID) then
  1374. addBuffer(attacker.pos,target, bufferID,nil,nil,conf)
  1375. end
  1376. end
  1377. end
  1378. function handler.zuzhou(target,buffer,conf)
  1379. local hurt = buffer.arg[1]
  1380. local attacker = CombatImpl.objList[buffer.attackPos]
  1381. -- 二次元结算方式调整成
  1382. if BeSkill.getRandomBuffCmd(attacker, target, conf.cmd) and target.bufferCmd[conf.cmd] then
  1383. hurt = hurt * #target.bufferCmd[conf.cmd]
  1384. end
  1385. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1386. hurt = hurt * (1 + beSkillHurtRate)
  1387. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1388. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1389. BeSkill.handlerBuff(attacker, target, hurt, conf.cmd)
  1390. end
  1391. function yinbaoZuzhou(obj, skillTargets, skillConfig)
  1392. local newFrame = nil
  1393. for k,v in ipairs(skillTargets) do
  1394. if v.bufferCmd["zuzhou"] then
  1395. for i = #v.bufferCmd["zuzhou"],1,-1 do
  1396. local ind = v.bufferCmd["zuzhou"][i]
  1397. local buffer = v.buffer[ind]
  1398. local conf = BufferExcel.buffer[buffer.id]
  1399. if conf and handler[conf.cmd] then
  1400. handler[conf.cmd](v, buffer, conf)
  1401. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_HOLD)
  1402. end
  1403. local bufferCnt = delBuffer(v, ind)
  1404. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_DEL)
  1405. newFrame = true
  1406. end
  1407. end
  1408. end
  1409. -- 有引爆成功的
  1410. if newFrame and ProjectLogic.isSsecy() then
  1411. CombatImpl.addFrame()
  1412. end
  1413. end
  1414. --主动技能释放后buff作用
  1415. handlerEx = {}
  1416. --印记
  1417. function handlerEx.yinJi(target, buffer, conf)
  1418. local attacker = CombatImpl.objList[buffer.attackPos]
  1419. if attacker == nil then
  1420. return
  1421. end
  1422. local hurtRate = conf.args[1]
  1423. local hurtRateMax = conf.args[2]
  1424. local hpMax = CombatObj.getHpMax(target)
  1425. local hurt = hurtRate * hpMax / 10000
  1426. local atk = CombatObj.getValue(attacker,RoleDefine.ATK) * hurtRateMax / 10000
  1427. if hurt > atk then
  1428. hurt = atk
  1429. end
  1430. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1431. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1432. return true
  1433. end
  1434. function qingsuan(target)
  1435. if target.hp <= 0 then
  1436. return 0
  1437. end
  1438. local baseValue = 0
  1439. local round
  1440. for j = target.buffer[0], 1, -1 do
  1441. local buffer = target.buffer[j]
  1442. local conf = BufferExcel.buffer[buffer.id]
  1443. local cmd = conf.cmd
  1444. if cmd == "ranshao" or cmd == "ranshao1" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "hurt" or cmd == "hurt1" then
  1445. round = 1
  1446. if buffer.round and buffer.round > 0 then
  1447. round = buffer.round
  1448. end
  1449. baseValue = baseValue + buffer.arg * round
  1450. local bufferCnt = delBuffer(target, j)
  1451. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1452. end
  1453. end
  1454. return baseValue
  1455. end
  1456. --解控
  1457. function jiekong(target)
  1458. if target.hp <= 0 then
  1459. return 0
  1460. end
  1461. local baseValue = 0
  1462. local state = false
  1463. for j = target.buffer[0], 1, -1 do
  1464. local buffer = target.buffer[j]
  1465. local conf = BufferExcel.buffer[buffer.id]
  1466. local cmd = conf.cmd
  1467. if isControlCmd(cmd) then
  1468. local bufferCnt = delBuffer(target, j)
  1469. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1470. state = true
  1471. end
  1472. end
  1473. if state == true then
  1474. CombatImpl.setExtraHit(target,nil, Skill.getCMD2ID("jiekong"))
  1475. end
  1476. end
  1477. --杀意
  1478. function delShayi(target)
  1479. if target.hp <= 0 then
  1480. return 0
  1481. end
  1482. for j = target.buffer[0], 1, -1 do
  1483. local buffer = target.buffer[j]
  1484. local conf = BufferExcel.buffer[buffer.id]
  1485. local cmd = conf.cmd
  1486. if cmd == "shayi" then
  1487. local bufferCnt = delBuffer(target, j)
  1488. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1489. end
  1490. end
  1491. end
  1492. function getBuffCnt(target,checkCmd)
  1493. if target.hp <= 0 then
  1494. return 0
  1495. end
  1496. local cnt = 0
  1497. for j = target.buffer[0], 1, -1 do
  1498. local buffer = target.buffer[j]
  1499. local conf = BufferExcel.buffer[buffer.id]
  1500. local cmd = conf.cmd
  1501. if cmd == checkCmd then
  1502. cnt = cnt + 1
  1503. end
  1504. end
  1505. return cnt
  1506. end
  1507. -- 获取护盾值
  1508. function getBuffHuDun(obj)
  1509. if obj and obj.bufferAttr and obj.bufferAttr[RoleDefine.HUDUN_COMBAT] then
  1510. return obj.bufferAttr[RoleDefine.HUDUN_COMBAT]
  1511. end
  1512. return 0
  1513. end
  1514. -- 护盾值的修改
  1515. function updateHuDun(obj, value)
  1516. if obj and obj.bufferAttr then
  1517. local oldValue = obj.bufferAttr[RoleDefine.HUDUN_COMBAT] or 0
  1518. local newValue = oldValue + value
  1519. if newValue <= 0 then
  1520. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = 0
  1521. delBufferByCmd(obj,"hudun", 0)
  1522. else
  1523. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = newValue
  1524. end
  1525. -- 护盾值没有全部去除 则 在对应英雄上吧 BUF 上的arg 数值 减除 防止 BufChange 重置 属性
  1526. if value < 0 and newValue > 0 then
  1527. if obj and obj.buffer then
  1528. for j = 1 , obj.buffer[0] do -- 从最早的护盾BUF中删除arg
  1529. local buffer = obj.buffer[j]
  1530. local conf = BufferExcel.buffer[buffer.id]
  1531. local bufferCmd = conf.cmd
  1532. if bufferCmd == "hudun" then
  1533. local have = buffer.arg
  1534. if have > -value then
  1535. buffer.arg = have + value
  1536. else
  1537. buffer.arg = 0
  1538. local bufferCnt = delBuffer(obj, j)
  1539. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1540. break
  1541. end
  1542. end
  1543. end
  1544. end
  1545. end
  1546. end
  1547. end
  1548. BUFFER_COMBAT_TYPE = nil
  1549. function initCombatBufferType()
  1550. if BUFFER_COMBAT_TYPE then return end
  1551. BUFFER_COMBAT_TYPE = {}
  1552. for k,conf in pairs(BufferExcel.qusan) do
  1553. if conf then
  1554. BUFFER_COMBAT_TYPE[conf.buffcmd] = conf.type
  1555. end
  1556. end
  1557. end
  1558. --
  1559. function getCombatBufferCnt(target, qusanType)
  1560. initCombatBufferType()
  1561. local buffCnt = 0
  1562. for i = target.buffer[0], 1, -1 do
  1563. local buffer = target.buffer[i]
  1564. local conf = BufferExcel.buffer[buffer.id]
  1565. local cmd = conf.cmd
  1566. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  1567. buffCnt = buffCnt + 1
  1568. end
  1569. end
  1570. return buffCnt
  1571. end
  1572. --抵抗
  1573. QUSAN_CMD2KEY = {
  1574. ["zuzhou"] = RoleDefine.STATUS_DIKANG_RATE9,
  1575. }
  1576. function qusan(target, qusanType,cnt)
  1577. if target.isPet or not qusanType then
  1578. return 0
  1579. end
  1580. initCombatBufferType()
  1581. local state = false
  1582. local delIndex = {}
  1583. for i = target.buffer[0], 1, -1 do
  1584. local buffer = target.buffer[i]
  1585. local conf = BufferExcel.buffer[buffer.id]
  1586. local cmd = conf.cmd
  1587. if conf.noQusan ~= 1 then
  1588. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  1589. local isDiKang = nil
  1590. local key = QUSAN_CMD2KEY[cmd]
  1591. local r = math.random(1,10000)
  1592. if key and target.attr[key] >= r then
  1593. isDiKang = true
  1594. end
  1595. if not isDiKang then
  1596. delIndex[#delIndex + 1] = i
  1597. end
  1598. elseif cmd == "attr" or cmd == "attrdne" then
  1599. if conf.args and conf.args[1][2] < 0 and qusanType == 1 then
  1600. delIndex[#delIndex + 1] = i
  1601. elseif conf.args and conf.args[1][2] > 0 and qusanType == 2 then
  1602. delIndex[#delIndex + 1] = i
  1603. end
  1604. end
  1605. end
  1606. end
  1607. cnt = cnt or 0
  1608. if cnt > 0 and cnt < #delIndex then
  1609. for i = cnt + 1,#delIndex do
  1610. delIndex[i] = nil
  1611. end
  1612. end
  1613. for k,v in ipairs(delIndex) do
  1614. local buffer = target.buffer[v]
  1615. if not buffer then break end
  1616. local bufferCnt = delBuffer(target, v)
  1617. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1618. end
  1619. return #delIndex
  1620. end
  1621. function qusanAddBuff(attacker, targets, bufferID)
  1622. for _,target in ipairs(targets) do
  1623. if canAdd(target,bufferID) then
  1624. addBuffer(attacker.pos, target, bufferID)
  1625. end
  1626. end
  1627. end
  1628. function beforeUpdateHp(obj,sum)
  1629. local isStatus,cmd,ind = isStatus(obj,{"miansi","waitMiansi"})
  1630. if not isStatus then
  1631. return
  1632. end
  1633. --免死逻辑
  1634. if cmd == "miansi" then
  1635. return true
  1636. end
  1637. if sum == 0 and cmd == "waitMiansi" then
  1638. local buffer = obj.buffer[ind]
  1639. local bufferCnt = delBuffer(obj, ind)
  1640. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1641. local conf = BufferExcel.buffer[buffer.id]
  1642. local bufferID = conf.args[1]
  1643. if canAdd(obj,bufferID) then
  1644. addBuffer(obj.pos,obj, bufferID)
  1645. end
  1646. return true
  1647. end
  1648. end
  1649. function checkBaohu(obj,value)
  1650. local isStatus,cmd,ind = isStatus(obj,{"baohu"})
  1651. if not isStatus then
  1652. return value
  1653. end
  1654. local buffer = obj.buffer[ind]
  1655. local attackPos = buffer.attackPos
  1656. local attacker = CombatImpl.objList[attackPos]
  1657. if attacker.hp <= 0 then
  1658. return value
  1659. end
  1660. value = BeSkill.onCheckBuffer(attacker,obj,value)
  1661. return value
  1662. end
  1663. function onExtraCombatRecord(pos,value,param)
  1664. local obj = CombatObj.getObjByPos(pos)
  1665. if not obj then return end
  1666. obj.extraCombatRecord = obj.extraCombatRecord or {}
  1667. if param == "zhongdu" then
  1668. obj.extraCombatRecord.zhongdu = (obj.extraCombatRecord.zhongdu or 0) + value
  1669. elseif param == "liuxue" then
  1670. obj.extraCombatRecord.liuxue = (obj.extraCombatRecord.liuxue or 0) + value
  1671. elseif param == "ranshao" then
  1672. obj.extraCombatRecord.ranshao = (obj.extraCombatRecord.ranshao or 0) + value
  1673. elseif param == "xuanyun" then
  1674. obj.extraCombatRecord.xuanyun = (obj.extraCombatRecord.xuanyun or 0) + value
  1675. elseif param == "revive" then
  1676. obj.extraCombatRecord.revive = (obj.extraCombatRecord.revive or 0) + value
  1677. elseif param == "reviveBeUse" then
  1678. obj.extraCombatRecord.reviveBeUse = (obj.extraCombatRecord.reviveBeUse or 0) + value
  1679. elseif param == "kill" then
  1680. obj.extraCombatRecord.kill = (obj.extraCombatRecord.kill or 0) + value
  1681. end
  1682. end