Code:
;Fishbuddy - made by [email protected].
;This source is ment to learn from only, please do not publish this claiming you've made it. You're only fooling yourself
;Making a bot yourself and seeing it catch a fish is much more satisfacting
;vars, edit this
$bobcolor = 0xb73a15 ;color for the bob (in HEX format)
$hotkey = 7 ;hotkey for fishing
$border = 150 ;the edge of the screen that the bot will not search in (hard to explain :P)
;don't change anything below this line
HotKeySet("{scrolllock}", "stop") ;set the hotkey to stop the bot
HotKeySet("{pause}", "pause") ;set the hotkey to pause the bot
Dim $timerstart, $pos, $pause ;dim some vars that will be used later, to prevent errors
$fishcaught = 0 ;this will be shown in the tooltip. default is 0 as we haven't caught any fish yet doh
Func stop() ;function to stop the bot
tt("Quiting - " & $fishcaught & " fish were caught") ;tooltip telling the user that we're is quiting
sleep(1000) ;sleeping before quiting
Exit ;exit the bot ^^
EndFunc
Func pause() ;function to pause the bot
if $pause = 1 Then ;if the bot is already paused,
global $pause = 0 ;then change the pause var to 0
Else ;else
global $pause = 1 ;change the pause var to 1
tt("Bot paused - press pause again to resume fishing") ;tell the user that the bot is pausing
while $pause = 1 ;as long as the bot is paused,
sleep(1000) ;do nothing
WEnd ;end of the loop
EndIf
EndFunc
Func castpole() ;function to cast the pole (proper grammer?)
tt("Casting pole") ;tell the user we're casting the pole
Send($hotkey) ;press the hotkey for fishing (defined at the top)
Global $timerstart = TimerStart() ;start a timer, will be used later to check if 30 seconds have passed
sleep(3000) ;do nothing for 3 seconds, to wait for the bob to appear (lag)
tt("Searching for the bob") ;tell the user we're searching for the bob
Global $pos = PixelSearch($border, $border, @DesktopWidth - $border, @DesktopHeight - $border, $bobcolor, 20, 3)
;search for the bob, color defined at the top. if found, set the $pos var, this contains the location for the bob
if not @error Then ;if no error has occured while searching, the bob has been found
tt("Found the bob!") ;tell the user that it was found
MouseMove($pos[0], $pos[1]) ;move the mouse to that position
Global $gotbite = 0 ;reset this var, will be used later
waitforbite() ;run the function that waits for a bite
EndIf
EndFunc
Func waitforbite() ;function that waits untill the splash was found, then it loots.
while(TimerDiff($timerstart) < 30000) ;as long as 30 seconds have not passed, continue to search for a splash
tt("Waiting for a bite") ;tell the user we're waiting for a bite
PixelSearch($pos[0]-60, $pos[1] - 60, $pos[0] + 60, $pos[1] + 60, 0xffffff, 25, 3) ;search for the splash
if not @error Then ;if no error has occured, the splash was found
tt("Bite!") ;tell the user we have a bite!
loot() ;run the function that handles looting
ExitLoop ;exit the loop that was looking for a splash. removing this might make the bot crash after a very long time
EndIf
sleep(10) ;wait a very short while before looking for the splash again, removing this MIGHT make your fps drop
WEnd
EndFunc
Func loot() ;function that handles looting when we have a bite
tt("Looting") ;tell the user we're looting
$fishcaught = $fishcaught + 1 ;adding +1 to the fish caught, will be shown in the tooltip
Send("{lshift down}") ;press the left shift button
MouseClick('right', $pos[0], $pos[1], 1, 0) ;click the right mouse button on the location where the bob was found earlier
Send("{lshift up}") ;release the left shift button
sleep(1000) ;wait one second, to make sure we got the loot (lag)
EndFunc
Func tt($txt) ;function that shows a text at the top-left of the screen, it will also show how many fish have been caught
ToolTip('[' & $fishcaught & '] - '& $txt, 1, 1) ;make the tooltip and add text
EndFunc
if not WinExists("World of Warcraft") Then ;check if WoW is (not) running
tt("Please start WoW before running the bot") ;if that's the case, warn the user and quit
stop() ;quit, like said 1 line before :p
EndIf
WinActivate("World of Warcraft") ;activate the WoW window
WinWait("World of Warcraft") ;wait untill WoW is active
tt("Starting the bot - [Scrolllock] to exit, [Pause] to pause") ;tell the user that the bot is starting
sleep(1000) ;wait a second, so the user can read the previous message
MouseMove($border, $border, 1000) ;these 4 lines show the user where the bot is gonna search for the bob by moving the mouse
MouseMove(@DesktopWidth - $border, $border, 1000)
MouseMove(@DesktopWidth - $border, @DesktopHeight - $border, 1000)
MouseMove(150, @DesktopHeight - $border, 1000)
While 1 ;as long as.. forever,
castpole() ;run this function, which casts the pole and leads to everything else
WEnd
Also, feel free to ask any questions about AutoIt. I'll try to help you the best I can