Jump to content

Script crashes?


Recommended Posts

I'm having trouble with a script i wrote to automate defend your castle.

CODE
WinWaitActive ("http://www.xgenstudios.com - XGen Studios - Online Flash Games - Defend Your Castle - Mozilla Firefox", "")

HotKeySet ("{pause}", "term")

HotKeySet ("{end}", "termi")

HotKeySet ("a", "archer")

HotKeySet ("w", "wizard")

Hotkeyset ("{space}", "boss")

Func termi ()

Exit

EndFunc

Func boss ()

Mouseclick ("left", 501, 185, 1, 1)

$boss = PixelSearch (227, 366, 382, 482, 0x666666)

MouseClick ("left", $boss[0] + 4, $boss[1], 1, 1)

EndFunc

$var = PixelSearch (40, 80, 856, 560, 0x000000)

MouseMove ($var[0], $var[1])

Func term ()

While 1

sleep (1000)

$wait = PixelGetColor (375, 279)

If $wait = 3256542 Then

$count = 20

ExitLoop

EndIf

Wend

EndFunc

Func archer ()

Mouseclick ("left", 533, 281, 1, 1)

EndFunc

Func wizard ()

MouseClick ("left", 459, 203, 1, 1)

EndFunc

$count = 0

While 1

While 2

$guy = PixelSearch (227, 316, 515, 484, 0x000000)

If Not @error = 1 Then

ExitLoop

EndIf

Wend

If $count = 20 Then

MouseMove ($guy[0] + 4, $guy[1], 0)

MouseDown ("left")

MouseMove (593, 291, 1)

MouseUp ("left")

$count = 0

EndIf

PixelSearch (227, 366, 382, 482, 0x666666)

If not @error = 1 Then

Mouseclick ("left", 501, 185, 1, 2)

$boss = PixelSearch (227, 366, 382, 482, 0x666666)

MouseClick ("left", $boss[0] + 4, $boss[1], 1, 2)

Sleep (100)

EndIf

SetError (0)

MouseMove ($guy[0] + 4, $guy[1], 0)

MouseDown ("left")

Mousemove ($guy[0] + 4, $guy[1] - 300, 1)

Mouseup ("left")

$count = $count + 1

sleep (10)

Wend

MsgBox (0, "", "1")

The code works fine until the boss thing comes where it must perform a different action from click and drag. When the code stops working, the msg box does not appear so i dont think it is somehow exiting the loop. Any ideas?

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...