Skill.lua 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  1. local CombatImpl = require("combat.CombatImpl")
  2. local TargetMode = require("combat.TargetMode")
  3. local CombatCalc = require("combat.CombatCalc")
  4. local CombatObj = require("combat.CombatObj")
  5. local RoleDefine = require("role.RoleDefine")
  6. local CombatBuff = require("combat.CombatBuff")
  7. local CombatDefine = require("combat.CombatDefine")
  8. local BeSkill = require("combat.BeSkill")
  9. local Util = require("common.Util")
  10. local SkillExcel = require("excel.skill").skill
  11. local CmdExcel = require("excel.skill").cmd
  12. local ProjectLogic = require("platform.ProjectLogic")
  13. -- local BufferExcel = require("excel.buffer")
  14. local weaponSkillConfig = require("excel.weapon").skill
  15. local function calcHp(attacker,target,calcType,rate,limit,isAddHp,param, flag)
  16. local hp = CombatCalc.calcHp(attacker,target,calcType,rate, isAddHp, flag)
  17. if param and param.targetCnt then
  18. hp = hp / param.targetCnt
  19. end
  20. if limit then
  21. if hp > limit then
  22. hp = limit
  23. end
  24. end
  25. return hp
  26. end
  27. function GetSkillConfig(skillId)
  28. return weaponSkillConfig[skillId] or SkillExcel[skillId]
  29. end
  30. --如果该技能属于专属武器加强的技能, 则用专属武器配置表中的配置
  31. function GetFinalSkillConfig(obj, skillId)
  32. local targetId = skillId
  33. if obj and obj.weaponEffectIdList and obj.weaponEffectIdList[skillId] then
  34. targetId = obj.weaponEffectIdList[skillId]
  35. end
  36. return GetSkillConfig(targetId)
  37. end
  38. -- 技能释放条件检测表
  39. COND_CMD = {}
  40. -- 技能释放代价表
  41. COST_CMD = {}
  42. -- 技能释放条件检查
  43. function COND_CMD.attrCheck(obj, skillId)
  44. local skillConfig = GetSkillConfig(skillId)
  45. local skillCond = skillConfig.cond
  46. local attrType = skillCond[2]
  47. local attrCondVal = skillCond[3] * 100
  48. local nowAttrVal = CombatObj.getValue(obj, attrType)
  49. if nowAttrVal <= attrCondVal then
  50. return false
  51. end
  52. return true
  53. end
  54. -- 扣除技能释放的消耗, 暂时写死,胡须再看看怎么优化
  55. function COST_CMD.attrCheck(obj, skillConfig)
  56. local skillCond = skillConfig.cond
  57. local rate = skillCond[3] * 100
  58. local hurt = calcHp(obj, {}, 2, rate)
  59. if hurt ~= 0 then
  60. local d = CombatObj.updateHp(obj,-hurt,nil,true, obj.pos,CombatObj.SKILL_HP_TYPE)
  61. if d ~= 0 then
  62. CombatImpl.setExtraHit(obj,-hurt,CMD2ID["hurt"])
  63. CombatObj.onHpCB(obj, d, obj.pos)
  64. end
  65. end
  66. end
  67. -- 技能释放条件检测
  68. function SkillCondCheck(obj, skillId)
  69. local skillConfig = GetSkillConfig(skillId)
  70. local skillCond = skillConfig.cond
  71. if not skillCond or not next(skillCond) then
  72. return true
  73. end
  74. if COND_CMD[skillCond[1]] then
  75. return COND_CMD[skillCond[1]](obj, skillId)
  76. end
  77. return false
  78. end
  79. function setSkill(obj,config,skinConfig)
  80. config = skinConfig or config
  81. local skillList = {}
  82. local skillConfig
  83. local normalAtkID = config.normalAtkID
  84. local temp = {}
  85. --普通技能
  86. if normalAtkID then
  87. --skillConfig = SkillExcel[normalAtkID]
  88. skillConfig = GetFinalSkillConfig(obj, normalAtkID)
  89. normalAtkID = skillConfig.id
  90. skillList[#skillList + 1] = {normalAtkID,skillConfig.cd[1] or 0,skillConfig.cd[2] or 0}--skillID,开始使用回合,冷切回合
  91. temp[normalAtkID] = true
  92. end
  93. --主动技能
  94. for _,skillID in ipairs(config.skillList) do
  95. --skillConfig = SkillExcel[skillID]
  96. --使用新的ID
  97. skillConfig = GetFinalSkillConfig(obj, skillID)
  98. skillID = skillConfig.id
  99. if not temp[skillID] and skillConfig and skillConfig.need <= obj.quality then
  100. skillList[#skillList + 1] = {skillID,skillConfig.cd[1] or 0,skillConfig.cd[2] or 0}--skillID,开始使用回合,冷切回合
  101. temp[skillID] = true
  102. end
  103. end
  104. if #skillList > 1 then
  105. table.sort(skillList,function(a,b)
  106. return a[3] > b[3]
  107. end)
  108. end
  109. obj.skillList = skillList
  110. end
  111. CMD2ID = {}
  112. function initAfterHot()
  113. for k,v in pairs(CMD2ID) do
  114. CMD2ID[k] = nil
  115. end
  116. for k,v in pairs(CmdExcel) do
  117. CMD2ID[v.cmd] = k
  118. end
  119. end
  120. function getCMD2ID(cmd)
  121. return CMD2ID[cmd]
  122. end
  123. GroupSkillCnt = 0--技能包触发技能次数
  124. local function realUse(obj, skillID, fanjiTargets,otherArgs)
  125. --local skillConfig = SkillExcel[skillID]
  126. local skillConfig = GetSkillConfig(skillID)
  127. CombatImpl.nowAttacker = obj
  128. if skillConfig then
  129. --直接伤害
  130. CombatCalc.initAttacker(obj)
  131. local targets = TargetMode.getTargets(obj, skillConfig.targetMode, fanjiTargets, nil, true,skillConfig.type == CombatDefine.SKILL_TYPE1,skillID, true)
  132. -- local fentanBuffObjs = {}
  133. local len = #targets
  134. if len < 1 then return end
  135. for i=1, len do
  136. local defobj = targets[i]
  137. -- if defobj.addByfentan then
  138. -- fentanBuffObjs[defobj.pos] = defobj.id
  139. -- end
  140. CombatCalc.initAttacker(defobj)
  141. end
  142. GroupSkillCnt = GroupSkillCnt + 1
  143. -- 复活技能不走这里
  144. if skillConfig.cmd ~= "revive" then
  145. CombatImpl.addFrame()
  146. CombatImpl.setSkillID(obj, skillID)
  147. CombatImpl.setSaySkill(obj.pos,skillConfig.id,skillConfig.contentType)
  148. end
  149. attack(obj, targets, skillConfig)
  150. local newTargets = {}
  151. -- for _, lObj in ipairs(targets) do
  152. -- if not lObj.addByfentan and not fentanBuffObjs[lObj.pos] then
  153. -- newTargets[#newTargets+1] = lObj
  154. -- end
  155. -- end
  156. for _, lObj in ipairs(targets) do
  157. if not lObj.addByfentan then
  158. newTargets[#newTargets+1] = lObj
  159. end
  160. end
  161. if not fanjiTargets and skillConfig.otherArgs.addBuffBeforeCmd then
  162. CombatBuff.onHit(obj,newTargets,skillConfig)
  163. end
  164. --额外作用
  165. local cmdTargets
  166. if CMD[skillConfig.cmd] then
  167. cmdTargets = CMD[skillConfig.cmd](obj, skillConfig, newTargets)
  168. end
  169. if not fanjiTargets then
  170. if not skillConfig.otherArgs.addBuffBeforeCmd then
  171. CombatBuff.onHit(obj,newTargets,skillConfig,cmdTargets,otherArgs)
  172. end
  173. end
  174. BeSkill.onHit(obj,newTargets,skillID)
  175. CombatImpl.totalAtkCnt = CombatImpl.totalAtkCnt + 1
  176. end
  177. CombatImpl.nowAttacker = nil
  178. end
  179. function use(obj, skillID, fanjiTargets)
  180. --local skillConfig = SkillExcel[skillID]
  181. local skillConfig = GetSkillConfig(skillID)
  182. GroupSkillCnt = 0
  183. if skillConfig.type == CombatDefine.SKILL_TYPE5 then
  184. for k,v in ipairs(skillConfig.otherArgs.skillList) do
  185. --local config = SkillExcel[v]
  186. local config = GetSkillConfig(v)
  187. local targets = TargetMode.getTargets(obj, config.targetMode,fanjiTargets, nil , true)
  188. if #targets > 0 then
  189. realUse(obj, v,fanjiTargets)
  190. return
  191. end
  192. end
  193. elseif skillConfig.type == CombatDefine.SKILL_TYPE6 then
  194. for k,v in ipairs(skillConfig.otherArgs.skillList) do
  195. --local config = SkillExcel[v]
  196. local config = GetSkillConfig(v)
  197. local targets = TargetMode.getTargets(obj, config.targetMode,fanjiTargets, nil , true)
  198. if #targets > 0 then
  199. realUse(obj, v,fanjiTargets,{noFirst = (k ~= 1)})
  200. end
  201. end
  202. -- 扣除技能消耗
  203. local skillCond = skillConfig.cond
  204. if COST_CMD[skillCond[1]] then
  205. COST_CMD[skillCond[1]](obj, skillConfig)
  206. end
  207. elseif skillConfig.type == CombatDefine.SKILL_TYPE7 then
  208. local r = math.random(1,10000)
  209. for k,v in ipairs(skillConfig.otherArgs.skillList) do
  210. if r <= v[1] then
  211. --local config = SkillExcel[v[2]]
  212. local config = GetSkillConfig(v[2])
  213. local targets = TargetMode.getTargets(obj, config.targetMode,fanjiTargets, nil , true)
  214. if #targets > 0 then
  215. realUse(obj, v[2], fanjiTargets)
  216. end
  217. return
  218. else
  219. r = r - v[1]
  220. end
  221. end
  222. else
  223. realUse(obj, skillID,fanjiTargets)
  224. end
  225. end
  226. local hitList = {}
  227. local flagList = {}
  228. function attack(obj, targets, skillConfig)
  229. if not skillConfig.hurtRate[1] then obj.isAllCalcHp = true return end
  230. local totalHurt = 0
  231. local limitHurt = 0
  232. local fenTanHurt = 0
  233. -- 分摊技能操作
  234. if skillConfig.otherArgs and skillConfig.otherArgs.hurtFenTan and skillConfig.otherArgs.hurtFenTan[1] == 1 then
  235. for index = 1, #targets do
  236. local target = targets[index]
  237. if target.hp > 0 then
  238. local hurt, flag = CombatCalc.calcHurt(obj, index, targets, skillConfig)
  239. fenTanHurt = hurt
  240. limitHurt = CombatObj.getValue(obj,RoleDefine.ATK) * skillConfig.otherArgs.hurtFenTan[2]
  241. if fenTanHurt >= limitHurt then
  242. fenTanHurt = limitHurt
  243. end
  244. flagList[index] = flagList[index] or 0
  245. flagList[index] = flag
  246. end
  247. end
  248. end
  249. local len = 0
  250. obj.isAllCalcHp = nil
  251. if #targets == 0 then
  252. obj.isAllCalcHp = true
  253. end
  254. -- local fentanObjList = {}
  255. -- for _, obj in ipairs(targets) do
  256. -- if obj.fentq then
  257. -- fentanObjList[obj.pos] = obj.fentq
  258. -- end
  259. -- end
  260. for index = 1, #targets do
  261. local target = targets[index]
  262. if target.hp > 0 then
  263. BeSkill.beforeHit(obj,target)
  264. -- if fentanObjList[target.pos] then
  265. -- target.fentq = fentanObjList[target.pos]
  266. -- end
  267. local hurt,flag = nil
  268. if fenTanHurt == 0 then
  269. hurt,flag = CombatCalc.calcHurt(obj, index, targets, skillConfig)
  270. target.isShanBi = Util.getBit(flag, CombatDefine.FLAG_SHANBI)
  271. else
  272. hurt = fenTanHurt
  273. flag = flagList[index]
  274. end
  275. -- 闪避不处理目标被动技能
  276. obj.isAllCalcHp = index == #targets
  277. target.attackSkillID = skillConfig.id
  278. local hpValue,srcValue = 0,0
  279. if hurt > 0 then
  280. hpValue,srcValue = CombatObj.updateHp(target, -hurt,nil,true, obj.pos,CombatObj.SKILL_HP_TYPE)
  281. CombatObj.onHpCB(target,hpValue,obj.pos,skillConfig.id)
  282. end
  283. CombatImpl.setSkillHit(target,srcValue,nil,flag,obj,skillConfig.id)
  284. if target.isShanBi ~= 1 then
  285. len = len + 1
  286. hitList[len] = target
  287. BeSkill.afterHit(obj,target)
  288. -- if fentanObjList[target.pos] then
  289. -- target.fentq = fentanObjList[target.pos]
  290. -- end
  291. end
  292. target.attackSkillID = nil
  293. end
  294. end
  295. -- 处理命中列表
  296. for index = 1, #targets do
  297. targets[index] = nil
  298. end
  299. for index = 1, len do
  300. targets[index] = hitList[index]
  301. end
  302. end
  303. CMD = {}
  304. function CMD.hp(obj,skillConfig,skillTargets)
  305. local ret = {}
  306. local args = obj.isPet and obj.args or skillConfig.args
  307. local r = math.random(0,10000)
  308. if args[4] and r > args[4] then
  309. return
  310. end
  311. local calcType = args[1]
  312. local rate = args[2]
  313. local targets = TargetMode.getTargets(obj, args[3], skillTargets)
  314. local targetCnt = #targets
  315. local hp
  316. local limit
  317. if args[5] and args[5] > 0 then
  318. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  319. end
  320. if not obj.isPet and args[6] and args[6] > 0 then
  321. limit = args[6] * CombatObj.getHpMax(obj) / 10000
  322. end
  323. local hpAddRate = CombatObj.getValue(obj,RoleDefine.ZAOCHENG_HP_ADD_RATE) / 10000
  324. for _,target in ipairs(targets) do
  325. if not target.bufferCmd["noHp"] then
  326. hp = calcHp(obj,target,calcType,rate,limit,true)
  327. hp = hp * (1 + hpAddRate)
  328. hp = hp < 0 and 1 or hp
  329. if hp > 0 and obj.isAllCalcHp == true then
  330. if target.side == CombatDefine.DEFEND_SIDE then
  331. hp = CombatImpl.commonArgs.hpLimit or hp
  332. end
  333. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  334. local showHp = hp
  335. if hp > 0 and d < 0 then
  336. showHp = hp * (-1)
  337. end
  338. CombatImpl.setExtraHit(target, showHp, CMD2ID["hp"])
  339. CombatObj.onHpCB(target,d, obj.pos)
  340. end
  341. if hp < 0 then
  342. if target.side == CombatDefine.DEFEND_SIDE then
  343. hp = CombatImpl.commonArgs.hpLimit or hp
  344. end
  345. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  346. if hp > 0 and d < 0 then
  347. hp = hp * (-1)
  348. end
  349. CombatImpl.setExtraHit(target, hp, CMD2ID["hp"])
  350. CombatObj.onHpCB(target,d, obj.pos)
  351. end
  352. ret[#ret+1] = target
  353. end
  354. end
  355. return ret
  356. end
  357. function CMD.speedHp(obj,skillConfig,skillTargets)
  358. if not (skillTargets and skillTargets[1]) then
  359. return
  360. end
  361. local args = obj.isPet and obj.args or skillConfig.args
  362. local r = math.random(0,10000)
  363. if args[4] and r > args[4] then
  364. return
  365. end
  366. local calcType = args[1]
  367. local rate = args[2]
  368. local target = skillTargets[1]
  369. local ret = {}
  370. local hp
  371. local limit
  372. if args[5] then
  373. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  374. end
  375. local hpAddRate = CombatObj.getValue(obj,RoleDefine.ZAOCHENG_HP_ADD_RATE) / 10000
  376. local aSpeed = CombatImpl.getValue(obj,RoleDefine.SPEED)
  377. local bSpeed = CombatImpl.getValue(target,RoleDefine.SPEED)
  378. local checkSpeed = aSpeed - bSpeed
  379. if args[3] == 1 then
  380. checkSpeed = -checkSpeed
  381. end
  382. if checkSpeed > 0 then
  383. local targets = TargetMode.getTargets(obj, args[3], skillTargets)
  384. for _,target in ipairs(targets) do
  385. hp = calcHp(obj,target,calcType,rate,limit,true)
  386. hp = hp * (1 + hpAddRate)
  387. hp = hp < 0 and 1 or hp
  388. if hp ~= 0 and not target.bufferCmd["noHp"] then
  389. if target.side == CombatDefine.DEFEND_SIDE then
  390. hp = CombatImpl.commonArgs.hpLimit or hp
  391. end
  392. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  393. if hp > 0 and d < 0 then
  394. hp = hp * (-1)
  395. end
  396. CombatImpl.setExtraHit(target,hp,CMD2ID["hp"])
  397. CombatObj.onHpCB(target,d, obj.pos)
  398. end
  399. ret[#ret+1] = target
  400. end
  401. end
  402. return ret
  403. end
  404. function CMD.statusHp(obj,skillConfig,skillTargets)
  405. if not skillTargets then
  406. return
  407. end
  408. local isAdd = false
  409. local args = obj.isPet and obj.args or skillConfig.args
  410. for _,v in ipairs(skillTargets) do
  411. if CombatBuff.isStatus(v,args[4]) then
  412. isAdd = true
  413. break
  414. end
  415. end
  416. if not isAdd then return end
  417. local calcType = args[1]
  418. local rate = args[2]
  419. local ret = {}
  420. local hp
  421. local limit
  422. if args[5] then
  423. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  424. end
  425. local targets = TargetMode.getTargets(obj, args[3], skillTargets)
  426. for _,target in ipairs(targets) do
  427. hp = calcHp(obj,target,calcType,rate,limit,true)
  428. hp = hp < 0 and 1 or hp
  429. if hp ~= 0 and not target.bufferCmd["noHp"] then
  430. if target.side == CombatDefine.DEFEND_SIDE then
  431. hp = CombatImpl.commonArgs.hpLimit or hp
  432. end
  433. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  434. if hp > 0 and d < 0 then
  435. hp = hp * (-1)
  436. end
  437. CombatImpl.setExtraHit(target,hp,CMD2ID["hp"])
  438. CombatObj.onHpCB(target,d, obj.pos)
  439. end
  440. ret[#ret+1] = target
  441. end
  442. return ret
  443. end
  444. function CMD.hurt(obj,skillConfig,skillTargets)
  445. local args = obj.isPet and obj.args or skillConfig.args
  446. local r = math.random(0,10000)
  447. if r > args[4] then
  448. return
  449. end
  450. local calcType = args[1]
  451. local rate = args[2]
  452. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  453. local hp
  454. local limit
  455. local ret = {}
  456. if args[5] then
  457. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  458. end
  459. for _,target in ipairs(targets) do
  460. hp = calcHp(obj,target,calcType,rate,limit)
  461. if hp ~= 0 then
  462. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  463. if d ~= 0 then
  464. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurt"])
  465. CombatObj.onHpCB(target,d, obj.pos)
  466. ret[#ret+1] = target
  467. end
  468. end
  469. end
  470. return ret
  471. end
  472. function CMD.behurt(obj,skillConfig,skillTargets)
  473. local args = obj.isPet and obj.args or skillConfig.args
  474. local r = math.random(0,10000)
  475. if r > args[4] then
  476. return
  477. end
  478. local calcType = args[1]
  479. local rate = args[2]
  480. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  481. local hp
  482. local limit
  483. local ret = {}
  484. if args[5] then
  485. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  486. end
  487. for _,target in ipairs(targets) do
  488. if calcType ~= 17 then
  489. hp = calcHp(target,obj,calcType,rate,limit)
  490. else
  491. hp = calcHp(obj, target,calcType,rate,limit)
  492. end
  493. if hp ~= 0 then
  494. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  495. if d ~= 0 then
  496. CombatImpl.setExtraHit(target,-hp,CMD2ID["behurt"])
  497. CombatObj.onHpCB(target,d, obj.pos)
  498. ret[#ret+1] = target
  499. end
  500. end
  501. end
  502. return ret
  503. end
  504. function CMD.hurtwalun(obj,skillConfig,skillTargets)
  505. local args = obj.isPet and obj.args or skillConfig.args
  506. local r = math.random(0,10000)
  507. if r > args[4] then
  508. return
  509. end
  510. local calcType = args[1]
  511. local rate = args[2]
  512. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  513. local hp
  514. local limit
  515. local ret = {}
  516. if args[5] then
  517. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  518. end
  519. for _,target in ipairs(targets) do
  520. hp = calcHp(obj,target,calcType,rate,limit)
  521. if hp ~= 0 then
  522. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  523. if d ~= 0 then
  524. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtwalun"])
  525. CombatObj.onHpCB(target,d, obj.pos)
  526. ret[#ret+1] = target
  527. end
  528. end
  529. end
  530. return ret
  531. end
  532. function CMD.posHurt(obj,skillConfig,skillTargets)
  533. local args = obj.isPet and obj.args or skillConfig.args
  534. local r = math.random(0,10000)
  535. if r > args[4] then
  536. return
  537. end
  538. local calcType = args[1]
  539. local rate = args[2]
  540. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  541. local hp
  542. local limit
  543. local ret = {}
  544. if args[5] then
  545. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  546. end
  547. local posList = args[6]
  548. if posList == nil then
  549. return
  550. end
  551. for _,target in ipairs(targets) do
  552. local bfind = false
  553. for k, v in pairs(posList) do
  554. if v == target.pos then
  555. bfind = true
  556. break
  557. end
  558. end
  559. if bfind then
  560. hp = calcHp(obj,target,calcType,rate,limit, false)
  561. if hp ~= 0 then
  562. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  563. if d ~= 0 then
  564. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurt"])
  565. CombatObj.onHpCB(target,d, obj.pos)
  566. ret[#ret+1] = target
  567. end
  568. end
  569. end
  570. end
  571. return ret
  572. end
  573. function CMD.hurtxia(obj,skillConfig,skillTargets)
  574. local args = obj.isPet and obj.args or skillConfig.args
  575. local r = math.random(0,10000)
  576. if r > args[4] then
  577. return
  578. end
  579. local calcType = args[1]
  580. local rate = args[2]
  581. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  582. local hp
  583. local limit
  584. local ret = {}
  585. if args[5] then
  586. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  587. end
  588. for _,target in ipairs(targets) do
  589. hp = calcHp(obj,target,calcType,rate,limit)
  590. if hp ~= 0 then
  591. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  592. if d ~= 0 then
  593. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtxia"])
  594. CombatObj.onHpCB(target,d, obj.pos)
  595. ret[#ret+1] = target
  596. end
  597. end
  598. end
  599. return ret
  600. end
  601. function CMD.hurtmingli(obj,skillConfig,skillTargets)
  602. local args = obj.isPet and obj.args or skillConfig.args
  603. local r = math.random(0,10000)
  604. if r > args[4] then
  605. return
  606. end
  607. local calcType = args[1]
  608. local rate = args[2]
  609. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  610. local hp
  611. local limit
  612. local ret = {}
  613. if args[5] then
  614. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  615. end
  616. for _,target in ipairs(targets) do
  617. hp = calcHp(obj,target,calcType,rate,limit)
  618. if hp ~= 0 then
  619. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  620. if d ~= 0 then
  621. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtmingli"])
  622. CombatObj.onHpCB(target,d, obj.pos)
  623. ret[#ret+1] = target
  624. end
  625. end
  626. end
  627. return ret
  628. end
  629. function CMD.hurtmingli2(obj,skillConfig,skillTargets)
  630. local args = obj.isPet and obj.args or skillConfig.args
  631. local r = math.random(0,10000)
  632. if r > args[4] then
  633. return
  634. end
  635. local calcType = args[1]
  636. local rate = args[2]
  637. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  638. local hp
  639. local limit
  640. local ret = {}
  641. if args[5] then
  642. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  643. end
  644. for _,target in ipairs(targets) do
  645. hp = calcHp(obj,target,calcType,rate,limit)
  646. if hp ~= 0 then
  647. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  648. if d ~= 0 then
  649. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtmingli2"])
  650. CombatObj.onHpCB(target,d, obj.pos)
  651. ret[#ret+1] = target
  652. end
  653. end
  654. end
  655. return ret
  656. end
  657. function CMD.hurtguangci(obj,skillConfig,skillTargets)
  658. local args = obj.isPet and obj.args or skillConfig.args
  659. local r = math.random(0,10000)
  660. if r > args[4] then
  661. return
  662. end
  663. local calcType = args[1]
  664. local rate = args[2]
  665. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  666. local hp
  667. local limit
  668. local ret = {}
  669. if args[5] then
  670. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  671. end
  672. for _,target in ipairs(targets) do
  673. hp = calcHp(obj,target,calcType,rate,limit)
  674. if hp ~= 0 then
  675. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  676. if d ~= 0 then
  677. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtguangci"])
  678. CombatObj.onHpCB(target,d, obj.pos)
  679. ret[#ret+1] = target
  680. end
  681. end
  682. end
  683. return ret
  684. end
  685. function CMD.jobHurt(obj,skillConfig,skillTargets)
  686. local args = obj.isPet and obj.args or skillConfig.args
  687. local calcType = args[1]
  688. local rate = args[2]
  689. local r = math.random(0,10000)
  690. if r > args[3] then
  691. return
  692. end
  693. local job = args[4]
  694. local hp
  695. local limit
  696. if args[5] then
  697. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  698. end
  699. local ret = {}
  700. for _,target in ipairs(skillTargets) do
  701. if target.job == job then
  702. hp = calcHp(obj,target,calcType,rate,limit)
  703. if hp and hp ~= 0 then
  704. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  705. if d ~= 0 then
  706. CombatImpl.setExtraHit(target,-hp,CMD2ID["jobHurt"])
  707. CombatObj.onHpCB(target,d, obj.pos)
  708. ret[#ret+1] = target
  709. end
  710. end
  711. end
  712. end
  713. return ret
  714. end
  715. function CMD.statusHurt(obj,skillConfig,skillTargets)
  716. local args = obj.isPet and obj.args or skillConfig.args
  717. local calcType = args[1]
  718. local rate = args[2]
  719. local r = math.random(0,10000)
  720. if r > args[3] then
  721. return
  722. end
  723. local status = args[4]
  724. local hp
  725. local limit
  726. if args[5] then
  727. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  728. end
  729. local ret = {}
  730. for _,target in ipairs(skillTargets) do
  731. if CombatBuff.isStatus(target, status) then
  732. hp = calcHp(obj,target,calcType,rate,limit)
  733. if hp and hp ~= 0 then
  734. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  735. if d ~= 0 then
  736. CombatImpl.setExtraHit(target,-hp,CMD2ID["jobHurt"])
  737. CombatObj.onHpCB(target,d, obj.pos)
  738. ret[#ret+1] = target
  739. end
  740. end
  741. end
  742. end
  743. return ret
  744. end
  745. function CMD.hpHurt(obj,skillConfig,skillTargets)
  746. local args = obj.isPet and obj.args or skillConfig.args
  747. local calcType = args[1]
  748. local rate = args[2]
  749. local hpRate = args[3]/10000
  750. local ret = {}
  751. for _,target in ipairs(skillTargets) do
  752. local hpLimit = CombatObj.getHpMax(target) * hpRate
  753. if target.hp >= hpLimit then
  754. hp = calcHp(obj,target,calcType,rate)
  755. if hp and hp ~= 0 then
  756. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  757. if d ~= 0 then
  758. CombatImpl.setExtraHit(target,-hp,CMD2ID["hpHurt"])
  759. CombatObj.onHpCB(target,d, obj.pos)
  760. ret[#ret+1] = target
  761. end
  762. end
  763. end
  764. end
  765. return ret
  766. end
  767. function CMD.fanji(obj,skillConfig,skillTargets)
  768. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  769. if CombatBuff.isStatus(obj,{"xuanyun","shihua","bingdong"}) then return end
  770. if obj.side == skillTargets[1].side then
  771. return
  772. end
  773. if obj.hp > 0 then
  774. local r = math.random(0,10000)
  775. if r < skillConfig.args[2] then
  776. CombatImpl.fanjiList[#CombatImpl.fanjiList + 1] = {obj,skillConfig.args[1],skillTargets}
  777. end
  778. end
  779. end
  780. function CMD.qingsuan(obj,skillConfig,skillTargets)
  781. if obj.isPet then return {} end
  782. local args = skillConfig.args
  783. local r = math.random(0,10000)
  784. if r > args[3] then
  785. return
  786. end
  787. local rate = args[1]
  788. local limit
  789. if args[4] then
  790. limit = args[4] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  791. end
  792. local targets = TargetMode.getTargets(obj, args[2],skillTargets)
  793. local ret = {}
  794. for _,target in ipairs(targets) do
  795. local baseValue = CombatBuff.qingsuan(target)
  796. if baseValue > 0 then
  797. local hurt = baseValue * rate / 10000
  798. if limit and hurt > limit then
  799. hurt = limit
  800. end
  801. local d = CombatObj.updateHp(target,-hurt,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  802. CombatImpl.setExtraHit(target,-hurt,CMD2ID["qingsuan"])
  803. CombatObj.onHpCB(target,d, obj.pos)
  804. ret[#ret+1] = target
  805. end
  806. end
  807. return ret
  808. end
  809. function CMD.jiekong(obj,skillConfig,skillTargets)
  810. if obj.isPet then return {} end
  811. local args = skillConfig.args
  812. local r = math.random(0,10000)
  813. if r > args[2] then
  814. return
  815. end
  816. local targets = TargetMode.getTargets(obj, args[1],skillTargets)
  817. local ret = {}
  818. for _,target in ipairs(targets) do
  819. CombatBuff.jiekong(target)
  820. ret[#ret+1] = target
  821. end
  822. return ret
  823. end
  824. function CMD.groupcmd(obj,skillConfig,skillTargets)
  825. if obj.isPet then return {} end
  826. for k,v in ipairs(skillConfig.args) do
  827. local cmd = v[1]
  828. local conf = {args = v[2]}
  829. if CMD[cmd] then
  830. CMD[cmd](obj,conf,skillTargets)
  831. end
  832. end
  833. return {}
  834. end
  835. function CMD.randcmd(obj,skillConfig,skillTargets)
  836. if obj.isPet then return {} end
  837. local total = 0
  838. for k,v in ipairs(skillConfig.args) do
  839. total = total + v[3]
  840. end
  841. local r = math.random(0,total)
  842. for k,v in ipairs(skillConfig.args) do
  843. if r <= v[3] then
  844. local cmd = v[1]
  845. local conf = {args = v[2]}
  846. if CMD[cmd] then
  847. CMD[cmd](obj,conf,skillTargets)
  848. end
  849. break
  850. else
  851. r = r - v[1]
  852. end
  853. end
  854. return {}
  855. end
  856. function CMD.qusan(obj,skillConfig,skillTargets)
  857. if obj.isPet then return {} end
  858. local args = skillConfig.args
  859. local r = math.random(0,10000)
  860. if r > args[3] then
  861. return
  862. end
  863. local qusanType = args[1]
  864. local calcType = args[5] and args[5][1]
  865. local rate = args[5] and args[5][2]
  866. local buffers = args[8] and args[8][1]
  867. local targets = TargetMode.getTargets(obj, args[2],skillTargets)
  868. local ret = {}
  869. if args[7] then
  870. limit = args[7] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  871. end
  872. for _,target in ipairs(targets) do
  873. local cnt = CombatBuff.qusan(target, qusanType,args[4])
  874. if limit then
  875. limit = limit * cnt
  876. end
  877. if buffers and cnt > 0 then
  878. local targets = TargetMode.getTargets(obj, args[8][2],skillTargets)
  879. CombatBuff.qusanAddBuff(obj, targets, buffers)
  880. end
  881. ret[#ret+1] = target
  882. if calcType and rate and cnt > 0 then
  883. local hp = calcHp(obj,target,calcType,rate * cnt, limit, nil, nil, args[6])
  884. if hp ~= 0 then
  885. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  886. if d ~= 0 then
  887. CombatImpl.setExtraHit(target,-hp,CMD2ID["qusan"])
  888. CombatObj.onHpCB(target,d, obj.pos)
  889. end
  890. end
  891. end
  892. end
  893. return ret
  894. end
  895. function CMD.hurtwalun2(obj,skillConfig,skillTargets)
  896. local args = obj.isPet and obj.args or skillConfig.args
  897. local r = math.random(0,10000)
  898. if r > args[4] then
  899. return
  900. end
  901. local calcType = args[1]
  902. local rate = args[2]
  903. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  904. local hp
  905. local limit
  906. local ret = {}
  907. if args[5] then
  908. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  909. end
  910. for _,target in ipairs(targets) do
  911. hp = calcHp(obj,target,calcType,rate,limit)
  912. if hp ~= 0 then
  913. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  914. if d ~= 0 then
  915. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtwalun2"])
  916. CombatObj.onHpCB(target,d, obj.pos)
  917. ret[#ret+1] = target
  918. end
  919. end
  920. end
  921. return ret
  922. end
  923. function CMD.hurtxia2(obj,skillConfig,skillTargets)
  924. local args = obj.isPet and obj.args or skillConfig.args
  925. local r = math.random(0,10000)
  926. if r > args[4] then
  927. return
  928. end
  929. local calcType = args[1]
  930. local rate = args[2]
  931. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  932. local hp
  933. local limit
  934. local ret = {}
  935. if args[5] then
  936. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  937. end
  938. for _,target in ipairs(targets) do
  939. hp = calcHp(obj,target,calcType,rate,limit)
  940. if hp ~= 0 then
  941. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  942. if d ~= 0 then
  943. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtxia2"])
  944. CombatObj.onHpCB(target,d, obj.pos)
  945. ret[#ret+1] = target
  946. end
  947. end
  948. end
  949. return ret
  950. end
  951. function CMD.hurtxia3(obj,skillConfig,skillTargets)
  952. local args = obj.isPet and obj.args or skillConfig.args
  953. local r = math.random(0,10000)
  954. if r > args[4] then
  955. return
  956. end
  957. local calcType = args[1]
  958. local rate = args[2]
  959. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  960. local hp
  961. local limit
  962. local ret = {}
  963. if args[5] then
  964. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  965. end
  966. for _,target in ipairs(targets) do
  967. hp = calcHp(obj,target,calcType,rate,limit)
  968. if hp ~= 0 then
  969. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  970. if d ~= 0 then
  971. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtxia3"])
  972. CombatObj.onHpCB(target,d, obj.pos)
  973. ret[#ret+1] = target
  974. end
  975. end
  976. end
  977. return ret
  978. end
  979. NO_SKILL_CHECK_COMBO_LIST = {
  980. ["hp"] = 1,
  981. ["revive"] = 1,
  982. ["baohu"] = 1,
  983. }
  984. function skillIsHpOrRevive(obj, argSkillID)
  985. --local argSkillConf = SkillExcel[argSkillID]
  986. local argSkillConf = GetSkillConfig(argSkillID)
  987. if not argSkillConf then return end
  988. -- 带有伤害
  989. if argSkillConf.hurtRate[1] then return end
  990. if argSkillConf.continuous and argSkillConf.continuous == 1 then return true end
  991. if NO_SKILL_CHECK_COMBO_LIST[argSkillConf.cmd] then
  992. return true
  993. end
  994. local bRet = false
  995. if argSkillConf.cmd == "groupcmd" then
  996. for k,v in ipairs(argSkillConf.args) do
  997. local cmd = v[1]
  998. if cmd == "hurt" then return end
  999. if NO_SKILL_CHECK_COMBO_LIST[cmd] then
  1000. bRet = true
  1001. end
  1002. end
  1003. end
  1004. -- 技能包
  1005. if argSkillConf.type == CombatDefine.SKILL_TYPE5 or
  1006. argSkillConf.type == CombatDefine.SKILL_TYPE6 or
  1007. argSkillConf.type == CombatDefine.SKILL_TYPE7 then
  1008. for k,v in ipairs(argSkillConf.otherArgs.skillList) do
  1009. local config = SkillExcel[v]
  1010. -- 带有伤害
  1011. if config and config.hurtRate[1] then return end
  1012. if config then
  1013. if NO_SKILL_CHECK_COMBO_LIST[config.cmd] or config.continuous == 1 then
  1014. bRet = true
  1015. end
  1016. for k,v in ipairs(config.buffers) do
  1017. --local bufConfig = BufferExcel.buffer[v[1]]
  1018. local bufConfig = CombatBuff.GetBuffConfig(v[1])
  1019. -- 带有伤害
  1020. if bufConfig and NO_SKILL_CHECK_COMBO_LIST[bufConfig.cmd] then
  1021. bRet = true
  1022. end
  1023. end
  1024. end
  1025. end
  1026. for k,v in ipairs(argSkillConf.buffers) do
  1027. --local bufConfig = BufferExcel[v[1]]
  1028. local bufConfig = CombatBuff.GetBuffConfig(v[1])
  1029. -- 带有伤害
  1030. if bufConfig and NO_SKILL_CHECK_COMBO_LIST[bufConfig.cmd] then
  1031. bRet = true
  1032. end
  1033. end
  1034. end
  1035. return bRet
  1036. end
  1037. function CMD.combo(obj,skillConfig,skillTargets)
  1038. -- 二次元 屏蔽 治疗 复活的连击
  1039. if ProjectLogic.isSsecy() then
  1040. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1041. if skillIsHpOrRevive(obj, argSkillID) then
  1042. return
  1043. end
  1044. if skillIsHpOrRevive(obj, skillConfig.id) then
  1045. return
  1046. end
  1047. end
  1048. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1049. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1050. local r = math.random(0,10000)
  1051. if r < skillConfig.args[1] then
  1052. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],skillConfig.args[4] or 1, skillConfig.args[5]}
  1053. return true
  1054. end
  1055. end
  1056. --
  1057. function CMD.comboFight(obj,skillConfig,skillTargets)
  1058. -- 二次元 屏蔽 治疗 复活的连击
  1059. if ProjectLogic.isSsecy() then
  1060. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1061. if skillIsHpOrRevive(obj, argSkillID) then
  1062. return
  1063. end
  1064. if skillIsHpOrRevive(obj, skillConfig.id) then
  1065. return
  1066. end
  1067. end
  1068. if CombatImpl.isFanji then return end
  1069. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1070. local r = math.random(0,10000)
  1071. if r < skillConfig.args[1] then
  1072. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],skillConfig.args[4] or 1, skillConfig.args[5]}
  1073. return true
  1074. end
  1075. end
  1076. function CMD.combo1(obj,skillConfig,skillTargets)
  1077. -- 二次元 屏蔽 治疗 复活的连击
  1078. if ProjectLogic.isSsecy() then
  1079. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1080. if skillIsHpOrRevive(obj, skillConfig) then
  1081. return
  1082. end
  1083. if skillIsHpOrRevive(obj, skillConfig.id) then
  1084. return
  1085. end
  1086. end
  1087. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1088. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1089. local r = math.random(0,10000)
  1090. if r < skillConfig.args[1] then
  1091. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],2}
  1092. return true
  1093. end
  1094. end
  1095. function CMD.combo2(obj,skillConfig,skillTargets)
  1096. -- 二次元 屏蔽 治疗 复活的连击
  1097. if ProjectLogic.isSsecy() then
  1098. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1099. if skillIsHpOrRevive(obj, argSkillID) then
  1100. return
  1101. end
  1102. if skillIsHpOrRevive(obj, skillConfig.id) then
  1103. return
  1104. end
  1105. end
  1106. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1107. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1108. local r = math.random(0,10000)
  1109. if r < skillConfig.args[1] then
  1110. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],3}
  1111. return true
  1112. end
  1113. end
  1114. function CMD.comboNormal(obj, skillConfig, skillTargets)
  1115. -- 二次元 屏蔽 治疗 复活的连击
  1116. if ProjectLogic.isSsecy() then
  1117. local argSkillID = skillConfig.args[3] or CombatImpl.getNormalSkill(obj)
  1118. if skillIsHpOrRevive(obj, argSkillID) then
  1119. return
  1120. end
  1121. if skillIsHpOrRevive(obj, skillConfig.id) then
  1122. return
  1123. end
  1124. end
  1125. if CombatImpl.comboType > 0 then return end
  1126. if CombatImpl.isFanji then
  1127. if GroupSkillCnt > 2 then return end
  1128. else
  1129. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1130. end
  1131. local r = math.random(0,10000)
  1132. if r < skillConfig.args[1] then
  1133. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 2, skillConfig.args[2], skillConfig.args[3],skillConfig.args[4] or 1}
  1134. end
  1135. end
  1136. function CMD.attrcomboAgain(obj, skillConfig, skillTargets)
  1137. local tComboCof = nil
  1138. for _, v in ipairs(skillConfig.args) do
  1139. if v[1] == 2 then
  1140. tComboCof = v
  1141. break
  1142. end
  1143. end
  1144. if not tComboCof then
  1145. print("[CMD.attrcomboAgain] 不存在连击配置")
  1146. return
  1147. end
  1148. --table.print_lua_table(tComboCof)
  1149. -- 二次元 屏蔽 治疗 复活的连击
  1150. if ProjectLogic.isSsecy() then
  1151. local argSkillID = tComboCof[3] or CombatImpl.getSkillID(obj)
  1152. if skillIsHpOrRevive(obj, argSkillID) then
  1153. return
  1154. end
  1155. if skillIsHpOrRevive(obj, skillConfig.id) then
  1156. return
  1157. end
  1158. end
  1159. local nSkillID = tComboCof[3] or CombatImpl.getSkillID(obj)
  1160. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1161. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1162. local r = math.random(0,10000)
  1163. --print("[CMD.attrcomboAgain] nSkillID = "..nSkillID)
  1164. if r < tComboCof[2] then
  1165. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, tComboCof[3], nSkillID, tComboCof[5] or 1, tComboCof[6]}
  1166. return true
  1167. end
  1168. end
  1169. function CMD.baohu(obj,skillConfig,skillTargets)
  1170. local d = CombatObj.updateHp(obj,obj.baohuHurt,nil,nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1171. if d ~= 0 then
  1172. local attrs = {}
  1173. attrs[RoleDefine.BAOHU_COMBAT] = skillTargets[1].pos
  1174. CombatImpl.setExtraHit(obj,d,CMD2ID["baohu"],attrs)
  1175. CombatObj.onHpCB(obj,d, skillTargets[1].pos)
  1176. end
  1177. end
  1178. function CMD.yinbaoZuzhou(obj,skillConfig,skillTargets)
  1179. CombatBuff.yinbaoZuzhou(obj, skillTargets, skillConfig)
  1180. end
  1181. --指定普攻目标模式
  1182. function CMD.normalTarget(obj,skillConfig)
  1183. obj.normalTarget = {status = {}}
  1184. if skillConfig.args.status then
  1185. for k,v in ipairs(skillConfig.args.status) do
  1186. obj.normalTarget.status[k] = v
  1187. end
  1188. end
  1189. end
  1190. --诅咒附加伤害
  1191. function CMD.zuzhouHurt(obj, skillConfig, skillTargets)
  1192. if not obj.args then return end
  1193. local confArgs = skillConfig.args
  1194. local targets = TargetMode.getTargets(obj, confArgs[1], skillTargets)
  1195. local zuzhouHurt = obj.args * confArgs[2] / 10000
  1196. for _,target in ipairs(targets) do
  1197. if zuzhouHurt ~= 0 then
  1198. local d = CombatObj.updateHp(target,-zuzhouHurt,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  1199. if d ~= 0 then
  1200. CombatImpl.setExtraHit(target,-zuzhouHurt,CMD2ID["zuzhouHurt"])
  1201. CombatObj.onHpCB(target,d, obj.pos)
  1202. end
  1203. end
  1204. end
  1205. obj.args = nil
  1206. end
  1207. function CMD.dnexhurt(obj,skillConfig,skillTargets)
  1208. local args = obj.isPet and obj.args or skillConfig.args
  1209. local r = math.random(0,10000)
  1210. if r > args[4] then
  1211. return
  1212. end
  1213. local calcType = args[1]
  1214. local rate = args[2]
  1215. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  1216. local hp
  1217. local limit
  1218. local ret = {}
  1219. if args[5] then
  1220. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK)
  1221. end
  1222. for _,target in ipairs(targets) do
  1223. hp = calcHp(obj,target,calcType,rate,limit)
  1224. if hp ~= 0 then
  1225. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  1226. if d ~= 0 then
  1227. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurt"])
  1228. CombatObj.onHpCB(target,d, obj.pos)
  1229. ret[#ret+1] = target
  1230. end
  1231. end
  1232. end
  1233. return ret
  1234. end
  1235. --拥有指定buff后的额外效果
  1236. function CMD.targetBuffExtraEffect(obj,skillConfig,skillTargets)
  1237. local args = skillConfig.args
  1238. if not args then
  1239. return
  1240. end
  1241. local targetBuffCmd = args[1]
  1242. local targetBuffCnt = args[2]
  1243. if not targetBuffCmd or not targetBuffCnt then
  1244. return
  1245. end
  1246. local nowTargetBuffCnt = CombatBuff.getBuffCnt(obj, targetBuffCmd)
  1247. if nowTargetBuffCnt < targetBuffCnt then
  1248. return
  1249. end
  1250. local targetMode = args[3]
  1251. local targets = TargetMode.getTargets(obj, targetMode, skillTargets)
  1252. local hurt, limitVale
  1253. local calcType, rate = args[4], args[5]
  1254. local maxNum = args[6] or 1
  1255. local nowNum = math.floor(nowTargetBuffCnt / targetBuffCnt)
  1256. if nowNum < maxNum then
  1257. maxNum = nowNum
  1258. end
  1259. local limitAttrType = args[7]
  1260. local limitAttrRate = args[8]
  1261. if limitAttrType and limitAttrRate then
  1262. limitVale = limitAttrRate * CombatObj.getValue(obj, limitAttrType)
  1263. end
  1264. table.shuffle(targets)
  1265. for idx, target in ipairs(targets) do
  1266. if idx > maxNum then
  1267. break
  1268. end
  1269. hurt = calcHp(obj, target, calcType, rate, limitVale)
  1270. if hurt ~= 0 then
  1271. local d = CombatObj.updateHp(target,-hurt,nil,true, obj.pos,CombatObj.SKILL_HP_TYPE)
  1272. if d ~= 0 then
  1273. CombatImpl.setExtraHit(target,-hurt,CMD2ID["hurt"])
  1274. CombatObj.onHpCB(target,d, obj.pos)
  1275. end
  1276. end
  1277. end
  1278. CombatBuff.DelBuffByCmd(obj, targetBuffCmd, nowTargetBuffCnt)
  1279. end
  1280. --debuff 和 buff 数量差的额外伤害
  1281. function CMD.buffDiffHurt(obj,skillConfig,skillTargets)
  1282. local args = skillConfig.args
  1283. if not args then
  1284. return
  1285. end
  1286. local buffType1 = args[1] --buff类型1, 对应配置表buff中qusan分页中的type
  1287. local buffType2 = args[2] --buff类型2, 对应配置表buff中qusan分页中的type
  1288. local targetMode = args[3]
  1289. local calcType, rate = args[4], args[5]
  1290. local limitAttrType, limitAttrMul = args[6], args[7]
  1291. local maxHurt = CombatObj.getValue(obj, limitAttrType) * limitAttrMul
  1292. local targets = TargetMode.getTargets(obj, targetMode, skillTargets)
  1293. for _, targetObj in ipairs(targets) do
  1294. local buffCnt1 = CombatBuff.getCombatBufferCnt(targetObj, buffType1)
  1295. local buffCnt2 = CombatBuff.getCombatBufferCnt(targetObj, buffType2)
  1296. if buffCnt1 > buffCnt2 then
  1297. local hurt = calcHp(obj, targetObj, calcType, rate)
  1298. hurt = hurt * (buffCnt1 - buffCnt2)
  1299. if hurt > maxHurt then
  1300. hurt = maxHurt
  1301. end
  1302. local d = CombatObj.updateHp(targetObj, -hurt, nil, true, obj.pos, CombatObj.EXTRA_HP_TYPE)
  1303. if d ~= 0 then
  1304. CombatImpl.setExtraHit(targetObj, -hurt, CMD2ID["hurt"])
  1305. CombatObj.onHpCB(targetObj, d, obj.pos)
  1306. end
  1307. end
  1308. end
  1309. end
  1310. -- 与其中一个符合条件的队友交换血量, 交换成功后,恢复自身一定血量
  1311. function CMD.exchangeHP(obj,skillConfig,skillTargets)
  1312. local args = skillConfig.args
  1313. if not args then
  1314. return
  1315. end
  1316. local targetMode = args[3]
  1317. local targets = TargetMode.getTargets(obj, targetMode, skillTargets)
  1318. local targetObj = targets[1]
  1319. if targetObj then
  1320. -- 不能是自己
  1321. if targetObj.pos == obj.pos then
  1322. return
  1323. end
  1324. -- 不能满血
  1325. local attrID = targetMode[4] or RoleDefine.HP -- 默认是HP
  1326. local targetObjSubRate = CombatObj.getValue(targetObj, attrID)
  1327. if targetObjSubRate >= 10000 then
  1328. return
  1329. end
  1330. local targetHP = targetObj.hp
  1331. local attackerHp = obj.hp
  1332. local subHP = attackerHp - targetHP
  1333. -- 施放者血量不能最低
  1334. if subHP > 0 then
  1335. -- 给目标加血量差值
  1336. local d = CombatObj.updateHp(targetObj, subHP, nil, true, obj.pos, CombatObj.EXTRA_HP_TYPE)
  1337. if d ~= 0 then
  1338. CombatImpl.setExtraHit(targetObj, subHP, CMD2ID["hp"])
  1339. CombatObj.onHpCB(targetObj, d, obj.pos)
  1340. end
  1341. -- 给施放者扣血量差值
  1342. d = CombatObj.updateHp(obj, -subHP, nil, true, targetObj.pos, CombatObj.EXTRA_HP_TYPE)
  1343. if d ~= 0 then
  1344. CombatImpl.setExtraHit(obj, -subHP, CMD2ID["hp"])
  1345. CombatObj.onHpCB(obj, d, targetObj.pos)
  1346. end
  1347. -- 给施放者恢复一定血量
  1348. local calcType = args[1]
  1349. local rate = args[2]
  1350. local hp = calcHp(obj,targetObj, calcType, rate, nil, true)
  1351. d = CombatObj.updateHp(obj,hp, nil, true, obj.pos, CombatObj.EXTRA_HP_TYPE)
  1352. local showHp = hp
  1353. if hp > 0 and d < 0 then
  1354. showHp = hp * (-1)
  1355. end
  1356. CombatImpl.setExtraHit(obj, showHp, CMD2ID["hp"])
  1357. CombatObj.onHpCB(obj,d, obj.pos)
  1358. end
  1359. end
  1360. end