Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_Icon=Data\Images\pokemon-pokemon-30613442-500-500.ico
- #AutoIt3Wrapper_Outfile=PokeMMO Trainer.exe
- #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
- ;######################################################################################################################################################
- ;######################################################Bot made and Developed by Kyle##################################################################
- ;######################################################Common Forum Name: InunoTaishou#################################################################
- ;#############################################################Tested by Nate###########################################################################
- ;#########################################################Commonly known as n8techy####################################################################
- ;######################################################################################################################################################
- ;######################################################################################################################################################
- ;#################################################Necessary AUTOIT libraries and variables#############################################################
- ;######################################################################################################################################################
- #include <Data\lib\ImageSearch.Au3>
- #include <GUIConstantsEx.au3>
- #include <EditConstants.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- AutoItSetOption("WinTitleMatchMode", 2)
- AutoItSetOption("MouseCoordMode", 2)
- AutoItSetOption("SendKeyDelay", 25)
- AutoItSetOption("SendKeyDownDelay", 100)
- ;######################################################################################################################################################
- ;##########################################################Hotkeys#####################################################################################
- ;######################################################################################################################################################
- HotKeySet("{End}", "Terminate")
- HotKeySet("{Pause}", "Paused")
- ;######################################################################################################################################################
- ;##########################################################Variables###################################################################################
- ;######################################################################################################################################################
- Global $UnPaused
- Global $Paused
- Global $Test
- Global $fainted, $expMS, $LR = 0
- Global $a1, $a2, $a3, $a4, $A, $B, $isChecked, $LR
- Global $size, $inpL, $inpR
- Global $tol = 10
- Global $tolPKMN = 10
- Global $pkmn1, $pkmn2, $pkmn3, $pkmn4, $pkmn5
- Global $debug = 0 ;Setting this to 1 will enable the tooltips. Letting you better understand what exactly the bot is doing and if an error occurs lets you know where it's stuck at.
- Local $iniData = @LF & "PokeMMO Dir=" & @LF & "A Key=" & @LF & "B Key=" & @LF & "FirstPP=" & @LF & "SecondPP=" & @LF & "ThirdPP=" & @LF & "FourthPP=" & @LF & "First PKMN=" & @LF & "Second PKMN=" & @LF & "Third PKMN=" & @LF & "Fourth PKMN=" & @LF & "Fifth PKMN=" & @LF & "Battle All="
- ;Above variable is used for creating the ini file
- Local $iniPath = @ScriptDir & "\Data\" ;ini Path
- Global $x = 0, $y = 0 ;x and y coordinates used for the image search
- ;######################################################################################################################################################
- ;############################################################The GUI###################################################################################
- ;######################################################################################################################################################
- #region ### START Koda GUI section ### Form=
- $EvTrainer = GUICreate("Pokemon EV Trainer", 525, 300, 569, 304)
- $lblPath = GUICtrlCreateLabel("Please select the PokeMMO.exe path", 250, 10, 220, 20)
- $inputFolder = GUICtrlCreateInput("", 250, 35, 250, 20, $ES_ReadOnly)
- $selectBtn = GUICtrlCreateButton("Select", 250, 62, 81, 20)
- $startP = GUICtrlCreateButton("Start PokeMMO", 355, 62, 90, 20)
- $lblPP = GUICtrlCreateLabel("Please put in how much PP each attack has", 20, 10, 220, 20)
- $inpFirst = GUICtrlCreateInput("", 25, 40, 80, 20, $ES_Number)
- $inpSecond = GUICtrlCreateInput("", 130, 40, 80, 20, $ES_Number)
- $inpThird = GUICtrlCreateInput("", 25, 70, 80, 20, $ES_Number)
- $inpFourth = GUICtrlCreateInput("", 130, 70, 80, 20, $ES_Number)
- $lblA = GUICtrlCreateLabel("A Button", 25, 95, 80, 20)
- $inpA = GUICtrlCreateInput("", 25, 115, 81, 20, $ES_UpperCase)
- $lblB = GUICtrlCreateLabel("B Button", 130, 95, 80, 20)
- $inpB = GUICtrlCreateInput("", 130, 115, 80, 20, $ES_UpperCase)
- $chkGrinder = GUICtrlCreateCheckbox("Master..Slave", 25, 145, 81, 20)
- $chkALL = GUICtrlCreateCheckbox("Battle all PKMN", 130, 145, 90, 20)
- $lblLeft = GUICtrlCreateLabel("Steps Left:",25,175,60,20)
- $inpLeft = GUICtrlCreateInput("",80,175,30,20,$ES_Number)
- $lblRight = GUICtrlCreateLabel("Steps Right:",130,175,60,20)
- $inpRight = GUICtrlCreateInput("",190,175,30,20,$ES_Number)
- $lblNames = GUICtrlCreateLabel("Please put in the names of the PKMN you wish to battle, ignore this if 'Battle all PKMN' is checked.",25,200,500,20)
- $inpPKMN1 = GUICtrlCreateInput("",25,220,80,20)
- $inpPKMN2 = GUICtrlCreateInput("",120,220,80,20)
- $inpPKMN3 = GUICtrlCreateInput("",215,220,80,20)
- $inpPKMN4 = GUICtrlCreateInput("",310,220,80,20)
- $inpPKMN5 = GUICtrlCreateInput("",405,220,80,20)
- $lblMade = GUICtrlCreateLabel("Bot made and developed by some guy, tested by another guy. If you really want to know who, it's in my source code. So decompile it.",25,250,485,50)
- GUICtrlSetfont($lblMade,12,100,"","Bell MT")
- $startBot = GUICtrlCreateButton("Start Bot", 250, 85, 250, 45)
- $stopBot = GUICtrlCreateButton("Stop Bot", 275, 135, 200, 35)
- GUICtrlSetFont($startBot, 16, 800, "", "Ariel")
- GUICtrlSetFont($stopBot,12,800,"","Ariel")
- GUISetState(@SW_SHOW)
- #endregion ### END Koda GUI section ###
- ;######################################################################################################################################################
- ;########################################################INI Settings Start############################################################################
- ;######################################################################################################################################################
- If FileExists($iniPath & "Settings.ini") Then
- $path = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "PokeMMO Dir", "")
- GUICtrlSetData($inputFolder, $path)
- $A = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "A Key", "")
- GUICtrlSetData($inpA, $A)
- $B = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "B Key", "")
- GUICtrlSetData($inpB, $B)
- $a1 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "FirstPP", "")
- GUICtrlSetData($inpFirst, $a1)
- $a2 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "SecondPP", "")
- GUICtrlSetData($inpSecond, $a2)
- $a3 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "ThirdPP", "")
- GUICtrlSetData($inpThird, $a3)
- $a4 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "FourthPP", "")
- GUICtrlSetData($inpFourth, $a4)
- $pkmn1 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "First PKMN", "")
- GUICtrlSetData($inpPKMN1,$pkmn1)
- $pkmn2 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "Second PKMN", "")
- GUICtrlSetData($inpPKMN2,$pkmn2)
- $pkmn3 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "Third PKMN", "")
- GUICtrlSetData($inpPKMN3,$pkmn3)
- $pkmn4 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "Fourth PKMN", "")
- GUICtrlSetData($inpPKMN4,$pkmn4)
- $pkmn5 = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "Fifth PKMN", "")
- GUICtrlSetData($inpPKMN5,$pkmn5)
- Sleep(250)
- $battleAll = IniRead($iniPath & "Settings.ini", "EV Trainer Settings", "Battle All","")
- GUICtrlSetState($chkALL,$battleAll)
- Else
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "", "")
- IniWriteSection($iniPath & "Settings.ini", "EV Trainer Settings", $iniData)
- EndIf
- ;######################################################################################################################################################
- ;##########################################################GUI Statements#############################################################################
- ;######################################################################################################################################################
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE ;On exit will save the current settings
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "PokeMMO Dir", $path)
- GUICtrlRead($inpA)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "A Key", $A)
- GUICtrlRead($inpB)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "B Key", $B)
- GUICtrlRead($inpFirst)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "FirstPP", $a1)
- GUICtrlRead($inpSecond)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "SecondPP", $a2)
- GUICtrlRead($inpThird)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "ThirdPP", $a3)
- GUICtrlRead($inpFourth)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "FourthPP", $a4)
- GUICtrlRead($inpPKMN1)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "First PKMN", $pkmn1)
- GUICtrlRead($inpPKMN2)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Second PKMN", $pkmn2)
- GUICtrlRead($inpPKMN3)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Third PKMN", $pkmn3)
- GUICtrlRead($inpPKMN4)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Fourth PKMN", $pkmn4)
- GUICtrlRead($inpPKMN5)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Fifth PKMN", $pkmn5)
- If GUICtrlRead($chkALL) = $GUI_Checked Then
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Battle All", 1)
- Else
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Battle All", 0)
- EndIf
- Exit
- Case $selectBtn ;Select the PokeMMO folder
- $path = FileSelectFolder("Select Folder", "C:\Program Files (x86)")
- GUICtrlSetData($inputFolder, $path & "\")
- Case $startP ;Button for starting PokeMMO
- _StartPokeMMO()
- Case $startBot ;Button to start the bot
- $PokeMMO_Exists = WinExists("[Class:LWJGL]") ;Checks to make sure PokeMMO is actually running. Note: I could not get autoit to recognize the game by the title so I used it's class. LWJGL is the class for java
- If $PokeMMO_Exists = 1 Then ;If the game is Running it activates the window
- WinActivate("[Class:LWJGL]")
- $size = WinGetPos("[Active]")
- $a1 = GUICtrlRead($inpFirst)
- $a2 = GUICtrlRead($inpSecond)
- $a3 = GUICtrlRead($inpThird)
- $a4 = GUICtrlRead($inpFourth)
- $A = GUICtrlRead($inpA)
- $B = GUICtrlRead($inpB)
- $isChecked = GUICtrlRead($chkGrinder)
- $pkmn1 = GUICtrlRead($inpPKMN1)
- $pkmn2 = GUICtrlRead($inpPKMN2)
- $pkmn3 = GUICtrlRead($inpPKMN3)
- $pkmn4 = GUICtrlread($inpPKMN4)
- $pkmn5 = GUICtrlRead($inpPKMN5)
- $inpL = GUICtrlRead($inpLeft)
- $inpR = GUICtrlRead($inpRight)
- If GUICtrlRead($inpLeft) = "" Then $inpL = Random(8,11)
- If GUICtrlRead($inpRight) = "" Then $inpR = $inpL
- If GUICtrlRead($chkALL) = $GUI_Checked Then $tolPKMN = 250
- _Start()
- Else
- MsgBox("", "PokeMMO", "PokeMMO not running")
- EndIf
- Case $stopBot
- Terminate()
- EndSwitch
- WEnd
- While 2
- Sleep(250)
- WEnd
- Func _StartPokeMMO() ;Function to start the game, only starts if there is a specified path and if the game file is named PokeMMO.exe
- If $path <> "" Then
- ShellExecute("PokeMMO.exe", "", $path & "\")
- If Not @error Then
- Sleep(250)
- Else
- MsgBox("", "", "Unable to launch PokeMMO.exe, did you do something?")
- EndIf
- Else
- MsgBox("", "", "Please select the PokeMMO folder first")
- EndIf
- EndFunc ;==>_StartPokeMMO
- Func _Start()
- _Hunting()
- EndFunc ;==>_Start
- Func _Hunting()
- If $a1+$a2+$a3+$a4 = 0 Then ;This are some user input variables I have for the PP of attack1/2/3/4
- MsgBox("", "No attacks", "No PP left for any movies. Heal, re-input the PP on the GUI and press OK when you're ready to continue.") ;The bot is checking to see if I have any PP before it starts to go "hunt"
- WinActivate("{Class:LWJGL]")
- Sleep(250)
- $a1 = GUICtrlRead($inpFirst) ;Reading the user input variables and setting corresponding attack variable to that variable
- $a2 = GUICtrlRead($inpSecond) ;I.E. $a2 is the second attack and it gets the value from $inpSecond which is the user input for the number of PP's for the second attack.
- $a3 = GUICtrlRead($inpThird)
- $a4 = GUICtrlRead($inpFourth)
- If $a1+$a2+$a3+$a4 = 0 Then ;Just another check to make sure the pokemon has enough PP to start attacking because sometimes people click too fast ;)
- MsgBox("", "No attacks", "No PP left for any movies. Heal, re-input the PP on the GUI and press OK when you're ready to continue.")
- WinActivate("{Class:LWJGL]")
- Sleep(250)
- $a1 = GUICtrlRead($inpFirst)
- $a2 = GUICtrlRead($inpSecond)
- $a3 = GUICtrlRead($inpThird)
- $a4 = GUICtrlRead($inpFourth)
- EndIf
- EndIf
- If $debug = 1 Then ToolTip("Hunting for PKMN", 0, 0) ;This is a great debugger to see where the script is at
- While 3
- Do
- If $LR = 0 Then ;Checking to see if it needs to move right or left first
- Send("{Right " & $inpR & "}") ;how many times right the bot must go
- $ran1 = Random(0,10) ;Just to make the bot look a little more human
- If $ran1 >= 7 Then Send("{Right " & $inpR/2 & "}")
- $LR = 1
- Sleep(50)
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\1.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- ;After moving right it looks for the image that shows up when user is in battle
- ElseIf $LR = 1 Then ;If LR does not = 0 then it uses this statement to move left first instead
- Send("{Left " & $inpL & "}") ;how many times left the bot must go
- $ran2 = Random(0,10) ;Just to make the bot look a little more human
- If $ran2 >= 8 Then Send("{Left " & $inpL/2 & "}")
- $LR = 0
- Sleep(50)
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\1.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- EndIf
- Until $Search = 1 ;It's going to continue doing everything above here until the variable $Search = 1, meaning it found the image
- If $debug = 1 Then ToolTip("In battle", 0, 0)
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;This is the arrow key in the game that shows up until the user presses their A or B key
- Until $Search = 1
- Send($A)
- Sleep(1000)
- _wtPKMN()
- WEnd
- EndFunc ;==>_Hunting
- Func _wtPKMN()
- Local $PKMN = 0
- Do
- If $tolPKMN = 250 Then
- If $debug = 1 Then ToolTip("Battling all PKMN", 0, 0)
- $PKMN = 1 ;$PKMN is a variable to identify wheter or not we're battling all PKMN or specified ones, 1 = all
- Sleep(250)
- Else
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\" & $pkmn1 & ".bmp", 0, $size[0] * .25, $size[1], $size[2] * .75, $size[3] / 2, $x, $y, $tolPKMN) ;Checking to see if it's one of the pokemon it's supposed to attack
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\" & $pkmn2 & ".bmp", 0, $size[0] * .25, $size[1], $size[2] * .75, $size[3] / 2, $x, $y, $tolPKMN)
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\" & $pkmn3 & ".bmp", 0, $size[0] * .25, $size[1], $size[2] * .75, $size[3] / 2, $x, $y, $tolPKMN)
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\" & $pkmn4 & ".bmp", 0, $size[0] * .25, $size[1], $size[2] * .75, $size[3] / 2, $x, $y, $tolPKMN)
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\" & $pkmn5 & ".bmp", 0, $size[0] * .25, $size[1], $size[2] * .75, $size[3] / 2, $x, $y, $tolPKMN)
- If $Search = 1 Or $Search2 = 1 Or $Search3 = 1 or $Search4 or $Search5 Then ;One of the searches was true so it's setting the variable $PKMN = 2, used in the next If statement
- $PKMN = 2
- Sleep(250)
- Else
- $PKMN = 3 ;None of the searches were true so the variable is 3, used in the next If statement
- Sleep(250)
- EndIf
- EndIf
- Until $PKMN <> 0
- If $PKMN = 1 or $PKMN = 2 Then ;Calling upon that variable and then deciding if we attack or run away, 1 and 2 mean we start _Grinder or _chooseAttack, 3 means we move to _exitBattle
- If $isChecked = 1 Then
- _Grinder()
- Else
- _chooseAttack()
- EndIf
- Else
- _exitBattle()
- EndIf
- EndFunc ;==>_wtPKMN
- Func _Grinder() ;Grinder function is kind of buggy, helps to have a very strong second spot pokemon
- While 4
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Battle select screen
- If $debug = 1 Then ToolTip("Waiting for selection screen...", 0, 0)
- Until $Search = 1
- Send("{Down}")
- Sleep(50)
- Send($A)
- Sleep(100)
- Do
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\10.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Pokemon select screen
- If $debug = 1 Then ToolTip("Selecting slave PKMN", 0, 0)
- Until $Search2 = 1
- Send("{Right}")
- Sleep(50)
- Send($A)
- Sleep(1500)
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\12.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;A trapped message will go here if available
- If $Search = 1 Then
- $expMS = 1
- _chooseAttack()
- Else
- Sleep(500)
- $expMS = 1
- _chooseAttack()
- EndIf
- WEnd
- EndFunc ;==>_Grinder
- Func _chooseAttack()
- Select
- Case $a1 > 0
- _firstAttack()
- Case $a1 = 0 And $a2 > 0
- _secondAttack()
- Case $a1+$a2 = 0 And $a3 > 0
- _thirdAttack()
- Case $a1+$a2+$a3 = 0 And $a4 > 0
- _fourthAttack()
- Case $a1+$a2+$a3+$a4 = 0
- MsgBox("", "No attacks", "No PP left for any movies. Stopping Bot.")
- EndSelect
- EndFunc ;==>_chooseAttack
- Func _firstAttack()
- While 5
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for the words "Select your", identified in the image 3.bmp.
- ;Signifies we're on the menu where we select Battle, Bag, Pokemon and Run
- If $Search = 1 Then
- If $a1 > 0 Then
- If $debug = 1 Then ToolTip("Using first attack", 0, 0)
- Send($A)
- Sleep(50)
- Send($A)
- Sleep(250)
- $a1 -= 1
- GUICtrlSetData($inpFirst, $a1)
- Sleep(3000)
- ElseIf $a1 = 0 Then
- _secondAttack()
- EndIf
- Else
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\4.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Checking for image 4.bmp which is the fainted text
- If $Search2 = 1 Then
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\6.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Checking for image 6.bmp which is FOE fainted
- If $Search3 = 1 Then
- If $debug = 1 Then ToolTip("Foe fainted moving to _endBattle", 0, 0)
- Do
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Checking for image 2.bmp which is the arrow. Signifies battle is over
- Until $Search4 = 1
- Send($A)
- Sleep(500)
- _endBattle() ;Moving to end battle
- Else
- If $debug = 1 Then ToolTip("I fainted, moving to _Fainted", 0, 0) ;Since the image 2.bmp was not found user PKMN fainted, moving to the Fainted function
- Do
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- Until $Search5 = 1
- Send($A)
- Sleep(500)
- $fainted += 1
- _Fainted()
- EndIf
- EndIf
- EndIf
- Until $Search2 = 1
- WEnd
- EndFunc ;==>_firstAttack
- Func _secondAttack()
- While 5
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- If $debug = 1 Then ToolTip("Using second attack", 0, 0)
- If $Search = 1 Then
- If $a2 > 0 Then
- If $debug = 1 Then ToolTip("Attacking", 0, 0)
- Send($A)
- Sleep(50)
- Send("{Right}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $a2 -= 1
- Sleep(250)
- GUICtrlSetData($inpSecond, $a2)
- Sleep(3000)
- ElseIf $a2 = 0 Then
- _thirdAttack()
- EndIf
- Else
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\4.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- If $Search2 = 1 Then
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\6.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- If $Search3 = 1 Then
- If $debug = 1 Then ToolTip("Foe fainted moving to _endBattle",0,0)
- Do
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- Until $Search4 = 1
- Send($A)
- Sleep(500)
- _endBattle()
- Else
- If $debug = 1 Then ToolTip("I fainted, moving to _Fainted",0,0)
- Do
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- Until $Search5 = 1
- Send($A)
- Sleep(500)
- $fainted += 1
- _Fainted()
- EndIf
- EndIf
- EndIf
- Until $Search = 1
- WEnd
- EndFunc ;==>_secondAttack
- Func _thirdAttack()
- While 5
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- If $debug = 1 Then ToolTip("Using third attack", 0, 0)
- If $Search = 1 Then
- If $a3 > 0 Then
- If $debug = 1 Then ToolTip("Attacking", 0, 0)
- Send($A)
- Sleep(50)
- Send("{Down}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $a3 -= 1
- Sleep(250)
- GUICtrlSetData($inpThird, $a3)
- Sleep(3000)
- ElseIf $a3 = 0 Then
- _fourthAttack()
- EndIf
- Else
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\4.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- If $Search2 = 1 Then
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\6.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- If $Search3 = 1 Then
- If $debug = 1 Then ToolTip("Foe fainted moving to _endBattle",0,0)
- Do
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- Until $Search4 = 1
- Send($A)
- Sleep(500)
- _endBattle()
- Else
- If $debug = 1 Then ToolTip("I fainted, moving to _Fainted",0,0)
- Do
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- Until $Search5 = 1
- Send($A)
- Sleep(500)
- $fainted += 1
- _Fainted()
- EndIf
- EndIf
- EndIf
- Until $Search = 1
- WEnd
- EndFunc ;==>_thirdAttack
- Func _fourthAttack()
- While 5
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- If $debug = 1 Then ToolTip("Using fourth attack", 0, 0)
- If $Search = 1 Then
- If $a4 > 0 Then
- If $debug = 1 Then ToolTip("Attacking", 0, 0)
- Send($A)
- Sleep(50)
- Send("{Right}")
- Sleep(50)
- Send("{Down}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $a4 -= 1
- Sleep(250)
- GUICtrlSetData($inpFourth, $a4)
- Sleep(3000)
- ElseIf $a4 = 0 Then
- MsgBox("", "", "No more Moves")
- Exit
- EndIf
- Else
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\4.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- If $Search2 = 1 Then
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\6.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- If $Search3 = 1 Then
- If $debug = 1 Then ToolTip("Foe fainted moving to _endBattle",0,0)
- Do
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- Until $Search4 = 1
- Send($A)
- Sleep(500)
- _endBattle()
- Else
- If $debug = 1 Then ToolTip("I fainted, moving to _Fainted",0,0)
- Do
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp",0,$size[2]*.25,$size[3]*.33,$size[2]*.75,$size[3]*.66,$x,$y,$tol)
- Until $Search5 = 1
- Send($A)
- Sleep(500)
- $fainted += 1
- _Fainted()
- EndIf
- EndIf
- EndIf
- Until $Search = 1
- WEnd
- EndFunc ;==>_fourthAttack
- Func _exitBattle()
- Local $run = 3 ;Variable for running away. Tries to run away 3 times if at failure we move to attack
- ;Programmer note: Declaring $run as local means we only use it in this function, when we leave the function (i.e. when we move back to _Hunting or _chooseAttack) the variable is reset back to 3 even if while in the function it is 0
- While 6
- Do
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for battle menu
- If $debug = 1 Then ToolTip("Trying to run away", 0, 0)
- Sleep(250)
- Until $Search = 1
- If $Search = 1 Then
- Send("{right}")
- Sleep(50)
- Send("{down}")
- Sleep(50)
- Send($A)
- $run -= 1 ;Subtracting one from run, when it gets to three it means we're in some kind of trap like arena trap, whirlpool, etc.
- Sleep(500)
- Do
- $Search2 = _ImageSearchArea(@ScriptDir & "\Data\Images\8.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Got away safely
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\9.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Wild pokemon fled
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\11.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Cannot escape
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Running away failed
- If $Search2 = 1 Or $Search3 = 1 Then
- If $debug = 1 Then ToolTip("Got away successfully", 0, 0)
- If $fainted = 0 Then
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\8.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\9.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- Until $Search <> 1 ;Keep looking for the escape messages until they are no longer there, signifiying the battle is over and move back to the beginning
- Sleep(500)
- _Hunting()
- Else
- If $chkGrinder = 1 Then ;Grinder box is checked and we got a faint message for our slave PKMN-the one doing all the fighting
- MsgBox("", "Fainted", "Slave pokemon has fainted")
- Exit
- Else
- MsgBox("", "Fainted", "Pokemon in spot 1 has fainted") ;Grinder box is not checked and the pokemon in the first spot fainted
- Exit
- EndIf
- EndIf
- ElseIf $Search4 = 1 Then ;Search4 is true which means we were not able to escape. A trap message like arena trap.
- If $debug = 1 Then ToolTip("Can't escape!", 0, 0)
- If $run = 0 Then
- _chooseAttack()
- EndIf
- Sleep(250)
- ElseIf $Search5 = 1 Then
- If $debug = 1 Then ToolTip("I cannot run away, moving to attack", 0, 0)
- Sleep(250)
- _chooseAttack()
- EndIf
- Until $Search2 = 1 Or $Search3 = 1 Or $Search4 = 1 Or $Search5 = 1
- $Search6 = _ImageSearchArea(@ScriptDir & "\Data\Images\4.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for image 4.bmp which is the fainted message, only our PKMN can faint
- If $Search6 = 1 Then
- If $debug = 1 Then ToolTip("My PKMN Fainted Fainted!", 0, 0)
- $fainted += 1
- Send($A)
- _Fainted()
- EndIf
- EndIf
- Until $Search2 = 1 Or $Search3 = 1
- WEnd
- EndFunc ;==>_exitBattle
- Func _endBattle()
- Local $lvl = 0 ;Another local variable used for checking if our PKMN leveled up. I don't think I was able to ever get this to work.
- While 7
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Checking for for the first EXP
- If $debug = 1 Then ToolTip("Waiting until the EXP points message", 0, 0)
- Until $Search = 1
- If $Search = 1 Then
- Send($A)
- Sleep(500)
- $Search3 = _ImageSearchArea(@ScriptDir & "\Data\Images\5.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for the "pokemon grew to level *"
- If $debug = 1 Then ToolTip("Checking to see if PKMN leveled", 0, 0)
- If $Search3 = 1 Then
- If $debug = 1 Then ToolTip("My PKMN Leveled!", 0, 0)
- Do
- $endSent = _ImageSearchArea(@ScriptDir & "\Data\Images\5.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for the "pokemon grew to level *"
- Until $endSent <> 1
- Sleep(750)
- EndIf
- $newmove = _ImageSearchArea(@ScriptDir & "\Data\Images\learn.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol)
- ;Second pokemon
- If $expMS = 1 Then
- Sleep(250)
- Do
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\2.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Checking for for the second EXP
- If $debug = 1 Then ToolTip("Looking to see if second PKMN gained EXP", 0, 0)
- Until $Search4 = 1
- If $Search4 = 1 Then
- Send($A)
- Sleep(500)
- $Search5 = _ImageSearchArea(@ScriptDir & "\Data\Images\5.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for the "pokemon grew to level *"
- If $debug = 1 Then ToolTip("Checking to see if other PKMN leveled", 0, 0)
- If $Search5 = 1 Then
- If $debug = 1 Then ToolTip("My PKMN leveled", 0, 0)
- Do
- $endSent = _ImageSearchArea(@ScriptDir & "\Data\Images\endsent.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Don't think I was able to get this to work
- Until $endSent <> 1
- Sleep(500)
- $newmove = _ImageSearchArea(@ScriptDir & "\Data\Images\learn.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Trying to get the bot to recognize if PKMN is trying to learn new move
- If $newmove = 1 Then MsgBox("","New Move!","Pokemon is trying to learn a new move") ;Don't think I was able to get this to work
- EndIf
- EndIf
- Else
- Sleep(250)
- EndIf
- EndIf
- Do
- $Search4 = _ImageSearchArea(@ScriptDir & "\Data\Images\1.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Checking to see if still in battle
- If $Search4 = 1 Then
- If $debug = 1 Then ToolTip("Still in battle...", 0, 0)
- Sleep(250)
- Else
- If $debug = 1 Then ToolTip("Battle over, if fainted then stopping, else moving to _Hunting", 0, 0)
- Sleep(250)
- If $fainted = 0 Then ;If no PKMN fainted moving back to _Hunting, else stopping bot
- _Hunting()
- Else
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "PokeMMO Dir", $path)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "A Key", $A)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "B Key", $B)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "FirstPP", $a1)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "SecondPP", $a2)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "ThirdPP", $a3)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "FourthPP", $a4)
- If GUICtrlRead($chkALL) = $GUI_Checked Then
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Battle All", 1)
- Else
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Battle All", 0)
- EndIf
- MsgBox("", "Fainted", "Pokemon in spot 1 has fainted")
- Exit
- EndIf
- EndIf
- Until $Search4 <> 1
- WEnd
- EndFunc ;==>_endBattle
- Func _Fainted() ;This got a little buggy, not sure if it works because I based it off having 6 pokemon
- While 8
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\10.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Looking for the PKMN select screen
- If $debug = 1 Then ToolTip("Searching for pokemon select screen", 0, 0)
- Sleep(250)
- If $Search = 1 Then
- Select
- Case $fainted = 1
- Send("{Right 2}")
- Sleep(50)
- Send("{Down}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $fainted += 1
- Case $fainted = 2
- Send("{Right}")
- Sleep(50)
- Send("{Down}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $fainted += 1
- Case $fainted = 3
- Send("{Down}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $fainted += 1
- Case $fainted = 4
- Send("{Right 2}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $fainted += 1
- Case $fainted = 5
- Send("{Right}")
- Sleep(50)
- Send($A)
- Sleep(250)
- $fainted = +1
- Case $fainted = 6
- Send($A)
- Sleep(250)
- MsgBox("", "No usable PKMN", "Blacked out because of no usable PKMN")
- EndSelect
- EndIf
- Until $Search = 1
- Do
- $Search = _ImageSearchArea(@ScriptDir & "\Data\Images\3.bmp", 0, $size[2] * .25, $size[3] * .33, $size[2] * .75, $size[3] * .66, $x, $y, $tol) ;Able to switch PKMN now trying to exit battle
- If $debug = 1 Then ToolTip("Waiting for selection screen...", 0, 0)
- Sleep(250)
- If $Search = 1 Then
- _exitBattle()
- Else
- Sleep(250)
- EndIf
- Until $Search = 1
- WEnd
- EndFunc ;==>_Fainted
- Func Paused() ;The pause bot hotkey. Kind of buggy because if you skip something it's looking for the bot is forever frozen.
- $Paused = Not $Paused
- MsgBox("", "Paused", "Bot is paused")
- WinActivate("[Class:LWJGL]")
- Sleep(250)
- EndFunc ;==>Paused
- Func Terminate()
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "PokeMMO Dir", $path)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "A Key", $A)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "B Key", $B)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "FirstPP", $a1)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "SecondPP", $a2)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "ThirdPP", $a3)
- IniWrite($iniPath & "Settings.ini", "EV Trainer Settings", "FourthPP", $a4)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "First PKMN", $pkmn1)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Second PKMN", $pkmn2)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Third PKMN", $pkmn3)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Fourth PKMN", $pkmn4)
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Fifth PKMN", $pkmn5)
- If GUICtrlRead($chkALL) = $GUI_Checked Then
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Battle All", 1)
- Else
- IniWrite($inipath & "Settings.ini", "EV Trainer Settings", "Battle All", 0)
- EndIf
- Exit
- EndFunc ;==>Terminate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement