BeSkill.lua 61 KB

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