BeSkill.lua 78 KB

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