AutoProxy.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local AutoProxy = class("AutoProxy", RemoteProxy)
  3. AutoProxy.NAME = global.ProxyTable.Auto
  4. local ResetFightInterval = 2 -- reset _tryExitFight 时间间隔
  5. local function init_target()
  6. local target =
  7. {
  8. x = nil,
  9. y = nil,
  10. mapID = nil,
  11. targetIndex = global.MMO.AUTO_FIND_TARGET_NONE, -- current auto fight target type_index
  12. targetType = global.MMO.ACTOR_NONE, -- current auto fight target type
  13. autoMoveType= global.MMO.AUTO_MOVE_TYPE_TARGET,
  14. }
  15. return target
  16. end
  17. function AutoProxy:ctor()
  18. AutoProxy.super.ctor(self)
  19. local Queue = requireUtil("queue")
  20. ----------- state ------------------------
  21. self._afkState = false -- 是否在挂机状态
  22. self._randStoneAFKFlag = false -- 随机石否继续挂机状态
  23. self._pickState = false -- 是否自动捡物状态
  24. self._fightState = false -- 是否自动战斗
  25. self._moveState = false -- 是否自动寻路
  26. self._lockState = false -- 是否锁定目标
  27. self._inputPriority = global.MMO.INPUT_PRIORITY_SYSTEM -- input priority
  28. ------------------------------------------
  29. ----------- move queue ------------------
  30. self._moveQueue = Queue.new() -- move queue
  31. ------------------------------------------
  32. ----------- auto fight state -------------
  33. self._target = init_target() -- trace current target( index/type/priority/pos...)
  34. self._interruptFlag = false -- interrupt flag
  35. self._tryExitFight = 0 -- try to exit auto fight
  36. self._findTargetState = global.MMO.AUTO_TARGET_STATE_END -- find target state
  37. self._afkTargetDeath = false
  38. ------------------------------------------
  39. ----------- auto pick target -------------
  40. self._pickFlag = false -- 是否有掉落物
  41. self._pickItemID = nil -- current pick item ID
  42. self._pickBeginT = nil -- current pick begin time
  43. ------------------------------------------
  44. ----------- launch first -----------------
  45. self._launchFirstSkillID = nil -- 下次自动释放技能 优先释放的skillID
  46. self._launchFirstPos = nil
  47. self._launchFirstStamp = nil
  48. ------------------------------------------
  49. ---------- launch lock skill -------------
  50. self._launchAutoLockSkillID = nil
  51. ------------------------------------------
  52. ---------- launch avoid skill ------------
  53. self._launchAvoidStamp = 0
  54. ------------------------------------------
  55. ---------- auto mining -------------------
  56. self._autoMiningDir = nil -- 自动挖矿
  57. self._autoMiningDst = nil -- 自动挖矿
  58. ------------------------------------------
  59. ----------- launch du -------------------
  60. self._duTimes = 0 -- 施毒次数
  61. self._duStamp = nil -- 检测结束时间戳
  62. ------------------------------------------
  63. ---------- auto juling -------------------
  64. self._autoJuling = false -- 是否自动检测聚灵珠满使用
  65. ------------------------------------------
  66. end
  67. function AutoProxy:GetAutoInputPriority()
  68. return self._inputPriority
  69. end
  70. function AutoProxy:SetAutoInputPriority(type)
  71. self._inputPriority = type
  72. end
  73. ----------- auto move -------------
  74. function AutoProxy:IsAutoMoveState()
  75. return self._moveState
  76. end
  77. function AutoProxy:SetIsAutoMoveState(state)
  78. self._moveState = state
  79. end
  80. function AutoProxy:GetMoveQueueSize()
  81. return self._moveQueue:size()
  82. end
  83. -- queue back
  84. function AutoProxy:PushMove(pos)
  85. self._moveQueue:push(pos)
  86. end
  87. function AutoProxy:PopMove()
  88. if self._moveQueue:empty() then
  89. return nil
  90. end
  91. return self._moveQueue:pop()
  92. end
  93. function AutoProxy:IsMoveCompleted()
  94. return self._moveQueue:empty()
  95. end
  96. function AutoProxy:ClearAutoMove()
  97. self:SetIsAutoMoveState(false)
  98. self._moveQueue:clear()
  99. end
  100. ----------- auto move end -------------
  101. ----------- auto fight -------------
  102. function AutoProxy:IsAFKState()
  103. return self._afkState
  104. end
  105. function AutoProxy:SetIsAFKState(state)
  106. self._afkState = state
  107. local DataTrackProxy = global.Facade:retrieveProxy(global.ProxyTable.DataTrackProxy)
  108. DataTrackProxy:OnExpandInfoChanage()
  109. end
  110. function AutoProxy:ClearAFKState()
  111. if self:IsAFKState() then
  112. self:SetIsAFKState(false)
  113. self:RequestNoticeIntteruptAFK()
  114. SLBridge:onLUAEvent(LUA_EVENT_AFKEND)
  115. end
  116. end
  117. function AutoProxy:IsPickState()
  118. return self._pickState
  119. end
  120. function AutoProxy:SetIsPickState(state)
  121. self._pickState = state
  122. --
  123. if self._pickState then
  124. global.Facade:sendNotification(global.NoticeTable.AutoPickBeginTips)
  125. SLBridge:onLUAEvent(LUA_EVENT_AUTOPICK_TIPS_SHOW, true)
  126. SLBridge:onLUAEvent(LUA_EVENT_AUTOPICKBEGIN)
  127. end
  128. end
  129. function AutoProxy:ClearPickState()
  130. if self:IsPickState() then
  131. self:SetIsPickState(false)
  132. --
  133. global.Facade:sendNotification(global.NoticeTable.AutoPickEndTips)
  134. SLBridge:onLUAEvent(LUA_EVENT_AUTOPICK_TIPS_SHOW, false)
  135. SLBridge:onLUAEvent(LUA_EVENT_AUTOPICKEND)
  136. end
  137. end
  138. function AutoProxy:GetRandStoneAFKFlag()
  139. return self._randStoneAFKFlag
  140. end
  141. function AutoProxy:SetRandStoneAFKFlag(flag)
  142. self._randStoneAFKFlag = flag
  143. if self._randStoneTimerID then
  144. UnSchedule(self._randStoneTimerID)
  145. self._randStoneTimerID = nil
  146. end
  147. if self._randStoneAFKFlag then
  148. self._randStoneTimerID = PerformWithDelayGlobal(function()
  149. self._randStoneAFKFlag = false
  150. self._randStoneTimerID = nil
  151. end, 2)
  152. end
  153. end
  154. function AutoProxy:IsAutoFightState()
  155. return self._fightState
  156. end
  157. function AutoProxy:SetIsAutoFightState(state)
  158. if self._fightState == state then
  159. return
  160. end
  161. self._fightState = state
  162. end
  163. function AutoProxy:SetTargetType(t)
  164. self._target.targetType = t
  165. end
  166. function AutoProxy:GetTargetType()
  167. return self._target.targetType
  168. end
  169. function AutoProxy:SetTargetIndex(index)
  170. self._target.targetIndex = index
  171. end
  172. function AutoProxy:GetTargetIndex()
  173. return self._target.targetIndex
  174. end
  175. function AutoProxy:SetTargetState(state)
  176. self._findTargetState = state
  177. end
  178. function AutoProxy:GetTargetState()
  179. return self._findTargetState
  180. end
  181. function AutoProxy:SetAFKTargetDeath(t)
  182. self._afkTargetDeath = t
  183. if self._afkTargetDeath then
  184. -- 挂机目标死亡
  185. if self._afkTargetDeathScheduleID then
  186. UnSchedule(self._afkTargetDeathScheduleID)
  187. self._afkTargetDeathScheduleID = nil
  188. end
  189. self._afkTargetDeathScheduleID = PerformWithDelayGlobal(function()
  190. self._afkTargetDeath = false
  191. end, 0.2)
  192. end
  193. end
  194. function AutoProxy:GetAFKTargetDeath()
  195. return self._afkTargetDeath
  196. end
  197. function AutoProxy:GetAutoTarget()
  198. return self._target
  199. end
  200. function AutoProxy:SetAutoTarget(target)
  201. if target then
  202. self._target.x = target.x
  203. self._target.y = target.y
  204. self._target.mapID = target.mapID
  205. self._target.targetType = target.targetType
  206. self._target.targetIndex = target.targetIndex
  207. self._target.priority = target.priority
  208. self._target.state = target.state
  209. self._target.autoMoveType = target.autoMoveType
  210. else
  211. self._target = init_target()
  212. end
  213. end
  214. function AutoProxy:SetAutoTargetInterruptFlag(flag)
  215. self._interruptFlag = flag
  216. end
  217. function AutoProxy:GetAutoTargetInterruptFlag()
  218. return self._interruptFlag
  219. end
  220. function AutoProxy:PauseAutoTarget()
  221. if self:GetAutoTargetInterruptFlag() then
  222. return
  223. end
  224. -- clone target
  225. local oldAutoTarget = self:GetAutoTarget()
  226. local autoTarget = clone(oldAutoTarget)
  227. oldAutoTarget.isPauseAutoTarget = true
  228. self:ClearAllState()
  229. self:SetAutoTarget(autoTarget)
  230. self:SetAutoTargetInterruptFlag(true)
  231. end
  232. function AutoProxy:ResumeAutoTarget()
  233. if not self:GetAutoTargetInterruptFlag() then
  234. return
  235. end
  236. self:SetAutoTargetInterruptFlag(false)
  237. local autoTarget = clone(self:GetAutoTarget())
  238. if autoTarget then
  239. if autoTarget.x and autoTarget.y then
  240. global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, autoTarget)
  241. elseif autoTarget.targetType ~= global.MMO.ACTOR_NONE then
  242. global.Facade:sendNotification(global.NoticeTable.AutoFightBegin, autoTarget)
  243. ssr.ssrBridge:OnAutoFightBegin()
  244. end
  245. end
  246. end
  247. function AutoProxy:IsTargetTypePickEnable(targetType)
  248. if targetType == nil then
  249. targetType = self:GetTargetType()
  250. end
  251. -- 开始自动寻找NPC时,不再处罚自动拾取
  252. local currType = self:GetTargetType()
  253. if currType == global.MMO.ACTOR_NPC then
  254. local state = self:GetTargetState()
  255. return state ~= global.MMO.AUTO_TARGET_STATE_RUNNING
  256. end
  257. return targetType ~= global.MMO.ACTOR_COLLECTION
  258. end
  259. function AutoProxy:IsTargetTypeLaunchEnable()
  260. local targetType = self:GetTargetType()
  261. return (targetType == global.MMO.ACTOR_MONSTER or targetType == global.MMO.ACTOR_PLAYER) -- 目标为 怪、人
  262. end
  263. function AutoProxy:TryExitAutoFight()
  264. if self:IsAutoFightState() then
  265. if self:IsTargetTypeLaunchEnable() then
  266. self:TimerBegan()
  267. self._tryExitFight = self._tryExitFight + 1
  268. if self._tryExitFight >= 2 then
  269. self:TimerEnded()
  270. global.Facade:sendNotification(global.NoticeTable.ClearAllInputState)
  271. global.Facade:sendNotification(global.NoticeTable.ClearAllAutoState)
  272. self:ClearAutoLock()
  273. self:ClearAllState()
  274. self:ClearAFKState()
  275. self:ClearPickState()
  276. return true
  277. else
  278. return false
  279. end
  280. else
  281. if self:IsAutoFightState() then
  282. global.Facade:sendNotification(global.NoticeTable.ClearAllInputState)
  283. global.Facade:sendNotification(global.NoticeTable.ClearAllAutoState)
  284. self:ClearAutoLock()
  285. self:ClearAllState()
  286. self:ClearAFKState()
  287. self:ClearPickState()
  288. end
  289. end
  290. end
  291. return true
  292. end
  293. function AutoProxy:TimerBegan()
  294. if not self._exitFightTimerID then
  295. local function callback(delta)
  296. self._tryExitFight = 0
  297. self:TimerEnded()
  298. end
  299. self._exitFightTimerID = Schedule(callback, ResetFightInterval)
  300. end
  301. end
  302. function AutoProxy:TimerEnded()
  303. if self._exitFightTimerID then
  304. UnSchedule(self._exitFightTimerID)
  305. self._exitFightTimerID = nil
  306. end
  307. end
  308. function AutoProxy:ClearAutoTarget()
  309. self:SetIsAutoFightState(false)
  310. self:SetAutoTargetInterruptFlag(false)
  311. self:SetAutoInputPriority(global.MMO.INPUT_PRIORITY_SYSTEM)
  312. self:SetTargetState(global.MMO.AUTO_TARGET_STATE_END)
  313. self:SetAutoTarget(nil)
  314. self:TimerEnded()
  315. self._tryExitFight = 0
  316. end
  317. function AutoProxy:ClearAllState()
  318. if self:IsAutoMoveState() then
  319. global.Facade:sendNotification(global.NoticeTable.AutoMoveEnd)
  320. end
  321. if self:IsAutoFightState() then
  322. global.Facade:sendNotification(global.NoticeTable.AutoFightEnd)
  323. ssr.ssrBridge:OnAutoFightEnd()
  324. end
  325. end
  326. ----------- auto fight end -------------
  327. ----------- auto pick -------------
  328. function AutoProxy:IsCanAutoPick(targetType)
  329. return self:GetPickItemFlag() and self:IsTargetTypePickEnable(targetType)
  330. end
  331. function AutoProxy:GetPickItemFlag()
  332. return self._pickFlag
  333. end
  334. function AutoProxy:SetPickItemFlag(state)
  335. self._pickFlag = state
  336. end
  337. function AutoProxy:SetPickItemID(id)
  338. self._pickItemID = id
  339. end
  340. function AutoProxy:GetPickItemID()
  341. return self._pickItemID
  342. end
  343. function AutoProxy:SetPickBeginTime(t)
  344. self._pickBeginT = t
  345. end
  346. function AutoProxy:GetPickBeginTime()
  347. return self._pickBeginT
  348. end
  349. function AutoProxy:CheckPickTimeout()
  350. local lastPickTime = self:GetPickBeginTime()
  351. local currTime = GetServerTime()
  352. -- if pick time to long, discard current pick item
  353. if not lastPickTime then
  354. self:SetPickBeginTime(currTime)
  355. else
  356. if currTime - lastPickTime >= 3 then
  357. local itemID = self:GetPickItemID()
  358. local item = global.dropItemManager:FindDropItem(self:GetPickItemID())
  359. if item then
  360. item:SetPickTimeout()
  361. end
  362. self:SetPickItemID(nil)
  363. self:SetPickBeginTime(currTime)
  364. end
  365. end
  366. end
  367. function AutoProxy:ClearAutoPick()
  368. self:SetPickItemFlag(false)
  369. self:SetPickItemID(nil)
  370. self:SetPickBeginTime(nil)
  371. end
  372. ----------- auto pick end -------------
  373. ----------- auto lock begin -------------
  374. function AutoProxy:IsAutoLockState()
  375. return self._lockState
  376. end
  377. function AutoProxy:SetIsAutoLockState(state)
  378. self._lockState = state
  379. end
  380. function AutoProxy:GetAutoLockSkillID()
  381. return self._launchAutoLockSkillID
  382. end
  383. function AutoProxy:SetAutoLockSkillID(skillID)
  384. self._launchAutoLockSkillID = skillID
  385. end
  386. function AutoProxy:ClearAutoLock()
  387. self._lockState = false
  388. self._launchAutoLockSkillID = nil
  389. end
  390. ----------- auto lock end -------------
  391. ----------- launch first skill --------
  392. function AutoProxy:SetLaunchFirstSkill(skillID, destPos)
  393. self._launchFirstSkillID = skillID
  394. self._launchFirstPos = destPos
  395. self._launchFirstStamp = GetServerTime()
  396. end
  397. function AutoProxy:GetLaunchFirstSkill()
  398. return self._launchFirstSkillID, self._launchFirstPos, self._launchFirstStamp
  399. end
  400. function AutoProxy:ClearLaunchFirstSkill()
  401. self._launchFirstSkillID = nil
  402. self._launchFirstPos = nil
  403. self._launchFirstStamp = nil
  404. end
  405. ----------- launch first skill
  406. function AutoProxy:ResetLaunchAvoidStamp()
  407. self._launchAvoidStamp = GetServerTime()
  408. end
  409. function AutoProxy:GetLaunchAvoidStamp()
  410. return self._launchAvoidStamp
  411. end
  412. ----------- auto mining
  413. function AutoProxy:SetAutoMining(dir, dst)
  414. self._autoMiningDir = dir
  415. self._autoMiningDst = dst
  416. end
  417. function AutoProxy:GetAutoMining()
  418. return self._autoMiningDir, self._autoMiningDst
  419. end
  420. function AutoProxy:ClearAutoMining()
  421. self:SetAutoMining(nil, nil)
  422. end
  423. -------------- auto du
  424. function AutoProxy:UpdateDuTime()
  425. self._duTimes = self._duTimes + 1
  426. if self._duTimes >= 4 then
  427. self._duStamp = GetServerTime()
  428. end
  429. end
  430. function AutoProxy:CheckDu()
  431. if not self._duStamp then
  432. return true
  433. end
  434. if GetServerTime() - self._duStamp > 5 then
  435. self:ClearDu()
  436. return true
  437. end
  438. return false
  439. end
  440. function AutoProxy:ClearDu()
  441. if self._duTimes == 0 then
  442. return
  443. end
  444. self._duTimes = 0
  445. self._duStamp = nil
  446. end
  447. ----------- auto juling
  448. function AutoProxy:IsAutoUseJuling()
  449. return self._autoJuling
  450. end
  451. ----------- notice
  452. function AutoProxy:RequestNoticeBeginAFK()
  453. -- 自动战斗通知服务器
  454. LuaSendMsg(global.MsgType.MSG_CS_START_AFK)
  455. end
  456. function AutoProxy:RequestNoticeIntteruptAFK()
  457. -- 自动战斗被打断,通知服务器
  458. LuaSendMsg(global.MsgType.MSG_SC_INTTERUPT_AFK)
  459. end
  460. function AutoProxy:RequestAutoMoveNotify(act, destX, destY)
  461. -- 通知服务器自动寻路状态
  462. if act == global.MMO.AUTO_MOVE_START then
  463. LuaSendMsg(global.MsgType.MSG_CS_AUTO_MOVE_NOTIFY, act, destX, destY)
  464. else
  465. LuaSendMsg(global.MsgType.MSG_CS_AUTO_MOVE_NOTIFY, act)
  466. end
  467. end
  468. function AutoProxy:handle_MSG_SC_AFK(msg)
  469. local msgLen = msg:GetDataLength()
  470. if msgLen <= 0 then
  471. -- stop auto fight
  472. global.Facade:sendNotification(global.NoticeTable.AFKEnd)
  473. return
  474. end
  475. local moveTarget = ParseRawMsgToJson(msg)
  476. print("AFK +++++++++++++++++++++++++++++++++++++++++++")
  477. dump(moveTarget)
  478. -- stop auto fight
  479. global.Facade:sendNotification(global.NoticeTable.AFKEnd)
  480. -- check param
  481. if not moveTarget or not next(moveTarget) then
  482. return nil
  483. end
  484. global.Facade:sendNotification(global.NoticeTable.AFKBegin)
  485. end
  486. function AutoProxy:handle_MSG_SC_AUTO_FIND(msg)
  487. local jsonData = ParseRawMsgToJson( msg )
  488. -- debug
  489. print( "auto find+++++++++++++++++++++++++++++++++++++++++++" )
  490. dump(jsonData)
  491. if not jsonData or not next(jsonData) then
  492. releasePrint( "auto find error!, json" )
  493. return nil
  494. end
  495. if jsonData.T == 1 then
  496. jsonData.autoMoveType = global.MMO.AUTO_MOVE_TYPE_SERVER
  497. end
  498. global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, jsonData)
  499. -- self:SetAutoTarget(jsonData)
  500. end
  501. function AutoProxy:handle_MSG_SC_STOP_AUTO_FIND(msg)
  502. -- debug
  503. print( "stop auto find+++++++++++++++++++++++++++++++++++++++++++" )
  504. -- clear current state
  505. global.Facade:sendNotification(global.NoticeTable.ClearAllInputState)
  506. global.Facade:sendNotification(global.NoticeTable.ClearAllAutoState)
  507. self:ClearAllState()
  508. self:ClearAFKState()
  509. end
  510. function AutoProxy:handle_MSG_SC_MAP_ITEM_PICK_FAIL(msg)
  511. local header = msg:GetHeader()
  512. -- case -2: // 一定时间内无法捡(别人的东西)
  513. -- case -3: // 禁止拾取
  514. -- case -4: // 背包满
  515. -- case -5: // 最多只能拾取X个
  516. -- case -6: // 不能捡特定阵营的道具
  517. if header.recog <= -2 then
  518. self:SetPickItemID(nil)
  519. if header.recog == -5 then
  520. local tips = string.format(GET_STRING(800905), header.param1)
  521. global.Facade:sendNotification(global.NoticeTable.SystemTips, tips)
  522. else
  523. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(800900 - header.recog))
  524. end
  525. end
  526. end
  527. function AutoProxy:handle_MSG_SC_NET_PLAYER_MOVE_FAIL(msg)
  528. if not self:GetAutoTargetInterruptFlag() then
  529. if self:IsAutoFightState() or self:IsAutoMoveState() then
  530. self:PauseAutoTarget()
  531. self:ResumeAutoTarget()
  532. end
  533. end
  534. end
  535. function AutoProxy:handle_MSG_SC_PICKUP_MODE_UPDATE(msg)
  536. local header = msg:GetHeader()
  537. local visible = header.recog == 1
  538. global.Facade:sendNotification(global.NoticeTable.PickupModeUpdate, visible)
  539. end
  540. function AutoProxy:handle_MSG_SC_AUTO_MOVE(msg)
  541. local header = msg:GetHeader()
  542. local mapX = header.param1
  543. local mapY = header.param2
  544. print( "auto move ++++++++++++++++++++++++++++++" )
  545. dump(header)
  546. if header.recog == 0 then
  547. global.Facade:sendNotification(global.NoticeTable.AutoMoveEnd)
  548. end
  549. if mapX == 0 or mapY == 0 then
  550. return nil
  551. end
  552. -- 开始寻路
  553. local moveData =
  554. {
  555. x = mapX,
  556. y = mapY,
  557. autoMoveType = global.MMO.AUTO_MOVE_TYPE_SERVER
  558. }
  559. global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, moveData)
  560. end
  561. function AutoProxy:handle_MSG_SC_AUTOUSE_JULINGPEARL(msg)
  562. local header = msg:GetHeader()
  563. local isAuto = header.recog == 1
  564. local bagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  565. local ItemManagerProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemManagerProxy)
  566. local ItemUseProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemUseProxy)
  567. if self._autoJuling ~= isAuto and isAuto then
  568. self._autoJuling = isAuto
  569. local bagItems = bagProxy:GetBagData()
  570. for makeIndex, item in pairs(bagItems) do
  571. if item.StdMode == 49 and item.Dura >= item.DuraMax then
  572. global.Facade:sendNotification(global.NoticeTable.AutoUseJulingItem_Add, item)
  573. end
  574. end
  575. end
  576. self._autoJuling = isAuto
  577. end
  578. function AutoProxy:onRegister()
  579. AutoProxy.super.onRegister(self)
  580. local msgType = global.MsgType
  581. LuaRegisterMsgHandler(msgType.MSG_SC_AFK, handler(self, self.handle_MSG_SC_AFK)) -- 自动挂机
  582. LuaRegisterMsgHandler(msgType.MSG_SC_AUTO_FIND, handler(self, self.handle_MSG_SC_AUTO_FIND)) -- 自动任务
  583. LuaRegisterMsgHandler(msgType.MSG_SC_STOP_AUTO_FIND, handler(self, self.handle_MSG_SC_STOP_AUTO_FIND)) -- 自动任务停止
  584. LuaRegisterMsgHandler(msgType.MSG_SC_MAP_ITEM_PICK_FAIL, handler(self, self.handle_MSG_SC_MAP_ITEM_PICK_FAIL)) -- 拾取掉落物失败
  585. LuaRegisterMsgHandler(msgType.MSG_SC_NET_PLAYER_MOVE_FAIL, handler(self, self.handle_MSG_SC_NET_PLAYER_MOVE_FAIL)) -- 移动失败
  586. LuaRegisterMsgHandler(msgType.MSG_SC_PICKUP_MODE_UPDATE, handler(self, self.handle_MSG_SC_PICKUP_MODE_UPDATE)) -- 拾取模式
  587. LuaRegisterMsgHandler(msgType.MSG_SC_AUTO_MOVE, handler(self, self.handle_MSG_SC_AUTO_MOVE)) -- 脚本通知寻路
  588. LuaRegisterMsgHandler(msgType.MSG_SC_AUTOUSE_JULINGPEARL, handler(self, self.handle_MSG_SC_AUTOUSE_JULINGPEARL)) -- 聚灵珠满自动使用
  589. end
  590. return AutoProxy