CombatBuff.lua 55 KB

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