CombatBuff.lua 70 KB

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