Jump to content

Why doesn't my script work


Sunava
 Share

Recommended Posts

I'm new to AutoIt and I have just made a very simple bot program. So I run the script with AutoIt and it detects nothing wrong, then I press the start button (F11) but nothing happens. I can't figure out why doesn't my bot start.

$bot = 0

HotKeySet("F11","start")            ; F11 to start bot
HotKeySet("F12","stop")             ; F12 to pause bot


while $bot = 1 
    call("detect")
WEnd



func start()
    if $bot = 0 Then
        $bot =1
    EndIf
EndFunc



func stop()
    if $bot = 1 Then
        $bot =0
    EndIf
EndFunc



func detect()                            ; detect monsters
while $bot = 1                                               
    if PixelGetColor(95,53)=0x282861 Then            ; if your hp is below 50%
        call("rest")
    Else
        send("{F9}")                                 ; insert buffs here
        send("{F10}")
        send("{!f}")                    
        if PixelGetColor(657,128)=0xFF718D Then      ; if monster is selected
            call("attack")               ; begins battle sequence
        EndIf
    EndIf
WEnd
EndFunc



func attack()                        ; in battle with good hp
while $bot = 1 
    if PixelGetColor(682,128)=0x80525C Then          ; monster hp is 0
        sleep(15000)
        call("pickup")
    EndIf
    if PixelGetColor(95,53)=0x282861 Then        ; if your hp is below 50%
        call("attack2")
    EndIf
WEnd
EndFunc



func pickup()
while $bot = 1 
    send("{F3}")                    ; F3 for pickup items
    sleep(100)
    send("{F3}")
    sleep(100)
    send("{F3}")
    sleep(100)
    send("{F3}")
    sleep(100)
    send("{F3}")
    sleep(100)
    send("{F3}")
    sleep(100)
    call("detect")                  ; goes back to detecting monsters
WEnd
EndFunc

    
func rest()                     ; rests till hp fully recovered or attacked by monsters
while $bot = 1 
    send("{F4}")                    ; F4 for sit down
    sleep(100)
    send("{!f}")                    ; tries to detect if you are getting attacked by monsters
    if PixelGetColor(657,128)=0xFF718D Then     ; if monster is selected
        call("attack")
    EndIf
    if PixelGetColor(117,53)=0xEABAC6 Then          ; if your hp is fully recovered
        sleep(10000)
        send("{F5}")                ; F5 for stand up
        call("detect")
    EndIf       
WEnd
EndFunc


func attack2()                       ; in battle while having low hp
while $bot = 1 
    send("{F1}")                     ; all emergancy skills or potions here
    rest(100)
    send("{F2}")
    rest(100)
    if PixelGetColor(682,128)=0x80525C Then          ; monster hp is 0
        sleep(15000)
        call("pickup")
    EndIf
WEnd
EndFunc
Edited by Sunava
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...