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