CombatBuff.lua 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913
  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. -- 战斗回合开始时添加buffer
  782. function beforeCombat()
  783. end
  784. function getSkillBuffers(skillConfig)
  785. local randBuffCnt = skillConfig.otherArgs.randBuffCnt
  786. if not randBuffCnt then
  787. return skillConfig.buffers
  788. end
  789. local ret = {}
  790. local c = #skillConfig.buffers
  791. if randBuffCnt >= c then
  792. return skillConfig.buffers
  793. end
  794. for i = 1,c do
  795. ret[i] = skillConfig.buffers[i]
  796. end
  797. for i = 1,c do
  798. if i <= randBuffCnt then
  799. local r = math.random(i,c)
  800. ret[i],ret[r] = ret[r],ret[i]
  801. else
  802. ret[i] = nil
  803. end
  804. end
  805. return ret
  806. end
  807. -- 战斗回合中触发buffer
  808. function onHit(attacker, skillTargets, skillConfig, cmdTargets, otherArgs)
  809. -- 处理施法者身上的buff
  810. if skillConfig.type == CombatDefine.SKILL_TYPE2 and
  811. attacker.buffer ~= nil then
  812. delayBegin()
  813. for j = attacker.buffer[0], 1, -1 do
  814. local buffer = attacker.buffer[j]
  815. local conf = BufferExcel.buffer[buffer.id]
  816. buffer.attrs = { }
  817. if attacker.hp > 0 and handlerEx[conf.cmd] then
  818. if handlerEx[conf.cmd](attacker, buffer, conf) then
  819. CombatImpl.addFrameBuffer(attacker, buffer, CombatDefine.BUFFER_OP_HOLD)
  820. end
  821. end
  822. end
  823. delayEnd()
  824. end
  825. for k, v in ipairs(skillTargets) do
  826. if attacker.helpType == 0 and attacker.side ~= v.side then
  827. local fantanBufferInd = v.bufferCmd["fantan"] and v.bufferCmd["fantan"][1]
  828. local fantanBuffer = v.buffer[fantanBufferInd]
  829. if fantanBuffer then
  830. local conf = BufferExcel.buffer[fantanBuffer.id]
  831. -- 是否限制技能类型
  832. local bHit = false
  833. if conf.args[3] then
  834. if conf.args[3] == skillConfig.type then
  835. bHit = true
  836. end
  837. else
  838. bHit = true
  839. end
  840. if bHit then
  841. local hurt = CombatCalc.calcHp(attacker, v, conf.args[1], conf.args[2])
  842. local d = CombatObj.updateHp(attacker, - hurt, nil, nil, v.pos, CombatObj.BUFFER_HP_TYPE)
  843. CombatImpl.setExtraHit(attacker, d)
  844. CombatObj.onHpCB(attacker, d, v.pos)
  845. end
  846. end
  847. end
  848. -- 只能敌方攻击触发降低冰冻
  849. if not(otherArgs and otherArgs.noFirst) and skillConfig.hurtRate[1] then
  850. local bufferCmd = v.bufferCmd["bingdong"]
  851. if bufferCmd then
  852. local delList = { }
  853. for i = #bufferCmd, 1, -1 do
  854. local bingdongBuffer = v.buffer[bufferCmd[i]]
  855. local conf = BufferExcel.buffer[bingdongBuffer.id]
  856. bingdongBuffer.arg = bingdongBuffer.arg or 0
  857. bingdongBuffer.arg = bingdongBuffer.arg + 1
  858. if bingdongBuffer.arg >=(conf.args[1] or 0) then
  859. delList[#delList + 1] = bufferCmd[i]
  860. end
  861. end
  862. --冰冻buffer被打碎
  863. if #delList > 0 then
  864. local delBuffer = v.buffer[delList[1]]
  865. BeSkill.onDelBingDongBuffer(v, delBuffer)
  866. end
  867. for k1, v1 in ipairs(delList) do
  868. local buffer = v.buffer[v1]
  869. local bufferCnt = delBuffer(v, v1)
  870. CombatImpl.addFrameBuffer(v, buffer, CombatDefine.BUFFER_OP_DEL)
  871. end
  872. end
  873. end
  874. end
  875. local buffers = getSkillBuffers(skillConfig)
  876. local statusBuffRate = skillConfig.otherArgs.statusBuffRate
  877. for i = 1, #buffers do
  878. local bufferID = buffers[i][1]
  879. if type(bufferID) == "table" then
  880. local r = math.random(1, #bufferID)
  881. bufferID = bufferID[r]
  882. end
  883. local targetMode = buffers[i][2]
  884. local random = buffers[i][3]
  885. local bufferEx = buffers[i][4]
  886. local delayRound = buffers[i][5]
  887. if attacker.isPet and #skillConfig.bufferGrow > 0 then
  888. local growRate = 0
  889. local bufLv = attacker.lv
  890. if attacker.quality > 1 then
  891. bufLv = attacker.lv -(attacker.quality - 1) * 30
  892. end
  893. if skillConfig.bufferGrow and skillConfig.bufferGrow[i] then
  894. local gorwRat = skillConfig.bufferGrow[i][1]
  895. local growLv = skillConfig.bufferGrow[i][2]
  896. growRate = math.floor(bufLv / growLv) * gorwRat
  897. end
  898. random = random + growRate
  899. end
  900. local targets = TargetMode.getTargets(attacker, targetMode, skillTargets, cmdTargets, nil, nil, skillConfig.id)
  901. if #targets > 0 then
  902. local bufferConf = BufferExcel.buffer[bufferID]
  903. for _, target in ipairs(targets) do
  904. local r = random
  905. if statusBuffRate and bufferConf.cmd == statusBuffRate[1] and isStatus(target, statusBuffRate[2]) then
  906. r = r + statusBuffRate[3]
  907. end
  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. if bufferEx then
  936. local bufferID = bufferEx[1]
  937. local random = bufferEx[2]
  938. local delayRound = bufferEx[3]
  939. local bufferConf = BufferExcel.buffer[bufferID]
  940. for _, target in ipairs(targets) do
  941. local r = random
  942. if canAdd(target, bufferID, r, attacker, skillConfig) then
  943. local arg
  944. if bufferConf.cmd == "zuzhou" then
  945. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker, bufferID, bufferConf.cmd)
  946. arg = { CombatCalc.calcHp(attacker, target, bufferConf.args[1], rate) }
  947. end
  948. if bufferConf.cmd == "stealattr" then
  949. local value = CombatCalc.calcValue(attacker, target, bufferConf.args[1], bufferConf.args[2])
  950. arg = { { bufferConf.args[3], value } }
  951. end
  952. if bufferConf.cmd == "handleattr" then
  953. arg = { }
  954. if attacker.handleAttr then
  955. local value = attacker.handleAttr[2] *(bufferConf.args[1] / 10000)
  956. if target.side == attacker.side then
  957. arg = { { attacker.handleAttr[1], value * bufferConf.args[2] } }
  958. else
  959. arg = { { attacker.handleAttr[1], - value } }
  960. end
  961. end
  962. end
  963. if delayRound and delayRound > 0 then
  964. target.delayAddBuffer = target.delayAddBuffer or { }
  965. target.delayAddBuffer[#target.delayAddBuffer + 1] = { delayRound, attacker.pos, bufferID, skillConfig.id, arg }
  966. else
  967. addBuffer(attacker.pos, target, bufferID, skillConfig.id, arg)
  968. end
  969. end
  970. end
  971. end
  972. end
  973. end
  974. end
  975. end
  976. end
  977. local function getBeskillBuffers(attacker,skillConfig)
  978. if skillConfig.otherArgs.buffer then
  979. local checkArg = skillConfig.otherArgs.buffer
  980. local checkValue
  981. if checkArg.cmd == "hurtRate" then
  982. checkValue = -attacker.combatResult[1]
  983. elseif checkArg.cmd == "hpRate" then
  984. checkValue = attacker.combatResult[2]
  985. end
  986. if checkValue and checkValue > 0 then
  987. local hpMax = attacker.attr[RoleDefine.HP]
  988. local rate = (10000 * checkValue)/(hpMax * checkArg.param[1])
  989. if rate > 1 then
  990. local retArg = {}
  991. for k,v in ipairs(checkArg.param[2]) do
  992. retArg[#retArg + 1] = {v[1],math.floor(v[2] * rate)}
  993. end
  994. return skillConfig.buffers,retArg
  995. end
  996. end
  997. else
  998. return skillConfig.buffers
  999. end
  1000. end
  1001. function onUseBeSkill(attacker,skillConfig,objs,cmdTargets, arg)--attacker是被动技能释放者,objs是attacker的对立方(attacker是攻击者的话,objs是被攻击者,attacker是被攻击者的话,objs是攻击者),cmdTargets是额外作用对象
  1002. local buffers,bufferArg = getBeskillBuffers(attacker,skillConfig)
  1003. if not buffers then
  1004. return
  1005. end
  1006. bufferArg = bufferArg or arg
  1007. local isAddSkillFrame
  1008. local bufferArg1
  1009. for i = 1, #buffers do
  1010. local bufferID = buffers[i][1]
  1011. local bufferConf = BufferExcel.buffer[bufferID]
  1012. local targetMode = buffers[i][2]
  1013. local targets
  1014. bufferArg1 = nil
  1015. if targetMode[1] == 13 then
  1016. targets = objs
  1017. else
  1018. targets = TargetMode.getTargets(attacker, targetMode,objs,cmdTargets)
  1019. end
  1020. if #targets > 0 then
  1021. if bufferConf.cmd == "zuzhou" then
  1022. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker,bufferID)
  1023. bufferArg1 = {CombatCalc.calcHp(attacker,targets[1],bufferConf.args[1],rate)}
  1024. end
  1025. local attackPos = attacker.pos
  1026. if bufferConf.roundOne == 1 and objs and objs[1] then
  1027. attackPos = objs[1].pos
  1028. end
  1029. for _,target in ipairs(targets) do
  1030. if canAdd(target,bufferID,buffers[i][3], attacker, skillConfig) then
  1031. isAddSkillFrame = true
  1032. addBuffer(attackPos,target, bufferID,skillConfig.id,bufferArg1 or bufferArg)
  1033. end
  1034. end
  1035. end
  1036. end
  1037. return isAddSkillFrame
  1038. end
  1039. --战斗回合结束时处理buffer效果。删除失效buffer
  1040. --只执行一次的cmd,比如持续加血。
  1041. HANDLER_ONCE = HANDLER_ONCE or {}
  1042. function onRoundEnd(attacker,isRoundEnd)
  1043. --处理施法者身上的buff
  1044. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1045. local obj = CombatImpl.objList[i]
  1046. if obj then
  1047. for k,v in pairs(HANDLER_ONCE) do
  1048. HANDLER_ONCE[k] = nil
  1049. end
  1050. delayBegin()
  1051. for j = obj.buffer[0], 1, -1 do
  1052. local buffer = obj.buffer[j]
  1053. local conf = BufferExcel.buffer[buffer.id]
  1054. if conf.type == CombatDefine.BUFFER_TYPE1 or isRoundEnd then
  1055. buffer.attrs = {}
  1056. local setFrame = false
  1057. if conf.type ~= CombatDefine.BUFFER_TYPE4 and handler[conf.cmd] then
  1058. if obj.hp > 0 or conf.cmd == "totem" then
  1059. if conf.cmd == "zuzhou" then
  1060. -- 最后一回合生效
  1061. if buffer.round == 1 then
  1062. handler[conf.cmd](obj, buffer,conf)
  1063. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1064. end
  1065. else
  1066. handler[conf.cmd](obj, buffer,conf)
  1067. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1068. end
  1069. end
  1070. end
  1071. if buffer.round then
  1072. local cmd = conf.cmd
  1073. buffer.round = buffer.round - 1
  1074. if buffer.round < 1 then
  1075. local bufferCnt = delBuffer(obj, j)
  1076. if (conf.type ~= CombatDefine.BUFFER_TYPE1 and obj.hp > 0) or conf.cmd == "fixPos" or conf.holdOnDie == 1 then
  1077. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1078. end
  1079. end
  1080. end
  1081. end
  1082. end
  1083. if isRoundEnd and obj.delayAddBuffer then
  1084. --{delayRound,attacker.pos,bufferID,skillConfig.id,arg}
  1085. for k,v in ipairs(obj.delayAddBuffer) do
  1086. v[1] = v[1] - 1
  1087. end
  1088. local temp = {}
  1089. for i = 1,#obj.delayAddBuffer do
  1090. local data = obj.delayAddBuffer[i]
  1091. if data[1] > 0 then
  1092. temp[#temp + 1] = data
  1093. else
  1094. addBuffer(data[2],obj,data[3],data[4],data[5])
  1095. end
  1096. end
  1097. if #temp > 0 then
  1098. obj.delayAddBuffer = temp
  1099. else
  1100. obj.delayAddBuffer = nil
  1101. end
  1102. end
  1103. delayEnd()
  1104. end
  1105. end
  1106. for k,v in pairs(HANDLER_ONCE) do
  1107. HANDLER_ONCE[k] = nil
  1108. end
  1109. end
  1110. --攻击结束后,反击前,整合buffer前处理buffer效果
  1111. function beforeFanji()
  1112. local isFanshe = false
  1113. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1114. local obj = CombatImpl.objList[i]
  1115. if obj then
  1116. for k,v in pairs(obj.combatResult[3]) do
  1117. if k ~= i and v[1] and v[1] < 0 then
  1118. local target = CombatImpl.objList[k]
  1119. if target and target.hp > 0 then
  1120. local d = CombatObj.updateHp(target, v[1], nil, nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1121. CombatImpl.setExtraHit(target,d)
  1122. CombatObj.onHpCB(target,d, obj.pos)
  1123. isFanshe = true
  1124. end
  1125. end
  1126. end
  1127. if isFanshe then
  1128. delBufferByCmd(obj,"fansheZhuangjia",1)
  1129. end
  1130. end
  1131. end
  1132. end
  1133. function getExtraHurtRate(attacker,target,skillConfig)
  1134. local skillID = skillConfig.id
  1135. local isBaoji = target.isBaoji
  1136. local baojiHurtRate = 0
  1137. local guanxinzheHurtRate = 0
  1138. local huiheHurtRate = 0
  1139. local shandianHurtRate = 0
  1140. local attackerHurtRat = 0
  1141. local biaoshiHurtRate = 0
  1142. local biaoshiCnt = 0
  1143. local moweiHurtRate = 0
  1144. local biaoshiCntLimit
  1145. if skillConfig.otherArgs.biaoshiHurtRate then
  1146. biaoshiCntLimit = skillConfig.otherArgs.biaoshiHurtRate[1]
  1147. end
  1148. for j = target.buffer[0], 1, -1 do
  1149. local obj = target
  1150. local buffer = obj.buffer[j]
  1151. local conf = BufferExcel.buffer[buffer.id]
  1152. if conf.cmd == "guanxinzheYinji" then --观星者印记
  1153. guanxinzheHurtRate = guanxinzheHurtRate + conf.args[2]
  1154. elseif conf.cmd == "shandianYinji" then --闪电印记
  1155. for _,v in ipairs(conf.args[2]) do
  1156. if skillID == v then
  1157. shandianHurtRate = shandianHurtRate + conf.args[3]
  1158. break
  1159. end
  1160. end
  1161. elseif conf.cmd == "biaoshi" then
  1162. biaoshiCnt = biaoshiCnt + 1
  1163. end
  1164. end
  1165. --攻击者
  1166. for j = attacker.buffer[0], 1, -1 do
  1167. local obj = attacker
  1168. local buffer = obj.buffer[j]
  1169. local conf = BufferExcel.buffer[buffer.id]
  1170. if conf.cmd == "mowei" then --魔威
  1171. local nowHp = attacker.hp
  1172. local hpMax = CombatObj.getHpMax(attacker)
  1173. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1174. if percent >= 1 then
  1175. --moweiHurtRate = moweiHurtRate + (percent * conf.args[1])
  1176. moweiHurtRate = percent * conf.args[1]
  1177. break
  1178. end
  1179. end
  1180. end
  1181. guanxinzheHurtRate = guanxinzheHurtRate > 30000 and 30000 or guanxinzheHurtRate --300%限制
  1182. if biaoshiCntLimit and biaoshiCnt >= biaoshiCntLimit then
  1183. biaoshiHurtRate = skillConfig.otherArgs.biaoshiHurtRate[2]
  1184. end
  1185. local extraHurtRate = baojiHurtRate + guanxinzheHurtRate + huiheHurtRate + shandianHurtRate + attackerHurtRat + biaoshiHurtRate + moweiHurtRate
  1186. return extraHurtRate
  1187. end
  1188. function getExtraHurt(attacker, target, skillConfig)
  1189. local extraHurt = 0
  1190. for j = target.buffer[0], 1, -1 do
  1191. local obj = target
  1192. local buffer = obj.buffer[j]
  1193. local conf = BufferExcel.buffer[buffer.id]
  1194. if conf.cmd == "shenhuo" then
  1195. local hurt = CombatCalc.calcHp(attacker, target, conf.args[1], conf.args[2], true)
  1196. extraHurt = extraHurt + hurt
  1197. end
  1198. end
  1199. return extraHurt
  1200. end
  1201. --处理器
  1202. local function chixuHurtDel(target,buffer)
  1203. local hurt = buffer.arg
  1204. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1205. --持续类buff 伤害加成
  1206. local attacker = CombatImpl.objList[buffer.attackPos]
  1207. local conf = BufferExcel.buffer[buffer.id]
  1208. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1209. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1210. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1211. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1212. end
  1213. return hurt
  1214. end
  1215. --处理器, 实时计算伤害
  1216. local function chixuHurtDel2(target,buffer)
  1217. local id = buffer.id
  1218. local conf = BufferExcel.buffer[id]
  1219. local attackPos = buffer.attackPos
  1220. local attacker
  1221. if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
  1222. attacker = CombatImpl.helpList[attackPos]
  1223. else
  1224. attacker = CombatImpl.objList[attackPos]
  1225. end
  1226. local isAddHp = conf.cmd == "hp"
  1227. buffer.arg = CombatCalc.calcBufferHp(attacker,target,id,isAddHp)
  1228. local hurt = buffer.arg
  1229. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1230. --持续类buff 伤害加成
  1231. -- local attacker = CombatImpl.objList[buffer.attackPos]
  1232. -- local conf = BufferExcel.buffer[buffer.id]
  1233. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1234. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1235. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1236. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1237. end
  1238. return hurt
  1239. end
  1240. handler = {}
  1241. --持续伤害
  1242. function handler.hurt(target, buffer,conf)
  1243. local hurt = chixuHurtDel(target,buffer)
  1244. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1245. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1246. end
  1247. --燃烧
  1248. function handler.hurt1(target, buffer,conf)
  1249. local hurt = chixuHurtDel(target,buffer)
  1250. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1251. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1252. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1253. -- 删除attr1 buffer
  1254. local attacker = CombatImpl.objList[buffer.attackPos]
  1255. if attacker and attacker.bufferCmd["attr1"] then
  1256. for i = #attacker.bufferCmd["attr1"],1,-1 do
  1257. local ind = attacker.bufferCmd["attr1"][i]
  1258. local buff = attacker.buffer[ind]
  1259. local conf = BufferExcel.buffer[buff.id]
  1260. local bufferCnt = delBuffer(attacker, ind)
  1261. CombatImpl.addFrameBuffer(attacker, buff, CombatDefine.BUFFER_OP_DEL)
  1262. end
  1263. end
  1264. end
  1265. --持续治疗
  1266. function handler.hp(target, buffer,conf)
  1267. if target.bufferCmd["noHp"] then
  1268. return
  1269. end
  1270. if HANDLER_ONCE["hp"] == target.pos then
  1271. return
  1272. end
  1273. local hp = buffer.arg
  1274. local attacker = CombatImpl.objList[buffer.attackPos]
  1275. if attacker and attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1276. local hpAddRate = attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] / 10000
  1277. hp = hp * (1 + hpAddRate)
  1278. end
  1279. local calcType = conf and conf.args[1] or 0
  1280. if CombatCalc.NO_EXCALC_LIST[calcType] and target.attr[RoleDefine.HP_ADD_RATE] then
  1281. local hpAddRate = target.attr[RoleDefine.HP_ADD_RATE] / 10000
  1282. hp = hp * (1 + hpAddRate)
  1283. end
  1284. hp = hp < 0 and 1 or hp
  1285. if target.side == CombatDefine.DEFEND_SIDE then
  1286. hp = CombatImpl.commonArgs.hpLimit or hp
  1287. end
  1288. local d = CombatObj.updateHp(target, hp, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1289. buffer.attrs[RoleDefine.HP_COMBAT] = hp
  1290. HANDLER_ONCE["hp"] = target.pos
  1291. end
  1292. --流血
  1293. function handler.liuxue(target, buffer,conf)
  1294. local hurt = chixuHurtDel(target,buffer)
  1295. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1296. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1297. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1298. end
  1299. --流血2
  1300. function handler.liuxue2(target, buffer,conf)
  1301. local hurt = chixuHurtDel2(target,buffer)
  1302. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1303. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1304. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1305. end
  1306. --中毒
  1307. function handler.zhongdu(target, buffer,conf)
  1308. local hurt = chixuHurtDel(target,buffer)
  1309. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1310. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1311. onExtraCombatRecord(buffer.attackPos,hurt,"zhongdu")
  1312. end
  1313. --燃烧
  1314. function handler.ranshao(target, buffer,conf)
  1315. local hurt = chixuHurtDel(target,buffer)
  1316. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1317. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1318. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1319. end
  1320. --燃烧
  1321. function handler.ranshao1(target, buffer,conf)
  1322. local hurt = chixuHurtDel(target,buffer)
  1323. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1324. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1325. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1326. end
  1327. --回合印记
  1328. function handler.huiheYinji(target, buffer,conf)
  1329. if buffer.round > 1 then return end --最后一回合才生效
  1330. local hurt = chixuHurtDel(target,buffer)
  1331. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1332. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1333. end
  1334. --种子
  1335. function handler.zhongzi(target, buffer, conf)
  1336. if buffer.round > 1 then return end --最后一回合才生效
  1337. local cnt = #conf.args
  1338. for i= 1, cnt do
  1339. local bufferID = conf.args[i]
  1340. if canAdd(target,bufferID) then
  1341. addBuffer(buffer.attackPos, target, bufferID)
  1342. end
  1343. end
  1344. end
  1345. --buffer包处理器
  1346. --偷取护甲
  1347. function handler.touquhujia(attacker,target,conf)
  1348. local arg = conf.args[1]/10000
  1349. local targetBufferID = conf.args[2]
  1350. local attackerBufferID = conf.args[3]
  1351. local def = CombatObj.getValue(target,RoleDefine.DEF)
  1352. --local rate = CombatObj.getValue(target,RoleDefine.DEF_RATE)/10000
  1353. --def = def * (1 + rate)
  1354. def = def > 0 and def or 0
  1355. local arg = def * arg
  1356. if arg > 0 then
  1357. if canAdd(attacker,attackerBufferID) then
  1358. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1359. end
  1360. if canAdd(target,targetBufferID) then
  1361. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1362. end
  1363. end
  1364. end
  1365. --偷取攻击
  1366. function handler.touqugongji(attacker,target,conf)
  1367. local arg = conf.args[1]/10000
  1368. local targetBufferID = conf.args[2]
  1369. local attackerBufferID = conf.args[3]
  1370. local atk = CombatObj.getValue(target,RoleDefine.ATK)
  1371. --local rate = CombatObj.getValue(target,RoleDefine.ATK_RATE)/10000
  1372. --def = def * (1 + rate)
  1373. atk = atk > 0 and atk or 0
  1374. local arg = atk * arg
  1375. if arg > 0 then
  1376. if canAdd(attacker,attackerBufferID) then
  1377. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1378. end
  1379. if canAdd(target,targetBufferID) then
  1380. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1381. end
  1382. end
  1383. end
  1384. function handler.totem(obj,buffer,conf)
  1385. --图腾逻辑
  1386. local buffers = conf.args
  1387. for i = 1, #buffers do
  1388. local bufferID = buffers[i][1]
  1389. if type(bufferID) == "table" then
  1390. local r = math.random(1,#bufferID)
  1391. bufferID = bufferID[r]
  1392. end
  1393. local targetMode = buffers[i][2]
  1394. local random = buffers[i][3]
  1395. local targets = TargetMode.getTargets(obj, targetMode,{})
  1396. if #targets > 0 then
  1397. for _,target in ipairs(targets) do
  1398. if canAdd(target,bufferID,random) then
  1399. addBuffer(obj.pos,target, bufferID)
  1400. end
  1401. end
  1402. end
  1403. end
  1404. end
  1405. function handler.groupbuffer(attacker,target,conf)
  1406. for _,bufferID in ipairs(conf.args) do
  1407. if canAdd(target,bufferID) then
  1408. addBuffer(attacker.pos,target, bufferID,nil,nil,conf)
  1409. end
  1410. end
  1411. end
  1412. function handler.zuzhou(target,buffer,conf)
  1413. local hurt = buffer.arg[1]
  1414. local attacker = CombatImpl.objList[buffer.attackPos]
  1415. -- 二次元结算方式调整成
  1416. if BeSkill.getRandomBuffCmd(attacker, target, conf.cmd) and target.bufferCmd[conf.cmd] then
  1417. hurt = hurt * #target.bufferCmd[conf.cmd]
  1418. end
  1419. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1420. hurt = hurt * (1 + beSkillHurtRate)
  1421. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1422. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1423. BeSkill.handlerBuff(attacker, target, hurt, conf.cmd)
  1424. end
  1425. function yinbaoZuzhou(obj, skillTargets, skillConfig)
  1426. local newFrame = nil
  1427. for k,v in ipairs(skillTargets) do
  1428. if v.bufferCmd["zuzhou"] then
  1429. for i = #v.bufferCmd["zuzhou"],1,-1 do
  1430. local ind = v.bufferCmd["zuzhou"][i]
  1431. local buffer = v.buffer[ind]
  1432. local conf = BufferExcel.buffer[buffer.id]
  1433. if conf and handler[conf.cmd] then
  1434. handler[conf.cmd](v, buffer, conf)
  1435. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_HOLD)
  1436. end
  1437. local bufferCnt = delBuffer(v, ind)
  1438. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_DEL)
  1439. newFrame = true
  1440. end
  1441. end
  1442. end
  1443. -- 有引爆成功的
  1444. if newFrame and ProjectLogic.isSsecy() then
  1445. CombatImpl.addFrame()
  1446. end
  1447. end
  1448. --主动技能释放后buff作用
  1449. handlerEx = {}
  1450. --印记
  1451. function handlerEx.yinJi(target, buffer, conf)
  1452. local attacker = CombatImpl.objList[buffer.attackPos]
  1453. if attacker == nil then
  1454. return
  1455. end
  1456. local hurtRate = conf.args[1]
  1457. local hurtRateMax = conf.args[2]
  1458. local hpMax = CombatObj.getHpMax(target)
  1459. local hurt = hurtRate * hpMax / 10000
  1460. local atk = CombatObj.getValue(attacker,RoleDefine.ATK) * hurtRateMax / 10000
  1461. if hurt > atk then
  1462. hurt = atk
  1463. end
  1464. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1465. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1466. return true
  1467. end
  1468. function qingsuan(target)
  1469. if target.hp <= 0 then
  1470. return 0
  1471. end
  1472. local baseValue = 0
  1473. local round
  1474. for j = target.buffer[0], 1, -1 do
  1475. local buffer = target.buffer[j]
  1476. local conf = BufferExcel.buffer[buffer.id]
  1477. local cmd = conf.cmd
  1478. if cmd == "ranshao" or cmd == "ranshao1" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "hurt" or cmd == "hurt1" then
  1479. round = 1
  1480. if buffer.round and buffer.round > 0 then
  1481. round = buffer.round
  1482. end
  1483. baseValue = baseValue + buffer.arg * round
  1484. local bufferCnt = delBuffer(target, j)
  1485. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1486. end
  1487. end
  1488. return baseValue
  1489. end
  1490. --解控
  1491. function jiekong(target)
  1492. if target.hp <= 0 then
  1493. return 0
  1494. end
  1495. local baseValue = 0
  1496. local state = false
  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 isControlCmd(cmd) then
  1502. local bufferCnt = delBuffer(target, j)
  1503. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1504. state = true
  1505. end
  1506. end
  1507. if state == true then
  1508. CombatImpl.setExtraHit(target,nil, Skill.getCMD2ID("jiekong"))
  1509. end
  1510. end
  1511. --杀意
  1512. function delShayi(target)
  1513. if target.hp <= 0 then
  1514. return 0
  1515. end
  1516. for j = target.buffer[0], 1, -1 do
  1517. local buffer = target.buffer[j]
  1518. local conf = BufferExcel.buffer[buffer.id]
  1519. local cmd = conf.cmd
  1520. if cmd == "shayi" then
  1521. local bufferCnt = delBuffer(target, j)
  1522. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1523. end
  1524. end
  1525. end
  1526. function getBuffCnt(target,checkCmd)
  1527. if target.hp <= 0 then
  1528. return 0
  1529. end
  1530. local cnt = 0
  1531. for j = target.buffer[0], 1, -1 do
  1532. local buffer = target.buffer[j]
  1533. local conf = BufferExcel.buffer[buffer.id]
  1534. local cmd = conf.cmd
  1535. if cmd == checkCmd then
  1536. cnt = cnt + 1
  1537. end
  1538. end
  1539. return cnt
  1540. end
  1541. -- 获取护盾值
  1542. function getBuffHuDun(obj)
  1543. if obj and obj.bufferAttr and obj.bufferAttr[RoleDefine.HUDUN_COMBAT] then
  1544. return obj.bufferAttr[RoleDefine.HUDUN_COMBAT]
  1545. end
  1546. return 0
  1547. end
  1548. -- 护盾值的修改
  1549. function updateHuDun(obj, value)
  1550. if obj and obj.bufferAttr then
  1551. local oldValue = obj.bufferAttr[RoleDefine.HUDUN_COMBAT] or 0
  1552. local newValue = oldValue + value
  1553. if newValue <= 0 then
  1554. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = 0
  1555. delBufferByCmd(obj,"hudun", 0)
  1556. else
  1557. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = newValue
  1558. end
  1559. -- 护盾值没有全部去除 则 在对应英雄上吧 BUF 上的arg 数值 减除 防止 BufChange 重置 属性
  1560. if value < 0 and newValue > 0 then
  1561. if obj and obj.buffer then
  1562. for j = 1 , obj.buffer[0] do -- 从最早的护盾BUF中删除arg
  1563. local buffer = obj.buffer[j]
  1564. local conf = BufferExcel.buffer[buffer.id]
  1565. local bufferCmd = conf.cmd
  1566. if bufferCmd == "hudun" then
  1567. local have = buffer.arg
  1568. if have > -value then
  1569. buffer.arg = have + value
  1570. else
  1571. buffer.arg = 0
  1572. local bufferCnt = delBuffer(obj, j)
  1573. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1574. break
  1575. end
  1576. end
  1577. end
  1578. end
  1579. end
  1580. end
  1581. end
  1582. BUFFER_COMBAT_TYPE = nil
  1583. function initCombatBufferType()
  1584. if BUFFER_COMBAT_TYPE then return end
  1585. BUFFER_COMBAT_TYPE = {}
  1586. for k,conf in pairs(BufferExcel.qusan) do
  1587. if conf then
  1588. BUFFER_COMBAT_TYPE[conf.buffcmd] = conf.type
  1589. end
  1590. end
  1591. end
  1592. --
  1593. function getCombatBufferCnt(target, qusanType)
  1594. initCombatBufferType()
  1595. local buffCnt = 0
  1596. for i = target.buffer[0], 1, -1 do
  1597. local buffer = target.buffer[i]
  1598. local conf = BufferExcel.buffer[buffer.id]
  1599. local cmd = conf.cmd
  1600. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  1601. buffCnt = buffCnt + 1
  1602. end
  1603. end
  1604. return buffCnt
  1605. end
  1606. --抵抗
  1607. QUSAN_CMD2KEY = {
  1608. ["zuzhou"] = RoleDefine.STATUS_DIKANG_RATE9,
  1609. }
  1610. function qusan(target, qusanType,cnt)
  1611. if target.isPet or not qusanType then
  1612. return 0
  1613. end
  1614. initCombatBufferType()
  1615. local state = false
  1616. local delIndex = {}
  1617. for i = target.buffer[0], 1, -1 do
  1618. local buffer = target.buffer[i]
  1619. local conf = BufferExcel.buffer[buffer.id]
  1620. local cmd = conf.cmd
  1621. if conf.noQusan ~= 1 then
  1622. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  1623. local isDiKang = nil
  1624. local key = QUSAN_CMD2KEY[cmd]
  1625. local r = math.random(1,10000)
  1626. if key and target.attr[key] >= r then
  1627. isDiKang = true
  1628. end
  1629. if not isDiKang then
  1630. delIndex[#delIndex + 1] = i
  1631. end
  1632. elseif cmd == "attr" or cmd == "attrdne" then
  1633. if conf.args and conf.args[1][2] < 0 and qusanType == 1 then
  1634. delIndex[#delIndex + 1] = i
  1635. elseif conf.args and conf.args[1][2] > 0 and qusanType == 2 then
  1636. delIndex[#delIndex + 1] = i
  1637. end
  1638. end
  1639. end
  1640. end
  1641. cnt = cnt or 0
  1642. if cnt > 0 and cnt < #delIndex then
  1643. for i = cnt + 1,#delIndex do
  1644. delIndex[i] = nil
  1645. end
  1646. end
  1647. for k,v in ipairs(delIndex) do
  1648. local buffer = target.buffer[v]
  1649. if not buffer then break end
  1650. local bufferCnt = delBuffer(target, v)
  1651. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1652. end
  1653. return #delIndex
  1654. end
  1655. function qusanAddBuff(attacker, targets, bufferID)
  1656. for _,target in ipairs(targets) do
  1657. if canAdd(target,bufferID) then
  1658. addBuffer(attacker.pos, target, bufferID)
  1659. end
  1660. end
  1661. end
  1662. function beforeUpdateHp(obj,sum)
  1663. local isStatus,cmd,ind = isStatus(obj,{"miansi","waitMiansi"})
  1664. if not isStatus then
  1665. return
  1666. end
  1667. --免死逻辑
  1668. if cmd == "miansi" then
  1669. return true
  1670. end
  1671. if sum == 0 and cmd == "waitMiansi" then
  1672. local buffer = obj.buffer[ind]
  1673. local bufferCnt = delBuffer(obj, ind)
  1674. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1675. local conf = BufferExcel.buffer[buffer.id]
  1676. local bufferID = conf.args[1]
  1677. if canAdd(obj,bufferID) then
  1678. addBuffer(obj.pos,obj, bufferID)
  1679. end
  1680. return true
  1681. end
  1682. end
  1683. function checkBaohu(obj,value)
  1684. local isStatus,cmd,ind = isStatus(obj,{"baohu"})
  1685. if not isStatus then
  1686. return value
  1687. end
  1688. local buffer = obj.buffer[ind]
  1689. local attackPos = buffer.attackPos
  1690. local attacker = CombatImpl.objList[attackPos]
  1691. if attacker.hp <= 0 then
  1692. return value
  1693. end
  1694. value = BeSkill.onCheckBuffer(attacker,obj,value)
  1695. return value
  1696. end
  1697. function onExtraCombatRecord(pos,value,param)
  1698. local obj = CombatObj.getObjByPos(pos)
  1699. if not obj then return end
  1700. obj.extraCombatRecord = obj.extraCombatRecord or {}
  1701. if param == "zhongdu" then
  1702. obj.extraCombatRecord.zhongdu = (obj.extraCombatRecord.zhongdu or 0) + value
  1703. elseif param == "liuxue" then
  1704. obj.extraCombatRecord.liuxue = (obj.extraCombatRecord.liuxue or 0) + value
  1705. elseif param == "ranshao" then
  1706. obj.extraCombatRecord.ranshao = (obj.extraCombatRecord.ranshao or 0) + value
  1707. elseif param == "xuanyun" then
  1708. obj.extraCombatRecord.xuanyun = (obj.extraCombatRecord.xuanyun or 0) + value
  1709. elseif param == "revive" then
  1710. obj.extraCombatRecord.revive = (obj.extraCombatRecord.revive or 0) + value
  1711. elseif param == "reviveBeUse" then
  1712. obj.extraCombatRecord.reviveBeUse = (obj.extraCombatRecord.reviveBeUse or 0) + value
  1713. elseif param == "kill" then
  1714. obj.extraCombatRecord.kill = (obj.extraCombatRecord.kill or 0) + value
  1715. end
  1716. end