CombatBuff.lua 56 KB

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