BeSkill.lua 60 KB

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