Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Credits:
- ;Script wrote by InunoTaishou
- ;######################################################################################################################################################
- ;#################################################Necessary AUTOIT libraries and variables#############################################################
- ;######################################################################################################################################################
- #include <Lib\ImageSearch.au3>
- #include <ButtonConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- AutoItSetOption("WinTitleMatchMode", 2)
- AutoItSetOption("MouseCoordMode", 2)
- AutoItSetOption("SendKeyDelay", 25)
- AutoItSetOption("SendKeyDownDelay", 150)
- AutoItSetOption("PixelCoordMode", 2)
- ;######################################################################################################################################################
- ;##########################################################Hotkeys#####################################################################################
- ;######################################################################################################################################################
- HotKeySet("{End}", "Terminate")
- HotKeySet("{Del}", "_Restart")
- HotKeySet("{Home}", "FindOffset")
- ;######################################################################################################################################################
- ;############################################################The GUI###################################################################################
- ;######################################################################################################################################################
- #region ### START Koda GUI section ### Form=
- $frmMain = GUICreate("Safari Fisher", 220, 120)
- $grpBalls = GUICtrlCreateGroup("Safari Balls", 10, 75, 70, 40)
- $grpPKMN = GUICtrlCreateGroup("Safari PKMN", 10, 10, 200, 60)
- $inpBalls = GUICtrlCreateInput("0", 15, 90, 60, 20, $ES_Number)
- $lblEncounter = GUICtrlCreateLabel("PKMN Encountered: ", 15, 25, 140, 20)
- $lblEncounter_count = GUICtrlCreateLabel("0", 155, 25, 40, 20)
- $lblPKMNCaught = GUICtrlCreateLabel("PKMN Caught: ", 15, 45, 140, 20)
- $lblPKMNCaught_count = GUICtrlCreateLabel("0", 155, 45, 40, 20)
- $btnStart = GUICtrlCreateButton("Start", 85, 75, 60, 40)
- $btnStop = GUICtrlCreateButton("Stop", 150, 75, 60, 40)
- GUICtrlSetFont($lblEncounter, 10, 800, "", "Ariel")
- GUICtrlSetFont($lblEncounter_count, 10, 800, "", "Ariel")
- GUICtrlSetFont($lblPKMNCaught, 10, 800, "", "Ariel")
- GUICtrlSetFont($lblPKMNCaught_count, 10, 800, "", "Ariel")
- GUICtrlSetFont($btnStart, 12, 1000, "", "Ariel")
- GUICtrlSetFont($btnStop, 12, 1000, "", "Ariel")
- GUISetState(@SW_SHOW)
- #endregion ### END Koda GUI section ###
- ;######################################################################################################################################################
- ;##########################################################Variables###################################################################################
- ;######################################################################################################################################################
- Global $keyPress, $toggleRun, $fishingRod, $aButton, $bButton, $balls, $Delay, $PKMN1, $PKMN2, $PKMN3, $debug, $offset, $size
- Global $Start = False
- Global $x = 0, $y = 0, $caught = 0, $encountered = 0
- 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="
- ;Above variable is used for creating the ini file
- ;######################################################################################################################################################
- ;########################################################INI Settings Start############################################################################
- ;######################################################################################################################################################
- If FileExists(@ScriptDir & "\Config.ini") Then
- $keyPress = IniRead(@ScriptDir & "\Config.ini", "Settings", "Key Press", "")
- $toggleRun = IniRead(@ScriptDir & "\Config.ini", "Settings", "Toggle Run", "")
- $fishingRod = IniRead(@ScriptDir & "\Config.ini", "Settings", "Fishing Hot Key", "")
- $aButton = IniRead(@ScriptDir & "\Config.ini", "Settings", "A Button", "")
- $bButton = IniRead(@ScriptDir & "\Config.ini", "Settings", "B Button", "")
- $PKMN1 = IniRead(@ScriptDir & "\Config.ini", "Settings", "PKMN1", "")
- $PKMN2 = IniRead(@ScriptDir & "\Config.ini", "Settings", "PKMN2", "")
- $PKMN3 = IniRead(@ScriptDir & "\Config.ini", "Settings", "PKMN3", "")
- $debug = IniRead(@ScriptDir & "\Config.ini", "Settings", "Debug", "")
- $afk = IniRead(@ScriptDir & "\Config.ini", "Settings", "Afk", "")
- $offset = IniRead(@ScriptDir & "\Config.ini", "Settings", "Offset", "")
- Else
- IniWrite(@ScriptDir & "Config.ini", "Settings", "", "")
- IniWriteSection(@ScriptDir & "Config.ini", "Settings", $iniData)
- 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!")
- EndIf
- Func FindOffset()
- $offset = IniRead(@ScriptDir & "\Config.ini", "Settings", "Offset", "")
- $size = WinGetPos("[Class:LWJGL]")
- WinActivate("[Class:LWJGL]")
- $summary = _ImageSearchArea(@ScriptDir & "\Images\summary.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- If $summary = 1 Then
- $closeSum = _ImageSearchArea(@ScriptDir & "\Images\x.bmp", 0, $x, $y - $offset, $size[2], $size[3], $x, $y, 5)
- If $closeSum = 1 Then
- MouseMove($x, $y - $offset)
- 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.")
- EndIf
- EndIf
- EndFunc ;==>FindOffset
- Func Test()
- $size = WinGetPos("[Class:LWJGL]")
- WinActivate("[Class:LWJGL]")
- $water = PixelSearch($size[0], $size[1], $size[2], $size[3], 0x4776D4, 10)
- If Not @error Then $water = 1
- MsgBox("", "", $water)
- EndFunc ;==>Test
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- ExitLoop
- Case $btnStart
- $balls = GUICtrlRead($inpBalls)
- _GetLocation()
- Case $btnStop
- If $Start = True Then
- ExitLoop
- Else
- MsgBox("", "Error", "Bot has not started yet")
- EndIf
- EndSwitch
- WEnd
- Func _GetLocation()
- WinActivate("[Class:LWJGL]")
- If @error Then
- MsgBox("", "PokeMMO Not Found", "Cannot switch to PokeMMO, is it runnning?")
- Exit
- Else
- $size = WinGetPos("[Class:LWJGL]")
- EndIf
- If $debug = True Then ToolTip("Trying to figure out where I am.", 0, 0)
- Do
- $fuchsia = _ImageSearchArea(@ScriptDir & "\Images\fuchsia.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- $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)
- $fuchsia_npc = _ImageSearchArea(@ScriptDir & "\Images\fuchsia_npc.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- Select
- Case $fuchsia = 1 And $fuchsia_npc = 1
- $aSend = 0
- If $debug = True Then ToolTip("Character is currently in the safari building.", 0, 0)
- Send("{Up 2}")
- Do
- $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)
- $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)
- If $ok_yes = 1 Then
- If $debug = True Then ToolTip("Sending A so I can get into the safari zone! $aSend Count = " & $aSend, 0, 0)
- Send($aButton)
- Sleep(250 + Random(0, $Delay))
- $aSend += 1
- Else
- Sleep(250)
- EndIf
- Until $aSend = 9
- $balls = 30
- GUICtrlSetData($inpBalls, 30)
- Sleep(1000 + Random(0, $Delay))
- Case $safari = 1
- If $debug = True Then ToolTip("In the safari zone, checking to see if I have any safari balls then moving to _Location()", 0, 0)
- If $balls = 0 Then
- 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...")
- ToolTip("", 0, 0)
- ExitLoop
- EndIf
- Sleep(500 + Random(0, $Delay))
- _Location()
- EndSelect
- Until $safari = 1
- EndFunc ;==>_GetLocation
- Func _Location()
- If $debug = True Then ToolTip("In the safari zone, checking to see if I need to pathfind or start fishing.", 0, 0)
- $safari_sign = _ImageSearchArea(@ScriptDir & "\Images\sign.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- $safari_sign2 = _ImageSearchArea(@ScriptDir & "\Images\sign2.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- $safari_hedges = _ImageSearchArea(@ScriptDir & "\Images\hedges.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- Select
- Case $safari_sign = 1 And $safari_hedges = 1
- If $debug = True Then ToolTip("At the first fishing spot. Fishing...", 0, 0)
- _Start()
- Case $safari_sign2 = 1 And $safari_hedges = 1
- If $debug = True Then ToolTip("At the second fishing spot. Fishing...", 0, 0)
- _Start()
- Case $safari_sign = 1 And $safari_hedges = 0
- If $debug = True Then ToolTip("At the entrance of the safari zone, pathfinding to the fishing spot.", 0, 0)
- $path = Random(1, 3)
- Select
- Case $path >= 1 And $path < 2
- _Pathfind1()
- Case $path >= 2 And $path < 3
- _PathFind2()
- Case $path >= 3
- _PathFind3()
- EndSelect
- EndSelect
- EndFunc ;==>_Location
- Func _Pathfind1()
- If $debug = True Then ToolTip("Using the first path.", 0, 0)
- If $toggleRun = True Then
- Send($bButton)
- Sleep(150)
- Else
- Send("{" & $bButton & " down}")
- EndIf
- Send("{Up 9}")
- Sleep(Random(0, $Delay))
- Send("{Right 7}")
- Sleep(Random(0, $Delay))
- Send("{Up 3}")
- Sleep(Random(0, $Delay))
- If $toggleRun = True Then
- Send($bButton)
- Sleep(150)
- Else
- Send("{" & $bButton & " up}")
- EndIf
- _Start()
- EndFunc ;==>_Pathfind1
- Func _PathFind2()
- If $debug = True Then ToolTip("Using the second path.", 0, 0)
- If $toggleRun = True Then
- Send($bButton)
- Sleep(150)
- Else
- Send("{" & $bButton & " down}")
- EndIf
- Send("{Up}")
- Sleep(Random(0, $Delay))
- Send("{Right 5}")
- Sleep(Random(0, $Delay))
- Send("{Up 4}")
- Sleep(Random(0, $Delay))
- Send("{Right 3}")
- Sleep(Random(0, $Delay))
- Send("{Up 6}")
- Sleep(Random(0, $Delay))
- Send("{Left 2}")
- Sleep(Random(0, $Delay))
- Send("{Up 3}")
- Sleep(Random(0, $Delay))
- If $toggleRun = True Then
- Send($bButton)
- Sleep(150)
- Else
- Send("{" & $bButton & " up}")
- EndIf
- _Start()
- EndFunc ;==>_PathFind2
- Func _PathFind3()
- If $debug = True Then ToolTip("Using the second path.", 0, 0)
- If $toggleRun = True Then
- Send($bButton)
- Sleep(150)
- Else
- Send("{" & $bButton & " down}")
- EndIf
- Send("{Up}")
- Sleep(Random(0, $Delay))
- Send("{Right 17}")
- Sleep(Random(0, $Delay))
- Send("{Up 13}")
- $up = Random(1, 2)
- If $up = 1 Then
- Send("{Up}")
- Else
- Send("{Up 2}")
- EndIf
- Sleep(Random(0, $Delay))
- Send("{Left 9}")
- Sleep(Random(0, $Delay))
- If $toggleRun = True Then
- Send($bButton)
- Sleep(150)
- Else
- Send("{" & $bButton & " up}")
- EndIf
- _Start()
- EndFunc ;==>_PathFind3
- Func _Start()
- $Start = True
- While $Start = True
- If $debug = True Then ToolTip("Fishing...", 0, 0)
- Send("{" & $fishingRod & "}")
- Sleep(1000 + Random(0, $Delay))
- Do
- $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)
- If $fishingMsg = 1 Then
- $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)
- If $notANibble = 1 Then
- If $debug = True Then ToolTip("Not even a nibble...", 0, 0)
- Sleep(250)
- Send($aButton)
- Sleep(250 + Random(0, $Delay))
- _Start()
- Else
- If $debug = True Then ToolTip("Got a bite!", 0, 0)
- Send($aButton)
- Sleep(1000 + Random(0, $Delay))
- EndIf
- EndIf
- Until $fishingMsg = 1
- $encountered += 1
- GUICtrlSetData($lblEncounter_count, $encountered)
- Do
- $inBattleImg = _ImageSearchArea(@ScriptDir & "\Images\battleimg.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- If $inBattleImg = 1 Then
- If $debug = True Then ToolTip("In a battle.", 0, 0)
- If $keyPress = True Then
- Send($aButton)
- Sleep(250 + Random(0, $Delay))
- _wtPKMN()
- Else
- Sleep(250 + Random(0, $Delay))
- _wtPKMN()
- EndIf
- EndIf
- Until $inBattleImg = 1
- WEnd
- EndFunc ;==>_Start
- Func _wtPKMN()
- If $debug = True Then ToolTip("Trying to see if it's a PKMN I need to catch...", 0, 0)
- Do
- $ball = _ImageSearchArea(@ScriptDir & "\Images\ball.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- If $ball = 1 Then
- $catchPKMN1 = _ImageSearchArea(@ScriptDir & "\Images\" & $PKMN1 & ".bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- $catchPKMN2 = _ImageSearchArea(@ScriptDir & "\Images\" & $PKMN2 & ".bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- $catchPKMN3 = _ImageSearchArea(@ScriptDir & "\Images\" & $PKMN3 & ".bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 25)
- If $catchPKMN1 = 1 Or $catchPKMN2 = 1 Or $catchPKMN3 = 1 Then
- If $debug = True Then ToolTip("Catchable PKMN.", 0, 0)
- _catch()
- Else
- _endBattle()
- EndIf
- EndIf
- Until $ball = 1
- EndFunc ;==>_wtPKMN
- Func _catch()
- Do
- $ball = _ImageSearchArea(@ScriptDir & "\Images\ball.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- Until $ball = 1
- If $debug = True Then ToolTip("Catchable PKMN. Throwing Safari Ball...", 0, 0)
- Send($aButton)
- $balls -= 1
- GUICtrlSetData($inpBalls, $balls)
- Sleep(250)
- While 2
- $failed = _ImageSearchArea(@ScriptDir & "\Images\failed.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- $fled = _ImageSearchArea(@ScriptDir & "\Images\fled.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- $success = _ImageSearchArea(@ScriptDir & "\Images\success.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- Select
- Case $failed = 1
- If $debug = True Then ToolTip("Safari ball failed.", 0, 0)
- Sleep(250 + Random(0, $Delay))
- If $balls = 0 Then
- If $debug = True Then ToolTip("Safari ball failed, I'm out of safari balls but still in battle. Moving to _endBattle()", 0, 0)
- _endBattle()
- Else
- _catch()
- EndIf
- Case $fled = 1
- If $debug = True Then ToolTip("PKMN Fled...", 0, 0)
- Sleep(1000 + Random(0, $Delay))
- If $balls = 0 Then
- 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)
- If $afk = True Then
- _Restart()
- Else
- Exit
- EndIf
- Else
- _Start()
- EndIf
- Case $success = 1
- If $debug = True Then ToolTip("Successfully captured PKMN.", 0, 0)
- $caught += 1
- GUICtrlSetData($lblPKMNCaught_count, $caught)
- Sleep(250 + Random(0, $Delay))
- Do
- $summary = _ImageSearchArea(@ScriptDir & "\Images\summary.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- If $summary = 1 Then
- If $debug = True Then ToolTip("Closing PKMN summary window.", 0, 0)
- $closeSum = _ImageSearchArea(@ScriptDir & "\Images\x.bmp", 0, $x, $y - 20, $size[2], $size[3], $x, $y, 5)
- If $closeSum = 1 Then
- Sleep(250 + Random(0, $Delay))
- MouseClick("Left", $x, $y - $offset, 1, Random(3, 10))
- Sleep(250 + Random(0, $Delay))
- MouseMove(Random(0, $size[3] / 10), Random(0, $size[2] / 10))
- Sleep(250)
- If $balls = 0 Then
- If $debug = True Then ToolTip("Caught PKMN and out of safari balls, moving to _Restart() if Afk=True in settings", 0, 0)
- If $afk = True Then
- _Restart()
- Else
- Exit
- EndIf
- Else
- If $debug = True Then ToolTip("Moving back to _Start()", 0, 0)
- _Start()
- EndIf
- EndIf
- EndIf
- Until $summary = 1 And $closeSum = 1
- EndSelect
- WEnd
- EndFunc ;==>_catch
- Func _endBattle()
- If $debug = True Then ToolTip("On _endBattle(), checking to make sure I am on the battle screen...", 0, 0)
- Do
- $ball = _ImageSearchArea(@ScriptDir & "\Images\ball.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- Until $ball = 1
- If $debug = True Then ToolTip("Running away...", 0, 0)
- Send("{right}")
- Sleep(200)
- Send("{down}")
- Sleep(200)
- Send($aButton)
- Sleep(750 + Random(0, $Delay))
- If $balls > 0 Then
- If $debug = True Then ToolTip("Fishing...", 0, 0)
- _Start()
- Else
- If $debug = True Then ToolTip("Ran away, moving to _Restart() if Afk=True in settings", 0, 0)
- If $afk = True Then
- _Restart()
- Else
- Exit
- EndIf
- EndIf
- EndFunc ;==>_endBattle
- Func _Restart()
- $size = WinGetPos("[Class:LWJGL]")
- If $debug = True Then ToolTip("Making sure Ithere isn't a PKMN summary window open.", 0, 0)
- $summary = _ImageSearchArea(@ScriptDir & "\Images\summary.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- If $summary = 1 Then
- If $debug = True Then ToolTip("Trying to close summary window.", 0, 0)
- $closeSum = _ImageSearchArea(@ScriptDir & "\Images\x.bmp", 0, $x, $y - 20, $size[2], $size[3], $x, $y, 5)
- If $closeSum = 1 Then
- Sleep(250 + Random(0, $Delay))
- MouseClick("Left", $x, $y - $offset, 1, Random(3, 10))
- Sleep(500 + Random(0, $Delay))
- EndIf
- EndIf
- If $debug = True Then ToolTip("Leaving safari zone.", 0, 0)
- Do
- $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)
- If $PA = 1 Then
- Do
- $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)
- $fuchsia = _ImageSearchArea(@ScriptDir & "\Images\fuchsia.bmp", 0, $size[0], $size[1], $size[2], $size[3], $x, $y, 10)
- Select
- Case $ok_arrow = 1
- If $debug = True Then ToolTip("Sending A key until I'm back at the safari building.", 0, 0)
- Send($aButton)
- Sleep(250 + Random(0, $Delay))
- Case $fuchsia = 1
- If $debug = True Then ToolTip("In the safari building, going to _GetLocation()", 0, 0)
- Sleep(500 + Random(0, $Delay))
- _GetLocation()
- EndSelect
- Until $fuchsia = 1
- EndIf
- Until $PA = 1
- EndFunc ;==>_Restart
- Func Terminate()
- Exit
- EndFunc ;==>Terminate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement