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 calcObjBuffCnt(objList, buffCMDArr, skillConfig, bufferConf, bufferID, attacker, randomVal)
  984. local buffCnt = 0
  985. if not objList or not buffCMDArr then
  986. return buffCnt
  987. end
  988. local statusBuffRate = skillConfig.otherArgs.statusBuffRate
  989. local jobRateAdd = skillConfig.otherArgs.jobRateAdd
  990. for _, target in ipairs(objList) 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. for _, cmd in ipairs(buffCMDArr) do
  1000. buffCnt = buffCnt + getBuffCnt(target, cmd)
  1001. end
  1002. end
  1003. end
  1004. return buffCnt
  1005. end
  1006. -- 战斗回合中触发buffer
  1007. function onHit(attacker, skillTargets, skillConfig, cmdTargets, otherArgs, cmdChangeArgs)
  1008. -- 处理施法者身上的buff
  1009. if skillConfig.type == CombatDefine.SKILL_TYPE2 and
  1010. attacker.buffer ~= nil then
  1011. delayBegin()
  1012. for j = attacker.buffer[0], 1, -1 do
  1013. local buffer = attacker.buffer[j]
  1014. --local conf = BufferExcel.buffer[buffer.id]
  1015. local conf = GetBuffConfig(buffer.id)
  1016. buffer.attrs = { }
  1017. if attacker.hp > 0 and handlerEx[conf.cmd] then
  1018. if handlerEx[conf.cmd](attacker, buffer, conf) then
  1019. CombatImpl.addFrameBuffer(attacker, buffer, CombatDefine.BUFFER_OP_HOLD)
  1020. end
  1021. end
  1022. end
  1023. delayEnd()
  1024. end
  1025. for k, v in ipairs(skillTargets) do
  1026. if attacker.helpType == 0 and attacker.side ~= v.side then
  1027. local fantanBufferInd = v.bufferCmd["fantan"] and v.bufferCmd["fantan"][1]
  1028. local fantanBuffer = v.buffer[fantanBufferInd]
  1029. if fantanBuffer then
  1030. --local conf = BufferExcel.buffer[fantanBuffer.id]
  1031. local conf = GetBuffConfig(fantanBuffer.id)
  1032. -- 是否限制技能类型
  1033. local bHit = false
  1034. if conf.args[3] then
  1035. if conf.args[3] == skillConfig.type then
  1036. bHit = true
  1037. end
  1038. else
  1039. bHit = true
  1040. end
  1041. if bHit then
  1042. local hurt = CombatCalc.calcHp(attacker, v, conf.args[1], conf.args[2])
  1043. local d = CombatObj.updateHp(attacker, - hurt, nil, nil, v.pos, CombatObj.BUFFER_HP_TYPE)
  1044. CombatImpl.setExtraHit(attacker, d)
  1045. CombatObj.onHpCB(attacker, d, v.pos)
  1046. end
  1047. end
  1048. end
  1049. -- 只能敌方攻击触发降低冰冻
  1050. if not(otherArgs and otherArgs.noFirst) and skillConfig.hurtRate[1] then
  1051. local bufferCmd = v.bufferCmd["bingdong"]
  1052. if bufferCmd then
  1053. local delList = { }
  1054. for i = #bufferCmd, 1, -1 do
  1055. local bingdongBuffer = v.buffer[bufferCmd[i]]
  1056. --local conf = BufferExcel.buffer[bingdongBuffer.id]
  1057. local conf = GetBuffConfig(bingdongBuffer.id)
  1058. bingdongBuffer.arg = bingdongBuffer.arg or 0
  1059. bingdongBuffer.arg = bingdongBuffer.arg + 1
  1060. if bingdongBuffer.arg >=(conf.args[1] or 0) then
  1061. delList[#delList + 1] = bufferCmd[i]
  1062. end
  1063. end
  1064. --冰冻buffer被打碎
  1065. if #delList > 0 then
  1066. local delBuffer = v.buffer[delList[1]]
  1067. BeSkill.onDelBingDongBuffer(v, delBuffer)
  1068. end
  1069. for k1, v1 in ipairs(delList) do
  1070. local buffer = v.buffer[v1]
  1071. local bufferCnt = delBuffer(v, v1)
  1072. CombatImpl.addFrameBuffer(v, buffer, CombatDefine.BUFFER_OP_DEL)
  1073. end
  1074. end
  1075. end
  1076. if true == isLianjie1(v) then
  1077. CombatBuff_handleLianjie(v, attacker)
  1078. -- local LianJieBufferInd = v.bufferCmd["lianjie1"] and v.bufferCmd["lianjie1"][1]
  1079. -- local LianJieBBuffer = v.buffer[LianJieBufferInd]
  1080. -- if LianJieBBuffer then
  1081. -- local conf = GetBuffConfig(LianJieBBuffer.id)
  1082. -- handler[conf.cmd](v, LianJieBBuffer, conf, attacker)
  1083. -- end
  1084. end
  1085. end
  1086. local buffers = getSkillBuffers(skillConfig)
  1087. local statusBuffRate = skillConfig.otherArgs.statusBuffRate
  1088. local jobRateAdd = skillConfig.otherArgs.jobRateAdd
  1089. for i = 1, #buffers do
  1090. local bufferID = buffers[i][1]
  1091. if type(bufferID) == "table" then
  1092. local r = math.random(1, #bufferID)
  1093. bufferID = bufferID[r]
  1094. end
  1095. local targetMode = buffers[i][2]
  1096. local random = buffers[i][3]
  1097. local bufferEx = buffers[i][4]
  1098. local delayRound = buffers[i][5]
  1099. if attacker.isPet and #skillConfig.bufferGrow > 0 then
  1100. local growRate = 0
  1101. local bufLv = attacker.lv
  1102. if attacker.quality > 1 then
  1103. bufLv = attacker.lv -(attacker.quality - 1) * 30
  1104. end
  1105. if skillConfig.bufferGrow and skillConfig.bufferGrow[i] then
  1106. local gorwRat = skillConfig.bufferGrow[i][1]
  1107. local growLv = skillConfig.bufferGrow[i][2]
  1108. growRate = math.floor(bufLv / growLv) * gorwRat
  1109. end
  1110. random = random + growRate
  1111. end
  1112. local targets = TargetMode.getTargets(attacker, targetMode, skillTargets, cmdTargets, nil, nil, skillConfig.id)
  1113. if #targets > 0 then
  1114. --local bufferConf = BufferExcel.buffer[bufferID]
  1115. local bufferConf = GetBuffConfig(bufferID)
  1116. local targetBuffCnt
  1117. for _, target in ipairs(targets) do
  1118. local r = random
  1119. if statusBuffRate and bufferConf.cmd == statusBuffRate[1] and isStatus(target, statusBuffRate[2]) then
  1120. r = r + statusBuffRate[3]
  1121. end
  1122. if jobRateAdd and bufferConf.cmd == jobRateAdd[1] and isJob(target, jobRateAdd[2]) then
  1123. r = r + jobRateAdd[3]
  1124. end
  1125. if canAdd(target, bufferID, r, attacker, skillConfig) then
  1126. local arg
  1127. if bufferConf.cmd == "zuzhou" then
  1128. local rate = bufferConf.args[2] + BeSkill.getBufferExtraHurt(attacker, bufferID, bufferConf.cmd)
  1129. arg = { CombatCalc.calcHp(attacker, target, bufferConf.args[1], rate) }
  1130. end
  1131. if bufferConf.cmd == "stealattr" then
  1132. local value = CombatCalc.calcValue(attacker, target, bufferConf.args[1], bufferConf.args[2])
  1133. arg = { { bufferConf.args[3], value } }
  1134. end
  1135. if bufferConf.cmd == "handleattr" then
  1136. arg = { }
  1137. if attacker.handleAttr then
  1138. local value = attacker.handleAttr[2] *(bufferConf.args[1] / 10000)
  1139. if target.side == attacker.side then
  1140. arg = { { attacker.handleAttr[1], value * bufferConf.args[2] } }
  1141. else
  1142. arg = { { attacker.handleAttr[1], - value } }
  1143. end
  1144. end
  1145. end
  1146. if cmdChangeArgs and #bufferConf.calcMode > 0 and #bufferConf.args > 0 then --后面优化
  1147. if cmdChangeArgs[1] == bufferConf.calcMode[1] then
  1148. arg = {}
  1149. local val = cmdChangeArgs[2] or 1
  1150. local calcType = bufferConf.calcMode[2]
  1151. for kk, attrCfg in ipairs(bufferConf.args) do
  1152. arg[kk] = { attrCfg[1], 0}
  1153. if calcType == 1 then -- +
  1154. arg[kk][2] = attrCfg[2] + val
  1155. elseif calcType == 2 then -- -
  1156. arg[kk][2] = math.max(attrCfg[2] - val, 0)
  1157. elseif calcType == 3 then -- *
  1158. arg[kk][2] = math.max(attrCfg[2] * val, 0)
  1159. elseif calcType == 4 then -- /
  1160. arg[kk][2] = attrCfg[2] / val
  1161. end
  1162. end
  1163. end
  1164. end
  1165. if bufferConf.cmd == "hudun1" then
  1166. if not targetBuffCnt then
  1167. targetBuffCnt = calcObjBuffCnt(objList, {"hudun1"}, skillConfig, bufferConf, bufferID, attacker, random)
  1168. end
  1169. targetBuffCnt = math.max(targetBuffCnt, 1)
  1170. local val = CombatObj.getHpMax(attacker) - attacker.hp
  1171. arg = math.floor(val / targetBuffCnt)
  1172. print("==================", arg and arg or -1)
  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 targetBuffCnt
  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 targetBuffCnt then
  1313. targetBuffCnt = calcObjBuffCnt(objList, {"hudun1"}, skillConfig, bufferConf, bufferID, attacker, buffers[i][3])
  1314. end
  1315. targetBuffCnt = math.max(targetBuffCnt, 1)
  1316. local val = CombatObj.getHpMax(attacker) - attacker.hp
  1317. bufferArg1 = math.floor(val / targetBuffCnt)
  1318. print("==================", bufferArg1 and bufferArg1 or -1)
  1319. end
  1320. if bufferConf.cmd == "shaqi" then
  1321. for k=1, addBuffTimes do
  1322. addBuffer(attackPos,target, bufferID,skillConfig.id,bufferArg1 or bufferArg)
  1323. end
  1324. else
  1325. addBuffer(attackPos,target, bufferID,skillConfig.id,bufferArg1 or bufferArg)
  1326. end
  1327. end
  1328. end
  1329. end
  1330. end
  1331. -- if skillConfig.cmd == "winnerRelicSkill" then
  1332. -- if skillConfig and skillConfig.otherArgs.selefDefense then
  1333. -- if attacker then
  1334. -- print("[onUseBeSkill] winnerRelicSkill 进入 1")
  1335. -- attacker.attr[RoleDefine.DEF] = 0
  1336. -- end
  1337. -- elseif skillConfig and skillConfig.otherArgs.jobDefense then
  1338. -- if isJob(attacker, {CombatDefine.JOB_TYPE4, CombatDefine.JOB_TYPE1}) then
  1339. -- if winnerID > 0 and winnerStar > 0 then
  1340. -- print("[onUseBeSkill] winnerRelicSkill 进入 2")
  1341. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1342. -- attacker.attr[RoleDefine.DEF] = attacker.attr[RoleDefine.DEF] + extraRate
  1343. -- print("当前防御提升量为:",extraRate)
  1344. -- end
  1345. -- end
  1346. -- elseif skillConfig and skillConfig.otherArgs.jobMianshang then
  1347. -- if isJob(attacker, {CombatDefine.JOB_TYPE1}) then
  1348. -- print("[onUseBeSkill] winnerRelicSkill 进入 3")
  1349. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateDef(winnerID, winnerStar)
  1350. -- attacker.attr[RoleDefine.JIANSHANG_RATE] = attacker.attr[RoleDefine.JIANSHANG_RATE] *(1 + extraRate/100)
  1351. -- print("当前护卫免伤量提升量为:",extraRate)
  1352. -- end
  1353. -- elseif skillConfig and skillConfig.otherArgs.racialAtk then
  1354. -- if isCamp(attacker, {CombatDefine.COMBAT_TYPE27}) then
  1355. -- print("[onUseBeSkill] winnerRelicSkill 进入 4")
  1356. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1357. -- attacker.attr[RoleDefine.ATK] = attacker.attr[RoleDefine.ATK] *(1+ extraRate/100)
  1358. -- end
  1359. -- elseif skillConfig and skillConfig.otherArgs.jobZhiliao then
  1360. -- if isJob(attacker, {CombatDefine.JOB_TYPE4}) then
  1361. -- print("[onUseBeSkill] winnerRelicSkill 进入 5")
  1362. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1363. -- attacker.attr[RoleDefine.HP_ADD_RATE] = attacker.attr[RoleDefine.HP_ADD_RATE] *(1 + extraRate/100)
  1364. -- end
  1365. -- end
  1366. -- end
  1367. return isAddSkillFrame
  1368. end
  1369. --战斗回合结束时处理buffer效果。删除失效buffer
  1370. --只执行一次的cmd,比如持续加血。
  1371. HANDLER_ONCE = HANDLER_ONCE or {}
  1372. function onRoundEnd(attacker,isRoundEnd)
  1373. --处理施法者身上的buff
  1374. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1375. local obj = CombatImpl.objList[i]
  1376. if obj then
  1377. for k,v in pairs(HANDLER_ONCE) do
  1378. HANDLER_ONCE[k] = nil
  1379. end
  1380. delayBegin()
  1381. for j = obj.buffer[0], 1, -1 do
  1382. local buffer = obj.buffer[j]
  1383. --local conf = BufferExcel.buffer[buffer.id]
  1384. local conf = GetBuffConfig(buffer.id)
  1385. if conf.type == CombatDefine.BUFFER_TYPE1 or isRoundEnd then
  1386. buffer.attrs = {}
  1387. local setFrame = false
  1388. if conf.type ~= CombatDefine.BUFFER_TYPE4 and handler[conf.cmd] then
  1389. if obj.hp > 0 or conf.cmd == "totem" then
  1390. if conf.cmd == "zuzhou" then
  1391. -- 最后一回合生效
  1392. if buffer.round == 1 then
  1393. handler[conf.cmd](obj, buffer,conf)
  1394. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1395. end
  1396. else
  1397. handler[conf.cmd](obj, buffer,conf)
  1398. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1399. end
  1400. end
  1401. end
  1402. if buffer.round then
  1403. local cmd = conf.cmd
  1404. buffer.round = buffer.round - 1
  1405. if buffer.round < 1 then
  1406. local bufferCnt = delBuffer(obj, j)
  1407. if (conf.type ~= CombatDefine.BUFFER_TYPE1 and obj.hp > 0) or conf.cmd == "fixPos" or conf.holdOnDie == 1 then
  1408. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  1409. end
  1410. end
  1411. end
  1412. end
  1413. end
  1414. if isRoundEnd and obj.delayAddBuffer then
  1415. --{delayRound,attacker.pos,bufferID,skillConfig.id,arg}
  1416. for k,v in ipairs(obj.delayAddBuffer) do
  1417. v[1] = v[1] - 1
  1418. end
  1419. local temp = {}
  1420. for i = 1,#obj.delayAddBuffer do
  1421. local data = obj.delayAddBuffer[i]
  1422. if data[1] > 0 then
  1423. temp[#temp + 1] = data
  1424. else
  1425. addBuffer(data[2],obj,data[3],data[4],data[5])
  1426. end
  1427. end
  1428. if #temp > 0 then
  1429. obj.delayAddBuffer = temp
  1430. else
  1431. obj.delayAddBuffer = nil
  1432. end
  1433. end
  1434. delayEnd()
  1435. end
  1436. end
  1437. for k,v in pairs(HANDLER_ONCE) do
  1438. HANDLER_ONCE[k] = nil
  1439. end
  1440. end
  1441. --攻击结束后,反击前,整合buffer前处理buffer效果
  1442. function beforeFanji()
  1443. local isFanshe = false
  1444. for i = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1445. local obj = CombatImpl.objList[i]
  1446. if obj then
  1447. for k,v in pairs(obj.combatResult[3]) do
  1448. if k ~= i and v[1] and v[1] < 0 then
  1449. local target = CombatImpl.objList[k]
  1450. if target and target.hp > 0 then
  1451. local d = CombatObj.updateHp(target, v[1], nil, nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1452. CombatImpl.setExtraHit(target,d)
  1453. CombatObj.onHpCB(target,d, obj.pos)
  1454. isFanshe = true
  1455. end
  1456. end
  1457. end
  1458. if isFanshe then
  1459. delBufferByCmd(obj,"fansheZhuangjia",1)
  1460. end
  1461. end
  1462. end
  1463. end
  1464. function getExtraHurtRate(attacker,target,skillConfig)
  1465. local skillID = skillConfig.id
  1466. local isBaoji = target.isBaoji
  1467. local baojiHurtRate = 0
  1468. local guanxinzheHurtRate = 0
  1469. local huiheHurtRate = 0
  1470. local shandianHurtRate = 0
  1471. local attackerHurtRat = 0
  1472. local biaoshiHurtRate = 0
  1473. local biaoshiCnt = 0
  1474. local moweiHurtRate = 0
  1475. local biaoshiCntLimit
  1476. local zhanyiHurtRate = 0
  1477. local chenshuiHurtRate = 0
  1478. if skillConfig.otherArgs.biaoshiHurtRate then
  1479. biaoshiCntLimit = skillConfig.otherArgs.biaoshiHurtRate[1]
  1480. end
  1481. local bHaveQianXing = false -- 是否有潜行
  1482. for j = target.buffer[0], 1, -1 do
  1483. local obj = target
  1484. local buffer = obj.buffer[j]
  1485. --local conf = BufferExcel.buffer[buffer.id]
  1486. local conf = GetBuffConfig(buffer.id)
  1487. if conf.cmd == "guanxinzheYinji" then --观星者印记
  1488. guanxinzheHurtRate = guanxinzheHurtRate + conf.args[2]
  1489. elseif conf.cmd == "shandianYinji" then --闪电印记
  1490. for _,v in ipairs(conf.args[2]) do
  1491. if skillID == v then
  1492. shandianHurtRate = shandianHurtRate + conf.args[3]
  1493. break
  1494. end
  1495. end
  1496. elseif conf.cmd == "biaoshi" then
  1497. biaoshiCnt = biaoshiCnt + 1
  1498. elseif conf.cmd == "chenshui" then
  1499. chenshuiHurtRate = chenshuiHurtRate + 3000
  1500. elseif conf.cmd == "qianxing" then
  1501. bHaveQianXing = true
  1502. end
  1503. end
  1504. local bHaveTrueVision, nTrueVisionBuffID = false, 0 -- 是否有真视
  1505. --攻击者
  1506. for j = attacker.buffer[0], 1, -1 do
  1507. local obj = attacker
  1508. local buffer = obj.buffer[j]
  1509. --local conf = BufferExcel.buffer[buffer.id]
  1510. local conf = GetBuffConfig(buffer.id)
  1511. if conf.cmd == "mowei" then --魔威
  1512. local nowHp = attacker.hp
  1513. local hpMax = CombatObj.getHpMax(attacker)
  1514. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1515. if percent >= 1 then
  1516. --moweiHurtRate = moweiHurtRate + (percent * conf.args[1])
  1517. moweiHurtRate = percent * conf.args[1]
  1518. break
  1519. end
  1520. elseif conf.cmd == "zhanyi" then
  1521. local nowHp = attacker.hp
  1522. local hpMax = CombatObj.getHpMax(attacker)
  1523. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1524. if percent >= 1 then
  1525. local args = conf.args
  1526. percent = percent / (args[1] / 100)
  1527. zhanyiHurtRate = percent * args[2]
  1528. break
  1529. end
  1530. elseif conf.cmd == "truevision" then
  1531. bHaveTrueVision = true
  1532. nTrueVisionBuffID = buffer.id
  1533. end
  1534. end
  1535. local TrueVisionRate = 0
  1536. if bHaveTrueVision and bHaveQianXing then
  1537. local conf = GetBuffConfig(nTrueVisionBuffID)
  1538. TrueVisionRate = TrueVisionRate + conf.args[1]
  1539. delBufferByCmd(target,"qianxing",1)
  1540. -- print("[CombatBuff_getExtraHurtRate] 真视对潜行增伤 并删除对应的潜行buffer TrueVisionRate = "..TrueVisionRate
  1541. -- .." buffid = "..nTrueVisionBuffID.." args[1] = "..conf.args[1])
  1542. end
  1543. guanxinzheHurtRate = guanxinzheHurtRate > 30000 and 30000 or guanxinzheHurtRate --300%限制
  1544. if biaoshiCntLimit and biaoshiCnt >= biaoshiCntLimit then
  1545. biaoshiHurtRate = skillConfig.otherArgs.biaoshiHurtRate[2]
  1546. end
  1547. local extraHurtRate = baojiHurtRate + guanxinzheHurtRate + huiheHurtRate + shandianHurtRate
  1548. + attackerHurtRat + biaoshiHurtRate + moweiHurtRate + zhanyiHurtRate + chenshuiHurtRate + TrueVisionRate
  1549. return extraHurtRate
  1550. end
  1551. function getExtraHurt(attacker, target, skillConfig)
  1552. local extraHurt = 0
  1553. for j = target.buffer[0], 1, -1 do
  1554. local obj = target
  1555. local buffer = obj.buffer[j]
  1556. --local conf = BufferExcel.buffer[buffer.id]
  1557. local conf = GetBuffConfig(buffer.id)
  1558. if conf.cmd == "shenhuo" then
  1559. local hurt = CombatCalc.calcHp(attacker, target, conf.args[1], conf.args[2], true)
  1560. extraHurt = extraHurt + hurt
  1561. end
  1562. end
  1563. return extraHurt
  1564. end
  1565. --处理器
  1566. local function chixuHurtDel(target,buffer)
  1567. local hurt = buffer.arg
  1568. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1569. --持续类buff 伤害加成
  1570. local attacker = CombatImpl.objList[buffer.attackPos]
  1571. --local conf = BufferExcel.buffer[buffer.id]
  1572. local conf = GetBuffConfig(buffer.id)
  1573. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1574. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1575. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1576. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1577. end
  1578. return hurt
  1579. end
  1580. --处理器, 实时计算伤害
  1581. local function chixuHurtDel2(target,buffer)
  1582. local id = buffer.id
  1583. --local conf = BufferExcel.buffer[id]
  1584. local conf = GetBuffConfig(buffer.id)
  1585. local attackPos = buffer.attackPos
  1586. local attacker
  1587. if attackPos <= CombatDefine.COMBAT_HERO_ALL_CNT then
  1588. attacker = CombatImpl.objList[attackPos]
  1589. elseif attackPos > CombatDefine.COMBAT_HERO_ALL_CNT and attackPos < CombatDefine.COMBAT_HERO_ALL_CNT + CombatDefine.COMBAT_HELP_ALL_CNT then
  1590. attacker = CombatImpl.helpList[attackPos]
  1591. elseif attackPos >= CombatDefine.ELF_MIN_POS then
  1592. attacker = CombatImpl.elfList[attackPos]
  1593. end
  1594. local isAddHp = conf.cmd == "hp"
  1595. buffer.arg = CombatCalc.calcBufferHp(attacker,target,id,isAddHp)
  1596. local hurt = buffer.arg
  1597. local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
  1598. --持续类buff 伤害加成
  1599. -- local attacker = CombatImpl.objList[buffer.attackPos]
  1600. -- local conf = BufferExcel.buffer[buffer.id]
  1601. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1602. hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
  1603. if hurtDelRate > 0 or beSkillHurtRate > 0 then
  1604. hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
  1605. end
  1606. return hurt
  1607. end
  1608. handler = {}
  1609. --持续伤害
  1610. function handler.hurt(target, buffer,conf)
  1611. local hurt = chixuHurtDel(target,buffer)
  1612. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1613. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1614. end
  1615. --燃烧
  1616. function handler.hurt1(target, buffer,conf)
  1617. local hurt = chixuHurtDel(target,buffer)
  1618. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1619. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1620. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1621. -- 删除attr1 buffer
  1622. local attacker = CombatImpl.objList[buffer.attackPos]
  1623. if attacker and attacker.bufferCmd["attr1"] then
  1624. for i = #attacker.bufferCmd["attr1"],1,-1 do
  1625. local ind = attacker.bufferCmd["attr1"][i]
  1626. local buff = attacker.buffer[ind]
  1627. --local conf = BufferExcel.buffer[buff.id]
  1628. local conf = GetBuffConfig(buffer.id)
  1629. local bufferCnt = delBuffer(attacker, ind)
  1630. CombatImpl.addFrameBuffer(attacker, buff, CombatDefine.BUFFER_OP_DEL)
  1631. end
  1632. end
  1633. end
  1634. --持续治疗
  1635. function handler.hp(target, buffer,conf)
  1636. if target.bufferCmd["noHp"] then
  1637. return
  1638. end
  1639. if HANDLER_ONCE["hp"] == target.pos then
  1640. return
  1641. end
  1642. local hp = buffer.arg
  1643. local attacker = CombatImpl.objList[buffer.attackPos]
  1644. if attacker and attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1645. local hpAddRate = attacker.attr[RoleDefine.ZAOCHENG_HP_ADD_RATE] / 10000
  1646. hp = hp * (1 + hpAddRate)
  1647. end
  1648. local calcType = conf and conf.args[1] or 0
  1649. if CombatCalc.NO_EXCALC_LIST[calcType] and target.attr[RoleDefine.HP_ADD_RATE] then
  1650. local hpAddRate = target.attr[RoleDefine.HP_ADD_RATE] / 10000
  1651. hp = hp * (1 + hpAddRate)
  1652. end
  1653. hp = hp < 0 and 1 or hp
  1654. if target.side == CombatDefine.DEFEND_SIDE then
  1655. hp = CombatImpl.commonArgs.hpLimit or hp
  1656. end
  1657. local d = CombatObj.updateHp(target, hp, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1658. buffer.attrs[RoleDefine.HP_COMBAT] = hp
  1659. HANDLER_ONCE["hp"] = target.pos
  1660. end
  1661. --流血
  1662. function handler.liuxue(target, buffer,conf)
  1663. local hurt = chixuHurtDel(target,buffer)
  1664. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1665. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1666. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1667. end
  1668. --流血2
  1669. function handler.liuxue2(target, buffer,conf)
  1670. local hurt = chixuHurtDel2(target,buffer)
  1671. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1672. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1673. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1674. end
  1675. --中毒
  1676. function handler.zhongdu(target, buffer,conf)
  1677. local hurt = chixuHurtDel(target,buffer)
  1678. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1679. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1680. onExtraCombatRecord(buffer.attackPos,hurt,"zhongdu")
  1681. end
  1682. --燃烧
  1683. function handler.ranshao(target, buffer,conf)
  1684. local hurt = chixuHurtDel(target,buffer)
  1685. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1686. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1687. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1688. end
  1689. --燃烧
  1690. function handler.ranshao1(target, buffer,conf)
  1691. local hurt = chixuHurtDel(target,buffer)
  1692. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1693. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1694. onExtraCombatRecord(buffer.attackPos,hurt,"ranshao")
  1695. end
  1696. --回合印记
  1697. function handler.huiheYinji(target, buffer,conf)
  1698. if buffer.round > 1 then return end --最后一回合才生效
  1699. local hurt = chixuHurtDel(target,buffer)
  1700. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1701. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1702. end
  1703. --种子
  1704. function handler.zhongzi(target, buffer, conf)
  1705. if buffer.round > 1 then return end --最后一回合才生效
  1706. local cnt = #conf.args
  1707. for i= 1, cnt do
  1708. local bufferID = conf.args[i]
  1709. if canAdd(target,bufferID) then
  1710. addBuffer(buffer.attackPos, target, bufferID)
  1711. end
  1712. end
  1713. end
  1714. --buffer包处理器
  1715. --偷取护甲
  1716. function handler.touquhujia(attacker,target,conf)
  1717. local arg = conf.args[1]/10000
  1718. local targetBufferID = conf.args[2]
  1719. local attackerBufferID = conf.args[3]
  1720. local def = CombatObj.getValue(target,RoleDefine.DEF)
  1721. --local rate = CombatObj.getValue(target,RoleDefine.DEF_RATE)/10000
  1722. --def = def * (1 + rate)
  1723. def = def > 0 and def or 0
  1724. local arg = def * arg
  1725. if arg > 0 then
  1726. if canAdd(attacker,attackerBufferID) then
  1727. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1728. end
  1729. if canAdd(target,targetBufferID) then
  1730. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1731. end
  1732. end
  1733. end
  1734. --偷取攻击
  1735. function handler.touqugongji(attacker,target,conf)
  1736. local arg = conf.args[1]/10000
  1737. local targetBufferID = conf.args[2]
  1738. local attackerBufferID = conf.args[3]
  1739. local atk = CombatObj.getValue(target,RoleDefine.ATK)
  1740. --local rate = CombatObj.getValue(target,RoleDefine.ATK_RATE)/10000
  1741. --def = def * (1 + rate)
  1742. atk = atk > 0 and atk or 0
  1743. local arg = atk * arg
  1744. if arg > 0 then
  1745. if canAdd(attacker,attackerBufferID) then
  1746. addBuffer(target.pos,attacker, attackerBufferID,nil,arg,conf)
  1747. end
  1748. if canAdd(target,targetBufferID) then
  1749. addBuffer(attacker.pos,target, targetBufferID,nil,-arg,conf)
  1750. end
  1751. end
  1752. end
  1753. function handler.totem(obj,buffer,conf)
  1754. --图腾逻辑
  1755. local buffers = conf.args
  1756. for i = 1, #buffers do
  1757. local bufferID = buffers[i][1]
  1758. if type(bufferID) == "table" then
  1759. local r = math.random(1,#bufferID)
  1760. bufferID = bufferID[r]
  1761. end
  1762. local targetMode = buffers[i][2]
  1763. local random = buffers[i][3]
  1764. local targets = TargetMode.getTargets(obj, targetMode,{})
  1765. if #targets > 0 then
  1766. for _,target in ipairs(targets) do
  1767. if canAdd(target,bufferID,random) then
  1768. addBuffer(obj.pos,target, bufferID)
  1769. end
  1770. end
  1771. end
  1772. end
  1773. end
  1774. function handler.groupbuffer(attacker,target,conf)
  1775. for _,bufferID in ipairs(conf.args) do
  1776. if canAdd(target,bufferID) then
  1777. addBuffer(attacker.pos,target, bufferID,nil,nil,conf)
  1778. end
  1779. end
  1780. end
  1781. function handler.zuzhou(target,buffer,conf)
  1782. local hurt = buffer.arg[1]
  1783. local attacker = CombatImpl.objList[buffer.attackPos]
  1784. -- 二次元结算方式调整成
  1785. if BeSkill.getRandomBuffCmd(attacker, target, conf.cmd) and target.bufferCmd[conf.cmd] then
  1786. hurt = hurt * #target.bufferCmd[conf.cmd]
  1787. end
  1788. local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
  1789. hurt = hurt * (1 + beSkillHurtRate)
  1790. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1791. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1792. BeSkill.handlerBuff(attacker, target, hurt, conf.cmd)
  1793. end
  1794. function handler.lianjie1(target, buffer1, conf1, attacker)
  1795. if not attacker then
  1796. return
  1797. end
  1798. local nHurt = CombatObj.getValue(attacker, RoleDefine.HURT_COMBAT_NOW)
  1799. if 0 >= nHurt or not target then
  1800. print("[handler.lianjie1] 不正确的目标和伤害值")
  1801. return
  1802. end
  1803. if not target.bufferCmd or not target.bufferCmd["lianjie1"] then
  1804. print("[handler.lianjie1] 不存在对应buff")
  1805. return
  1806. end
  1807. local nTargetPos, nTargetSide = target.pos, target.side
  1808. print("[handler.lianjie1] 回合结束进行处理 nTargetPos = "..nTargetPos.." nTargetSide = "..nTargetSide.." id = "..target.id)
  1809. for i = #target.bufferCmd["lianjie1"],1,-1 do
  1810. local ind = target.bufferCmd["lianjie1"][i]
  1811. local buffer = target.buffer[ind]
  1812. -- 自己身上有链接
  1813. local conf = GetBuffConfig(buffer.id)
  1814. local arg = conf.args[1]
  1815. local nDelHurt = nHurt * arg / 10000
  1816. print("[handler.lianjie1] 计算出来的值 nDelHurt = "..nDelHurt.." arg = "..arg.." nHurt = "..nHurt)
  1817. local nGetSide = nTargetSide == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  1818. for _,pos in ipairs(CombatDefine.SIDE2POS[nGetSide]) do
  1819. local objM = CombatImpl.objList[pos]
  1820. if objM and objM.hp > 0 and isLianjie2(objM) then
  1821. local bHave = false
  1822. for j = #objM.bufferCmd["lianjie2"], 1, -1 do
  1823. local index = objM.bufferCmd["lianjie2"][j]
  1824. local tBuffData = objM.buffer[index]
  1825. if tBuffData and tBuffData.attackPos == nTargetPos then
  1826. bHave = true
  1827. break
  1828. end
  1829. end
  1830. if bHave == true then
  1831. print("[handler.lianjie1] 对目标英雄 进行扣血操作 id = "..target.id.." 目标英雄ID = "..objM.id .." nDelHurt = "..nDelHurt)
  1832. local d = CombatObj.updateHp(objM, -nDelHurt, nil, true, objM.pos,CombatObj.BUFFER_HP_TYPE)
  1833. CombatImpl.setExtraHit(objM, d)
  1834. CombatObj.onHpCB(objM, d, objM.pos)
  1835. end
  1836. end
  1837. end
  1838. end
  1839. end
  1840. function handler.lianjie3(obj, buffer1, conf1, nAddNum)
  1841. if not obj.bufferCmd or not obj.bufferCmd["lianjie3"] or not nAddNum then
  1842. return
  1843. end
  1844. if 0 >= nAddNum then
  1845. return
  1846. end
  1847. for i = #obj.bufferCmd["lianjie3"], 1, -1 do
  1848. local ind = obj.bufferCmd["lianjie3"][i]
  1849. local buffer = obj.buffer[ind]
  1850. local nAttackPos = buffer.attackPos
  1851. local conf = GetBuffConfig(buffer.id)
  1852. local arg = conf.args[1]
  1853. local nSum = nAddNum * arg / 10000
  1854. local tAttacker = CombatImpl.objList[nAttackPos]
  1855. if tAttacker and tAttacker.hp > 0 then
  1856. -- print("[handler.lianjie3] 进行加血操作 nAddNum = "..nAddNum.." nSum = "..nSum.." arg = "..arg)
  1857. local d = CombatObj.updateHp(tAttacker, nSum, nil, true, tAttacker.pos,CombatObj.BUFFER_HP_TYPE)
  1858. CombatImpl.setExtraHit(tAttacker, d)
  1859. CombatObj.onHpCB(tAttacker, d, tAttacker.pos)
  1860. end
  1861. end
  1862. end
  1863. function yinbaoZuzhou(obj, skillTargets, skillConfig)
  1864. local newFrame = nil
  1865. for k,v in ipairs(skillTargets) do
  1866. if v.bufferCmd["zuzhou"] then
  1867. for i = #v.bufferCmd["zuzhou"],1,-1 do
  1868. local ind = v.bufferCmd["zuzhou"][i]
  1869. local buffer = v.buffer[ind]
  1870. --local conf = BufferExcel.buffer[buffer.id]
  1871. local conf = GetBuffConfig(buffer.id)
  1872. if conf and handler[conf.cmd] then
  1873. handler[conf.cmd](v, buffer, conf)
  1874. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_HOLD)
  1875. end
  1876. local bufferCnt = delBuffer(v, ind)
  1877. CombatImpl.addFrameBuffer(v,buffer,CombatDefine.BUFFER_OP_DEL)
  1878. newFrame = true
  1879. end
  1880. end
  1881. end
  1882. -- 有引爆成功的
  1883. if newFrame and ProjectLogic.isSsecy() then
  1884. CombatImpl.addFrame()
  1885. end
  1886. end
  1887. --主动技能释放后buff作用
  1888. handlerEx = {}
  1889. --印记
  1890. function handlerEx.yinJi(target, buffer, conf)
  1891. local attacker = CombatImpl.objList[buffer.attackPos]
  1892. if attacker == nil then
  1893. return
  1894. end
  1895. local hurtRate = conf.args[1]
  1896. local hurtRateMax = conf.args[2]
  1897. local hpMax = CombatObj.getHpMax(target)
  1898. local hurt = hurtRate * hpMax / 10000
  1899. local atk = CombatObj.getValue(attacker,RoleDefine.ATK) * hurtRateMax / 10000
  1900. if hurt > atk then
  1901. hurt = atk
  1902. end
  1903. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1904. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1905. return true
  1906. end
  1907. handle2 = {}
  1908. function handle2.liuxue3(target, buffer)
  1909. local hurt = chixuHurtDel2(target,buffer)
  1910. local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
  1911. buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
  1912. onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
  1913. end
  1914. -- 有些buff, 在释放技能后会触发效果
  1915. function BuffHandleAfterSkill(obj)
  1916. local res, _, idx = isStatus(obj, {"liuxue3"})
  1917. if res then
  1918. local buffer = obj.buffer[idx]
  1919. handle2.liuxue3(obj, buffer)
  1920. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1921. end
  1922. end
  1923. -- 通过 xishou buff吸收伤害回血
  1924. function AddHPByXishouBuff(obj, targetBuffCMD, hpVal)
  1925. print(string.format("==============英雄: %d, 当前血量: %s 通过buff: %s 回血 : %s=========", obj.id, obj.hp, targetBuffCMD, hpVal))
  1926. local res, _, idx = isStatus(obj, {targetBuffCMD})
  1927. if res then
  1928. local buffer = obj.buffer[idx]
  1929. local d = CombatObj.updateHp(obj, hpVal, nil, nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1930. buffer.attrs[RoleDefine.HP_COMBAT] = hpVal
  1931. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_HOLD)
  1932. print(string.format("==============英雄: %d 通过buff: %s 回血后血量: %s =========\n", obj.id, targetBuffCMD, obj.hp))
  1933. end
  1934. end
  1935. function qingsuan(target)
  1936. if target.hp <= 0 then
  1937. return 0
  1938. end
  1939. local baseValue = 0
  1940. local round
  1941. for j = target.buffer[0], 1, -1 do
  1942. local buffer = target.buffer[j]
  1943. --local conf = BufferExcel.buffer[buffer.id]
  1944. local conf = GetBuffConfig(buffer.id)
  1945. local cmd = conf.cmd
  1946. if cmd == "ranshao" or cmd == "ranshao1" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "liuxue3"
  1947. or cmd == "zhongdu" or cmd == "hurt" or cmd == "hurt1" then
  1948. round = 1
  1949. if buffer.round and buffer.round > 0 then
  1950. round = buffer.round
  1951. end
  1952. baseValue = baseValue + buffer.arg * round
  1953. local bufferCnt = delBuffer(target, j)
  1954. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1955. end
  1956. end
  1957. return baseValue
  1958. end
  1959. --解控
  1960. function jiekong(target)
  1961. if target.hp <= 0 then
  1962. return 0
  1963. end
  1964. local baseValue = 0
  1965. local state = false
  1966. for j = target.buffer[0], 1, -1 do
  1967. local buffer = target.buffer[j]
  1968. --local conf = BufferExcel.buffer[buffer.id]
  1969. local conf = GetBuffConfig(buffer.id)
  1970. local cmd = conf.cmd
  1971. if isControlCmd(cmd) then
  1972. local bufferCnt = delBuffer(target, j)
  1973. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1974. state = true
  1975. end
  1976. end
  1977. if state == true then
  1978. CombatImpl.setExtraHit(target,nil, Skill.getCMD2ID("jiekong"))
  1979. end
  1980. end
  1981. --杀意
  1982. function delShayi(target)
  1983. if target.hp <= 0 then
  1984. return 0
  1985. end
  1986. for j = target.buffer[0], 1, -1 do
  1987. local buffer = target.buffer[j]
  1988. --local conf = BufferExcel.buffer[buffer.id]
  1989. local conf = GetBuffConfig(buffer.id)
  1990. local cmd = conf.cmd
  1991. if cmd == "shayi" then
  1992. local bufferCnt = delBuffer(target, j)
  1993. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  1994. end
  1995. end
  1996. end
  1997. function getBuffCnt(target,checkCmd)
  1998. if target.hp <= 0 then
  1999. return 0
  2000. end
  2001. local cnt = 0
  2002. for j = target.buffer[0], 1, -1 do
  2003. local buffer = target.buffer[j]
  2004. --local conf = BufferExcel.buffer[buffer.id]
  2005. local conf = GetBuffConfig(buffer.id)
  2006. local cmd = conf.cmd
  2007. if cmd == checkCmd then
  2008. cnt = cnt + 1
  2009. end
  2010. end
  2011. return cnt
  2012. end
  2013. -- 获取护盾值
  2014. function getBuffHuDun(obj)
  2015. if obj and obj.bufferAttr and obj.bufferAttr[RoleDefine.HUDUN_COMBAT] then
  2016. return obj.bufferAttr[RoleDefine.HUDUN_COMBAT]
  2017. end
  2018. return 0
  2019. end
  2020. -- 护盾值的修改
  2021. function updateHuDun(obj, value)
  2022. if obj and obj.bufferAttr then
  2023. local oldValue = obj.bufferAttr[RoleDefine.HUDUN_COMBAT] or 0
  2024. local newValue = oldValue + value
  2025. if newValue <= 0 then
  2026. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = 0
  2027. delBufferByCmd(obj,"hudun", 0)
  2028. delBufferByCmd(obj,"hudun1", 0)
  2029. else
  2030. obj.bufferAttr[RoleDefine.HUDUN_COMBAT] = newValue
  2031. end
  2032. -- 护盾值没有全部去除 则 在对应英雄上吧 BUF 上的arg 数值 减除 防止 BufChange 重置 属性
  2033. if value < 0 and newValue > 0 then
  2034. if obj and obj.buffer then
  2035. local subVal = value
  2036. for j = 1 , obj.buffer[0] do -- 从最早的护盾BUF中删除arg
  2037. local buffer = obj.buffer[j]
  2038. --local conf = BufferExcel.buffer[buffer.id]
  2039. local conf = GetBuffConfig(buffer.id)
  2040. local bufferCmd = conf.cmd
  2041. if bufferCmd == "hudun" then
  2042. local have = buffer.arg
  2043. if have > -value then
  2044. buffer.arg = have + value
  2045. else
  2046. subVal = subVal + have
  2047. buffer.arg = 0
  2048. local bufferCnt = delBuffer(obj, j)
  2049. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  2050. break
  2051. end
  2052. end
  2053. end
  2054. if subVal < 0 then
  2055. for j = 1 , obj.buffer[0] do
  2056. local buffer = obj.buffer[j]
  2057. --local conf = BufferExcel.buffer[buffer.id]
  2058. local conf = GetBuffConfig(buffer.id)
  2059. local bufferCmd = conf.cmd
  2060. if bufferCmd == "hudun1" then
  2061. buffer.arg = buffer.arg + subVal
  2062. subVal = buffer.arg
  2063. if subVal >= 0 then
  2064. break
  2065. end
  2066. if subVal < 0 then
  2067. buffer.arg = 0
  2068. local bufferCnt = delBuffer(obj, j)
  2069. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  2070. end
  2071. end
  2072. end
  2073. end
  2074. end
  2075. end
  2076. end
  2077. end
  2078. BUFFER_COMBAT_TYPE = nil
  2079. function initCombatBufferType()
  2080. if BUFFER_COMBAT_TYPE then return end
  2081. BUFFER_COMBAT_TYPE = {}
  2082. for k,conf in pairs(BufferExcel.qusan) do
  2083. if conf then
  2084. BUFFER_COMBAT_TYPE[conf.buffcmd] = conf.type
  2085. end
  2086. end
  2087. end
  2088. --
  2089. function getCombatBufferCnt(target, qusanType)
  2090. initCombatBufferType()
  2091. local buffCnt = 0
  2092. for i = target.buffer[0], 1, -1 do
  2093. local buffer = target.buffer[i]
  2094. --local conf = BufferExcel.buffer[buffer.id]
  2095. local conf = GetBuffConfig(buffer.id)
  2096. local cmd = conf.cmd
  2097. if conf.skillbufftype == 1 and BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  2098. buffCnt = buffCnt + 1
  2099. end
  2100. end
  2101. return buffCnt
  2102. end
  2103. --抵抗
  2104. QUSAN_CMD2KEY = {
  2105. ["zuzhou"] = RoleDefine.STATUS_DIKANG_RATE9,
  2106. }
  2107. function qusan(target, qusanType,cnt)
  2108. if target.isPet or not qusanType then
  2109. return 0
  2110. end
  2111. initCombatBufferType()
  2112. local state = false
  2113. local delIndex = {}
  2114. for i = target.buffer[0], 1, -1 do
  2115. local buffer = target.buffer[i]
  2116. --local conf = BufferExcel.buffer[buffer.id]
  2117. local conf = GetBuffConfig(buffer.id)
  2118. local cmd = conf.cmd
  2119. if conf.noQusan ~= 1 and conf.skillbufftype ~= 0 then
  2120. if BUFFER_COMBAT_TYPE[cmd] and BUFFER_COMBAT_TYPE[cmd] == qusanType then
  2121. local isDiKang = nil
  2122. local key = QUSAN_CMD2KEY[cmd]
  2123. local r = math.random(1,10000)
  2124. if key and target.attr[key] >= r then
  2125. isDiKang = true
  2126. end
  2127. if not isDiKang then
  2128. delIndex[#delIndex + 1] = i
  2129. end
  2130. elseif cmd == "attr" or cmd == "attrdne" or cmd == "attr2" then
  2131. if conf.args and conf.args[1][2] < 0 and qusanType == 1 then
  2132. delIndex[#delIndex + 1] = i
  2133. elseif conf.args and conf.args[1][2] > 0 and qusanType == 2 then
  2134. delIndex[#delIndex + 1] = i
  2135. end
  2136. end
  2137. end
  2138. end
  2139. cnt = cnt or 0
  2140. if cnt > 0 and cnt < #delIndex then
  2141. for i = cnt + 1,#delIndex do
  2142. delIndex[i] = nil
  2143. end
  2144. end
  2145. for k,v in ipairs(delIndex) do
  2146. local buffer = target.buffer[v]
  2147. if not buffer then break end
  2148. local bufferCnt = delBuffer(target, v)
  2149. CombatImpl.addFrameBuffer(target,buffer,CombatDefine.BUFFER_OP_DEL)
  2150. end
  2151. return #delIndex
  2152. end
  2153. function qusanAddBuff(attacker, targets, bufferID)
  2154. for _,target in ipairs(targets) do
  2155. if canAdd(target,bufferID) then
  2156. addBuffer(attacker.pos, target, bufferID)
  2157. end
  2158. end
  2159. end
  2160. function beforeUpdateHp(obj,sum, nAddNum, nDelHP)
  2161. local isLianjie, Lianjie2Cmd, index = isStatus(obj,{"lianjie3"})
  2162. if isLianjie then
  2163. local buffer = obj.buffer[index]
  2164. local conf = GetBuffConfig(buffer.id)
  2165. if handler[conf.cmd] then
  2166. handler[conf.cmd](obj, nil, nil, nAddNum)
  2167. end
  2168. end
  2169. local isStatus,cmd,ind = isStatus(obj,{"miansi","waitMiansi"})
  2170. if not isStatus then
  2171. return
  2172. end
  2173. --免死逻辑
  2174. if cmd == "miansi" then
  2175. return true
  2176. end
  2177. if sum == 0 and cmd == "waitMiansi" then
  2178. local buffer = obj.buffer[ind]
  2179. local bufferCnt = delBuffer(obj, ind)
  2180. CombatImpl.addFrameBuffer(obj,buffer,CombatDefine.BUFFER_OP_DEL)
  2181. --local conf = BufferExcel.buffer[buffer.id]
  2182. local conf = GetBuffConfig(buffer.id)
  2183. local bufferID = conf.args[1]
  2184. if canAdd(obj,bufferID) then
  2185. addBuffer(obj.pos,obj, bufferID)
  2186. end
  2187. return true
  2188. end
  2189. end
  2190. function checkBaohu(obj,value)
  2191. local isStatus,cmd,ind = isStatus(obj,{"baohu"})
  2192. if not isStatus then
  2193. return value
  2194. end
  2195. local buffer = obj.buffer[ind]
  2196. local attackPos = buffer.attackPos
  2197. local attacker = CombatImpl.objList[attackPos]
  2198. if attacker.hp <= 0 then
  2199. return value
  2200. end
  2201. value = BeSkill.onCheckBuffer(attacker,obj,value)
  2202. return value
  2203. end
  2204. function onExtraCombatRecord(pos,value,param)
  2205. local obj = CombatObj.getObjByPos(pos)
  2206. if not obj then return end
  2207. obj.extraCombatRecord = obj.extraCombatRecord or {}
  2208. if param == "zhongdu" then
  2209. obj.extraCombatRecord.zhongdu = (obj.extraCombatRecord.zhongdu or 0) + value
  2210. elseif param == "liuxue" then
  2211. obj.extraCombatRecord.liuxue = (obj.extraCombatRecord.liuxue or 0) + value
  2212. elseif param == "ranshao" then
  2213. obj.extraCombatRecord.ranshao = (obj.extraCombatRecord.ranshao or 0) + value
  2214. elseif param == "xuanyun" or param == "xuanyun2" then
  2215. obj.extraCombatRecord.xuanyun = (obj.extraCombatRecord.xuanyun or 0) + value
  2216. elseif param == "revive" then
  2217. obj.extraCombatRecord.revive = (obj.extraCombatRecord.revive or 0) + value
  2218. elseif param == "reviveBeUse" then
  2219. obj.extraCombatRecord.reviveBeUse = (obj.extraCombatRecord.reviveBeUse or 0) + value
  2220. elseif param == "kill" then
  2221. obj.extraCombatRecord.kill = (obj.extraCombatRecord.kill or 0) + value
  2222. elseif param == "chenshui" then
  2223. obj.extraCombatRecord.chenshui = (obj.extraCombatRecord.chenshui or 0) + value
  2224. elseif param == "donghe" then
  2225. obj.extraCombatRecord.donghe = (obj.extraCombatRecord.donghe or 0) + value
  2226. elseif param == "gandian" then
  2227. obj.extraCombatRecord.gandian = (obj.extraCombatRecord.gandian or 0) + value
  2228. end
  2229. end