CombatBuff.lua 63 KB

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