CombatBuff.lua 71 KB

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