CombatBuff.lua 80 KB

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