CombatBuff.lua 76 KB

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