Skip to content

Instantly share code, notes, and snippets.

@Sniffx
Forked from A2TC-YT/auto_fishing.ahk
Last active January 27, 2024 20:11
Show Gist options
  • Select an option

  • Save Sniffx/ee5ae43d42894a6499c24b66586cc10c to your computer and use it in GitHub Desktop.

Select an option

Save Sniffx/ee5ae43d42894a6499c24b66586cc10c to your computer and use it in GitHub Desktop.
afk fishing macro for destiny 2. You will need to install the Gdip_all library which you can find here: https://www.autohotkey.com/boards/viewtopic.php?t=6517 and the virtual controller from here: https://github.com/A2TC-YT/Tabbed-Out-AFK
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
MsgBox, ***READ BEFORE USING***`nYou must have a 1440p screen for this to work. Make sure you are on 7 brightness, chromatic abberation is off, and hud opacity is max. Make sure you have interact bound to "E". Press F3 to start and F4 to stop. Does NOT work on Nessus.
pToken := Gdip_Startup()
F3::
{
Loop,
{
loop,
{
pBitmap := Gdip_BitmapFromScreen("1243|971|37|21")
pWhite := simpleColorCheck(pBitmap, 37, 21)
Gdip_DisposeImage(pBitmap)
if (pWhite >= 0.15)
Break
}
Send, {e down}
Sleep, 800
Send, {e Up}
DllCall("mouse_event",uint,1,int,-300,int,0,uint,0,int,0)
Sleep, 200
DllCall("mouse_event",uint,1,int,300,int,0,uint,0,int,0)
Send, {d Down}
Sleep, 100
Send, {d Up}
Sleep, 100
Send, {a Down}
Sleep, 100
Send, {a Up}
}
}
Return
simpleColorCheck(pBitmap, w, h)
{
x := 0
y := 0
white := 0
total := 0
loop %h%
{
loop %w%
{
color := (Gdip_GetPixel(pBitmap, x, y) & 0x00F0F0F0)
if (color == 0xF0F0F0)
white += 1
total += 1
x+= 1
}
x := 0
y += 1
}
pWhite := white/total
return pWhite
}
F4::Reload
#Include <Gdip_all>
@tomekkk1
Copy link

tomekkk1 commented Jun 9, 2023

Hey, I can't get this to work, installed everything as you described, but it only loops through the instances and never even casts the line in the first place, window is always visible, but no casting or catching, any ideas? I also had to change the bits where it says include to include AHK-ViGEm-Bus.ahk or it wouldn't play ball for me at all
It seems to be detecting the controller support as it gives me a notification, but doesn't execute the script past that.

@Sniffx
Copy link
Author

Sniffx commented Jun 9, 2023

I would try this simple script to check if the virtual gamepad works.
While you are ingame in any patrol zone, press F5 and check if your character does anything. If it does maybe you have your ingame controller buttons customized and you would need to find the Interact button and use it in the fishing script.
The name of the buttons are: Square, Cross, Circle, Triangle, L1, R1, L2, R2, LS, RS

#SingleInstance, Force
#include <AHK-ViGEm-Bus> ;Needed for PS4 controller support
SendMode Input
SetWorkingDir, %A_ScriptDir%

controller := new ViGEmDS4()

F5:: 
{
	controller.Buttons.Square.SetState(true) ;Press Square button. Equivalent to pressing the button "E" on the keyboard.
	Sleep, 800 ; DO NOT CHANGE
	controller.Buttons.Square.SetState(false) ;We release the button. Equivalent to stop touching the "E" key on the keyboard.
	Sleep, 2000 	
	
	controller.Buttons.Circle.SetState(true)
	Sleep, 800 ; DO NOT CHANGE
	controller.Buttons.Circle.SetState(false) 
	Sleep, 2000 	
	
	controller.Buttons.Triangle.SetState(true)
	Sleep, 800 ; DO NOT CHANGE
	controller.Buttons.Triangle.SetState(false) 
	Sleep, 2000 	

	controller.Buttons.Cross.SetState(true)
	Sleep, 800 ; DO NOT CHANGE
	controller.Buttons.Cross.SetState(false) 
	Sleep, 2000 	
}
Return

@tomekkk1
Copy link

tomekkk1 commented Jun 12, 2023

it doesn't look like it's liking the virtual input, firing what you sent doesn't seem to be doing anything, neither when the window is focused and not

And again, I had to change to AHK-ViGEm-Bus.ahk for it to even fire up

works after changing the button layout to xbox controller with perfect catches every time, thanks

@Revadike
Copy link

I also saw this https://github.com/Chadhendrixs/D2SemiAutoFisher which uses python instead.

@Revadike
Copy link

Anyway, I wonder if it's possible to take a screenshot using the controller and analyze that instead. I know the game on PC lets u take screenshots using any key you want by editing cvars.xml (in appdata). Not sure about the controller.

@SBP1213
Copy link

SBP1213 commented Jun 23, 2023

Few things that may answer peoples problems here...

  1. You will need AHK v1.xxx
  2. If you have multiple AHK versions installed, Open AHK, Select launch settings, select run all scripts with a specific interpreter and use C:\Program Files\AutoHotkey**v1.(YOURVERSIONHERE)**\AutoHotkeyU64.exe
  3. Tabbed-Out-AFK comes with 3 main files in a LIB folder you care about, AHK-ViGEM-BUS.ahk, CLR,ahk, and ViGEmWrapper.dll, right click each and go to properties. Depending on version of windows you may see at the bottom of the general tab something about the file being downloaded from the internet, select unblock and apply/ok.
  4. Navigate to C:\Program Files\AutoHotkey**v1.(YOURVERSIONHERE)**\ and copy the entire LIB folder here
  5. If youre having issues where nothing is happening, there is a chance PS4 Emulator isnt launching try replacing the following lines in auto_fishing.ahk

controller := new ViGEmDS4()
to
controller := new ViGEmXb360()

and

controller.Buttons.Square.SetState(true) ;Initial fishing cast using the virtual gamepad. Equivalent to pressing the button "E" on the keyboard.
Sleep, 800 ; DO NOT CHANGE
controller.Buttons.Square.SetState(false) ;We release the button. Equivalent to stop touching the "E" key on the keyboard.
Sleep, 250 

to

`controller.Buttons.X.SetState(true) ;Initial fishing cast using the virtual gamepad. Equivalent to pressing the button "E" on the keyboard.
Sleep, 800 ; DO NOT CHANGE
controller.Buttons.X.SetState(false) ;We release the button. Equivalent to stop touching the "E" key on the keyboard.
Sleep, 250 `

@Sniffx
Copy link
Author

Sniffx commented Jun 23, 2023

I adapted AmJustS (https://gist.github.com/AmJustS/d1eff6b0f78a48d99868c224e5dbbaaf) fishing script to be used in window mode and virtual gamepad.
Original A2TC-YT script is good enough (1000fish captured with it) but new AmJustS script is better imo (3000 fish captured). It almost never fails to catch a fish (maybe 1 fail per hour fishing), they are always "perfect catch!":
https://gist.github.com/Sniffx/da7b3eb0e13211eb15a9114c89674ebe

@Revadike
Copy link

I adapted AmJustS (AmJustS/d1eff6b0f78a48d99868c224e5dbbaaf) fishing script to be used in window mode and virtual gamepad. Original A2TC-YT script is good enough (1000fish captured with it) but new AmJustS script is better imo (3000 fish captured). It almost never fails to catch a fish (maybe 1 fail per hour fishing), they are always "perfect catch!": Sniffx/da7b3eb0e13211eb15a9114c89674ebe

Can you use it in a virtual desktop?

@mrIncoder
Copy link

#MaxThreadsPerHotKey, 2
Toggle := 0

F1::
Toggle := !Toggle

While (Toggle) {

Click

Sleep, 3000

Click

Sleep, 100

PixelSearch, tap, tapy, 1497, 233, 1430, 842, 0x000000, 1, fast, RGB

If (tapX) {
                        
    While (tapX && Toggle) {
          
        Click
                       
        Sleep, 10
         
        PixelSearch, tapX, tapY, 1497, 233, 1430, 842, 0x000000, 1, fast, RGB
    }
}

}

@mrIncoder
Copy link

your welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment