skillUtils.lua 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730
  1. local skillUtils = {}
  2. local proxyUtils = requireProxy("proxyUtils")
  3. local SKILL_ID_PuGong = 0 --普攻
  4. local SKILL_ID_ShiDuShu = 6 --施毒术
  5. local SKILL_ID_GongSha = 7 --攻杀
  6. local SKILL_ID_KJHuoHuan = 8 --抗拒火环
  7. local SKILL_ID_CiSha = 12 --刺杀
  8. local SKILL_ID_YouLingDun = 14 --幽灵顿
  9. local SKILL_ID_SSZhanJia = 15 --神圣战甲术
  10. local SKILL_ID_ZHKuLou = 17 --召唤骷髅
  11. local SKILL_ID_YinShenShu = 18 --隐身术
  12. local SKILL_ID_HuoQiang = 22 --火墙
  13. local SKILL_ID_DYLeiGuang = 24 --地狱雷光
  14. local SKILL_ID_BanYue = 25 --半月
  15. local SKILL_ID_LieHuo = 26 --烈火
  16. local SKILL_ID_QTZhiYuShu = 29 --群体治愈术
  17. local SKILL_ID_ZHShenShou = 30 --召唤神兽
  18. local SKILL_ID_MoFaDun = 31 --魔法盾
  19. local SKILL_ID_HuoYanBing = 36 --火焰冰
  20. local SKILL_ID_ShuangLongZhan = 40 --双龙斩
  21. local SKILL_ID_LYJianFa = 42 --龙影剑法
  22. local SKILL_ID_LTJianFa = 43 --雷霆剑法
  23. local SKILL_ID_HanBingZhang = 44 --寒冰掌
  24. local SKILL_ID_WuJiZhenQi = 50 --无极真气
  25. local SKILL_ID_QTShiDuShu = 51 --群体施毒术
  26. local SKILL_ID_ZHYueLing = 55 --召唤月灵
  27. local SKILL_ID_ZhuRi = 56 --逐日
  28. local SKILL_ID_ShiXueShu = 57 --嗜血术
  29. local SKILL_ID_KaiTian = 66 --开天
  30. local SKILL_ID_DaoLiDun = 73 --道力盾
  31. local SKILL_ID_ZHShengShou = 76 --召唤圣兽
  32. local SKILL_ID_ZHJianShu = 81 --纵横剑术
  33. local SKILL_ID_BingLianShu = 83 --冰镰术
  34. local SKILL_ID_BSQunYu = 84 --冰霜群雨
  35. local SKILL_ID_LieShenFu = 85 --裂神服
  36. local SKILL_ID_SWZhiYan = 86 --死亡之眼
  37. local SKILL_ID_WuLiDun = 87 --武力盾
  38. local SKILL_ID_XPYiJi = 115 --血泊一击
  39. local SKILL_ID_ShiZiHou = 41 --狮子吼
  40. local AUTO_SETTING_KEY_VALUE = {
  41. [SKILL_ID_MoFaDun] = global.MMO.SETTING_IDX_AUTO_MOFADUN, -- 自动魔法盾
  42. [SKILL_ID_HuoQiang] = global.MMO.SETTING_IDX_AUTO_FIRE_WALL, -- 自动火墙
  43. [SKILL_ID_ShiDuShu] = global.MMO.SETTING_IDX_AUTO_DU, -- 自动施毒术
  44. [SKILL_ID_YouLingDun] = global.MMO.SETTING_IDX_AUTO_YOULINGDUN, -- 自动幽灵盾
  45. [SKILL_ID_SSZhanJia] = global.MMO.SETTING_IDX_AUTO_SSZJS, -- 自动神圣战甲术
  46. [SKILL_ID_WuJiZhenQi] = global.MMO.SETTING_IDX_AUTO_WJZQ, -- 自动无极真气
  47. [SKILL_ID_YinShenShu] = global.MMO.SETTING_IDX_AUTO_CLOAKING, -- 自动隐身
  48. [SKILL_ID_HanBingZhang] = global.MMO.SETTING_IDX_AUTO_ICE_PALM, -- 自动寒冰掌
  49. [SKILL_ID_ShiXueShu] = global.MMO.SETTING_IDX_AUTO_BLOODTHIRSTY_S, -- 自动嗜血术
  50. [SKILL_ID_LieShenFu] = global.MMO.SETTING_IDX_AUTO_BREACH_NERVE_FU, -- 自动裂神符
  51. [SKILL_ID_BingLianShu] = global.MMO.SETTING_IDX_AUTO_ICE_SICKLE_S, -- 自动冰镰术
  52. [SKILL_ID_HuoYanBing] = global.MMO.SETTING_IDX_AUTO_FLAME_ICE, -- 自动火焰冰
  53. [SKILL_ID_BSQunYu] = global.MMO.SETTING_IDX_AUTO_ICE_GROUP_RAIN, -- 自动冰霜群雨
  54. [SKILL_ID_SWZhiYan] = global.MMO.SETTING_IDX_AUTO_DEATH_EYE, -- 自动死亡之眼
  55. [SKILL_ID_ShiZiHou] = global.MMO.SETTING_IDX_AUTO_SHI_ZI_HOU, -- 自动狮子吼
  56. [SKILL_ID_ZHJianShu] = global.MMO.SETTING_IDX_AUTO_FREELY_JS, -- 自动纵横剑术
  57. [SKILL_ID_WuLiDun] = global.MMO.SETTING_IDX_AUTO_SHIELD_OF_FORCE, -- 自动武力盾
  58. [SKILL_ID_DaoLiDun] = global.MMO.SETTING_IDX_AUTO_SHIELD_OF_TAOIST, -- 自动道力盾
  59. }
  60. -- 内挂检测技能
  61. local SETTING_SKILL = {
  62. SKILL_ID_KaiTian,
  63. SKILL_ID_ZhuRi,
  64. SKILL_ID_LYJianFa,
  65. SKILL_ID_LTJianFa,
  66. SKILL_ID_ZHJianShu,
  67. SKILL_ID_ShiDuShu,
  68. SKILL_ID_HuoQiang,
  69. SKILL_ID_HanBingZhang,
  70. SKILL_ID_ShiXueShu,
  71. SKILL_ID_LieShenFu,
  72. SKILL_ID_SWZhiYan,
  73. SKILL_ID_BingLianShu,
  74. SKILL_ID_HuoYanBing,
  75. SKILL_ID_BSQunYu,
  76. SKILL_ID_LieHuo,
  77. SKILL_ID_ShiZiHou,
  78. }
  79. skillUtils.calcLaunchDirection = function(dstPos, srcPos)
  80. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  81. if not mainPlayer then
  82. return global.MMO.ORIENT_U
  83. end
  84. if not srcPos or not dstPos then
  85. return mainPlayer:GetDirection()
  86. end
  87. if srcPos.x == dstPos.x and srcPos.y == dstPos.y then
  88. return mainPlayer:GetDirection()
  89. end
  90. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  91. return inputProxy:calcMapDirection(dstPos, srcPos)
  92. end
  93. --------------------------- 技能检测 begin -------------------------------
  94. skillUtils.CHECK_SKILL = {
  95. -- 武力盾
  96. [SKILL_ID_WuLiDun] = function(target)
  97. local skillID = SKILL_ID_WuLiDun
  98. -- exist shield
  99. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  100. if global.BuffManager:IsHaveShield(mainPlayerID) then
  101. return nil
  102. end
  103. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  104. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  105. end,
  106. -- 魔法盾
  107. [SKILL_ID_MoFaDun] = function(target)
  108. local skillID = SKILL_ID_MoFaDun
  109. -- exist shield
  110. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  111. if global.BuffManager:IsHaveShield(mainPlayerID) then
  112. return nil
  113. end
  114. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  115. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  116. end,
  117. -- 道力盾
  118. [SKILL_ID_DaoLiDun] = function(target)
  119. local skillID = SKILL_ID_DaoLiDun
  120. -- exist shield
  121. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  122. if global.BuffManager:IsHaveShield(mainPlayerID) then
  123. return nil
  124. end
  125. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  126. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  127. end,
  128. -- 无极真气
  129. [SKILL_ID_WuJiZhenQi] = function(target)
  130. local skillID = SKILL_ID_WuJiZhenQi
  131. -- exit shield
  132. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  133. if global.BuffManager:IsHaveOneBuff(mainPlayerID, global.MMO.BUFF_ID_WUJI_SHIELD) then
  134. return nil
  135. end
  136. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  137. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  138. end,
  139. -- 幽灵盾
  140. [SKILL_ID_YouLingDun] = function(target)
  141. local skillID = SKILL_ID_YouLingDun
  142. -- exist shield
  143. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  144. if global.BuffManager:IsHaveGhostShield(mainPlayerID) then
  145. return nil
  146. end
  147. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  148. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  149. end,
  150. -- 神圣战甲术
  151. [SKILL_ID_SSZhanJia] = function(target)
  152. local skillID = SKILL_ID_SSZhanJia
  153. -- exist shield
  154. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  155. if global.BuffManager:IsHaveAngelShield(mainPlayerID) then
  156. return nil
  157. end
  158. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  159. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  160. end,
  161. -- 召唤月灵
  162. [SKILL_ID_ZHYueLing] = function(target)
  163. local skillID = SKILL_ID_ZHYueLing
  164. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  165. if not SummonsProxy:canSummons(skillID) then
  166. return nil
  167. end
  168. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  169. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  170. end,
  171. -- 召唤神兽
  172. [SKILL_ID_ZHShenShou] = function(target)
  173. local skillID = SKILL_ID_ZHShenShou
  174. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  175. if not SummonsProxy:canSummons(skillID) then
  176. return nil
  177. end
  178. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  179. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  180. end,
  181. -- 召唤圣兽
  182. [SKILL_ID_ZHShengShou] = function(target)
  183. local skillID = SKILL_ID_ZHShengShou
  184. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  185. if not SummonsProxy:canSummons(skillID) then
  186. return nil
  187. end
  188. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  189. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  190. end,
  191. -- 召唤骷髅
  192. [SKILL_ID_ZHKuLou] = function(target)
  193. local skillID = SKILL_ID_ZHKuLou
  194. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  195. if not SummonsProxy:canSummons(skillID) then
  196. return nil
  197. end
  198. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  199. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  200. end,
  201. -- 火墙
  202. [SKILL_ID_HuoQiang] = function(target)
  203. if not target then
  204. return nil
  205. end
  206. local skillID = SKILL_ID_HuoQiang
  207. -- check fire is existed
  208. local dstX = target:GetMapX()
  209. local dstY = target:GetMapY()
  210. if global.sceneEffectManager:IsExistedFireInMapXY(dstX, dstY) then
  211. return nil
  212. end
  213. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  214. -- check launchTime
  215. local lastLaunchTime = skillProxy:GetSkillCustomData(skillID)
  216. local currTime = os.time()
  217. if lastLaunchTime and currTime - lastLaunchTime < 3 then
  218. return nil
  219. end
  220. skillProxy:SetSkillCustomData(skillID, currTime)
  221. return skillID, cc.p(target:GetMapX(), target:GetMapY())
  222. end,
  223. -- 施毒术
  224. [SKILL_ID_ShiDuShu] = function(target)
  225. if not target then
  226. return nil
  227. end
  228. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  229. if not autoProxy:CheckDu() then
  230. return nil
  231. end
  232. local skillID = SKILL_ID_ShiDuShu
  233. -- 红绿毒
  234. local res = 0
  235. if global.BuffManager:IsPoisoningRed(target:GetID()) then
  236. res = res + 1
  237. end
  238. if global.BuffManager:IsPoisoningGreen(target:GetID()) then
  239. res = res + 2
  240. end
  241. local assistProxy = global.Facade:retrieveProxy(global.ProxyTable.AssistProxy)
  242. if res == 0 then
  243. local skillProxy = global.Facade:retrieveProxy( global.ProxyTable.Skill )
  244. if skillProxy:CheckAbleToLaunch(skillID) == 1 then
  245. autoProxy:UpdateDuTime()
  246. end
  247. return skillID
  248. elseif res == 1 and assistProxy:CheckDu(1) then
  249. return skillID
  250. elseif res == 2 and assistProxy:CheckDu(2) then
  251. return skillID
  252. end
  253. return nil
  254. end,
  255. -- 群体施毒术
  256. [SKILL_ID_QTShiDuShu] = function(target)
  257. if not target then
  258. return nil
  259. end
  260. local skillID = SKILL_ID_QTShiDuShu
  261. if global.BuffManager:IsPoisoning(target:GetID()) then
  262. return nil
  263. end
  264. return skillID
  265. end,
  266. -- 隐身术
  267. [SKILL_ID_YinShenShu] = function(target)
  268. local skillID = SKILL_ID_YinShenShu
  269. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  270. if global.BuffManager:IsHaveOneBuff(mainPlayerID, global.MMO.BUFF_ID_HIDDEN) then
  271. return nil
  272. end
  273. -- 根据模式来确定是否判断符毒
  274. -- (0:穿戴,1:背包,2:无)
  275. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  276. local MapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  277. local AssistProxy = global.Facade:retrieveProxy(global.ProxyTable.AssistProxy)
  278. local skillAmuleType = MapProxy:GetUseAmuletType()
  279. if skillAmuleType == 2 then
  280. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  281. end
  282. if not ((skillAmuleType == 0 or skillAmuleType == 1) and
  283. (AssistProxy:checkDressEquipSkillID(skillID) or AssistProxy:checkBagEquipSkillID(skillID))) then
  284. return nil
  285. end
  286. return skillID, cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  287. end,
  288. -- 半月
  289. [SKILL_ID_BanYue] = function(target)
  290. local skillID = SKILL_ID_BanYue
  291. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  292. local ret = skillProxy:CheckAbleToLaunch(skillID)
  293. if ret ~= 1 and CHECK_SETTING(SLDefine.SETTINGID.SETTING_IDX_SMART_BANYUE) ~= 1 then
  294. return nil
  295. end
  296. if not target then
  297. return nil
  298. end
  299. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  300. local monsterID = target:GetTypeIndex()
  301. if not skillProxy:CheckAbleToAttack(skillID, monsterID) then
  302. return nil
  303. end
  304. local around = {
  305. [global.MMO.ORIENT_U] = {{-1, -1}, {0, -1}, {1, -1}, {1, 0}},
  306. [global.MMO.ORIENT_RU] = {{0, -1}, {1, -1}, {1, 0}, {1, 1}},
  307. [global.MMO.ORIENT_R] = {{1, -1}, {1, 0}, {1, 1}, {0, 1}},
  308. [global.MMO.ORIENT_RB] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}},
  309. [global.MMO.ORIENT_B] = {{1, 1}, {0, 1}, {-1, 1}, {-1, 0}},
  310. [global.MMO.ORIENT_LB] = {{0, 1}, {-1, 1}, {-1, 0}, {-1, -1}},
  311. [global.MMO.ORIENT_L] = {{-1, 1}, {-1, 0}, {-1, -1}, {0, -1}},
  312. [global.MMO.ORIENT_LU] = {{-1, 0}, {-1, -1}, {0, -1}, {1, -1}}
  313. }
  314. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  315. local pmapX = mainPlayer:GetMapX()
  316. local pmapY = mainPlayer:GetMapY()
  317. local mainPlayerDir = mainPlayer:GetDirection()
  318. local count = 0
  319. local targetID = target:GetID()
  320. local isTargetAround = false
  321. for k, v in pairs(around[mainPlayerDir] or {}) do
  322. local monsters = global.actorManager:GetMonsterActorByMapXY(pmapX + v[1], pmapY + v[2], true)
  323. if monsters then
  324. for i, mon in ipairs(monsters) do
  325. if proxyUtils.checkLaunchTargetByID(mon:GetID()) and
  326. skillProxy:CheckIgnoreMon(skillID, mon:GetTypeIndex()) then
  327. count = count + 1
  328. if not isTargetAround then
  329. isTargetAround = targetID == mon:GetID()
  330. end
  331. end
  332. end
  333. end
  334. if not isTargetAround or count < 2 then
  335. local players = global.actorManager:GetPlayerActorByMapXY(pmapX + v[1], pmapY + v[2], true)
  336. if players then
  337. for i, player in ipairs(players) do
  338. if proxyUtils.checkLaunchTargetByID(player:GetID()) and
  339. skillProxy:CheckIgnoreMon(skillID, player:GetTypeIndex()) then
  340. count = count + 1
  341. if not isTargetAround then
  342. isTargetAround = targetID == player:GetID()
  343. end
  344. end
  345. end
  346. end
  347. end
  348. if count >= 2 and isTargetAround then
  349. break
  350. end
  351. end
  352. if not isTargetAround then
  353. count = 0
  354. end
  355. -- 自动打开/关闭
  356. if CHECK_SETTING(SLDefine.SETTINGID.SETTING_IDX_SMART_BANYUE) == 1 then
  357. local isOnSkill = skillProxy:IsOnSkill(skillID)
  358. if isOnSkill and count < 2 then
  359. skillProxy:SkillOff(skillID)
  360. return nil
  361. elseif not isOnSkill and count >= 2 then
  362. skillProxy:SkillOn(skillID)
  363. return nil
  364. end
  365. end
  366. return count >= 2 and skillID or nil, target and cc.p(target:GetMapX(), target:GetMapY()) or nil, false
  367. end,
  368. -- 双龙斩
  369. [SKILL_ID_ShuangLongZhan] = function(target)
  370. local skillID = SKILL_ID_ShuangLongZhan
  371. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  372. local ret = skillProxy:CheckAbleToLaunch(skillID)
  373. if ret ~= 1 and CHECK_SETTING(SLDefine.SETTINGID.SETTING_IDX_SMART_BANYUE) ~= 1 then
  374. return nil
  375. end
  376. if not target then
  377. return nil
  378. end
  379. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  380. local monsterID = target:GetTypeIndex()
  381. if not skillProxy:CheckAbleToAttack(skillID, monsterID) then
  382. return nil
  383. end
  384. local around = {
  385. [global.MMO.ORIENT_U] = {{-1, 0}, {-1, -1}, {0, -1}, {1, -1}, {1, 0}},
  386. [global.MMO.ORIENT_RU] = {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}},
  387. [global.MMO.ORIENT_R] = {{0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}},
  388. [global.MMO.ORIENT_RB] = {{1, -1}, {1, 0}, {1, 1}, {0, 1},{-1, 1}},
  389. [global.MMO.ORIENT_B] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},{0, -1}},
  390. [global.MMO.ORIENT_LB] = {{1, 1}, {0, 1}, {-1, 1}, {-1, 0},{-1, -1}},
  391. [global.MMO.ORIENT_L] = {{0, 1}, {-1, 1}, {-1, 0}, {-1, -1},{0, -1}},
  392. [global.MMO.ORIENT_LU] = {{-1, 1}, {-1, 0}, {-1, -1}, {0, -1},{1, -1}}
  393. }
  394. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  395. local pmapX = mainPlayer:GetMapX()
  396. local pmapY = mainPlayer:GetMapY()
  397. local mainPlayerDir = mainPlayer:GetDirection()
  398. local count = 0
  399. local targetID = target:GetID()
  400. local isTargetAround = false
  401. local aroundT = targetID and around[mainPlayerDir] or {}
  402. for k, v in pairs(aroundT) do
  403. local monsters = global.actorManager:GetMonsterActorByMapXY(pmapX + v[1], pmapY + v[2], true)
  404. if monsters then
  405. for i, mon in ipairs(monsters) do
  406. if proxyUtils.checkLaunchTargetByID(mon:GetID()) and
  407. skillProxy:CheckIgnoreMon(skillID, mon:GetTypeIndex()) then
  408. count = count + 1
  409. if not isTargetAround then
  410. isTargetAround = targetID == mon:GetID()
  411. end
  412. end
  413. end
  414. end
  415. if not isTargetAround or count < 2 then
  416. local players = global.actorManager:GetPlayerActorByMapXY(pmapX + v[1], pmapY + v[2], true)
  417. if players then
  418. for i, player in ipairs(players) do
  419. if proxyUtils.checkLaunchTargetByID(player:GetID()) and
  420. skillProxy:CheckIgnoreMon(skillID, player:GetTypeIndex()) then
  421. count = count + 1
  422. if not isTargetAround then
  423. isTargetAround = targetID == player:GetID()
  424. end
  425. end
  426. end
  427. end
  428. end
  429. if count >= 2 and isTargetAround then
  430. break
  431. end
  432. end
  433. if not isTargetAround then
  434. count = 0
  435. end
  436. -- 自动打开/关闭
  437. if CHECK_SETTING(SLDefine.SETTINGID.SETTING_IDX_SMART_BANYUE) == 1 then
  438. local isOnSkill = skillProxy:IsOnSkill(skillID)
  439. if isOnSkill and count < 2 then
  440. skillProxy:SkillOff(skillID)
  441. return nil
  442. elseif not isOnSkill and count >= 2 then
  443. skillProxy:SkillOn(skillID)
  444. return nil
  445. end
  446. end
  447. return count >= 2 and skillID or nil, target and cc.p(target:GetMapX(), target:GetMapY()) or nil, false
  448. end,
  449. -- 群体治愈术
  450. [SKILL_ID_QTZhiYuShu] = function(target)
  451. local skillID = SKILL_ID_QTZhiYuShu
  452. if not target then
  453. return nil
  454. end
  455. if proxyUtils.checkEnemyTag(target) == 1 then
  456. return nil
  457. end
  458. return skillID
  459. end,
  460. -- 刺杀
  461. [SKILL_ID_CiSha] = function(target)
  462. local skillID = SKILL_ID_CiSha
  463. if target then
  464. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  465. local monsterID = target:GetTypeIndex()
  466. if not skillProxy:CheckAbleToAttack(skillID, monsterID) then
  467. return nil
  468. end
  469. end
  470. return skillID
  471. end
  472. }
  473. -- 检测技能内挂开关
  474. skillUtils.checkAutoSetting = function(skillID)
  475. local settingID = nil
  476. if skillID and skillID > 1000 then --自定义技能
  477. settingID = 10000 + skillID
  478. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  479. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  480. local config = skillProxy:FindConfigBySkillID(skillID)
  481. if (config and config.skilltype == 4) or GameSettingProxy:GetConfigByID(settingID) == nil then
  482. settingID = nil
  483. end
  484. else
  485. settingID = AUTO_SETTING_KEY_VALUE[skillID]
  486. end
  487. if not settingID then
  488. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  489. settingID = skillProxy:GetMagicSettingID(skillID)
  490. end
  491. if not settingID then
  492. return true
  493. end
  494. return CHECK_SETTING(settingID) == 1
  495. end
  496. -- 检测技能释放
  497. skillUtils.checkSkillLaunch = function(skillID, target, isNotCheckSetting)
  498. if not isNotCheckSetting and not skillUtils.checkAutoSetting(skillID) then
  499. return nil
  500. end
  501. local destPos = nil
  502. local checkSkill = skillUtils.CHECK_SKILL[skillID]
  503. if checkSkill then
  504. local skillIDT, destPosT = checkSkill(target)
  505. if not skillIDT then
  506. return nil
  507. end
  508. destPos = destPosT
  509. end
  510. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  511. if skillID and skillProxy:CheckAbleToLaunch(skillID) ~= 1 then
  512. return nil
  513. end
  514. return skillID, destPos
  515. end
  516. -- 检测自动战斗技能释放
  517. skillUtils.checkAbleToAutoLaunch = function(skillID, target, multiJob)
  518. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  519. local PlayerProperty = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  520. local roleJob = PlayerProperty:GetRoleJob()
  521. if multiJob and roleJob ~= global.MMO.ACTOR_PLAYER_JOB_FIGHTER and roleJob ~= global.MMO.ACTOR_PLAYER_JOB_WIZZARD and roleJob ~= global.MMO.ACTOR_PLAYER_JOB_TAOIST then
  522. else
  523. if not skillUtils.checkAutoSetting(skillID) then
  524. return nil
  525. end
  526. end
  527. local skillID, destPos = skillUtils.checkSkillLaunch(skillID, target)
  528. if not skillID then
  529. return nil
  530. end
  531. if target then
  532. local monsterID = target:GetTypeIndex()
  533. if not skillProxy:CheckAbleToAttack(skillID, monsterID) then
  534. return nil
  535. end
  536. end
  537. -- 召唤
  538. local config = skillProxy:FindConfigBySkillID(skillID)
  539. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  540. if config and config.skilltype == 4 and not SummonsProxy:canSummons(skillID) then
  541. return nil
  542. end
  543. -- 根据模式来确定是否判断符毒
  544. -- (0:穿戴,1:背包,2:无)
  545. local MapProxy = global.Facade:retrieveProxy( global.ProxyTable.Map )
  546. local AssistProxy = global.Facade:retrieveProxy( global.ProxyTable.AssistProxy )
  547. local skillAmuleType = MapProxy:GetUseAmuletType()
  548. -- 无
  549. if not skillAmuleType or skillAmuleType == 2 then
  550. return skillID, destPos
  551. end
  552. if (skillAmuleType == 0 or skillAmuleType == 1) and (AssistProxy:checkDressEquipSkillID(skillID) or AssistProxy:checkBagEquipSkillID(skillID)) then
  553. return skillID, destPos
  554. end
  555. return nil
  556. end
  557. -- 飞行技能被阻挡
  558. skillUtils.checkSkillBlocked = function(skillID, srcPos, dstPos)
  559. if not (skillID == 1 or skillID == 5 or skillID == 13) then
  560. return false
  561. end
  562. if srcPos.x == dstPos.x and srcPos.y == dstPos.y then
  563. return false
  564. end
  565. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  566. if not inputProxy:GetTargetID() then
  567. return false
  568. end
  569. local isMiss = inputProxy:GetTargetID() == global.GameActorSkillController:getHitMissUserID()
  570. global.GameActorSkillController:resetHitMissUserID()
  571. return isMiss
  572. end
  573. skillUtils.checkTarget = function(skillID)
  574. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  575. local SkillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  576. local targetID = inputProxy:GetTargetID()
  577. if nil == targetID then
  578. return nil, nil
  579. end
  580. local targetActor = global.actorManager:GetActor(targetID)
  581. if nil == targetActor then
  582. return nil, nil
  583. end
  584. -- 是否是增益技能
  585. if skillID and SkillProxy:IsAdditionSkill(skillID) then
  586. -- 是友方
  587. if proxyUtils.checkMemberByID(targetID) then
  588. return targetID, targetActor
  589. end
  590. return nil, nil
  591. end
  592. -- 是否可攻击
  593. if false == proxyUtils.checkLaunchTarget(targetActor) then
  594. return nil, nil
  595. end
  596. return targetID, targetActor
  597. end
  598. -- 检测目标范围群怪
  599. skillUtils.checkTargetNeighbors = function(target, count)
  600. -- body
  601. if not target or target:IsDie() or target:IsDeath() then
  602. return {}
  603. end
  604. local neighbors = {}
  605. local mapX = target:GetMapX()
  606. local mapY = target:GetMapY()
  607. local targetID = target:GetID()
  608. local around = {{1, 0}, {1, 1}, {1, -1}, {-1, 0}, {-1, 1}, {-1, -1}, {0, 1}, {0, -1}, {0, 0}}
  609. for i, v in ipairs(around) do
  610. if count and #neighbors >= count then
  611. break
  612. end
  613. if target:IsMonster() then
  614. local monsters = global.actorManager:GetMonsterActorByMapXY(mapX + v[1], mapY + v[2], true)
  615. if monsters then
  616. for i, _mon in ipairs(monsters) do
  617. if targetID ~= _mon:GetID() and true == proxyUtils.checkAutoTargetEnableByID(_mon:GetID()) then
  618. table.insert(neighbors, _mon)
  619. end
  620. end
  621. end
  622. elseif target:IsPlayer() then
  623. local players = global.actorManager:GetPlayerActorByMapXY(mapX + v[1], mapY + v[2], true)
  624. if players then
  625. for i, _player in ipairs(players) do
  626. if targetID ~= _player:GetID() and target:GetType() == _player:GetType() and true ==
  627. proxyUtils.checkAutoTargetEnableByID(_player:GetID()) then
  628. table.insert(neighbors, _player)
  629. end
  630. end
  631. end
  632. end
  633. end
  634. return neighbors
  635. end
  636. --------------------------- 技能检测 end -------------------------------
  637. -- 自动找目标,只会找可攻击的
  638. skillUtils.findTarget = function()
  639. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  640. local targetID = inputProxy:GetTargetID()
  641. -- auto select monster
  642. if not targetID then
  643. global.Facade:sendNotification(global.NoticeTable.AutoFindPlayer)
  644. targetID = inputProxy:GetTargetID()
  645. end
  646. -- auto select player
  647. if not targetID then
  648. local sData = {}
  649. sData.type = global.MMO.ACTOR_PLAYER
  650. sData.imgNotice = false
  651. sData.systemTips = false
  652. global.Facade:sendNotification(global.NoticeTable.QuickSelectTarget, sData)
  653. end
  654. -- found
  655. if nil == inputProxy:GetTargetID() then
  656. return nil, nil
  657. end
  658. -- 2.check target actor
  659. local targetActor = global.actorManager:GetActor(inputProxy:GetTargetID())
  660. if nil == targetActor then
  661. return nil, nil
  662. end
  663. return inputProxy:GetTargetID(), targetActor
  664. end
  665. -- 技能释放位置
  666. skillUtils.findBestLaunchPos = function(skillID, targetID, srcX, srcY, dstX, dstY)
  667. if not skillID then
  668. return srcX, srcY, srcX, srcY
  669. end
  670. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  671. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  672. local minLaunchDis = skillProxy:GetMinDistance(skillID)
  673. local maxLaunchDis = skillProxy:GetMaxDistance(skillID)
  674. local launchBestX = srcX
  675. local launchBestY = srcY
  676. local moveBestX = srcX
  677. local moveBestY = srcY
  678. if skillProxy:IsLineSlopeSkill(skillID) then
  679. if not (srcX == dstX and srcY == dstY and targetID == nil) then
  680. launchBestX, launchBestY = inputProxy:FindBestAttackPos(srcX, srcY, dstX, dstY, maxLaunchDis, minLaunchDis)
  681. moveBestX = launchBestX
  682. moveBestY = launchBestY
  683. if skillID == SKILL_ID_CiSha then
  684. elseif targetID then
  685. local target = global.actorManager:GetActor(targetID)
  686. if target and (target:IsPlayer() and target:GetAction() == global.MMO.ACTION_WALK) then
  687. local srcPos = cc.p(target:GetMapX(), target:GetMapY())
  688. local moveDir = target:GetDirection()
  689. local moveStep = 1
  690. local destPos = global.PathFindController:FindDestPosJoystick(srcPos, moveDir, moveStep)
  691. if destPos then
  692. moveBestX, moveBestY = inputProxy:FindBestAttackPos(srcX, srcY, destPos.x, destPos.y,
  693. maxLaunchDis, minLaunchDis)
  694. end
  695. end
  696. end
  697. end
  698. else
  699. launchBestX, launchBestY = inputProxy:FindBestSkillPos(srcX, srcY, dstX, dstY, maxLaunchDis, minLaunchDis)
  700. moveBestX = launchBestX
  701. moveBestY = launchBestY
  702. -- 自动走位多走一步
  703. if minLaunchDis > 1 and (srcX ~= launchBestX or srcY ~= launchBestY) then
  704. moveBestX, moveBestY = inputProxy:FindBestSkillPos(srcX, srcY, dstX, dstY, maxLaunchDis, minLaunchDis + 1)
  705. end
  706. end
  707. return launchBestX, launchBestY, moveBestX, moveBestY
  708. end
  709. skillUtils.findRobotLaunchSkill = function()
  710. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  711. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  712. if not mainPlayerID or not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  713. return nil
  714. end
  715. local destPos = cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  716. -- 魔法盾
  717. local skillID = SKILL_ID_MoFaDun
  718. if skillUtils.checkAbleToAutoLaunch(skillID) then
  719. return skillID, destPos
  720. end
  721. -- 武力盾
  722. skillID = SKILL_ID_WuLiDun
  723. if skillUtils.checkAbleToAutoLaunch(skillID) then
  724. return skillID, destPos
  725. end
  726. -- 道力盾
  727. skillID = SKILL_ID_DaoLiDun
  728. if skillUtils.checkAbleToAutoLaunch(skillID) then
  729. return skillID, destPos
  730. end
  731. -- 幽灵盾
  732. skillID = SKILL_ID_YouLingDun
  733. if skillUtils.checkAbleToAutoLaunch(skillID) then
  734. return skillID, destPos
  735. end
  736. -- 神圣战甲术
  737. skillID = SKILL_ID_SSZhanJia
  738. if skillUtils.checkAbleToAutoLaunch(skillID) then
  739. return skillID, destPos
  740. end
  741. -- 自动隐身术
  742. skillID = SKILL_ID_YinShenShu
  743. if skillUtils.checkAbleToAutoLaunch(skillID) then
  744. return skillID, destPos
  745. end
  746. -- 自动无极真气
  747. skillID = SKILL_ID_WuJiZhenQi
  748. if skillUtils.checkAbleToAutoLaunch(skillID) then
  749. return skillID, destPos
  750. end
  751. -- 自动招怪
  752. if CHECK_SETTING(global.MMO.SETTING_IDX_AUTO_SUMMON) == 1 then
  753. local value = GET_SETTING(global.MMO.SETTING_IDX_AUTO_SUMMON)
  754. local value1 = value[1]
  755. skillID = value[2]
  756. if value1 == 1 and skillID then
  757. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  758. local newAutoSummon = SL:GetMetaValue("SERVER_OPTION", "CallMobSet")
  759. if newAutoSummon and skillID == -1 then
  760. skillID = SummonsProxy:autoSummon()
  761. if skillID ~= -1 then
  762. return skillID,destPos
  763. end
  764. else
  765. if skillUtils.checkAbleToAutoLaunch(skillID) and SummonsProxy:canSummons(skillID) then
  766. return skillID, destPos
  767. end
  768. end
  769. end
  770. end
  771. -- 自动治愈术
  772. if CHECK_SETTING(global.MMO.SETTING_IDX_HP_LOW_USE_SKILL) == 1 then
  773. local value = GET_SETTING(global.MMO.SETTING_IDX_HP_LOW_USE_SKILL)
  774. local value2 = value[2]
  775. skillID = tonumber(value[3])
  776. local PlayerProperty = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  777. if value2 and tonumber(value2) and skillID and PlayerProperty:GetRoleHPPercent() <= value2 then
  778. if skillID and skillUtils.checkAbleToAutoLaunch(skillID) then
  779. return skillID, destPos
  780. end
  781. end
  782. end
  783. return nil
  784. end
  785. skillUtils.findFirstLaunchSkill = function()
  786. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  787. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  788. return nil
  789. end
  790. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  791. local skillID, destPos, stamp = autoProxy:GetLaunchFirstSkill()
  792. if not skillID then
  793. return nil
  794. end
  795. local skillProxy = global.Facade:retrieveProxy( global.ProxyTable.Skill )
  796. if not (skillProxy:CheckAbleToLaunch(skillID) == 1) then
  797. return nil
  798. end
  799. autoProxy:ClearLaunchFirstSkill()
  800. if stamp and GetServerTime() - stamp > 2 then
  801. return nil
  802. end
  803. return skillID, destPos
  804. end
  805. -- 闪避
  806. skillUtils.findAvoidDangerSkill = function()
  807. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  808. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  809. return nil
  810. end
  811. if mainPlayer:GetJobID() == global.MMO.ACTOR_PLAYER_JOB_FIGHTER then
  812. return nil
  813. end
  814. -- 未开启自动走位
  815. if CHECK_SETTING(global.MMO.SETTING_IDX_AUTO_MOVE) ~= 1 then
  816. return nil
  817. end
  818. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  819. local avoidStamp = autoProxy:GetLaunchAvoidStamp()
  820. if GetServerTime() - avoidStamp < 3 then
  821. return nil
  822. end
  823. -- 检测躲避怪
  824. local around = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}
  825. local pMapX = mainPlayer:GetMapX()
  826. local pMapY = mainPlayer:GetMapY()
  827. local avoidMonster = false
  828. for i, v in ipairs(around) do
  829. local monsters = global.actorManager:GetMonsterActorByMapXY(pMapX + v[1], pMapY + v[2], true)
  830. if monsters then
  831. for k, mon in pairs(monsters) do
  832. if proxyUtils.checkAutoTargetEnableByID(mon:GetID()) then
  833. avoidMonster = true
  834. break
  835. end
  836. end
  837. if avoidMonster then
  838. break
  839. end
  840. end
  841. end
  842. if not avoidMonster then
  843. return nil
  844. end
  845. -- 抗拒火环 地图雷光 隐身术
  846. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  847. local autoMoveSkills = {SKILL_ID_KJHuoHuan, SKILL_ID_DYLeiGuang, SKILL_ID_YinShenShu}
  848. local launchSkill = nil
  849. for i, _skill in ipairs(autoMoveSkills) do
  850. local priority = skillProxy:GetPriorityBySkillID(_skill)
  851. if priority > 0 and skillUtils.checkSkillLaunch(_skill) then
  852. launchSkill = _skill
  853. break
  854. end
  855. end
  856. return launchSkill, launchSkill and cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY()) or nil
  857. end
  858. -- 内挂自动技能
  859. skillUtils.findAutoSettingLaunchSkill = function()
  860. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  861. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  862. return nil
  863. end
  864. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  865. local targetID = inputProxy:GetTargetID()
  866. if not targetID then
  867. return nil
  868. end
  869. local target = global.actorManager:GetActor(targetID)
  870. if not target then
  871. return nil
  872. end
  873. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  874. local distance = nil
  875. if target then
  876. distance = inputProxy:calcMapDistance(cc.p(target:GetMapX(), target:GetMapY()),
  877. cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY()))
  878. end
  879. local isGeWei = false
  880. if CHECK_SETTING(global.MMO.SETTING_IDX_MOVE_GEWEI_CISHA) == 1 or CHECK_SETTING(global.MMO.SETTING_IDX_GEWEICISHA) == 1 then
  881. isGeWei = true
  882. end
  883. -- 内挂技能
  884. --刺杀12 烈火剑法26 半月25 开天斩66 逐日56 双龙斩40 龙影剑法42 雷霆剑法43 纵横剑术81
  885. --施毒6 火墙22 寒冰掌44 噬血术57 裂神符85 死亡之眼86 冰镰术83 火焰冰36 冰霜群雨84
  886. --自动连击
  887. local skillID = nil
  888. local destPos = nil
  889. local skillIDT = nil
  890. local destPosT = nil
  891. local priority = 0
  892. local priorityT = nil
  893. -- 自定义技能
  894. local skillCount = #SETTING_SKILL
  895. local settingCustomSkills = {}
  896. local customSkill = skillProxy:GetAllCustomSkill()
  897. for k, v in pairs(customSkill) do
  898. local priority = skillProxy:GetLocalPriorityBySkillID(v)
  899. if priority > 0 and skillUtils.checkAutoSetting(v) then
  900. skillCount = skillCount + 1
  901. settingCustomSkills[skillCount] = v
  902. end
  903. end
  904. for i = 1, skillCount, 1 do
  905. local id = SETTING_SKILL[i] or settingCustomSkills[i]
  906. priority = skillProxy:GetLocalPriorityBySkillID(id)
  907. if not priorityT or (priority > priorityT) then
  908. skillIDT, destPosT = skillUtils.checkAbleToAutoLaunch(id, target)
  909. if skillIDT then
  910. if skillIDT == SKILL_ID_LieHuo and CHECK_SETTING(global.MMO.SETTING_IDX_NEAR_LIEHUO) ~= 1 then
  911. if 2 == distance and skillUtils.checkAbleToAutoLaunch(SKILL_ID_CiSha, target) then
  912. skillIDT = nil
  913. end
  914. end
  915. priorityT = priority
  916. skillID = skillIDT
  917. destPos = destPosT
  918. end
  919. end
  920. end
  921. return skillID, destPos or cc.p(target:GetMapX(), target:GetMapY())
  922. end
  923. -- 自动释放技能
  924. skillUtils.findAutoLaunchSkill = function()
  925. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  926. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  927. return nil
  928. end
  929. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  930. local targetID = inputProxy:GetTargetID()
  931. if not targetID then
  932. return nil
  933. end
  934. local target = global.actorManager:GetActor(targetID)
  935. if not target then
  936. inputProxy:ClearTarget()
  937. return nil
  938. end
  939. local targetdestPos = cc.p(target:GetMapX(), target:GetMapY())
  940. -- 自动连击
  941. local destPos = nil
  942. local skillID,destPos = skillUtils.findAutoComboLaunchSkill()
  943. if skillID then
  944. return skillID, destPos or targetdestPos or inputProxy:getCursorMapPosition()
  945. end
  946. skillID,destPos = skillUtils.findRobotLaunchSkill()
  947. if skillID then
  948. return skillID, destPos or inputProxy:getCursorMapPosition()
  949. end
  950. local srcPos = cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  951. -- 施毒术
  952. skillID,destPos = skillUtils.checkAbleToAutoLaunch(global.MMO.SKILL_INDEX_SDS, target)
  953. if skillID and not skillUtils.checkSkillBlocked(skillID, srcPos, destPos) then
  954. return skillID, destPos or inputProxy:getCursorMapPosition()
  955. end
  956. -- 火墙
  957. skillID,destPos = skillUtils.checkAbleToAutoLaunch(SKILL_ID_HuoQiang, target)
  958. if skillID and not skillUtils.checkSkillBlocked(skillID, srcPos, destPos) then
  959. return skillID, destPos or inputProxy:getCursorMapPosition()
  960. end
  961. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  962. -- 内挂 群、单体技能
  963. local neighbors = skillUtils.checkTargetNeighbors(target, 1)
  964. local isSample = not neighbors[1]
  965. local settingID = isSample and global.MMO.SETTING_IDX_AUTO_SIMPSKILL or global.MMO.SETTING_IDX_AUTO_GROUPSKILL
  966. local optionValue = GameSettingProxy:getRankData(settingID)
  967. local sttingSkills = optionValue.indexs or {}
  968. local isBlocked = false
  969. -- 单群体技能检测
  970. local isNeighbors = false
  971. local destPosT = nil
  972. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  973. for k, _skillid in ipairs(sttingSkills) do
  974. if not isNeighbors and skillProxy:IsLearned(_skillid) then --职业变更后内挂的单群体技能还没改变的情况
  975. isNeighbors = true
  976. end
  977. local isNotCheckSetting = _skillid == SKILL_ID_YinShenShu
  978. skillID,destPosT = skillUtils.checkSkillLaunch(_skillid, target, isNotCheckSetting)
  979. if skillID then
  980. destPos = destPosT
  981. if not isBlocked and skillUtils.checkSkillBlocked(skillID, srcPos, targetdestPos) then
  982. isBlocked = true
  983. end
  984. break
  985. end
  986. end
  987. if skillID then
  988. return skillID, destPos or targetdestPos or inputProxy:getCursorMapPosition()
  989. end
  990. -- 单群体施法检测开关
  991. local isSkillSN = tonumber(global.ConstantConfig.check_skill_neighbors) == 1
  992. if not isSkillSN then
  993. sttingSkills = {}
  994. end
  995. -- 自动战斗检测先检测内挂技能, 然后再检测其它技能
  996. local ngSkillPriority = 0
  997. local checkAutoNGLauncher = function(skillID, priority)
  998. if SETTING_SKILL[skillID] then
  999. return priority > ngSkillPriority, true
  1000. end
  1001. if skillID and skillID > 1000 then
  1002. local settingID = 10000 + skillID
  1003. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  1004. if GameSettingProxy:GetConfigByID(settingID) then
  1005. return priority > ngSkillPriority, true
  1006. end
  1007. end
  1008. if ngSkillPriority == 0 then
  1009. return true, false
  1010. end
  1011. return false, false
  1012. end
  1013. skillID,destPos = skillUtils.findAutoSettingLaunchSkill()
  1014. if skillID then
  1015. return skillID, destPos or targetdestPos or inputProxy:getCursorMapPosition()
  1016. end
  1017. local skills = isNeighbors and {} or skillProxy:GetSkills(true)
  1018. local priorityT = 0
  1019. local skillIDT = nil
  1020. local distance = nil
  1021. if target then
  1022. distance = inputProxy:calcMapDistance(cc.p(target:GetMapX(), target:GetMapY()),
  1023. cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY()))
  1024. end
  1025. local isGeWei = CHECK_SETTING(global.MMO.SETTING_IDX_MOVE_GEWEI_CISHA) == 1 or
  1026. CHECK_SETTING(global.MMO.SETTING_IDX_GEWEICISHA) == 1
  1027. local skillSNCount = 0
  1028. local skillSNPriorityT = 0
  1029. local skillSNSkillT = nil
  1030. local ignoreSkills = {[SKILL_ID_BanYue]=true, [SKILL_ID_ShuangLongZhan] = true, [SKILL_ID_CiSha]=true, [SKILL_ID_LieHuo]=true}
  1031. for k, v in pairs(skills) do
  1032. if not sttingSkills[v.MagicID] and not ignoreSkills[v.MagicID] then
  1033. local priority = skillProxy:GetPriorityBySkillID(v.MagicID)
  1034. local config = skillProxy:FindConfigBySkillID(v.MagicID)
  1035. local isCheckSkillSN = false
  1036. local isLuanch = not (config and config.skilltype == 4 or false)
  1037. if isSkillSN and config then
  1038. if isSample and 1 == config.skilltype then
  1039. if priority > 0 then
  1040. skillSNCount = skillSNCount + 1
  1041. end
  1042. isCheckSkillSN = true
  1043. elseif not isSample and 2 == config.skilltype then
  1044. if priority > 0 then
  1045. skillSNCount = skillSNCount + 1
  1046. end
  1047. isCheckSkillSN = true
  1048. end
  1049. end
  1050. local isMarkNGProiority = false
  1051. isLuanch,isMarkNGProiority = isLuanch and checkAutoNGLauncher(v.MagicID, priority)
  1052. if isMarkNGProiority then
  1053. priority = (priorityT or 0) + priority
  1054. end
  1055. if isLuanch and priority > 0 and ((skillSNCount == 0 and priority > priorityT) or (skillSNCount > 0 and priority > skillSNPriorityT)) then
  1056. skillIDT,destPosT = skillUtils.checkAbleToAutoLaunch(v.MagicID, target)
  1057. if skillIDT then
  1058. if not isBlocked and skillUtils.checkSkillBlocked(skillIDT, srcPos, targetdestPos) then
  1059. isBlocked = true
  1060. end
  1061. if isCheckSkillSN then
  1062. skillSNSkillT = skillIDT
  1063. skillSNPriorityT = priority
  1064. end
  1065. if isMarkNGProiority then
  1066. ngSkillPriority = priority - (priorityT or 0)
  1067. end
  1068. skillID = skillIDT
  1069. priorityT = priority
  1070. destPos = destPosT
  1071. end
  1072. end
  1073. end
  1074. end
  1075. if skillSNCount > 0 then
  1076. skillID = skillSNSkillT
  1077. end
  1078. if (not skillID or isBlocked) and skillProxy:CheckAbleToLaunch(0) == 1 then
  1079. local PlayerProperty = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  1080. local roleJob = PlayerProperty:GetRoleJob()
  1081. if roleJob == global.MMO.ACTOR_PLAYER_JOB_FIGHTER then
  1082. skillID = 0
  1083. elseif roleJob == global.MMO.ACTOR_PLAYER_JOB_WIZZARD then
  1084. local skills = not isBlocked and skillProxy:GetSkills(true, true, true) or {}
  1085. if CHECK_SETTING(global.MMO.SETTING_IDX_SKILL_NEXT_ATTACK) == 1 or isBlocked or not next(skills) then
  1086. skillID = 0
  1087. end
  1088. elseif roleJob == global.MMO.ACTOR_PLAYER_JOB_TAOIST then
  1089. local skills = not isBlocked and skillProxy:GetSkills(true, true, true) or {}
  1090. if CHECK_SETTING(global.MMO.SETTING_IDX_SKILL_NEXT_ATTACK) == 1 or isBlocked or not next(skills) then
  1091. skillID = 0
  1092. end
  1093. else
  1094. local skillSNCount = 0
  1095. local skillSNPriorityT = 0
  1096. local skillSNSkillT = nil
  1097. for k, v in pairs(skills) do
  1098. if not sttingSkills[v.MagicID] and not ignoreSkills[v.MagicID] then
  1099. local priority = skillProxy:GetPriorityBySkillID(v.MagicID)
  1100. local config = skillProxy:FindConfigBySkillID(v.MagicID)
  1101. local isCheckSkillSN = false
  1102. local isLaunch = not (config and config.skilltype == 4 or false)
  1103. if isSkillSN and config then
  1104. if isSample and 1 == config.skilltype then
  1105. if priority > 0 then
  1106. skillSNCount = skillSNCount + 1
  1107. end
  1108. isCheckSkillSN = true
  1109. elseif not isSample and 2 == config.skilltype then
  1110. if priority > 0 then
  1111. skillSNCount = skillSNCount + 1
  1112. end
  1113. isCheckSkillSN = true
  1114. end
  1115. end
  1116. if isLaunch and priority > 0 and ((skillSNCount == 0 and priority > priorityT) or (skillSNCount > 0 and priority > skillSNPriorityT)) then
  1117. skillIDT,destPosT = skillUtils.checkAbleToAutoLaunch(v.MagicID, target, config and config.job == roleJob or false)
  1118. if skillIDT then
  1119. if not isBlocked and skillUtils.checkSkillBlocked(skillIDT, srcPos, targetdestPos) then
  1120. isBlocked = true
  1121. end
  1122. if isCheckSkillSN then
  1123. skillSNSkillT = skillIDT
  1124. skillSNPriorityT = priority
  1125. end
  1126. skillID = skillIDT
  1127. priorityT = priority
  1128. destPos = destPosT
  1129. end
  1130. end
  1131. end
  1132. end
  1133. if skillSNCount > 0 then
  1134. skillID = skillSNSkillT
  1135. end
  1136. if not skillID then
  1137. skillID = SKILL_ID_PuGong
  1138. end
  1139. end
  1140. end
  1141. if not skillID or skillID == SKILL_ID_PuGong then
  1142. local newSkillID, newDestPos = skillUtils.findAttackExLaunchSkill()
  1143. if newSkillID then
  1144. skillID = newSkillID
  1145. destPos = newDestPos
  1146. end
  1147. end
  1148. return skillID, destPos or targetdestPos or inputProxy:getCursorMapPosition()
  1149. end
  1150. -- 闪避走位
  1151. skillUtils.findAvoidDangerPos = function()
  1152. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1153. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1154. return nil
  1155. end
  1156. -- 战士不生效
  1157. if mainPlayer:GetJobID() == global.MMO.ACTOR_PLAYER_JOB_FIGHTER then
  1158. return nil
  1159. end
  1160. -- 未开启自动走位
  1161. if CHECK_SETTING(global.MMO.SETTING_IDX_AUTO_MOVE) ~= 1 then
  1162. return nil
  1163. end
  1164. local mapData = global.sceneManager:GetMapData2DPtr()
  1165. if not mapData then
  1166. return nil
  1167. end
  1168. local matrixAround = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}
  1169. local pMapX = mainPlayer:GetMapX()
  1170. local pMapY = mainPlayer:GetMapY()
  1171. local mMapX = 0
  1172. local mMapY = 0
  1173. local monsterMatrix = {}
  1174. for i, v in ipairs(matrixAround) do
  1175. local monsters = global.actorManager:GetMonsterActorByMapXY(pMapX + v[1], pMapY + v[2], true)
  1176. if monsters then
  1177. for k, mon in pairs(monsters) do
  1178. if proxyUtils.checkAutoTargetEnableByID(mon:GetID()) then
  1179. mMapX = mon:GetMapX()
  1180. mMapY = mon:GetMapY()
  1181. monsterMatrix[mMapX] = monsterMatrix[mMapX] or {}
  1182. monsterMatrix[mMapX][mMapY] = mon
  1183. end
  1184. end
  1185. end
  1186. end
  1187. if not next(monsterMatrix) then
  1188. return nil
  1189. end
  1190. local mapRows = mapData:getMapDataRows()
  1191. local mapCols = mapData:getMapDataCols()
  1192. local around = {{pMapX + 1, pMapY}, -- right
  1193. {pMapX, pMapY + 1}, -- bottom
  1194. {pMapX - 1, pMapY}, -- left
  1195. {pMapX, pMapY - 1}, -- top
  1196. {pMapX + 1, pMapY - 1}, -- right up
  1197. {pMapX + 1, pMapY + 1}, -- right bottom
  1198. {pMapX - 1, pMapY + 1}, -- left bottom
  1199. {pMapX - 1, pMapY - 1} -- left top
  1200. }
  1201. local avoidDangerPos = nil
  1202. for _, p in ipairs(around) do
  1203. if p[1] < 0 or p[1] >= mapCols or p[2] < 0 or p[2] >= mapRows then
  1204. elseif mapData:isObstacle(p[1], p[2]) == 1 then
  1205. elseif monsterMatrix[p[1]] and monsterMatrix[p[1]][p[2]] then
  1206. else
  1207. avoidDangerPos = cc.p(p[1], p[2])
  1208. break
  1209. end
  1210. end
  1211. return avoidDangerPos
  1212. end
  1213. -- 自动连击
  1214. skillUtils.findAutoComboLaunchSkill = function()
  1215. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1216. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1217. return nil
  1218. end
  1219. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  1220. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1221. local isAttackState = global.isWinPlayMode and inputProxy:IsAttackState() or false
  1222. if not isAttackState and not autoProxy:IsAutoLockState() and not autoProxy:IsAFKState() and not autoProxy:IsAutoFightState() then
  1223. return nil
  1224. end
  1225. if tonumber(SL:GetMetaValue("GAME_DATA", "OpenNGUI")) ~= 1 then
  1226. return nil
  1227. end
  1228. if CHECK_SETTING(global.MMO.SETTING_IDX_AUTO_COMBO) ~= 1 then
  1229. return nil
  1230. end
  1231. local targetID = inputProxy:GetTargetID()
  1232. if nil == targetID then
  1233. return nil
  1234. end
  1235. local target = global.actorManager:GetActor(targetID)
  1236. if not target then
  1237. return nil
  1238. end
  1239. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  1240. if not skillProxy:GetlaunchComboStatus() then
  1241. return nil
  1242. end
  1243. local setComboSkill = skillProxy:haveSetComboSkill()
  1244. local skillID = setComboSkill and setComboSkill[1]
  1245. if not skillID then
  1246. return nil
  1247. end
  1248. local destPos = nil
  1249. skillID, destPos = skillUtils.checkAbleToAutoLaunch(skillID, target)
  1250. return skillID, destPos or inputProxy:getCursorMapPosition()
  1251. end
  1252. -- 连击技能
  1253. skillUtils.findComboLaunchSkill = function()
  1254. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1255. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1256. return nil
  1257. end
  1258. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  1259. local skillID = skillProxy:GetComboLanunchID()
  1260. local destPos = nil
  1261. local isAuto = false
  1262. if not skillID then
  1263. skillID, destPos = skillUtils.findAutoComboLaunchSkill()
  1264. isAuto = skillID and true or false
  1265. end
  1266. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1267. return skillID, destPos or inputProxy:getCursorMapPosition(), isAuto
  1268. end
  1269. -- 自定义技能
  1270. skillUtils.findAutoCustomLaunchSkill = function(priority)
  1271. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1272. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1273. return nil
  1274. end
  1275. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1276. local targetID = inputProxy:GetTargetID()
  1277. if not targetID then
  1278. return nil
  1279. end
  1280. local target = global.actorManager:GetActor(targetID)
  1281. if not target then
  1282. return nil
  1283. end
  1284. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  1285. local isProiority = CHECK_SETTING(global.MMO.SETTING_IDX_ALWAYS_ATTACK) == 1 or global.isWinPlayMode
  1286. local priorityT = priority or 0
  1287. local skillID = nil
  1288. local destPos = nil
  1289. local skillIDT = nil
  1290. local destPosT = nil
  1291. local customSkill = skillProxy:GetAllCustomSkill()
  1292. for k, v in pairs(customSkill) do
  1293. skillIDT, destPosT = skillUtils.checkSkillLaunch(v, target)
  1294. if skillIDT then
  1295. if not isProiority then
  1296. break
  1297. end
  1298. local priority = skillProxy:GetLocalPriorityBySkillID(v)
  1299. if not priorityT or priority > priorityT then
  1300. priorityT = priority
  1301. skillID, destPos = skillIDT, destPosT
  1302. end
  1303. end
  1304. end
  1305. if skillID then
  1306. return skillID, destPos or inputProxy:getCursorMapPosition()
  1307. end
  1308. return nil
  1309. end
  1310. -- 锁定释放技能
  1311. skillUtils.findLockLaunchSkill = function()
  1312. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1313. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1314. return nil
  1315. end
  1316. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1317. local targetID = inputProxy:GetTargetID()
  1318. if not targetID then
  1319. return nil
  1320. end
  1321. local target = global.actorManager:GetActor(targetID)
  1322. if not target then
  1323. return nil
  1324. end
  1325. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  1326. local distance = nil
  1327. if target then
  1328. distance = inputProxy:calcMapDistance(cc.p(target:GetMapX(), target:GetMapY()),
  1329. cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY()))
  1330. end
  1331. local isGeWei = CHECK_SETTING(global.MMO.SETTING_IDX_MOVE_GEWEI_CISHA) == 1 or
  1332. CHECK_SETTING(global.MMO.SETTING_IDX_GEWEICISHA) == 1
  1333. -- 逐日 56 开天 66 烈火 26 刺杀 12 双龙斩 40 半月 25 攻杀 7 纵横剑术 81 龙影剑法 42 雷霆剑法 43 血魄一击(战) 115 刺杀 12 普攻 0
  1334. local skills = {
  1335. SKILL_ID_ZhuRi,
  1336. SKILL_ID_KaiTian,
  1337. SKILL_ID_LieHuo,
  1338. SKILL_ID_ShuangLongZhan,
  1339. SKILL_ID_BanYue,
  1340. SKILL_ID_ZHJianShu,
  1341. SKILL_ID_LYJianFa,
  1342. SKILL_ID_LTJianFa,
  1343. SKILL_ID_XPYiJi,
  1344. SKILL_ID_CiSha,
  1345. }
  1346. local priorityT = nil
  1347. local skillID = nil
  1348. local destPos = nil
  1349. local skillIDT = nil
  1350. local destPosT = nil
  1351. for i, id in ipairs(skills) do
  1352. local priority = skillProxy:GetLocalPriorityBySkillID(id)
  1353. if not skillID and id == SKILL_ID_PuGong then
  1354. priorityT = nil
  1355. end
  1356. if not priorityT or (priority > priorityT) or (isGeWei and id == SKILL_ID_CiSha and CHECK_SETTING(global.MMO.SETTING_IDX_DAODAOCISHA) == 1) then
  1357. skillIDT, destPosT = skillUtils.checkAbleToAutoLaunch(id, target)
  1358. if skillIDT then
  1359. if skillIDT == SKILL_ID_CiSha then -- 刺杀位
  1360. if 2 == distance and skillID and (skillID ~= SKILL_ID_LieHuo or CHECK_SETTING(global.MMO.SETTING_IDX_NEAR_LIEHUO) == 1) then
  1361. break
  1362. end
  1363. if 2 ~= distance and skillID and priorityT and priority < priorityT then
  1364. break
  1365. end
  1366. end
  1367. priorityT = priority
  1368. skillID = skillIDT
  1369. destPos = destPosT
  1370. end
  1371. end
  1372. end
  1373. -- 攻杀处理
  1374. if 1 == distance and skillID == SKILL_ID_CiSha and skillProxy:IsLockTargetSkill(SKILL_ID_GongSha, true) then
  1375. local srcPos = cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  1376. local distance = inputProxy:calcMapDistance(cc.p(target:GetMapX(), target:GetMapY()), srcPos)
  1377. local newSkillID, newDestPos = skillUtils.checkSkillLaunch(SKILL_ID_GongSha, target)
  1378. if newSkillID then
  1379. skillID, destPos = newSkillID, newDestPos
  1380. end
  1381. end
  1382. local newSkillID, newDestPos = skillUtils.findAutoCustomLaunchSkill(priorityT)
  1383. if newSkillID then
  1384. skillID = newSkillID
  1385. destPos = newDestPos
  1386. end
  1387. if not skillID and skillUtils.checkSkillLaunch(SKILL_ID_GongSha) then
  1388. skillID = SKILL_ID_GongSha
  1389. end
  1390. if not skillID and skillUtils.checkSkillLaunch(SKILL_ID_PuGong) then
  1391. skillID = SKILL_ID_PuGong
  1392. end
  1393. return skillID, destPos or inputProxy:getCursorMapPosition()
  1394. end
  1395. skillUtils.findSimpleLaunchSkill = function()
  1396. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1397. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1398. return nil
  1399. end
  1400. -- 自动连击
  1401. local skillID, destPos = skillUtils.findAutoComboLaunchSkill()
  1402. if skillID then
  1403. return skillID, destPos
  1404. end
  1405. -- 自动释放技能
  1406. skillID, destPos = skillUtils.findRobotLaunchSkill()
  1407. if skillID then
  1408. return skillID, destPos
  1409. end
  1410. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  1411. skillID = autoProxy:GetAutoLockSkillID()
  1412. if not skillID then
  1413. return nil
  1414. end
  1415. -- 普攻
  1416. skillID, destPos = skillUtils.findAutoSettingLaunchSkill()
  1417. if not skillID then
  1418. skillID, destPos = skillUtils.findAutoCustomLaunchSkill()
  1419. end
  1420. if skillID then
  1421. return skillID, destPos
  1422. end
  1423. skillID, destPos = skillUtils.findAttackExLaunchSkill()
  1424. if skillID then
  1425. return skillID, destPos
  1426. end
  1427. skillID = autoProxy:GetAutoLockSkillID()
  1428. if skillID == SKILL_ID_PuGong and skillUtils.checkSkillLaunch(SKILL_ID_GongSha) then
  1429. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1430. return SKILL_ID_GongSha, inputProxy:getCursorMapPosition()
  1431. end
  1432. if skillID and skillUtils.checkSkillLaunch(skillID) then
  1433. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1434. return skillID, inputProxy:getCursorMapPosition()
  1435. end
  1436. local isPugong = CHECK_SETTING(global.MMO.SETTING_IDX_SKILL_NEXT_ATTACK) == 1
  1437. if isPugong and skillUtils.checkSkillLaunch(SKILL_ID_PuGong) then
  1438. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1439. return SKILL_ID_PuGong, inputProxy:getCursorMapPosition()
  1440. end
  1441. return nil
  1442. end
  1443. skillUtils.findAttackExLaunchSkill = function(target)
  1444. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1445. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1446. return nil
  1447. end
  1448. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1449. local targetID = inputProxy:GetTargetID()
  1450. local target = nil
  1451. if targetID then
  1452. target = global.actorManager:GetActor(targetID)
  1453. end
  1454. -- 半月
  1455. local skillID, destPos = skillUtils.checkAbleToAutoLaunch(SKILL_ID_BanYue, target)
  1456. if not skillID then
  1457. skillID, destPos = skillUtils.checkAbleToAutoLaunch(SKILL_ID_ShuangLongZhan, target)
  1458. end
  1459. if not skillID then
  1460. skillID, destPos = skillUtils.checkAbleToAutoLaunch(SKILL_ID_CiSha)
  1461. local distance = nil
  1462. if target then
  1463. distance = inputProxy:calcMapDistance(cc.p(target:GetMapX(), target:GetMapY()),
  1464. cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY()))
  1465. end
  1466. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  1467. -- 攻杀处理
  1468. if 1 == distance and skillID == SKILL_ID_CiSha and skillProxy:IsLockTargetSkill(SKILL_ID_GongSha, true) then
  1469. local srcPos = cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  1470. local distance = inputProxy:calcMapDistance(cc.p(target:GetMapX(), target:GetMapY()), srcPos)
  1471. local newSkillID, newDestPos = skillUtils.checkSkillLaunch(SKILL_ID_GongSha, target)
  1472. if newSkillID then
  1473. skillID, destPos = newSkillID, newDestPos
  1474. end
  1475. end
  1476. end
  1477. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1478. return skillID, destPos or inputProxy:getCursorMapPosition()
  1479. end
  1480. skillUtils.findAttackLaunchSkill = function()
  1481. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1482. if not mainPlayer or mainPlayer:IsDie() or mainPlayer:IsDeath() then
  1483. return nil
  1484. end
  1485. -- 刺杀
  1486. local skillID, destPos = skillUtils.checkSkillLaunch(SKILL_ID_CiSha)
  1487. if not skillID then
  1488. -- 普攻
  1489. skillID, destPos = skillUtils.checkSkillLaunch(SKILL_ID_PuGong)
  1490. end
  1491. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1492. return skillID, destPos or inputProxy:getCursorMapPosition()
  1493. end
  1494. -- 技能优先级检测
  1495. skillUtils.findSkills = function(skilltype, filterJob, filterLearned, noBasic)
  1496. local PlayerProperty = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  1497. local SkillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  1498. local roleJob = PlayerProperty:GetRoleJob()
  1499. local allSkills = SkillProxy:FindAllSkillsByJob(filterJob)
  1500. local items = {}
  1501. for i, v in ipairs(allSkills) do
  1502. if (v.MagicID ~= 0 or not noBasic) and (skilltype == -1 or v.skilltype == skilltype) and
  1503. (filterJob == 3 or roleJob == filterJob) then
  1504. if (not filterLearned or (SkillProxy:IsLearned(v.MagicID) and not SkillProxy:IsComboSkill(v.MagicID))) then
  1505. items[v.MagicID] = v
  1506. end
  1507. end
  1508. end
  1509. return items
  1510. end
  1511. return skillUtils