[AHK SCRIPT] Torchlight II Auto-fishing

WikingWiking Posts: 12
edited November 2016 in Mod Showcase
15d70e0e10ccedcbd2f9c4f2580d47f8.png

Just a small script I made, tested and debugged over time, so I could watch a movie or something while this sucker did fishing for me.
And hooooo boy, did it take ~3-4h+ to catch 1000fishes or what!
Efficiency is around 70-80% so I'm quite satisfied. Decided to share it here as I couldnt find any already made.


;controls:
;F5 to start fishing
;P hold for 5s+ to stop fishing
;F6 to start/stop color and coordinate find
;F7 to copy color and coordinate values to clipboard


IT WILL NOT WORK OUT OF THE BOX, YOU WILL NEED TO TWEAK IT BASED ON YOUR PC/SETTINGS


1.===========================================================================
-Get Autohotkey program from http://www.autohotkey.com/
-Get Notepad++ for editing (not necessary, but it will help a lot) http://notepad-plus-plus.org/download/v6.7.5.html
-Get my script source-code from one of the 3 places:
http://pastebin.com/HDJqNCHb
or
https://mega.co.nz/#!FpQThQAB!Grszrpgp9 ... hUdr-Mb5OY
or
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;==================================================================

;TORCHLIGHT 2 FISHING AHK SCRIPT BY WIKING

;V0.8 - working
;efficiency:
;~8/10 fishes during day/night
;~7/10 fishes during transition time when shadows move

;controls:
;F5 to start fishing
;P hold for 5s+ to stop fishing
;F6 to start/stop color and coordinate find
;F7 to copy color and coordinate values to clipboard

;==================================================================


;**************************************************************

;***********************Fishing Script*************************
F5::
loop {
	PixelSearch, Px, Py, 780, 493, 811, 539, 0x80798F, 20, Fast         ;search box coordinates go here x1, y1, x2, y2, color, shades, speed
		GetKeyState, state, P
			if state = D
			{
			ToolTip
			break
			}
		else{	
			if ErrorLevel
				{
				ToolTip SEARCHING
				MouseMove, 955, 444											;clicks on the fishing hole
				Sleep 200
				Send, {LButton down}
				Sleep 100
				Send, {LButton up}
				Sleep 200
				}
			else
				{
				ToolTip MATCH
				sleep 20
				MouseMove, 1680/2, 1050/2									;clicks on the centre of the screen, aka catch fish
				Sleep 40
				Send, {LButton down}
				Sleep 40
				Send, {LButton up}
				Sleep 100
				MouseMove, 955, 444											;clicks on the fishing hole
				Sleep 3000
				Send, {LButton down}
				Sleep 100
				Send, {LButton up}
				Sleep 100
				}
			}
	}
return
;**************************************************************

;***********************Get Color**************************
;F6  = Start stop Color Detection
;F7 = Copy currently color to clipboard
;***********************************************************

#MaxThreadsPerHotkey 2

F6::
Toggle := !Toggle
While Toggle {
	MouseGetPos Xpos, Ypos
	PixelGetColor Colour, %Xpos%, %Ypos%, RGB
	StringTrimLeft Colour, Colour, 2					; Remove 0x
	ToolTip %Colour% X%Xpos% Y%Ypos%
	}
ToolTip
Return

F7::
StringTrimLeft Colour, Colour, 2					; Remove 0x
Clipboard = %Colour% X%Xpos% Y%Ypos%
ToolTip Copied to the clipboard:`n%Colour% X%Xpos% Y%Ypos%
Sleep 3000
ToolTip %Colour%
Return

2.===========================================================================
Get to the fishing spot in Zeryphesh, just above the broken barrel
c1d9532ad3d5198bc6dc33f722a9ed37.jpg
and these are my video settings in case you need them, shadows do affect catch rate so I recommend you turn them off.
2149e1470cb9e7413542402059a8bc0f.png

3.===========================================================================
Run the script with AHK, also open it in notepad++ for editing.
Now prepare a pen and paper, press F6 while above barrel, next to fishing hole, to start coordinate/color sniffing, and write down stuff.
You need the following coordinates:
Your game resolution (mine was 1680x1050), goes under line 50 (and its divided /2 so it would be center of your screen)
MouseMove, 1680/2, 1050/2									;clicks on the centre of the screen, aka catch fish
Fishing hole coordinates. Its on lines 36 & 56
MouseMove, 955, 444											;clicks on the fishing hole
MouseMove, 955, 444											;clicks on the fishing hole
Search box TOP_LEFT and BOTTOM_RIGHT goes under line 28 and its those two dots on the pic
PixelSearch, Px, Py, 780, 493, 811, 539, 0x80798F, 20, Fast         ;search box coordinates go here x1, y1, x2, y2, color, shades, speed
c6134dbce8160261da9fef208d835199.png

4.===========================================================================
Press F6 to stop the color/coordinate finder, and start editing the script with your coordinates.
When you finish typing in your coordinates, make sure to SAVE and RELOAD the script!
Now pressing F5 while in that right position, should click on the fishing hole and show you a tooltip box saying SEARCHING.
When those 2 circles meet script will detect it (it has specific color) and tooltip box will say MATCH before clicking on the center of your screen then back on fishing hole.
Hold P till the SEARCHING tooltip box dissapears to stop fishing.

Comments

  • WikingWiking Posts: 12
    Here's the thing in action, a showcase of the script working:

    efdbab978f891fe52f7f361a1a840d00.png

    https://www.youtube.com/watch?v=bh1NRXMeFB0
  • JAILJAIL Posts: 2
    I can not set up when I do play an active window at me hot keys do not work
  • WikingWiking Posts: 12
    JAIL wrote:
    I can not set up when I do play an active window at me hot keys do not work

    I'm sorry, I dont quite understand your problem here, could you try describing it with a few more sentences?
    Also, when you run script and just press F6, does it give you the color/coordinates like here:
    107b0d8242850685914efc7e78a5a165.png

    As long as you have autohotkey installed and script running, it should be working in any window, I didn't limit its functionality to TL2 only.
  • JAILJAIL Posts: 2
    Thank you, at that time were not working hotkeys in the game, and now it works!
  • Hi there!
    First of all i want to thank you for the script and work you put in it. Want to make good use of it but have a hard time. I`m trying to get 1000 fish achivment in Torchlight 1 not 2 but this doesnt matter because i cant really run macro porperly. I was trying MacroGamer, Pulovers Macro Creator and now this script adjusting all coordinates but still no go. Was wondering if you have any good solution how to "catch" this **** pixel colour.
    This is my script based on your work. Resolution im playing is 1920x1080.

    1. AHK tool is installed. Script is running
    2. In game im pressing F6 - coordinate/colour is beeing shown
    3. Putting those number into the script, save, reload
    4. Pressing F5 in game
    5. Character is starting to fish and immiedatly stops after 0.5 sec. And this state is looping.
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    ;==================================================================
    
    ;TORCHLIGHT 2 FISHING AHK SCRIPT BY WIKING
    
    ;V0.8 - working
    ;efficiency:
    ;~8/10 fishes during day/night
    ;~7/10 fishes during transition time when shadows move
    
    ;controls:
    ;F5 to start fishing
    ;P hold for 5s+ to stop fishing
    ;F6 to start/stop color and coordinate find
    ;F7 to copy color and coordinate values to clipboard
    
    ;==================================================================
    
    
    ;**************************************************************
    
    ;***********************Fishing Script*************************
    F5::
    loop {
    	PixelSearch, Px, Py, 964, 650, 995, 663, 0x737288, 20, Fast         ;search box coordinates go here x1, y1, x2, y2, color, shades, speed
    		GetKeyState, state, P
    			if state = D
    			{
    			ToolTip
    			break
    			}
    		else{	
    			if ErrorLevel
    				{
    				ToolTip SEARCHING
    				MouseMove, 1052, 686											;clicks on the fishing hole
    				Sleep 200
    				Send, {LButton down}
    				Sleep 100
    				Send, {LButton up}
    				Sleep 200
    				}
    			else
    				{
    				ToolTip MATCH
    				sleep 20
    				MouseMove, 1920/2, 1080/2								;clicks on the centre of the screen, aka catch fish
    				Sleep 40
    				Send, {LButton down}
    				Sleep 40
    				Send, {LButton up}
    				Sleep 100
    				MouseMove, 1052, 686											;clicks on the fishing hole
    				Sleep 3000
    				Send, {LButton down}
    				Sleep 100
    				Send, {LButton up}
    				Sleep 100
    				}
    			}
    	}
    return
    ;**************************************************************
    
    ;***********************Get Color**************************
    ;F6  = Start stop Color Detection
    ;F7 = Copy currently color to clipboard
    ;***********************************************************
    
    #MaxThreadsPerHotkey 2
    
    F6::
    Toggle := !Toggle
    While Toggle {
    	MouseGetPos Xpos, Ypos
    	PixelGetColor Colour, %Xpos%, %Ypos%, RGB
    	StringTrimLeft Colour, Colour, 2					; Remove 0x
    	ToolTip %Colour% X%Xpos% Y%Ypos%
    	}
    ToolTip
    Return
    
    F7::
    StringTrimLeft Colour, Colour, 2					; Remove 0x
    Clipboard = %Colour% X%Xpos% Y%Ypos%
    ToolTip Copied to the clipboard:`n%Colour% X%Xpos% Y%Ypos%
    Sleep 3000
    ToolTip %Colour%
    Return
    

    And some script logs
    Script lines most recently executed (oldest first).  Press [F5] to refresh.  The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0).  The bottommost line's elapsed time is the number of seconds since it executed.
    
    ---- D:\***************\Fishing Bot TL2 - Wiking v0.8.ahk
    002: SendMode,Input
    003: SetWorkingDir,%A_ScriptDir%
    026: Return (4.41)
    027: Loop
    028: PixelSearch,Px,Py,964,650,995,663,0x737288,20,Fast (0.03)
    029: GetKeyState,state,P
    030: if state = D
    036: if ErrorLevel  
    038: ToolTip,SEARCHING (0.03)
    039: MouseMove,1052,686 (0.17)
    040: Sleep,200 (0.20)
    041: Send,{LButton down} (0.03)
    042: Sleep,100 (0.11)
    043: Send,{LButton up} (0.03)
    044: Sleep,200 (0.20)
    045: }
    063: }
    064: }
    
  • Nvm. Managed to did this in a hard way.
  • WikingWiking Posts: 12
    pioters wrote:
    Nvm. Managed to did this in a hard way.

    Hard way as in "Manual Fishing", or hard was as in "Smack stuff into script until it works"?
    Either way you saved me from installing Torchlight 1 to try it out myself, heh.
Sign In or Register to comment.