BeSkill.lua 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522
  1. local Util = require("common.Util")
  2. local CombatBuff = require("combat.CombatBuff")
  3. local CombatDefine = require("combat.CombatDefine")
  4. local CombatImpl = require("combat.CombatImpl")
  5. local Skill = require("combat.Skill")
  6. local CombatObj = require("combat.CombatObj")
  7. local RoleAttr = require("role.RoleAttr")
  8. local RoleDefine = require("role.RoleDefine")
  9. local HeroExcel = require("excel.hero").hero
  10. local SkillExcel = require("excel.skill").skill
  11. -- local BufferExcel = require("excel.buffer").buffer
  12. local FuwenExcel = require("excel.fuwen")
  13. local SkinSkillExcel = require("excel.skin").skill
  14. local BingshuLogic = require("fuwen.BingshuLogic")
  15. local ProjectLogic = require("platform.ProjectLogic")
  16. local HeroDefine = require("hero.HeroDefine")
  17. local WinnerRelicLogic = require("winnerRelic.WinnerRelicLogic")
  18. local TargetMode = require("combat.TargetMode")
  19. local HeroExclusiveWeapon = require("hero.HeroExclusiveWeapon")
  20. local tbFuwenSkillGroupID = {}
  21. local posSortBySpeed = posSortBySpeed or {}
  22. function initBeSkill(obj)
  23. obj.beSkillList = {}
  24. obj.beSkillListTemp = {}
  25. end
  26. function setBeSkillID(obj, skillID, isFuWenSkill, isRelicSkill)
  27. local skillConfig = Skill.GetFinalSkillConfig(obj, skillID)
  28. skillID = skillConfig.id
  29. if obj.beSkillListTemp[skillID] then return end
  30. --local skillConfig = SkillExcel[skillID]
  31. if skillConfig.need > obj.quality then return end
  32. if skillConfig.beSkillType == 0 then return end
  33. if skillConfig.beSkillType == BESKILL_TYPE24 then
  34. obj.beSkillListTemp[BESKILL_TYPE24] = obj.beSkillListTemp[BESKILL_TYPE24] or {}
  35. obj.beSkillListTemp[BESKILL_TYPE24][#obj.beSkillListTemp[BESKILL_TYPE24] + 1] = {
  36. skillID,
  37. skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,
  38. skillConfig.cd[2] or 0,
  39. isFuWenSkill or 0, isRelicSkill or 0}
  40. for _,skillID in ipairs(skillConfig.args) do
  41. --local skillConfig = SkillExcel[skillID]
  42. local skillConfig = Skill.GetFinalSkillConfig(obj, skillID)
  43. if not obj.beSkillListTemp[skillID] and skillConfig.need <= obj.quality then
  44. obj.beSkillList[skillConfig.beSkillType] = obj.beSkillList[skillConfig.beSkillType] or {}
  45. obj.beSkillList[skillConfig.beSkillType][#obj.beSkillList[skillConfig.beSkillType] + 1] = {
  46. skillID,
  47. skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,
  48. skillConfig.cd[2] or 0,
  49. isFuWenSkill or 0, isRelicSkill or 0}
  50. obj.beSkillListTemp[skillID] = 1
  51. end
  52. end
  53. else
  54. obj.beSkillList[skillConfig.beSkillType] = obj.beSkillList[skillConfig.beSkillType] or {}
  55. obj.beSkillList[skillConfig.beSkillType][#obj.beSkillList[skillConfig.beSkillType] + 1] = {
  56. skillID,
  57. skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,
  58. skillConfig.cd[2] or 0,
  59. isFuWenSkill or 0, isRelicSkill or 0}
  60. obj.beSkillListTemp[skillID] = 1
  61. end
  62. end
  63. function setBeSkill(obj, config, skinConf, monsterOutConfig)
  64. local temp = {}
  65. local confBeskillID = skinConf and skinConf.beSkillList or config.beSkillList
  66. for _,skillID in ipairs(confBeskillID) do
  67. setBeSkillID(obj,skillID)
  68. end
  69. -- 加载 赋能技能 这个策划说放到最后
  70. if config.bePvPSkillList and CombatImpl.isPVP == 1 then
  71. for _,skillID in ipairs(config.bePvPSkillList) do
  72. setBeSkillID(obj, skillID)
  73. end
  74. end
  75. -- 怪物组附加的被动技能
  76. if monsterOutConfig then
  77. for _, skillID in ipairs(monsterOutConfig) do
  78. setBeSkillID(obj,skillID)
  79. end
  80. end
  81. -- 符文被动技能
  82. -- 符文技能效果这里 如果有多个同类型的技能 效果不叠加 只取最高等级的那个技能的效果
  83. if obj.fuwen or obj.bingshu then
  84. local hasFuwenBeSkill = nil
  85. Util.initTable(tbFuwenSkillGroupID)
  86. if obj.fuwen then
  87. for i = 1, 2 do
  88. local fuwenGrid = obj.fuwen[i]
  89. if fuwenGrid and fuwenGrid.skill then
  90. for j = 1, #fuwenGrid.skill do
  91. local fuwenSkillID = fuwenGrid.skill[j]
  92. local fuwenSkillConfig = FuwenExcel.skill[fuwenSkillID]
  93. local fuwenGroupID = fuwenSkillConfig.groupID
  94. if fuwenSkillConfig.fuwenBeSkill ~= 0 then
  95. hasFuwenBeSkill = true
  96. if tbFuwenSkillGroupID[fuwenGroupID] then
  97. if tbFuwenSkillGroupID[fuwenGroupID] < fuwenSkillID then
  98. tbFuwenSkillGroupID[fuwenGroupID] = fuwenSkillID
  99. end
  100. else
  101. tbFuwenSkillGroupID[fuwenGroupID] = fuwenSkillID
  102. end
  103. end
  104. end
  105. end
  106. end
  107. end
  108. if obj.bingshu then
  109. for i = 1, BingshuLogic.BINGSHU_MAXCNT do
  110. local bingshuGrid = obj.bingshu[i]
  111. if bingshuGrid then
  112. local skillID = bingshuGrid.skillID
  113. local skillConfig = FuwenExcel.skill[skillID]
  114. local groupID = skillConfig.groupID
  115. hasFuwenBeSkill = true
  116. if (tbFuwenSkillGroupID[groupID] or 0) < skillID then
  117. tbFuwenSkillGroupID[groupID] = skillID
  118. end
  119. end
  120. end
  121. end
  122. if hasFuwenBeSkill == true then
  123. for groupID, skillIDTemp in pairs(tbFuwenSkillGroupID) do
  124. local fuwenSkillConfig = FuwenExcel.skill[skillIDTemp]
  125. local fuwenBeSkillID = fuwenSkillConfig.fuwenBeSkill
  126. fuwenBeSkillID = obj.fuwenStrengthenSkillList and obj.fuwenStrengthenSkillList[fuwenBeSkillID] or fuwenBeSkillID
  127. setBeSkillID(obj,fuwenBeSkillID, 1)
  128. end
  129. end
  130. end
  131. --遗物被动技能
  132. if obj.relic and nil ~= _G.next(obj.relic) then
  133. local nRelicID = obj.relic.relicID
  134. local star = obj.relic.star
  135. local nSkillID = WinnerRelicLogic.WinnerRelic_GetSkillID(nRelicID, star)
  136. if 0 < nSkillID then
  137. setBeSkillID(obj, nSkillID, 0, 1)
  138. local tSkilConfig = SkillExcel and SkillExcel[nSkillID]
  139. if tSkilConfig and tSkilConfig.otherArgs and tSkilConfig.otherArgs.skillList then
  140. for k,v in ipairs(tSkilConfig.otherArgs.skillList) do
  141. local config = SkillExcel[v]
  142. if config and config.id then
  143. setBeSkillID(obj, config.id, 0, 1)
  144. end
  145. end
  146. end
  147. end
  148. end
  149. -- 神威灵装被动技能
  150. if obj.artifactsBeSkillList then
  151. for _, skillId in ipairs(obj.artifactsBeSkillList) do
  152. setBeSkillID(obj, skillId)
  153. end
  154. end
  155. end
  156. function setPetBeSkill(obj)
  157. --if obj
  158. --local skillConfig = SkillExcel[1999]
  159. local skillConfig = Skill.GetSkillConfig(1999)
  160. if skillConfig then
  161. obj.beSkillList = obj.beSkillList or {}
  162. obj.beSkillList[skillConfig.beSkillType] = obj.beSkillList[skillConfig.beSkillType] or {}
  163. obj.beSkillList[skillConfig.beSkillType][#obj.beSkillList[skillConfig.beSkillType] + 1] = {1999,skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,skillConfig.cd[2] or 0}
  164. end
  165. end
  166. --被动技能类型
  167. BESKILL_TYPE1 = 1 --普攻附带
  168. BESKILL_TYPE2 = 2 --被击触发
  169. BESKILL_TYPE3 = 3 --自身生命低于参数
  170. BESKILL_TYPE4 = 4 --自己暴击触发
  171. BESKILL_TYPE5 = 5 --受到技能伤害
  172. BESKILL_TYPE6 = 6 --自己攻击被格挡
  173. BESKILL_TYPE7 = 7 --受到暴击触发
  174. BESKILL_TYPE8 = 8 --自己格挡触发(其他单位对自己发动攻击,自己触发格挡)
  175. BESKILL_TYPE9 = 9 --敌方英雄触发格挡
  176. BESKILL_TYPE10 = 10 --自己受持续状态伤害
  177. BESKILL_TYPE11 = 11 --自己受控制类状态
  178. BESKILL_TYPE12 = 12 --场上有英雄被添加燃烧状态
  179. BESKILL_TYPE13 = 13 -- 我方英雄施放主动技能
  180. BESKILL_TYPE14 = 14 -- 我方英雄暴击
  181. BESKILL_TYPE15 = 15 -- 自己死亡
  182. BESKILL_TYPE16 = 16 --我方英雄死亡
  183. BESKILL_TYPE17 = 17 --敌方英雄死亡
  184. BESKILL_TYPE18 = 18 --有英雄死亡
  185. BESKILL_TYPE19 = 19 --回合开始
  186. BESKILL_TYPE20 = 20 --回合结束
  187. BESKILL_TYPE23 = 23 --激活就生效(计入面板属性)
  188. BESKILL_TYPE24 = 24 --技能包
  189. BESKILL_TYPE25 = 25 --替换初始普攻
  190. BESKILL_TYPE26 = 26 --激活就生效(进入战斗前算。不计入面板属性)
  191. BESKILL_TYPE27 = 27 --魔兽回能量被动
  192. BESKILL_TYPE28 = 28 --自身触发格挡次数
  193. BESKILL_TYPE29 = 29 --有人受到缠绕时
  194. BESKILL_TYPE30 = 30 --使生命低于x时
  195. BESKILL_TYPE31 = 31 --任意英雄释放主动技能
  196. BESKILL_TYPE32 = 32 --战斗开始时触发
  197. BESKILL_TYPE33 = 33 --复活时触发
  198. BESKILL_TYPE34 = 34 --使用主动技能时
  199. BESKILL_TYPE35 = 35 --自身击杀敌人时
  200. BESKILL_TYPE36 = 36 --攻击回合结束时触发
  201. BESKILL_TYPE37 = 37 --物攻后触发
  202. BESKILL_TYPE38 = 38 --法攻后触发
  203. BESKILL_TYPE39 = 39 --攻击附带 (普攻 主动 都算)
  204. BESKILL_TYPE40 = 40 --攻击前根据条件判断是否触发(小战斗回合,针对每个对象单独判断)
  205. BESKILL_TYPE41 = 41 --实际扣血前触发
  206. BESKILL_TYPE42 = 42 --由其他英雄的buff触发
  207. BESKILL_TYPE43 = 43 --被某个技能打死
  208. BESKILL_TYPE44 = 44 --自己暴击+反击触发
  209. BESKILL_TYPE45 = 45 --计算伤害时触发
  210. BESKILL_TYPE46 = 46 --攻击附带 (普攻 主动 连击 反击都算)
  211. BESKILL_TYPE47 = 47 --每回合叠加属性
  212. BESKILL_TYPE48 = 48 --死亡英雄伤害率
  213. BESKILL_TYPE49 = 49 --加血变成减血
  214. BESKILL_TYPE50 = 50 --每回合触发 降低对方首次攻击目标伤害率
  215. BESKILL_TYPE51 = 51 --场上有英雄被添加诅咒状态
  216. BESKILL_TYPE52 = 52 --场上有英雄被攻击
  217. BESKILL_TYPE53 = 53 --场上有英雄有特定被动技能 友军普攻触发
  218. BESKILL_TYPE54 = 54 --场上有英雄特定buff 伤害加成
  219. BESKILL_TYPE55 = 55 --场上有英雄指定buff层数 额外伤害加成
  220. BESKILL_TYPE56 = 56 --场上有英雄特定bufer且概率产生
  221. BESKILL_TYPE57 = 57 --特定buff被引爆消除时 触发的效果
  222. BESKILL_TYPE58 = 58 --指定技能暴击
  223. BESKILL_TYPE59 = 59 --没有暴击触发一个效果
  224. BESKILL_TYPE60 = 60 --暴击加成
  225. BESKILL_TYPE61 = 61 --技能未击杀目标时触发
  226. BESKILL_TYPE62 = 62 --回合开始生命值触发
  227. BESKILL_TYPE63 = 63 --回合开始生命值触发
  228. BESKILL_TYPE64 = 64 --冰冻buffer被击碎
  229. BESKILL_TYPE65 = 65 --场上有英雄有特定被动技能 友军普攻暴击触发
  230. BESKILL_TYPE66 = 66 --敌方死亡特定buff触发
  231. BESKILL_TYPE67 = 67 --血量低于多少跟受控制触发
  232. BESKILL_TYPE68 = 68 --血族英雄特殊处理
  233. BESKILL_TYPE69 = 69 --血族英雄特殊处理
  234. BESKILL_TYPE70 = 70 --增加的属性激活就生效(计入面板属性)并且概率连击
  235. BESKILL_TYPE71 = 71 --回合开始 在其他buff添加结束
  236. BESKILL_TYPE72 = 72 -- 不施放技能,只用来做其他效果的判断条件
  237. BESKILL_TYPE73 = 73 --使用技能(包括普攻技能)命中敌方且造成伤害
  238. NO_CHECK_FANJI_LIST = {
  239. [BESKILL_TYPE3] = 1,
  240. [BESKILL_TYPE15] = 1,
  241. [BESKILL_TYPE16] = 1,
  242. [BESKILL_TYPE17] = 1,
  243. [BESKILL_TYPE18] = 1,
  244. [BESKILL_TYPE35] = 1,
  245. [BESKILL_TYPE36] = 1,
  246. [BESKILL_TYPE37] = 1,
  247. [BESKILL_TYPE38] = 1,
  248. [BESKILL_TYPE44] = 1,
  249. [BESKILL_TYPE46] = 1,
  250. [BESKILL_TYPE73] = 1,
  251. }
  252. NO_CHECK_COMBO_LIST = {
  253. [BESKILL_TYPE1] = 1,
  254. [BESKILL_TYPE3] = 1,
  255. [BESKILL_TYPE14] = 1,
  256. [BESKILL_TYPE16] = 1,
  257. [BESKILL_TYPE17] = 1,
  258. [BESKILL_TYPE18] = 1,
  259. [BESKILL_TYPE35] = 1,
  260. [BESKILL_TYPE34] = 1,
  261. [BESKILL_TYPE25] = 1,
  262. [BESKILL_TYPE46] = 1,
  263. [BESKILL_TYPE37] = 1,
  264. [BESKILL_TYPE38] = 1,
  265. [BESKILL_TYPE43] = 1,
  266. [BESKILL_TYPE15] = 1,
  267. [BESKILL_TYPE73] = 1,
  268. }
  269. local function checkLimit(data)
  270. if data[2] and data[2] <= 0 then
  271. return
  272. end
  273. if data[4] > 0 and data[3] > CombatImpl.round then
  274. return
  275. end
  276. return true
  277. end
  278. local function canUse(obj,data)
  279. if obj.isPet then
  280. return true
  281. end
  282. --被动技能次数限制判断
  283. if not checkLimit(data) then
  284. return
  285. end
  286. --local skillConfig = SkillExcel[data[1]]
  287. local skillConfig = Skill.GetSkillConfig(data[1])
  288. if not NO_CHECK_FANJI_LIST[skillConfig.beSkillType] and CombatImpl.isFanji then
  289. return
  290. end
  291. if not NO_CHECK_COMBO_LIST[skillConfig.beSkillType] and CombatImpl.comboType > 0 then
  292. return
  293. end
  294. local bNotFeng = nil
  295. -- boss 被动不能被封印
  296. -- 世界boss模式下 boss不受feng状态影响
  297. if CombatImpl.fightMode[1] == CombatDefine.FIGHT_MODE3 then
  298. if obj.type == CombatDefine.COMBAT_OBJ_TYPE3 then
  299. bNotFeng = true
  300. end
  301. end
  302. if not bNotFeng and CombatBuff.isStatus(obj,{"banBeSkill","feng"}) then
  303. return
  304. end
  305. data[3] = data[3] + data[4]
  306. local beSkillArgs = skillConfig.beSkillArgs
  307. local ret = true
  308. --被动技能触发条件判断
  309. if beSkillArgs[1] then
  310. if beSkillArgs[1] == "hp" then
  311. local hp = obj.hp
  312. local hpMax = CombatObj.getHpMax(obj)
  313. if hp > hpMax * beSkillArgs[2]/10000 then
  314. ret = false
  315. end
  316. elseif beSkillArgs[1] == "hpOrControl" then
  317. ret = false
  318. local hp = obj.hp
  319. local hpMax = CombatObj.getHpMax(obj)
  320. if hp <= hpMax * beSkillArgs[2]/10000 then
  321. ret = true
  322. end
  323. if CombatBuff.isAtControl(obj) then
  324. ret = true
  325. end
  326. elseif beSkillArgs[1] == "fanji" then
  327. local r = math.random(0,10000)
  328. if r > beSkillArgs[2] then
  329. return
  330. end
  331. elseif beSkillArgs[1] == "pos" then
  332. local pos = obj.pos
  333. ret = false
  334. if beSkillArgs[2] then
  335. for i = 1,#beSkillArgs[2] do
  336. if pos == beSkillArgs[2][i] then
  337. ret = true
  338. break
  339. end
  340. end
  341. end
  342. elseif beSkillArgs[1] == "noBuffCmd" then
  343. return not CombatBuff.isStatus(obj,beSkillArgs[2])
  344. elseif beSkillArgs[1] == "attackerBuffCmd" then
  345. local isStatus,cmd = CombatBuff.isStatus(obj,beSkillArgs[2])
  346. return isStatus
  347. elseif beSkillArgs[1] == "myjob" then
  348. ret = false
  349. for k,v in ipairs(beSkillArgs[2]) do
  350. if v == obj.job then
  351. ret = true
  352. break
  353. end
  354. end
  355. elseif beSkillArgs[1] == "sideLimit" then
  356. for k,v in ipairs(beSkillArgs[2]) do
  357. local useCnt = CombatImpl.getBeSkillSideUse(obj.pos,v[1])
  358. if useCnt >= v[2] then
  359. return
  360. end
  361. end
  362. elseif beSkillArgs[1] == "firstAttackOrder" then
  363. local side = obj.side
  364. if side then
  365. local isFirstAttack = CombatImpl.firstAttack[side]
  366. if beSkillArgs[2] == 1 then
  367. return isFirstAttack
  368. else
  369. return not isFirstAttack
  370. end
  371. end
  372. end
  373. end
  374. if ret and data[2] then
  375. data[2] = data[2] - 1
  376. end
  377. if skillConfig.cmd == "hp" then
  378. local hp = obj.hp
  379. local targetMode = skillConfig.args[3]
  380. --英雄血量为0时不能加血
  381. if (hp <= 0 or CombatBuff.isStatus(obj,{"revive"})) and targetMode and targetMode[1] == 10 then
  382. ret = false
  383. end
  384. end
  385. return ret
  386. end
  387. --被攻击触发,需要判断攻击者状态的被动技能
  388. local function canUseOnHit(obj,data)
  389. if not obj then
  390. return true
  391. end
  392. --local skillConfig = SkillExcel[data[1]]
  393. local skillConfig = Skill.GetSkillConfig(data[1])
  394. local beSkillArgs = skillConfig.beSkillArgs
  395. local condCmd = beSkillArgs[1]
  396. if condCmd == "job" then
  397. for _,job in ipairs(beSkillArgs[2]) do
  398. if obj.job == job then
  399. return true
  400. end
  401. end
  402. return false
  403. elseif condCmd == "buffCmd" then
  404. return CombatBuff.isStatus(obj,beSkillArgs[2])
  405. elseif condCmd == "targetHp" then
  406. local hp = obj.hp
  407. local checkHp = CombatObj.getHpMax(obj) * beSkillArgs[3] / 10000
  408. if beSkillArgs[2] == 1 and hp > checkHp then
  409. return true
  410. elseif beSkillArgs[2] == 2 and hp < checkHp then
  411. return true
  412. end
  413. else
  414. return true
  415. end
  416. end
  417. local function isCanRevive(obj, attacker , data)
  418. -- local skillConfig = SkillExcel[data[1]]
  419. local skillConfig = Skill.GetSkillConfig(data[1])
  420. if skillConfig.cmd == "shengling" or
  421. skillConfig.cmd == "revive" then
  422. if skillConfig.cmd == "shengling" and CombatImpl.checkSideResult(obj.pos) == true then -- 如果是队伍最后一个死亡的不释放 圣灵复活
  423. return false
  424. end
  425. if CombatBuff.canRevive(obj) ~= true then
  426. return false
  427. end
  428. if skillConfig.cmd == "shengling" then
  429. if CombatBuff.isStatus(obj,{"revive"}) then
  430. return false
  431. end
  432. end
  433. if attacker and attacker.beSkillList then
  434. for k,skillList in pairs(attacker.beSkillList) do
  435. for j,v in pairs(skillList) do
  436. --local config = SkillExcel[v[1]]
  437. local config = Skill.GetSkillConfig(data[1])
  438. if config and skillConfig.cmd == "shengling" and config.cmd == "noShengling" then --击杀方有 不准圣灵复活被动
  439. return false
  440. elseif config and config.cmd == "noRevive" then -- 击杀方 有不准复活的
  441. if #config.args > 0 then
  442. local canNum = config.args[1]
  443. local random = math.random(1, 10000)
  444. if random > canNum then -- noRevive 概率不生效
  445. return true
  446. else
  447. return false
  448. end
  449. end
  450. return true
  451. end
  452. end
  453. end
  454. end
  455. end
  456. return true
  457. end
  458. -- 连击检测
  459. local function comboCheck(targetObj, side)
  460. if Skill.GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  461. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  462. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  463. local obj = CombatImpl.objList[pos]
  464. if obj and obj.beSkillList then
  465. for _, skillInfo in ipairs(obj.beSkillList[BESKILL_TYPE72] or {}) do
  466. local skillCfg = Skill.GetSkillConfig(skillInfo[1])
  467. if skillCfg and skillCfg.cmd == "comboProb" then
  468. local targetType = skillCfg.beSkillArgs[2] or 0
  469. local targetList = skillCfg.beSkillArgs[3]
  470. if targetType <= 0 or not targetList then
  471. return
  472. end
  473. local bl = false
  474. if targetType == 1 then -- 职业
  475. if table.find(targetList, targetObj.job) then
  476. bl = true
  477. end
  478. elseif targetType == 2 then -- 种族
  479. if table.find(targetList, targetObj.camp) then
  480. bl = true
  481. end
  482. end
  483. if not bl then return end
  484. local comboProbVal = skillCfg.beSkillArgs[1] or 0
  485. local randval = math.random(0, 10000)
  486. if comboProbVal >= randval then
  487. CombatImpl.comboList[#CombatImpl.comboList + 1] = {targetObj, 1}
  488. end
  489. end
  490. end
  491. end
  492. end
  493. end
  494. -- 是否触发灭魂
  495. local function triggerMieHunCheck(targetPos)
  496. local attacker = CombatImpl.objList[targetPos]
  497. if not attacker then
  498. return
  499. end
  500. if attacker.beSkillList[BESKILL_TYPE72] then
  501. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE72]) do
  502. --local skillConfig = SkillExcel[v[1]]
  503. local skillConfig = Skill.GetSkillConfig(v[1])
  504. if skillConfig.cmd == "miehun" then
  505. local triggerVal, banRound = skillConfig.args[1] or 0, skillConfig.args[2] or 0
  506. if banRound <= 0 then
  507. return
  508. end
  509. local r = math.random(0, 10000)
  510. if triggerVal >= r then
  511. return true, banRound
  512. end
  513. end
  514. end
  515. end
  516. end
  517. function onSkillID(obj,skillID)
  518. --local skillConfig = SkillExcel[skillID]
  519. local skillConfig = Skill.GetSkillConfig(skillID)
  520. if skillConfig.type == CombatDefine.SKILL_TYPE1 and obj.beSkillList[BESKILL_TYPE25] then
  521. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE25]) do
  522. if canUse(obj,v) then
  523. --local conf = SkillExcel[v[1]]
  524. local conf = Skill.GetSkillConfig(v[1])
  525. return conf.args[1]
  526. end
  527. end
  528. end
  529. return skillID
  530. end
  531. local function use(attacker,targets,data,newFrame, packBuff, hitObj)
  532. if canUse(attacker,data) and canUseOnHit(targets and targets[1],data) then
  533. --print("beskill realuse:",attacker.pos,data[1])
  534. --local skillConfig = SkillExcel[data[1]]
  535. local skillConfig = Skill.GetSkillConfig(data[1])
  536. local ret, arg2
  537. -- 二次元连击触发帧不新加帧
  538. if ProjectLogic.isSsecy() and skillConfig.cmd == "combo" then
  539. newFrame = false
  540. end
  541. if packBuff then
  542. CombatImpl.afterBuff()
  543. end
  544. if Skill.CMD[skillConfig.cmd] then
  545. if newFrame or CombatImpl.isSkillFrameEmpty() then
  546. --进入战斗时,未加入任何战斗帧触发被动技能时,先添加被动技能的战斗帧,可以在这个战斗帧上挂被动技能引发的额外作用
  547. CombatImpl.addFrame()
  548. CombatImpl.setSkillID(attacker, data[1])
  549. end
  550. ret, arg2 = Skill.CMD[skillConfig.cmd](attacker,skillConfig,targets, hitObj)
  551. end
  552. --判断是否加喊话
  553. local isAddSkillFrame = CombatBuff.onUseBeSkill(attacker, skillConfig, targets, ret, nil, arg2)
  554. if skillConfig.contentType > 0 then
  555. if isAddSkillFrame then
  556. CombatImpl.addSaySkill(attacker,skillConfig)
  557. elseif ret or skillConfig.beSkillType == BESKILL_TYPE26 or
  558. skillConfig.beSkillType == BESKILL_TYPE23 or
  559. skillConfig.beSkillType == BESKILL_TYPE4 or
  560. skillConfig.beSkillType == BESKILL_TYPE44 then
  561. if CombatImpl.isSkillFrameEmpty() then
  562. CombatImpl.addFrame()
  563. CombatImpl.setSkillID(attacker, data[1])
  564. end
  565. CombatImpl.setSaySkill(attacker.pos,skillConfig.id,skillConfig.contentType)
  566. end
  567. end
  568. CombatImpl.addBeSkillPosUse(attacker.pos,data[1])
  569. else
  570. -- print("[beskill - use] 直接返回了1 id = "..data[1])
  571. end
  572. end
  573. function onHit(attacker,targets,skillID)
  574. if attacker.isPet or attacker.isElf then
  575. return
  576. end
  577. --local useSkillConfig = SkillExcel[skillID]
  578. local useSkillConfig = Skill.GetSkillConfig(skillID)
  579. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 then
  580. --[[for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  581. local obj = CombatImpl.objList[pos]
  582. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE13] then
  583. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE13]) do
  584. use(obj,targets,v)
  585. end
  586. end
  587. end]]
  588. if attacker.beSkillList[BESKILL_TYPE34] then
  589. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE34]) do
  590. --local skillConfig = SkillExcel[v[1]]
  591. local skillConfig = Skill.GetSkillConfig(v[1])
  592. local beSkillArgs = skillConfig.beSkillArgs
  593. if beSkillArgs[1] == "attackerBuffCmd" and beSkillArgs[2][1] == "shayi" then
  594. local shayiCnt = CombatBuff.getBuffCnt(attacker,"shayi")
  595. if shayiCnt > 0 then
  596. for i = 1,shayiCnt do
  597. use(attacker,targets,v,true)
  598. CombatImpl.instantFrameBuffer(attacker,v[1])
  599. end
  600. end
  601. CombatBuff.delShayi(attacker)
  602. elseif beSkillArgs[1] == "qusanNeedCmd" then
  603. local canUse = false
  604. for h,need in ipairs(beSkillArgs[2]) do
  605. if need == useSkillConfig.cmd then
  606. canUse = true
  607. break
  608. end
  609. end
  610. if canUse == true then
  611. use(attacker,targets,v,true)
  612. end
  613. elseif beSkillArgs[1] == "jiekongNeedCmd" then
  614. local canUse = false
  615. for h,need in ipairs(beSkillArgs[2]) do
  616. if need == useSkillConfig.cmd then
  617. canUse = true
  618. break
  619. end
  620. end
  621. if canUse == true then
  622. use(attacker,targets,v,true)
  623. end
  624. elseif beSkillArgs[1] == "skillID" then
  625. local canUse = false
  626. for _, targetSkill in ipairs(beSkillArgs[2]) do
  627. if skillID == targetSkill then
  628. canUse = true
  629. break
  630. end
  631. end
  632. if canUse == true then
  633. use(attacker,targets,v,true)
  634. end
  635. else
  636. use(attacker,targets,v)
  637. end
  638. end
  639. end
  640. end
  641. --非攻击性主动技能不处理被击被动技能
  642. if CombatObj.getValue(attacker,RoleDefine.HURT_COMBAT_NOW) <= 0 then
  643. if (useSkillConfig.type == CombatDefine.SKILL_TYPE1 or useSkillConfig.type == CombatDefine.SKILL_TYPE2) then
  644. if attacker.beSkillList[BESKILL_TYPE39] then
  645. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE39]) do
  646. use(attacker,targets,v)
  647. end
  648. end
  649. if attacker.beSkillList[BESKILL_TYPE70] then
  650. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE70]) do
  651. use(attacker,targets,v)
  652. end
  653. end
  654. end
  655. return
  656. end
  657. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 and attacker.beSkillList[BESKILL_TYPE1] then
  658. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE1]) do
  659. use(attacker,targets,v)
  660. end
  661. end
  662. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 and attacker.beSkillList[BESKILL_TYPE61] then
  663. local canUseSkill = true
  664. for index = 1, #targets do
  665. local target = targets[index]
  666. if target.hp <=0 then
  667. canUseSkill = false
  668. end
  669. end
  670. if canUseSkill then
  671. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE61]) do
  672. --local skillConfig = SkillExcel[v[1]]
  673. local skillConfig = Skill.GetSkillConfig(v[1])
  674. local beSkillArgs = skillConfig.beSkillArgs
  675. if beSkillArgs[1] == "skillID" then
  676. local canUse = false
  677. for _,v in ipairs(beSkillArgs[2]) do
  678. if skillID == v then
  679. canUse = true
  680. break
  681. end
  682. end
  683. if canUse then
  684. use(attacker,{},v)
  685. end
  686. end
  687. end
  688. end
  689. end
  690. if (useSkillConfig.type == CombatDefine.SKILL_TYPE1 or useSkillConfig.type == CombatDefine.SKILL_TYPE2 or useSkillConfig.type == CombatDefine.SKILL_TYPE3) then
  691. if attacker.beSkillList[BESKILL_TYPE39] then
  692. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE39]) do
  693. use(attacker,targets,v)
  694. end
  695. end
  696. if attacker.beSkillList[BESKILL_TYPE46] then
  697. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE46]) do
  698. use(attacker,targets,v)
  699. end
  700. end
  701. if attacker.beSkillList[BESKILL_TYPE70] then
  702. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE70]) do
  703. use(attacker,targets,v)
  704. end
  705. end
  706. end
  707. local isDefendSideGedang = false
  708. local baojiDefender = {}
  709. for _,target in ipairs(targets) do
  710. if target.beSkillList[BESKILL_TYPE2] then
  711. for _,v in ipairs(target.beSkillList[BESKILL_TYPE2]) do
  712. use(target,{attacker},v)
  713. -- print("當前受到攻擊,觸發被動技能11111111111111ssssssssss1111111111111111",skillID)
  714. --table.print_lua_table(v)
  715. end
  716. end
  717. -- 友军受击
  718. for _,pos in ipairs(CombatDefine.SIDE2POS[target.side]) do
  719. local obj = CombatImpl.objList[pos]
  720. if obj and obj.pos ~= target.pos and obj.beSkillList[BESKILL_TYPE52] then
  721. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE52]) do
  722. use(target,{attacker},v)
  723. end
  724. end
  725. end
  726. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 and target.beSkillList[BESKILL_TYPE5] then
  727. for _,v in ipairs(target.beSkillList[BESKILL_TYPE5]) do
  728. use(target,{attacker},v)
  729. end
  730. end
  731. if target.isGedang then
  732. isDefendSideGedang = true
  733. if target.beSkillList[BESKILL_TYPE8] then
  734. for _,v in ipairs(target.beSkillList[BESKILL_TYPE8]) do
  735. use(target,{attacker},v)
  736. end
  737. end
  738. if attacker.beSkillList[BESKILL_TYPE6] then
  739. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE6]) do
  740. use(attacker,{target},v)
  741. end
  742. end
  743. --目标触发格挡次数
  744. if target.beSkillList[BESKILL_TYPE28] then
  745. for _, v in ipairs(target.beSkillList[BESKILL_TYPE28]) do
  746. --local skillConfig = SkillExcel[v[1]]
  747. local skillConfig = Skill.GetSkillConfig(v[1])
  748. local beSkillArgs = skillConfig.beSkillArgs
  749. if beSkillArgs[1] == "gedang" then
  750. target.isGedangCnt = target.isGedangCnt or 0
  751. local geDangLimit = beSkillArgs[2]
  752. if target.isGedangCnt >= geDangLimit then
  753. target.isGedangCnt = 0
  754. use(target,{attacker},v)
  755. end
  756. end
  757. end
  758. end
  759. end
  760. local chanRao = CombatBuff.isChanRao(target)
  761. if chanRao then
  762. if target.beSkillList[BESKILL_TYPE29] then
  763. for _,v in ipairs(target.beSkillList[BESKILL_TYPE29]) do
  764. use(target,{attacker},v)
  765. end
  766. end
  767. end
  768. if target.isBaoji then
  769. if target.beSkillList[BESKILL_TYPE7] then
  770. for _,v in ipairs(target.beSkillList[BESKILL_TYPE7]) do
  771. use(target,{attacker},v)
  772. end
  773. end
  774. baojiDefender[#baojiDefender+1] = target
  775. end
  776. -- if target.buffCmd["winner_nuhuo"] then
  777. -- local nIndex = target.buffCmd["winner_nuhuo"][1]
  778. -- local tBuffData = target.buffer[nIndex]
  779. -- if tBuffData.cnt < 10 then
  780. -- tBuffData.cnt = tBuffData.cnt + 1
  781. -- end
  782. -- end
  783. end
  784. local side = attacker.side
  785. local defendSide = side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  786. local target = targets[1]
  787. if target and target.side == defendSide and CombatObj.getValue(attacker,RoleDefine.HURT_COMBAT_NOW) > 0 then
  788. if attacker.beSkillList[BESKILL_TYPE73] then
  789. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE73]) do
  790. use(attacker,targets,v)
  791. end
  792. end
  793. end
  794. --普通技能触发
  795. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 then
  796. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  797. local obj = CombatImpl.objList[pos]
  798. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE53] then
  799. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE53]) do
  800. use(attacker,targets,v)
  801. end
  802. end
  803. end
  804. end
  805. --主动技能触发
  806. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 then
  807. for _,pos in ipairs(CombatDefine.SIDE2POS[0]) do
  808. local obj = CombatImpl.objList[pos]
  809. local objSide = pos <= 6 and CombatDefine.ATTACK_SIDE or CombatDefine.DEFEND_SIDE
  810. --触发自己这方的
  811. if side == objSide then
  812. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE13] then
  813. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE13]) do
  814. use(obj,targets,v)
  815. end
  816. end
  817. end
  818. --触发任意一方
  819. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE31] then
  820. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE31]) do
  821. use(obj,targets,v)
  822. end
  823. end
  824. end
  825. end
  826. if not attacker.isBaoji then
  827. --指定技能没有暴击
  828. if attacker.beSkillList[BESKILL_TYPE59] then
  829. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE59]) do
  830. --local skillConfig = SkillExcel[v[1]]
  831. local skillConfig = Skill.GetSkillConfig(v[1])
  832. local beSkillArgs = skillConfig.beSkillArgs
  833. if beSkillArgs[1] == "skillID" then
  834. local canUse = false
  835. for _,v in ipairs(beSkillArgs[2]) do
  836. if skillID == v then
  837. canUse = true
  838. break
  839. end
  840. end
  841. if canUse then
  842. use(attacker,{},v)
  843. end
  844. end
  845. end
  846. end
  847. end
  848. if attacker.isBaoji then
  849. --普通暴击技能触发
  850. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 then
  851. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  852. local obj = CombatImpl.objList[pos]
  853. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE65] then
  854. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE65]) do
  855. use(attacker,targets,v)
  856. end
  857. end
  858. end
  859. end
  860. if attacker.beSkillList[BESKILL_TYPE4] then
  861. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE4]) do
  862. use(attacker,baojiDefender,v)
  863. end
  864. end
  865. if attacker.beSkillList[BESKILL_TYPE44] and CombatImpl.isFanji then
  866. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE44]) do
  867. use(attacker,baojiDefender,v)
  868. end
  869. end
  870. --指定技能暴击
  871. if attacker.beSkillList[BESKILL_TYPE58] then
  872. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE58]) do
  873. --local skillConfig = SkillExcel[v[1]]
  874. local skillConfig = Skill.GetSkillConfig(v[1])
  875. local beSkillArgs = skillConfig.beSkillArgs
  876. if beSkillArgs[1] == "skillID" then
  877. local canUse = false
  878. for _,v in ipairs(beSkillArgs[2]) do
  879. if skillID == v then
  880. canUse = true
  881. break
  882. end
  883. end
  884. if canUse then
  885. use(attacker,baojiDefender,v)
  886. end
  887. end
  888. end
  889. end
  890. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  891. local obj = CombatImpl.objList[pos]
  892. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE14] then
  893. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE14]) do
  894. use(obj,targets,v)
  895. end
  896. end
  897. end
  898. end
  899. if isDefendSideGedang then
  900. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  901. local obj = CombatImpl.objList[pos]
  902. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE9] then
  903. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE9]) do
  904. use(obj,targets,v)
  905. end
  906. end
  907. end
  908. end
  909. comboCheck(attacker, side)
  910. end
  911. function onHp(obj, hurt, attackPos)
  912. if obj.beSkillList[BESKILL_TYPE3] then
  913. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE3]) do
  914. use(obj,{},v)
  915. end
  916. end
  917. if obj.beSkillList[BESKILL_TYPE67] then
  918. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE67]) do
  919. use(obj,{},v)
  920. end
  921. end
  922. local attacker = CombatImpl.objList[attackPos]
  923. if attacker and attacker.beSkillList[BESKILL_TYPE30] and obj.pos ~= attackPos then
  924. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE30]) do
  925. --local skillConfig = SkillExcel[v[1]]
  926. local skillConfig = Skill.GetSkillConfig(v[1])
  927. local beSkillArgs = skillConfig.beSkillArgs
  928. obj.paramData.isbeSkillByHp = obj.paramData.isbeSkillByHp or 0
  929. if beSkillArgs[1] then
  930. if beSkillArgs[1] == "tohp" then
  931. local hp = obj.hp
  932. local hpMax = CombatObj.getHpMax(obj)
  933. if hp > hpMax * beSkillArgs[2]/10000 then
  934. obj.paramData.isbeSkillByHp = 0 --恢复到上限
  935. else
  936. if obj.isbeSkillByHp == 0 then
  937. obj.paramData.isbeSkillByHp = 1 --达到下限
  938. end
  939. end
  940. elseif beSkillArgs[1] == "hurthpper" then
  941. local hpMax = CombatObj.getHpMax(obj)
  942. local percent = -hurt/hpMax
  943. if percent > beSkillArgs[2]/10000 then -- 伤害超过目标生命值上限X%时
  944. use(attacker,{obj},v)
  945. end
  946. elseif beSkillArgs[1] == "speed" then
  947. local atkSpeed = CombatImpl.getValue(attacker,RoleDefine.SPEED)
  948. local defSpeed = CombatImpl.getValue(obj,RoleDefine.SPEED)
  949. if atkSpeed > defSpeed then
  950. use(attacker,{obj},v)
  951. end
  952. end
  953. end
  954. --使用技能
  955. if obj.paramData.isbeSkillByHp == 1 then
  956. use(attacker,{obj},v)
  957. obj.paramData.isbeSkillByHp = 2
  958. end
  959. end
  960. end
  961. end
  962. -- 选择合适的复活技能
  963. function selectReviceSkill(obj, attacker)
  964. local reviveSkillList = {}
  965. local len = 0
  966. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  967. local skillID = v[1]
  968. local isFuwenSkill = v[5]
  969. --local skillConfig = SkillExcel[skillID]
  970. local skillConfig = Skill.GetSkillConfig(skillID)
  971. if skillConfig.cmd == "revive" then
  972. --有可使用的主动复活技能
  973. local state = isCanRevive(obj, attacker, v)
  974. if state and isFuwenSkill == 0 then
  975. if checkLimit(v) then
  976. len = len + 1
  977. reviveSkillList[k] = 1
  978. break
  979. end
  980. end
  981. end
  982. end
  983. -- 没有再取符文技能的复活
  984. if len == 0 then
  985. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  986. local skillID = v[1]
  987. local isFuwenSkill = v[5]
  988. --local skillConfig = SkillExcel[skillID]
  989. local skillConfig = Skill.GetSkillConfig(skillID)
  990. if skillConfig.cmd == "revive" then
  991. local state = isCanRevive(obj, attacker, v)
  992. if state and isFuwenSkill == 1 then
  993. --被动技能次数限制判断
  994. if checkLimit(v) then
  995. reviveSkillList[k] = 1
  996. break
  997. end
  998. end
  999. end
  1000. end
  1001. end
  1002. return reviveSkillList
  1003. end
  1004. function onDie(obj, hurt, attackPos)
  1005. if obj.hp > 0 then
  1006. return
  1007. end
  1008. local side = obj.side
  1009. local attacker = CombatImpl.objList[attackPos]
  1010. if obj.dieSkill then
  1011. if attacker and attacker.beSkillList[BESKILL_TYPE43] then
  1012. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE43]) do
  1013. --local skillConfig = SkillExcel[v[1]]
  1014. local skillConfig = Skill.GetSkillConfig(v[1])
  1015. for _,v1 in ipairs(skillConfig.beSkillArgs) do
  1016. if v1 == obj.dieSkill then
  1017. use(attacker,{obj},v)
  1018. break
  1019. end
  1020. end
  1021. end
  1022. end
  1023. end
  1024. -- 灭魂处理, 只针对英雄
  1025. if not obj.isPet and not obj.isElf then
  1026. local res, banRound = triggerMieHunCheck(attackPos)
  1027. if res and banRound then
  1028. obj.miehunBanReviveUntilRound = CombatImpl.round + banRound
  1029. end
  1030. end
  1031. local defendSide = side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  1032. for _,posData in ipairs(posSortBySpeed[side]) do
  1033. local pos = posData[1]
  1034. local target = CombatImpl.objList[pos]
  1035. if target and target.hp > 0 then
  1036. if target.beSkillList[BESKILL_TYPE16] then
  1037. for _,v in ipairs(target.beSkillList[BESKILL_TYPE16]) do
  1038. use(target,{obj},v)
  1039. end
  1040. end
  1041. if target.beSkillList[BESKILL_TYPE18] then
  1042. for _,v in ipairs(target.beSkillList[BESKILL_TYPE18]) do
  1043. use(target,{obj},v)
  1044. end
  1045. end
  1046. end
  1047. end
  1048. for _,posData in ipairs(posSortBySpeed[defendSide]) do
  1049. local pos = posData[1]
  1050. local target = CombatImpl.objList[pos]
  1051. if target and target.hp > 0 then
  1052. if target.beSkillList[BESKILL_TYPE17] then
  1053. for _,v in ipairs(target.beSkillList[BESKILL_TYPE17]) do
  1054. use(target,{obj},v)
  1055. end
  1056. end
  1057. if target.beSkillList[BESKILL_TYPE18] then
  1058. for _,v in ipairs(target.beSkillList[BESKILL_TYPE18]) do
  1059. use(target,{obj},v)
  1060. end
  1061. end
  1062. end
  1063. end
  1064. if attacker and attacker.beSkillList and attacker.beSkillList[BESKILL_TYPE30] and obj.pos ~= attackPos then
  1065. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE30]) do
  1066. if obj.isbeSkillByHp == nil or
  1067. obj.isbeSkillByHp == 0 then
  1068. use(attacker,{},v)
  1069. end
  1070. end
  1071. end
  1072. if attacker and attacker.beSkillList and attacker.beSkillList[BESKILL_TYPE35] then
  1073. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE35]) do
  1074. use(attacker,{obj},v)
  1075. end
  1076. end
  1077. if obj.beSkillList[BESKILL_TYPE15] then
  1078. -- 选择其中一个使用
  1079. local reviceSkillList = selectReviceSkill(obj, attacker)
  1080. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  1081. local skillID = v[1]
  1082. --local skillConfig = SkillExcel[skillID]
  1083. local skillConfig = Skill.GetSkillConfig(skillID)
  1084. if skillConfig.cmd == "revive" then
  1085. if reviceSkillList[k] then
  1086. use(obj,{},v)
  1087. -- break
  1088. end
  1089. else
  1090. use(obj,{},v)
  1091. end
  1092. end
  1093. end
  1094. for _,pos in ipairs(CombatDefine.SIDE2POS[defendSide]) do
  1095. local defendobj = CombatImpl.objList[pos]
  1096. if defendobj and defendobj.hp > 0 and defendobj.beSkillList[BESKILL_TYPE66] then
  1097. for _,v in ipairs(defendobj.beSkillList[BESKILL_TYPE66]) do
  1098. --local skillConfig = SkillExcel[v[1]]
  1099. local skillConfig = Skill.GetSkillConfig(v[1])
  1100. if skillConfig and skillConfig.otherArgs.tdBuffCmd then
  1101. if obj.bufferCmd[skillConfig.otherArgs.tdBuffCmd] then
  1102. use(defendobj,{},v)
  1103. end
  1104. end
  1105. end
  1106. end
  1107. end
  1108. end
  1109. function onAddBuffer(obj,buffer)
  1110. --local conf = BufferExcel[buffer.id]
  1111. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1112. local attacker = CombatImpl.objList[buffer.attackPos]
  1113. if not attacker then -- 非英雄
  1114. return
  1115. end
  1116. local cmd = conf.cmd
  1117. if cmd == "hurt" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "ranshao" then
  1118. if obj.beSkillList[BESKILL_TYPE10] then
  1119. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE10]) do
  1120. use(obj,{attacker},v)
  1121. end
  1122. end
  1123. end
  1124. if cmd == "bingdong" or cmd == "jiansu" then
  1125. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1126. local target = CombatImpl.objList[pos]
  1127. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE63] then
  1128. for _,v in ipairs(target.beSkillList[BESKILL_TYPE63]) do
  1129. use(target,{obj},v)
  1130. end
  1131. end
  1132. end
  1133. end
  1134. if CombatBuff.isControlCmd(cmd) then
  1135. if obj.beSkillList[BESKILL_TYPE11] then
  1136. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE11]) do
  1137. use(obj,{attacker},v)
  1138. end
  1139. end
  1140. if obj.beSkillList[BESKILL_TYPE67] then
  1141. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE67]) do
  1142. use(obj,{attacker},v, true, true)
  1143. end
  1144. end
  1145. end
  1146. if cmd == "ranshao" then
  1147. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1148. local target = CombatImpl.objList[pos]
  1149. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE12] then
  1150. for _,v in ipairs(target.beSkillList[BESKILL_TYPE12]) do
  1151. local beSkillUseCnt = CombatImpl.getBeSkillUse(target,obj.pos,v[1])--特殊条件特殊处理:同一英雄在同一时间被施加多次燃烧状态时只触发一次
  1152. if beSkillUseCnt == 0 then
  1153. use(target,{obj},v)
  1154. CombatImpl.addBeSkillUse(target,obj.pos,v[1])
  1155. end
  1156. end
  1157. end
  1158. end
  1159. end
  1160. if cmd == "zuzhou" then
  1161. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1162. local target = CombatImpl.objList[pos]
  1163. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE51] then
  1164. for _,v in ipairs(target.beSkillList[BESKILL_TYPE51]) do
  1165. use(target,{obj},v)
  1166. end
  1167. end
  1168. end
  1169. end
  1170. if cmd == "revive" then
  1171. if obj.beSkillList[BESKILL_TYPE33] then
  1172. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE33]) do
  1173. use(obj,{attacker},v)
  1174. end
  1175. end
  1176. end
  1177. end
  1178. function onDelBingDongBuffer(obj, buffer)
  1179. --local conf = BufferExcel[buffer.id]
  1180. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1181. local attacker = CombatImpl.objList[buffer.attackPos]
  1182. if not attacker then
  1183. return
  1184. end
  1185. if conf.cmd == "bingdong" then
  1186. for _, pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1187. local target = CombatImpl.objList[pos]
  1188. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE64] then
  1189. for _,v in ipairs(target.beSkillList[BESKILL_TYPE64]) do
  1190. use(target,{obj},v)
  1191. end
  1192. end
  1193. end
  1194. end
  1195. end
  1196. --援军上阵触发
  1197. function onBackupBegin(obj)
  1198. if not obj then return end
  1199. if CombatDefine.isBackup(obj) ~= CombatDefine.BACKUP_TYPE2 then return end
  1200. -- 备份的被动技能上阵
  1201. if obj.backUpSkillList then
  1202. obj.beSkillList = obj.backUpSkillList
  1203. obj.backUpSkillList = nil
  1204. end
  1205. -- 出站计算属性
  1206. if obj.beSkillList[BESKILL_TYPE26] then
  1207. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE26]) do
  1208. if canUse(obj,v) then
  1209. --local skillConfig = SkillExcel[v[1]]
  1210. local skillConfig = Skill.GetSkillConfig(v[1])
  1211. if skillConfig.cmd == "attr" then
  1212. for _,v1 in ipairs(skillConfig.args) do
  1213. obj.sysAttr[v1[1]] = obj.sysAttr[v1[1]] +v1[2]
  1214. end
  1215. obj.isSysAttrChange = true
  1216. elseif skillConfig.cmd == "normalTarget" then
  1217. use(obj,{},v)
  1218. end
  1219. end
  1220. end
  1221. end
  1222. table.sort(posSortBySpeed[CombatDefine.ATTACK_SIDE],posSpeedCmp)
  1223. table.sort(posSortBySpeed[CombatDefine.DEFEND_SIDE],posSpeedCmp)
  1224. --援军出战触发
  1225. if obj and obj.beSkillList[BESKILL_TYPE32] then
  1226. for k,v in ipairs(obj.beSkillList[BESKILL_TYPE32]) do
  1227. use(obj,{},v)
  1228. end
  1229. end
  1230. --上场技能
  1231. CombatDefine.BACKUP_BUFF_SKILL[2] = 1
  1232. use(obj,{}, CombatDefine.BACKUP_BUFF_SKILL)
  1233. end
  1234. function onRoundBegin(round)
  1235. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1236. local target = CombatImpl.objList[pos]
  1237. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE19] then
  1238. for _,v in ipairs(target.beSkillList[BESKILL_TYPE19]) do
  1239. --table.print_lua_table(v)
  1240. -- print("beskill = onRoundBegin 开始使用技能 ID = "..v[1])
  1241. use(target,{},v)
  1242. end
  1243. end
  1244. -- 生命值触发
  1245. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE62] then
  1246. for _,v in ipairs(target.beSkillList[BESKILL_TYPE62]) do
  1247. --local skillConfig = SkillExcel[v[1]]
  1248. local skillConfig = Skill.GetSkillConfig(v[1])
  1249. local beSkillArgs = skillConfig.beSkillArgs
  1250. if beSkillArgs[1] == 1 then
  1251. local hpMax = CombatObj.getHpMax(target)
  1252. local percent = target.hp/hpMax
  1253. if percent > beSkillArgs[2]/10000 then
  1254. use(target,{},v)
  1255. end
  1256. end
  1257. if beSkillArgs[1] == 2 then
  1258. local hpMax = CombatObj.getHpMax(target)
  1259. local percent = target.hp/hpMax
  1260. if percent < beSkillArgs[2]/10000 then
  1261. use(target,{},v)
  1262. end
  1263. end
  1264. end
  1265. end
  1266. end
  1267. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1268. local target = CombatImpl.objList[pos]
  1269. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE47] then
  1270. for _,v in ipairs(target.beSkillList[BESKILL_TYPE47]) do
  1271. --local skillConfig = SkillExcel[v[1]]
  1272. local skillConfig = Skill.GetSkillConfig(v[1])
  1273. if skillConfig.cmd == "attr" then
  1274. for _,v1 in ipairs(skillConfig.args) do
  1275. target.sysAttr[v1[1]] = target.sysAttr[v1[1]] +v1[2]
  1276. end
  1277. CombatObj.calcAttr(target)
  1278. CombatImpl.addFrame()
  1279. CombatImpl.setSkillID(target, v[1])
  1280. CombatImpl.setSaySkill(target.pos,skillConfig.id,skillConfig.contentType)
  1281. end
  1282. end
  1283. end
  1284. end
  1285. if round and round == 1 then
  1286. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1287. local obj = CombatImpl.objList[pos]
  1288. if obj and obj.beSkillList[BESKILL_TYPE32] then
  1289. for k,v in ipairs(obj.beSkillList[BESKILL_TYPE32]) do
  1290. use(obj,{},v)
  1291. end
  1292. end
  1293. end
  1294. end
  1295. -- 在最后加
  1296. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1297. local target = CombatImpl.objList[pos]
  1298. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE71] then
  1299. for _,v in ipairs(target.beSkillList[BESKILL_TYPE71]) do
  1300. -- print("[onRoundBegin] 开始加类型71的被动技能 pos = "..pos)
  1301. local skillConfig = Skill.GetSkillConfig(v[1])
  1302. if skillConfig and skillConfig.args then
  1303. -- local nLen = skillConfig.args[1]
  1304. -- for i = 1, nLen, 1 do
  1305. use(target,{},v)
  1306. -- end
  1307. end
  1308. end
  1309. end
  1310. end
  1311. end
  1312. function beforeFanji(obj, hitObj, isEnd)
  1313. if not obj or obj.isPet or obj.isElf then
  1314. return
  1315. end
  1316. if obj and obj.hurtType == CombatDefine.PHY_HURT_TYPE then
  1317. if obj and obj.beSkillList and obj.beSkillList[BESKILL_TYPE37] then
  1318. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE37]) do
  1319. -- use(obj,{},v)
  1320. use(obj, {}, v, nil, nil, hitObj)
  1321. end
  1322. end
  1323. else
  1324. if obj and obj.beSkillList and obj.beSkillList[BESKILL_TYPE38] then
  1325. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE38]) do
  1326. use(obj,{},v)
  1327. end
  1328. end
  1329. end
  1330. end
  1331. function onRoundEnd(isRoundEnd)
  1332. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1333. local obj = CombatImpl.objList[pos]
  1334. if obj and obj.beSkillList[BESKILL_TYPE36] then
  1335. if pos == 1 then
  1336. end
  1337. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE36]) do
  1338. use(obj,{},v)
  1339. end
  1340. end
  1341. end
  1342. if isRoundEnd then
  1343. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1344. local target = CombatImpl.objList[pos]
  1345. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE20] then
  1346. for _,v in ipairs(target.beSkillList[BESKILL_TYPE20]) do
  1347. use(target,{},v)
  1348. end
  1349. end
  1350. end
  1351. end
  1352. end
  1353. function posSpeedCmp(a,b)
  1354. if a[2] > b[2] then
  1355. return true
  1356. elseif a[2] < b[2] then
  1357. return false
  1358. else
  1359. return a[1] < b[1]
  1360. end
  1361. end
  1362. -- 计算遗物特殊属性部分
  1363. local function BeSkill_RelicAttribute(ReleaserObj, tSkillInfo)
  1364. local nSkillID = tSkillInfo[1]
  1365. local tSkilConfig = Skill.GetSkillConfig(nSkillID)
  1366. if not tSkilConfig then
  1367. -- print("[BeSkill_RelicAttribute] 不存在技能配置 nSkillID = "..nSkillID)
  1368. return
  1369. end
  1370. local winnerID = ReleaserObj and ReleaserObj.relic and ReleaserObj.relic.relicID or 0
  1371. local winnerStar = ReleaserObj and ReleaserObj.relic and ReleaserObj.relic.star or 0
  1372. if 0 >= winnerID or 0 >= winnerStar then
  1373. return
  1374. end
  1375. -- 特殊处理防御为0, 加标识
  1376. if tSkilConfig.otherArgs.selefDefense then
  1377. ReleaserObj.relicAttr.bSpecialDef = true
  1378. end
  1379. -- 是否增加args属性
  1380. local bAddArgs = true
  1381. if tSkilConfig.otherArgs.winnerfiveraces then
  1382. bAddArgs = false
  1383. end
  1384. local targets = TargetMode.getTargets(ReleaserObj, tSkilConfig.targetMode)
  1385. if #targets > 0 and true == bAddArgs then
  1386. for _, obj in ipairs(targets) do
  1387. -- 加固定值属性
  1388. for _, v in ipairs(tSkilConfig.args) do
  1389. if not obj.relicAttr.FixedAttr[v[1]] then
  1390. obj.relicAttr.FixedAttr[v[1]] = 0
  1391. end
  1392. obj.relicAttr.FixedAttr[v[1]] = obj.relicAttr.FixedAttr[v[1]] + v[2]
  1393. end
  1394. end
  1395. else
  1396. -- print("[BeSkill_RelicAttribute] 获取不到对应的技能目标对象")
  1397. end
  1398. local nSide = ReleaserObj.side
  1399. local tCamp = {}
  1400. -- 检查
  1401. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1402. local obj = CombatImpl.objList[pos]
  1403. if obj and obj.side and nSide == obj.side then
  1404. local nCamp = obj.camp
  1405. if nCamp then
  1406. tCamp[nCamp] = 1
  1407. end
  1408. end
  1409. end
  1410. local bAllCamp = true
  1411. for i = CombatDefine.CAMP_TYPE1, CombatDefine.CAMP_TYPE5, 1 do
  1412. if not tCamp[i] then
  1413. bAllCamp = false
  1414. break
  1415. end
  1416. end
  1417. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1418. local obj = CombatImpl.objList[pos]
  1419. if obj and obj.side and nSide == obj.side then
  1420. -- 处理百分比值
  1421. -- 治疗
  1422. if tSkilConfig.otherArgs.jobZhiliao then
  1423. --table.print_lua_table(tSkilConfig.otherArgs.jobZhiliao)
  1424. if CombatBuff.isJob(obj, {CombatDefine.JOB_TYPE4}) then
  1425. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1426. if not obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1427. obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] = 0
  1428. end
  1429. local nValue = tSkilConfig.otherArgs.jobZhiliao[2]
  1430. -- print("BeSkill_RelicAttribute 治療 nValue = ".. nValue)
  1431. obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] = obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] + nValue
  1432. if obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1433. -- print("[BeSkill_RelicAttribute] 治療加成 為 nNewValue = "..obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] )
  1434. else
  1435. -- print("[BeSkill_RelicAttribute] 不存在 nNewValue" )
  1436. end
  1437. end
  1438. end
  1439. -- 免伤 百分比
  1440. if tSkilConfig.otherArgs.jobMianshang then
  1441. if CombatBuff.isJob(obj, {CombatDefine.JOB_TYPE1}) then
  1442. --local extraRate = WinnerRelicLogic.WinnerRelic_GetRateDef(winnerID, winnerStar)
  1443. if not obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] then
  1444. obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] = 0
  1445. end
  1446. local nValue = tSkilConfig.otherArgs.jobMianshang[2]
  1447. -- print("BeSkill_RelicAttribute 免伤 nValue = ".. nValue)
  1448. obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] = obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] + nValue
  1449. -- print("[BeSkill_RelicAttribute] 免傷加成 為 nValue = "..nValue.." nNewValue = "..obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE])
  1450. end
  1451. end
  1452. -- 防御增加固定值
  1453. if tSkilConfig.otherArgs.jobDefense then
  1454. if CombatBuff.isJob(obj, {CombatDefine.JOB_TYPE4, CombatDefine.JOB_TYPE1}) then
  1455. if winnerID > 0 and winnerStar > 0 then
  1456. local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1457. if not obj.relicAttr.FixedAttr[RoleDefine.DEF] then
  1458. obj.relicAttr.FixedAttr[RoleDefine.DEF] = 0
  1459. end
  1460. obj.relicAttr.FixedAttr[RoleDefine.DEF] = obj.relicAttr.FixedAttr[RoleDefine.DEF] + extraRate
  1461. end
  1462. end
  1463. end
  1464. -- 攻击 百分比
  1465. if tSkilConfig.otherArgs.racialAtk then
  1466. if CombatBuff.isCamp(obj, {CombatDefine.COMBAT_TYPE27}) then
  1467. local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1468. if not obj.relicAttr.ProAttr[RoleDefine.ATK] then
  1469. obj.relicAttr.ProAttr[RoleDefine.ATK] = 0
  1470. end
  1471. obj.relicAttr.ProAttr[RoleDefine.ATK] = obj.relicAttr.ProAttr[RoleDefine.ATK] + extraRate
  1472. end
  1473. end
  1474. -- 上阵阵容为全职业,加固定值
  1475. if tSkilConfig.otherArgs.winnerfiveraces and bAllCamp == true then
  1476. for _, v in ipairs(tSkilConfig.args) do
  1477. if not obj.relicAttr.FixedAttr[v[1]] then
  1478. obj.relicAttr.FixedAttr[v[1]] = 0
  1479. end
  1480. obj.relicAttr.FixedAttr[v[1]] = obj.relicAttr.FixedAttr[v[1]] + v[2]
  1481. end
  1482. end
  1483. end
  1484. end
  1485. end
  1486. function onFightBegin()
  1487. posSortBySpeed[CombatDefine.ATTACK_SIDE] = {}
  1488. posSortBySpeed[CombatDefine.DEFEND_SIDE] = {}
  1489. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1490. local obj = CombatImpl.objList[pos]
  1491. if obj then
  1492. obj.hp = obj.hp and obj.hp or 1
  1493. end
  1494. end
  1495. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1496. local obj = CombatImpl.objList[pos]
  1497. if obj then
  1498. if obj.beSkillList[BESKILL_TYPE26] then
  1499. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE26]) do
  1500. if canUse(obj,v) then
  1501. --local skillConfig = SkillExcel[v[1]]
  1502. local skillConfig = Skill.GetSkillConfig(v[1])
  1503. if skillConfig.cmd == "attr" then
  1504. for _,v1 in ipairs(skillConfig.args) do
  1505. obj.sysAttr[v1[1]] = obj.sysAttr[v1[1]] +v1[2]
  1506. end
  1507. obj.isSysAttrChange = true
  1508. elseif skillConfig.cmd == "normalTarget" then
  1509. use(obj,{},v)
  1510. elseif skillConfig.cmd == "winnerRelicSkill" then
  1511. use(obj,{},v)
  1512. BeSkill_RelicAttribute(obj, v)
  1513. end
  1514. end
  1515. end
  1516. end
  1517. if pos <= CombatDefine.COMBAT_HERO_CNT then
  1518. posSortBySpeed[CombatDefine.ATTACK_SIDE][#posSortBySpeed[CombatDefine.ATTACK_SIDE]+1] = {pos,obj.attr and obj.attr[RoleDefine.SPEED] or 0}
  1519. elseif pos <= CombatDefine.COMBAT_HERO_CNT * 2 then
  1520. posSortBySpeed[CombatDefine.DEFEND_SIDE][#posSortBySpeed[CombatDefine.DEFEND_SIDE]+1] = {pos,obj.attr and obj.attr[RoleDefine.SPEED] or 0}
  1521. end
  1522. end
  1523. end
  1524. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1525. local obj = CombatImpl.objList[pos]
  1526. if obj then
  1527. obj.hp = nil
  1528. end
  1529. end
  1530. table.sort(posSortBySpeed[CombatDefine.ATTACK_SIDE],posSpeedCmp)
  1531. table.sort(posSortBySpeed[CombatDefine.DEFEND_SIDE],posSpeedCmp)
  1532. end
  1533. function onCombatPetBe(round)
  1534. if round <= 1 then
  1535. return
  1536. end
  1537. for side = 1,CombatDefine.DEFEND_SIDE do
  1538. local pet = CombatImpl.petList[side]
  1539. if pet and pet.petID and pet.beSkillList[BESKILL_TYPE27] then
  1540. for _,v in ipairs(pet.beSkillList[BESKILL_TYPE27]) do
  1541. --local skillConfig = SkillExcel[v[1]]
  1542. local skillConfig = Skill.GetSkillConfig(v[1])
  1543. if skillConfig.cmd == "mp" then
  1544. use(pet,{},v)
  1545. end
  1546. end
  1547. end
  1548. end
  1549. end
  1550. -- 计算被动技能属性
  1551. local beSkillIDList = {}
  1552. function doCalcHero(obj, attrs, skinSkillID, heroConf)
  1553. for i = 1, #beSkillIDList do
  1554. beSkillIDList[i] = nil
  1555. end
  1556. heroConf = heroConf or HeroDefine.getAttrConfig(obj.id, obj.star)
  1557. local beSkillIDs = heroConf.beSkillList
  1558. local skinSkillConf = skinSkillID and SkinSkillExcel[skinSkillID]
  1559. if skinSkillConf then
  1560. beSkillIDs = skinSkillConf.beSkillList
  1561. end
  1562. local weapSkillList = HeroExclusiveWeapon.GetweaponEffectIdList(obj)
  1563. for _, skillID in ipairs(beSkillIDs) do
  1564. --local skillConfig = SkillExcel[skillID]
  1565. skillID = weapSkillList and weapSkillList[skillID] or skillID
  1566. local skillConfig = Skill.GetSkillConfig(skillID)
  1567. if skillConfig.beSkillType == BESKILL_TYPE24 and
  1568. ((not obj) or (obj.quality >= skillConfig.need)) then
  1569. for _,v in ipairs(skillConfig.args) do
  1570. beSkillIDList[#beSkillIDList + 1] = v
  1571. end
  1572. else
  1573. beSkillIDList[#beSkillIDList + 1] = skillID
  1574. end
  1575. end
  1576. for _, skillID in ipairs(beSkillIDList) do
  1577. --local skillConfig = SkillExcel[skillID]
  1578. local skillConfig = Skill.GetSkillConfig(skillID)
  1579. if skillConfig and skillConfig.cmd == "attr" and
  1580. skillConfig.beSkillType == BESKILL_TYPE23 and
  1581. ((not obj) or (obj.quality >= skillConfig.need)) then
  1582. for _, v in ipairs(skillConfig.args) do
  1583. RoleAttr.updateValue(v[1], v[2], attrs)
  1584. end
  1585. elseif skillConfig and skillConfig.cmd == "attrcomboAgain" and
  1586. skillConfig.beSkillType == BESKILL_TYPE70 and
  1587. ((not obj) or (obj.quality >= skillConfig.need)) then
  1588. for i, v in ipairs(skillConfig.args) do
  1589. if v[1] == 1 then
  1590. RoleAttr.updateValue(v[2], v[3], attrs)
  1591. end
  1592. end
  1593. end
  1594. end
  1595. end
  1596. function beforeHit(attacker,defender)
  1597. attacker.beforeHitCheck = false
  1598. if attacker.beSkillList[BESKILL_TYPE40] then
  1599. local hpMax = CombatObj.getHpMax(defender)
  1600. local hp = defender.hp
  1601. local defendHpRate = hp*10000/hpMax
  1602. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1603. --local skillConfig = SkillExcel[v[1]]
  1604. local skillConfig = Skill.GetSkillConfig(v[1])
  1605. if skillConfig.cmd == "lowerLimit" then
  1606. local args = skillConfig.args
  1607. if defendHpRate < args[1] then
  1608. attacker.beforeHitCheck = true
  1609. attacker.beskill40 = attacker.beskill40 or {}
  1610. attacker.beskill40[defender.pos] = 1
  1611. end
  1612. end
  1613. end
  1614. end
  1615. end
  1616. function afterHit(attacker,target, isEnd)
  1617. if attacker.beforeHitCheck then
  1618. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1619. use(attacker,{target},v)
  1620. end
  1621. end
  1622. -- beforeFanji(attacker, isEnd)
  1623. beforeFanji(attacker, target, isEnd)
  1624. end
  1625. function getOutAtkRate(attacker, defender)
  1626. local outAtkRate = 0
  1627. -- 首次攻击
  1628. local isFirstAttack = CombatImpl.firstAttack[attacker.side]
  1629. if isFirstAttack then
  1630. for _,pos in ipairs(CombatDefine.SIDE2POS[defender.side]) do
  1631. local objM = CombatImpl.objList[pos]
  1632. if objM and objM.beSkillList[BESKILL_TYPE50] then
  1633. for _,v in ipairs(objM.beSkillList[BESKILL_TYPE50]) do
  1634. --local skillConfig = SkillExcel[v[1]]
  1635. local skillConfig = Skill.GetSkillConfig(v[1])
  1636. if skillConfig and skillConfig.otherArgs.outAtkRate then
  1637. if skillConfig.otherArgs.outAtkRate >= outAtkRate then
  1638. outAtkRate = skillConfig.otherArgs.outAtkRate
  1639. end
  1640. end
  1641. end
  1642. end
  1643. end
  1644. end
  1645. return outAtkRate
  1646. end
  1647. function getOutAtkRate2(attacker, skillConfig)
  1648. local outAtkRate = 0
  1649. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE72] or {}) do
  1650. local config = Skill.GetSkillConfig(v[1])
  1651. if config.cmd == "addHurtRateByRand" then
  1652. local addHurtRate = 0
  1653. for _, skillInfo in ipairs(config.beSkillArgs[2]) do
  1654. if table.find(skillInfo[1], skillConfig.id) then
  1655. addHurtRate = skillInfo[2]
  1656. break
  1657. end
  1658. end
  1659. local randVal = math.random(0, 10000)
  1660. if randVal <= config.beSkillArgs[1] then
  1661. outAtkRate = outAtkRate + addHurtRate
  1662. end
  1663. end
  1664. end
  1665. return outAtkRate
  1666. end
  1667. function getExtraHurtRate(attacker,defender,skillConfig)
  1668. if not attacker or attacker.isPet then
  1669. return 0
  1670. end
  1671. local zhanyiRet = 0
  1672. local bodongHurtRet = 0
  1673. local zhenduiHurtRate = 0
  1674. local zhenduiLen = 0
  1675. local zhenduiList = {}
  1676. local bezhenduiList = {}
  1677. local hpHurtRate = 0
  1678. local extraSpeedHurt = 0
  1679. local firstHurt = 0
  1680. local sexHurt = 0
  1681. local campHurt = 0
  1682. local reJobHurt = 0
  1683. local buffAndHPSubHurt = 0
  1684. for k,skillList in pairs(attacker.beSkillList) do
  1685. for j,v in pairs(skillList) do
  1686. --local config = SkillExcel[v[1]]
  1687. local config = Skill.GetSkillConfig(v[1])
  1688. if config.cmd == "zhanyi" then --战意 伤害加成
  1689. local nowHp = attacker.hp
  1690. local hpMax = CombatObj.getHpMax(attacker)
  1691. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1692. if percent >= 1 then
  1693. zhanyiRet = zhanyiRet + (percent * config.args[2])
  1694. end
  1695. elseif config.cmd == "fuwenAKH" then
  1696. for i = 1,#config.otherArgs do
  1697. zhenduiLen = zhenduiLen + 1
  1698. zhenduiList[config.otherArgs[i][1]] = zhenduiList[config.otherArgs[i][1]] or 0
  1699. zhenduiList[config.otherArgs[i][1]] = zhenduiList[config.otherArgs[i][1]] + config.otherArgs[i][2]
  1700. end
  1701. elseif config.cmd == "hurtBodong" then
  1702. if canUse(attacker, v) then
  1703. local minRet = config.args[1]
  1704. local maxRet = config.args[2]
  1705. local randomRet = math.random(minRet, maxRet)
  1706. bodongHurtRet = bodongHurtRet + randomRet - 10000
  1707. end
  1708. elseif config.cmd == "hpExtraHurt" then
  1709. local hp = defender.hp
  1710. local beSkillArgs = config.beSkillArgs
  1711. local checkHp = CombatObj.getHpMax(defender) * beSkillArgs[3] / 10000
  1712. if beSkillArgs[2] == 1 and hp > checkHp then
  1713. hpHurtRate = beSkillArgs[4]
  1714. elseif beSkillArgs[2] == 2 and hp < checkHp then
  1715. hpHurtRate = beSkillArgs[4]
  1716. end
  1717. elseif config.cmd == "extraSpeedHurt" then
  1718. extraSpeedHurt = config.args[1]
  1719. elseif config.cmd == "firstAttackHurt" then
  1720. if canUse(attacker, v) then
  1721. firstHurt = config.args[1]
  1722. end
  1723. elseif config.cmd == "buffAndHPSub" then
  1724. local nowHp = defender.hp
  1725. local hpMax = CombatObj.getHpMax(defender)
  1726. local percent = math.floor((hpMax - nowHp )/hpMax * 100) --已损失血量百分比
  1727. local condCfg = config.args
  1728. local condRate = condCfg[1]
  1729. if percent >= condRate then
  1730. local condStatusList = condCfg[2] or {}
  1731. local objNowSatus = CombatBuff.getStatus(defender)
  1732. for _, buffCmd in pairs(condStatusList) do
  1733. if objNowSatus[buffCmd] then
  1734. buffAndHPSubHurt = condCfg[3] or 0
  1735. break
  1736. end
  1737. end
  1738. end
  1739. elseif config.cmd == "hpSubHurtAdd" then
  1740. local nowHp = attacker.hp
  1741. local hpMax = CombatObj.getHpMax(attacker)
  1742. local percent = math.floor((hpMax - nowHp )/hpMax * 100) --已损失血量百分比
  1743. local condCfg = config.beSkillArgs
  1744. local condRate = condCfg[1]
  1745. if percent >= condRate then
  1746. hpHurtRate = hpHurtRate + condCfg[2]
  1747. end
  1748. end
  1749. end
  1750. end
  1751. for k,skillList in pairs(defender.beSkillList) do
  1752. for j,v in pairs(skillList) do
  1753. --local conf = SkillExcel[v[1]]
  1754. local conf = Skill.GetSkillConfig(v[1])
  1755. if conf then
  1756. if conf.cmd == "befuwenAKH" then
  1757. for i = 1,#conf.otherArgs do
  1758. zhenduiLen = zhenduiLen + 1
  1759. bezhenduiList[conf.otherArgs[i][1]] = bezhenduiList[conf.otherArgs[i][1]] or 0
  1760. bezhenduiList[conf.otherArgs[i][1]] = bezhenduiList[conf.otherArgs[i][1]] + conf.otherArgs[i][2]
  1761. end
  1762. -- 受性别增伤
  1763. elseif conf.cmd == "sexHurt" then
  1764. if attacker.sex == conf.args[1] then
  1765. sexHurt = sexHurt + conf.args[2]
  1766. end
  1767. -- 受阵营增伤
  1768. elseif conf.cmd == "campHurt" then
  1769. if attacker.camp == conf.args[1] then
  1770. campHurt = campHurt + conf.args[2]
  1771. end
  1772. -- 受职业增伤
  1773. elseif conf.cmd == "reJobHurt" then
  1774. if attacker.job == conf.args[1] then
  1775. reJobHurt = reJobHurt + conf.args[2]
  1776. end
  1777. end
  1778. end
  1779. end
  1780. end
  1781. if zhenduiLen > 0 then
  1782. local bAdd = 0
  1783. for k,skillList in pairs(defender.beSkillList) do
  1784. for j,v in pairs(skillList) do
  1785. --local conf = SkillExcel[v[1]]
  1786. local conf = Skill.GetSkillConfig(v[1])
  1787. local isFuWenSkill = v[5]
  1788. if conf.cmd and conf.cmd ~= "" and zhenduiList[conf.cmd] then
  1789. -- 符文技能只生效一个
  1790. if isFuWenSkill == 1 then
  1791. if bAdd == 0 then
  1792. zhenduiHurtRate = zhenduiHurtRate + zhenduiList[conf.cmd]
  1793. bAdd = 1
  1794. end
  1795. else
  1796. zhenduiHurtRate = zhenduiHurtRate + zhenduiList[conf.cmd]
  1797. end
  1798. end
  1799. end
  1800. end
  1801. bAdd = 0
  1802. for k,skillList in pairs(attacker.beSkillList) do
  1803. for j,v in pairs(skillList) do
  1804. --local conf = SkillExcel[v[1]]
  1805. local conf = Skill.GetSkillConfig(v[1])
  1806. local isFuWenSkill = v[5]
  1807. if conf.cmd and conf.cmd ~= "" and bezhenduiList[conf.cmd] then
  1808. if isFuWenSkill == 1 then
  1809. if bAdd == 0 then
  1810. zhenduiHurtRate = zhenduiHurtRate + bezhenduiList[conf.cmd]
  1811. bAdd = 1
  1812. end
  1813. else
  1814. zhenduiHurtRate = zhenduiHurtRate + bezhenduiList[conf.cmd]
  1815. end
  1816. end
  1817. end
  1818. end
  1819. end
  1820. --特殊buff 对血族的加成
  1821. local campHurtRate = 0
  1822. local campRate = nil
  1823. local buffCmd = nil
  1824. local camp = nil
  1825. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1826. obj = CombatImpl.objList[pos]
  1827. if obj and obj.hp > 0 then
  1828. if obj.beSkillList[BESKILL_TYPE68] then
  1829. local beSkillList = obj.beSkillList[BESKILL_TYPE68][1]
  1830. --local skillConfig = SkillExcel[beSkillList[1]]
  1831. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1832. if skillConfig then
  1833. camp = skillConfig.otherArgs.calcCamp[1]
  1834. buffCmd = skillConfig.otherArgs.calcCamp[2]
  1835. campRate = skillConfig.otherArgs.calcCamp[3]
  1836. break
  1837. end
  1838. end
  1839. end
  1840. end
  1841. if buffCmd and campRate and attacker.camp == camp then
  1842. local campHurtCnt = 0
  1843. for _,pos in ipairs(CombatDefine.SIDE2POS[defender.side]) do
  1844. obj = CombatImpl.objList[pos]
  1845. if obj and obj.hp > 0 then
  1846. local isStatus1, cmd1, ind1 = CombatBuff.isStatus(obj, buffCmd)
  1847. if isStatus1 then
  1848. campHurtCnt = campHurtCnt + 1
  1849. end
  1850. end
  1851. end
  1852. if campHurtCnt > 0 then
  1853. campHurtRate = campHurtCnt * campRate
  1854. end
  1855. end
  1856. local extraHurtRate = zhanyiRet + zhenduiHurtRate + bodongHurtRet + hpHurtRate + extraSpeedHurt + firstHurt + sexHurt + campHurt + reJobHurt + campHurtRate + buffAndHPSubHurt
  1857. if attacker.beSkillList[BESKILL_TYPE40] and attacker.beforeHitCheck then
  1858. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1859. --local skillConfig = SkillExcel[v[1]]
  1860. local skillConfig = Skill.GetSkillConfig(v[1])
  1861. if skillConfig.cmd == "extraHurt" then
  1862. local args = skillConfig.args
  1863. extraHurtRate = extraHurtRate + args[1]
  1864. end
  1865. end
  1866. end
  1867. return extraHurtRate
  1868. end
  1869. --
  1870. function getExtraHurt(attacker, target, tUseskillConfig)
  1871. local extraHurt = 0
  1872. if attacker.beSkillList[BESKILL_TYPE55] then
  1873. local beSkillList = attacker.beSkillList[BESKILL_TYPE55][1]
  1874. --local skillConfig = SkillExcel[beSkillList[1]]
  1875. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1876. local buffCmd = target.bufferCmd[skillConfig.otherArgs.buffCmdHurtRate[1]]
  1877. local rate = skillConfig.otherArgs.buffCmdHurtRate[2] / 10000
  1878. if buffCmd then
  1879. local buffCnt = #buffCmd
  1880. local buffIndex = buffCmd[buffCnt]
  1881. local buffer = target.buffer[buffIndex]
  1882. --local conf = BufferExcel[buffer.id]
  1883. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1884. local hurt = buffer.arg[1]
  1885. extraHurt = extraHurt + hurt * rate * buffCnt
  1886. end
  1887. end
  1888. return extraHurt
  1889. end
  1890. -- 根据杀气buff获得额外属性加成
  1891. function GetExtraAttrByShaQi(attacker, targetAttrId)
  1892. local attrVal = 0
  1893. if not attacker then
  1894. return attrVal
  1895. end
  1896. -- for _, skillList in pairs(attacker.beSkillList) do
  1897. -- for _, v in pairs(skillList) do
  1898. -- local config = Skill.GetSkillConfig(v[1])
  1899. -- if config.cmd == "shaqi" then
  1900. -- local buffNum = CombatBuff.getBuffCnt(attacker, config.cmd)
  1901. -- if buffNum <= 0 then
  1902. -- return attrVal
  1903. -- end
  1904. -- for _, attrTb in ipairs(config.args) do
  1905. -- if attrTb[1] == targetAttrId then
  1906. -- attrVal = (attrTb[2] or 0) * buffNum
  1907. -- break
  1908. -- end
  1909. -- end
  1910. -- end
  1911. -- end
  1912. -- end
  1913. local buffNum = CombatBuff.getBuffCnt(attacker, "shaqi")
  1914. if buffNum <= 0 then
  1915. return attrVal
  1916. end
  1917. local attrArr
  1918. for i=1, attacker.buffer[0] do
  1919. local buffer = attacker.buffer[i]
  1920. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1921. if conf.cmd == "shaqi" then
  1922. attrArr = conf.args
  1923. break
  1924. end
  1925. end
  1926. if not attrArr then
  1927. return attrVal
  1928. end
  1929. for _, attrTb in ipairs(attrArr) do
  1930. if attrTb[1] == targetAttrId then
  1931. attrVal = (attrTb[2] or 0) * buffNum
  1932. break
  1933. end
  1934. end
  1935. return attrVal
  1936. end
  1937. --
  1938. function getRandomBuffCmd(attacker, target, cmd)
  1939. local side = attacker.side
  1940. local mathRandom = math.random
  1941. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1942. local obj = CombatImpl.objList[pos]
  1943. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE56] then
  1944. local beSkillList = obj.beSkillList[BESKILL_TYPE56][1]
  1945. --local skillConfig = SkillExcel[beSkillList[1]]
  1946. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1947. local buffCmdRand = skillConfig.otherArgs.buffCmdRand
  1948. if buffCmdRand and cmd == buffCmdRand[1] then
  1949. local random = mathRandom(1, 10000)
  1950. if random <= buffCmdRand[2] then
  1951. return true
  1952. end
  1953. end
  1954. end
  1955. end
  1956. end
  1957. function getHurtPercentRate(attacker, defender, hurt, tUseskillConfig)
  1958. local rate = 0
  1959. for k,skillList in pairs(defender.beSkillList) do
  1960. for j,v in pairs(skillList) do
  1961. --local conf = SkillExcel[v[1]]
  1962. local conf = Skill.GetSkillConfig(v[1])
  1963. if conf and conf.cmd == "behurtRet" then
  1964. local canUse = true
  1965. if conf.beSkillArgs and #conf.beSkillArgs > 0 then
  1966. if conf.beSkillArgs[1] == "hurthpper" then
  1967. local hpMax = CombatObj.getHpMax(defender)
  1968. local percent = hurt/hpMax
  1969. if percent < conf.beSkillArgs[2]/10000 then -- 伤害超过目标生命值上限X%时
  1970. canUse = false
  1971. end
  1972. end
  1973. end
  1974. if canUse == true then
  1975. local random = math.random(1, 10000)
  1976. if random <= conf.args[2] then
  1977. rate = rate + conf.args[1]
  1978. end
  1979. end
  1980. end
  1981. end
  1982. end
  1983. if tUseskillConfig.type == CombatDefine.SKILL_TYPE1 then
  1984. if attacker.beSkillList[BESKILL_TYPE1] then
  1985. for _, v in pairs(attacker.beSkillList[BESKILL_TYPE1]) do
  1986. local nSkillID = v[1]
  1987. --local skillConfig = SkillExcel[nSkillID]
  1988. local skillConfig = Skill.GetSkillConfig(nSkillID)
  1989. if skillConfig and skillConfig.hurtRate and skillConfig.hurtRate[1] then
  1990. local fRate = skillConfig.hurtRate[1]
  1991. rate = rate + fRate
  1992. --print("[getExtraHurt] 获取到的普工伤害加成概率 fRate = "..fRate.." 总加成 rate = "..rate)
  1993. end
  1994. end
  1995. end
  1996. end
  1997. return rate
  1998. end
  1999. function getBufferExtraHurt(attacker,bufferID,cmd)
  2000. local rate = 0
  2001. for _,skillList in pairs(attacker.beSkillList) do
  2002. for k,v in pairs(skillList) do
  2003. --local conf = SkillExcel[v[1]]
  2004. local conf = Skill.GetSkillConfig(v[1])
  2005. local otherArgs = conf.otherArgs
  2006. if bufferID and otherArgs.bufferExtraHurt then
  2007. for k1,v1 in ipairs(otherArgs.bufferExtraHurt[1]) do
  2008. if bufferID == v1 then
  2009. rate = rate + otherArgs.bufferExtraHurt[2]
  2010. end
  2011. end
  2012. end
  2013. if cmd and otherArgs.bufferCmdExtraHurt then
  2014. for k1,v1 in ipairs(otherArgs.bufferCmdExtraHurt[1]) do
  2015. if cmd == v1 then
  2016. rate = rate + otherArgs.bufferCmdExtraHurt[2]
  2017. end
  2018. end
  2019. end
  2020. end
  2021. end
  2022. return rate
  2023. end
  2024. function getExtraHurtRateEx(attacker, defender)
  2025. local rate = 0
  2026. -- 死亡数伤害率
  2027. if attacker.beSkillList[BESKILL_TYPE48] then
  2028. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE48]) do
  2029. --local skillConfig = SkillExcel[v[1]]
  2030. local skillConfig = Skill.GetSkillConfig(v[1])
  2031. if skillConfig and skillConfig.otherArgs.deathHurt then
  2032. local side = defender.side
  2033. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  2034. local obj = CombatImpl.objList[pos]
  2035. if obj and obj.hp <=0 then
  2036. if rate == 0 then
  2037. rate = skillConfig.otherArgs.deathHurt
  2038. else
  2039. rate = rate + 10000
  2040. end
  2041. end
  2042. end
  2043. end
  2044. end
  2045. end
  2046. return rate
  2047. end
  2048. --
  2049. function getBuffChixuHurt(attacker, cmd)
  2050. if not attacker then return 0 end
  2051. local hurt = 0
  2052. local side = attacker.side
  2053. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  2054. local objM = CombatImpl.objList[pos]
  2055. if objM and objM.hp > 0 and objM.beSkillList[BESKILL_TYPE54] then
  2056. for _,v in ipairs(objM.beSkillList[BESKILL_TYPE54]) do
  2057. --local skillConfig = SkillExcel[v[1]]
  2058. local skillConfig = Skill.GetSkillConfig(v[1])
  2059. if skillConfig and skillConfig.otherArgs[cmd] then
  2060. hurt = hurt + skillConfig.otherArgs[cmd]
  2061. end
  2062. end
  2063. end
  2064. end
  2065. return hurt / 10000
  2066. end
  2067. --
  2068. function handlerBuff(attacker, target, arg, cmd)
  2069. if not attacker then return end
  2070. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  2071. local obj = CombatImpl.objList[pos]
  2072. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE57] then
  2073. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE57]) do
  2074. attacker.args = arg
  2075. use(attacker, {target}, v, false)
  2076. end
  2077. end
  2078. end
  2079. end
  2080. function beforeMinusHp(obj, value)
  2081. if value <= 0 then return end
  2082. --敌对阵营 有对象有 49号被动技能 加血变成减血
  2083. local side = obj.side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  2084. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  2085. local objM = CombatImpl.objList[pos]
  2086. if objM and objM.hp > 0 and objM.beSkillList[BESKILL_TYPE49] then
  2087. value = value * (-1)
  2088. break
  2089. end
  2090. end
  2091. return value
  2092. end
  2093. function beforeUpdateHp(obj,sum)
  2094. if sum <= 0 and obj.beSkillList[BESKILL_TYPE41] then
  2095. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE41]) do
  2096. --local skillConfig = SkillExcel[v[1]]
  2097. local skillConfig = Skill.GetSkillConfig(v[1])
  2098. if skillConfig.cmd == "miansi" and canUse(obj,v) then
  2099. use(obj,{},v)
  2100. return true
  2101. end
  2102. end
  2103. end
  2104. end
  2105. function onCheckBuffer(obj,attacker,value)
  2106. local ret = value
  2107. if obj.beSkillList[BESKILL_TYPE42] then
  2108. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE42]) do
  2109. --local skillConfig = SkillExcel[v[1]]
  2110. local skillConfig = Skill.GetSkillConfig(v[1])
  2111. if canUse(obj,v) then
  2112. local newFrame = true
  2113. if skillConfig.cmd == "baohu" then
  2114. obj.baohuHurt = value * skillConfig.args[1] / 10000
  2115. if obj.hp < -obj.baohuHurt then
  2116. obj.baohuHurt = -obj.hp
  2117. end
  2118. ret = value - obj.baohuHurt
  2119. newFrame = false
  2120. end
  2121. use(obj,{attacker},v, newFrame)
  2122. break
  2123. end
  2124. end
  2125. end
  2126. return ret
  2127. end
  2128. function getStatusBaoji(attacker, defender)
  2129. local baoji = 0
  2130. local firstBaoji = 0
  2131. for k, skillList in pairs(attacker.beSkillList) do
  2132. for j, v in pairs(skillList) do
  2133. --local config = SkillExcel[v[1]]
  2134. local config = Skill.GetSkillConfig(v[1])
  2135. if config.cmd == "firstAttackHurt" then
  2136. if canUse(attacker, v) then
  2137. firstBaoji = config.args[2] or 0
  2138. end
  2139. end
  2140. end
  2141. end
  2142. if attacker.beSkillList[BESKILL_TYPE60] then
  2143. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE60]) do
  2144. --local skillConfig = SkillExcel[v[1]]
  2145. local skillConfig = Skill.GetSkillConfig(v[1])
  2146. if skillConfig and skillConfig.otherArgs.addStatusBaoji then
  2147. local status = CombatBuff.getStatus(defender)
  2148. local isStatus = false
  2149. for k, v in ipairs(skillConfig.otherArgs.addStatusBaoji[1]) do
  2150. if status[v] then
  2151. isStatus = true
  2152. break
  2153. end
  2154. end
  2155. if isStatus then
  2156. baoji = baoji + skillConfig.otherArgs.addStatusBaoji[2]
  2157. end
  2158. end
  2159. end
  2160. end
  2161. if attacker.beSkillList[BESKILL_TYPE69] and attacker.notBaoJi then
  2162. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE69]) do
  2163. --local skillConfig = SkillExcel[v[1]]
  2164. local skillConfig = Skill.GetSkillConfig(v[1])
  2165. if skillConfig and skillConfig.otherArgs.addNotBaoji then
  2166. baoji = baoji + skillConfig.otherArgs.addNotBaoji
  2167. end
  2168. end
  2169. end
  2170. return baoji + firstBaoji
  2171. end
  2172. function getStatusPojia(attacker, defender)
  2173. local poJia = 0
  2174. -- 对指定状态破甲加成 走的技能状态属性
  2175. if attacker.beSkillList[BESKILL_TYPE60] then
  2176. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE60]) do
  2177. --local skillConfig = SkillExcel[v[1]]
  2178. local skillConfig = Skill.GetSkillConfig(v[1])
  2179. if skillConfig.otherArgs.addStatusPoJia then
  2180. local status = CombatBuff.getStatus(defender)
  2181. local isStatus = false
  2182. for k, v in ipairs(skillConfig.otherArgs.addStatusPoJia[1]) do
  2183. if status[v] then
  2184. isStatus = true
  2185. break
  2186. end
  2187. end
  2188. if isStatus then
  2189. poJia = poJia + skillConfig.otherArgs.addStatusPoJia[2]
  2190. end
  2191. end
  2192. end
  2193. end
  2194. return poJia
  2195. end
  2196. -- 是否不会被反击
  2197. function isNoFanji(obj)
  2198. if obj.beSkillList[BESKILL_TYPE72] then
  2199. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2200. local skillConfig = Skill.GetSkillConfig(v[1])
  2201. if skillConfig.cmd == "noFanji" then
  2202. return true
  2203. end
  2204. end
  2205. end
  2206. return false
  2207. end
  2208. -- 获取与神威灵装"真伤附加"效果相对的"真伤减免"
  2209. function GetTrueDamegeOffset(obj)
  2210. if obj.beSkillList[BESKILL_TYPE72] then
  2211. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2212. local skillConfig = Skill.GetSkillConfig(v[1])
  2213. if skillConfig.cmd == "trueDamegeOffset" then
  2214. local offsetInfo = {}
  2215. offsetInfo[1] = skillConfig.beSkillArgs[1]
  2216. offsetInfo[2] = skillConfig.beSkillArgs[2]
  2217. return offsetInfo
  2218. end
  2219. end
  2220. end
  2221. end
  2222. -- 触发格挡后额外减伤
  2223. function GetGeDangExtraDef(obj)
  2224. if obj.beSkillList[BESKILL_TYPE72] then
  2225. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2226. local skillConfig = Skill.GetSkillConfig(v[1])
  2227. if skillConfig.cmd == "gedangExtraDef" then
  2228. return skillConfig.beSkillArgs[1]
  2229. end
  2230. end
  2231. end
  2232. return 0
  2233. end
  2234. -- 伤害翻倍
  2235. function GetBeSkillHurtMul(obj)
  2236. if obj.beSkillList[BESKILL_TYPE72] then
  2237. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2238. local skillConfig = Skill.GetSkillConfig(v[1])
  2239. if skillConfig.cmd == "physicalDamageMul" and obj.hurtType == CombatDefine.PHY_HURT_TYPE then
  2240. return math.random(skillConfig.beSkillArgs[1], skillConfig.beSkillArgs[2])
  2241. end
  2242. if skillConfig.cmd == "magicDamageMul" and obj.hurtType == CombatDefine.MAGIC_HURT_TYPE then
  2243. return math.random(skillConfig.beSkillArgs[1], skillConfig.beSkillArgs[2])
  2244. end
  2245. end
  2246. end
  2247. end
  2248. -- 回血翻倍
  2249. function GetBeSkillRestoretHPMul(obj)
  2250. local mul = 1
  2251. if obj.beSkillList[BESKILL_TYPE72] then
  2252. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2253. local skillConfig = Skill.GetSkillConfig(v[1])
  2254. if skillConfig.cmd == "restoreHPMul" then
  2255. local r = math.random(1,10000)
  2256. if r <= (skillConfig.beSkillArgs[2] or 0) then
  2257. mul = skillConfig.beSkillArgs[1] or 1
  2258. end
  2259. return mul
  2260. end
  2261. end
  2262. end
  2263. return mul
  2264. end