CombatBuff.lua 72 KB

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