CombatBuff.lua 73 KB

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