BeSkill.lua 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481
  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. function onSkillID(obj,skillID)
  495. --local skillConfig = SkillExcel[skillID]
  496. local skillConfig = Skill.GetSkillConfig(skillID)
  497. if skillConfig.type == CombatDefine.SKILL_TYPE1 and obj.beSkillList[BESKILL_TYPE25] then
  498. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE25]) do
  499. if canUse(obj,v) then
  500. --local conf = SkillExcel[v[1]]
  501. local conf = Skill.GetSkillConfig(v[1])
  502. return conf.args[1]
  503. end
  504. end
  505. end
  506. return skillID
  507. end
  508. local function use(attacker,targets,data,newFrame, packBuff, hitObj)
  509. if canUse(attacker,data) and canUseOnHit(targets and targets[1],data) then
  510. --print("beskill realuse:",attacker.pos,data[1])
  511. --local skillConfig = SkillExcel[data[1]]
  512. local skillConfig = Skill.GetSkillConfig(data[1])
  513. local ret, arg2
  514. -- 二次元连击触发帧不新加帧
  515. if ProjectLogic.isSsecy() and skillConfig.cmd == "combo" then
  516. newFrame = false
  517. end
  518. if packBuff then
  519. CombatImpl.afterBuff()
  520. end
  521. if Skill.CMD[skillConfig.cmd] then
  522. if newFrame or CombatImpl.isSkillFrameEmpty() then
  523. --进入战斗时,未加入任何战斗帧触发被动技能时,先添加被动技能的战斗帧,可以在这个战斗帧上挂被动技能引发的额外作用
  524. CombatImpl.addFrame()
  525. CombatImpl.setSkillID(attacker, data[1])
  526. end
  527. ret, arg2 = Skill.CMD[skillConfig.cmd](attacker,skillConfig,targets, hitObj)
  528. end
  529. --判断是否加喊话
  530. local isAddSkillFrame = CombatBuff.onUseBeSkill(attacker, skillConfig, targets, ret, nil, arg2)
  531. if skillConfig.contentType > 0 then
  532. if isAddSkillFrame then
  533. CombatImpl.addSaySkill(attacker,skillConfig)
  534. elseif ret or skillConfig.beSkillType == BESKILL_TYPE26 or
  535. skillConfig.beSkillType == BESKILL_TYPE23 or
  536. skillConfig.beSkillType == BESKILL_TYPE4 or
  537. skillConfig.beSkillType == BESKILL_TYPE44 then
  538. if CombatImpl.isSkillFrameEmpty() then
  539. CombatImpl.addFrame()
  540. CombatImpl.setSkillID(attacker, data[1])
  541. end
  542. CombatImpl.setSaySkill(attacker.pos,skillConfig.id,skillConfig.contentType)
  543. end
  544. end
  545. CombatImpl.addBeSkillPosUse(attacker.pos,data[1])
  546. else
  547. -- print("[beskill - use] 直接返回了1 id = "..data[1])
  548. end
  549. end
  550. function onHit(attacker,targets,skillID)
  551. if attacker.isPet or attacker.isElf then
  552. return
  553. end
  554. --local useSkillConfig = SkillExcel[skillID]
  555. local useSkillConfig = Skill.GetSkillConfig(skillID)
  556. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 then
  557. --[[for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  558. local obj = CombatImpl.objList[pos]
  559. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE13] then
  560. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE13]) do
  561. use(obj,targets,v)
  562. end
  563. end
  564. end]]
  565. if attacker.beSkillList[BESKILL_TYPE34] then
  566. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE34]) do
  567. --local skillConfig = SkillExcel[v[1]]
  568. local skillConfig = Skill.GetSkillConfig(v[1])
  569. local beSkillArgs = skillConfig.beSkillArgs
  570. if beSkillArgs[1] == "attackerBuffCmd" and beSkillArgs[2][1] == "shayi" then
  571. local shayiCnt = CombatBuff.getBuffCnt(attacker,"shayi")
  572. if shayiCnt > 0 then
  573. for i = 1,shayiCnt do
  574. use(attacker,targets,v,true)
  575. CombatImpl.instantFrameBuffer(attacker,v[1])
  576. end
  577. end
  578. CombatBuff.delShayi(attacker)
  579. elseif beSkillArgs[1] == "qusanNeedCmd" then
  580. local canUse = false
  581. for h,need in ipairs(beSkillArgs[2]) do
  582. if need == useSkillConfig.cmd then
  583. canUse = true
  584. break
  585. end
  586. end
  587. if canUse == true then
  588. use(attacker,targets,v,true)
  589. end
  590. elseif beSkillArgs[1] == "jiekongNeedCmd" then
  591. local canUse = false
  592. for h,need in ipairs(beSkillArgs[2]) do
  593. if need == useSkillConfig.cmd then
  594. canUse = true
  595. break
  596. end
  597. end
  598. if canUse == true then
  599. use(attacker,targets,v,true)
  600. end
  601. elseif beSkillArgs[1] == "skillID" then
  602. local canUse = false
  603. for _, targetSkill in ipairs(beSkillArgs[2]) do
  604. if skillID == targetSkill then
  605. canUse = true
  606. break
  607. end
  608. end
  609. if canUse == true then
  610. use(attacker,targets,v,true)
  611. end
  612. else
  613. use(attacker,targets,v)
  614. end
  615. end
  616. end
  617. end
  618. --非攻击性主动技能不处理被击被动技能
  619. if CombatObj.getValue(attacker,RoleDefine.HURT_COMBAT_NOW) <= 0 then
  620. if (useSkillConfig.type == CombatDefine.SKILL_TYPE1 or useSkillConfig.type == CombatDefine.SKILL_TYPE2) then
  621. if attacker.beSkillList[BESKILL_TYPE39] then
  622. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE39]) do
  623. use(attacker,targets,v)
  624. end
  625. end
  626. if attacker.beSkillList[BESKILL_TYPE70] then
  627. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE70]) do
  628. use(attacker,targets,v)
  629. end
  630. end
  631. end
  632. return
  633. end
  634. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 and attacker.beSkillList[BESKILL_TYPE1] then
  635. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE1]) do
  636. use(attacker,targets,v)
  637. end
  638. end
  639. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 and attacker.beSkillList[BESKILL_TYPE61] then
  640. local canUseSkill = true
  641. for index = 1, #targets do
  642. local target = targets[index]
  643. if target.hp <=0 then
  644. canUseSkill = false
  645. end
  646. end
  647. if canUseSkill then
  648. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE61]) do
  649. --local skillConfig = SkillExcel[v[1]]
  650. local skillConfig = Skill.GetSkillConfig(v[1])
  651. local beSkillArgs = skillConfig.beSkillArgs
  652. if beSkillArgs[1] == "skillID" then
  653. local canUse = false
  654. for _,v in ipairs(beSkillArgs[2]) do
  655. if skillID == v then
  656. canUse = true
  657. break
  658. end
  659. end
  660. if canUse then
  661. use(attacker,{},v)
  662. end
  663. end
  664. end
  665. end
  666. end
  667. if (useSkillConfig.type == CombatDefine.SKILL_TYPE1 or useSkillConfig.type == CombatDefine.SKILL_TYPE2 or useSkillConfig.type == CombatDefine.SKILL_TYPE3) then
  668. if attacker.beSkillList[BESKILL_TYPE39] then
  669. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE39]) do
  670. use(attacker,targets,v)
  671. end
  672. end
  673. if attacker.beSkillList[BESKILL_TYPE46] then
  674. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE46]) do
  675. use(attacker,targets,v)
  676. end
  677. end
  678. if attacker.beSkillList[BESKILL_TYPE70] then
  679. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE70]) do
  680. use(attacker,targets,v)
  681. end
  682. end
  683. end
  684. local isDefendSideGedang = false
  685. local baojiDefender = {}
  686. for _,target in ipairs(targets) do
  687. if target.beSkillList[BESKILL_TYPE2] then
  688. for _,v in ipairs(target.beSkillList[BESKILL_TYPE2]) do
  689. use(target,{attacker},v)
  690. -- print("當前受到攻擊,觸發被動技能11111111111111ssssssssss1111111111111111",skillID)
  691. --table.print_lua_table(v)
  692. end
  693. end
  694. -- 友军受击
  695. for _,pos in ipairs(CombatDefine.SIDE2POS[target.side]) do
  696. local obj = CombatImpl.objList[pos]
  697. if obj and obj.pos ~= target.pos and obj.beSkillList[BESKILL_TYPE52] then
  698. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE52]) do
  699. use(target,{attacker},v)
  700. end
  701. end
  702. end
  703. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 and target.beSkillList[BESKILL_TYPE5] then
  704. for _,v in ipairs(target.beSkillList[BESKILL_TYPE5]) do
  705. use(target,{attacker},v)
  706. end
  707. end
  708. if target.isGedang then
  709. isDefendSideGedang = true
  710. if target.beSkillList[BESKILL_TYPE8] then
  711. for _,v in ipairs(target.beSkillList[BESKILL_TYPE8]) do
  712. use(target,{attacker},v)
  713. end
  714. end
  715. if attacker.beSkillList[BESKILL_TYPE6] then
  716. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE6]) do
  717. use(attacker,{target},v)
  718. end
  719. end
  720. --目标触发格挡次数
  721. if target.beSkillList[BESKILL_TYPE28] then
  722. for _, v in ipairs(target.beSkillList[BESKILL_TYPE28]) do
  723. --local skillConfig = SkillExcel[v[1]]
  724. local skillConfig = Skill.GetSkillConfig(v[1])
  725. local beSkillArgs = skillConfig.beSkillArgs
  726. if beSkillArgs[1] == "gedang" then
  727. target.isGedangCnt = target.isGedangCnt or 0
  728. local geDangLimit = beSkillArgs[2]
  729. if target.isGedangCnt >= geDangLimit then
  730. target.isGedangCnt = 0
  731. use(target,{attacker},v)
  732. end
  733. end
  734. end
  735. end
  736. end
  737. local chanRao = CombatBuff.isChanRao(target)
  738. if chanRao then
  739. if target.beSkillList[BESKILL_TYPE29] then
  740. for _,v in ipairs(target.beSkillList[BESKILL_TYPE29]) do
  741. use(target,{attacker},v)
  742. end
  743. end
  744. end
  745. if target.isBaoji then
  746. if target.beSkillList[BESKILL_TYPE7] then
  747. for _,v in ipairs(target.beSkillList[BESKILL_TYPE7]) do
  748. use(target,{attacker},v)
  749. end
  750. end
  751. baojiDefender[#baojiDefender+1] = target
  752. end
  753. -- if target.buffCmd["winner_nuhuo"] then
  754. -- local nIndex = target.buffCmd["winner_nuhuo"][1]
  755. -- local tBuffData = target.buffer[nIndex]
  756. -- if tBuffData.cnt < 10 then
  757. -- tBuffData.cnt = tBuffData.cnt + 1
  758. -- end
  759. -- end
  760. end
  761. local side = attacker.side
  762. local defendSide = side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  763. local target = targets[1]
  764. if target and target.side == defendSide and CombatObj.getValue(attacker,RoleDefine.RATE_COMBAT_NOW) > 0 then
  765. if attacker.beSkillList[BESKILL_TYPE73] then
  766. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE73]) do
  767. use(attacker,targets,v)
  768. end
  769. end
  770. end
  771. --普通技能触发
  772. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 then
  773. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  774. local obj = CombatImpl.objList[pos]
  775. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE53] then
  776. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE53]) do
  777. use(attacker,targets,v)
  778. end
  779. end
  780. end
  781. end
  782. --主动技能触发
  783. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 then
  784. for _,pos in ipairs(CombatDefine.SIDE2POS[0]) do
  785. local obj = CombatImpl.objList[pos]
  786. local objSide = pos <= 6 and CombatDefine.ATTACK_SIDE or CombatDefine.DEFEND_SIDE
  787. --触发自己这方的
  788. if side == objSide then
  789. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE13] then
  790. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE13]) do
  791. use(obj,targets,v)
  792. end
  793. end
  794. end
  795. --触发任意一方
  796. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE31] then
  797. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE31]) do
  798. use(obj,targets,v)
  799. end
  800. end
  801. end
  802. end
  803. if not attacker.isBaoji then
  804. --指定技能没有暴击
  805. if attacker.beSkillList[BESKILL_TYPE59] then
  806. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE59]) do
  807. --local skillConfig = SkillExcel[v[1]]
  808. local skillConfig = Skill.GetSkillConfig(v[1])
  809. local beSkillArgs = skillConfig.beSkillArgs
  810. if beSkillArgs[1] == "skillID" then
  811. local canUse = false
  812. for _,v in ipairs(beSkillArgs[2]) do
  813. if skillID == v then
  814. canUse = true
  815. break
  816. end
  817. end
  818. if canUse then
  819. use(attacker,{},v)
  820. end
  821. end
  822. end
  823. end
  824. end
  825. if attacker.isBaoji then
  826. --普通暴击技能触发
  827. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 then
  828. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  829. local obj = CombatImpl.objList[pos]
  830. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE65] then
  831. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE65]) do
  832. use(attacker,targets,v)
  833. end
  834. end
  835. end
  836. end
  837. if attacker.beSkillList[BESKILL_TYPE4] then
  838. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE4]) do
  839. use(attacker,baojiDefender,v)
  840. end
  841. end
  842. if attacker.beSkillList[BESKILL_TYPE44] and CombatImpl.isFanji then
  843. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE44]) do
  844. use(attacker,baojiDefender,v)
  845. end
  846. end
  847. --指定技能暴击
  848. if attacker.beSkillList[BESKILL_TYPE58] then
  849. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE58]) do
  850. --local skillConfig = SkillExcel[v[1]]
  851. local skillConfig = Skill.GetSkillConfig(v[1])
  852. local beSkillArgs = skillConfig.beSkillArgs
  853. if beSkillArgs[1] == "skillID" then
  854. local canUse = false
  855. for _,v in ipairs(beSkillArgs[2]) do
  856. if skillID == v then
  857. canUse = true
  858. break
  859. end
  860. end
  861. if canUse then
  862. use(attacker,baojiDefender,v)
  863. end
  864. end
  865. end
  866. end
  867. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  868. local obj = CombatImpl.objList[pos]
  869. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE14] then
  870. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE14]) do
  871. use(obj,targets,v)
  872. end
  873. end
  874. end
  875. end
  876. if isDefendSideGedang then
  877. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  878. local obj = CombatImpl.objList[pos]
  879. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE9] then
  880. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE9]) do
  881. use(obj,targets,v)
  882. end
  883. end
  884. end
  885. end
  886. comboCheck(attacker, side)
  887. end
  888. function onHp(obj, hurt, attackPos)
  889. if obj.beSkillList[BESKILL_TYPE3] then
  890. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE3]) do
  891. use(obj,{},v)
  892. end
  893. end
  894. if obj.beSkillList[BESKILL_TYPE67] then
  895. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE67]) do
  896. use(obj,{},v)
  897. end
  898. end
  899. local attacker = CombatImpl.objList[attackPos]
  900. if attacker and attacker.beSkillList[BESKILL_TYPE30] and obj.pos ~= attackPos then
  901. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE30]) do
  902. --local skillConfig = SkillExcel[v[1]]
  903. local skillConfig = Skill.GetSkillConfig(v[1])
  904. local beSkillArgs = skillConfig.beSkillArgs
  905. obj.paramData.isbeSkillByHp = obj.paramData.isbeSkillByHp or 0
  906. if beSkillArgs[1] then
  907. if beSkillArgs[1] == "tohp" then
  908. local hp = obj.hp
  909. local hpMax = CombatObj.getHpMax(obj)
  910. if hp > hpMax * beSkillArgs[2]/10000 then
  911. obj.paramData.isbeSkillByHp = 0 --恢复到上限
  912. else
  913. if obj.isbeSkillByHp == 0 then
  914. obj.paramData.isbeSkillByHp = 1 --达到下限
  915. end
  916. end
  917. elseif beSkillArgs[1] == "hurthpper" then
  918. local hpMax = CombatObj.getHpMax(obj)
  919. local percent = -hurt/hpMax
  920. if percent > beSkillArgs[2]/10000 then -- 伤害超过目标生命值上限X%时
  921. use(attacker,{obj},v)
  922. end
  923. elseif beSkillArgs[1] == "speed" then
  924. local atkSpeed = CombatImpl.getValue(attacker,RoleDefine.SPEED)
  925. local defSpeed = CombatImpl.getValue(obj,RoleDefine.SPEED)
  926. if atkSpeed > defSpeed then
  927. use(attacker,{obj},v)
  928. end
  929. end
  930. end
  931. --使用技能
  932. if obj.paramData.isbeSkillByHp == 1 then
  933. use(attacker,{obj},v)
  934. obj.paramData.isbeSkillByHp = 2
  935. end
  936. end
  937. end
  938. end
  939. -- 选择合适的复活技能
  940. function selectReviceSkill(obj, attacker)
  941. local reviveSkillList = {}
  942. local len = 0
  943. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  944. local skillID = v[1]
  945. local isFuwenSkill = v[5]
  946. --local skillConfig = SkillExcel[skillID]
  947. local skillConfig = Skill.GetSkillConfig(skillID)
  948. if skillConfig.cmd == "revive" then
  949. --有可使用的主动复活技能
  950. local state = isCanRevive(obj, attacker, v)
  951. if state and isFuwenSkill == 0 then
  952. if checkLimit(v) then
  953. len = len + 1
  954. reviveSkillList[k] = 1
  955. break
  956. end
  957. end
  958. end
  959. end
  960. -- 没有再取符文技能的复活
  961. if len == 0 then
  962. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  963. local skillID = v[1]
  964. local isFuwenSkill = v[5]
  965. --local skillConfig = SkillExcel[skillID]
  966. local skillConfig = Skill.GetSkillConfig(skillID)
  967. if skillConfig.cmd == "revive" then
  968. local state = isCanRevive(obj, attacker, v)
  969. if state and isFuwenSkill == 1 then
  970. --被动技能次数限制判断
  971. if checkLimit(v) then
  972. reviveSkillList[k] = 1
  973. break
  974. end
  975. end
  976. end
  977. end
  978. end
  979. return reviveSkillList
  980. end
  981. function onDie(obj, hurt, attackPos)
  982. if obj.hp > 0 then
  983. return
  984. end
  985. local side = obj.side
  986. local attacker = CombatImpl.objList[attackPos]
  987. if obj.dieSkill then
  988. if attacker and attacker.beSkillList[BESKILL_TYPE43] then
  989. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE43]) do
  990. --local skillConfig = SkillExcel[v[1]]
  991. local skillConfig = Skill.GetSkillConfig(v[1])
  992. for _,v1 in ipairs(skillConfig.beSkillArgs) do
  993. if v1 == obj.dieSkill then
  994. use(attacker,{obj},v)
  995. break
  996. end
  997. end
  998. end
  999. end
  1000. end
  1001. local defendSide = side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  1002. for _,posData in ipairs(posSortBySpeed[side]) do
  1003. local pos = posData[1]
  1004. local target = CombatImpl.objList[pos]
  1005. if target and target.hp > 0 then
  1006. if target.beSkillList[BESKILL_TYPE16] then
  1007. for _,v in ipairs(target.beSkillList[BESKILL_TYPE16]) do
  1008. use(target,{obj},v)
  1009. end
  1010. end
  1011. if target.beSkillList[BESKILL_TYPE18] then
  1012. for _,v in ipairs(target.beSkillList[BESKILL_TYPE18]) do
  1013. use(target,{obj},v)
  1014. end
  1015. end
  1016. end
  1017. end
  1018. for _,posData in ipairs(posSortBySpeed[defendSide]) do
  1019. local pos = posData[1]
  1020. local target = CombatImpl.objList[pos]
  1021. if target and target.hp > 0 then
  1022. if target.beSkillList[BESKILL_TYPE17] then
  1023. for _,v in ipairs(target.beSkillList[BESKILL_TYPE17]) do
  1024. use(target,{obj},v)
  1025. end
  1026. end
  1027. if target.beSkillList[BESKILL_TYPE18] then
  1028. for _,v in ipairs(target.beSkillList[BESKILL_TYPE18]) do
  1029. use(target,{obj},v)
  1030. end
  1031. end
  1032. end
  1033. end
  1034. if attacker and attacker.beSkillList and attacker.beSkillList[BESKILL_TYPE30] and obj.pos ~= attackPos then
  1035. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE30]) do
  1036. if obj.isbeSkillByHp == nil or
  1037. obj.isbeSkillByHp == 0 then
  1038. use(attacker,{},v)
  1039. end
  1040. end
  1041. end
  1042. if attacker and attacker.beSkillList and attacker.beSkillList[BESKILL_TYPE35] then
  1043. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE35]) do
  1044. use(attacker,{obj},v)
  1045. end
  1046. end
  1047. if obj.beSkillList[BESKILL_TYPE15] then
  1048. -- 选择其中一个使用
  1049. local reviceSkillList = selectReviceSkill(obj, attacker)
  1050. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  1051. local skillID = v[1]
  1052. --local skillConfig = SkillExcel[skillID]
  1053. local skillConfig = Skill.GetSkillConfig(skillID)
  1054. if skillConfig.cmd == "revive" then
  1055. if reviceSkillList[k] then
  1056. use(obj,{},v)
  1057. -- break
  1058. end
  1059. else
  1060. use(obj,{},v)
  1061. end
  1062. end
  1063. end
  1064. for _,pos in ipairs(CombatDefine.SIDE2POS[defendSide]) do
  1065. local defendobj = CombatImpl.objList[pos]
  1066. if defendobj and defendobj.hp > 0 and defendobj.beSkillList[BESKILL_TYPE66] then
  1067. for _,v in ipairs(defendobj.beSkillList[BESKILL_TYPE66]) do
  1068. --local skillConfig = SkillExcel[v[1]]
  1069. local skillConfig = Skill.GetSkillConfig(v[1])
  1070. if skillConfig and skillConfig.otherArgs.tdBuffCmd then
  1071. if obj.bufferCmd[skillConfig.otherArgs.tdBuffCmd] then
  1072. use(defendobj,{},v)
  1073. end
  1074. end
  1075. end
  1076. end
  1077. end
  1078. end
  1079. function onAddBuffer(obj,buffer)
  1080. --local conf = BufferExcel[buffer.id]
  1081. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1082. local attacker = CombatImpl.objList[buffer.attackPos]
  1083. local cmd = conf.cmd
  1084. if cmd == "hurt" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "ranshao" then
  1085. if obj.beSkillList[BESKILL_TYPE10] then
  1086. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE10]) do
  1087. use(obj,{attacker},v)
  1088. end
  1089. end
  1090. end
  1091. if cmd == "bingdong" or cmd == "jiansu" then
  1092. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1093. local target = CombatImpl.objList[pos]
  1094. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE63] then
  1095. for _,v in ipairs(target.beSkillList[BESKILL_TYPE63]) do
  1096. use(target,{obj},v)
  1097. end
  1098. end
  1099. end
  1100. end
  1101. if CombatBuff.isControlCmd(cmd) then
  1102. if obj.beSkillList[BESKILL_TYPE11] then
  1103. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE11]) do
  1104. use(obj,{attacker},v)
  1105. end
  1106. end
  1107. if obj.beSkillList[BESKILL_TYPE67] then
  1108. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE67]) do
  1109. use(obj,{attacker},v, true, true)
  1110. end
  1111. end
  1112. end
  1113. if cmd == "ranshao" then
  1114. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1115. local target = CombatImpl.objList[pos]
  1116. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE12] then
  1117. for _,v in ipairs(target.beSkillList[BESKILL_TYPE12]) do
  1118. local beSkillUseCnt = CombatImpl.getBeSkillUse(target,obj.pos,v[1])--特殊条件特殊处理:同一英雄在同一时间被施加多次燃烧状态时只触发一次
  1119. if beSkillUseCnt == 0 then
  1120. use(target,{obj},v)
  1121. CombatImpl.addBeSkillUse(target,obj.pos,v[1])
  1122. end
  1123. end
  1124. end
  1125. end
  1126. end
  1127. if cmd == "zuzhou" then
  1128. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1129. local target = CombatImpl.objList[pos]
  1130. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE51] then
  1131. for _,v in ipairs(target.beSkillList[BESKILL_TYPE51]) do
  1132. use(target,{obj},v)
  1133. end
  1134. end
  1135. end
  1136. end
  1137. if cmd == "revive" then
  1138. if obj.beSkillList[BESKILL_TYPE33] then
  1139. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE33]) do
  1140. use(obj,{attacker},v)
  1141. end
  1142. end
  1143. end
  1144. end
  1145. function onDelBingDongBuffer(obj, buffer)
  1146. --local conf = BufferExcel[buffer.id]
  1147. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1148. local attacker = CombatImpl.objList[buffer.attackPos]
  1149. if conf.cmd == "bingdong" then
  1150. for _, pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1151. local target = CombatImpl.objList[pos]
  1152. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE64] then
  1153. for _,v in ipairs(target.beSkillList[BESKILL_TYPE64]) do
  1154. use(target,{obj},v)
  1155. end
  1156. end
  1157. end
  1158. end
  1159. end
  1160. --援军上阵触发
  1161. function onBackupBegin(obj)
  1162. if not obj then return end
  1163. if CombatDefine.isBackup(obj) ~= CombatDefine.BACKUP_TYPE2 then return end
  1164. -- 备份的被动技能上阵
  1165. if obj.backUpSkillList then
  1166. obj.beSkillList = obj.backUpSkillList
  1167. obj.backUpSkillList = nil
  1168. end
  1169. -- 出站计算属性
  1170. if obj.beSkillList[BESKILL_TYPE26] then
  1171. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE26]) do
  1172. if canUse(obj,v) then
  1173. --local skillConfig = SkillExcel[v[1]]
  1174. local skillConfig = Skill.GetSkillConfig(v[1])
  1175. if skillConfig.cmd == "attr" then
  1176. for _,v1 in ipairs(skillConfig.args) do
  1177. obj.sysAttr[v1[1]] = obj.sysAttr[v1[1]] +v1[2]
  1178. end
  1179. obj.isSysAttrChange = true
  1180. elseif skillConfig.cmd == "normalTarget" then
  1181. use(obj,{},v)
  1182. end
  1183. end
  1184. end
  1185. end
  1186. table.sort(posSortBySpeed[CombatDefine.ATTACK_SIDE],posSpeedCmp)
  1187. table.sort(posSortBySpeed[CombatDefine.DEFEND_SIDE],posSpeedCmp)
  1188. --援军出战触发
  1189. if obj and obj.beSkillList[BESKILL_TYPE32] then
  1190. for k,v in ipairs(obj.beSkillList[BESKILL_TYPE32]) do
  1191. use(obj,{},v)
  1192. end
  1193. end
  1194. --上场技能
  1195. CombatDefine.BACKUP_BUFF_SKILL[2] = 1
  1196. use(obj,{}, CombatDefine.BACKUP_BUFF_SKILL)
  1197. end
  1198. function onRoundBegin(round)
  1199. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1200. local target = CombatImpl.objList[pos]
  1201. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE19] then
  1202. for _,v in ipairs(target.beSkillList[BESKILL_TYPE19]) do
  1203. --table.print_lua_table(v)
  1204. -- print("beskill = onRoundBegin 开始使用技能 ID = "..v[1])
  1205. use(target,{},v)
  1206. end
  1207. end
  1208. -- 生命值触发
  1209. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE62] then
  1210. for _,v in ipairs(target.beSkillList[BESKILL_TYPE62]) do
  1211. --local skillConfig = SkillExcel[v[1]]
  1212. local skillConfig = Skill.GetSkillConfig(v[1])
  1213. local beSkillArgs = skillConfig.beSkillArgs
  1214. if beSkillArgs[1] == 1 then
  1215. local hpMax = CombatObj.getHpMax(target)
  1216. local percent = target.hp/hpMax
  1217. if percent > beSkillArgs[2]/10000 then
  1218. use(target,{},v)
  1219. end
  1220. end
  1221. if beSkillArgs[1] == 2 then
  1222. local hpMax = CombatObj.getHpMax(target)
  1223. local percent = target.hp/hpMax
  1224. if percent < beSkillArgs[2]/10000 then
  1225. use(target,{},v)
  1226. end
  1227. end
  1228. end
  1229. end
  1230. end
  1231. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1232. local target = CombatImpl.objList[pos]
  1233. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE47] then
  1234. for _,v in ipairs(target.beSkillList[BESKILL_TYPE47]) do
  1235. --local skillConfig = SkillExcel[v[1]]
  1236. local skillConfig = Skill.GetSkillConfig(v[1])
  1237. if skillConfig.cmd == "attr" then
  1238. for _,v1 in ipairs(skillConfig.args) do
  1239. target.sysAttr[v1[1]] = target.sysAttr[v1[1]] +v1[2]
  1240. end
  1241. CombatObj.calcAttr(target)
  1242. CombatImpl.addFrame()
  1243. CombatImpl.setSkillID(target, v[1])
  1244. CombatImpl.setSaySkill(target.pos,skillConfig.id,skillConfig.contentType)
  1245. end
  1246. end
  1247. end
  1248. end
  1249. if round and round == 1 then
  1250. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1251. local obj = CombatImpl.objList[pos]
  1252. if obj and obj.beSkillList[BESKILL_TYPE32] then
  1253. for k,v in ipairs(obj.beSkillList[BESKILL_TYPE32]) do
  1254. use(obj,{},v)
  1255. end
  1256. end
  1257. end
  1258. end
  1259. -- 在最后加
  1260. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1261. local target = CombatImpl.objList[pos]
  1262. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE71] then
  1263. for _,v in ipairs(target.beSkillList[BESKILL_TYPE71]) do
  1264. -- print("[onRoundBegin] 开始加类型71的被动技能 pos = "..pos)
  1265. local skillConfig = Skill.GetSkillConfig(v[1])
  1266. if skillConfig and skillConfig.args then
  1267. -- local nLen = skillConfig.args[1]
  1268. -- for i = 1, nLen, 1 do
  1269. use(target,{},v)
  1270. -- end
  1271. end
  1272. end
  1273. end
  1274. end
  1275. end
  1276. function beforeFanji(obj, hitObj, isEnd)
  1277. if not obj or obj.isPet or obj.isElf then
  1278. return
  1279. end
  1280. if obj and obj.hurtType == CombatDefine.PHY_HURT_TYPE then
  1281. if obj and obj.beSkillList and obj.beSkillList[BESKILL_TYPE37] then
  1282. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE37]) do
  1283. -- use(obj,{},v)
  1284. use(obj, {}, v, nil, nil, hitObj)
  1285. end
  1286. end
  1287. else
  1288. if obj and obj.beSkillList and obj.beSkillList[BESKILL_TYPE38] then
  1289. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE38]) do
  1290. use(obj,{},v)
  1291. end
  1292. end
  1293. end
  1294. end
  1295. function onRoundEnd(isRoundEnd)
  1296. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1297. local obj = CombatImpl.objList[pos]
  1298. if obj and obj.beSkillList[BESKILL_TYPE36] then
  1299. if pos == 1 then
  1300. end
  1301. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE36]) do
  1302. use(obj,{},v)
  1303. end
  1304. end
  1305. end
  1306. if isRoundEnd then
  1307. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1308. local target = CombatImpl.objList[pos]
  1309. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE20] then
  1310. for _,v in ipairs(target.beSkillList[BESKILL_TYPE20]) do
  1311. use(target,{},v)
  1312. end
  1313. end
  1314. end
  1315. end
  1316. end
  1317. function posSpeedCmp(a,b)
  1318. if a[2] > b[2] then
  1319. return true
  1320. elseif a[2] < b[2] then
  1321. return false
  1322. else
  1323. return a[1] < b[1]
  1324. end
  1325. end
  1326. -- 计算遗物特殊属性部分
  1327. local function BeSkill_RelicAttribute(ReleaserObj, tSkillInfo)
  1328. local nSkillID = tSkillInfo[1]
  1329. local tSkilConfig = Skill.GetSkillConfig(nSkillID)
  1330. if not tSkilConfig then
  1331. -- print("[BeSkill_RelicAttribute] 不存在技能配置 nSkillID = "..nSkillID)
  1332. return
  1333. end
  1334. local winnerID = ReleaserObj and ReleaserObj.relic and ReleaserObj.relic.relicID or 0
  1335. local winnerStar = ReleaserObj and ReleaserObj.relic and ReleaserObj.relic.star or 0
  1336. if 0 >= winnerID or 0 >= winnerStar then
  1337. return
  1338. end
  1339. -- 特殊处理防御为0, 加标识
  1340. if tSkilConfig.otherArgs.selefDefense then
  1341. ReleaserObj.relicAttr.bSpecialDef = true
  1342. end
  1343. -- 是否增加args属性
  1344. local bAddArgs = true
  1345. if tSkilConfig.otherArgs.winnerfiveraces then
  1346. bAddArgs = false
  1347. end
  1348. local targets = TargetMode.getTargets(ReleaserObj, tSkilConfig.targetMode)
  1349. if #targets > 0 and true == bAddArgs then
  1350. for _, obj in ipairs(targets) do
  1351. -- 加固定值属性
  1352. for _, v in ipairs(tSkilConfig.args) do
  1353. if not obj.relicAttr.FixedAttr[v[1]] then
  1354. obj.relicAttr.FixedAttr[v[1]] = 0
  1355. end
  1356. obj.relicAttr.FixedAttr[v[1]] = obj.relicAttr.FixedAttr[v[1]] + v[2]
  1357. end
  1358. end
  1359. else
  1360. -- print("[BeSkill_RelicAttribute] 获取不到对应的技能目标对象")
  1361. end
  1362. local nSide = ReleaserObj.side
  1363. local tCamp = {}
  1364. -- 检查
  1365. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1366. local obj = CombatImpl.objList[pos]
  1367. if obj and obj.side and nSide == obj.side then
  1368. local nCamp = obj.camp
  1369. if nCamp then
  1370. tCamp[nCamp] = 1
  1371. end
  1372. end
  1373. end
  1374. local bAllCamp = true
  1375. for i = CombatDefine.CAMP_TYPE1, CombatDefine.CAMP_TYPE5, 1 do
  1376. if not tCamp[i] then
  1377. bAllCamp = false
  1378. break
  1379. end
  1380. end
  1381. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1382. local obj = CombatImpl.objList[pos]
  1383. if obj and obj.side and nSide == obj.side then
  1384. -- 处理百分比值
  1385. -- 治疗
  1386. if tSkilConfig.otherArgs.jobZhiliao then
  1387. --table.print_lua_table(tSkilConfig.otherArgs.jobZhiliao)
  1388. if CombatBuff.isJob(obj, {CombatDefine.JOB_TYPE4}) then
  1389. -- local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1390. if not obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1391. obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] = 0
  1392. end
  1393. local nValue = tSkilConfig.otherArgs.jobZhiliao[2]
  1394. -- print("BeSkill_RelicAttribute 治療 nValue = ".. nValue)
  1395. obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] = obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] + nValue
  1396. if obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] then
  1397. -- print("[BeSkill_RelicAttribute] 治療加成 為 nNewValue = "..obj.relicAttr.ProAttr[RoleDefine.ZAOCHENG_HP_ADD_RATE] )
  1398. else
  1399. -- print("[BeSkill_RelicAttribute] 不存在 nNewValue" )
  1400. end
  1401. end
  1402. end
  1403. -- 免伤 百分比
  1404. if tSkilConfig.otherArgs.jobMianshang then
  1405. if CombatBuff.isJob(obj, {CombatDefine.JOB_TYPE1}) then
  1406. --local extraRate = WinnerRelicLogic.WinnerRelic_GetRateDef(winnerID, winnerStar)
  1407. if not obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] then
  1408. obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] = 0
  1409. end
  1410. local nValue = tSkilConfig.otherArgs.jobMianshang[2]
  1411. -- print("BeSkill_RelicAttribute 免伤 nValue = ".. nValue)
  1412. obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] = obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE] + nValue
  1413. -- print("[BeSkill_RelicAttribute] 免傷加成 為 nValue = "..nValue.." nNewValue = "..obj.relicAttr.ProAttr[RoleDefine.JIANSHANG_RATE])
  1414. end
  1415. end
  1416. -- 防御增加固定值
  1417. if tSkilConfig.otherArgs.jobDefense then
  1418. if CombatBuff.isJob(obj, {CombatDefine.JOB_TYPE4, CombatDefine.JOB_TYPE1}) then
  1419. if winnerID > 0 and winnerStar > 0 then
  1420. local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1421. if not obj.relicAttr.FixedAttr[RoleDefine.DEF] then
  1422. obj.relicAttr.FixedAttr[RoleDefine.DEF] = 0
  1423. end
  1424. obj.relicAttr.FixedAttr[RoleDefine.DEF] = obj.relicAttr.FixedAttr[RoleDefine.DEF] + extraRate
  1425. end
  1426. end
  1427. end
  1428. -- 攻击 百分比
  1429. if tSkilConfig.otherArgs.racialAtk then
  1430. if CombatBuff.isCamp(obj, {CombatDefine.COMBAT_TYPE27}) then
  1431. local extraRate = WinnerRelicLogic.WinnerRelic_GetRateAttack(winnerID, winnerStar)
  1432. if not obj.relicAttr.ProAttr[RoleDefine.ATK] then
  1433. obj.relicAttr.ProAttr[RoleDefine.ATK] = 0
  1434. end
  1435. obj.relicAttr.ProAttr[RoleDefine.ATK] = obj.relicAttr.ProAttr[RoleDefine.ATK] + extraRate
  1436. end
  1437. end
  1438. -- 上阵阵容为全职业,加固定值
  1439. if tSkilConfig.otherArgs.winnerfiveraces and bAllCamp == true then
  1440. for _, v in ipairs(tSkilConfig.args) do
  1441. if not obj.relicAttr.FixedAttr[v[1]] then
  1442. obj.relicAttr.FixedAttr[v[1]] = 0
  1443. end
  1444. obj.relicAttr.FixedAttr[v[1]] = obj.relicAttr.FixedAttr[v[1]] + v[2]
  1445. end
  1446. end
  1447. end
  1448. end
  1449. end
  1450. function onFightBegin()
  1451. posSortBySpeed[CombatDefine.ATTACK_SIDE] = {}
  1452. posSortBySpeed[CombatDefine.DEFEND_SIDE] = {}
  1453. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1454. local obj = CombatImpl.objList[pos]
  1455. if obj then
  1456. obj.hp = obj.hp and obj.hp or 1
  1457. end
  1458. end
  1459. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1460. local obj = CombatImpl.objList[pos]
  1461. if obj then
  1462. if obj.beSkillList[BESKILL_TYPE26] then
  1463. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE26]) do
  1464. if canUse(obj,v) then
  1465. --local skillConfig = SkillExcel[v[1]]
  1466. local skillConfig = Skill.GetSkillConfig(v[1])
  1467. if skillConfig.cmd == "attr" then
  1468. for _,v1 in ipairs(skillConfig.args) do
  1469. obj.sysAttr[v1[1]] = obj.sysAttr[v1[1]] +v1[2]
  1470. end
  1471. obj.isSysAttrChange = true
  1472. elseif skillConfig.cmd == "normalTarget" then
  1473. use(obj,{},v)
  1474. elseif skillConfig.cmd == "winnerRelicSkill" then
  1475. use(obj,{},v)
  1476. BeSkill_RelicAttribute(obj, v)
  1477. end
  1478. end
  1479. end
  1480. end
  1481. if pos <= CombatDefine.COMBAT_HERO_CNT then
  1482. posSortBySpeed[CombatDefine.ATTACK_SIDE][#posSortBySpeed[CombatDefine.ATTACK_SIDE]+1] = {pos,obj.attr and obj.attr[RoleDefine.SPEED] or 0}
  1483. elseif pos <= CombatDefine.COMBAT_HERO_CNT * 2 then
  1484. posSortBySpeed[CombatDefine.DEFEND_SIDE][#posSortBySpeed[CombatDefine.DEFEND_SIDE]+1] = {pos,obj.attr and obj.attr[RoleDefine.SPEED] or 0}
  1485. end
  1486. end
  1487. end
  1488. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1489. local obj = CombatImpl.objList[pos]
  1490. if obj then
  1491. obj.hp = nil
  1492. end
  1493. end
  1494. table.sort(posSortBySpeed[CombatDefine.ATTACK_SIDE],posSpeedCmp)
  1495. table.sort(posSortBySpeed[CombatDefine.DEFEND_SIDE],posSpeedCmp)
  1496. end
  1497. function onCombatPetBe(round)
  1498. if round <= 1 then
  1499. return
  1500. end
  1501. for side = 1,CombatDefine.DEFEND_SIDE do
  1502. local pet = CombatImpl.petList[side]
  1503. if pet and pet.petID and pet.beSkillList[BESKILL_TYPE27] then
  1504. for _,v in ipairs(pet.beSkillList[BESKILL_TYPE27]) do
  1505. --local skillConfig = SkillExcel[v[1]]
  1506. local skillConfig = Skill.GetSkillConfig(v[1])
  1507. if skillConfig.cmd == "mp" then
  1508. use(pet,{},v)
  1509. end
  1510. end
  1511. end
  1512. end
  1513. end
  1514. -- 计算被动技能属性
  1515. local beSkillIDList = {}
  1516. function doCalcHero(obj, attrs, skinSkillID, heroConf)
  1517. for i = 1, #beSkillIDList do
  1518. beSkillIDList[i] = nil
  1519. end
  1520. heroConf = heroConf or HeroDefine.getAttrConfig(obj.id, obj.star)
  1521. local beSkillIDs = heroConf.beSkillList
  1522. local skinSkillConf = skinSkillID and SkinSkillExcel[skinSkillID]
  1523. if skinSkillConf then
  1524. beSkillIDs = skinSkillConf.beSkillList
  1525. end
  1526. local weapSkillList = HeroExclusiveWeapon.GetweaponEffectIdList(obj)
  1527. for _, skillID in ipairs(beSkillIDs) do
  1528. --local skillConfig = SkillExcel[skillID]
  1529. skillID = weapSkillList and weapSkillList[skillID] or skillID
  1530. local skillConfig = Skill.GetSkillConfig(skillID)
  1531. if skillConfig.beSkillType == BESKILL_TYPE24 and
  1532. ((not obj) or (obj.quality >= skillConfig.need)) then
  1533. for _,v in ipairs(skillConfig.args) do
  1534. beSkillIDList[#beSkillIDList + 1] = v
  1535. end
  1536. else
  1537. beSkillIDList[#beSkillIDList + 1] = skillID
  1538. end
  1539. end
  1540. for _, skillID in ipairs(beSkillIDList) do
  1541. --local skillConfig = SkillExcel[skillID]
  1542. local skillConfig = Skill.GetSkillConfig(skillID)
  1543. if skillConfig and skillConfig.cmd == "attr" and
  1544. skillConfig.beSkillType == BESKILL_TYPE23 and
  1545. ((not obj) or (obj.quality >= skillConfig.need)) then
  1546. for _, v in ipairs(skillConfig.args) do
  1547. RoleAttr.updateValue(v[1], v[2], attrs)
  1548. end
  1549. elseif skillConfig and skillConfig.cmd == "attrcomboAgain" and
  1550. skillConfig.beSkillType == BESKILL_TYPE70 and
  1551. ((not obj) or (obj.quality >= skillConfig.need)) then
  1552. for i, v in ipairs(skillConfig.args) do
  1553. if v[1] == 1 then
  1554. RoleAttr.updateValue(v[2], v[3], attrs)
  1555. end
  1556. end
  1557. end
  1558. end
  1559. end
  1560. function beforeHit(attacker,defender)
  1561. attacker.beforeHitCheck = false
  1562. if attacker.beSkillList[BESKILL_TYPE40] then
  1563. local hpMax = CombatObj.getHpMax(defender)
  1564. local hp = defender.hp
  1565. local defendHpRate = hp*10000/hpMax
  1566. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1567. --local skillConfig = SkillExcel[v[1]]
  1568. local skillConfig = Skill.GetSkillConfig(v[1])
  1569. if skillConfig.cmd == "lowerLimit" then
  1570. local args = skillConfig.args
  1571. if defendHpRate < args[1] then
  1572. attacker.beforeHitCheck = true
  1573. attacker.beskill40 = attacker.beskill40 or {}
  1574. attacker.beskill40[defender.pos] = 1
  1575. end
  1576. end
  1577. end
  1578. end
  1579. end
  1580. function afterHit(attacker,target, isEnd)
  1581. if attacker.beforeHitCheck then
  1582. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1583. use(attacker,{target},v)
  1584. end
  1585. end
  1586. -- beforeFanji(attacker, isEnd)
  1587. beforeFanji(attacker, target, isEnd)
  1588. end
  1589. function getOutAtkRate(attacker, defender)
  1590. local outAtkRate = 0
  1591. -- 首次攻击
  1592. local isFirstAttack = CombatImpl.firstAttack[attacker.side]
  1593. if isFirstAttack then
  1594. for _,pos in ipairs(CombatDefine.SIDE2POS[defender.side]) do
  1595. local objM = CombatImpl.objList[pos]
  1596. if objM and objM.beSkillList[BESKILL_TYPE50] then
  1597. for _,v in ipairs(objM.beSkillList[BESKILL_TYPE50]) do
  1598. --local skillConfig = SkillExcel[v[1]]
  1599. local skillConfig = Skill.GetSkillConfig(v[1])
  1600. if skillConfig and skillConfig.otherArgs.outAtkRate then
  1601. if skillConfig.otherArgs.outAtkRate >= outAtkRate then
  1602. outAtkRate = skillConfig.otherArgs.outAtkRate
  1603. end
  1604. end
  1605. end
  1606. end
  1607. end
  1608. end
  1609. return outAtkRate
  1610. end
  1611. function getOutAtkRate2(attacker, skillConfig)
  1612. local outAtkRate = 0
  1613. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE72] or {}) do
  1614. local config = Skill.GetSkillConfig(v[1])
  1615. if config.cmd == "addHurtRateByRand" then
  1616. local addHurtRate = 0
  1617. for _, skillInfo in ipairs(config.beSkillArgs[2]) do
  1618. if table.find(skillInfo[1], skillConfig.id) then
  1619. addHurtRate = skillInfo[2]
  1620. break
  1621. end
  1622. end
  1623. local randVal = math.random(0, 10000)
  1624. if randVal <= config.beSkillArgs[1] then
  1625. outAtkRate = outAtkRate + addHurtRate
  1626. end
  1627. end
  1628. end
  1629. return outAtkRate
  1630. end
  1631. function getExtraHurtRate(attacker,defender,skillConfig)
  1632. if not attacker or attacker.isPet then
  1633. return 0
  1634. end
  1635. local zhanyiRet = 0
  1636. local bodongHurtRet = 0
  1637. local zhenduiHurtRate = 0
  1638. local zhenduiLen = 0
  1639. local zhenduiList = {}
  1640. local bezhenduiList = {}
  1641. local hpHurtRate = 0
  1642. local extraSpeedHurt = 0
  1643. local firstHurt = 0
  1644. local sexHurt = 0
  1645. local campHurt = 0
  1646. local reJobHurt = 0
  1647. local buffAndHPSubHurt = 0
  1648. for k,skillList in pairs(attacker.beSkillList) do
  1649. for j,v in pairs(skillList) do
  1650. --local config = SkillExcel[v[1]]
  1651. local config = Skill.GetSkillConfig(v[1])
  1652. if config.cmd == "zhanyi" then --战意 伤害加成
  1653. local nowHp = attacker.hp
  1654. local hpMax = CombatObj.getHpMax(attacker)
  1655. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1656. if percent >= 1 then
  1657. zhanyiRet = zhanyiRet + (percent * config.args[2])
  1658. end
  1659. elseif config.cmd == "fuwenAKH" then
  1660. for i = 1,#config.otherArgs do
  1661. zhenduiLen = zhenduiLen + 1
  1662. zhenduiList[config.otherArgs[i][1]] = zhenduiList[config.otherArgs[i][1]] or 0
  1663. zhenduiList[config.otherArgs[i][1]] = zhenduiList[config.otherArgs[i][1]] + config.otherArgs[i][2]
  1664. end
  1665. elseif config.cmd == "hurtBodong" then
  1666. if canUse(attacker, v) then
  1667. local minRet = config.args[1]
  1668. local maxRet = config.args[2]
  1669. local randomRet = math.random(minRet, maxRet)
  1670. bodongHurtRet = bodongHurtRet + randomRet - 10000
  1671. end
  1672. elseif config.cmd == "hpExtraHurt" then
  1673. local hp = defender.hp
  1674. local beSkillArgs = config.beSkillArgs
  1675. local checkHp = CombatObj.getHpMax(defender) * beSkillArgs[3] / 10000
  1676. if beSkillArgs[2] == 1 and hp > checkHp then
  1677. hpHurtRate = beSkillArgs[4]
  1678. elseif beSkillArgs[2] == 2 and hp < checkHp then
  1679. hpHurtRate = beSkillArgs[4]
  1680. end
  1681. elseif config.cmd == "extraSpeedHurt" then
  1682. extraSpeedHurt = config.args[1]
  1683. elseif config.cmd == "firstAttackHurt" then
  1684. if canUse(attacker, v) then
  1685. firstHurt = config.args[1]
  1686. end
  1687. elseif config.cmd == "buffAndHPSub" then
  1688. local nowHp = defender.hp
  1689. local hpMax = CombatObj.getHpMax(defender)
  1690. local percent = math.floor((hpMax - nowHp )/hpMax * 100) --已损失血量百分比
  1691. local condCfg = config.args
  1692. local condRate = condCfg[1]
  1693. if percent >= condRate then
  1694. local condStatusList = condCfg[2] or {}
  1695. local objNowSatus = CombatBuff.getStatus(defender)
  1696. for _, buffCmd in pairs(condStatusList) do
  1697. if objNowSatus[buffCmd] then
  1698. buffAndHPSubHurt = condCfg[3] or 0
  1699. break
  1700. end
  1701. end
  1702. end
  1703. elseif config.cmd == "hpSubHurtAdd" then
  1704. local nowHp = attacker.hp
  1705. local hpMax = CombatObj.getHpMax(attacker)
  1706. local percent = math.floor((hpMax - nowHp )/hpMax * 100) --已损失血量百分比
  1707. local condCfg = config.beSkillArgs
  1708. local condRate = condCfg[1]
  1709. if percent >= condRate then
  1710. hpHurtRate = hpHurtRate + condCfg[2]
  1711. end
  1712. end
  1713. end
  1714. end
  1715. for k,skillList in pairs(defender.beSkillList) do
  1716. for j,v in pairs(skillList) do
  1717. --local conf = SkillExcel[v[1]]
  1718. local conf = Skill.GetSkillConfig(v[1])
  1719. if conf then
  1720. if conf.cmd == "befuwenAKH" then
  1721. for i = 1,#conf.otherArgs do
  1722. zhenduiLen = zhenduiLen + 1
  1723. bezhenduiList[conf.otherArgs[i][1]] = bezhenduiList[conf.otherArgs[i][1]] or 0
  1724. bezhenduiList[conf.otherArgs[i][1]] = bezhenduiList[conf.otherArgs[i][1]] + conf.otherArgs[i][2]
  1725. end
  1726. -- 受性别增伤
  1727. elseif conf.cmd == "sexHurt" then
  1728. if attacker.sex == conf.args[1] then
  1729. sexHurt = sexHurt + conf.args[2]
  1730. end
  1731. -- 受阵营增伤
  1732. elseif conf.cmd == "campHurt" then
  1733. if attacker.camp == conf.args[1] then
  1734. campHurt = campHurt + conf.args[2]
  1735. end
  1736. -- 受职业增伤
  1737. elseif conf.cmd == "reJobHurt" then
  1738. if attacker.job == conf.args[1] then
  1739. reJobHurt = reJobHurt + conf.args[2]
  1740. end
  1741. end
  1742. end
  1743. end
  1744. end
  1745. if zhenduiLen > 0 then
  1746. local bAdd = 0
  1747. for k,skillList in pairs(defender.beSkillList) do
  1748. for j,v in pairs(skillList) do
  1749. --local conf = SkillExcel[v[1]]
  1750. local conf = Skill.GetSkillConfig(v[1])
  1751. local isFuWenSkill = v[5]
  1752. if conf.cmd and conf.cmd ~= "" and zhenduiList[conf.cmd] then
  1753. -- 符文技能只生效一个
  1754. if isFuWenSkill == 1 then
  1755. if bAdd == 0 then
  1756. zhenduiHurtRate = zhenduiHurtRate + zhenduiList[conf.cmd]
  1757. bAdd = 1
  1758. end
  1759. else
  1760. zhenduiHurtRate = zhenduiHurtRate + zhenduiList[conf.cmd]
  1761. end
  1762. end
  1763. end
  1764. end
  1765. bAdd = 0
  1766. for k,skillList in pairs(attacker.beSkillList) do
  1767. for j,v in pairs(skillList) do
  1768. --local conf = SkillExcel[v[1]]
  1769. local conf = Skill.GetSkillConfig(v[1])
  1770. local isFuWenSkill = v[5]
  1771. if conf.cmd and conf.cmd ~= "" and bezhenduiList[conf.cmd] then
  1772. if isFuWenSkill == 1 then
  1773. if bAdd == 0 then
  1774. zhenduiHurtRate = zhenduiHurtRate + bezhenduiList[conf.cmd]
  1775. bAdd = 1
  1776. end
  1777. else
  1778. zhenduiHurtRate = zhenduiHurtRate + bezhenduiList[conf.cmd]
  1779. end
  1780. end
  1781. end
  1782. end
  1783. end
  1784. --特殊buff 对血族的加成
  1785. local campHurtRate = 0
  1786. local campRate = nil
  1787. local buffCmd = nil
  1788. local camp = nil
  1789. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1790. obj = CombatImpl.objList[pos]
  1791. if obj and obj.hp > 0 then
  1792. if obj.beSkillList[BESKILL_TYPE68] then
  1793. local beSkillList = obj.beSkillList[BESKILL_TYPE68][1]
  1794. --local skillConfig = SkillExcel[beSkillList[1]]
  1795. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1796. if skillConfig then
  1797. camp = skillConfig.otherArgs.calcCamp[1]
  1798. buffCmd = skillConfig.otherArgs.calcCamp[2]
  1799. campRate = skillConfig.otherArgs.calcCamp[3]
  1800. break
  1801. end
  1802. end
  1803. end
  1804. end
  1805. if buffCmd and campRate and attacker.camp == camp then
  1806. local campHurtCnt = 0
  1807. for _,pos in ipairs(CombatDefine.SIDE2POS[defender.side]) do
  1808. obj = CombatImpl.objList[pos]
  1809. if obj and obj.hp > 0 then
  1810. local isStatus1, cmd1, ind1 = CombatBuff.isStatus(obj, buffCmd)
  1811. if isStatus1 then
  1812. campHurtCnt = campHurtCnt + 1
  1813. end
  1814. end
  1815. end
  1816. if campHurtCnt > 0 then
  1817. campHurtRate = campHurtCnt * campRate
  1818. end
  1819. end
  1820. local extraHurtRate = zhanyiRet + zhenduiHurtRate + bodongHurtRet + hpHurtRate + extraSpeedHurt + firstHurt + sexHurt + campHurt + reJobHurt + campHurtRate + buffAndHPSubHurt
  1821. if attacker.beSkillList[BESKILL_TYPE40] and attacker.beforeHitCheck then
  1822. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1823. --local skillConfig = SkillExcel[v[1]]
  1824. local skillConfig = Skill.GetSkillConfig(v[1])
  1825. if skillConfig.cmd == "extraHurt" then
  1826. local args = skillConfig.args
  1827. extraHurtRate = extraHurtRate + args[1]
  1828. end
  1829. end
  1830. end
  1831. return extraHurtRate
  1832. end
  1833. --
  1834. function getExtraHurt(attacker, target, tUseskillConfig)
  1835. local extraHurt = 0
  1836. if attacker.beSkillList[BESKILL_TYPE55] then
  1837. local beSkillList = attacker.beSkillList[BESKILL_TYPE55][1]
  1838. --local skillConfig = SkillExcel[beSkillList[1]]
  1839. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1840. local buffCmd = target.bufferCmd[skillConfig.otherArgs.buffCmdHurtRate[1]]
  1841. local rate = skillConfig.otherArgs.buffCmdHurtRate[2] / 10000
  1842. if buffCmd then
  1843. local buffCnt = #buffCmd
  1844. local buffIndex = buffCmd[buffCnt]
  1845. local buffer = target.buffer[buffIndex]
  1846. --local conf = BufferExcel[buffer.id]
  1847. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1848. local hurt = buffer.arg[1]
  1849. extraHurt = extraHurt + hurt * rate * buffCnt
  1850. end
  1851. end
  1852. return extraHurt
  1853. end
  1854. -- 根据杀气buff获得额外属性加成
  1855. function GetExtraAttrByShaQi(attacker, targetAttrId)
  1856. local attrVal = 0
  1857. if not attacker then
  1858. return attrVal
  1859. end
  1860. -- for _, skillList in pairs(attacker.beSkillList) do
  1861. -- for _, v in pairs(skillList) do
  1862. -- local config = Skill.GetSkillConfig(v[1])
  1863. -- if config.cmd == "shaqi" then
  1864. -- local buffNum = CombatBuff.getBuffCnt(attacker, config.cmd)
  1865. -- if buffNum <= 0 then
  1866. -- return attrVal
  1867. -- end
  1868. -- for _, attrTb in ipairs(config.args) do
  1869. -- if attrTb[1] == targetAttrId then
  1870. -- attrVal = (attrTb[2] or 0) * buffNum
  1871. -- break
  1872. -- end
  1873. -- end
  1874. -- end
  1875. -- end
  1876. -- end
  1877. local buffNum = CombatBuff.getBuffCnt(attacker, "shaqi")
  1878. if buffNum <= 0 then
  1879. return attrVal
  1880. end
  1881. local attrArr
  1882. for i=1, attacker.buffer[0] do
  1883. local buffer = attacker.buffer[i]
  1884. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1885. if conf.cmd == "shaqi" then
  1886. attrArr = conf.args
  1887. break
  1888. end
  1889. end
  1890. if not attrArr then
  1891. return attrVal
  1892. end
  1893. for _, attrTb in ipairs(attrArr) do
  1894. if attrTb[1] == targetAttrId then
  1895. attrVal = (attrTb[2] or 0) * buffNum
  1896. break
  1897. end
  1898. end
  1899. return attrVal
  1900. end
  1901. --
  1902. function getRandomBuffCmd(attacker, target, cmd)
  1903. local side = attacker.side
  1904. local mathRandom = math.random
  1905. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1906. local obj = CombatImpl.objList[pos]
  1907. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE56] then
  1908. local beSkillList = obj.beSkillList[BESKILL_TYPE56][1]
  1909. --local skillConfig = SkillExcel[beSkillList[1]]
  1910. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1911. local buffCmdRand = skillConfig.otherArgs.buffCmdRand
  1912. if buffCmdRand and cmd == buffCmdRand[1] then
  1913. local random = mathRandom(1, 10000)
  1914. if random <= buffCmdRand[2] then
  1915. return true
  1916. end
  1917. end
  1918. end
  1919. end
  1920. end
  1921. function getHurtPercentRate(attacker, defender, hurt, tUseskillConfig)
  1922. local rate = 0
  1923. for k,skillList in pairs(defender.beSkillList) do
  1924. for j,v in pairs(skillList) do
  1925. --local conf = SkillExcel[v[1]]
  1926. local conf = Skill.GetSkillConfig(v[1])
  1927. if conf and conf.cmd == "behurtRet" then
  1928. local canUse = true
  1929. if conf.beSkillArgs and #conf.beSkillArgs > 0 then
  1930. if conf.beSkillArgs[1] == "hurthpper" then
  1931. local hpMax = CombatObj.getHpMax(defender)
  1932. local percent = hurt/hpMax
  1933. if percent < conf.beSkillArgs[2]/10000 then -- 伤害超过目标生命值上限X%时
  1934. canUse = false
  1935. end
  1936. end
  1937. end
  1938. if canUse == true then
  1939. local random = math.random(1, 10000)
  1940. if random <= conf.args[2] then
  1941. rate = rate + conf.args[1]
  1942. end
  1943. end
  1944. end
  1945. end
  1946. end
  1947. if tUseskillConfig.type == CombatDefine.SKILL_TYPE1 then
  1948. if attacker.beSkillList[BESKILL_TYPE1] then
  1949. for _, v in pairs(attacker.beSkillList[BESKILL_TYPE1]) do
  1950. local nSkillID = v[1]
  1951. --local skillConfig = SkillExcel[nSkillID]
  1952. local skillConfig = Skill.GetSkillConfig(nSkillID)
  1953. if skillConfig and skillConfig.hurtRate and skillConfig.hurtRate[1] then
  1954. local fRate = skillConfig.hurtRate[1]
  1955. rate = rate + fRate
  1956. --print("[getExtraHurt] 获取到的普工伤害加成概率 fRate = "..fRate.." 总加成 rate = "..rate)
  1957. end
  1958. end
  1959. end
  1960. end
  1961. return rate
  1962. end
  1963. function getBufferExtraHurt(attacker,bufferID,cmd)
  1964. local rate = 0
  1965. for _,skillList in pairs(attacker.beSkillList) do
  1966. for k,v in pairs(skillList) do
  1967. --local conf = SkillExcel[v[1]]
  1968. local conf = Skill.GetSkillConfig(v[1])
  1969. local otherArgs = conf.otherArgs
  1970. if bufferID and otherArgs.bufferExtraHurt then
  1971. for k1,v1 in ipairs(otherArgs.bufferExtraHurt[1]) do
  1972. if bufferID == v1 then
  1973. rate = rate + otherArgs.bufferExtraHurt[2]
  1974. end
  1975. end
  1976. end
  1977. if cmd and otherArgs.bufferCmdExtraHurt then
  1978. for k1,v1 in ipairs(otherArgs.bufferCmdExtraHurt[1]) do
  1979. if cmd == v1 then
  1980. rate = rate + otherArgs.bufferCmdExtraHurt[2]
  1981. end
  1982. end
  1983. end
  1984. end
  1985. end
  1986. return rate
  1987. end
  1988. function getExtraHurtRateEx(attacker, defender)
  1989. local rate = 0
  1990. -- 死亡数伤害率
  1991. if attacker.beSkillList[BESKILL_TYPE48] then
  1992. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE48]) do
  1993. --local skillConfig = SkillExcel[v[1]]
  1994. local skillConfig = Skill.GetSkillConfig(v[1])
  1995. if skillConfig and skillConfig.otherArgs.deathHurt then
  1996. local side = defender.side
  1997. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1998. local obj = CombatImpl.objList[pos]
  1999. if obj and obj.hp <=0 then
  2000. if rate == 0 then
  2001. rate = skillConfig.otherArgs.deathHurt
  2002. else
  2003. rate = rate + 10000
  2004. end
  2005. end
  2006. end
  2007. end
  2008. end
  2009. end
  2010. return rate
  2011. end
  2012. --
  2013. function getBuffChixuHurt(attacker, cmd)
  2014. if not attacker then return 0 end
  2015. local hurt = 0
  2016. local side = attacker.side
  2017. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  2018. local objM = CombatImpl.objList[pos]
  2019. if objM and objM.hp > 0 and objM.beSkillList[BESKILL_TYPE54] then
  2020. for _,v in ipairs(objM.beSkillList[BESKILL_TYPE54]) do
  2021. --local skillConfig = SkillExcel[v[1]]
  2022. local skillConfig = Skill.GetSkillConfig(v[1])
  2023. if skillConfig and skillConfig.otherArgs[cmd] then
  2024. hurt = hurt + skillConfig.otherArgs[cmd]
  2025. end
  2026. end
  2027. end
  2028. end
  2029. return hurt / 10000
  2030. end
  2031. --
  2032. function handlerBuff(attacker, target, arg, cmd)
  2033. if not attacker then return end
  2034. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  2035. local obj = CombatImpl.objList[pos]
  2036. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE57] then
  2037. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE57]) do
  2038. attacker.args = arg
  2039. use(attacker, {target}, v, false)
  2040. end
  2041. end
  2042. end
  2043. end
  2044. function beforeMinusHp(obj, value)
  2045. if value <= 0 then return end
  2046. --敌对阵营 有对象有 49号被动技能 加血变成减血
  2047. local side = obj.side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  2048. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  2049. local objM = CombatImpl.objList[pos]
  2050. if objM and objM.hp > 0 and objM.beSkillList[BESKILL_TYPE49] then
  2051. value = value * (-1)
  2052. break
  2053. end
  2054. end
  2055. return value
  2056. end
  2057. function beforeUpdateHp(obj,sum)
  2058. if sum <= 0 and obj.beSkillList[BESKILL_TYPE41] then
  2059. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE41]) do
  2060. --local skillConfig = SkillExcel[v[1]]
  2061. local skillConfig = Skill.GetSkillConfig(v[1])
  2062. if skillConfig.cmd == "miansi" and canUse(obj,v) then
  2063. use(obj,{},v)
  2064. return true
  2065. end
  2066. end
  2067. end
  2068. end
  2069. function onCheckBuffer(obj,attacker,value)
  2070. local ret = value
  2071. if obj.beSkillList[BESKILL_TYPE42] then
  2072. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE42]) do
  2073. --local skillConfig = SkillExcel[v[1]]
  2074. local skillConfig = Skill.GetSkillConfig(v[1])
  2075. if canUse(obj,v) then
  2076. local newFrame = true
  2077. if skillConfig.cmd == "baohu" then
  2078. obj.baohuHurt = value * skillConfig.args[1] / 10000
  2079. if obj.hp < -obj.baohuHurt then
  2080. obj.baohuHurt = -obj.hp
  2081. end
  2082. ret = value - obj.baohuHurt
  2083. newFrame = false
  2084. end
  2085. use(obj,{attacker},v, newFrame)
  2086. break
  2087. end
  2088. end
  2089. end
  2090. return ret
  2091. end
  2092. function getStatusBaoji(attacker, defender)
  2093. local baoji = 0
  2094. local firstBaoji = 0
  2095. for k, skillList in pairs(attacker.beSkillList) do
  2096. for j, v in pairs(skillList) do
  2097. --local config = SkillExcel[v[1]]
  2098. local config = Skill.GetSkillConfig(v[1])
  2099. if config.cmd == "firstAttackHurt" then
  2100. if canUse(attacker, v) then
  2101. firstBaoji = config.args[2] or 0
  2102. end
  2103. end
  2104. end
  2105. end
  2106. if attacker.beSkillList[BESKILL_TYPE60] then
  2107. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE60]) do
  2108. --local skillConfig = SkillExcel[v[1]]
  2109. local skillConfig = Skill.GetSkillConfig(v[1])
  2110. if skillConfig and skillConfig.otherArgs.addStatusBaoji then
  2111. local status = CombatBuff.getStatus(defender)
  2112. local isStatus = false
  2113. for k, v in ipairs(skillConfig.otherArgs.addStatusBaoji[1]) do
  2114. if status[v] then
  2115. isStatus = true
  2116. break
  2117. end
  2118. end
  2119. if isStatus then
  2120. baoji = baoji + skillConfig.otherArgs.addStatusBaoji[2]
  2121. end
  2122. end
  2123. end
  2124. end
  2125. if attacker.beSkillList[BESKILL_TYPE69] and attacker.notBaoJi then
  2126. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE69]) do
  2127. --local skillConfig = SkillExcel[v[1]]
  2128. local skillConfig = Skill.GetSkillConfig(v[1])
  2129. if skillConfig and skillConfig.otherArgs.addNotBaoji then
  2130. baoji = baoji + skillConfig.otherArgs.addNotBaoji
  2131. end
  2132. end
  2133. end
  2134. return baoji + firstBaoji
  2135. end
  2136. function getStatusPojia(attacker, defender)
  2137. local poJia = 0
  2138. -- 对指定状态破甲加成 走的技能状态属性
  2139. if attacker.beSkillList[BESKILL_TYPE60] then
  2140. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE60]) do
  2141. --local skillConfig = SkillExcel[v[1]]
  2142. local skillConfig = Skill.GetSkillConfig(v[1])
  2143. if skillConfig.otherArgs.addStatusPoJia then
  2144. local status = CombatBuff.getStatus(defender)
  2145. local isStatus = false
  2146. for k, v in ipairs(skillConfig.otherArgs.addStatusPoJia[1]) do
  2147. if status[v] then
  2148. isStatus = true
  2149. break
  2150. end
  2151. end
  2152. if isStatus then
  2153. poJia = poJia + skillConfig.otherArgs.addStatusPoJia[2]
  2154. end
  2155. end
  2156. end
  2157. end
  2158. return poJia
  2159. end
  2160. -- 是否不会被反击
  2161. function isNoFanji(obj)
  2162. if obj.beSkillList[BESKILL_TYPE72] then
  2163. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2164. local skillConfig = Skill.GetSkillConfig(v[1])
  2165. if skillConfig.cmd == "noFanji" then
  2166. return true
  2167. end
  2168. end
  2169. end
  2170. return false
  2171. end
  2172. -- 获取与神威灵装"真伤附加"效果相对的"真伤减免"
  2173. function GetTrueDamegeOffset(obj)
  2174. if obj.beSkillList[BESKILL_TYPE72] then
  2175. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2176. local skillConfig = Skill.GetSkillConfig(v[1])
  2177. if skillConfig.cmd == "trueDamegeOffset" then
  2178. local offsetInfo = {}
  2179. offsetInfo[1] = skillConfig.beSkillArgs[1]
  2180. offsetInfo[2] = skillConfig.beSkillArgs[2]
  2181. return offsetInfo
  2182. end
  2183. end
  2184. end
  2185. end
  2186. -- 触发格挡后额外减伤
  2187. function GetGeDangExtraDef(obj)
  2188. if obj.beSkillList[BESKILL_TYPE72] then
  2189. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2190. local skillConfig = Skill.GetSkillConfig(v[1])
  2191. if skillConfig.cmd == "gedangExtraDef" then
  2192. return skillConfig.beSkillArgs[1]
  2193. end
  2194. end
  2195. end
  2196. return 0
  2197. end
  2198. -- 伤害翻倍
  2199. function GetBeSkillHurtMul(obj)
  2200. if obj.beSkillList[BESKILL_TYPE72] then
  2201. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2202. local skillConfig = Skill.GetSkillConfig(v[1])
  2203. if skillConfig.cmd == "physicalDamageMul" and obj.hurtType == CombatDefine.PHY_HURT_TYPE then
  2204. return math.random(skillConfig.beSkillArgs[1], skillConfig.beSkillArgs[2])
  2205. end
  2206. if skillConfig.cmd == "magicDamageMul" and obj.hurtType == CombatDefine.MAGIC_HURT_TYPE then
  2207. return math.random(skillConfig.beSkillArgs[1], skillConfig.beSkillArgs[2])
  2208. end
  2209. end
  2210. end
  2211. end
  2212. -- 回血翻倍
  2213. function GetBeSkillRestoretHPMul(obj)
  2214. local mul = 1
  2215. if obj.beSkillList[BESKILL_TYPE72] then
  2216. for _, v in ipairs(obj.beSkillList[BESKILL_TYPE72]) do
  2217. local skillConfig = Skill.GetSkillConfig(v[1])
  2218. if skillConfig.cmd == "restoreHPMul" then
  2219. local r = math.random(1,10000)
  2220. if r <= (skillConfig.beSkillArgs[2] or 0) then
  2221. mul = skillConfig.beSkillArgs[1] or 1
  2222. end
  2223. return mul
  2224. end
  2225. end
  2226. end
  2227. return mul
  2228. end