CombatBuff.lua 54 KB

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