CombatBuff.lua 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068
  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 winnerID = obj and obj.relic and obj.relic.relicID or 0
  622. local winnerStar = obj and obj.relic and obj.relic.star or 0
  623. -- local conf = BufferExcel.buffer[id]
  624. local conf = GetBuffConfig(id)
  625. local bufferCmd = conf.cmd
  626. if DELAY_BUFF_OP then
  627. if not NO_DELAY_BUFFCMD[bufferCmd] then
  628. DELAY_LIST.add[#DELAY_LIST.add + 1] = {attackPos,obj, id, skillID,arg,parentConf}
  629. end
  630. return
  631. end
  632. if checkRevive(attackPos,obj, id, skillID) then
  633. return
  634. end
  635. if beforeAddBuffer(attackPos,obj, id, skillID,arg,parentConf) then
  636. return
  637. end
  638. local bufferCnt = 1
  639. local index
  640. local buffer
  641. local bufferCmdInd
  642. local bufferInd
  643. local tround = 0
  644. local index = 0
  645. local groupCnt = 0
  646. local group = conf.group[1]
  647. for i = 1, obj.buffer[0] do
  648. buffer = obj.buffer[i]
  649. if buffer.id == id then
  650. bufferCnt = bufferCnt + 1
  651. bufferInd = i
  652. if tround > buffer.round or tround == 0 then
  653. tround = buffer.round
  654. index = i
  655. end
  656. end
  657. --local nowBuffConf = BufferExcel.buffer[buffer.id]
  658. local nowBuffConf = GetBuffConfig(buffer.id)
  659. if nowBuffConf.cmd == bufferCmd then
  660. bufferCmdInd = i
  661. end
  662. if group and group == nowBuffConf.group[1] then
  663. groupCnt = groupCnt + 1
  664. end
  665. end
  666. local groupCmd = conf.group[2]
  667. if groupCmd and groupCnt > 0 and groupCnt >= groupCmd then
  668. return
  669. end
  670. if bufferCnt > 100 then
  671. return
  672. end
  673. local canAppend = parentConf and parentConf.canAppend or conf.canAppend
  674. local round = parentConf and parentConf.round or conf.round
  675. round = round == 0 and 1 or round
  676. if canAppend == 1 then
  677. local appendCnt = conf.appendCnt or 0
  678. if appendCnt > 0 and bufferCnt > conf.appendCnt then
  679. if conf.type == CombatDefine.BUFFER_TYPE2 then
  680. buffer = obj.buffer[index]
  681. buffer.round = round
  682. --bingdong清除buffer参数
  683. if conf.cmd == "bingdong" then
  684. buffer.arg = nil
  685. end
  686. CombatImpl.onAddBuffer(id)
  687. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_ADD,0)
  688. return
  689. end
  690. return
  691. end
  692. else
  693. if bufferCnt > 1 then
  694. if conf.type == CombatDefine.BUFFER_TYPE2 then
  695. buffer = obj.buffer[bufferInd]
  696. buffer.round = round
  697. --bingdong清除buffer参数
  698. if conf.cmd == "bingdong" then
  699. buffer.arg = nil
  700. end
  701. CombatImpl.onAddBuffer(id)
  702. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_ADD,0)
  703. return
  704. end
  705. return
  706. end
  707. end
  708. if isControlCmd(bufferCmd) and bufferCmdInd then
  709. buffer = obj.buffer[bufferCmdInd]
  710. if buffer.round < round then
  711. buffer.round = round
  712. end
  713. if conf.cmd == "bingdong" then
  714. buffer.arg = nil
  715. end
  716. return
  717. end
  718. obj.buffer[0] = obj.buffer[0] + 1
  719. index = obj.buffer[0]
  720. buffer = obj.buffer[index]
  721. if not buffer then
  722. obj.buffer[index] = {}
  723. buffer = obj.buffer[index]
  724. end
  725. buffer.id = id
  726. buffer.round = nil -- 剩余回合
  727. buffer.attrs = nil
  728. buffer.attackPos = nil
  729. buffer.skillID = nil
  730. buffer.cnt = 1
  731. buffer.arg = nil
  732. if round then
  733. buffer.round = round
  734. elseif conf.type == CombatDefine.BUFFER_TYPE1 then
  735. buffer.round = 1
  736. elseif conf.type == CombatDefine.BUFFER_TYPE2 then
  737. buffer.round = round
  738. elseif conf.type == CombatDefine.BUFFER_TYPE3 then
  739. buffer.round = nil
  740. else
  741. assert()
  742. end
  743. local attacker
  744. if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
  745. attacker = CombatImpl.helpList[attackPos]
  746. else
  747. attacker = CombatImpl.objList[attackPos]
  748. end
  749. if arg then
  750. buffer.arg = arg
  751. elseif isHpCmd(conf.cmd) then
  752. local isAddHp = conf.cmd == "hp"
  753. buffer.arg = CombatCalc.calcBufferHp(attacker,obj,id,isAddHp)
  754. end
  755. buffer.attackPos = attackPos
  756. buffer.skillID = skillID
  757. buffer.attrs = {}
  758. if bufferCmd == "shengling" then
  759. buffer.arg = conf.args[3]
  760. elseif bufferCmd == "hudun" then
  761. local attackerHp = CombatCalc.calcHp(attacker, obj, conf.args[1], conf.args[2], true)
  762. local hudunValue = math.floor(conf.args[2] * attackerHp / 10000)
  763. buffer.arg = hudunValue
  764. end
  765. onBufferChange(obj)
  766. if conf.isAddCmd == 1 and handler[conf.cmd] then
  767. handler[conf.cmd](obj,buffer,conf)
  768. HANDLER_ONCE[conf.cmd] = nil
  769. end
  770. if conf.type ~= CombatDefine.BUFFER_TYPE1 then
  771. CombatImpl.onAddBuffer(id)
  772. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_ADD)
  773. end
  774. BeSkill.onAddBuffer(obj,buffer)
  775. onExtraCombatRecord(attackPos,1,bufferCmd)
  776. return buffer
  777. end
  778. local function delBufferByTotem(obj,totemId)
  779. for j = obj.buffer[0], 1, -1 do
  780. local buffer = obj.buffer[j]
  781. --local conf = BufferExcel.buffer[buffer.id]
  782. local conf = GetBuffConfig(buffer.id)
  783. if bufferCmd ~= "totem" and buffer.totem == totemId then
  784. delBuffer(obj,j)
  785. end
  786. end
  787. end
  788. local function beforeDelBuffer(obj, buffer)
  789. --local conf = BufferExcel.buffer[buffer.id]
  790. local conf = GetBuffConfig(buffer.id)
  791. if conf.cmd == "fentan" and buffer.round < 1 then
  792. local hurt = CombatCalc.calcHp(obj, obj, conf.args[1], conf.args[2])
  793. if hurt > 0 then
  794. local d = CombatObj.updateHp(obj, hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  795. CombatImpl.setExtraHit(obj, hurt)
  796. CombatObj.onHpCB(obj, d, obj.pos)
  797. end
  798. end
  799. end
  800. function delBuffer(obj, ind)
  801. if not obj.buffer[ind] then
  802. return
  803. end
  804. if DELAY_BUFF_OP then
  805. for k,v in ipairs(DELAY_LIST.del) do
  806. if v[2] == ind then
  807. return
  808. end
  809. end
  810. DELAY_LIST.del[#DELAY_LIST.del + 1] = {obj, ind}
  811. return
  812. end
  813. local id = obj.buffer[ind].id
  814. beforeDelBuffer(obj,obj.buffer[ind])
  815. obj.buffer[ind] = obj.buffer[obj.buffer[0]]
  816. obj.buffer[obj.buffer[0]] = nil
  817. obj.buffer[0] = obj.buffer[0] - 1
  818. onBufferChange(obj)
  819. local bufferCnt = 0
  820. for i = 1, obj.buffer[0] do
  821. local buffer = obj.buffer[i]
  822. if buffer.id == id then
  823. bufferCnt = bufferCnt + 1
  824. end
  825. end
  826. return bufferCnt
  827. end
  828. --通过buff的cmd删除一定数量的buff
  829. function DelBuffByCmd(obj, cmd, cnt)
  830. delBufferByCmd(obj, cmd, cnt)
  831. end
  832. -- 战斗回合开始时添加buffer
  833. function beforeCombat()
  834. end
  835. function getSkillBuffers(skillConfig)
  836. local randBuffCnt = skillConfig.otherArgs.randBuffCnt
  837. if not randBuffCnt then
  838. return skillConfig.buffers
  839. end
  840. local ret = {}
  841. local c = #skillConfig.buffers
  842. if randBuffCnt >= c then
  843. return skillConfig.buffers
  844. end
  845. for i = 1,c do
  846. ret[i] = skillConfig.buffers[i]
  847. end
  848. for i = 1,c do
  849. if i <= randBuffCnt then
  850. local r = math.random(i,c)
  851. ret[i],ret[r] = ret[r],ret[i]
  852. else
  853. ret[i] = nil
  854. end
  855. end
  856. return ret
  857. end
  858. -- 战斗回合中触发buffer
  859. function onHit(attacker, skillTargets, skillConfig, cmdTargets, otherArgs)
  860. -- 处理施法者身上的buff
  861. if skillConfig.type == CombatDefine.SKILL_TYPE2 and
  862. attacker.buffer ~= nil then
  863. delayBegin()
  864. for j = attacker.buffer[0], 1, -1 do
  865. local buffer = attacker.buffer[j]
  866. --local conf = BufferExcel.buffer[buffer.id]
  867. local conf = GetBuffConfig(buffer.id)
  868. buffer.attrs = { }
  869. if attacker.hp > 0 and handlerEx[conf.cmd] then
  870. if handlerEx[conf.cmd](attacker, buffer, conf) then
  871. CombatImpl.addFrameBuffer(attacker, buffer, CombatDefine.BUFFER_OP_HOLD)
  872. end
  873. end
  874. end
  875. delayEnd()
  876. end
  877. for k, v in ipairs(skillTargets) do
  878. if attacker.helpType == 0 and attacker.side ~= v.side then
  879. local fantanBufferInd = v.bufferCmd["fantan"] and v.bufferCmd["fantan"][1]
  880. local fantanBuffer = v.buffer[fantanBufferInd]
  881. if fantanBuffer then
  882. --local conf = BufferExcel.buffer[fantanBuffer.id]
  883. local conf = GetBuffConfig(fantanBuffer.id)
  884. -- 是否限制技能类型
  885. local bHit = false
  886. if conf.args[3] then
  887. if conf.args[3] == skillConfig.type then
  888. bHit = true
  889. end
  890. else
  891. bHit = true
  892. end
  893. if bHit then
  894. local hurt = CombatCalc.calcHp(attacker, v, conf.args[1], conf.args[2])
  895. local d = CombatObj.updateHp(attacker, - hurt, nil, nil, v.pos, CombatObj.BUFFER_HP_TYPE)
  896. CombatImpl.setExtraHit(attacker, d)
  897. CombatObj.onHpCB(attacker, d, v.pos)
  898. end
  899. end
  900. end
  901. -- 只能敌方攻击触发降低冰冻
  902. if not(otherArgs and otherArgs.noFirst) and skillConfig.hurtRate[1] then
  903. local bufferCmd = v.bufferCmd["bingdong"]
  904. if bufferCmd then
  905. local delList = { }
  906. for i = #bufferCmd, 1, -1 do
  907. local bingdongBuffer = v.buffer[bufferCmd[i]]
  908. --local conf = BufferExcel.buffer[bingdongBuffer.id]
  909. local conf = GetBuffConfig(bingdongBuffer.id)
  910. bingdongBuffer.arg = bingdongBuffer.arg or 0
  911. bingdongBuffer.arg = bingdongBuffer.arg + 1
  912. if bingdongBuffer.arg >=(conf.args[1] or 0) then
  913. delList[#delList + 1] = bufferCmd[i]
  914. end
  915. end
  916. --冰冻buffer被打碎
  917. if #delList > 0 then
  918. local delBuffer = v.buffer[delList[1]]
  919. BeSkill.onDelBingDongBuffer(v, delBuffer)
  920. end
  921. for k1, v1 in ipairs(delList) do
  922. local buffer = v.buffer[v1]
  923. local bufferCnt = delBuffer(v, v1)
  924. CombatImpl.addFrameBuffer(v, buffer, CombatDefine.BUFFER_OP_DEL)
  925. end
  926. end
  927. end
  928. end
  929. local buffers = getSkillBuffers(skillConfig)
  930. local statusBuffRate = skillConfig.otherArgs.statusBuffRate
  931. local jobRateAdd = skillConfig.otherArgs.jobRateAdd
  932. for i = 1, #buffers do
  933. local bufferID = buffers[i][1]
  934. if type(bufferID) == "table" then
  935. local r = math.random(1, #bufferID)
  936. bufferID = bufferID[r]
  937. end
  938. local targetMode = buffers[i][2]
  939. local random = buffers[i][3]
  940. local bufferEx = buffers[i][4]
  941. local delayRound = buffers[i][5]
  942. if attacker.isPet and #skillConfig.bufferGrow > 0 then
  943. local growRate = 0
  944. local bufLv = attacker.lv
  945. if attacker.quality > 1 then
  946. bufLv = attacker.lv -(attacker.quality - 1) * 30
  947. end
  948. if skillConfig.bufferGrow and skillConfig.bufferGrow[i] then
  949. local gorwRat = skillConfig.bufferGrow[i][1]
  950. local growLv = skillConfig.bufferGrow[i][2]
  951. growRate = math.floor(bufLv / growLv) * gorwRat
  952. end
  953. random = random + growRate
  954. end
  955. local targets = TargetMode.getTargets(attacker, targetMode, skillTargets, cmdTargets, nil, nil, skillConfig.id)
  956. if #targets > 0 then
  957. --local bufferConf = BufferExcel.buffer[bufferID]
  958. local bufferConf = GetBuffConfig(bufferID)
  959. for _, target in ipairs(targets) do
  960. local r = random
  961. if statusBuffRate and bufferConf.cmd == statusBuffRate[1] and isStatus(target, statusBuffRate[2]) then
  962. r = r + statusBuffRate[3]
  963. end
  964. if jobRateAdd and bufferConf.cmd == jobRateAdd[1] and isJob(target, jobRateAdd[2]) then
  965. r = r + jobRateAdd[3]
  966. end
  967. if canAdd(target, bufferID, r, attacker, skillConfig) then
  968. local arg
  969. if bufferConf.cmd == "zuzhou" then
  970. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker, bufferID, bufferConf.cmd)
  971. arg = { CombatCalc.calcHp(attacker, target, bufferConf.args[1], rate) }
  972. end
  973. if bufferConf.cmd == "stealattr" then
  974. local value = CombatCalc.calcValue(attacker, target, bufferConf.args[1], bufferConf.args[2])
  975. arg = { { bufferConf.args[3], value } }
  976. end
  977. if bufferConf.cmd == "handleattr" then
  978. arg = { }
  979. if attacker.handleAttr then
  980. local value = attacker.handleAttr[2] *(bufferConf.args[1] / 10000)
  981. if target.side == attacker.side then
  982. arg = { { attacker.handleAttr[1], value * bufferConf.args[2] } }
  983. else
  984. arg = { { attacker.handleAttr[1], - value } }
  985. end
  986. end
  987. end
  988. if delayRound and delayRound > 0 then
  989. target.delayAddBuffer = target.delayAddBuffer or { }
  990. target.delayAddBuffer[#target.delayAddBuffer + 1] = { delayRound, attacker.pos, bufferID, skillConfig.id, arg }
  991. else
  992. addBuffer(attacker.pos, target, bufferID, skillConfig.id, arg)
  993. end
  994. if bufferEx then
  995. local bufferID = bufferEx[1]
  996. local random = bufferEx[2]
  997. local delayRound = bufferEx[3]
  998. --local bufferConf = BufferExcel.buffer[bufferID]
  999. local bufferConf = GetBuffConfig(bufferID)
  1000. for _, target in ipairs(targets) do
  1001. local r = random
  1002. if canAdd(target, bufferID, r, attacker, skillConfig) then
  1003. local arg
  1004. if bufferConf.cmd == "zuzhou" then
  1005. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker, bufferID, bufferConf.cmd)
  1006. arg = { CombatCalc.calcHp(attacker, target, bufferConf.args[1], rate) }
  1007. end
  1008. if bufferConf.cmd == "stealattr" then
  1009. local value = CombatCalc.calcValue(attacker, target, bufferConf.args[1], bufferConf.args[2])
  1010. arg = { { bufferConf.args[3], value } }
  1011. end
  1012. if bufferConf.cmd == "handleattr" then
  1013. arg = { }
  1014. if attacker.handleAttr then
  1015. local value = attacker.handleAttr[2] *(bufferConf.args[1] / 10000)
  1016. if target.side == attacker.side then
  1017. arg = { { attacker.handleAttr[1], value * bufferConf.args[2] } }
  1018. else
  1019. arg = { { attacker.handleAttr[1], - value } }
  1020. end
  1021. end
  1022. end
  1023. if delayRound and delayRound > 0 then
  1024. target.delayAddBuffer = target.delayAddBuffer or { }
  1025. target.delayAddBuffer[#target.delayAddBuffer + 1] = { delayRound, attacker.pos, bufferID, skillConfig.id, arg }
  1026. else
  1027. addBuffer(attacker.pos, target, bufferID, skillConfig.id, arg)
  1028. end
  1029. end
  1030. end
  1031. end
  1032. end
  1033. end
  1034. end
  1035. end
  1036. end
  1037. local function getBeskillBuffers(attacker,skillConfig)
  1038. if skillConfig.otherArgs.buffer then
  1039. local checkArg = skillConfig.otherArgs.buffer
  1040. local checkValue
  1041. if checkArg.cmd == "hurtRate" then
  1042. checkValue = -attacker.combatResult[1]
  1043. elseif checkArg.cmd == "hpRate" then
  1044. checkValue = attacker.combatResult[2]
  1045. end
  1046. if checkValue and checkValue > 0 then
  1047. local hpMax = attacker.attr[RoleDefine.HP]
  1048. local rate = (10000 * checkValue)/(hpMax * checkArg.param[1])
  1049. if rate > 1 then
  1050. local retArg = {}
  1051. for k,v in ipairs(checkArg.param[2]) do
  1052. retArg[#retArg + 1] = {v[1],math.floor(v[2] * rate)}
  1053. end
  1054. return skillConfig.buffers,retArg
  1055. end
  1056. end
  1057. else
  1058. return skillConfig.buffers
  1059. end
  1060. end
  1061. function onUseBeSkill(attacker,skillConfig,objs,cmdTargets, arg)--attacker是被动技能释放者,objs是attacker的对立方(attacker是攻击者的话,objs是被攻击者,attacker是被攻击者的话,objs是攻击者),cmdTargets是额外作用对象
  1062. -- 使用被动技能时,需要特殊处理遗物的args和otherArgs
  1063. local winnerID = attacker and attacker.relic and attacker.relic.relicID or 0
  1064. local winnerStar = attacker and attacker.relic and attacker.relic.star or 0
  1065. local buffers,bufferArg = getBeskillBuffers(attacker,skillConfig)
  1066. if not buffers then
  1067. -- print("[onUseBeSkill] 获取不到配置直接返回 id = "..skillConfig[1])
  1068. return
  1069. end
  1070. bufferArg = bufferArg or arg
  1071. local isAddSkillFrame
  1072. local bufferArg1
  1073. for i = 1, #buffers do
  1074. local bufferID = buffers[i][1]
  1075. --local bufferConf = BufferExcel.buffer[bufferID]
  1076. local bufferConf = GetBuffConfig(bufferID)
  1077. local targetMode = buffers[i][2]
  1078. local targets
  1079. bufferArg1 = nil
  1080. if targetMode[1] == 13 then
  1081. targets = objs
  1082. else
  1083. targets = TargetMode.getTargets(attacker, targetMode,objs,cmdTargets)
  1084. end
  1085. if #targets > 0 then
  1086. if bufferConf.cmd == "zuzhou" then
  1087. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker,bufferID)
  1088. bufferArg1 = {CombatCalc.calcHp(attacker,targets[1],bufferConf.args[1],rate)}
  1089. end
  1090. local attackPos = attacker.pos
  1091. if bufferConf.roundOne == 1 and objs and objs[1] then
  1092. attackPos = objs[1].pos
  1093. end
  1094. for _,target in ipairs(targets) do
  1095. -- print("[onUseBeSkill]进入加buff判断",skillConfig.id, bufferID)
  1096. if canAdd(target,bufferID,buffers[i][3], attacker, skillConfig) then
  1097. -- print("[onUseBeSkill] buff判断条件成功,开始加buff",skillConfig.id, bufferID)
  1098. isAddSkillFrame = true
  1099. addBuffer(attackPos,target, bufferID,skillConfig.id,bufferArg1 or bufferArg)
  1100. end
  1101. end
  1102. end
  1103. end
  1104. -- if skillConfig.cmd == "winnerRelicSkill" then
  1105. -- if skillConfig and skillConfig.otherArgs.selefDefense then
  1106. -- if attacker then
  1107. -- print("[onUseBeSkill] winnerRelicSkill 进入 1")
  1108. -- attacker.attr[RoleDefine.DEF] = 0
  1109. -- end
  1110. -- elseif skillConfig and skillConfig.otherArgs.jobDefense then
  1111. -- if isJob(attacker, {CombatDefine.JOB_TYPE4, CombatDefine.JOB_TYPE1}) then
  1112. -- if winnerID > 0 and winnerStar > 0 then
  1113. -- print("[onUseBeSkill] winnerRelicSkill 进入 2")
  1114. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1115. -- attacker.attr[RoleDefine.DEF] = attacker.attr[RoleDefine.DEF] + extraRate
  1116. -- print("当前防御提升量为:",extraRate)
  1117. -- end
  1118. -- end
  1119. -- elseif skillConfig and skillConfig.otherArgs.jobMianshang then
  1120. -- if isJob(attacker, {CombatDefine.JOB_TYPE1}) then
  1121. -- print("[onUseBeSkill] winnerRelicSkill 进入 3")
  1122. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateDef(winnerID, winnerStar)
  1123. -- attacker.attr[RoleDefine.JIANSHANG_RATE] = attacker.attr[RoleDefine.JIANSHANG_RATE] *(1 + extraRate/100)
  1124. -- print("当前护卫免伤量提升量为:",extraRate)
  1125. -- end
  1126. -- elseif skillConfig and skillConfig.otherArgs.racialAtk then
  1127. -- if isCamp(attacker, {CombatDefine.COMBAT_TYPE27}) then
  1128. -- print("[onUseBeSkill] winnerRelicSkill 进入 4")
  1129. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1130. -- attacker.attr[RoleDefine.ATK] = attacker.attr[RoleDefine.ATK] *(1+ extraRate/100)
  1131. -- end
  1132. -- elseif skillConfig and skillConfig.otherArgs.jobZhiliao then
  1133. -- if isJob(attacker, {CombatDefine.JOB_TYPE4}) then
  1134. -- print("[onUseBeSkill] winnerRelicSkill 进入 5")
  1135. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1136. -- attacker.attr[RoleDefine.HP_ADD_RATE] = attacker.attr[RoleDefine.HP_ADD_RATE] *(1 + extraRate/100)
  1137. -- end
  1138. -- end
  1139. -- end
  1140. return isAddSkillFrame
  1141. end
  1142. --战斗回合结束时处理buffer效果。删除失效buffer
  1143. --只执行一次的cmd,比如持续加血。
  1144. HANDLER_ONCE = HANDLER_ONCE or {}
  1145. function onRoundEnd(attacker,isRoundEnd)
  1146. --处理施法者身上的buff
  1147. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1148. local obj = CombatImpl.objList[i]
  1149. if obj then
  1150. for k,v in pairs(HANDLER_ONCE) do
  1151. HANDLER_ONCE[k] = nil
  1152. end
  1153. delayBegin()
  1154. for j = obj.buffer[0], 1, -1 do
  1155. local buffer = obj.buffer[j]
  1156. --local conf = BufferExcel.buffer[buffer.id]
  1157. local conf = GetBuffConfig(buffer.id)
  1158. if conf.type == CombatDefine.BUFFER_TYPE1 or isRoundEnd then
  1159. buffer.attrs = {}
  1160. local setFrame = false
  1161. if conf.type ~= CombatDefine.BUFFER_TYPE4 and handler[conf.cmd] then
  1162. if obj.hp > 0 or conf.cmd == "totem" then
  1163. if conf.cmd == "zuzhou" then
  1164. -- 最后一回合生效
  1165. if buffer.round == 1 then
  1166. handler[conf.cmd](obj, buffer,conf)
  1167. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1168. end
  1169. else
  1170. handler[conf.cmd](obj, buffer,conf)
  1171. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1172. end
  1173. end
  1174. end
  1175. if buffer.round then
  1176. local cmd = conf.cmd
  1177. buffer.round = buffer.round - 1
  1178. if buffer.round < 1 then
  1179. local bufferCnt = delBuffer(obj, j)
  1180. if (conf.type ~= CombatDefine.BUFFER_TYPE1 and obj.hp > 0) or conf.cmd == "fixPos" or conf.holdOnDie == 1 then
  1181. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1182. end
  1183. end
  1184. end
  1185. end
  1186. end
  1187. if isRoundEnd and obj.delayAddBuffer then
  1188. --{delayRound,attacker.pos,bufferID,skillConfig.id,arg}
  1189. for k,v in ipairs(obj.delayAddBuffer) do
  1190. v[1] = v[1] - 1
  1191. end
  1192. local temp = {}
  1193. for i = 1,#obj.delayAddBuffer do
  1194. local data = obj.delayAddBuffer[i]
  1195. if data[1] > 0 then
  1196. temp[#temp + 1] = data
  1197. else
  1198. addBuffer(data[2],obj,data[3],data[4],data[5])
  1199. end
  1200. end
  1201. if #temp > 0 then
  1202. obj.delayAddBuffer = temp
  1203. else
  1204. obj.delayAddBuffer = nil
  1205. end
  1206. end
  1207. delayEnd()
  1208. end
  1209. end
  1210. for k,v in pairs(HANDLER_ONCE) do
  1211. HANDLER_ONCE[k] = nil
  1212. end
  1213. end
  1214. --攻击结束后,反击前,整合buffer前处理buffer效果
  1215. function beforeFanji()
  1216. local isFanshe = false
  1217. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1218. local obj = CombatImpl.objList[i]
  1219. if obj then
  1220. for k,v in pairs(obj.combatResult[3]) do
  1221. if k ~= i and v[1] and v[1] < 0 then
  1222. local target = CombatImpl.objList[k]
  1223. if target and target.hp > 0 then
  1224. local d = CombatObj.updateHp(target, v[1], nil, nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1225. CombatImpl.setExtraHit(target,d)
  1226. CombatObj.onHpCB(target,d, obj.pos)
  1227. isFanshe = true
  1228. end
  1229. end
  1230. end
  1231. if isFanshe then
  1232. delBufferByCmd(obj,"fansheZhuangjia",1)
  1233. end
  1234. end
  1235. end
  1236. end
  1237. function getExtraHurtRate(attacker,target,skillConfig)
  1238. local skillID = skillConfig.id
  1239. local isBaoji = target.isBaoji
  1240. local baojiHurtRate = 0
  1241. local guanxinzheHurtRate = 0
  1242. local huiheHurtRate = 0
  1243. local shandianHurtRate = 0
  1244. local attackerHurtRat = 0
  1245. local biaoshiHurtRate = 0
  1246. local biaoshiCnt = 0
  1247. local moweiHurtRate = 0
  1248. local biaoshiCntLimit
  1249. local zhanyiHurtRate = 0
  1250. if skillConfig.otherArgs.biaoshiHurtRate then
  1251. biaoshiCntLimit = skillConfig.otherArgs.biaoshiHurtRate[1]
  1252. end
  1253. for j = target.buffer[0], 1, -1 do
  1254. local obj = target
  1255. local buffer = obj.buffer[j]
  1256. --local conf = BufferExcel.buffer[buffer.id]
  1257. local conf = GetBuffConfig(buffer.id)
  1258. if conf.cmd == "guanxinzheYinji" then --观星者印记
  1259. guanxinzheHurtRate = guanxinzheHurtRate + conf.args[2]
  1260. elseif conf.cmd == "shandianYinji" then --闪电印记
  1261. for _,v in ipairs(conf.args[2]) do
  1262. if skillID == v then
  1263. shandianHurtRate = shandianHurtRate + conf.args[3]
  1264. break
  1265. end
  1266. end
  1267. elseif conf.cmd == "biaoshi" then
  1268. biaoshiCnt = biaoshiCnt + 1
  1269. end
  1270. end
  1271. --攻击者
  1272. for j = attacker.buffer[0], 1, -1 do
  1273. local obj = attacker
  1274. local buffer = obj.buffer[j]
  1275. --local conf = BufferExcel.buffer[buffer.id]
  1276. local conf = GetBuffConfig(buffer.id)
  1277. if conf.cmd == "mowei" then --魔威
  1278. local nowHp = attacker.hp
  1279. local hpMax = CombatObj.getHpMax(attacker)
  1280. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1281. if percent >= 1 then
  1282. --moweiHurtRate = moweiHurtRate + (percent * conf.args[1])
  1283. moweiHurtRate = percent * conf.args[1]
  1284. break
  1285. end
  1286. elseif conf.cmd == "zhanyi" 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. local args = conf.args
  1292. percent = percent / (args[1] / 100)
  1293. zhanyiHurtRate = percent * args[2]
  1294. break
  1295. end
  1296. end
  1297. end
  1298. guanxinzheHurtRate = guanxinzheHurtRate > 30000 and 30000 or guanxinzheHurtRate --300%限制
  1299. if biaoshiCntLimit and biaoshiCnt >= biaoshiCntLimit then
  1300. biaoshiHurtRate = skillConfig.otherArgs.biaoshiHurtRate[2]
  1301. end
  1302. local extraHurtRate = baojiHurtRate + guanxinzheHurtRate + huiheHurtRate + shandianHurtRate + attackerHurtRat + biaoshiHurtRate + moweiHurtRate + zhanyiHurtRate
  1303. return extraHurtRate
  1304. end
  1305. function getExtraHurt(attacker, target, skillConfig)
  1306. local extraHurt = 0
  1307. for j = target.buffer[0], 1, -1 do
  1308. local obj = target
  1309. local buffer = obj.buffer[j]
  1310. --local conf = BufferExcel.buffer[buffer.id]
  1311. local conf = GetBuffConfig(buffer.id)
  1312. if conf.cmd == "shenhuo" then
  1313. local hurt = CombatCalc.calcHp(attacker, target, conf.args[1], conf.args[2], true)
  1314. extraHurt = extraHurt + hurt
  1315. end
  1316. end
  1317. return extraHurt
  1318. end
  1319. --处理器
  1320. local function chixuHurtDel(target,buffer)
  1321. local hurt = buffer.arg
  1322. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1323. --持续类buff 伤害加成
  1324. local attacker = CombatImpl.objList[buffer.attackPos]
  1325. --local conf = BufferExcel.buffer[buffer.id]
  1326. local conf = GetBuffConfig(buffer.id)
  1327. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1328. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1329. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1330. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1331. end
  1332. return hurt
  1333. end
  1334. --处理器, 实时计算伤害
  1335. local function chixuHurtDel2(target,buffer)
  1336. local id = buffer.id
  1337. --local conf = BufferExcel.buffer[id]
  1338. local conf = GetBuffConfig(buffer.id)
  1339. local attackPos = buffer.attackPos
  1340. local attacker
  1341. if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
  1342. attacker = CombatImpl.helpList[attackPos]
  1343. else
  1344. attacker = CombatImpl.objList[attackPos]
  1345. end
  1346. local isAddHp = conf.cmd == "hp"
  1347. buffer.arg = CombatCalc.calcBufferHp(attacker,target,id,isAddHp)
  1348. local hurt = buffer.arg
  1349. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1350. --持续类buff 伤害加成
  1351. -- local attacker = CombatImpl.objList[buffer.attackPos]
  1352. -- local conf = BufferExcel.buffer[buffer.id]
  1353. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1354. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1355. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1356. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1357. end
  1358. return hurt
  1359. end
  1360. handler = {}
  1361. --持续伤害
  1362. function handler.hurt(target, buffer,conf)
  1363. local hurt = chixuHurtDel(target,buffer)
  1364. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1365. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1366. end
  1367. --燃烧
  1368. function handler.hurt1(target, buffer,conf)
  1369. local hurt = chixuHurtDel(target,buffer)
  1370. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1371. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1372. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1373. -- 删除attr1 buffer
  1374. local attacker = CombatImpl.objList[buffer.attackPos]
  1375. if attacker and attacker.bufferCmd["attr1"] then
  1376. for i = #attacker.bufferCmd["attr1"],1,-1 do
  1377. local ind = attacker.bufferCmd["attr1"][i]
  1378. local buff = attacker.buffer[ind]
  1379. --local conf = BufferExcel.buffer[buff.id]
  1380. local conf = GetBuffConfig(buffer.id)
  1381. local bufferCnt = delBuffer(attacker, ind)
  1382. CombatImpl.addFrameBuffer(attacker, buff, CombatDefine.BUFFER_OP_DEL)
  1383. end
  1384. end
  1385. end
  1386. --持续治疗
  1387. function handler.hp(target, buffer,conf)
  1388. if target.bufferCmd["noHp"] then
  1389. return
  1390. end
  1391. if HANDLER_ONCE["hp"] == target.pos then
  1392. return
  1393. end
  1394. local hp = buffer.arg
  1395. local attacker = CombatImpl.objList[buffer.attackPos]
  1396. if attacker and attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1397. local hpAddRate = attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] / 10000
  1398. hp = hp * (1 + hpAddRate)
  1399. end
  1400. local calcType = conf and conf.args[1] or 0
  1401. if CombatCalc.NO_EXCALC_LIST[calcType] and target.attr[RoleDefine.HP_ADD_RATE] then
  1402. local hpAddRate = target.attr[RoleDefine.HP_ADD_RATE] / 10000
  1403. hp = hp * (1 + hpAddRate)
  1404. end
  1405. hp = hp < 0 and 1 or hp
  1406. if target.side == CombatDefine.DEFEND_SIDE then
  1407. hp = CombatImpl.commonArgs.hpLimit or hp
  1408. end
  1409. local d = CombatObj.updateHp(target, hp, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1410. buffer.attrs[RoleDefine.HP_COMBAT] = hp
  1411. HANDLER_ONCE["hp"] = target.pos
  1412. end
  1413. --流血
  1414. function handler.liuxue(target, buffer,conf)
  1415. local hurt = chixuHurtDel(target,buffer)
  1416. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1417. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1418. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1419. end
  1420. --流血2
  1421. function handler.liuxue2(target, buffer,conf)
  1422. local hurt = chixuHurtDel2(target,buffer)
  1423. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1424. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1425. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1426. end
  1427. --中毒
  1428. function handler.zhongdu(target, buffer,conf)
  1429. local hurt = chixuHurtDel(target,buffer)
  1430. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1431. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1432. onExtraCombatRecord(buffer.attackPos,hurt,"zhongdu")
  1433. end
  1434. --燃烧
  1435. function handler.ranshao(target, buffer,conf)
  1436. local hurt = chixuHurtDel(target,buffer)
  1437. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1438. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1439. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1440. end
  1441. --燃烧
  1442. function handler.ranshao1(target, buffer,conf)
  1443. local hurt = chixuHurtDel(target,buffer)
  1444. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1445. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1446. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1447. end
  1448. --回合印记
  1449. function handler.huiheYinji(target, buffer,conf)
  1450. if buffer.round > 1 then return end --最后一回合才生效
  1451. local hurt = chixuHurtDel(target,buffer)
  1452. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1453. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1454. end
  1455. --种子
  1456. function handler.zhongzi(target, buffer, conf)
  1457. if buffer.round > 1 then return end --最后一回合才生效
  1458. local cnt = #conf.args
  1459. for i= 1, cnt do
  1460. local bufferID = conf.args[i]
  1461. if canAdd(target,bufferID) then
  1462. addBuffer(buffer.attackPos, target, bufferID)
  1463. end
  1464. end
  1465. end
  1466. --buffer包处理器
  1467. --偷取护甲
  1468. function handler.touquhujia(attacker,target,conf)
  1469. local arg = conf.args[1]/10000
  1470. local targetBufferID = conf.args[2]
  1471. local attackerBufferID = conf.args[3]
  1472. local def = CombatObj.getValue(target,RoleDefine.DEF)
  1473. --local rate = CombatObj.getValue(target,RoleDefine.DEF_RATE)/10000
  1474. --def = def * (1 + rate)
  1475. def = def > 0 and def or 0
  1476. local arg = def * arg
  1477. if arg > 0 then
  1478. if canAdd(attacker,attackerBufferID) then
  1479. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1480. end
  1481. if canAdd(target,targetBufferID) then
  1482. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1483. end
  1484. end
  1485. end
  1486. --偷取攻击
  1487. function handler.touqugongji(attacker,target,conf)
  1488. local arg = conf.args[1]/10000
  1489. local targetBufferID = conf.args[2]
  1490. local attackerBufferID = conf.args[3]
  1491. local atk = CombatObj.getValue(target,RoleDefine.ATK)
  1492. --local rate = CombatObj.getValue(target,RoleDefine.ATK_RATE)/10000
  1493. --def = def * (1 + rate)
  1494. atk = atk > 0 and atk or 0
  1495. local arg = atk * arg
  1496. if arg > 0 then
  1497. if canAdd(attacker,attackerBufferID) then
  1498. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1499. end
  1500. if canAdd(target,targetBufferID) then
  1501. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1502. end
  1503. end
  1504. end
  1505. function handler.totem(obj,buffer,conf)
  1506. --图腾逻辑
  1507. local buffers = conf.args
  1508. for i = 1, #buffers do
  1509. local bufferID = buffers[i][1]
  1510. if type(bufferID) == "table" then
  1511. local r = math.random(1,#bufferID)
  1512. bufferID = bufferID[r]
  1513. end
  1514. local targetMode = buffers[i][2]
  1515. local random = buffers[i][3]
  1516. local targets = TargetMode.getTargets(obj, targetMode,{})
  1517. if #targets > 0 then
  1518. for _,target in ipairs(targets) do
  1519. if canAdd(target,bufferID,random) then
  1520. addBuffer(obj.pos,target, bufferID)
  1521. end
  1522. end
  1523. end
  1524. end
  1525. end
  1526. function handler.groupbuffer(attacker,target,conf)
  1527. for _,bufferID in ipairs(conf.args) do
  1528. if canAdd(target,bufferID) then
  1529. addBuffer(attacker.pos,target, bufferID,nil,nil,conf)
  1530. end
  1531. end
  1532. end
  1533. function handler.zuzhou(target,buffer,conf)
  1534. local hurt = buffer.arg[1]
  1535. local attacker = CombatImpl.objList[buffer.attackPos]
  1536. -- 二次元结算方式调整成
  1537. if BeSkill.getRandomBuffCmd(attacker, target, conf.cmd) and target.bufferCmd[conf.cmd] then
  1538. hurt = hurt * #target.bufferCmd[conf.cmd]
  1539. end
  1540. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1541. hurt = hurt * (1 + beSkillHurtRate)
  1542. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1543. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1544. BeSkill.handlerBuff(attacker, target, hurt, conf.cmd)
  1545. end
  1546. function yinbaoZuzhou(obj, skillTargets, skillConfig)
  1547. local newFrame = nil
  1548. for k,v in ipairs(skillTargets) do
  1549. if v.bufferCmd["zuzhou"] then
  1550. for i = #v.bufferCmd["zuzhou"],1,-1 do
  1551. local ind = v.bufferCmd["zuzhou"][i]
  1552. local buffer = v.buffer[ind]
  1553. --local conf = BufferExcel.buffer[buffer.id]
  1554. local conf = GetBuffConfig(buffer.id)
  1555. if conf and handler[conf.cmd] then
  1556. handler[conf.cmd](v, buffer, conf)
  1557. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_HOLD)
  1558. end
  1559. local bufferCnt = delBuffer(v, ind)
  1560. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_DEL)
  1561. newFrame = true
  1562. end
  1563. end
  1564. end
  1565. -- 有引爆成功的
  1566. if newFrame and ProjectLogic.isSsecy() then
  1567. CombatImpl.addFrame()
  1568. end
  1569. end
  1570. --主动技能释放后buff作用
  1571. handlerEx = {}
  1572. --印记
  1573. function handlerEx.yinJi(target, buffer, conf)
  1574. local attacker = CombatImpl.objList[buffer.attackPos]
  1575. if attacker == nil then
  1576. return
  1577. end
  1578. local hurtRate = conf.args[1]
  1579. local hurtRateMax = conf.args[2]
  1580. local hpMax = CombatObj.getHpMax(target)
  1581. local hurt = hurtRate * hpMax / 10000
  1582. local atk = CombatObj.getValue(attacker,RoleDefine.ATK) * hurtRateMax / 10000
  1583. if hurt > atk then
  1584. hurt = atk
  1585. end
  1586. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1587. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1588. return true
  1589. end
  1590. function qingsuan(target)
  1591. if target.hp <= 0 then
  1592. return 0
  1593. end
  1594. local baseValue = 0
  1595. local round
  1596. for j = target.buffer[0], 1, -1 do
  1597. local buffer = target.buffer[j]
  1598. --local conf = BufferExcel.buffer[buffer.id]
  1599. local conf = GetBuffConfig(buffer.id)
  1600. local cmd = conf.cmd
  1601. if cmd == "ranshao" or cmd == "ranshao1" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "hurt" or cmd == "hurt1" then
  1602. round = 1
  1603. if buffer.round and buffer.round > 0 then
  1604. round = buffer.round
  1605. end
  1606. baseValue = baseValue + buffer.arg * round
  1607. local bufferCnt = delBuffer(target, j)
  1608. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1609. end
  1610. end
  1611. return baseValue
  1612. end
  1613. --解控
  1614. function jiekong(target)
  1615. if target.hp <= 0 then
  1616. return 0
  1617. end
  1618. local baseValue = 0
  1619. local state = false
  1620. for j = target.buffer[0], 1, -1 do
  1621. local buffer = target.buffer[j]
  1622. --local conf = BufferExcel.buffer[buffer.id]
  1623. local conf = GetBuffConfig(buffer.id)
  1624. local cmd = conf.cmd
  1625. if isControlCmd(cmd) then
  1626. local bufferCnt = delBuffer(target, j)
  1627. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1628. state = true
  1629. end
  1630. end
  1631. if state == true then
  1632. CombatImpl.setExtraHit(target,nil, Skill.getCMD2ID("jiekong"))
  1633. end
  1634. end
  1635. --杀意
  1636. function delShayi(target)
  1637. if target.hp <= 0 then
  1638. return 0
  1639. end
  1640. for j = target.buffer[0], 1, -1 do
  1641. local buffer = target.buffer[j]
  1642. --local conf = BufferExcel.buffer[buffer.id]
  1643. local conf = GetBuffConfig(buffer.id)
  1644. local cmd = conf.cmd
  1645. if cmd == "shayi" then
  1646. local bufferCnt = delBuffer(target, j)
  1647. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1648. end
  1649. end
  1650. end
  1651. function getBuffCnt(target,checkCmd)
  1652. if target.hp <= 0 then
  1653. return 0
  1654. end
  1655. local cnt = 0
  1656. for j = target.buffer[0], 1, -1 do
  1657. local buffer = target.buffer[j]
  1658. --local conf = BufferExcel.buffer[buffer.id]
  1659. local conf = GetBuffConfig(buffer.id)
  1660. local cmd = conf.cmd
  1661. if cmd == checkCmd then
  1662. cnt = cnt + 1
  1663. end
  1664. end
  1665. return cnt
  1666. end
  1667. -- 获取护盾值
  1668. function getBuffHuDun(obj)
  1669. if obj and obj.bufferAttr and obj.bufferAttr[RoleDefine.HUDUN_COMBAT] then
  1670. return obj.bufferAttr[RoleDefine.HUDUN_COMBAT]
  1671. end
  1672. return 0
  1673. end
  1674. -- 护盾值的修改
  1675. function updateHuDun(obj, value)
  1676. if obj and obj.bufferAttr then
  1677. local oldValue = obj.bufferAttr[RoleDefine.HUDUN_COMBAT] or 0
  1678. local newValue = oldValue + value
  1679. if newValue <= 0 then
  1680. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = 0
  1681. delBufferByCmd(obj,"hudun", 0)
  1682. else
  1683. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = newValue
  1684. end
  1685. -- 护盾值没有全部去除 则 在对应英雄上吧 BUF 上的arg 数值 减除 防止 BufChange 重置 属性
  1686. if value < 0 and newValue > 0 then
  1687. if obj and obj.buffer then
  1688. for j = 1 , obj.buffer[0] do -- 从最早的护盾BUF中删除arg
  1689. local buffer = obj.buffer[j]
  1690. --local conf = BufferExcel.buffer[buffer.id]
  1691. local conf = GetBuffConfig(buffer.id)
  1692. local bufferCmd = conf.cmd
  1693. if bufferCmd == "hudun" then
  1694. local have = buffer.arg
  1695. if have > -value then
  1696. buffer.arg = have + value
  1697. else
  1698. buffer.arg = 0
  1699. local bufferCnt = delBuffer(obj, j)
  1700. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1701. break
  1702. end
  1703. end
  1704. end
  1705. end
  1706. end
  1707. end
  1708. end
  1709. BUFFER_COMBAT_TYPE = nil
  1710. function initCombatBufferType()
  1711. if BUFFER_COMBAT_TYPE then return end
  1712. BUFFER_COMBAT_TYPE = {}
  1713. for k,conf in pairs(BufferExcel.qusan) do
  1714. if conf then
  1715. BUFFER_COMBAT_TYPE[conf.buffcmd] = conf.type
  1716. end
  1717. end
  1718. end
  1719. --
  1720. function getCombatBufferCnt(target, qusanType)
  1721. initCombatBufferType()
  1722. local buffCnt = 0
  1723. for i = target.buffer[0], 1, -1 do
  1724. local buffer = target.buffer[i]
  1725. --local conf = BufferExcel.buffer[buffer.id]
  1726. local conf = GetBuffConfig(buffer.id)
  1727. local cmd = conf.cmd
  1728. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  1729. buffCnt = buffCnt + 1
  1730. end
  1731. end
  1732. return buffCnt
  1733. end
  1734. --抵抗
  1735. QUSAN_CMD2KEY = {
  1736. ["zuzhou"] = RoleDefine.STATUS_DIKANG_RATE9,
  1737. }
  1738. function qusan(target, qusanType,cnt)
  1739. if target.isPet or not qusanType then
  1740. return 0
  1741. end
  1742. initCombatBufferType()
  1743. local state = false
  1744. local delIndex = {}
  1745. for i = target.buffer[0], 1, -1 do
  1746. local buffer = target.buffer[i]
  1747. --local conf = BufferExcel.buffer[buffer.id]
  1748. local conf = GetBuffConfig(buffer.id)
  1749. local cmd = conf.cmd
  1750. if conf.noQusan ~= 1 then
  1751. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  1752. local isDiKang = nil
  1753. local key = QUSAN_CMD2KEY[cmd]
  1754. local r = math.random(1,10000)
  1755. if key and target.attr[key] >= r then
  1756. isDiKang = true
  1757. end
  1758. if not isDiKang then
  1759. delIndex[#delIndex + 1] = i
  1760. end
  1761. elseif cmd == "attr" or cmd == "attrdne" then
  1762. if conf.args and conf.args[1][2] < 0 and qusanType == 1 then
  1763. delIndex[#delIndex + 1] = i
  1764. elseif conf.args and conf.args[1][2] > 0 and qusanType == 2 then
  1765. delIndex[#delIndex + 1] = i
  1766. end
  1767. end
  1768. end
  1769. end
  1770. cnt = cnt or 0
  1771. if cnt > 0 and cnt < #delIndex then
  1772. for i = cnt + 1,#delIndex do
  1773. delIndex[i] = nil
  1774. end
  1775. end
  1776. for k,v in ipairs(delIndex) do
  1777. local buffer = target.buffer[v]
  1778. if not buffer then break end
  1779. local bufferCnt = delBuffer(target, v)
  1780. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1781. end
  1782. return #delIndex
  1783. end
  1784. function qusanAddBuff(attacker, targets, bufferID)
  1785. for _,target in ipairs(targets) do
  1786. if canAdd(target,bufferID) then
  1787. addBuffer(attacker.pos, target, bufferID)
  1788. end
  1789. end
  1790. end
  1791. function beforeUpdateHp(obj,sum)
  1792. local isStatus,cmd,ind = isStatus(obj,{"miansi","waitMiansi"})
  1793. if not isStatus then
  1794. return
  1795. end
  1796. --免死逻辑
  1797. if cmd == "miansi" then
  1798. return true
  1799. end
  1800. if sum == 0 and cmd == "waitMiansi" then
  1801. local buffer = obj.buffer[ind]
  1802. local bufferCnt = delBuffer(obj, ind)
  1803. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1804. --local conf = BufferExcel.buffer[buffer.id]
  1805. local conf = GetBuffConfig(buffer.id)
  1806. local bufferID = conf.args[1]
  1807. if canAdd(obj,bufferID) then
  1808. addBuffer(obj.pos,obj, bufferID)
  1809. end
  1810. return true
  1811. end
  1812. end
  1813. function checkBaohu(obj,value)
  1814. local isStatus,cmd,ind = isStatus(obj,{"baohu"})
  1815. if not isStatus then
  1816. return value
  1817. end
  1818. local buffer = obj.buffer[ind]
  1819. local attackPos = buffer.attackPos
  1820. local attacker = CombatImpl.objList[attackPos]
  1821. if attacker.hp <= 0 then
  1822. return value
  1823. end
  1824. value = BeSkill.onCheckBuffer(attacker,obj,value)
  1825. return value
  1826. end
  1827. function onExtraCombatRecord(pos,value,param)
  1828. local obj = CombatObj.getObjByPos(pos)
  1829. if not obj then return end
  1830. obj.extraCombatRecord = obj.extraCombatRecord or {}
  1831. if param == "zhongdu" then
  1832. obj.extraCombatRecord.zhongdu = (obj.extraCombatRecord.zhongdu or 0) + value
  1833. elseif param == "liuxue" then
  1834. obj.extraCombatRecord.liuxue = (obj.extraCombatRecord.liuxue or 0) + value
  1835. elseif param == "ranshao" then
  1836. obj.extraCombatRecord.ranshao = (obj.extraCombatRecord.ranshao or 0) + value
  1837. elseif param == "xuanyun" then
  1838. obj.extraCombatRecord.xuanyun = (obj.extraCombatRecord.xuanyun or 0) + value
  1839. elseif param == "revive" then
  1840. obj.extraCombatRecord.revive = (obj.extraCombatRecord.revive or 0) + value
  1841. elseif param == "reviveBeUse" then
  1842. obj.extraCombatRecord.reviveBeUse = (obj.extraCombatRecord.reviveBeUse or 0) + value
  1843. elseif param == "kill" then
  1844. obj.extraCombatRecord.kill = (obj.extraCombatRecord.kill or 0) + value
  1845. end
  1846. end