Skill.lua 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626
  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.shixueHP(obj,skillConfig,skillTargets, hitObj)
  358. local ret = {}
  359. local args = obj.isPet and obj.args or skillConfig.args
  360. local r = math.random(0,10000)
  361. if args[4] and r > args[4] then
  362. return
  363. end
  364. local calcType = args[1]
  365. local rate = args[2]
  366. local targets = TargetMode.getTargets(obj, args[3], skillTargets)
  367. local hp
  368. local limit
  369. if args[5] and args[5] > 0 then
  370. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  371. end
  372. if not obj.isPet and args[6] and args[6] > 0 then
  373. limit = args[6] * CombatObj.getHpMax(obj) / 10000
  374. end
  375. local targetBuffInfo
  376. local res, _, buffIdx = CombatBuff.isStatus(obj, {"noShixue"})
  377. local bl = true
  378. if res and buffIdx then
  379. local objBuffList = CombatBuff.getBuffer(obj)
  380. targetBuffInfo = objBuffList[buffIdx]
  381. if hitObj and targetBuffInfo and targetBuffInfo.attackPos == hitObj.pos then
  382. bl = false
  383. end
  384. end
  385. local hpAddRate = CombatObj.getValue(obj,RoleDefine.ZAOCHENG_HP_ADD_RATE) / 10000
  386. for _,target in ipairs(targets) do
  387. if not target.bufferCmd["noHp"] and bl then
  388. hp = calcHp(obj,target,calcType,rate,limit,true)
  389. hp = hp * (1 + hpAddRate)
  390. hp = hp < 0 and 1 or hp
  391. if hp > 0 and obj.isAllCalcHp == true then
  392. if target.side == CombatDefine.DEFEND_SIDE then
  393. hp = CombatImpl.commonArgs.hpLimit or hp
  394. end
  395. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  396. local showHp = hp
  397. if hp > 0 and d < 0 then
  398. showHp = hp * (-1)
  399. end
  400. CombatImpl.setExtraHit(target, showHp, CMD2ID["hp"])
  401. CombatObj.onHpCB(target,d, obj.pos)
  402. end
  403. if hp < 0 then
  404. if target.side == CombatDefine.DEFEND_SIDE then
  405. hp = CombatImpl.commonArgs.hpLimit or hp
  406. end
  407. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  408. if hp > 0 and d < 0 then
  409. hp = hp * (-1)
  410. end
  411. CombatImpl.setExtraHit(target, hp, CMD2ID["hp"])
  412. CombatObj.onHpCB(target,d, obj.pos)
  413. end
  414. ret[#ret+1] = target
  415. end
  416. end
  417. return ret
  418. end
  419. function CMD.speedHp(obj,skillConfig,skillTargets)
  420. if not (skillTargets and skillTargets[1]) then
  421. return
  422. end
  423. local args = obj.isPet and obj.args or skillConfig.args
  424. local r = math.random(0,10000)
  425. if args[4] and r > args[4] then
  426. return
  427. end
  428. local calcType = args[1]
  429. local rate = args[2]
  430. local target = skillTargets[1]
  431. local ret = {}
  432. local hp
  433. local limit
  434. if args[5] then
  435. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  436. end
  437. local hpAddRate = CombatObj.getValue(obj,RoleDefine.ZAOCHENG_HP_ADD_RATE) / 10000
  438. local aSpeed = CombatImpl.getValue(obj,RoleDefine.SPEED)
  439. local bSpeed = CombatImpl.getValue(target,RoleDefine.SPEED)
  440. local checkSpeed = aSpeed - bSpeed
  441. if args[3] == 1 then
  442. checkSpeed = -checkSpeed
  443. end
  444. if checkSpeed > 0 then
  445. local targets = TargetMode.getTargets(obj, args[3], skillTargets)
  446. for _,target in ipairs(targets) do
  447. hp = calcHp(obj,target,calcType,rate,limit,true)
  448. hp = hp * (1 + hpAddRate)
  449. hp = hp < 0 and 1 or hp
  450. if hp ~= 0 and not target.bufferCmd["noHp"] then
  451. if target.side == CombatDefine.DEFEND_SIDE then
  452. hp = CombatImpl.commonArgs.hpLimit or hp
  453. end
  454. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  455. if hp > 0 and d < 0 then
  456. hp = hp * (-1)
  457. end
  458. CombatImpl.setExtraHit(target,hp,CMD2ID["hp"])
  459. CombatObj.onHpCB(target,d, obj.pos)
  460. end
  461. ret[#ret+1] = target
  462. end
  463. end
  464. return ret
  465. end
  466. function CMD.statusHp(obj,skillConfig,skillTargets)
  467. if not skillTargets then
  468. return
  469. end
  470. local isAdd = false
  471. local args = obj.isPet and obj.args or skillConfig.args
  472. for _,v in ipairs(skillTargets) do
  473. if CombatBuff.isStatus(v,args[4]) then
  474. isAdd = true
  475. break
  476. end
  477. end
  478. if not isAdd then return end
  479. local calcType = args[1]
  480. local rate = args[2]
  481. local ret = {}
  482. local hp
  483. local limit
  484. if args[5] then
  485. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  486. end
  487. local targets = TargetMode.getTargets(obj, args[3], skillTargets)
  488. for _,target in ipairs(targets) do
  489. hp = calcHp(obj,target,calcType,rate,limit,true)
  490. hp = hp < 0 and 1 or hp
  491. if hp ~= 0 and not target.bufferCmd["noHp"] then
  492. if target.side == CombatDefine.DEFEND_SIDE then
  493. hp = CombatImpl.commonArgs.hpLimit or hp
  494. end
  495. local d = CombatObj.updateHp(target,hp,nil,true,obj.pos,CombatObj.EXTRA_HP_TYPE)
  496. if hp > 0 and d < 0 then
  497. hp = hp * (-1)
  498. end
  499. CombatImpl.setExtraHit(target,hp,CMD2ID["hp"])
  500. CombatObj.onHpCB(target,d, obj.pos)
  501. end
  502. ret[#ret+1] = target
  503. end
  504. return ret
  505. end
  506. function CMD.hurt(obj,skillConfig,skillTargets)
  507. local args = obj.isPet and obj.args or skillConfig.args
  508. local r = math.random(0,10000)
  509. if r > args[4] then
  510. return
  511. end
  512. local calcType = args[1]
  513. local rate = args[2]
  514. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  515. local hp
  516. local limit
  517. local ret = {}
  518. if args[5] then
  519. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  520. end
  521. for _,target in ipairs(targets) do
  522. hp = calcHp(obj,target,calcType,rate,limit)
  523. if hp ~= 0 then
  524. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  525. if d ~= 0 then
  526. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurt"])
  527. CombatObj.onHpCB(target,d, obj.pos)
  528. ret[#ret+1] = target
  529. end
  530. end
  531. end
  532. return ret
  533. end
  534. function CMD.behurt(obj,skillConfig,skillTargets)
  535. local args = obj.isPet and obj.args or skillConfig.args
  536. local r = math.random(0,10000)
  537. if r > args[4] then
  538. return
  539. end
  540. local calcType = args[1]
  541. local rate = args[2]
  542. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  543. local hp
  544. local limit
  545. local ret = {}
  546. if args[5] then
  547. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  548. end
  549. for _,target in ipairs(targets) do
  550. if calcType ~= 17 then
  551. hp = calcHp(target,obj,calcType,rate,limit)
  552. else
  553. hp = calcHp(obj, target,calcType,rate,limit)
  554. end
  555. if hp ~= 0 then
  556. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  557. if d ~= 0 then
  558. CombatImpl.setExtraHit(target,-hp,CMD2ID["behurt"])
  559. CombatObj.onHpCB(target,d, obj.pos)
  560. ret[#ret+1] = target
  561. end
  562. end
  563. end
  564. return ret
  565. end
  566. function CMD.hurtwalun(obj,skillConfig,skillTargets)
  567. local args = obj.isPet and obj.args or skillConfig.args
  568. local r = math.random(0,10000)
  569. if r > args[4] then
  570. return
  571. end
  572. local calcType = args[1]
  573. local rate = args[2]
  574. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  575. local hp
  576. local limit
  577. local ret = {}
  578. if args[5] then
  579. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  580. end
  581. for _,target in ipairs(targets) do
  582. hp = calcHp(obj,target,calcType,rate,limit)
  583. if hp ~= 0 then
  584. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  585. if d ~= 0 then
  586. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtwalun"])
  587. CombatObj.onHpCB(target,d, obj.pos)
  588. ret[#ret+1] = target
  589. end
  590. end
  591. end
  592. return ret
  593. end
  594. function CMD.posHurt(obj,skillConfig,skillTargets)
  595. local args = obj.isPet and obj.args or skillConfig.args
  596. local r = math.random(0,10000)
  597. if r > args[4] then
  598. return
  599. end
  600. local calcType = args[1]
  601. local rate = args[2]
  602. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  603. local hp
  604. local limit
  605. local ret = {}
  606. if args[5] then
  607. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  608. end
  609. local posList = args[6]
  610. if posList == nil then
  611. return
  612. end
  613. for _,target in ipairs(targets) do
  614. local bfind = false
  615. for k, v in pairs(posList) do
  616. if v == target.pos then
  617. bfind = true
  618. break
  619. end
  620. end
  621. if bfind then
  622. hp = calcHp(obj,target,calcType,rate,limit, false)
  623. if hp ~= 0 then
  624. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  625. if d ~= 0 then
  626. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurt"])
  627. CombatObj.onHpCB(target,d, obj.pos)
  628. ret[#ret+1] = target
  629. end
  630. end
  631. end
  632. end
  633. return ret
  634. end
  635. function CMD.hurtxia(obj,skillConfig,skillTargets)
  636. local args = obj.isPet and obj.args or skillConfig.args
  637. local r = math.random(0,10000)
  638. if r > args[4] then
  639. return
  640. end
  641. local calcType = args[1]
  642. local rate = args[2]
  643. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  644. local hp
  645. local limit
  646. local ret = {}
  647. if args[5] then
  648. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  649. end
  650. for _,target in ipairs(targets) do
  651. hp = calcHp(obj,target,calcType,rate,limit)
  652. if hp ~= 0 then
  653. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  654. if d ~= 0 then
  655. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtxia"])
  656. CombatObj.onHpCB(target,d, obj.pos)
  657. ret[#ret+1] = target
  658. end
  659. end
  660. end
  661. return ret
  662. end
  663. function CMD.hurtmingli(obj,skillConfig,skillTargets)
  664. local args = obj.isPet and obj.args or skillConfig.args
  665. local r = math.random(0,10000)
  666. if r > args[4] then
  667. return
  668. end
  669. local calcType = args[1]
  670. local rate = args[2]
  671. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  672. local hp
  673. local limit
  674. local ret = {}
  675. if args[5] then
  676. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  677. end
  678. for _,target in ipairs(targets) do
  679. hp = calcHp(obj,target,calcType,rate,limit)
  680. if hp ~= 0 then
  681. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  682. if d ~= 0 then
  683. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtmingli"])
  684. CombatObj.onHpCB(target,d, obj.pos)
  685. ret[#ret+1] = target
  686. end
  687. end
  688. end
  689. return ret
  690. end
  691. function CMD.hurtmingli2(obj,skillConfig,skillTargets)
  692. local args = obj.isPet and obj.args or skillConfig.args
  693. local r = math.random(0,10000)
  694. if r > args[4] then
  695. return
  696. end
  697. local calcType = args[1]
  698. local rate = args[2]
  699. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  700. local hp
  701. local limit
  702. local ret = {}
  703. if args[5] then
  704. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  705. end
  706. for _,target in ipairs(targets) do
  707. hp = calcHp(obj,target,calcType,rate,limit)
  708. if hp ~= 0 then
  709. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  710. if d ~= 0 then
  711. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtmingli2"])
  712. CombatObj.onHpCB(target,d, obj.pos)
  713. ret[#ret+1] = target
  714. end
  715. end
  716. end
  717. return ret
  718. end
  719. function CMD.hurtguangci(obj,skillConfig,skillTargets)
  720. local args = obj.isPet and obj.args or skillConfig.args
  721. local r = math.random(0,10000)
  722. if r > args[4] then
  723. return
  724. end
  725. local calcType = args[1]
  726. local rate = args[2]
  727. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  728. local hp
  729. local limit
  730. local ret = {}
  731. if args[5] then
  732. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  733. end
  734. for _,target in ipairs(targets) do
  735. hp = calcHp(obj,target,calcType,rate,limit)
  736. if hp ~= 0 then
  737. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  738. if d ~= 0 then
  739. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtguangci"])
  740. CombatObj.onHpCB(target,d, obj.pos)
  741. ret[#ret+1] = target
  742. end
  743. end
  744. end
  745. return ret
  746. end
  747. function CMD.jobHurt(obj,skillConfig,skillTargets)
  748. local args = obj.isPet and obj.args or skillConfig.args
  749. local calcType = args[1]
  750. local rate = args[2]
  751. local r = math.random(0,10000)
  752. if r > args[3] then
  753. return
  754. end
  755. local job = args[4]
  756. local hp
  757. local limit
  758. if args[5] then
  759. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  760. end
  761. local ret = {}
  762. for _,target in ipairs(skillTargets) do
  763. if target.job == job then
  764. hp = calcHp(obj,target,calcType,rate,limit)
  765. if hp and hp ~= 0 then
  766. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  767. if d ~= 0 then
  768. CombatImpl.setExtraHit(target,-hp,CMD2ID["jobHurt"])
  769. CombatObj.onHpCB(target,d, obj.pos)
  770. ret[#ret+1] = target
  771. end
  772. end
  773. end
  774. end
  775. return ret
  776. end
  777. function CMD.statusHurt(obj,skillConfig,skillTargets)
  778. local args = obj.isPet and obj.args or skillConfig.args
  779. local calcType = args[1]
  780. local rate = args[2]
  781. local r = math.random(0,10000)
  782. if r > args[3] then
  783. return
  784. end
  785. local status = args[4]
  786. local hp
  787. local limit
  788. if args[5] then
  789. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  790. end
  791. local ret = {}
  792. for _,target in ipairs(skillTargets) do
  793. if CombatBuff.isStatus(target, status) then
  794. hp = calcHp(obj,target,calcType,rate,limit)
  795. if hp and hp ~= 0 then
  796. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  797. if d ~= 0 then
  798. CombatImpl.setExtraHit(target,-hp,CMD2ID["jobHurt"])
  799. CombatObj.onHpCB(target,d, obj.pos)
  800. ret[#ret+1] = target
  801. end
  802. end
  803. end
  804. end
  805. return ret
  806. end
  807. function CMD.hpHurt(obj,skillConfig,skillTargets)
  808. local args = obj.isPet and obj.args or skillConfig.args
  809. local calcType = args[1]
  810. local rate = args[2]
  811. local hpRate = args[3]/10000
  812. local ret = {}
  813. for _,target in ipairs(skillTargets) do
  814. local hpLimit = CombatObj.getHpMax(target) * hpRate
  815. if target.hp >= hpLimit then
  816. hp = calcHp(obj,target,calcType,rate)
  817. if hp and hp ~= 0 then
  818. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  819. if d ~= 0 then
  820. CombatImpl.setExtraHit(target,-hp,CMD2ID["hpHurt"])
  821. CombatObj.onHpCB(target,d, obj.pos)
  822. ret[#ret+1] = target
  823. end
  824. end
  825. end
  826. end
  827. return ret
  828. end
  829. function CMD.fanji(obj,skillConfig,skillTargets)
  830. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  831. if CombatBuff.isStatus(obj,{"xuanyun","shihua","bingdong", "xuanyun2"}) then return end
  832. if obj.side == skillTargets[1].side then
  833. return
  834. end
  835. if obj.hp > 0 then
  836. local r = math.random(0,10000)
  837. if r < skillConfig.args[2] then
  838. CombatImpl.fanjiList[#CombatImpl.fanjiList + 1] = {obj,skillConfig.args[1],skillTargets}
  839. end
  840. end
  841. end
  842. function CMD.qingsuan(obj,skillConfig,skillTargets)
  843. if obj.isPet then return {} end
  844. local args = skillConfig.args
  845. local r = math.random(0,10000)
  846. if r > args[3] then
  847. return
  848. end
  849. local rate = args[1]
  850. local limit
  851. if args[4] then
  852. limit = args[4] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  853. end
  854. local targets = TargetMode.getTargets(obj, args[2],skillTargets)
  855. local ret = {}
  856. for _,target in ipairs(targets) do
  857. local baseValue = CombatBuff.qingsuan(target)
  858. if baseValue > 0 then
  859. local hurt = baseValue * rate / 10000
  860. if limit and hurt > limit then
  861. hurt = limit
  862. end
  863. local d = CombatObj.updateHp(target,-hurt,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  864. CombatImpl.setExtraHit(target,-hurt,CMD2ID["qingsuan"])
  865. CombatObj.onHpCB(target,d, obj.pos)
  866. ret[#ret+1] = target
  867. end
  868. end
  869. return ret
  870. end
  871. function CMD.jiekong(obj,skillConfig,skillTargets)
  872. if obj.isPet then return {} end
  873. local args = skillConfig.args
  874. local r = math.random(0,10000)
  875. if r > args[2] then
  876. return
  877. end
  878. local targets = TargetMode.getTargets(obj, args[1],skillTargets)
  879. local ret = {}
  880. for _,target in ipairs(targets) do
  881. CombatBuff.jiekong(target)
  882. ret[#ret+1] = target
  883. end
  884. return ret
  885. end
  886. function CMD.groupcmd(obj,skillConfig,skillTargets)
  887. if obj.isPet then return {} end
  888. for k,v in ipairs(skillConfig.args) do
  889. local cmd = v[1]
  890. local conf = {args = v[2]}
  891. if CMD[cmd] then
  892. CMD[cmd](obj,conf,skillTargets)
  893. end
  894. end
  895. return {}
  896. end
  897. function CMD.randcmd(obj,skillConfig,skillTargets)
  898. if obj.isPet then return {} end
  899. local total = 0
  900. for k,v in ipairs(skillConfig.args) do
  901. total = total + v[3]
  902. end
  903. local r = math.random(0,total)
  904. for k,v in ipairs(skillConfig.args) do
  905. if r <= v[3] then
  906. local cmd = v[1]
  907. local conf = {args = v[2]}
  908. if CMD[cmd] then
  909. CMD[cmd](obj,conf,skillTargets)
  910. end
  911. break
  912. else
  913. r = r - v[1]
  914. end
  915. end
  916. return {}
  917. end
  918. function CMD.qusan(obj,skillConfig,skillTargets)
  919. if obj.isPet then return {} end
  920. local args = skillConfig.args
  921. local r = math.random(0,10000)
  922. if r > args[3] then
  923. return
  924. end
  925. local qusanType = args[1]
  926. local calcType = args[5] and args[5][1]
  927. local rate = args[5] and args[5][2]
  928. local buffers = args[8] and args[8][1]
  929. local targets = TargetMode.getTargets(obj, args[2],skillTargets)
  930. local ret = {}
  931. if args[7] then
  932. limit = args[7] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  933. end
  934. for _,target in ipairs(targets) do
  935. local cnt = CombatBuff.qusan(target, qusanType,args[4])
  936. if limit then
  937. limit = limit * cnt
  938. end
  939. if buffers and cnt > 0 then
  940. local targets = TargetMode.getTargets(obj, args[8][2],skillTargets)
  941. CombatBuff.qusanAddBuff(obj, targets, buffers)
  942. end
  943. ret[#ret+1] = target
  944. if calcType and rate and cnt > 0 then
  945. local hp = calcHp(obj,target,calcType,rate * cnt, limit, nil, nil, args[6])
  946. if hp ~= 0 then
  947. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  948. if d ~= 0 then
  949. CombatImpl.setExtraHit(target,-hp,CMD2ID["qusan"])
  950. CombatObj.onHpCB(target,d, obj.pos)
  951. end
  952. end
  953. end
  954. end
  955. return ret
  956. end
  957. function CMD.hurtwalun2(obj,skillConfig,skillTargets)
  958. local args = obj.isPet and obj.args or skillConfig.args
  959. local r = math.random(0,10000)
  960. if r > args[4] then
  961. return
  962. end
  963. local calcType = args[1]
  964. local rate = args[2]
  965. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  966. local hp
  967. local limit
  968. local ret = {}
  969. if args[5] then
  970. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  971. end
  972. for _,target in ipairs(targets) do
  973. hp = calcHp(obj,target,calcType,rate,limit)
  974. if hp ~= 0 then
  975. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  976. if d ~= 0 then
  977. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtwalun2"])
  978. CombatObj.onHpCB(target,d, obj.pos)
  979. ret[#ret+1] = target
  980. end
  981. end
  982. end
  983. return ret
  984. end
  985. function CMD.hurtxia2(obj,skillConfig,skillTargets)
  986. local args = obj.isPet and obj.args or skillConfig.args
  987. local r = math.random(0,10000)
  988. if r > args[4] then
  989. return
  990. end
  991. local calcType = args[1]
  992. local rate = args[2]
  993. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  994. local hp
  995. local limit
  996. local ret = {}
  997. if args[5] then
  998. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  999. end
  1000. for _,target in ipairs(targets) do
  1001. hp = calcHp(obj,target,calcType,rate,limit)
  1002. if hp ~= 0 then
  1003. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  1004. if d ~= 0 then
  1005. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtxia2"])
  1006. CombatObj.onHpCB(target,d, obj.pos)
  1007. ret[#ret+1] = target
  1008. end
  1009. end
  1010. end
  1011. return ret
  1012. end
  1013. function CMD.hurtxia3(obj,skillConfig,skillTargets)
  1014. local args = obj.isPet and obj.args or skillConfig.args
  1015. local r = math.random(0,10000)
  1016. if r > args[4] then
  1017. return
  1018. end
  1019. local calcType = args[1]
  1020. local rate = args[2]
  1021. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  1022. local hp
  1023. local limit
  1024. local ret = {}
  1025. if args[5] then
  1026. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK_COMBAT_NOW) / 10000
  1027. end
  1028. for _,target in ipairs(targets) do
  1029. hp = calcHp(obj,target,calcType,rate,limit)
  1030. if hp ~= 0 then
  1031. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  1032. if d ~= 0 then
  1033. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurtxia3"])
  1034. CombatObj.onHpCB(target,d, obj.pos)
  1035. ret[#ret+1] = target
  1036. end
  1037. end
  1038. end
  1039. return ret
  1040. end
  1041. NO_SKILL_CHECK_COMBO_LIST = {
  1042. ["hp"] = 1,
  1043. ["revive"] = 1,
  1044. ["baohu"] = 1,
  1045. }
  1046. function skillIsHpOrRevive(obj, argSkillID)
  1047. --local argSkillConf = SkillExcel[argSkillID]
  1048. local argSkillConf = GetSkillConfig(argSkillID)
  1049. if not argSkillConf then return end
  1050. -- 带有伤害
  1051. if argSkillConf.hurtRate[1] then return end
  1052. if argSkillConf.continuous and argSkillConf.continuous == 1 then return true end
  1053. if NO_SKILL_CHECK_COMBO_LIST[argSkillConf.cmd] then
  1054. return true
  1055. end
  1056. local bRet = false
  1057. if argSkillConf.cmd == "groupcmd" then
  1058. for k,v in ipairs(argSkillConf.args) do
  1059. local cmd = v[1]
  1060. if cmd == "hurt" then return end
  1061. if NO_SKILL_CHECK_COMBO_LIST[cmd] then
  1062. bRet = true
  1063. end
  1064. end
  1065. end
  1066. -- 技能包
  1067. if argSkillConf.type == CombatDefine.SKILL_TYPE5 or
  1068. argSkillConf.type == CombatDefine.SKILL_TYPE6 or
  1069. argSkillConf.type == CombatDefine.SKILL_TYPE7 then
  1070. for k,v in ipairs(argSkillConf.otherArgs.skillList) do
  1071. local config = SkillExcel[v]
  1072. -- 带有伤害
  1073. if config and config.hurtRate[1] then return end
  1074. if config then
  1075. if NO_SKILL_CHECK_COMBO_LIST[config.cmd] or config.continuous == 1 then
  1076. bRet = true
  1077. end
  1078. for k,v in ipairs(config.buffers) do
  1079. --local bufConfig = BufferExcel.buffer[v[1]]
  1080. local bufConfig = CombatBuff.GetBuffConfig(v[1])
  1081. -- 带有伤害
  1082. if bufConfig and NO_SKILL_CHECK_COMBO_LIST[bufConfig.cmd] then
  1083. bRet = true
  1084. end
  1085. end
  1086. end
  1087. end
  1088. for k,v in ipairs(argSkillConf.buffers) do
  1089. --local bufConfig = BufferExcel[v[1]]
  1090. local bufConfig = CombatBuff.GetBuffConfig(v[1])
  1091. -- 带有伤害
  1092. if bufConfig and NO_SKILL_CHECK_COMBO_LIST[bufConfig.cmd] then
  1093. bRet = true
  1094. end
  1095. end
  1096. end
  1097. return bRet
  1098. end
  1099. function CMD.combo(obj,skillConfig,skillTargets)
  1100. -- 二次元 屏蔽 治疗 复活的连击
  1101. if ProjectLogic.isSsecy() then
  1102. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1103. if skillIsHpOrRevive(obj, argSkillID) then
  1104. return
  1105. end
  1106. if skillIsHpOrRevive(obj, skillConfig.id) then
  1107. return
  1108. end
  1109. end
  1110. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1111. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1112. local r = math.random(0,10000)
  1113. if r < skillConfig.args[1] then
  1114. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],skillConfig.args[4] or 1, skillConfig.args[5]}
  1115. return true
  1116. end
  1117. end
  1118. --
  1119. function CMD.comboFight(obj,skillConfig,skillTargets)
  1120. -- 二次元 屏蔽 治疗 复活的连击
  1121. if ProjectLogic.isSsecy() then
  1122. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1123. if skillIsHpOrRevive(obj, argSkillID) then
  1124. return
  1125. end
  1126. if skillIsHpOrRevive(obj, skillConfig.id) then
  1127. return
  1128. end
  1129. end
  1130. if CombatImpl.isFanji then return end
  1131. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1132. local r = math.random(0,10000)
  1133. if r < skillConfig.args[1] then
  1134. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],skillConfig.args[4] or 1, skillConfig.args[5]}
  1135. return true
  1136. end
  1137. end
  1138. function CMD.combo1(obj,skillConfig,skillTargets)
  1139. -- 二次元 屏蔽 治疗 复活的连击
  1140. if ProjectLogic.isSsecy() then
  1141. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1142. if skillIsHpOrRevive(obj, skillConfig) then
  1143. return
  1144. end
  1145. if skillIsHpOrRevive(obj, skillConfig.id) then
  1146. return
  1147. end
  1148. end
  1149. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1150. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1151. local r = math.random(0,10000)
  1152. if r < skillConfig.args[1] then
  1153. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],2}
  1154. return true
  1155. end
  1156. end
  1157. function CMD.combo2(obj,skillConfig,skillTargets)
  1158. -- 二次元 屏蔽 治疗 复活的连击
  1159. if ProjectLogic.isSsecy() then
  1160. local argSkillID = skillConfig.args[3] or CombatImpl.getSkillID(obj)
  1161. if skillIsHpOrRevive(obj, argSkillID) then
  1162. return
  1163. end
  1164. if skillIsHpOrRevive(obj, skillConfig.id) then
  1165. return
  1166. end
  1167. end
  1168. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1169. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1170. local r = math.random(0,10000)
  1171. if r < skillConfig.args[1] then
  1172. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, skillConfig.args[2], skillConfig.args[3],3}
  1173. return true
  1174. end
  1175. end
  1176. function CMD.comboNormal(obj, skillConfig, skillTargets)
  1177. -- 二次元 屏蔽 治疗 复活的连击
  1178. if ProjectLogic.isSsecy() then
  1179. local argSkillID = skillConfig.args[3] or CombatImpl.getNormalSkill(obj)
  1180. if skillIsHpOrRevive(obj, argSkillID) then
  1181. return
  1182. end
  1183. if skillIsHpOrRevive(obj, skillConfig.id) then
  1184. return
  1185. end
  1186. end
  1187. if CombatImpl.comboType > 0 then return end
  1188. if CombatImpl.isFanji then
  1189. if GroupSkillCnt > 2 then return end
  1190. else
  1191. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1192. end
  1193. local r = math.random(0,10000)
  1194. if r < skillConfig.args[1] then
  1195. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 2, skillConfig.args[2], skillConfig.args[3],skillConfig.args[4] or 1}
  1196. end
  1197. end
  1198. function CMD.attrcomboAgain(obj, skillConfig, skillTargets)
  1199. local tComboCof = nil
  1200. for _, v in ipairs(skillConfig.args) do
  1201. if v[1] == 2 then
  1202. tComboCof = v
  1203. break
  1204. end
  1205. end
  1206. if not tComboCof then
  1207. print("[CMD.attrcomboAgain] 不存在连击配置")
  1208. return
  1209. end
  1210. --table.print_lua_table(tComboCof)
  1211. -- 二次元 屏蔽 治疗 复活的连击
  1212. if ProjectLogic.isSsecy() then
  1213. local argSkillID = tComboCof[3] or CombatImpl.getSkillID(obj)
  1214. if skillIsHpOrRevive(obj, argSkillID) then
  1215. return
  1216. end
  1217. if skillIsHpOrRevive(obj, skillConfig.id) then
  1218. return
  1219. end
  1220. end
  1221. local nSkillID = tComboCof[3] or CombatImpl.getSkillID(obj)
  1222. if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
  1223. if GroupSkillCnt ~= 1 then return end--技能包首次技能攻击才能触发
  1224. local r = math.random(0,10000)
  1225. --print("[CMD.attrcomboAgain] nSkillID = "..nSkillID)
  1226. if r < tComboCof[2] then
  1227. CombatImpl.comboList[#CombatImpl.comboList + 1] = {obj, 1, tComboCof[3], nSkillID, tComboCof[5] or 1, tComboCof[6]}
  1228. return true
  1229. end
  1230. end
  1231. function CMD.baohu(obj,skillConfig,skillTargets)
  1232. local d = CombatObj.updateHp(obj,obj.baohuHurt,nil,nil, obj.pos,CombatObj.BUFFER_HP_TYPE)
  1233. if d ~= 0 then
  1234. local attrs = {}
  1235. attrs[RoleDefine.BAOHU_COMBAT] = skillTargets[1].pos
  1236. CombatImpl.setExtraHit(obj,d,CMD2ID["baohu"],attrs)
  1237. CombatObj.onHpCB(obj,d, skillTargets[1].pos)
  1238. end
  1239. end
  1240. function CMD.yinbaoZuzhou(obj,skillConfig,skillTargets)
  1241. CombatBuff.yinbaoZuzhou(obj, skillTargets, skillConfig)
  1242. end
  1243. --指定普攻目标模式
  1244. function CMD.normalTarget(obj,skillConfig)
  1245. obj.normalTarget = {status = {}}
  1246. if skillConfig.args.status then
  1247. for k,v in ipairs(skillConfig.args.status) do
  1248. obj.normalTarget.status[k] = v
  1249. end
  1250. end
  1251. end
  1252. --诅咒附加伤害
  1253. function CMD.zuzhouHurt(obj, skillConfig, skillTargets)
  1254. if not obj.args then return end
  1255. local confArgs = skillConfig.args
  1256. local targets = TargetMode.getTargets(obj, confArgs[1], skillTargets)
  1257. local zuzhouHurt = obj.args * confArgs[2] / 10000
  1258. for _,target in ipairs(targets) do
  1259. if zuzhouHurt ~= 0 then
  1260. local d = CombatObj.updateHp(target,-zuzhouHurt,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  1261. if d ~= 0 then
  1262. CombatImpl.setExtraHit(target,-zuzhouHurt,CMD2ID["zuzhouHurt"])
  1263. CombatObj.onHpCB(target,d, obj.pos)
  1264. end
  1265. end
  1266. end
  1267. obj.args = nil
  1268. end
  1269. function CMD.dnexhurt(obj,skillConfig,skillTargets)
  1270. local args = obj.isPet and obj.args or skillConfig.args
  1271. local r = math.random(0,10000)
  1272. if r > args[4] then
  1273. return
  1274. end
  1275. local calcType = args[1]
  1276. local rate = args[2]
  1277. local targets = TargetMode.getTargets(obj, args[3],skillTargets)
  1278. local hp
  1279. local limit
  1280. local ret = {}
  1281. if args[5] then
  1282. limit = args[5] * CombatObj.getValue(obj,RoleDefine.ATK)
  1283. end
  1284. for _,target in ipairs(targets) do
  1285. hp = calcHp(obj,target,calcType,rate,limit)
  1286. if hp ~= 0 then
  1287. local d = CombatObj.updateHp(target,-hp,nil,true, obj.pos,CombatObj.EXTRA_HP_TYPE)
  1288. if d ~= 0 then
  1289. CombatImpl.setExtraHit(target,-hp,CMD2ID["hurt"])
  1290. CombatObj.onHpCB(target,d, obj.pos)
  1291. ret[#ret+1] = target
  1292. end
  1293. end
  1294. end
  1295. return ret
  1296. end
  1297. --拥有指定buff后的额外效果
  1298. function CMD.targetBuffExtraEffect(obj,skillConfig,skillTargets)
  1299. local args = skillConfig.args
  1300. if not args then
  1301. return
  1302. end
  1303. local targetBuffCmd = args[1]
  1304. local targetBuffCnt = args[2]
  1305. if not targetBuffCmd or not targetBuffCnt then
  1306. return
  1307. end
  1308. local nowTargetBuffCnt = CombatBuff.getBuffCnt(obj, targetBuffCmd)
  1309. if nowTargetBuffCnt < targetBuffCnt then
  1310. return
  1311. end
  1312. local targetMode = args[3]
  1313. local targets = TargetMode.getTargets(obj, targetMode, skillTargets)
  1314. local hurt, limitVale
  1315. local calcType, rate = args[4], args[5]
  1316. local maxNum = args[6] or 1
  1317. local nowNum = math.floor(nowTargetBuffCnt / targetBuffCnt)
  1318. if nowNum < maxNum then
  1319. maxNum = nowNum
  1320. end
  1321. local limitAttrType = args[7]
  1322. local limitAttrRate = args[8]
  1323. if limitAttrType and limitAttrRate then
  1324. limitVale = limitAttrRate * CombatObj.getValue(obj, limitAttrType)
  1325. end
  1326. table.shuffle(targets)
  1327. for idx, target in ipairs(targets) do
  1328. if idx > maxNum then
  1329. break
  1330. end
  1331. hurt = calcHp(obj, target, calcType, rate, limitVale)
  1332. if hurt ~= 0 then
  1333. local d = CombatObj.updateHp(target,-hurt,nil,true, obj.pos,CombatObj.SKILL_HP_TYPE)
  1334. if d ~= 0 then
  1335. CombatImpl.setExtraHit(target,-hurt,CMD2ID["hurt"])
  1336. CombatObj.onHpCB(target,d, obj.pos)
  1337. end
  1338. end
  1339. end
  1340. CombatBuff.DelBuffByCmd(obj, targetBuffCmd, nowTargetBuffCnt)
  1341. end
  1342. --debuff 和 buff 数量差的额外伤害
  1343. function CMD.buffDiffHurt(obj,skillConfig,skillTargets)
  1344. local args = skillConfig.args
  1345. if not args then
  1346. return
  1347. end
  1348. local buffType1 = args[1] --buff类型1, 对应配置表buff中qusan分页中的type
  1349. local buffType2 = args[2] --buff类型2, 对应配置表buff中qusan分页中的type
  1350. local targetMode = args[3]
  1351. local calcType, rate = args[4], args[5]
  1352. local limitAttrType, limitAttrMul = args[6], args[7]
  1353. local maxHurt = CombatObj.getValue(obj, limitAttrType) * limitAttrMul
  1354. local targets = TargetMode.getTargets(obj, targetMode, skillTargets)
  1355. for _, targetObj in ipairs(targets) do
  1356. local buffCnt1 = CombatBuff.getCombatBufferCnt(targetObj, buffType1)
  1357. local buffCnt2 = CombatBuff.getCombatBufferCnt(targetObj, buffType2)
  1358. if buffCnt1 > buffCnt2 then
  1359. local hurt = calcHp(obj, targetObj, calcType, rate)
  1360. hurt = hurt * (buffCnt1 - buffCnt2)
  1361. if hurt > maxHurt then
  1362. hurt = maxHurt
  1363. end
  1364. local d = CombatObj.updateHp(targetObj, -hurt, nil, true, obj.pos, CombatObj.EXTRA_HP_TYPE)
  1365. if d ~= 0 then
  1366. CombatImpl.setExtraHit(targetObj, -hurt, CMD2ID["hurt"])
  1367. CombatObj.onHpCB(targetObj, d, obj.pos)
  1368. end
  1369. end
  1370. end
  1371. end
  1372. -- 与其中一个符合条件的队友交换血量, 交换成功后,恢复自身一定血量
  1373. function CMD.exchangeHP(obj,skillConfig,skillTargets)
  1374. local args = skillConfig.args
  1375. if not args then
  1376. return
  1377. end
  1378. local targetMode = args[3]
  1379. local targets = TargetMode.getTargets(obj, targetMode, skillTargets)
  1380. local targetObj = targets[1]
  1381. if targetObj then
  1382. -- 不能是自己
  1383. if targetObj.pos == obj.pos then
  1384. return
  1385. end
  1386. -- 不能满血
  1387. local attrID = targetMode[4] or RoleDefine.HP -- 默认是HP
  1388. local targetObjSubRate = CombatObj.getValue(targetObj, attrID)
  1389. if targetObjSubRate >= 10000 then
  1390. return
  1391. end
  1392. local targetHP = targetObj.hp
  1393. local attackerHp = obj.hp
  1394. local subHP = attackerHp - targetHP
  1395. -- 施放者血量不能最低
  1396. if subHP > 0 then
  1397. -- 给目标加血量差值
  1398. local d = CombatObj.updateHp(targetObj, subHP, nil, true, obj.pos, CombatObj.EXTRA_HP_TYPE)
  1399. if d ~= 0 then
  1400. CombatImpl.setExtraHit(targetObj, subHP, CMD2ID["hp"])
  1401. CombatObj.onHpCB(targetObj, d, obj.pos)
  1402. end
  1403. -- 给施放者扣血量差值
  1404. d = CombatObj.updateHp(obj, -subHP, nil, true, targetObj.pos, CombatObj.EXTRA_HP_TYPE)
  1405. if d ~= 0 then
  1406. CombatImpl.setExtraHit(obj, -subHP, CMD2ID["hp"])
  1407. CombatObj.onHpCB(obj, d, targetObj.pos)
  1408. end
  1409. -- 给施放者恢复一定血量
  1410. local calcType = args[1]
  1411. local rate = args[2]
  1412. local hp = calcHp(obj,targetObj, calcType, rate, nil, true)
  1413. d = CombatObj.updateHp(obj,hp, nil, true, obj.pos, CombatObj.EXTRA_HP_TYPE)
  1414. local showHp = hp
  1415. if hp > 0 and d < 0 then
  1416. showHp = hp * (-1)
  1417. end
  1418. CombatImpl.setExtraHit(obj, showHp, CMD2ID["hp"])
  1419. CombatObj.onHpCB(obj,d, obj.pos)
  1420. end
  1421. end
  1422. end