Advertisement
Guest User

Untitled

a guest
Aug 17th, 2014
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 19.37 KB | None | 0 0
  1. ;Credits:
  2. ;Script wrote by InunoTaishou
  3.  
  4. ;######################################################################################################################################################
  5. ;#################################################Necessary AUTOIT libraries and variables#############################################################
  6. ;######################################################################################################################################################
  7. #include <Lib\ImageSearch.au3>
  8. #include <ButtonConstants.au3>
  9. #include <EditConstants.au3>
  10. #include <GUIConstantsEx.au3>
  11. #include <StaticConstants.au3>
  12. #include <WindowsConstants.au3>
  13. AutoItSetOption("WinTitleMatchMode", 2)
  14. AutoItSetOption("MouseCoordMode", 2)
  15. AutoItSetOption("SendKeyDelay", 25)
  16. AutoItSetOption("SendKeyDownDelay", 150)
  17. AutoItSetOption("PixelCoordMode", 2)
  18.  
  19. ;######################################################################################################################################################
  20. ;##########################################################Hotkeys#####################################################################################
  21. ;######################################################################################################################################################
  22. HotKeySet("{End}", "Terminate")
  23. HotKeySet("{Del}", "_Restart")
  24. HotKeySet("{Home}", "FindOffset")
  25.  
  26. ;######################################################################################################################################################
  27. ;############################################################The GUI###################################################################################
  28. ;######################################################################################################################################################
  29. #region ### START Koda GUI section ### Form=
  30. $frmMain = GUICreate("Safari Fisher", 220, 120)
  31. $grpBalls = GUICtrlCreateGroup("Safari Balls", 10, 75, 70, 40)
  32. $grpPKMN = GUICtrlCreateGroup("Safari PKMN", 10, 10, 200, 60)
  33. $inpBalls = GUICtrlCreateInput("0", 15, 90, 60, 20, $ES_Number)
  34. $lblEncounter = GUICtrlCreateLabel("PKMN Encountered: ", 15, 25, 140, 20)
  35. $lblEncounter_count = GUICtrlCreateLabel("0", 155, 25, 40, 20)
  36. $lblPKMNCaught = GUICtrlCreateLabel("PKMN Caught: ", 15, 45, 140, 20)
  37. $lblPKMNCaught_count = GUICtrlCreateLabel("0", 155, 45, 40, 20)
  38. $btnStart = GUICtrlCreateButton("Start", 85, 75, 60, 40)
  39. $btnStop = GUICtrlCreateButton("Stop", 150, 75, 60, 40)
  40. GUICtrlSetFont($lblEncounter, 10, 800, "", "Ariel")
  41. GUICtrlSetFont($lblEncounter_count, 10, 800, "", "Ariel")
  42. GUICtrlSetFont($lblPKMNCaught, 10, 800, "", "Ariel")
  43. GUICtrlSetFont($lblPKMNCaught_count, 10, 800, "", "Ariel")
  44. GUICtrlSetFont($btnStart, 12, 1000, "", "Ariel")
  45. GUICtrlSetFont($btnStop, 12, 1000, "", "Ariel")
  46. GUISetState(@SW_SHOW)
  47. #endregion ### END Koda GUI section ###
  48.  
  49. ;######################################################################################################################################################
  50. ;##########################################################Variables###################################################################################
  51. ;######################################################################################################################################################
  52. Global $keyPress, $toggleRun, $fishingRod, $aButton, $bButton, $balls, $Delay, $PKMN1, $PKMN2, $PKMN3, $debug, $offset, $size
  53. Global $Start = False
  54. Global $x = 0, $y = 0, $caught = 0, $encountered = 0
  55. Local $iniData = @LF & "Key Press=" & @LF & "Toggle Run=" & @LF & "Fishing Hot Key=" & @LF & "A Button=" & @LF & "B Button=" & @LF & "PKMN1=" & @LF & "PKMN2=" & @LF & "PKMN3=" & @LF & "Delay=" & @LF & "AFK=" & @LF & "Debug=" & @LF & "Offset="
  56. ;Above variable is used for creating the ini file
  57.  
  58. ;######################################################################################################################################################
  59. ;########################################################INI Settings Start############################################################################
  60. ;######################################################################################################################################################
  61. If FileExists(@ScriptDir & "\Config.ini") Then
  62.     $keyPress = IniRead(@ScriptDir & "\Config.ini", "Settings", "Key Press", "")
  63.     $toggleRun = IniRead(@ScriptDir & "\Config.ini", "Settings", "Toggle Run", "")
  64.     $fishingRod = IniRead(@ScriptDir & "\Config.ini", "Settings", "Fishing Hot Key", "")
  65.     $aButton = IniRead(@ScriptDir & "\Config.ini", "Settings", "A Button", "")
  66.     $bButton = IniRead(@ScriptDir & "\Config.ini", "Settings", "B Button", "")
  67.     $PKMN1 = IniRead(@ScriptDir & "\Config.ini", "Settings", "PKMN1", "")
  68.     $PKMN2 = IniRead(@ScriptDir & "\Config.ini", "Settings", "PKMN2", "")
  69.     $PKMN3 = IniRead(@ScriptDir & "\Config.ini", "Settings", "PKMN3", "")
  70.     $debug = IniRead(@ScriptDir & "\Config.ini", "Settings", "Debug", "")
  71.     $afk = IniRead(@ScriptDir & "\Config.ini", "Settings", "Afk", "")
  72.     $offset = IniRead(@ScriptDir & "\Config.ini", "Settings", "Offset", "")
  73. Else
  74.     IniWrite(@ScriptDir & "Config.ini", "Settings", "", "")
  75.     IniWriteSection(@ScriptDir & "Config.ini", "Settings", $iniData)
  76.     MsgBox("", "Settings", "Settings file created, please edit settings before starting bot!" & @CR & "If you don't understand what the values are go back to the download topic!")
  77. EndIf
  78.  
  79. Func FindOffset()
  80.     $offset = IniRead(@ScriptDir & "\Config.ini", "Settings", "Offset", "")
  81.     $size = WinGetPos("[Class:LWJGL]")
  82.     WinActivate("[Class:LWJGL]")
  83.     $summary = _ImageSearchArea(@ScriptDir & "\Images\summary.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  84.     If $summary = 1 Then
  85.         $closeSum = _ImageSearchArea(@ScriptDir & "\Images\x.bmp", 0, $x, $y - $offset, $size[2], $size[3], $x, $y, 5)
  86.         If $closeSum = 1 Then
  87.             MouseMove($x, $y - $offset)
  88.             MsgBox("", "Summary Window", "Mouse should be on the X of the summary window." & @CR & "If it's above it: increase offset, if it's below it: decrease offset." & @CR & "If it's on the X: offset is perfect.")
  89.         EndIf
  90.     EndIf
  91. EndFunc   ;==>FindOffset
  92.  
  93. Func Test()
  94.     $size = WinGetPos("[Class:LWJGL]")
  95.     WinActivate("[Class:LWJGL]")
  96.     $water = PixelSearch($size[0], $size[1], $size[2], $size[3], 0x4776D4, 10)
  97.     If Not @error Then $water = 1
  98.     MsgBox("", "", $water)
  99.  
  100. EndFunc   ;==>Test
  101.  
  102. While 1
  103.     $nMsg = GUIGetMsg()
  104.     Switch $nMsg
  105.         Case $GUI_EVENT_CLOSE
  106.             ExitLoop
  107.         Case $btnStart
  108.             $balls = GUICtrlRead($inpBalls)
  109.             _GetLocation()
  110.         Case $btnStop
  111.             If $Start = True Then
  112.                 ExitLoop
  113.             Else
  114.                 MsgBox("", "Error", "Bot has not started yet")
  115.             EndIf
  116.     EndSwitch
  117. WEnd
  118.  
  119. Func _GetLocation()
  120.     WinActivate("[Class:LWJGL]")
  121.     If @error Then
  122.         MsgBox("", "PokeMMO Not Found", "Cannot switch to PokeMMO, is it runnning?")
  123.         Exit
  124.     Else
  125.         $size = WinGetPos("[Class:LWJGL]")
  126.     EndIf
  127.  
  128.     If $debug = True Then ToolTip("Trying to figure out where I am.", 0, 0)
  129.     Do
  130.         $fuchsia = _ImageSearchArea(@ScriptDir & "\Images\fuchsia.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  131.         $safari = _ImageSearchArea(@ScriptDir & "\Images\safari.bmp", 0, $size[0], $size[1] - 30, $size[2], $size[3], $x, $y, 25) Or _ImageSearchArea(@ScriptDir & "\Images\safari_2.bmp", 0, $size[0], $size[1] - 30, $size[2], $size[3], $x, $y, 25)
  132.         $fuchsia_npc = _ImageSearchArea(@ScriptDir & "\Images\fuchsia_npc.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  133.         Select
  134.             Case $fuchsia = 1 And $fuchsia_npc = 1
  135.                 $aSend = 0
  136.                 If $debug = True Then ToolTip("Character is currently in the safari building.", 0, 0)
  137.                 Send("{Up 2}")
  138.                 Do
  139.                     $ok_yes = _ImageSearchArea(@ScriptDir & "\Images\ok.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25) Or _ImageSearchArea(@ScriptDir & "\Images\yes.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  140.                     $ok_yes = _ImageSearchArea(@ScriptDir & "\Images\arrow.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10) Or _ImageSearchArea(@ScriptDir & "\Images\yes_arrow.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  141.                     If $ok_yes = 1 Then
  142.                         If $debug = True Then ToolTip("Sending A so I can get into the safari zone! $aSend Count = " & $aSend, 0, 0)
  143.                         Send($aButton)
  144.                         Sleep(250 + Random(0, $Delay))
  145.                         $aSend += 1
  146.                     Else
  147.                         Sleep(250)
  148.                     EndIf
  149.                 Until $aSend = 9
  150.                 $balls = 30
  151.                 GUICtrlSetData($inpBalls, 30)
  152.                 Sleep(1000 + Random(0, $Delay))
  153.             Case $safari = 1
  154.                 If $debug = True Then ToolTip("In the safari zone, checking to see if I have any safari balls then moving to _Location()", 0, 0)
  155.                 If $balls = 0 Then
  156.                     MsgBox("", "Error", "I'm in the safari zone but I don't know how many safari balls I have!" & @CR & "Please tell me how many safari balls I have...")
  157.                     ToolTip("", 0, 0)
  158.                     ExitLoop
  159.                 EndIf
  160.                 Sleep(500 + Random(0, $Delay))
  161.                 _Location()
  162.         EndSelect
  163.     Until $safari = 1
  164. EndFunc   ;==>_GetLocation
  165.  
  166. Func _Location()
  167.     If $debug = True Then ToolTip("In the safari zone, checking to see if I need to pathfind or start fishing.", 0, 0)
  168.     $safari_sign = _ImageSearchArea(@ScriptDir & "\Images\sign.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  169.     $safari_sign2 = _ImageSearchArea(@ScriptDir & "\Images\sign2.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  170.     $safari_hedges = _ImageSearchArea(@ScriptDir & "\Images\hedges.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  171.     Select
  172.         Case $safari_sign = 1 And $safari_hedges = 1
  173.             If $debug = True Then ToolTip("At the first fishing spot. Fishing...", 0, 0)
  174.             _Start()
  175.         Case $safari_sign2 = 1 And $safari_hedges = 1
  176.             If $debug = True Then ToolTip("At the second fishing spot. Fishing...", 0, 0)
  177.             _Start()
  178.         Case $safari_sign = 1 And $safari_hedges = 0
  179.             If $debug = True Then ToolTip("At the entrance of the safari zone, pathfinding to the fishing spot.", 0, 0)
  180.             $path = Random(1, 3)
  181.             Select
  182.                 Case $path >= 1 And $path < 2
  183.                     _Pathfind1()
  184.                 Case $path >= 2 And $path < 3
  185.                     _PathFind2()
  186.                 Case $path >= 3
  187.                     _PathFind3()
  188.             EndSelect
  189.     EndSelect
  190. EndFunc   ;==>_Location
  191.  
  192. Func _Pathfind1()
  193.     If $debug = True Then ToolTip("Using the first path.", 0, 0)
  194.     If $toggleRun = True Then
  195.         Send($bButton)
  196.         Sleep(150)
  197.     Else
  198.         Send("{" & $bButton & " down}")
  199.     EndIf
  200.  
  201.     Send("{Up 9}")
  202.     Sleep(Random(0, $Delay))
  203.     Send("{Right 7}")
  204.     Sleep(Random(0, $Delay))
  205.     Send("{Up 3}")
  206.     Sleep(Random(0, $Delay))
  207.  
  208.     If $toggleRun = True Then
  209.         Send($bButton)
  210.         Sleep(150)
  211.     Else
  212.         Send("{" & $bButton & " up}")
  213.     EndIf
  214.     _Start()
  215. EndFunc   ;==>_Pathfind1
  216.  
  217. Func _PathFind2()
  218.     If $debug = True Then ToolTip("Using the second path.", 0, 0)
  219.     If $toggleRun = True Then
  220.         Send($bButton)
  221.         Sleep(150)
  222.     Else
  223.         Send("{" & $bButton & " down}")
  224.     EndIf
  225.  
  226.     Send("{Up}")
  227.     Sleep(Random(0, $Delay))
  228.     Send("{Right 5}")
  229.     Sleep(Random(0, $Delay))
  230.     Send("{Up 4}")
  231.     Sleep(Random(0, $Delay))
  232.     Send("{Right 3}")
  233.     Sleep(Random(0, $Delay))
  234.     Send("{Up 6}")
  235.     Sleep(Random(0, $Delay))
  236.     Send("{Left 2}")
  237.     Sleep(Random(0, $Delay))
  238.     Send("{Up 3}")
  239.     Sleep(Random(0, $Delay))
  240.  
  241.     If $toggleRun = True Then
  242.         Send($bButton)
  243.         Sleep(150)
  244.     Else
  245.         Send("{" & $bButton & " up}")
  246.     EndIf
  247.     _Start()
  248. EndFunc   ;==>_PathFind2
  249.  
  250. Func _PathFind3()
  251.     If $debug = True Then ToolTip("Using the second path.", 0, 0)
  252.     If $toggleRun = True Then
  253.         Send($bButton)
  254.         Sleep(150)
  255.     Else
  256.         Send("{" & $bButton & " down}")
  257.     EndIf
  258.  
  259.     Send("{Up}")
  260.     Sleep(Random(0, $Delay))
  261.     Send("{Right 17}")
  262.     Sleep(Random(0, $Delay))
  263.     Send("{Up 13}")
  264.     $up = Random(1, 2)
  265.     If $up = 1 Then
  266.         Send("{Up}")
  267.     Else
  268.         Send("{Up 2}")
  269.     EndIf
  270.     Sleep(Random(0, $Delay))
  271.     Send("{Left 9}")
  272.     Sleep(Random(0, $Delay))
  273.  
  274.     If $toggleRun = True Then
  275.         Send($bButton)
  276.         Sleep(150)
  277.     Else
  278.         Send("{" & $bButton & " up}")
  279.     EndIf
  280.     _Start()
  281. EndFunc   ;==>_PathFind3
  282.  
  283. Func _Start()
  284.     $Start = True
  285.     While $Start = True
  286.         If $debug = True Then ToolTip("Fishing...", 0, 0)
  287.         Send("{" & $fishingRod & "}")
  288.         Sleep(1000 + Random(0, $Delay))
  289.         Do
  290.             $fishingMsg = _ImageSearchArea(@ScriptDir & "\Images\arrow.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10) Or _ImageSearchArea(@ScriptDir & "\Images\ok.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  291.             If $fishingMsg = 1 Then
  292.                 $notANibble = _ImageSearchArea(@ScriptDir & "\Images\not.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10) Or _ImageSearchArea(@ScriptDir & "\Images\not2.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  293.                 If $notANibble = 1 Then
  294.                     If $debug = True Then ToolTip("Not even a nibble...", 0, 0)
  295.                     Sleep(250)
  296.                     Send($aButton)
  297.                     Sleep(250 + Random(0, $Delay))
  298.                     _Start()
  299.                 Else
  300.                     If $debug = True Then ToolTip("Got a bite!", 0, 0)
  301.                     Send($aButton)
  302.                     Sleep(1000 + Random(0, $Delay))
  303.                 EndIf
  304.             EndIf
  305.         Until $fishingMsg = 1
  306.  
  307.         $encountered += 1
  308.         GUICtrlSetData($lblEncounter_count, $encountered)
  309.  
  310.         Do
  311.             $inBattleImg = _ImageSearchArea(@ScriptDir & "\Images\battleimg.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  312.             If $inBattleImg = 1 Then
  313.                 If $debug = True Then ToolTip("In a battle.", 0, 0)
  314.                 If $keyPress = True Then
  315.                     Send($aButton)
  316.                     Sleep(250 + Random(0, $Delay))
  317.                     _wtPKMN()
  318.                 Else
  319.                     Sleep(250 + Random(0, $Delay))
  320.                     _wtPKMN()
  321.                 EndIf
  322.             EndIf
  323.         Until $inBattleImg = 1
  324.     WEnd
  325. EndFunc   ;==>_Start
  326.  
  327. Func _wtPKMN()
  328.     If $debug = True Then ToolTip("Trying to see if it's a PKMN I need to catch...", 0, 0)
  329.     Do
  330.         $ball = _ImageSearchArea(@ScriptDir & "\Images\ball.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  331.         If $ball = 1 Then
  332.             $catchPKMN1 = _ImageSearchArea(@ScriptDir & "\Images\" & $PKMN1 & ".bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  333.             $catchPKMN2 = _ImageSearchArea(@ScriptDir & "\Images\" & $PKMN2 & ".bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  334.             $catchPKMN3 = _ImageSearchArea(@ScriptDir & "\Images\" & $PKMN3 & ".bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
  335.             If $catchPKMN1 = 1 Or $catchPKMN2 = 1 Or $catchPKMN3 = 1 Then
  336.                 If $debug = True Then ToolTip("Catchable PKMN.", 0, 0)
  337.                 _catch()
  338.             Else
  339.                 _endBattle()
  340.             EndIf
  341.         EndIf
  342.     Until $ball = 1
  343. EndFunc   ;==>_wtPKMN
  344.  
  345. Func _catch()
  346.     Do
  347.         $ball = _ImageSearchArea(@ScriptDir & "\Images\ball.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  348.     Until $ball = 1
  349.  
  350.     If $debug = True Then ToolTip("Catchable PKMN. Throwing Safari Ball...", 0, 0)
  351.     Send($aButton)
  352.     $balls -= 1
  353.     GUICtrlSetData($inpBalls, $balls)
  354.     Sleep(250)
  355.     While 2
  356.         $failed = _ImageSearchArea(@ScriptDir & "\Images\failed.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  357.         $fled = _ImageSearchArea(@ScriptDir & "\Images\fled.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  358.         $success = _ImageSearchArea(@ScriptDir & "\Images\success.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  359.         Select
  360.             Case $failed = 1
  361.                 If $debug = True Then ToolTip("Safari ball failed.", 0, 0)
  362.                 Sleep(250 + Random(0, $Delay))
  363.                 If $balls = 0 Then
  364.                     If $debug = True Then ToolTip("Safari ball failed, I'm out of safari balls but still in battle. Moving to _endBattle()", 0, 0)
  365.                     _endBattle()
  366.                 Else
  367.                     _catch()
  368.                 EndIf
  369.             Case $fled = 1
  370.                 If $debug = True Then ToolTip("PKMN Fled...", 0, 0)
  371.                 Sleep(1000 + Random(0, $Delay))
  372.                 If $balls = 0 Then
  373.                     If $debug = True Then ToolTip("PKMN ran away and I have no more safari balls, moving to _Restart() if Afk=True in settings", 0, 0)
  374.                     If $afk = True Then
  375.                         _Restart()
  376.                     Else
  377.                         Exit
  378.                     EndIf
  379.                 Else
  380.                     _Start()
  381.                 EndIf
  382.             Case $success = 1
  383.                 If $debug = True Then ToolTip("Successfully captured PKMN.", 0, 0)
  384.                 $caught += 1
  385.                 GUICtrlSetData($lblPKMNCaught_count, $caught)
  386.                 Sleep(250 + Random(0, $Delay))
  387.                 Do
  388.                     $summary = _ImageSearchArea(@ScriptDir & "\Images\summary.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  389.                     If $summary = 1 Then
  390.                         If $debug = True Then ToolTip("Closing PKMN summary window.", 0, 0)
  391.                         $closeSum = _ImageSearchArea(@ScriptDir & "\Images\x.bmp", 0, $x, $y - 20, $size[2], $size[3], $x, $y, 5)
  392.                         If $closeSum = 1 Then
  393.                             Sleep(250 + Random(0, $Delay))
  394.                             MouseClick("Left", $x, $y - $offset, 1, Random(3, 10))
  395.                             Sleep(250 + Random(0, $Delay))
  396.                             MouseMove(Random(0, $size[3] / 10), Random(0, $size[2] / 10))
  397.                             Sleep(250)
  398.                             If $balls = 0 Then
  399.                                 If $debug = True Then ToolTip("Caught PKMN and out of safari balls, moving to _Restart() if Afk=True in settings", 0, 0)
  400.                                 If $afk = True Then
  401.                                     _Restart()
  402.                                 Else
  403.                                     Exit
  404.                                 EndIf
  405.                             Else
  406.                                 If $debug = True Then ToolTip("Moving back to _Start()", 0, 0)
  407.                                 _Start()
  408.                             EndIf
  409.                         EndIf
  410.                     EndIf
  411.                 Until $summary = 1 And $closeSum = 1
  412.         EndSelect
  413.     WEnd
  414. EndFunc   ;==>_catch
  415.  
  416. Func _endBattle()
  417.     If $debug = True Then ToolTip("On _endBattle(), checking to make sure I am on the battle screen...", 0, 0)
  418.     Do
  419.         $ball = _ImageSearchArea(@ScriptDir & "\Images\ball.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  420.     Until $ball = 1
  421.  
  422.     If $debug = True Then ToolTip("Running away...", 0, 0)
  423.     Send("{right}")
  424.     Sleep(200)
  425.     Send("{down}")
  426.     Sleep(200)
  427.     Send($aButton)
  428.     Sleep(750 + Random(0, $Delay))
  429.  
  430.     If $balls > 0 Then
  431.         If $debug = True Then ToolTip("Fishing...", 0, 0)
  432.         _Start()
  433.     Else
  434.         If $debug = True Then ToolTip("Ran away, moving to _Restart() if Afk=True in settings", 0, 0)
  435.         If $afk = True Then
  436.             _Restart()
  437.         Else
  438.             Exit
  439.         EndIf
  440.     EndIf
  441. EndFunc   ;==>_endBattle
  442.  
  443. Func _Restart()
  444.     $size = WinGetPos("[Class:LWJGL]")
  445.     If $debug = True Then ToolTip("Making sure Ithere isn't a PKMN summary window open.", 0, 0)
  446.     $summary = _ImageSearchArea(@ScriptDir & "\Images\summary.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  447.     If $summary = 1 Then
  448.         If $debug = True Then ToolTip("Trying to close summary window.", 0, 0)
  449.         $closeSum = _ImageSearchArea(@ScriptDir & "\Images\x.bmp", 0, $x, $y - 20, $size[2], $size[3], $x, $y, 5)
  450.         If $closeSum = 1 Then
  451.             Sleep(250 + Random(0, $Delay))
  452.             MouseClick("Left", $x, $y - $offset, 1, Random(3, 10))
  453.             Sleep(500 + Random(0, $Delay))
  454.         EndIf
  455.     EndIf
  456.  
  457.     If $debug = True Then ToolTip("Leaving safari zone.", 0, 0)
  458.     Do
  459.         $PA = _ImageSearchArea(@ScriptDir & "\Images\pa.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10) Or _ImageSearchArea(@ScriptDir & "\Images\pa_arrow.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  460.         If $PA = 1 Then
  461.             Do
  462.                 $ok_arrow = _ImageSearchArea(@ScriptDir & "\Images\ok.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10) Or _ImageSearchArea(@ScriptDir & "\Images\arrow.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  463.                 $fuchsia = _ImageSearchArea(@ScriptDir & "\Images\fuchsia.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
  464.                 Select
  465.                     Case $ok_arrow = 1
  466.                         If $debug = True Then ToolTip("Sending A key until I'm back at the safari building.", 0, 0)
  467.                         Send($aButton)
  468.                         Sleep(250 + Random(0, $Delay))
  469.                     Case $fuchsia = 1
  470.                         If $debug = True Then ToolTip("In the safari building, going to _GetLocation()", 0, 0)
  471.                         Sleep(500 + Random(0, $Delay))
  472.                         _GetLocation()
  473.                 EndSelect
  474.             Until $fuchsia = 1
  475.         EndIf
  476.     Until $PA = 1
  477. EndFunc   ;==>_Restart
  478.  
  479. Func Terminate()
  480.     Exit
  481. EndFunc   ;==>Terminate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement