CombatBuff.lua 71 KB

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