Skill.lua 49 KB

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