CombatBuff.lua 59 KB

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