CombatBuff.lua 62 KB

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