CombatBuff.lua 77 KB

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