CombatBuff.lua 57 KB

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