CombatBuff.lua 62 KB

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