AutoFightBeginCommand.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. local AutoFightBeginCommand = class('AutoFightBeginCommand', framework.SimpleCommand)
  2. function AutoFightBeginCommand:ctor()
  3. end
  4. function AutoFightBeginCommand:execute(notification)
  5. local facade = global.Facade
  6. local priority = notification:getBody()
  7. local autoProxy = facade:retrieveProxy( global.ProxyTable.Auto )
  8. local inputProxy = facade:retrieveProxy( global.ProxyTable.PlayerInputProxy )
  9. priority = priority and priority or autoProxy:GetAutoInputPriority()
  10. print("---------------------- auto fight begin")
  11. -- clear all state
  12. facade:sendNotification(global.NoticeTable.ClearAllInputState)
  13. facade:sendNotification(global.NoticeTable.ClearAllAutoState)
  14. facade:sendNotification(global.NoticeTable.InputIdle)
  15. autoProxy:ClearAllState()
  16. autoProxy:SetAutoInputPriority( priority )
  17. -- set auto fight default target
  18. if global.MMO.ACTOR_NONE == autoProxy:GetTargetType() then
  19. autoProxy:SetTargetType( global.MMO.ACTOR_MONSTER )
  20. end
  21. -- auto target state:running
  22. if global.MMO.ACTOR_NPC == autoProxy:GetTargetType() then
  23. autoProxy:SetTargetState( global.MMO.AUTO_TARGET_STATE_RUNNING )
  24. end
  25. -- tips
  26. if not autoProxy:IsAutoFightState() then -- must confirm state
  27. autoProxy:SetIsAutoFightState( true )
  28. if autoProxy:IsTargetTypeLaunchEnable() then
  29. SLBridge:onLUAEvent(LUA_EVENT_AUTOFIGHT_TIPS_SHOW, true)
  30. end
  31. end
  32. -- auto on skill banyue
  33. local SkillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  34. if not SkillProxy:IsOnSkill(25) and CHECK_SETTING(18) == 1 then
  35. SkillProxy:RequestSkillOnoff(25)
  36. end
  37. local SkillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  38. if not SkillProxy:IsOnSkill(12) and CHECK_SETTING(15) == 1 then
  39. SkillProxy:RequestSkillOnoff(12)
  40. end
  41. if autoProxy:GetTargetType() == global.MMO.ACTOR_MONSTER then
  42. -- 通知自动挂机开始(引擎会检测脚本)
  43. autoProxy:RequestNoticeBeginAFK()
  44. end
  45. end
  46. return AutoFightBeginCommand