BeSkill.lua 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996
  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 tbFuwenSkillGroupID = {}
  18. local posSortBySpeed = posSortBySpeed or {}
  19. function initBeSkill(obj)
  20. obj.beSkillList = {}
  21. obj.beSkillListTemp = {}
  22. end
  23. function setBeSkillID(obj, skillID, isFuWenSkill)
  24. local skillConfig = Skill.GetFinalSkillConfig(obj, skillID)
  25. skillID = skillConfig.id
  26. if obj.beSkillListTemp[skillID] then return end
  27. --local skillConfig = SkillExcel[skillID]
  28. if skillConfig.need > obj.quality then return end
  29. if skillConfig.beSkillType == 0 then return end
  30. if skillConfig.beSkillType == BESKILL_TYPE24 then
  31. obj.beSkillListTemp[BESKILL_TYPE24] = obj.beSkillListTemp[BESKILL_TYPE24] or {}
  32. obj.beSkillListTemp[BESKILL_TYPE24][#obj.beSkillListTemp[BESKILL_TYPE24] + 1] = {
  33. skillID,
  34. skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,
  35. skillConfig.cd[2] or 0,
  36. isFuWenSkill or 0}
  37. for _,skillID in ipairs(skillConfig.args) do
  38. --local skillConfig = SkillExcel[skillID]
  39. local skillConfig = Skill.GetFinalSkillConfig(obj, skillID)
  40. if not obj.beSkillListTemp[skillID] and skillConfig.need <= obj.quality then
  41. obj.beSkillList[skillConfig.beSkillType] = obj.beSkillList[skillConfig.beSkillType] or {}
  42. obj.beSkillList[skillConfig.beSkillType][#obj.beSkillList[skillConfig.beSkillType] + 1] = {
  43. skillID,
  44. skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,
  45. skillConfig.cd[2] or 0,
  46. isFuWenSkill or 0}
  47. obj.beSkillListTemp[skillID] = 1
  48. end
  49. end
  50. else
  51. obj.beSkillList[skillConfig.beSkillType] = obj.beSkillList[skillConfig.beSkillType] or {}
  52. obj.beSkillList[skillConfig.beSkillType][#obj.beSkillList[skillConfig.beSkillType] + 1] = {
  53. skillID,
  54. skillConfig.beSkillLimit > 0 and skillConfig.beSkillLimit,skillConfig.cd[1] or 0,
  55. skillConfig.cd[2] or 0,
  56. isFuWenSkill or 0}
  57. obj.beSkillListTemp[skillID] = 1
  58. end
  59. end
  60. function setBeSkill(obj, config, skinConf, monsterOutConfig)
  61. local temp = {}
  62. local confBeskillID = skinConf and skinConf.beSkillList or config.beSkillList
  63. for _,skillID in ipairs(confBeskillID) do
  64. setBeSkillID(obj,skillID)
  65. end
  66. -- 加载 赋能技能 这个策划说放到最后
  67. if config.bePvPSkillList and CombatImpl.isPVP == 1 then
  68. for _,skillID in ipairs(config.bePvPSkillList) do
  69. setBeSkillID(obj, skillID)
  70. end
  71. end
  72. -- 怪物组附加的被动技能
  73. if monsterOutConfig then
  74. for _, skillID in ipairs(monsterOutConfig) do
  75. setBeSkillID(obj,skillID)
  76. end
  77. end
  78. -- 符文被动技能
  79. -- 符文技能效果这里 如果有多个同类型的技能 效果不叠加 只取最高等级的那个技能的效果
  80. if obj.fuwen or obj.bingshu then
  81. local hasFuwenBeSkill = nil
  82. Util.initTable(tbFuwenSkillGroupID)
  83. if obj.fuwen then
  84. for i = 1, 2 do
  85. local fuwenGrid = obj.fuwen[i]
  86. if fuwenGrid and fuwenGrid.skill then
  87. for j = 1, #fuwenGrid.skill do
  88. local fuwenSkillID = fuwenGrid.skill[j]
  89. local fuwenSkillConfig = FuwenExcel.skill[fuwenSkillID]
  90. local fuwenGroupID = fuwenSkillConfig.groupID
  91. if fuwenSkillConfig.fuwenBeSkill ~= 0 then
  92. hasFuwenBeSkill = true
  93. if tbFuwenSkillGroupID[fuwenGroupID] then
  94. if tbFuwenSkillGroupID[fuwenGroupID] < fuwenSkillID then
  95. tbFuwenSkillGroupID[fuwenGroupID] = fuwenSkillID
  96. end
  97. else
  98. tbFuwenSkillGroupID[fuwenGroupID] = fuwenSkillID
  99. end
  100. end
  101. end
  102. end
  103. end
  104. end
  105. if obj.bingshu then
  106. for i = 1, BingshuLogic.BINGSHU_MAXCNT do
  107. local bingshuGrid = obj.bingshu[i]
  108. if bingshuGrid then
  109. local skillID = bingshuGrid.skillID
  110. local skillConfig = FuwenExcel.skill[skillID]
  111. local groupID = skillConfig.groupID
  112. hasFuwenBeSkill = true
  113. if (tbFuwenSkillGroupID[groupID] or 0) < skillID then
  114. tbFuwenSkillGroupID[groupID] = skillID
  115. end
  116. end
  117. end
  118. end
  119. if hasFuwenBeSkill == true then
  120. for groupID, skillIDTemp in pairs(tbFuwenSkillGroupID) do
  121. local fuwenSkillConfig = FuwenExcel.skill[skillIDTemp]
  122. local fuwenBeSkillID = fuwenSkillConfig.fuwenBeSkill
  123. setBeSkillID(obj,fuwenBeSkillID, 1)
  124. end
  125. end
  126. end
  127. end
  128. function setPetBeSkill(obj)
  129. --if obj
  130. --local skillConfig = SkillExcel[1999]
  131. local skillConfig = Skill.GetSkillConfig(1999)
  132. if skillConfig then
  133. obj.beSkillList = obj.beSkillList or {}
  134. obj.beSkillList[skillConfig.beSkillType] = obj.beSkillList[skillConfig.beSkillType] or {}
  135. 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}
  136. end
  137. end
  138. --被动技能类型
  139. BESKILL_TYPE1 = 1 --普攻附带
  140. BESKILL_TYPE2 = 2 --被击触发
  141. BESKILL_TYPE3 = 3 --自身生命低于参数
  142. BESKILL_TYPE4 = 4 --自己暴击触发
  143. BESKILL_TYPE5 = 5 --受到技能伤害
  144. BESKILL_TYPE6 = 6 --自己攻击被格挡
  145. BESKILL_TYPE7 = 7 --受到暴击触发
  146. BESKILL_TYPE8 = 8 --自己格挡触发(其他单位对自己发动攻击,自己触发格挡)
  147. BESKILL_TYPE9 = 9 --敌方英雄触发格挡
  148. BESKILL_TYPE10 = 10 --自己受持续状态伤害
  149. BESKILL_TYPE11 = 11 --自己受控制类状态
  150. BESKILL_TYPE12 = 12 --场上有英雄被添加燃烧状态
  151. BESKILL_TYPE13 = 13 -- 我方英雄施放主动技能
  152. BESKILL_TYPE14 = 14 -- 我方英雄暴击
  153. BESKILL_TYPE15 = 15 -- 自己死亡
  154. BESKILL_TYPE16 = 16 --我方英雄死亡
  155. BESKILL_TYPE17 = 17 --敌方英雄死亡
  156. BESKILL_TYPE18 = 18 --有英雄死亡
  157. BESKILL_TYPE19 = 19 --回合开始
  158. BESKILL_TYPE20 = 20 --回合结束
  159. BESKILL_TYPE23 = 23 --激活就生效(计入面板属性)
  160. BESKILL_TYPE24 = 24 --技能包
  161. BESKILL_TYPE25 = 25 --替换初始普攻
  162. BESKILL_TYPE26 = 26 --激活就生效(进入战斗前算。不计入面板属性)
  163. BESKILL_TYPE27 = 27 --魔兽回能量被动
  164. BESKILL_TYPE28 = 28 --自身触发格挡次数
  165. BESKILL_TYPE29 = 29 --有人受到缠绕时
  166. BESKILL_TYPE30 = 30 --使生命低于x时
  167. BESKILL_TYPE31 = 31 --任意英雄释放主动技能
  168. BESKILL_TYPE32 = 32 --战斗开始时触发
  169. BESKILL_TYPE33 = 33 --复活时触发
  170. BESKILL_TYPE34 = 34 --使用主动技能时
  171. BESKILL_TYPE35 = 35 --自身击杀敌人时
  172. BESKILL_TYPE36 = 36 --攻击回合结束时触发
  173. BESKILL_TYPE37 = 37 --物攻后触发
  174. BESKILL_TYPE38 = 38 --法攻后触发
  175. BESKILL_TYPE39 = 39 --攻击附带 (普攻 主动 都算)
  176. BESKILL_TYPE40 = 40 --攻击前根据条件判断是否触发(小战斗回合,针对每个对象单独判断)
  177. BESKILL_TYPE41 = 41 --实际扣血前触发
  178. BESKILL_TYPE42 = 42 --由其他英雄的buff触发
  179. BESKILL_TYPE43 = 43 --被某个技能打死
  180. BESKILL_TYPE44 = 44 --自己暴击+反击触发
  181. BESKILL_TYPE45 = 45 --计算伤害时触发
  182. BESKILL_TYPE46 = 46 --攻击附带 (普攻 主动 连击 反击都算)
  183. BESKILL_TYPE47 = 47 --每回合叠加属性
  184. BESKILL_TYPE48 = 48 --死亡英雄伤害率
  185. BESKILL_TYPE49 = 49 --加血变成减血
  186. BESKILL_TYPE50 = 50 --每回合触发 降低对方首次攻击目标伤害率
  187. BESKILL_TYPE51 = 51 --场上有英雄被添加诅咒状态
  188. BESKILL_TYPE52 = 52 --场上有英雄被攻击
  189. BESKILL_TYPE53 = 53 --场上有英雄有特定被动技能 友军普攻触发
  190. BESKILL_TYPE54 = 54 --场上有英雄特定buff 伤害加成
  191. BESKILL_TYPE55 = 55 --场上有英雄指定buff层数 额外伤害加成
  192. BESKILL_TYPE56 = 56 --场上有英雄特定bufer且概率产生
  193. BESKILL_TYPE57 = 57 --特定buff被引爆消除时 触发的效果
  194. BESKILL_TYPE58 = 58 --指定技能暴击
  195. BESKILL_TYPE59 = 59 --没有暴击触发一个效果
  196. BESKILL_TYPE60 = 60 --暴击加成
  197. BESKILL_TYPE61 = 61 --技能未击杀目标时触发
  198. BESKILL_TYPE62 = 62 --回合开始生命值触发
  199. BESKILL_TYPE63 = 63 --回合开始生命值触发
  200. BESKILL_TYPE64 = 64 --冰冻buffer被击碎
  201. BESKILL_TYPE65 = 65 --场上有英雄有特定被动技能 友军普攻暴击触发
  202. BESKILL_TYPE66 = 66 --敌方死亡特定buff触发
  203. BESKILL_TYPE67 = 67 --血量低于多少跟受控制触发
  204. BESKILL_TYPE68 = 68 --血族英雄特殊处理
  205. BESKILL_TYPE69 = 69 --血族英雄特殊处理
  206. BESKILL_TYPE70 = 70 --增加的属性激活就生效(计入面板属性)并且概率连击
  207. NO_CHECK_FANJI_LIST = {
  208. [BESKILL_TYPE3] = 1,
  209. [BESKILL_TYPE15] = 1,
  210. [BESKILL_TYPE16] = 1,
  211. [BESKILL_TYPE17] = 1,
  212. [BESKILL_TYPE18] = 1,
  213. [BESKILL_TYPE35] = 1,
  214. [BESKILL_TYPE36] = 1,
  215. [BESKILL_TYPE37] = 1,
  216. [BESKILL_TYPE38] = 1,
  217. [BESKILL_TYPE44] = 1,
  218. [BESKILL_TYPE46] = 1,
  219. }
  220. NO_CHECK_COMBO_LIST = {
  221. [BESKILL_TYPE1] = 1,
  222. [BESKILL_TYPE3] = 1,
  223. [BESKILL_TYPE14] = 1,
  224. [BESKILL_TYPE16] = 1,
  225. [BESKILL_TYPE17] = 1,
  226. [BESKILL_TYPE18] = 1,
  227. [BESKILL_TYPE35] = 1,
  228. [BESKILL_TYPE34] = 1,
  229. [BESKILL_TYPE25] = 1,
  230. [BESKILL_TYPE46] = 1,
  231. [BESKILL_TYPE37] = 1,
  232. }
  233. local function checkLimit(data)
  234. if data[2] and data[2] <= 0 then
  235. return
  236. end
  237. if data[4] > 0 and data[3] > CombatImpl.round then
  238. return
  239. end
  240. return true
  241. end
  242. local function canUse(obj,data)
  243. if obj.isPet then
  244. return true
  245. end
  246. --被动技能次数限制判断
  247. if not checkLimit(data) then
  248. return
  249. end
  250. --local skillConfig = SkillExcel[data[1]]
  251. local skillConfig = Skill.GetSkillConfig(data[1])
  252. if not NO_CHECK_FANJI_LIST[skillConfig.beSkillType] and CombatImpl.isFanji then
  253. return
  254. end
  255. if not NO_CHECK_COMBO_LIST[skillConfig.beSkillType] and CombatImpl.comboType > 0 then
  256. return
  257. end
  258. local bNotFeng = nil
  259. -- boss 被动不能被封印
  260. -- 世界boss模式下 boss不受feng状态影响
  261. if CombatImpl.fightMode[1] == CombatDefine.FIGHT_MODE3 then
  262. if obj.type == CombatDefine.COMBAT_OBJ_TYPE3 then
  263. bNotFeng = true
  264. end
  265. end
  266. if not bNotFeng and CombatBuff.isStatus(obj,{"banBeSkill","feng"}) then
  267. return
  268. end
  269. data[3] = data[3] + data[4]
  270. local beSkillArgs = skillConfig.beSkillArgs
  271. local ret = true
  272. --被动技能触发条件判断
  273. if beSkillArgs[1] then
  274. if beSkillArgs[1] == "hp" then
  275. local hp = obj.hp
  276. local hpMax = CombatObj.getHpMax(obj)
  277. if hp > hpMax * beSkillArgs[2]/10000 then
  278. ret = false
  279. end
  280. elseif beSkillArgs[1] == "hpOrControl" then
  281. ret = false
  282. local hp = obj.hp
  283. local hpMax = CombatObj.getHpMax(obj)
  284. if hp <= hpMax * beSkillArgs[2]/10000 then
  285. ret = true
  286. end
  287. if CombatBuff.isAtControl(obj) then
  288. ret = true
  289. end
  290. elseif beSkillArgs[1] == "fanji" then
  291. local r = math.random(0,10000)
  292. if r > beSkillArgs[2] then
  293. return
  294. end
  295. elseif beSkillArgs[1] == "pos" then
  296. local pos = obj.pos
  297. ret = false
  298. if beSkillArgs[2] then
  299. for i = 1,#beSkillArgs[2] do
  300. if pos == beSkillArgs[2][i] then
  301. ret = true
  302. break
  303. end
  304. end
  305. end
  306. elseif beSkillArgs[1] == "noBuffCmd" then
  307. return not CombatBuff.isStatus(obj,beSkillArgs[2])
  308. elseif beSkillArgs[1] == "attackerBuffCmd" then
  309. local isStatus,cmd = CombatBuff.isStatus(obj,beSkillArgs[2])
  310. return isStatus
  311. elseif beSkillArgs[1] == "myjob" then
  312. ret = false
  313. for k,v in ipairs(beSkillArgs[2]) do
  314. if v == obj.job then
  315. ret = true
  316. break
  317. end
  318. end
  319. elseif beSkillArgs[1] == "sideLimit" then
  320. for k,v in ipairs(beSkillArgs[2]) do
  321. local useCnt = CombatImpl.getBeSkillSideUse(obj.pos,v[1])
  322. if useCnt >= v[2] then
  323. return
  324. end
  325. end
  326. elseif beSkillArgs[1] == "firstAttackOrder" then
  327. local side = obj.side
  328. if side then
  329. local isFirstAttack = CombatImpl.firstAttack[side]
  330. if beSkillArgs[2] == 1 then
  331. return isFirstAttack
  332. else
  333. return not isFirstAttack
  334. end
  335. end
  336. end
  337. end
  338. if ret and data[2] then
  339. data[2] = data[2] - 1
  340. end
  341. if skillConfig.cmd == "hp" then
  342. local hp = obj.hp
  343. local targetMode = skillConfig.args[3]
  344. --英雄血量为0时不能加血
  345. if (hp <= 0 or CombatBuff.isStatus(obj,{"revive"})) and targetMode and targetMode[1] == 10 then
  346. ret = false
  347. end
  348. end
  349. return ret
  350. end
  351. --被攻击触发,需要判断攻击者状态的被动技能
  352. local function canUseOnHit(obj,data)
  353. if not obj then
  354. return true
  355. end
  356. --local skillConfig = SkillExcel[data[1]]
  357. local skillConfig = Skill.GetSkillConfig(data[1])
  358. local beSkillArgs = skillConfig.beSkillArgs
  359. local condCmd = beSkillArgs[1]
  360. if condCmd == "job" then
  361. for _,job in ipairs(beSkillArgs[2]) do
  362. if obj.job == job then
  363. return true
  364. end
  365. end
  366. return false
  367. elseif condCmd == "buffCmd" then
  368. return CombatBuff.isStatus(obj,beSkillArgs[2])
  369. elseif condCmd == "targetHp" then
  370. local hp = obj.hp
  371. local checkHp = CombatObj.getHpMax(obj) * beSkillArgs[3] / 10000
  372. if beSkillArgs[2] == 1 and hp > checkHp then
  373. return true
  374. elseif beSkillArgs[2] == 2 and hp < checkHp then
  375. return true
  376. end
  377. else
  378. return true
  379. end
  380. end
  381. local function isCanRevive(obj, attacker , data)
  382. -- local skillConfig = SkillExcel[data[1]]
  383. local skillConfig = Skill.GetSkillConfig(data[1])
  384. if skillConfig.cmd == "shengling" or
  385. skillConfig.cmd == "revive" then
  386. if skillConfig.cmd == "shengling" and CombatImpl.checkSideResult(obj.pos) == true then -- 如果是队伍最后一个死亡的不释放 圣灵复活
  387. return false
  388. end
  389. if CombatBuff.canRevive(obj) ~= true then
  390. return false
  391. end
  392. if skillConfig.cmd == "shengling" then
  393. if CombatBuff.isStatus(obj,{"revive"}) then
  394. return false
  395. end
  396. end
  397. if attacker and attacker.beSkillList then
  398. for k,skillList in pairs(attacker.beSkillList) do
  399. for j,v in pairs(skillList) do
  400. --local config = SkillExcel[v[1]]
  401. local config = Skill.GetSkillConfig(data[1])
  402. if config and skillConfig.cmd == "shengling" and config.cmd == "noShengling" then --击杀方有 不准圣灵复活被动
  403. return false
  404. elseif config and config.cmd == "noRevive" then -- 击杀方 有不准复活的
  405. if #config.args > 0 then
  406. local canNum = config.args[1]
  407. local random = math.random(1, 10000)
  408. if random > canNum then -- noRevive 概率不生效
  409. return true
  410. else
  411. return false
  412. end
  413. end
  414. return true
  415. end
  416. end
  417. end
  418. end
  419. end
  420. return true
  421. end
  422. function onSkillID(obj,skillID)
  423. --local skillConfig = SkillExcel[skillID]
  424. local skillConfig = Skill.GetSkillConfig(skillID)
  425. if skillConfig.type == CombatDefine.SKILL_TYPE1 and obj.beSkillList[BESKILL_TYPE25] then
  426. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE25]) do
  427. if canUse(obj,v) then
  428. --local conf = SkillExcel[v[1]]
  429. local conf = Skill.GetSkillConfig(v[1])
  430. return conf.args[1]
  431. end
  432. end
  433. end
  434. return skillID
  435. end
  436. local function use(attacker,targets,data,newFrame, packBuff)
  437. if canUse(attacker,data) and canUseOnHit(targets and targets[1],data) then
  438. --print("beskill realuse:",attacker.pos,data[1])
  439. --local skillConfig = SkillExcel[data[1]]
  440. local skillConfig = Skill.GetSkillConfig(data[1])
  441. local ret
  442. -- 二次元连击触发帧不新加帧
  443. if ProjectLogic.isSsecy() and skillConfig.cmd == "combo" then
  444. newFrame = false
  445. end
  446. if packBuff then
  447. CombatImpl.afterBuff()
  448. end
  449. if Skill.CMD[skillConfig.cmd] then
  450. if newFrame or CombatImpl.isSkillFrameEmpty() then
  451. --进入战斗时,未加入任何战斗帧触发被动技能时,先添加被动技能的战斗帧,可以在这个战斗帧上挂被动技能引发的额外作用
  452. CombatImpl.addFrame()
  453. CombatImpl.setSkillID(attacker, data[1])
  454. end
  455. ret = Skill.CMD[skillConfig.cmd](attacker,skillConfig,targets)
  456. end
  457. local isAddSkillFrame = CombatBuff.onUseBeSkill(attacker,skillConfig,targets,ret)
  458. --判断是否加喊话
  459. if skillConfig.contentType > 0 then
  460. if isAddSkillFrame then
  461. CombatImpl.addSaySkill(attacker,skillConfig)
  462. elseif ret or skillConfig.beSkillType == BESKILL_TYPE26 or
  463. skillConfig.beSkillType == BESKILL_TYPE23 or
  464. skillConfig.beSkillType == BESKILL_TYPE4 or
  465. skillConfig.beSkillType == BESKILL_TYPE44 then
  466. if CombatImpl.isSkillFrameEmpty() then
  467. CombatImpl.addFrame()
  468. CombatImpl.setSkillID(attacker, data[1])
  469. end
  470. CombatImpl.setSaySkill(attacker.pos,skillConfig.id,skillConfig.contentType)
  471. end
  472. end
  473. CombatImpl.addBeSkillPosUse(attacker.pos,data[1])
  474. end
  475. end
  476. function onHit(attacker,targets,skillID)
  477. if attacker.isPet then
  478. return
  479. end
  480. --local useSkillConfig = SkillExcel[skillID]
  481. local useSkillConfig = Skill.GetSkillConfig(skillID)
  482. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 then
  483. --[[for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  484. local obj = CombatImpl.objList[pos]
  485. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE13] then
  486. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE13]) do
  487. use(obj,targets,v)
  488. end
  489. end
  490. end]]
  491. if attacker.beSkillList[BESKILL_TYPE34] then
  492. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE34]) do
  493. --local skillConfig = SkillExcel[v[1]]
  494. local skillConfig = Skill.GetSkillConfig(v[1])
  495. local beSkillArgs = skillConfig.beSkillArgs
  496. if beSkillArgs[1] == "attackerBuffCmd" and beSkillArgs[2][1] == "shayi" then
  497. local shayiCnt = CombatBuff.getBuffCnt(attacker,"shayi")
  498. if shayiCnt > 0 then
  499. for i = 1,shayiCnt do
  500. use(attacker,targets,v,true)
  501. CombatImpl.instantFrameBuffer(attacker,v[1])
  502. end
  503. end
  504. CombatBuff.delShayi(attacker)
  505. elseif beSkillArgs[1] == "qusanNeedCmd" then
  506. local canUse = false
  507. for h,need in ipairs(beSkillArgs[2]) do
  508. if need == useSkillConfig.cmd then
  509. canUse = true
  510. break
  511. end
  512. end
  513. if canUse == true then
  514. use(attacker,targets,v,true)
  515. end
  516. elseif beSkillArgs[1] == "jiekongNeedCmd" then
  517. local canUse = false
  518. for h,need in ipairs(beSkillArgs[2]) do
  519. if need == useSkillConfig.cmd then
  520. canUse = true
  521. break
  522. end
  523. end
  524. if canUse == true then
  525. use(attacker,targets,v,true)
  526. end
  527. elseif beSkillArgs[1] == "skillID" then
  528. local canUse = false
  529. for _, targetSkill in ipairs(beSkillArgs[2]) do
  530. if skillID == targetSkill then
  531. canUse = true
  532. break
  533. end
  534. end
  535. if canUse == true then
  536. use(attacker,targets,v,true)
  537. end
  538. else
  539. use(attacker,targets,v)
  540. end
  541. end
  542. end
  543. end
  544. --非攻击性主动技能不处理被击被动技能
  545. if CombatObj.getValue(attacker,RoleDefine.HURT_COMBAT_NOW) <= 0 then
  546. if (useSkillConfig.type == CombatDefine.SKILL_TYPE1 or useSkillConfig.type == CombatDefine.SKILL_TYPE2) then
  547. if attacker.beSkillList[BESKILL_TYPE39] then
  548. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE39]) do
  549. use(attacker,targets,v)
  550. end
  551. end
  552. if attacker.beSkillList[BESKILL_TYPE70] then
  553. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE70]) do
  554. use(attacker,targets,v)
  555. end
  556. end
  557. end
  558. return
  559. end
  560. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 and attacker.beSkillList[BESKILL_TYPE1] then
  561. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE1]) do
  562. use(attacker,targets,v)
  563. end
  564. end
  565. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 and attacker.beSkillList[BESKILL_TYPE61] then
  566. local canUseSkill = true
  567. for index = 1, #targets do
  568. local target = targets[index]
  569. if target.hp <=0 then
  570. canUseSkill = false
  571. end
  572. end
  573. if canUseSkill then
  574. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE61]) do
  575. --local skillConfig = SkillExcel[v[1]]
  576. local skillConfig = Skill.GetSkillConfig(v[1])
  577. local beSkillArgs = skillConfig.beSkillArgs
  578. if beSkillArgs[1] == "skillID" then
  579. local canUse = false
  580. for _,v in ipairs(beSkillArgs[2]) do
  581. if skillID == v then
  582. canUse = true
  583. break
  584. end
  585. end
  586. if canUse then
  587. use(attacker,{},v)
  588. end
  589. end
  590. end
  591. end
  592. end
  593. if (useSkillConfig.type == CombatDefine.SKILL_TYPE1 or useSkillConfig.type == CombatDefine.SKILL_TYPE2 or useSkillConfig.type == CombatDefine.SKILL_TYPE3) then
  594. if attacker.beSkillList[BESKILL_TYPE39] then
  595. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE39]) do
  596. use(attacker,targets,v)
  597. end
  598. end
  599. if attacker.beSkillList[BESKILL_TYPE46] then
  600. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE46]) do
  601. use(attacker,targets,v)
  602. end
  603. end
  604. if attacker.beSkillList[BESKILL_TYPE70] then
  605. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE70]) do
  606. use(attacker,targets,v)
  607. end
  608. end
  609. end
  610. local isDefendSideGedang = false
  611. local baojiDefender = {}
  612. for _,target in ipairs(targets) do
  613. if target.beSkillList[BESKILL_TYPE2] then
  614. for _,v in ipairs(target.beSkillList[BESKILL_TYPE2]) do
  615. use(target,{attacker},v)
  616. end
  617. end
  618. -- 友军受击
  619. for _,pos in ipairs(CombatDefine.SIDE2POS[target.side]) do
  620. local obj = CombatImpl.objList[pos]
  621. if obj and obj.pos ~= target.pos and obj.beSkillList[BESKILL_TYPE52] then
  622. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE52]) do
  623. use(target,{attacker},v)
  624. end
  625. end
  626. end
  627. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 and target.beSkillList[BESKILL_TYPE5] then
  628. for _,v in ipairs(target.beSkillList[BESKILL_TYPE5]) do
  629. use(target,{attacker},v)
  630. end
  631. end
  632. if target.isGedang then
  633. isDefendSideGedang = true
  634. if target.beSkillList[BESKILL_TYPE8] then
  635. for _,v in ipairs(target.beSkillList[BESKILL_TYPE8]) do
  636. use(target,{attacker},v)
  637. end
  638. end
  639. if attacker.beSkillList[BESKILL_TYPE6] then
  640. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE6]) do
  641. use(attacker,{target},v)
  642. end
  643. end
  644. --目标触发格挡次数
  645. if target.beSkillList[BESKILL_TYPE28] then
  646. for _, v in ipairs(target.beSkillList[BESKILL_TYPE28]) do
  647. --local skillConfig = SkillExcel[v[1]]
  648. local skillConfig = Skill.GetSkillConfig(v[1])
  649. local beSkillArgs = skillConfig.beSkillArgs
  650. if beSkillArgs[1] == "gedang" then
  651. target.isGedangCnt = target.isGedangCnt or 0
  652. local geDangLimit = beSkillArgs[2]
  653. if target.isGedangCnt >= geDangLimit then
  654. target.isGedangCnt = 0
  655. use(target,{attacker},v)
  656. end
  657. end
  658. end
  659. end
  660. end
  661. local chanRao = CombatBuff.isChanRao(target)
  662. if chanRao then
  663. if target.beSkillList[BESKILL_TYPE29] then
  664. for _,v in ipairs(target.beSkillList[BESKILL_TYPE29]) do
  665. use(target,{attacker},v)
  666. end
  667. end
  668. end
  669. if target.isBaoji then
  670. if target.beSkillList[BESKILL_TYPE7] then
  671. for _,v in ipairs(target.beSkillList[BESKILL_TYPE7]) do
  672. use(target,{attacker},v)
  673. end
  674. end
  675. baojiDefender[#baojiDefender+1] = target
  676. end
  677. end
  678. local side = attacker.side
  679. local defendSide = side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  680. --普通技能触发
  681. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 then
  682. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  683. local obj = CombatImpl.objList[pos]
  684. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE53] then
  685. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE53]) do
  686. use(attacker,targets,v)
  687. end
  688. end
  689. end
  690. end
  691. --主动技能触发
  692. if useSkillConfig.type == CombatDefine.SKILL_TYPE2 then
  693. for _,pos in ipairs(CombatDefine.SIDE2POS[0]) do
  694. local obj = CombatImpl.objList[pos]
  695. local objSide = pos <= 6 and CombatDefine.ATTACK_SIDE or CombatDefine.DEFEND_SIDE
  696. --触发自己这方的
  697. if side == objSide then
  698. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE13] then
  699. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE13]) do
  700. use(obj,targets,v)
  701. end
  702. end
  703. end
  704. --触发任意一方
  705. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE31] then
  706. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE31]) do
  707. use(obj,targets,v)
  708. end
  709. end
  710. end
  711. end
  712. if not attacker.isBaoji then
  713. --指定技能没有暴击
  714. if attacker.beSkillList[BESKILL_TYPE59] then
  715. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE59]) do
  716. --local skillConfig = SkillExcel[v[1]]
  717. local skillConfig = Skill.GetSkillConfig(v[1])
  718. local beSkillArgs = skillConfig.beSkillArgs
  719. if beSkillArgs[1] == "skillID" then
  720. local canUse = false
  721. for _,v in ipairs(beSkillArgs[2]) do
  722. if skillID == v then
  723. canUse = true
  724. break
  725. end
  726. end
  727. if canUse then
  728. use(attacker,{},v)
  729. end
  730. end
  731. end
  732. end
  733. end
  734. if attacker.isBaoji then
  735. --普通暴击技能触发
  736. if useSkillConfig.type == CombatDefine.SKILL_TYPE1 then
  737. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  738. local obj = CombatImpl.objList[pos]
  739. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE65] then
  740. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE65]) do
  741. use(attacker,targets,v)
  742. end
  743. end
  744. end
  745. end
  746. if attacker.beSkillList[BESKILL_TYPE4] then
  747. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE4]) do
  748. use(attacker,baojiDefender,v)
  749. end
  750. end
  751. if attacker.beSkillList[BESKILL_TYPE44] and CombatImpl.isFanji then
  752. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE44]) do
  753. use(attacker,baojiDefender,v)
  754. end
  755. end
  756. --指定技能暴击
  757. if attacker.beSkillList[BESKILL_TYPE58] then
  758. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE58]) do
  759. --local skillConfig = SkillExcel[v[1]]
  760. local skillConfig = Skill.GetSkillConfig(v[1])
  761. local beSkillArgs = skillConfig.beSkillArgs
  762. if beSkillArgs[1] == "skillID" then
  763. local canUse = false
  764. for _,v in ipairs(beSkillArgs[2]) do
  765. if skillID == v then
  766. canUse = true
  767. break
  768. end
  769. end
  770. if canUse then
  771. use(attacker,baojiDefender,v)
  772. end
  773. end
  774. end
  775. end
  776. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  777. local obj = CombatImpl.objList[pos]
  778. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE14] then
  779. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE14]) do
  780. use(obj,targets,v)
  781. end
  782. end
  783. end
  784. end
  785. if isDefendSideGedang then
  786. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  787. local obj = CombatImpl.objList[pos]
  788. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE9] then
  789. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE9]) do
  790. use(obj,targets,v)
  791. end
  792. end
  793. end
  794. end
  795. end
  796. function onHp(obj, hurt, attackPos)
  797. if obj.beSkillList[BESKILL_TYPE3] then
  798. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE3]) do
  799. use(obj,{},v)
  800. end
  801. end
  802. if obj.beSkillList[BESKILL_TYPE67] then
  803. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE67]) do
  804. use(obj,{},v)
  805. end
  806. end
  807. local attacker = CombatImpl.objList[attackPos]
  808. if attacker and attacker.beSkillList[BESKILL_TYPE30] and obj.pos ~= attackPos then
  809. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE30]) do
  810. --local skillConfig = SkillExcel[v[1]]
  811. local skillConfig = Skill.GetSkillConfig(v[1])
  812. local beSkillArgs = skillConfig.beSkillArgs
  813. obj.paramData.isbeSkillByHp = obj.paramData.isbeSkillByHp or 0
  814. if beSkillArgs[1] then
  815. if beSkillArgs[1] == "tohp" then
  816. local hp = obj.hp
  817. local hpMax = CombatObj.getHpMax(obj)
  818. if hp > hpMax * beSkillArgs[2]/10000 then
  819. obj.paramData.isbeSkillByHp = 0 --恢复到上限
  820. else
  821. if obj.isbeSkillByHp == 0 then
  822. obj.paramData.isbeSkillByHp = 1 --达到下限
  823. end
  824. end
  825. elseif beSkillArgs[1] == "hurthpper" then
  826. local hpMax = CombatObj.getHpMax(obj)
  827. local percent = -hurt/hpMax
  828. if percent > beSkillArgs[2]/10000 then -- 伤害超过目标生命值上限X%时
  829. use(attacker,{obj},v)
  830. end
  831. elseif beSkillArgs[1] == "speed" then
  832. local atkSpeed = CombatImpl.getValue(attacker,RoleDefine.SPEED)
  833. local defSpeed = CombatImpl.getValue(obj,RoleDefine.SPEED)
  834. if atkSpeed > defSpeed then
  835. use(attacker,{obj},v)
  836. end
  837. end
  838. end
  839. --使用技能
  840. if obj.paramData.isbeSkillByHp == 1 then
  841. use(attacker,{obj},v)
  842. obj.paramData.isbeSkillByHp = 2
  843. end
  844. end
  845. end
  846. end
  847. -- 选择合适的复活技能
  848. function selectReviceSkill(obj, attacker)
  849. local reviveSkillList = {}
  850. local len = 0
  851. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  852. local skillID = v[1]
  853. local isFuwenSkill = v[5]
  854. --local skillConfig = SkillExcel[skillID]
  855. local skillConfig = Skill.GetSkillConfig(skillID)
  856. if skillConfig.cmd == "revive" then
  857. --有可使用的主动复活技能
  858. local state = isCanRevive(obj, attacker, v)
  859. if state and isFuwenSkill == 0 then
  860. if checkLimit(v) then
  861. len = len + 1
  862. reviveSkillList[k] = 1
  863. break
  864. end
  865. end
  866. end
  867. end
  868. -- 没有再取符文技能的复活
  869. if len == 0 then
  870. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  871. local skillID = v[1]
  872. local isFuwenSkill = v[5]
  873. --local skillConfig = SkillExcel[skillID]
  874. local skillConfig = Skill.GetSkillConfig(skillID)
  875. if skillConfig.cmd == "revive" then
  876. local state = isCanRevive(obj, attacker, v)
  877. if state and isFuwenSkill == 1 then
  878. --被动技能次数限制判断
  879. if checkLimit(v) then
  880. reviveSkillList[k] = 1
  881. break
  882. end
  883. end
  884. end
  885. end
  886. end
  887. return reviveSkillList
  888. end
  889. function onDie(obj, hurt, attackPos)
  890. if obj.hp > 0 then
  891. return
  892. end
  893. local side = obj.side
  894. local attacker = CombatImpl.objList[attackPos]
  895. if obj.attackSkillID then
  896. if attacker and attacker.beSkillList[BESKILL_TYPE43] then
  897. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE43]) do
  898. --local skillConfig = SkillExcel[v[1]]
  899. local skillConfig = Skill.GetSkillConfig(v[1])
  900. for _,v1 in ipairs(skillConfig.beSkillArgs) do
  901. if v1 == obj.attackSkillID then
  902. use(attacker,{obj},v)
  903. break
  904. end
  905. end
  906. end
  907. end
  908. end
  909. local defendSide = side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  910. for _,posData in ipairs(posSortBySpeed[side]) do
  911. local pos = posData[1]
  912. local target = CombatImpl.objList[pos]
  913. if target and target.hp > 0 then
  914. if target.beSkillList[BESKILL_TYPE16] then
  915. for _,v in ipairs(target.beSkillList[BESKILL_TYPE16]) do
  916. use(target,{obj},v)
  917. end
  918. end
  919. if target.beSkillList[BESKILL_TYPE18] then
  920. for _,v in ipairs(target.beSkillList[BESKILL_TYPE18]) do
  921. use(target,{obj},v)
  922. end
  923. end
  924. end
  925. end
  926. for _,posData in ipairs(posSortBySpeed[defendSide]) do
  927. local pos = posData[1]
  928. local target = CombatImpl.objList[pos]
  929. if target and target.hp > 0 then
  930. if target.beSkillList[BESKILL_TYPE17] then
  931. for _,v in ipairs(target.beSkillList[BESKILL_TYPE17]) do
  932. use(target,{obj},v)
  933. end
  934. end
  935. if target.beSkillList[BESKILL_TYPE18] then
  936. for _,v in ipairs(target.beSkillList[BESKILL_TYPE18]) do
  937. use(target,{obj},v)
  938. end
  939. end
  940. end
  941. end
  942. if attacker and attacker.beSkillList and attacker.beSkillList[BESKILL_TYPE30] and obj.pos ~= attackPos then
  943. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE30]) do
  944. if obj.isbeSkillByHp == nil or
  945. obj.isbeSkillByHp == 0 then
  946. use(attacker,{},v)
  947. end
  948. end
  949. end
  950. if attacker and attacker.beSkillList and attacker.beSkillList[BESKILL_TYPE35] then
  951. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE35]) do
  952. use(attacker,{obj},v)
  953. end
  954. end
  955. if obj.beSkillList[BESKILL_TYPE15] then
  956. -- 选择其中一个使用
  957. local reviceSkillList = selectReviceSkill(obj, attacker)
  958. for k, v in ipairs(obj.beSkillList[BESKILL_TYPE15]) do
  959. local skillID = v[1]
  960. --local skillConfig = SkillExcel[skillID]
  961. local skillConfig = Skill.GetSkillConfig(skillID)
  962. if skillConfig.cmd == "revive" then
  963. if reviceSkillList[k] then
  964. use(obj,{},v)
  965. break
  966. end
  967. else
  968. use(obj,{},v)
  969. end
  970. end
  971. end
  972. for _,pos in ipairs(CombatDefine.SIDE2POS[defendSide]) do
  973. local defendobj = CombatImpl.objList[pos]
  974. if defendobj and defendobj.hp > 0 and defendobj.beSkillList[BESKILL_TYPE66] then
  975. for _,v in ipairs(defendobj.beSkillList[BESKILL_TYPE66]) do
  976. --local skillConfig = SkillExcel[v[1]]
  977. local skillConfig = Skill.GetSkillConfig(v[1])
  978. if skillConfig and skillConfig.otherArgs.tdBuffCmd then
  979. if obj.bufferCmd[skillConfig.otherArgs.tdBuffCmd] then
  980. use(defendobj,{},v)
  981. end
  982. end
  983. end
  984. end
  985. end
  986. end
  987. function onAddBuffer(obj,buffer)
  988. --local conf = BufferExcel[buffer.id]
  989. local conf = CombatBuff.GetBuffConfig(buffer.id)
  990. local attacker = CombatImpl.objList[buffer.attackPos]
  991. local cmd = conf.cmd
  992. if cmd == "hurt" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "ranshao" then
  993. if obj.beSkillList[BESKILL_TYPE10] then
  994. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE10]) do
  995. use(obj,{attacker},v)
  996. end
  997. end
  998. end
  999. if cmd == "bingdong" or cmd == "jiansu" then
  1000. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1001. local target = CombatImpl.objList[pos]
  1002. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE63] then
  1003. for _,v in ipairs(target.beSkillList[BESKILL_TYPE63]) do
  1004. use(target,{obj},v)
  1005. end
  1006. end
  1007. end
  1008. end
  1009. if CombatBuff.isControlCmd(cmd) then
  1010. if obj.beSkillList[BESKILL_TYPE11] then
  1011. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE11]) do
  1012. use(obj,{attacker},v)
  1013. end
  1014. end
  1015. if obj.beSkillList[BESKILL_TYPE67] then
  1016. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE67]) do
  1017. use(obj,{attacker},v, true, true)
  1018. end
  1019. end
  1020. end
  1021. if cmd == "ranshao" then
  1022. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1023. local target = CombatImpl.objList[pos]
  1024. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE12] then
  1025. for _,v in ipairs(target.beSkillList[BESKILL_TYPE12]) do
  1026. local beSkillUseCnt = CombatImpl.getBeSkillUse(target,obj.pos,v[1])--特殊条件特殊处理:同一英雄在同一时间被施加多次燃烧状态时只触发一次
  1027. if beSkillUseCnt == 0 then
  1028. use(target,{obj},v)
  1029. CombatImpl.addBeSkillUse(target,obj.pos,v[1])
  1030. end
  1031. end
  1032. end
  1033. end
  1034. end
  1035. if cmd == "zuzhou" then
  1036. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1037. local target = CombatImpl.objList[pos]
  1038. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE51] then
  1039. for _,v in ipairs(target.beSkillList[BESKILL_TYPE51]) do
  1040. use(target,{obj},v)
  1041. end
  1042. end
  1043. end
  1044. end
  1045. if cmd == "revive" then
  1046. if obj.beSkillList[BESKILL_TYPE33] then
  1047. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE33]) do
  1048. use(obj,{attacker},v)
  1049. end
  1050. end
  1051. end
  1052. end
  1053. function onDelBingDongBuffer(obj, buffer)
  1054. --local conf = BufferExcel[buffer.id]
  1055. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1056. local attacker = CombatImpl.objList[buffer.attackPos]
  1057. if conf.cmd == "bingdong" then
  1058. for _, pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1059. local target = CombatImpl.objList[pos]
  1060. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE64] then
  1061. for _,v in ipairs(target.beSkillList[BESKILL_TYPE64]) do
  1062. use(target,{obj},v)
  1063. end
  1064. end
  1065. end
  1066. end
  1067. end
  1068. --援军上阵触发
  1069. function onBackupBegin(obj)
  1070. if not obj then return end
  1071. if CombatDefine.isBackup(obj) ~= CombatDefine.BACKUP_TYPE2 then return end
  1072. -- 备份的被动技能上阵
  1073. if obj.backUpSkillList then
  1074. obj.beSkillList = obj.backUpSkillList
  1075. obj.backUpSkillList = nil
  1076. end
  1077. -- 出站计算属性
  1078. if obj.beSkillList[BESKILL_TYPE26] then
  1079. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE26]) do
  1080. if canUse(obj,v) then
  1081. --local skillConfig = SkillExcel[v[1]]
  1082. local skillConfig = Skill.GetSkillConfig(v[1])
  1083. if skillConfig.cmd == "attr" then
  1084. for _,v1 in ipairs(skillConfig.args) do
  1085. obj.sysAttr[v1[1]] = obj.sysAttr[v1[1]] +v1[2]
  1086. end
  1087. obj.isSysAttrChange = true
  1088. elseif skillConfig.cmd == "normalTarget" then
  1089. use(obj,{},v)
  1090. end
  1091. end
  1092. end
  1093. end
  1094. table.sort(posSortBySpeed[CombatDefine.ATTACK_SIDE],posSpeedCmp)
  1095. table.sort(posSortBySpeed[CombatDefine.DEFEND_SIDE],posSpeedCmp)
  1096. --援军出战触发
  1097. if obj and obj.beSkillList[BESKILL_TYPE32] then
  1098. for k,v in ipairs(obj.beSkillList[BESKILL_TYPE32]) do
  1099. use(obj,{},v)
  1100. end
  1101. end
  1102. --上场技能
  1103. CombatDefine.BACKUP_BUFF_SKILL[2] = 1
  1104. use(obj,{}, CombatDefine.BACKUP_BUFF_SKILL)
  1105. end
  1106. function onRoundBegin(round)
  1107. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1108. local target = CombatImpl.objList[pos]
  1109. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE19] then
  1110. for _,v in ipairs(target.beSkillList[BESKILL_TYPE19]) do
  1111. use(target,{},v)
  1112. end
  1113. end
  1114. -- 生命值触发
  1115. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE62] then
  1116. for _,v in ipairs(target.beSkillList[BESKILL_TYPE62]) do
  1117. --local skillConfig = SkillExcel[v[1]]
  1118. local skillConfig = Skill.GetSkillConfig(v[1])
  1119. local beSkillArgs = skillConfig.beSkillArgs
  1120. if beSkillArgs[1] == 1 then
  1121. local hpMax = CombatObj.getHpMax(target)
  1122. local percent = target.hp/hpMax
  1123. if percent > beSkillArgs[2]/10000 then
  1124. use(target,{},v)
  1125. end
  1126. end
  1127. if beSkillArgs[1] == 2 then
  1128. local hpMax = CombatObj.getHpMax(target)
  1129. local percent = target.hp/hpMax
  1130. if percent < beSkillArgs[2]/10000 then
  1131. use(target,{},v)
  1132. end
  1133. end
  1134. end
  1135. end
  1136. end
  1137. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1138. local target = CombatImpl.objList[pos]
  1139. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE47] then
  1140. for _,v in ipairs(target.beSkillList[BESKILL_TYPE47]) do
  1141. --local skillConfig = SkillExcel[v[1]]
  1142. local skillConfig = Skill.GetSkillConfig(v[1])
  1143. if skillConfig.cmd == "attr" then
  1144. for _,v1 in ipairs(skillConfig.args) do
  1145. target.sysAttr[v1[1]] = target.sysAttr[v1[1]] +v1[2]
  1146. end
  1147. CombatObj.calcAttr(target)
  1148. CombatImpl.addFrame()
  1149. CombatImpl.setSkillID(target, v[1])
  1150. CombatImpl.setSaySkill(target.pos,skillConfig.id,skillConfig.contentType)
  1151. end
  1152. end
  1153. end
  1154. end
  1155. if round and round == 1 then
  1156. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1157. local obj = CombatImpl.objList[pos]
  1158. if obj and obj.beSkillList[BESKILL_TYPE32] then
  1159. for k,v in ipairs(obj.beSkillList[BESKILL_TYPE32]) do
  1160. use(obj,{},v)
  1161. end
  1162. end
  1163. end
  1164. end
  1165. end
  1166. function beforeFanji(obj)
  1167. if not obj or obj.isPet then
  1168. return
  1169. end
  1170. if obj and obj.hurtType == CombatDefine.PHY_HURT_TYPE then
  1171. if obj and obj.beSkillList and obj.beSkillList[BESKILL_TYPE37] then
  1172. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE37]) do
  1173. use(obj,{},v)
  1174. end
  1175. end
  1176. else
  1177. if obj and obj.beSkillList and obj.beSkillList[BESKILL_TYPE38] then
  1178. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE38]) do
  1179. use(obj,{},v)
  1180. end
  1181. end
  1182. end
  1183. end
  1184. function onRoundEnd(isRoundEnd)
  1185. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1186. local obj = CombatImpl.objList[pos]
  1187. if obj and obj.beSkillList[BESKILL_TYPE36] then
  1188. if pos == 1 then
  1189. end
  1190. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE36]) do
  1191. use(obj,{},v)
  1192. end
  1193. end
  1194. end
  1195. if isRoundEnd then
  1196. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1197. local target = CombatImpl.objList[pos]
  1198. if target and target.hp > 0 and target.beSkillList[BESKILL_TYPE20] then
  1199. for _,v in ipairs(target.beSkillList[BESKILL_TYPE20]) do
  1200. use(target,{},v)
  1201. end
  1202. end
  1203. end
  1204. end
  1205. end
  1206. function posSpeedCmp(a,b)
  1207. if a[2] > b[2] then
  1208. return true
  1209. elseif a[2] < b[2] then
  1210. return false
  1211. else
  1212. return a[1] < b[1]
  1213. end
  1214. end
  1215. function onFightBegin()
  1216. posSortBySpeed[CombatDefine.ATTACK_SIDE] = {}
  1217. posSortBySpeed[CombatDefine.DEFEND_SIDE] = {}
  1218. for pos = 1,CombatDefine.COMBAT_HERO_ALL_CNT do
  1219. local obj = CombatImpl.objList[pos]
  1220. if obj then
  1221. if obj.beSkillList[BESKILL_TYPE26] then
  1222. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE26]) do
  1223. if canUse(obj,v) then
  1224. --local skillConfig = SkillExcel[v[1]]
  1225. local skillConfig = Skill.GetSkillConfig(v[1])
  1226. if skillConfig.cmd == "attr" then
  1227. for _,v1 in ipairs(skillConfig.args) do
  1228. obj.sysAttr[v1[1]] = obj.sysAttr[v1[1]] +v1[2]
  1229. end
  1230. obj.isSysAttrChange = true
  1231. elseif skillConfig.cmd == "normalTarget" then
  1232. use(obj,{},v)
  1233. end
  1234. end
  1235. end
  1236. end
  1237. if pos <= CombatDefine.COMBAT_HERO_CNT then
  1238. posSortBySpeed[CombatDefine.ATTACK_SIDE][#posSortBySpeed[CombatDefine.ATTACK_SIDE]+1] = {pos,obj.attr and obj.attr[RoleDefine.SPEED] or 0}
  1239. elseif pos <= CombatDefine.COMBAT_HERO_CNT * 2 then
  1240. posSortBySpeed[CombatDefine.DEFEND_SIDE][#posSortBySpeed[CombatDefine.DEFEND_SIDE]+1] = {pos,obj.attr and obj.attr[RoleDefine.SPEED] or 0}
  1241. end
  1242. end
  1243. end
  1244. table.sort(posSortBySpeed[CombatDefine.ATTACK_SIDE],posSpeedCmp)
  1245. table.sort(posSortBySpeed[CombatDefine.DEFEND_SIDE],posSpeedCmp)
  1246. end
  1247. function onCombatPetBe(round)
  1248. if round <= 1 then
  1249. return
  1250. end
  1251. for side = 1,CombatDefine.DEFEND_SIDE do
  1252. local pet = CombatImpl.petList[side]
  1253. if pet and pet.petID and pet.beSkillList[BESKILL_TYPE27] then
  1254. for _,v in ipairs(pet.beSkillList[BESKILL_TYPE27]) do
  1255. --local skillConfig = SkillExcel[v[1]]
  1256. local skillConfig = Skill.GetSkillConfig(v[1])
  1257. if skillConfig.cmd == "mp" then
  1258. use(pet,{},v)
  1259. end
  1260. end
  1261. end
  1262. end
  1263. end
  1264. -- 计算被动技能属性
  1265. local beSkillIDList = {}
  1266. function doCalcHero(obj, attrs, skinSkillID, heroConf)
  1267. for i = 1, #beSkillIDList do
  1268. beSkillIDList[i] = nil
  1269. end
  1270. heroConf = heroConf or HeroDefine.getAttrConfig(obj.id, obj.star)
  1271. local beSkillIDs = heroConf.beSkillList
  1272. local skinSkillConf = skinSkillID and SkinSkillExcel[skinSkillID]
  1273. if skinSkillConf then
  1274. beSkillIDs = skinSkillConf.beSkillList
  1275. end
  1276. for _, skillID in ipairs(beSkillIDs) do
  1277. --local skillConfig = SkillExcel[skillID]
  1278. local skillConfig = Skill.GetSkillConfig(skillID)
  1279. if skillConfig.beSkillType == BESKILL_TYPE24 and
  1280. ((not obj) or (obj.quality >= skillConfig.need)) then
  1281. for _,v in ipairs(skillConfig.args) do
  1282. beSkillIDList[#beSkillIDList + 1] = v
  1283. end
  1284. else
  1285. beSkillIDList[#beSkillIDList + 1] = skillID
  1286. end
  1287. end
  1288. for _, skillID in ipairs(beSkillIDList) do
  1289. --local skillConfig = SkillExcel[skillID]
  1290. local skillConfig = Skill.GetSkillConfig(skillID)
  1291. if skillConfig and skillConfig.cmd == "attr" and
  1292. skillConfig.beSkillType == BESKILL_TYPE23 and
  1293. ((not obj) or (obj.quality >= skillConfig.need)) then
  1294. for _, v in ipairs(skillConfig.args) do
  1295. RoleAttr.updateValue(v[1], v[2], attrs)
  1296. end
  1297. elseif skillConfig and skillConfig.cmd == "attrcomboAgain" and
  1298. skillConfig.beSkillType == BESKILL_TYPE70 and
  1299. ((not obj) or (obj.quality >= skillConfig.need)) then
  1300. for i, v in ipairs(skillConfig.args) do
  1301. if v[1] == 1 then
  1302. RoleAttr.updateValue(v[2], v[3], attrs)
  1303. end
  1304. end
  1305. end
  1306. end
  1307. end
  1308. function beforeHit(attacker,defender)
  1309. attacker.beforeHitCheck = false
  1310. if attacker.beSkillList[BESKILL_TYPE40] then
  1311. local hpMax = CombatObj.getHpMax(defender)
  1312. local hp = defender.hp
  1313. local defendHpRate = hp*10000/hpMax
  1314. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1315. --local skillConfig = SkillExcel[v[1]]
  1316. local skillConfig = Skill.GetSkillConfig(v[1])
  1317. if skillConfig.cmd == "lowerLimit" then
  1318. local args = skillConfig.args
  1319. if defendHpRate < args[1] then
  1320. attacker.beforeHitCheck = true
  1321. attacker.beskill40 = attacker.beskill40 or {}
  1322. attacker.beskill40[defender.pos] = 1
  1323. end
  1324. end
  1325. end
  1326. end
  1327. end
  1328. function afterHit(attacker,target, isEnd)
  1329. if attacker.beforeHitCheck then
  1330. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1331. use(attacker,{target},v)
  1332. end
  1333. end
  1334. beforeFanji(attacker, isEnd)
  1335. end
  1336. function getOutAtkRate(attacker, defender)
  1337. local outAtkRate = 0
  1338. -- 首次攻击
  1339. local isFirstAttack = CombatImpl.firstAttack[attacker.side]
  1340. if isFirstAttack then
  1341. for _,pos in ipairs(CombatDefine.SIDE2POS[defender.side]) do
  1342. local objM = CombatImpl.objList[pos]
  1343. if objM and objM.beSkillList[BESKILL_TYPE50] then
  1344. for _,v in ipairs(objM.beSkillList[BESKILL_TYPE50]) do
  1345. --local skillConfig = SkillExcel[v[1]]
  1346. local skillConfig = Skill.GetSkillConfig(v[1])
  1347. if skillConfig and skillConfig.otherArgs.outAtkRate then
  1348. if skillConfig.otherArgs.outAtkRate >= outAtkRate then
  1349. outAtkRate = skillConfig.otherArgs.outAtkRate
  1350. end
  1351. end
  1352. end
  1353. end
  1354. end
  1355. end
  1356. return outAtkRate
  1357. end
  1358. function getExtraHurtRate(attacker,defender,skillConfig)
  1359. if not attacker or attacker.isPet then
  1360. return 0
  1361. end
  1362. local zhanyiRet = 0
  1363. local bodongHurtRet = 0
  1364. local zhenduiHurtRate = 0
  1365. local zhenduiLen = 0
  1366. local zhenduiList = {}
  1367. local bezhenduiList = {}
  1368. local hpHurtRate = 0
  1369. local extraSpeedHurt = 0
  1370. local firstHurt = 0
  1371. local sexHurt = 0
  1372. local campHurt = 0
  1373. local reJobHurt = 0
  1374. for k,skillList in pairs(attacker.beSkillList) do
  1375. for j,v in pairs(skillList) do
  1376. --local config = SkillExcel[v[1]]
  1377. local config = Skill.GetSkillConfig(v[1])
  1378. if config.cmd == "zhanyi" then --战意 伤害加成
  1379. local nowHp = attacker.hp
  1380. local hpMax = CombatObj.getHpMax(attacker)
  1381. local percent = math.floor( (hpMax - nowHp )/hpMax * 100)
  1382. if percent >= 1 then
  1383. zhanyiRet = zhanyiRet + (percent * config.args[2])
  1384. end
  1385. elseif config.cmd == "fuwenAKH" then
  1386. for i = 1,#config.otherArgs do
  1387. zhenduiLen = zhenduiLen + 1
  1388. zhenduiList[config.otherArgs[i][1]] = zhenduiList[config.otherArgs[i][1]] or 0
  1389. zhenduiList[config.otherArgs[i][1]] = zhenduiList[config.otherArgs[i][1]] + config.otherArgs[i][2]
  1390. end
  1391. elseif config.cmd == "hurtBodong" then
  1392. if canUse(attacker, v) then
  1393. local minRet = config.args[1]
  1394. local maxRet = config.args[2]
  1395. local randomRet = math.random(minRet, maxRet)
  1396. bodongHurtRet = bodongHurtRet + randomRet - 10000
  1397. end
  1398. elseif config.cmd == "hpExtraHurt" then
  1399. local hp = defender.hp
  1400. local beSkillArgs = config.beSkillArgs
  1401. local checkHp = CombatObj.getHpMax(defender) * beSkillArgs[3] / 10000
  1402. if beSkillArgs[2] == 1 and hp > checkHp then
  1403. hpHurtRate = beSkillArgs[4]
  1404. elseif beSkillArgs[2] == 2 and hp < checkHp then
  1405. hpHurtRate = beSkillArgs[4]
  1406. end
  1407. elseif config.cmd == "extraSpeedHurt" then
  1408. extraSpeedHurt = config.args[1]
  1409. elseif config.cmd == "firstAttackHurt" then
  1410. if canUse(attacker, v) then
  1411. firstHurt = config.args[1]
  1412. end
  1413. end
  1414. end
  1415. end
  1416. for k,skillList in pairs(defender.beSkillList) do
  1417. for j,v in pairs(skillList) do
  1418. --local conf = SkillExcel[v[1]]
  1419. local conf = Skill.GetSkillConfig(v[1])
  1420. if conf then
  1421. if conf.cmd == "befuwenAKH" then
  1422. for i = 1,#conf.otherArgs do
  1423. zhenduiLen = zhenduiLen + 1
  1424. bezhenduiList[conf.otherArgs[i][1]] = bezhenduiList[conf.otherArgs[i][1]] or 0
  1425. bezhenduiList[conf.otherArgs[i][1]] = bezhenduiList[conf.otherArgs[i][1]] + conf.otherArgs[i][2]
  1426. end
  1427. -- 受性别增伤
  1428. elseif conf.cmd == "sexHurt" then
  1429. if attacker.sex == conf.args[1] then
  1430. sexHurt = sexHurt + conf.args[2]
  1431. end
  1432. -- 受阵营增伤
  1433. elseif conf.cmd == "campHurt" then
  1434. if attacker.camp == conf.args[1] then
  1435. campHurt = campHurt + conf.args[2]
  1436. end
  1437. -- 受职业增伤
  1438. elseif conf.cmd == "reJobHurt" then
  1439. if attacker.job == conf.args[1] then
  1440. reJobHurt = reJobHurt + conf.args[2]
  1441. end
  1442. end
  1443. end
  1444. end
  1445. end
  1446. if zhenduiLen > 0 then
  1447. local bAdd = 0
  1448. for k,skillList in pairs(defender.beSkillList) do
  1449. for j,v in pairs(skillList) do
  1450. --local conf = SkillExcel[v[1]]
  1451. local conf = Skill.GetSkillConfig(v[1])
  1452. local isFuWenSkill = v[5]
  1453. if conf.cmd and conf.cmd ~= "" and zhenduiList[conf.cmd] then
  1454. -- 符文技能只生效一个
  1455. if isFuWenSkill == 1 then
  1456. if bAdd == 0 then
  1457. zhenduiHurtRate = zhenduiHurtRate + zhenduiList[conf.cmd]
  1458. bAdd = 1
  1459. end
  1460. else
  1461. zhenduiHurtRate = zhenduiHurtRate + zhenduiList[conf.cmd]
  1462. end
  1463. end
  1464. end
  1465. end
  1466. bAdd = 0
  1467. for k,skillList in pairs(attacker.beSkillList) do
  1468. for j,v in pairs(skillList) do
  1469. --local conf = SkillExcel[v[1]]
  1470. local conf = Skill.GetSkillConfig(v[1])
  1471. local isFuWenSkill = v[5]
  1472. if conf.cmd and conf.cmd ~= "" and bezhenduiList[conf.cmd] then
  1473. if isFuWenSkill == 1 then
  1474. if bAdd == 0 then
  1475. zhenduiHurtRate = zhenduiHurtRate + bezhenduiList[conf.cmd]
  1476. bAdd = 1
  1477. end
  1478. else
  1479. zhenduiHurtRate = zhenduiHurtRate + bezhenduiList[conf.cmd]
  1480. end
  1481. end
  1482. end
  1483. end
  1484. end
  1485. --特殊buff 对血族的加成
  1486. local campHurtRate = 0
  1487. local campRate = nil
  1488. local buffCmd = nil
  1489. local camp = nil
  1490. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1491. obj = CombatImpl.objList[pos]
  1492. if obj and obj.hp > 0 then
  1493. if obj.beSkillList[BESKILL_TYPE68] then
  1494. local beSkillList = obj.beSkillList[BESKILL_TYPE68][1]
  1495. --local skillConfig = SkillExcel[beSkillList[1]]
  1496. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1497. if skillConfig then
  1498. camp = skillConfig.otherArgs.calcCamp[1]
  1499. buffCmd = skillConfig.otherArgs.calcCamp[2]
  1500. campRate = skillConfig.otherArgs.calcCamp[3]
  1501. break
  1502. end
  1503. end
  1504. end
  1505. end
  1506. if buffCmd and campRate and attacker.camp == camp then
  1507. local campHurtCnt = 0
  1508. for _,pos in ipairs(CombatDefine.SIDE2POS[defender.side]) do
  1509. obj = CombatImpl.objList[pos]
  1510. if obj and obj.hp > 0 then
  1511. local isStatus1, cmd1, ind1 = CombatBuff.isStatus(obj, buffCmd)
  1512. if isStatus1 then
  1513. campHurtCnt = campHurtCnt + 1
  1514. end
  1515. end
  1516. end
  1517. if campHurtCnt > 0 then
  1518. campHurtRate = campHurtCnt * campRate
  1519. end
  1520. end
  1521. local extraHurtRate = zhanyiRet + zhenduiHurtRate + bodongHurtRet + hpHurtRate + extraSpeedHurt + firstHurt + sexHurt + campHurt + reJobHurt + campHurtRate
  1522. if attacker.beSkillList[BESKILL_TYPE40] and attacker.beforeHitCheck then
  1523. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE40]) do
  1524. --local skillConfig = SkillExcel[v[1]]
  1525. local skillConfig = Skill.GetSkillConfig(v[1])
  1526. if skillConfig.cmd == "extraHurt" then
  1527. local args = skillConfig.args
  1528. extraHurtRate = extraHurtRate + args[1]
  1529. end
  1530. end
  1531. end
  1532. return extraHurtRate
  1533. end
  1534. --
  1535. function getExtraHurt(attacker, target, tUseskillConfig)
  1536. local extraHurt = 0
  1537. if attacker.beSkillList[BESKILL_TYPE55] then
  1538. local beSkillList = attacker.beSkillList[BESKILL_TYPE55][1]
  1539. --local skillConfig = SkillExcel[beSkillList[1]]
  1540. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1541. local buffCmd = target.bufferCmd[skillConfig.otherArgs.buffCmdHurtRate[1]]
  1542. local rate = skillConfig.otherArgs.buffCmdHurtRate[2] / 10000
  1543. if buffCmd then
  1544. local buffCnt = #buffCmd
  1545. local buffIndex = buffCmd[buffCnt]
  1546. local buffer = target.buffer[buffIndex]
  1547. --local conf = BufferExcel[buffer.id]
  1548. local conf = CombatBuff.GetBuffConfig(buffer.id)
  1549. local hurt = buffer.arg[1]
  1550. extraHurt = extraHurt + hurt * rate * buffCnt
  1551. end
  1552. end
  1553. return extraHurt
  1554. end
  1555. --
  1556. function getRandomBuffCmd(attacker, target, cmd)
  1557. local side = attacker.side
  1558. local mathRandom = math.random
  1559. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1560. local obj = CombatImpl.objList[pos]
  1561. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE56] then
  1562. local beSkillList = obj.beSkillList[BESKILL_TYPE56][1]
  1563. --local skillConfig = SkillExcel[beSkillList[1]]
  1564. local skillConfig = Skill.GetSkillConfig(beSkillList[1])
  1565. local buffCmdRand = skillConfig.otherArgs.buffCmdRand
  1566. if buffCmdRand and cmd == buffCmdRand[1] then
  1567. local random = mathRandom(1, 10000)
  1568. if random <= buffCmdRand[2] then
  1569. return true
  1570. end
  1571. end
  1572. end
  1573. end
  1574. end
  1575. function getHurtPercentRate(attacker, defender, hurt, tUseskillConfig)
  1576. local rate = 0
  1577. for k,skillList in pairs(defender.beSkillList) do
  1578. for j,v in pairs(skillList) do
  1579. --local conf = SkillExcel[v[1]]
  1580. local conf = Skill.GetSkillConfig(v[1])
  1581. if conf and conf.cmd == "behurtRet" then
  1582. local canUse = true
  1583. if conf.beSkillArgs and #conf.beSkillArgs > 0 then
  1584. if conf.beSkillArgs[1] == "hurthpper" then
  1585. local hpMax = CombatObj.getHpMax(defender)
  1586. local percent = hurt/hpMax
  1587. if percent < conf.beSkillArgs[2]/10000 then -- 伤害超过目标生命值上限X%时
  1588. canUse = false
  1589. end
  1590. end
  1591. end
  1592. if canUse == true then
  1593. local random = math.random(1, 10000)
  1594. if random <= conf.args[2] then
  1595. rate = rate + conf.args[1]
  1596. end
  1597. end
  1598. end
  1599. end
  1600. end
  1601. if tUseskillConfig.type == CombatDefine.SKILL_TYPE1 then
  1602. if attacker.beSkillList[BESKILL_TYPE1] then
  1603. for _, v in pairs(attacker.beSkillList[BESKILL_TYPE1]) do
  1604. local nSkillID = v[1]
  1605. --local skillConfig = SkillExcel[nSkillID]
  1606. local skillConfig = Skill.GetSkillConfig(nSkillID)
  1607. if skillConfig and skillConfig.hurtRate and skillConfig.hurtRate[1] then
  1608. local fRate = skillConfig.hurtRate[1]
  1609. rate = rate + fRate
  1610. --print("[getExtraHurt] 获取到的普工伤害加成概率 fRate = "..fRate.." 总加成 rate = "..rate)
  1611. end
  1612. end
  1613. end
  1614. end
  1615. return rate
  1616. end
  1617. function getBufferExtraHurt(attacker,bufferID,cmd)
  1618. local rate = 0
  1619. for _,skillList in pairs(attacker.beSkillList) do
  1620. for k,v in pairs(skillList) do
  1621. --local conf = SkillExcel[v[1]]
  1622. local conf = Skill.GetSkillConfig(v[1])
  1623. local otherArgs = conf.otherArgs
  1624. if bufferID and otherArgs.bufferExtraHurt then
  1625. for k1,v1 in ipairs(otherArgs.bufferExtraHurt[1]) do
  1626. if bufferID == v1 then
  1627. rate = rate + otherArgs.bufferExtraHurt[2]
  1628. end
  1629. end
  1630. end
  1631. if cmd and otherArgs.bufferCmdExtraHurt then
  1632. for k1,v1 in ipairs(otherArgs.bufferCmdExtraHurt[1]) do
  1633. if cmd == v1 then
  1634. rate = rate + otherArgs.bufferCmdExtraHurt[2]
  1635. end
  1636. end
  1637. end
  1638. end
  1639. end
  1640. return rate
  1641. end
  1642. function getExtraHurtRateEx(attacker, defender)
  1643. local rate = 0
  1644. -- 死亡数伤害率
  1645. if attacker.beSkillList[BESKILL_TYPE48] then
  1646. for _,v in ipairs(attacker.beSkillList[BESKILL_TYPE48]) do
  1647. --local skillConfig = SkillExcel[v[1]]
  1648. local skillConfig = Skill.GetSkillConfig(v[1])
  1649. if skillConfig and skillConfig.otherArgs.deathHurt then
  1650. local side = defender.side
  1651. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1652. local obj = CombatImpl.objList[pos]
  1653. if obj and obj.hp <=0 then
  1654. if rate == 0 then
  1655. rate = skillConfig.otherArgs.deathHurt
  1656. else
  1657. rate = rate + 10000
  1658. end
  1659. end
  1660. end
  1661. end
  1662. end
  1663. end
  1664. return rate
  1665. end
  1666. --
  1667. function getBuffChixuHurt(attacker, cmd)
  1668. if not attacker then return 0 end
  1669. local hurt = 0
  1670. local side = attacker.side
  1671. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1672. local objM = CombatImpl.objList[pos]
  1673. if objM and objM.hp > 0 and objM.beSkillList[BESKILL_TYPE54] then
  1674. for _,v in ipairs(objM.beSkillList[BESKILL_TYPE54]) do
  1675. --local skillConfig = SkillExcel[v[1]]
  1676. local skillConfig = Skill.GetSkillConfig(v[1])
  1677. if skillConfig and skillConfig.otherArgs[cmd] then
  1678. hurt = hurt + skillConfig.otherArgs[cmd]
  1679. end
  1680. end
  1681. end
  1682. end
  1683. return hurt / 10000
  1684. end
  1685. --
  1686. function handlerBuff(attacker, target, arg, cmd)
  1687. if not attacker then return end
  1688. for _,pos in ipairs(CombatDefine.SIDE2POS[attacker.side]) do
  1689. local obj = CombatImpl.objList[pos]
  1690. if obj and obj.hp > 0 and obj.beSkillList[BESKILL_TYPE57] then
  1691. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE57]) do
  1692. attacker.args = arg
  1693. use(attacker, {target}, v, false)
  1694. end
  1695. end
  1696. end
  1697. end
  1698. function beforeMinusHp(obj, value)
  1699. if value <= 0 then return end
  1700. --敌对阵营 有对象有 49号被动技能 加血变成减血
  1701. local side = obj.side == CombatDefine.ATTACK_SIDE and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
  1702. for _,pos in ipairs(CombatDefine.SIDE2POS[side]) do
  1703. local objM = CombatImpl.objList[pos]
  1704. if objM and objM.hp > 0 and objM.beSkillList[BESKILL_TYPE49] then
  1705. value = value * (-1)
  1706. break
  1707. end
  1708. end
  1709. return value
  1710. end
  1711. function beforeUpdateHp(obj,sum)
  1712. if sum <= 0 and obj.beSkillList[BESKILL_TYPE41] then
  1713. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE41]) do
  1714. --local skillConfig = SkillExcel[v[1]]
  1715. local skillConfig = Skill.GetSkillConfig(v[1])
  1716. if skillConfig.cmd == "miansi" and canUse(obj,v) then
  1717. use(obj,{},v)
  1718. return true
  1719. end
  1720. end
  1721. end
  1722. end
  1723. function onCheckBuffer(obj,attacker,value)
  1724. local ret = value
  1725. if obj.beSkillList[BESKILL_TYPE42] then
  1726. for _,v in ipairs(obj.beSkillList[BESKILL_TYPE42]) do
  1727. --local skillConfig = SkillExcel[v[1]]
  1728. local skillConfig = Skill.GetSkillConfig(v[1])
  1729. if canUse(obj,v) then
  1730. local newFrame = true
  1731. if skillConfig.cmd == "baohu" then
  1732. obj.baohuHurt = value * skillConfig.args[1] / 10000
  1733. if obj.hp < -obj.baohuHurt then
  1734. obj.baohuHurt = -obj.hp
  1735. end
  1736. ret = value - obj.baohuHurt
  1737. newFrame = false
  1738. end
  1739. use(obj,{attacker},v, newFrame)
  1740. break
  1741. end
  1742. end
  1743. end
  1744. return ret
  1745. end
  1746. function getStatusBaoji(attacker, defender)
  1747. local baoji = 0
  1748. local firstBaoji = 0
  1749. for k, skillList in pairs(attacker.beSkillList) do
  1750. for j, v in pairs(skillList) do
  1751. --local config = SkillExcel[v[1]]
  1752. local config = Skill.GetSkillConfig(v[1])
  1753. if config.cmd == "firstAttackHurt" then
  1754. if canUse(attacker, v) then
  1755. firstBaoji = config.args[2] or 0
  1756. end
  1757. end
  1758. end
  1759. end
  1760. if attacker.beSkillList[BESKILL_TYPE60] then
  1761. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE60]) do
  1762. --local skillConfig = SkillExcel[v[1]]
  1763. local skillConfig = Skill.GetSkillConfig(v[1])
  1764. if skillConfig and skillConfig.otherArgs.addStatusBaoji then
  1765. local status = CombatBuff.getStatus(defender)
  1766. local isStatus = false
  1767. for k, v in ipairs(skillConfig.otherArgs.addStatusBaoji[1]) do
  1768. if status[v] then
  1769. isStatus = true
  1770. break
  1771. end
  1772. end
  1773. if isStatus then
  1774. baoji = baoji + skillConfig.otherArgs.addStatusBaoji[2]
  1775. end
  1776. end
  1777. end
  1778. end
  1779. if attacker.beSkillList[BESKILL_TYPE69] and attacker.notBaoJi then
  1780. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE69]) do
  1781. --local skillConfig = SkillExcel[v[1]]
  1782. local skillConfig = Skill.GetSkillConfig(v[1])
  1783. if skillConfig and skillConfig.otherArgs.addNotBaoji then
  1784. baoji = baoji + skillConfig.otherArgs.addNotBaoji
  1785. end
  1786. end
  1787. end
  1788. return baoji + firstBaoji
  1789. end
  1790. function getStatusPojia(attacker, defender)
  1791. local poJia = 0
  1792. -- 对指定状态破甲加成 走的技能状态属性
  1793. if attacker.beSkillList[BESKILL_TYPE60] then
  1794. for _, v in ipairs(attacker.beSkillList[BESKILL_TYPE60]) do
  1795. --local skillConfig = SkillExcel[v[1]]
  1796. local skillConfig = Skill.GetSkillConfig(v[1])
  1797. if skillConfig.otherArgs.addStatusPoJia then
  1798. local status = CombatBuff.getStatus(defender)
  1799. local isStatus = false
  1800. for k, v in ipairs(skillConfig.otherArgs.addStatusPoJia[1]) do
  1801. if status[v] then
  1802. isStatus = true
  1803. break
  1804. end
  1805. end
  1806. if isStatus then
  1807. poJia = poJia + skillConfig.otherArgs.addStatusPoJia[2]
  1808. end
  1809. end
  1810. end
  1811. end
  1812. return poJia
  1813. end