CombatBuff.lua 62 KB

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