Jump to content

Auto Tracking and moving


Recommended Posts

So i want to make a bot that controls a character to an object, but the object is moving.

Lets say the character is a square and the moving objects are circles that move up constantly. None remain stationary on screen.

How can i keep auto tracking, as in knowing where the object is or predicting it will be, giving enough time for the "square" to move to that location to intercept it? I suppose i answered my own question, i could just use pixlesearch and then compensate for the y-coords, but it doesn't seem efficient enough. and x is always changing direction back and forth (but a repeating pattern on all objects at the same time)

Here is the code i have so far, all it needs it the main/important parts that make it work.

HotKeySet("s", "Toggle")
HotKeySet("q", "Quit")
Dim $TickTimer = "True"
AdlibEnable("Toggle", 30000)

WinActivate("GreenBot");browser title
MouseClick( "left", 360, 400, 1, 0)
Sleep(500)

While 1
    While $TickTimer = "True"
           $coor = PixelSearch( 15, 140, 710, 590, 0x666666, 25, 10 )
            While Not @error
              ; CODE GOES HERE!!!
                $coor = PixelSearch( 15, 140, 710, 590, 0x666666, 25, 10 )
            WEnd
    WEnd
    Sleep(100)
WEnd

Func Move()
    

Func left()
    If $left = "true" then 
    send ("{LEFT down}")
Else
    Send ("{LEFT up}")
ElseIf
EndFunc

Func right()
    If $right = "true" then 
    send ("{RIGHT down}")
Else
    Send ("{RIGHT up}")
ElseIf
EndFunc

Func up()
    If $up = "true" then 
    send ("{UP down}")
Else
    Send ("{UP up}")
ElseIf
EndFunc

Func down()
    If $down = "true" then 
    send ("{DOWN down}")
Else
    Send ("{DOWN up}")
ElseIf
EndFunc

Func Toggle()
    If $TickTimer = "True" Then
        $TickTimer = "False"
    Else
        $TickTimer = "True"
    AdlibDisable()
    AdlibEnable( "Toggle", 30000)
    EndIf
EndFunc

Func Quit()
    Exit
EndFunc

Is it good, bad, or doesn't really matter how i have the functions set up for every direction? I don't really know i was just trying to brainstorm ideas.

Can anyone help me out? (pictures attached)

post-37310-1215341957_thumb.jpg

Edited by XZ3R0
Link to comment
Share on other sites

Heres the new code i wrote, but i get an error at like 43. Subscript used with non-array variable. But i use $coor[0] and $coor[1] in my other script and it works fine. dosn't pixlesearch have 2 outputs for that?

Can anyone look at this and tell me how i can improve it and what im doing wrong?

HotKeySet("s", "Toggle")
HotKeySet("q", "Quit")

Dim $TickTimer = "True"
AdlibEnable("Toggle", 30000)

WinActivate("GreenBot");browser title
MouseClick( "left", 360, 400, 1, 0)
Sleep(500)

While 1=1
    While $TickTimer = "True"
        $coor = PixelSearch( 15, 140, 710, 590, 0x666666, 0, 5 )
        $coord = PixelSearch (15,150, 710, 590, 0x1c1c1c, 0,0)
            While Not @error
                Call ("left")
                Call ("right")
                Call ("up")
                Call ("down")               
                $coord = PixelSearch (15,150, 710, 590, 0x1c1c1c, 0,0)  
                $coor = PixelSearch( 15, 140, 710, 590, 0x666666, 10, 5)
            WEnd
    WEnd
    Sleep(100)
WEnd


Func Toggle()
    If $TickTimer = "True" Then
        $TickTimer = "False"
    Else
        $TickTimer = "True"
    AdlibDisable()
    AdlibEnable( "Toggle", 30000)
    EndIf
EndFunc

Func Quit()
    Exit
EndFunc

Func left()
    If $coor[0] > $coord[0] Then 
        Send ("{right}")
    EndIf
EndFunc

Func right()
    If $coor[0] < $coord[0] Then
        Send ("{left}")
    EndIf
EndFunc

Func up()
    If $coor[1] < $coord[1] Then
        Send ("{up}")
    EndIf
EndFunc

Func down()
    If $coor[1] > $coord[1] Then
        Send ("{down}")
    EndIf
EndFunc

Are you not allowed to put "if" keyword reverences inside of while? It wouldnt act right when i did that. Also, am i using the call function correctly?

Edited by XZ3R0
Link to comment
Share on other sites

So what your saying is use pixelsearch and then repeat it after 250mms to simulate "tracking"? Wouldn't it target another object? Can you help me out with this one too? But im still having problems with this script as it is.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...