Skip to content

Instantly share code, notes, and snippets.

@A2TC-YT
Last active July 5, 2023 23:56
Show Gist options
  • Save A2TC-YT/4c2564442e2c60792e322a0dadfbec09 to your computer and use it in GitHub Desktop.
Save A2TC-YT/4c2564442e2c60792e322a0dadfbec09 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
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
global 1080p := 0
MsgBox, ***READ BEFORE USING***`nMake 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.
InputBox, 1080p, Resolution, If your computer monitor resolution is 1440p enter 0`nIf your computer monitor is 1080p enter 1
pToken := Gdip_Startup()
F3::
{
coords := "1243|971|37|21"
width := 37
height := 21
threshold := 0.16
if (1080p)
{
coords := "932|728|27|16"
width := 27
height := 16
threshold := 0.12
}
Loop,
{
loop,
{
pBitmap := Gdip_BitmapFromScreen(coords)
pWhite := simpleColorCheck(pBitmap, width, height)
Gdip_DisposeImage(pBitmap)
if (pWhite >= threshold)
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 %A_ScriptDir%\Gdip_all.ahk
@Yukari7777
Copy link

Yukari7777 commented Jun 5, 2023

Author has not answer questions so I leave some considerations to make this macro work.

Note that this macro recognizes a square area of the screen and looks for font color.
Catching a fish too early after n times or not catching/casting at all is related to the recognition failure not the timing.
You may adjust coords, width and threshold until it's working.

Things can unexpectedly affect color recognition including :

  • Set language of Destiny 2
    • if your language font is thinner then English's, try lower the threshold a bit. If bolder, vice versa. Or adjust the coords & width.
  • Shader of your armor
    • If you have applied too whitish shader on your armor, it will negatively affect for macro. I think it's best to use black shader.
  • Monitor manufacturer and monitor settings
    • Your monitor settings like brightness, contrast or color temperature and monitor manufacturer; because color calibration and color accuracy differs, can also be affected by recognition, even if you set ingame's brightness is 7 and chromatic abberation is off. Try lower threshold.

@D2professionalfisherman
Copy link

Author has not answer questions so I leave some considerations to make this macro work.

Note that this macro recognizes a square area of the screen and looks for font color. Catching a fish too early after n times or not catching/casting at all is related to the recognition failure not the timing. You may adjust coords, width and threshold until it's working.

Things can unexpectedly affect color recognition including :

  • Set language of Destiny 2

    • if your language font is thinner then English's, try lower the threshold a bit. If bolder, vice versa. Or adjust the coords & width.
  • Shader of your armor

    • If you have applied too whitish shader on your armor, it will negatively affect for macro. I think it's best to use black shader.
  • Monitor manufacturer and monitor settings

    • Your monitor settings like brightness, contrast or color temperature and monitor manufacturer; because color calibration and color accuracy differs, can also be affected by recognition, even if you set ingame's brightness is 7 and chromatic abberation is off. Try lower threshold.

Hey, I've never programmed anything in my whole life so I have potentially dumb questions for you. Is the script supposed to be constantly sending D>A>E and mouse movements before the prompt to catch the fish has come up? Because that is what it's doing on my end. If I start the script and open my chat it types D>A>E about every second and the cursor does its movements. Or is this unintentional and a symptom of the macro detecting (pWhite >= threshold) constantly? I'm not sure why it would be detecting any white because my entire character is black without any white and I've tried standing in the water vs the dock and nothing works. I've set my game to 60 fps and recorded it and it catches before the prompt even pops up because it's constantly sending D>A>E. I've tried changing my monitor brightness and contrast in 1/10ths and my ingame from 7>1. Any insight beyond what you've previously posted or any troubleshooting you've tried yourself?

I've also tried changing threshold from like .06 to .2 (it stops working at .2) in increments of .025 and nothing has worked.

@Sscryllix
Copy link

Fine, guess I'll help you guys

@Sscryllix
Copy link

Yea I’m slow too I guess cause I did exactly what was stated and this time drop the library file in the folder with the fishing script and same error. I’m not sure if the library script even runs for me since it’s not showing it’s running in taskbar. P.s. I’m new to all this

The script won't run if it catches an error, hence why it doesn't show up in your taskbar. To fix the error you're getting you need to copy the file path that leads to your Gdip_all.ahk and paste it after #include. It should look something like #include C:\users\username\whatever you saved it in\Gdip_all.ahk

@Sscryllix
Copy link

image Ok i have this error. How to fix this?

Use AHK v1.1 lol

@Sscryllix
Copy link

For all those asking how to speed it up, you can't. The script is just slow. If you want something more reliable then try mine https://gist.github.com/AmJustS/d1eff6b0f78a48d99868c224e5dbbaaf

@Sniffx
Copy link

Sniffx commented Jun 7, 2023

Thanks you A2TC-YT. I used your fishing macro and mixed it with your Tabbed-Out-AFK so I can fish in a tiny Destiny window while I do anything else in my PC, and it works in Nexus flawlessly just relaxing the threshold comparing condition!

@BloodXIII
Copy link

Thanks you A2TC-YT. I used your fishing macro and mixed it with your Tabbed-Out-AFK so I can fish in a tiny Destiny window while I do anything else in my PC, and it works in Nexus flawlessly just relaxing the threshold comparing condition!

By 'relax' in this case, do you mean increase or decrease the value? (Or feel free to just share your threshold values outright, lol)

@Sniffx
Copy link

Sniffx commented Jun 7, 2023

This is my version of A2TC-YT script. Maybe it is useful for somebody else: https://gist.github.com/Sniffx/ee5ae43d42894a6499c24b66586cc10c

@deng-kevin
Copy link

This is my version of A2TC-YT script. Maybe it is useful for somebody else: https://gist.github.com/Sniffx/ee5ae43d42894a6499c24b66586cc10c

Works great! Thanks

@Revadike
Copy link

@Sniffx
Copy link

Sniffx commented Jun 26, 2023

As far as I know/tried to do: You can't send keyboard commands to an inactive Destiny 2 window and you can't only capture a Destiny 2 window (it comes black. Whole monitor screen must be captured), so you can't interact with a non visible/non focused Destiny window.
Only way I know to interact with a non focused Destiny window (thanks to A2TC-YT scripts) is with virtual gamepads.

I guess that stuff can't be done to avoid cheats like aimbots.

@Sscryllix
Copy link

ControlSend

@Revadike
Copy link

Yeah, that's how its done, but I guess D2 ignores those

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