Sign in to follow this  
Followers 0
Altes

Need Some Help Looping

2 posts in this topic

#1 ·  Posted (edited)

I've made a script but after a couple hours it just crashes. I've tried looping myself but it doesn't work so any help will be greatly appreciated.(This is my first script so if you got any other suggestions please post them)

Global $Pause
Dim $revivetimes = 0
Dim $MonkeyKills = 0
Dim $PandaKills = 0
Dim $DuckKills = 0
HotKeySet("{DELETE}", "attack")
HotKeySet("{PAUSE}", "stop")
HotKeySet("{END}", "check")
HotKeySet("{INSERT}", "move")
HotKeySet("{HOME}", "SeeCounter")
    
;;;;;;  
;Loop;
;;;;;

While 1
Sleep(100)
WEnd
    
;;;;;;;;;;;;;
;closemarket;
;;;;;;;;;;;;

func closemarket()
$market = pixelgetcolor(845 , 119)
if $market = 16772095 Then
mouseclick("left" , 845 , 119 , 1 , 0)
call("attack")
Else
call("attack")
EndIf
EndFunc

;;;;;;
;Move;
;;;;;;

Func move()
$EWindow = PixelGetColor (143 , 118)
If $EWindow = 14083063 then
MouseClickDrag("left", 143, 118, 929, 625)
Endif
EndFunc

;;;;;;;
;NPots;
;;;;;;;

Func NoPots()
$Npots = PixelGetColor (1008 , 255)
If $Npots = 16235206 then
call("attack")
else
MsgBox(064, "Stopping Script", "You Have Run Out Of Pots.", 5)
sleep(2147483647)
endif
EndFunc

;;;;;;;
;NFood;
;;;;;;;

Func NoFood()
$Nfood = PixelGetColor (1003 , 294)
If $Nfood = 8077592 then
call("attack")
else
MsgBox(064, "Stopping Script", "You Have Run Out Of Food.", 5)
sleep(2147483647)
endif
EndFunc

;;;;;;;
;NAmmo;
;;;;;;;

Func NoAmmo()
$NoAmmo = PixelGetColor (999 , 337)
If $NoAmmo = 15717210 then
call("attack")
else
MsgBox(064, "Stopping Script", "You Have Run Out Of Ammo.". 5)
sleep(2147483647)
endif
EndFunc

;;;;;;;;;;;;
;SeeCounter;
;;;;;;;;;;;;

Func SeeCounter()
$sentence = ("Number Of Kills And Revives  =")
MsgBox(064, "Counter", $sentence & "  Monkey Kills: " & $MonkeyKills & "   Duck Kills: " & $DuckKills & "   Panda Kills: " & $PandaKills & "   Revives: " & $revivetimes, 15)
$OGoonzu = PixelSearch( 200, 744, 875, 766, 0xFCC570 )
If 0=@error then
Send("{ENTER}")
mouseclick("left", $OGoonzu[0], $OGoonzu[1], 1)
sleep(3000)
call("attack")
endif
EndFunc

;;;;;;;;
;Revive;
;;;;;;;;

Func revive()
$revive = PixelCheckSum (402,327, 586,347)
If $revive = 441634942 then
MouseMove(0, 0, 0)
$revivetimes = $revivetimes + 1
MouseClick("left", 442 , 398, 1)
sleep(10000)
MouseClick("left", 778 , 267, 1)
sleep(10000)
MouseClick("left", 910 , 408, 1)
sleep(10000)
MouseClick("left", 599 , 640, 1)
sleep(10000)
MouseClick("left", 1022 , 605, 1)
sleep(10000)
MouseClick("left", 673 , 483, 1)
sleep(10000)
MouseClick("left", 2 , 610, 1)
sleep(5000)
MouseClick("left", 4 , 494, 1)
sleep(5000)
MouseClick("left", 0 , 378, 1)
sleep(5000)
MouseClick("left", 19 , 138, 1)
sleep(5000)
call("attack")
else
call("attack")
endif
endfunc

;;;;;;;
;Close;
;;;;;;;

Func closebox()
$PClose = PixelCheckSum (402,327, 586,347)
If $PClose = 1217154423 then
Mouseclick("left", 615 , 317, 1)
sleep(3000)
else
call("attack")
EndIf
EndFunc


;;;;;;;;;
;Unstuck;
;;;;;;;;;

Func unstuck();Unstuck : 616 49 0xF7F7F7 16250871;Exit : 443 305
$wrongroom = PixelGetColor (616 , 49)
If $wrongroom = 16250871 then
mouseclick("left", 443, 305, 1)
sleep(2000)
else
call("attack")
endif
Endfunc

;;;;;;;;;;
;Unstuck2;
;;;;;;;;;;

Func unstuck2();479 149 0xFFAACE 16755406
$wrongplace = PixelGetColor (479, 149)
If $wrongplace = 16755406 then
mouseclick("left", 698, 276, 1)
sleep(2000)
else
Call("attack")
endif
Endfunc

;;;;;;;
;Check;
;;;;;;;

Func check()
$check = PixelGetColor (974 , 696)
If $Check = 13542061 then
MsgBox(0, "Colour Check", "Correct Position")
else
MsgBox(0, "Colour Check", "Incorrect Position")
Endif
EndFunc

;;;;;;;
;Pause;
;;;;;;;

Func stop()
sleep(60000)
endfunc

;;;;;;;;
;Reload;
;;;;;;;;

Func Reload()
Do
$Ammo = PixelGetColor (998 , 694)
If $Ammo = 13015708 then
$NAmmo = PixelSearch( 0, 0, 1023, 767, 0xEFD35A )
mouseclick("left", $NAmmo[0], $NAmmo[1], 1)
mouseclick("left", 998, 694, 1)
sleep(2000)
else
call("attack")
endif
Until $Ammo = 15717210
EndFunc

;;;;;;;;;;;;;
;townmeeting;
;;;;;;;;;;;;

func townmeeting()
$meeting = Pixelgetcolor(613 , 313)
If $meeting = 16767966 Then
$Health = PixelGetColor (111 , 90)
mouseclick("left" , 613, 313, 1, 0)
call("attack")
sleep(2000)
Else
call("attack")
EndIf
endfunc

;;;;;
;eat;
;;;;;

Func Eat()
Do
$Hunger = PixelGetColor (189 , 45)
If $Hunger = 1582137 then
send("{F2}")
sleep(1000)
else
call("attack")
Endif
Until $Hunger <>  1582137

EndFunc

;;;;;
;pot;
;;;;;

Func Hp()
Do
$revive = PixelGetColor (615 , 307)
If $revive = 16767966 then
call("revive")
$Health = PixelGetColor (111 , 90)
else
$Full = PixelGetColor (218 , 90)
$Health = PixelGetColor (111 , 90) 
If $Health = 528408 then
send("{F1}")
sleep(1000)
else
call("attack")
Endif
Endif
Until $Full =  16226948
EndFunc

;;;;;;;;;;;;;;;
;attack script;
;;;;;;;;;;;;;;;
Func attack();Monkeys 0xC69642   Ducks 0xEFAA73
Do
$market = pixelgetcolor(845 , 119)
if $market = 16772095 Then
$Health = PixelGetColor (111 , 90)
call("closemarket")
else
$meeting = Pixelgetcolor(613 , 313)
If $meeting = 16767966 Then
$Health = PixelGetColor (111 , 90)
call("townmeeting")
Else
$revive = PixelCheckSum (402,327, 586,347)
If $revive = 441634942 then
call("revive")
$Health = PixelGetColor (111 , 90)
else
$Nopots = PixelGetColor (1008 , 255)
If $Nopots <> 16235206 then
call("NoPots")
$Health = PixelGetColor (111 , 90)
else
$Nofood = PixelGetColor (1003 , 294)
If $Nofood <> 8077592 then
$Health = PixelGetColor (111 , 90)
call("NoFood")
else
$NoAmmo = PixelGetColor (999 , 337)
If $NoAmmo <> 15717210 then
call("NoAmmo") 
$Health = PixelGetColor (111 , 90)
else
$close = PixelGetColor (615 , 317)
If $close = 16766951 then
call("closebox")
$Health = PixelGetColor (111 , 90)
else
$wrongroom = PixelGetColor (616 , 49)
If $wrongroom = 16250871 then
call("unstuck")
$Health = PixelGetColor (111 , 90)
else
$wrongplace = PixelGetColor (479 , 149)
If $wrongplace = 16755406 then
call("unstuck2")
$Health = PixelGetColor (111 , 90)
else
$Hunger = PixelGetColor (189 , 45)
If $Hunger = 1582137 Then
call("Eat")
$Health = PixelGetColor (111 , 90) 
else
$Ammo = PixelGetColor (998 , 694)
If $Ammo = 13015708 Then
Call("Reload")
$Health = PixelGetColor (111 , 90) 
else
$monster = PixelSearch( 0, 0, 907, 685, 0xC69642 ) 
If 0=@error Then    
MouseClick("left", $monster[0], $monster[1], 1, 0)
$MonkeyKills = $MonkeyKills + 1
$Health = PixelGetColor (111 , 90)
sleep(3000)
$Health = PixelGetColor (111 , 90) 
Else
$monster2 = PixelSearch( 0, 0, 907, 685, 0xEFAA73)
If 0=@error Then
MouseClick("left", $monster2[0], $monster2[1], 1, 0)
$DuckKills = $DuckKills + 1
$Health = PixelGetColor (111 , 90)
Sleep(3000)
$Health = PixelGetColor (111 , 90) 
else
$monster3 = PixelSearch( 364, 233, 671, 491, 0xFF7931)
If 0=@error Then
MouseClick("left", $monster3[0], $monster3[1], 1, 0)
$PandaKills = $PandaKills + 1
$Health = PixelGetColor (111 , 90)
sleep(3000)
$Health = PixelGetColor (111 , 90)
Else
$wrongroom = PixelGetColor (616 , 49)
If $wrongroom = 16250871 then
call("unstuck")
$Health = PixelGetColor (111 , 90)
else
$wrongplace = PixelGetColor (479 , 149)
If $wrongplace = 16755406 then
call("unstuck2")
$Health = PixelGetColor (111 , 90)
else
MouseClick("left", random(0, 913, 1), random(0, 600, 1), 1)
sleep(4000) 
$Health = PixelGetColor (111 , 90)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
Endif
EndIf
EndIf
EndIf
Endif
EndIf
EndIf
EndIf
Until $Health = 528408
call("Hp")
EndFunc
Edited by Altes

Share this post


Link to post
Share on other sites



You've got a lot of recursion going on in your script. Redesign it to eliminate the recrusion and you're problem will probably go away. Hint: Do some research on how to use states in your program (and I don't mean Iowa, Illinois, etc. either) :whistle:


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
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
Sign in to follow this  
Followers 0