BTD6 Autoplay bot Topic is solved

Ask gaming related questions (AHK v1.1 and older)
heldge
Posts: 4
Joined: 06 Jan 2020, 08:07

BTD6 Autoplay bot

26 Jan 2020, 18:49

This is a script ive made to autofarm btd6 and it works great, I just need to figure out how to make a mouse click everytime i level up. Because in this game when you level up a popup will apear and you need to click twice, but how do I do that?

Moderator note: OP has been issued a warning for claiming code was his own and not citing the author and the applicable MIT license.

Code: Select all

F7::
Click 800, 900          ; Play
Sleep 500
Click 1400, 950	        ; Expert
Sleep 500
Click 900, 600          ; Dark Castle
Sleep 500
Click 550, 400          ; Easy
Sleep 500
Click 550, 600          ; Standard
Sleep 5000
Loop {
    Send "u"            ; Hero (Obyn)
    Sleep 200
    Click 549, 617		
    Sleep 400
    Send "q"            ; Dart Monkey
    Sleep 200
    MouseMove 549, 500
    Sleep 400
    Send " "            ; Start game
    Sleep 100
    Send " "            ; Increase Speed
    Sleep 100
    Click 549, 489		
    Sleep 100
    Click 549, 489
    Sleep 200
    Send "-"            ; Dart -> 0-0-1
    Sleep 100
    Send "-"            ; Dart -> 0-0-2
    Sleep 100
    Click 785, 555
    Sleep 100
    MouseMove 1500, 1000
    Sleep 9800		
    MouseMove 1071, 409
    Sleep 100
    Send "x"            ; Monkey Sub
    Sleep 100
    Click 1071, 409		
    Sleep 100
    Click 1071, 409
    Sleep 100
    Click 1500, 1000
    Sleep 24800
    Click 1071, 409
    Sleep 100		
    Send ","            ; Sub -> 1-0-0
    Sleep 100
    Send ","            ; Sub -> 2-0-0
    Sleep 100
    Click 1500, 1000
    Sleep 18800
    Click 1071, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-1
    Sleep 100
    Click 1500, 1000
    Sleep 48800
    Click 1071, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-2
    Sleep 100
    Click 1500, 1000
    Sleep 40800
    Click 1071, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-3
    Sleep 100
    Click 1500, 1000
    Sleep 59800
    Click 1071, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-4
    Sleep 100
    Click 1500, 1000
    Sleep 158500
    Click 1150, 911     ; Freeplay
    Sleep 500
    Click 980, 770      ; Ok
    Sleep 500
    Click 1565, 55      ; Menu
    Sleep 500
    Click 1100, 911     ; Restart
    Sleep 500
    Click 1180, 760     ; Confirm
    Sleep 1500
    MouseMove 549, 617
    Sleep 500
}
return
Tcharr
Posts: 41
Joined: 25 Jan 2020, 15:38

Re: BTD6 Autoplay bot

27 Jan 2020, 09:54

You might use Window Spy to identify unique colors within the popup (and their coordinates). You can then try adding a PixelSearch into your code to watch for the popup. It is possible to && (logical-AND) color/coordinate combinations to reduce false positives. If this does not work (due to no unique colors or something), you may have to rely on ImageSearch using a cropped screen capture.
heldge
Posts: 4
Joined: 06 Jan 2020, 08:07

Re: BTD6 Autoplay bot

27 Jan 2020, 11:08

Tcharr wrote:
27 Jan 2020, 09:54
You might use Window Spy to identify unique colors within the popup (and their coordinates). You can then try adding a PixelSearch into your code to watch for the popup. It is possible to && (logical-AND) color/coordinate combinations to reduce false positives. If this does not work (due to no unique colors or something), you may have to rely on ImageSearch using a cropped screen capture.
I dont really know how to do that stuff though...
Tcharr
Posts: 41
Joined: 25 Jan 2020, 15:38

Re: BTD6 Autoplay bot  Topic is solved

28 Jan 2020, 07:24

Window Spy is included when you download AHK. You can start it directly, or from the shortcut menu of a loaded script icon. It will stay on top of any windowed application. Just check the Follow Cursor checkbox, and watch the info in the app change as you move your cursor from place to place. Play with it a bit to get an idea of what it can show you.
Next, spend some time reading in the AHK help files. There is much to be learned in there, including what questions to ask and how to understand the answers you get. ;)
heldge
Posts: 4
Joined: 06 Jan 2020, 08:07

Re: BTD6 Autoplay bot

28 Jan 2020, 20:01

I think I understand a little bit but not enough. I have taken screenshots of things happening and put them into a imagesearch. But how do I make the program search for those images all the time and will do an action if it finds the picture?


Code: Select all

If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic4%)

{
Click 960, 820
Sleep 1500
return
}




If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic3%)

{
Click
}



If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic2%)

{
Click
Sleep 150
Click 970, 700

}



If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic1%)

{
Click
}



F7::
Click 800, 900          ; Play
Sleep 500
Click 1400, 950	        ; Expert
Sleep 500
Click 900, 600          ; Dark Castle
Sleep 500
Click 550, 400          ; Easy
Sleep 500
Click 550, 600          ; Standard
Sleep 5000
Loop {
    Send " "            ; Start game
    Sleep 100
    Send " "            ; Increase Speed
    Send "u"            ; Hero (Obyn)
    Sleep 100
    Click 549, 617		
    Sleep 100
    Send "q"            ; Dart Monkey
    MouseMove 549, 500
    Sleep 100
    Click 549, 489		
    Sleep 100
    Click 549, 489
    Sleep 200
    Send "-"            ; Dart -> 0-0-1
    Sleep 100
    Click 785, 555
    Sleep 100
    MouseMove 1500, 1000
    Sleep 13800		
    MouseMove 1084, 409
    Sleep 100
    Send "x"            ; Monkey Sub
    Sleep 100
    Click 1084, 409		
    Sleep 100
    Click 1084, 409
    Sleep 100
    Click 1500, 1000
    Sleep 24800
    Click 1084, 409
    Sleep 100		
    Send ","            ; Sub -> 1-0-0
    Sleep 100
    Send ","            ; Sub -> 2-0-0
    Sleep 100
    Click 1500, 1000
    Sleep 18800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-1
    Sleep 100
    Click 1500, 1000
    Sleep 48800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-2
    Sleep 100
    Click 1500, 1000
    Sleep 40800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-3
    Sleep 100
    Click 1500, 1000
    Sleep 59800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-4
    Click 549, 489
    Sleep 200
    Send "-"            ; Dart -> 0-0-2
    Sleep 100
    Click 1500, 1000
    Sleep 58500
    MouseMove 960, 430
    Sleep 100
    Send "k"
    Click 960, 430
    Sleep 100
    Click 960, 430
    Sleep 200
    Send "."
    Sleep 100
    Send "."
    Sleep 100
    Send ","
    Sleep 100
    Send ","
    Sleep 100
    Click 1500, 1000
    Sleep 48000
    MouseMove 770, 430
    Sleep 100
    Send "a"
    Sleep 100
    Click 770, 430
    Sleep 100
    Click 770, 430
    Send "."
    Sleep 100
    Send "."
    Sleep 100
    Send "."
    Sleep 100
    Click 1500, 1000
    Sleep 20000
    Click 1150, 911     ; Freeplay
    Sleep 1000
    Click 980, 770      ; Ok
    Sleep 1500
    Click 1600, 40      ; Menu
    Sleep 1000
    Click 1070, 850     ; Restart
    Sleep 1000
    Click 1140, 730     ; Confirm
    Sleep 1500
    MouseMove 549, 617
    Sleep 500
}





return

F8::
Exitapp
Tcharr
Posts: 41
Joined: 25 Jan 2020, 15:38

Re: BTD6 Autoplay bot

01 Feb 2020, 05:49

Perhaps you could put your image search in a loop?
AmperChild
Posts: 1
Joined: 29 May 2020, 12:03

Re: BTD6 Autoplay bot

29 May 2020, 12:08

You should make a function wich is beeing called before every click.
heldge wrote:
28 Jan 2020, 20:01
I think I understand a little bit but not enough. I have taken screenshots of things happening and put them into a imagesearch. But how do I make the program search for those images all the time and will do an action if it finds the picture?


Code: Select all

If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic4%)

{
Click 960, 820
Sleep 1500
return
}




If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic3%)

{
Click
}



If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic2%)

{
Click
Sleep 150
Click 970, 700

}



If (ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, %pic1%)

{
Click
}



F7::
Click 800, 900          ; Play
Sleep 500
Click 1400, 950	        ; Expert
Sleep 500
Click 900, 600          ; Dark Castle
Sleep 500
Click 550, 400          ; Easy
Sleep 500
Click 550, 600          ; Standard
Sleep 5000
Loop {
    Send " "            ; Start game
    Sleep 100
    Send " "            ; Increase Speed
    Send "u"            ; Hero (Obyn)
    Sleep 100
    Click 549, 617		
    Sleep 100
    Send "q"            ; Dart Monkey
    MouseMove 549, 500
    Sleep 100
    Click 549, 489		
    Sleep 100
    Click 549, 489
    Sleep 200
    Send "-"            ; Dart -> 0-0-1
    Sleep 100
    Click 785, 555
    Sleep 100
    MouseMove 1500, 1000
    Sleep 13800		
    MouseMove 1084, 409
    Sleep 100
    Send "x"            ; Monkey Sub
    Sleep 100
    Click 1084, 409		
    Sleep 100
    Click 1084, 409
    Sleep 100
    Click 1500, 1000
    Sleep 24800
    Click 1084, 409
    Sleep 100		
    Send ","            ; Sub -> 1-0-0
    Sleep 100
    Send ","            ; Sub -> 2-0-0
    Sleep 100
    Click 1500, 1000
    Sleep 18800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-1
    Sleep 100
    Click 1500, 1000
    Sleep 48800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-2
    Sleep 100
    Click 1500, 1000
    Sleep 40800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-3
    Sleep 100
    Click 1500, 1000
    Sleep 59800
    Click 1084, 409
    Sleep 100		
    Send "-"            ; Sub -> 2-0-4
    Click 549, 489
    Sleep 200
    Send "-"            ; Dart -> 0-0-2
    Sleep 100
    Click 1500, 1000
    Sleep 58500
    MouseMove 960, 430
    Sleep 100
    Send "k"
    Click 960, 430
    Sleep 100
    Click 960, 430
    Sleep 200
    Send "."
    Sleep 100
    Send "."
    Sleep 100
    Send ","
    Sleep 100
    Send ","
    Sleep 100
    Click 1500, 1000
    Sleep 48000
    MouseMove 770, 430
    Sleep 100
    Send "a"
    Sleep 100
    Click 770, 430
    Sleep 100
    Click 770, 430
    Send "."
    Sleep 100
    Send "."
    Sleep 100
    Send "."
    Sleep 100
    Click 1500, 1000
    Sleep 20000
    Click 1150, 911     ; Freeplay
    Sleep 1000
    Click 980, 770      ; Ok
    Sleep 1500
    Click 1600, 40      ; Menu
    Sleep 1000
    Click 1070, 850     ; Restart
    Sleep 1000
    Click 1140, 730     ; Confirm
    Sleep 1500
    MouseMove 549, 617
    Sleep 500
}





return

F8::
Exitapp
[/quote]
HOHANK
Posts: 1
Joined: 29 Apr 2022, 05:04

Re: BTD6 Autoplay bot

29 Apr 2022, 05:10

Hey, i made another script that works in 2022 without including any hotkeys but i still cant fix the level up issue. Can anyone help me? +window spy is weird

Code: Select all

F7::
Loop {    
    Click 800, 900          ; Play
    Sleep 500
    Click 1400, 950	        ; Expert
    Sleep 500
    Click 1644, 428          ; Dark Castle
    Click 965, 327 
    Sleep 500
    Click 550, 400          ; Easy
    Sleep 500
    Click 1279, 447          ; Deflation
    Sleep 5000
    Click 980, 760          ; Ok
    Sleep 1000
    Click 1712, 230          ; Hero (Obyn)
    Sleep 200
    Click 875, 446
    MouseMove 1766, 412          ; scroll  
    Send, {Wheeldown 20}
    Sleep 1000
    Click 1713, 624               ;Ninja 1 
    Sleep 300
    Click 798, 446
    Sleep 300
    Click 798, 446
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 780
    Sleep 300
    Click 1550, 780
    Sleep 500
    Click 1713, 624              ; Ninja 2 
    Sleep 300
    Click 733, 443
    Sleep 300
    Click 733, 443
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 780
    Sleep 300
    Click 1550, 780
    Sleep 400
    Click 1713, 624           ; Ninja 3
    Sleep 200 
    Click 683, 407
    Sleep 200
    Click 683, 407
    Sleep 200
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 490
    Sleep 300
    Click 1550, 780
    Sleep 300
    Click 1550, 780
    Sleep 500
    Click 1815, 620         ; Alchemist
    Sleep 200
    Click 749, 388
    Sleep 200
    Click 749, 388
    Sleep 200
    Click 1550, 490
    Sleep 200
    Click 1550, 490
    Sleep 200
    Click 1550, 490
    Sleep 200
    Click 1550, 490
    Sleep 200
    Sleep 500
    Click 1815, 620         ; Alchemist 2 
    Sleep 200
    Click 814, 389
    Sleep 200
    Click 814, 389
    Sleep 200
    Click 1550, 490
    Sleep 200
    Click 1550, 490
    Sleep 200
    MouseMove 1766, 412          ; scroll  
    Send, {Wheelup 20}
    Sleep 500
    Click 1805, 630              ; Sniper
    Sleep 200
    Click 1457, 559
    Sleep 200
    Click 1457, 559
    Sleep 200
    Click 80, 375
    Sleep 400
    Click 1810, 1010            ; Start
    Sleep 200
    Click 1810, 1010
    Click 900, 900
    Sleep 365000
    Click 970, 905
    Sleep 500
    Click 700, 850
    Sleep 2000
}
return


f8::
Exitapp
[Mod edit: [code][/code] tags added. Please use them yourself. Thank you!]
Bloonsguy
Posts: 1
Joined: 22 May 2022, 16:09

Re: BTD6 Autoplay bot

22 May 2022, 16:13

can anyone make me a autoplay bot that will grind chimps mode for me on dark castle chimps? I cant code yet I'm still learning how to so in the mean while if someone could create that bot that would be great. Thanks!
RamenG0D
Posts: 1
Joined: 13 Jul 2022, 17:02

My solution is running a separate script that check for the color and auto clicks the level up

13 Jul 2022, 17:14

Code: Select all

#NoEnv  			; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%  	; Ensures a consistent starting directory.
#SingleInstance, Force

g::
Loop {
PixelSearch, Px, Py, 870, 337, 1031, 499, 0x20D8FF, 3, Fast
if (ErrorLevel = 0)
{
MouseMove, Px, Py
Sleep 200
Click
}
}

return
F8:: Exitapp

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
UNONOU
Posts: 1
Joined: 09 Nov 2022, 04:59

Re: BTD6 Autoplay bot

09 Nov 2022, 05:02

@RamenG0D
how should it work?
can i use with the other script that autoplay?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 49 guests