CombatBuff.lua 63 KB

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