Jump to content

Defend your Castle


FitzChivalry
 Share

Recommended Posts

Here is a little script I wrote to help out with the game "Defend your Castle" This wont play the whole game for you, it'll just get you past the first 13 boring levels. Then the big monsters come out and it gets fun :-) Any suggestions or pointers on how to do it better would be welcome!

CODE
#cs

Defend your Castle.

http://www.xgenstudios.com/play/castle/

This script will help you out through about the first 12 levels. You'll have the highest score possible at that point.

At around lvl 12, some big guys come that you can't drop anywhere, you have to click them repeatedly, and that is when it gets fun.

Author: FitzChivalry

Contact: PM me on the forums at http://www.autoitscript.com/forum/index.php

#ce

#include <Array.au3>

HotKeySet("{ESC}", "Terminate")

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{HOME}", "Convert")

$Paused = False

Func message($string)

MsgBox(0, "message", " " & $string)

EndFunc ;==>message

$templenumber = 75;i originally set this pretty high so it will go through a couple levels and let you buy a temple before it trys to convert anyone. you can set it lower at anytime by pressing HOME

$count = 0

;this creates the arrays with some default values

$dropplace = _ArrayCreate("319", "294")

$templdrop = _ArrayCreate("745", "513")

$searchbox = _ArrayCreate("720", "500")

$searchbox2 = _ArrayCreate("737", "531")

MsgBox(0,"Welcome!","Welcome to Defend your Castle helper! First, the important hotkeys: ESC = quit, PAUSE = pause, HOME = immeadiatly convert a guy. Now since you are just starting this script, you will be asked to place your mouse in some different places on the screen. leave your mouse there until a new message pops up.")

;This part runs only when you start the script, to get the coordinates for your screen

message("click ok then put your mouse in the upper left hand corner of the screen. this is where the guys will drop from")

Sleep(3000)

$pos = MouseGetPos()

$dropplace[0] = $pos[0]

$dropplace[1] = $pos[1]

message("now click ok and put your mouse in the middle of your castle, to drop people to convert there")

Sleep(3000)

$pos = MouseGetPos()

$templdrop[0] = $pos[0]

$templdrop[1] = $pos[1]

message("now click ok and put your mouse at the upper left corner of your castle gate")

Sleep(3000)

$pos = MouseGetPos()

$searchbox2[0] = $pos[0]

$searchbox2[1] = $pos[1]

message("now click ok and put your mouse at the lower right corner of your castle gate. Make sure it is EXACTLY at the lower right corner!")

Sleep(3000)

$pos = MouseGetPos()

$searchbox[0] = $pos[0]

$searchbox[1] = $pos[1]

;now we move to actually killing the little guys

While 1

;first search by the gate

$coords = PixelSearch($searchbox2[0] - 20, $searchbox2[1] - 20, $searchbox[0], $searchbox[0] + 30, 19456);19456;13421772

If Not @error Then

If $count = $templenumber Then ;if it's time to convert another guy, drop him in the temple

MouseClickDrag("left", $coords[0] + 2, $coords[1], $templdrop[0], $templdrop[1], 0)

$count = 0

$templenumber = 27; if you dont hit home to set templenumber, then it will automatically lower itself after you convert the first guy

Else;otherwise just kill him

MouseClickDrag("left", $coords[0] + 2, $coords[1], $dropplace[0], $dropplace[1], 0)

$count = $count + 1

EndIf

EndIf

;then search the regular area

$coords = PixelSearch($dropplace[0] + 20, $searchbox2[1] - 20, $searchbox[0], $searchbox[0] + 30, 19456);19456;13421772

If Not @error Then

If $count = $templenumber Then

MouseClickDrag("left", $coords[0] + 2, $coords[1], $templdrop[0], $templdrop[1], 0)

$count = 0

$templenumber = 27

Else

MouseClickDrag("left", $coords[0] + 2, $coords[1], $dropplace[0], $dropplace[1], 0)

$count = $count + 1

EndIf

EndIf

Sleep(50)

WEnd

Func Terminate()

Exit 0

EndFunc ;==>Terminate

Func TogglePause()

$Paused = Not $Paused

While $Paused

Sleep(100)

ToolTip('Script is "Paused"', 0, 0)

WEnd

ToolTip("")

EndFunc ;==>TogglePause

Func Convert()

$count = $templenumber - 1

$templenumber = 27;after you kill this many guys, the conversion light will be gone and you can convert another guy

EndFunc ;==>Convert

Thanks for comments!

Edit: the game can be found at http://www.xgenstudios.com/play/castle/

Edited by FitzChivalry
Link to comment
Share on other sites

You have 550 characters on one line. You should do stuff like this:

MsgBox(0,"Welcome!","Welcome to Defend your Castle helper!  First, the important hotkeys:" & _ 
"  ESC = quit, PAUSE = pause, HOME = immeadiatly convert a guy. Now since you are just"& _ 
" starting this script, you will be asked to place your mouse in some different places on"& _ 
" the screen.  leave your mouse there until a new message pops up.")
;This part runs only when you start the script, to get the coordinates for your 
;screenmessage("click ok then put your mouse in the upper left hand corner of the screen.  this is where the guys will drop from")
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...