james3mg Posted May 30, 2008 Posted May 30, 2008 (edited) Well, I lied...I found enough things I wanted to do that I released this one new update!New features:-Supports building of demolition lab-Holding the Ctrl key overrides the script, allowing you easy access to your bombers-does not require compliation in VistaBug fixes:-Growing castle supportedHave fun!---Original Post:---I'd never do this for a multiplayer game, but it's not hurting anyone to bot a one-player game! Anyway, I needed something to occupy my mind this Friday afternoon, and since I'd recently heard of Defend your Castle through the Wii, I though I'd check it out. The game is OK, about a 30-minute time waster for me before I got sick of it. But I thought it might be an interesting challenge to bot. So here it is. It works pretty well, it'll get you to level 14 without ANY wall upgrades (just buy the temple and archery range when you can and it'll know what to do). I didn't try it with upgraded walls...I'm sure you could get far beyond that level.I know someone's going to ask me to add this or that to this...let me be clear. You may use this script, modify it, whatever, but I'm done with it. It's extremely unlikely that I'll ever touch it again. I've only used it on IE7.0 and it only works at the site whose URL is in the script.If you wanted to develop the script further, I'd recommend:-adding a override hotkey (for instance, hold space to disable all automatic movements so you can take control for a moment) [easy- just use "and _IsPressed(0x20)" at the end of the WinActive line]-moving the 'completed convert' search region to the right so that after you have a temple it always leaves one convert in reserve (useful for someone who wanted to make the demolition guys) [easy- that'd be the search within the "If $ArcheryBuilt Then" condition]-figure out a logical formula for splitting converts between wizards, builders and archers, etc. (I didn't play enough to get into this- I did a little with the demo guys, but none with the wizards) [not so easy]-allow tray icon menu access to the vars telling the script if archery, temple, etc is built-changing the coordinates to reflect client area coords, rather than window coords.The script will run only as long as the game is active and running, so to access the tray icon (thereby killing or pausing the script) just change one of those conditions. The 'p' button pauses the game, so when you do that, the script will hold until the game starts again, but also you could press the windows key or alt+tab to switch window focus away from the game and the script will stop moving your mouse. Also, since holding the Ctrl key overrides all movement, you could hold that button and do whatever you need with your mouse Note that if you buy things like a temple or archery range then later on die and restart the game, you should restart the bot or it will assume it's still the same game and that you've still got whatever you bought last game...so it would try and drop guys in the castle when you don't have a temple, for instance. Bad thing. So for what it is, here you go. Let me know if you enjoy it- I'd love to hear it ---updated script---expandcollapse popup#include <Misc.au3> $dll = Dllopen("dwmapi.dll") Dllcall($dll,"int","DwmEnableComposition","dword","DWM_EC_DISABLECOMPOSITION") Opt("PixelCoordMode",0) Opt("MouseCoordMode",0) Opt("MouseClickDragDelay",0) Global $TempleBuilt=0 Global $ArcheryBuilt=0 Global $DemoLabBuilt=0 Global $ConvertsArray[2]=[588,606] Global $ConvertNext=0 Global $ConvertTimer While 1 If WinActive("XGen Studios - Online Flash Games - Defend Your Castle","http://www.xgenstudios.com/game.php?keyword=castle") AND Not _IsPressed("11") Then PixelSearch(245,175,250,180,0x000000,5,2) If @error Then;not paused $Coord=PixelSearch(240,430,500,490,0xCCCCCC,15,5) If NOT @error Then If $ConvertNext=0 Then MouseClickDrag("primary",$Coord[0],$Coord[1],810,160,1) Else $ConvertNext=0 Opt("MouseClickDragDelay",50) MouseClickDrag("primary",$Coord[0],$Coord[1],635,410,1) Opt("MouseClickDragDelay",1) $ConvertTimer=TimerInit() EndIf EndIf If $TempleBuilt Then If TimerDiff($ConvertTimer) > 1000 Then PixelSearch(598,164,599,165,0x95D6F9,3);sky If NOT @error Then $ConvertNext=1 Else PixelSearch(598,164,599,165,0xFFFFFF,3);cloud If NOT @error Then $ConvertNext=1 EndIf EndIf EndIf If $ArcheryBuilt Then PixelSearch($ConvertsArray[$DemoLabBuilt],200,$ConvertsArray[$DemoLabBuilt]+1,201,0x00CCFF,5) If NOT @error Then $Coord=PixelSearch(533,200,575,420,0xF66262,5) If NOT @error Then MouseClick("left",$Coord[0],$Coord[1]);build archer, no matter how tall the castle MouseMove($Coord[0],$Coord[1]+20,1) EndIf EndIf EndIf Else;paused...check for upgraded stuff If NOT $TempleBuilt Then PixelSearch(551,243,552,244,0x59574A,2) If NOT @error Then $TempleBuilt=1 $ConvertNext=1 TrayTip("Temple built","Units will now be converted whenever possible",5) EndIf EndIf If NOT $ArcheryBuilt Then PixelSearch(544,313,545,324,0x272872,2) If NOT @error Then $ArcheryBuilt=1 TrayTip("Archery range built","Available converted units will be trained into archers",5) EndIf EndIf If NOT $DemoLabBuilt Then PixelSearch(550,359,551,359,0x954E4E,2) If NOT @error Then $DemoLabBuilt=1 TrayTip("Demolition Lab built","One convert will be held in reserve for your use as a bomber",5) EndIf EndIf EndIf Else Sleep(200) EndIf WEndEdit: forgot to mention...this works on Vista too, but you have to compile it and change compatability on that executable to disable desktop composition, or it will run sllllllloooooooowwwwwwwwwwwwwwwwwww Edited June 1, 2008 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
TnTProductions Posted May 30, 2008 Posted May 30, 2008 nice work i tried to make a bot for the same game a while ago! "FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"
james3mg Posted May 30, 2008 Author Posted May 30, 2008 (edited) nice work i tried to make a bot for the same game a while ago! And did you succeed? Did you incorporate any more functions than my script?Edit: forgot to say thanks Edited May 30, 2008 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
monoceres Posted May 30, 2008 Posted May 30, 2008 Nice! Remember when I was 12-13 years old and played this game for like hours This one is a bit nicer to the wrist Broken link? PM me and I'll send you the file!
TnTProductions Posted May 30, 2008 Posted May 30, 2008 1 funtion that your forgot to place was very important something to let people exit out of your script! I had problems getting out of the script with the mouseclicks so add this at the top: hotkeyset("{ESC}", "Terminate") function Terminate() Exit Ps: this may not be in correct functions so just check up on it i havent used this func in a while "FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"
james3mg Posted May 30, 2008 Author Posted May 30, 2008 1 funtion that your forgot to place was very important something to let people exit out of your script! I had problems getting out of the script with the mouseclicks so add this at the top: hotkeyset("{ESC}", "Terminate") function Terminate() Exit Ps: this may not be in correct functions so just check up on it i havent used this func in a while Yes, that's fine...I seemed to be having troubles with that on my computer (I think there's some script I wrote a while ago that's running and reserved the hotkeys I tried). Anyway, that's why I mentioned in my first post that pausing the game or switching the active window will release your mouse, allowing you to get to the tray icon. Did you try that? "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
TnTProductions Posted May 30, 2008 Posted May 30, 2008 Ok i tried that i didnt notice you posted that ill make sure to read the FULL post before i say anything lol "FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"
TnTProductions Posted May 30, 2008 Posted May 30, 2008 (edited) Edit: forgot to mention...this works on Vista too, but you have to compile it and change compatability on that executable to disable desktop composition, or it will run sllllllloooooooowwwwwwwwwwwwwwwwwwwI didnt have to compile and it worked fine i have a Vista Home BasicPs: i also found a problem with the mouse clicking off the screen onto advertisements when it was throwing man into the air or finding it happened a couple times Edited May 30, 2008 by TnTProductions "FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"
james3mg Posted May 30, 2008 Author Posted May 30, 2008 I didnt have to compile and it worked fine i have a Vista Home BasicPs: i also found a problem with the mouse clicking off the screen onto advertisements when it was throwing man into the air or finding it happened a couple timesThat's the only version of Vista that doesn't offer aero, which is what causes the desktop composition pixelgetcolor issue, so I guess I wasn't specific enough If you've got the transparent windows in Vista, you'll have to follow my instructions. "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
EvAsion Posted May 31, 2008 Posted May 31, 2008 This will disabled desktop composition on vista. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.9 Author: EvAsion Script Function: Disable desktop composition on vista. Notes: exiting script will turn desktop composition back on or: Dllcall($dll,"int","DwmEnableComposition","dword","DWM_EC_ENABLECOMPOSITION") #ce ---------------------------------------------------------------------------- $dll = Dllopen("dwmapi.dll") Dllcall($dll,"int","DwmEnableComposition","dword","DWM_EC_DISABLECOMPOSITION") |-- Periodic Table --||-- Dynamic Class Timetable --||-- Navigation in Counter-Strike --|
james3mg Posted May 31, 2008 Author Posted May 31, 2008 Wow...that's REALLY good to know! Does it have any side-effects on XP, requiring that I check the OS and conditionally run it? Thanks for sharing!!! "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
JRSmile Posted May 31, 2008 Posted May 31, 2008 Hey nice thingy i have written a bot some time ago, it does not automatically throw enemies into the temple and such, but its very efficient so that i got to stage 16 or somesting without one lost health point. the big problem are the juge enemies which have to be defeated by bombs to use my bot just hold space bar and hover over the enemy #include <misc.au3> Opt("MouseClickDragDelay",1) while 1 if _IsPressed(20) Then $pos = MouseGetPos() $pos2 = PixelSearch($pos[0]-25,$pos[1]-25,$pos[0]+25,$pos[1]+25, 0xCCCCCC) if @error then ContinueLoop MouseDown("primary") MouseMove($pos2[0], $pos2[1]-450, 1) MouseUp("primary") MouseMove($pos[0], $pos[1], 1) EndIf Sleep(1) WEnd Best regards, J. $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
james3mg Posted June 1, 2008 Author Posted June 1, 2008 Well, surprise, surprise. I found enough things that could be improved (and a few hours to kill this weekend), so I've made one revised release of this script...it's a lot better. It would easily allow you to get beyond level 14, where the big guys come. Enjoy! "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Alek Posted June 2, 2008 Posted June 2, 2008 Hello, i made a bot for this game awhile back. might as well share it It made it to level 40 befor i stoped it. press f6 to start and stop the bot. expandcollapse popupOpt('MouseCoordMode',2) Opt('PixelCoordMode',2) HotKeySet('{F6}','_Start') Global $Run = 0 Global $Level = 1 Global $Recruit_Timer = 0 Global $Recruits = 0 ;Bulding stuff Global $Has_Tempel = False Global $Has_Waterpool = False $oGame = ObjCreate ("ShockwaveFlash.ShockwaveFlash.1") $Form1 = GUICreate("", 560, 410, -1, -1) $GUIActiveX = GUICtrlCreateObj ($oGame, 5, 5, 550, 400) GUISetState() With $oGame .bgcolor = "#000000" .Movie = 'http://www.xgenstudios.com/castle/castlexgen.swf' .ScaleMode = 1 .Loop = True .wmode = "Opaque" EndWith $Pause = 1 While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit EndSwitch Sleep(10) WEnd Func _Start() If $Run = 1 Then $Run = 0 Return Else $Run = 1 ConsoleWrite('Starting----------------------' & @CRLF) EndIf WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) MouseMove(50, 255,10) MouseMove(295, 255,10) MouseMove(295, 335,10) MouseMove(50, 335,10) MouseMove(50, 255,10) While $Run $Recruits = _CountRecruits() Sleep(10) $Coords = PixelSearch(220, 255, 310, 335, 0x001300, 2) If Not @error Then _MouseClickDrag('Left', $Coords[0],$Coords[1],40, 30,0) EndIf $Coords = PixelSearch(50, 200, 310, 300, 0xFFFFFF) If Not @error Then If Hex(PixelGetColor(265, 45),6) = '0099FF' Then MouseClick('left',265, 65,1,0) MouseClick('left', $Coords[0] , $Coords[1], 1, 0) MouseMove($Coords[0],340,0) EndIf EndIf $Coords = PixelSearch(50, 255, 295, 335, 0x6A0000) If Not @error And Hex(PixelGetColor(265, 45),6) = '0099FF' Then MouseClick('left',265, 65,1,0) MouseClick('left', $Coords[0]+2 , $Coords[1], 1, 0) MouseMove($Coords[0],340,0) EndIf $Coords = PixelSearch(50, 255, 295, 335, 0x001300, 2) If @error Then _CheckState() ContinueLoop EndIf If TimerDiff($Recruit_Timer) > 18000 And $Recruits < 10 And $Has_Tempel Then $Check_Color = PixelGetColor(365, 200) _MouseClickDrag('left',$Coords[0],$Coords[1],365, 200,0) $Recruit_Timer = TimerInit() Do Sleep(10) Until PixelGetColor(365, 200) <> $Check_Color Or TimerDiff($Recruit_Timer) > 250 If TimerDiff($Recruit_Timer) < 251 Then $Recruits += 1 WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) Else _MouseClickDrag('Left', $Coords[0],$Coords[1],40, 30,0) EndIf If $Recruits > 5 And $Has_Waterpool Then $Wizard_Coords = _FindWizard() If $Wizard_Coords <> 0 Then MouseClick('left',$Wizard_Coords[0], $Wizard_Coords[1],1,0) $Recruits -= 1 EndIf EndIf WEnd EndFunc Func _MouseClickDrag($s_Button, $s_X1,$s_Y1, $s_X2,$s_Y2,$s_Speed) MouseMove($s_X1, $s_Y1,$s_Speed) MouseDown($s_Button) Sleep(25) MouseMove($s_X2, $s_Y2,$s_Speed) Sleep(25) MouseUp($s_Button) Return EndFunc Func _CheckState() Local $s_Cursor = MouseGetCursor() If PixelGetColor(8,8) = 0 Then MouseMove(365, 365) Do Sleep(10) Until MouseGetCursor() <> $s_Cursor Sleep(250) MouseClick('left') Switch $Level Case 6 MouseClick('left', 385, 105) $Has_Tempel = True Case 11 MouseClick('left', 385,310) $Has_Waterpool = True Case Else If Hex(PixelGetColor(245, 25),6) <> 'D90000' Then Do MouseClick('left',170, 140,1,0) Sleep(10) Until Hex(PixelGetColor(245, 25),6) <> 'D90000' EndIf If $Level > 12 Then MouseClick('Left',165, 280,Floor($Level/4),0) EndIf EndSwitch Sleep(750) MouseClick('left', 505, 375) While PixelGetColor(8,8) = 0 Sleep(10) WEnd $Level += 1 WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) Return EndIf EndFunc Func _FindWizard() Local $s_Coords = PixelSearch(215, 5,280, 155,0xFFFF75,4) If @error Then Return 0 Return $s_Coords EndFunc Func _CountRecruits() Local $s_Rec = 0 Local $x For $x = 0 To 10 If Hex(PixelGetColor(355+(18*$x), 45),6) = '00CCFF' Then $s_Rec += 1 EndIf Next Return $s_Rec EndFunc [font="Impact"]Never fear, I is here.[/font]
Kitsune Posted June 10, 2008 Posted June 10, 2008 Hello I'm new AutoIt, I've had courses in Basic, C++, Javascript, and Assembly so I should quickly catch on here. I'll be taking your codes James and Alek to blend together and add my own changes to see if I can make a better bot, I'll add your names into the header for using your codes as sources. I'll be glad for any ideas and opinions after I post the finished code.
Kitsune Posted June 13, 2008 Posted June 13, 2008 I made many improvements using the previous scripts as source material and hacking them to bits and the result is a bot that can easily reach lvl 30.It has support for all facilities save for the Demo upgrade,uses the Bomb spell whenever the gate is being crowded(with 10 second cooldown timer to prevent waste of mana),I left in the ability to pause the script briefly for user intervention,added ability for bot to automatically use the Convert spell,fixed a glitch found in Alek's code where the AI wastefully used the Kill spell on levels 12 & 13,better detection of attackers adjacent to the gate,changed the _MouseClickDrag() user-function to react quicker,fixed the code snippet that auto-repairs between waves to stop after the health gauge reached an appropriate level,Auto-detects any flagged facility added manually by the user,evenly distributes converts in a linear fashoin (i.e. skips over an unavailable facility).CODE#include <Misc.au3>;$dll = Dllopen("dwmapi.dll");Dllcall($dll,"int","DwmEnableComposition","dword","DWM_EC_DISABLECOMPOSITION")Opt('MouseCoordMode',2)Opt('PixelCoordMode',2)Opt("MouseClickDragDelay",0)HotKeySet('{F6}','_Start')Global $Run = 0Global $Level = 1Global $TempleBuilt=falseGlobal $ArcheryBuilt=falseGlobal $DemoLabBuilt=falseGlobal $WorkshopBuilt=falseGlobal $ManapoolBuilt=falseGlobal $ConvertNext=0Global $ConvertTimerGlobal $Recruits = 0Global $Dispense=1Global $BombTimerGlobal $DebugTimerGlobal $DebugTimer2Global $DebugCount=0Global $Debug0=0Global $Debug1=0Global $Debug2=0Global $Debug3=0Global $Debug4=0Global $Debug5=0Global $Debug6=0Global $Debug7=0$oGame = ObjCreate ("ShockwaveFlash.ShockwaveFlash.1")$Form1 = GUICreate("", 560, 410, -1, -1)$GUIActiveX = GUICtrlCreateObj ($oGame, 5, 5, 550, 400)GUISetState()With $oGame .bgcolor = "#000000" .Movie = '' .ScaleMode = 1 .Loop = True .wmode = "Opaque"EndWith$Pause = 1While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit EndSwitch Sleep(10)WEndFunc _Start() If $Run = 1 Then $Run = 0 Return Else $Run = 1 ConsoleWrite('Starting----------------------' & @CRLF) EndIf WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) MouseMove(50, 255,10) MouseMove(295, 255,10) MouseMove(295, 335,10) MouseMove(50, 335,10) MouseMove(50, 255,10) While $Run If Not _IsPressed("11") Then Sleep(9) $Debug0 += TimerDiff($DebugTimer) If Not $DebugCount Then Tooltip($Debug0/20 & @CRLF & $Debug1/20 & @CRLF & $Debug2/20 & @CRLF & $Debug3/20 & @CRLF & $Debug4/20 & @CRLF & $Debug5/20 & @CRLF & $Debug6/20 & @CRLF & $Debug7/20,40, 30) $Debug0=0 $Debug1=0 $Debug2=0 $Debug3=0 $Debug4=0 $Debug5=0 $Debug6=0 $Debug7=0 $DebugCount=20 Else $DebugCount -= 1 EndIf $DebugTimer=TimerInit() $DebugTimer2=TimerInit() $Coords = PixelSearch(220, 235, 310, 355, 0x000000, 19) If NOT @error Then If $ConvertNext=0 Then If TimerDiff($BombTimer) > 10000 Then If PixelGetColor(286,65) = 16763904 Then ;MouseClick('left',285, 65,1,0) Send("2") MouseClick('left', $Coords[0] , $Coords[1], 1, 0) MouseMove(40, 30,0) Sleep(9) EndIf $BombTimer=TimerInit() Else _MouseClickDrag("left",$Coords[0],$Coords[1],40, 30,0) EndIf Else $ConvertNext=0 _MouseClickDrag("left",$Coords[0],$Coords[1],365, 200,0) $ConvertTimer=TimerInit() EndIf EndIf $Debug1 += TimerDiff($DebugTimer2) $DebugTimer2=TimerInit() $Coords = PixelSearch(50, 200, 310, 300, 0xFFFFFF, 0, 2) If Not @error Then If PixelGetColor(258,62) = 13369344 Then ;MouseClick('left',265, 65,1,0) Send("1") MouseClick('left', $Coords[0] , $Coords[1], 1, 0) MouseMove(40, 30,0) Sleep(9) EndIf EndIf $Debug2 += TimerDiff($DebugTimer2) $DebugTimer2=TimerInit() $Coords = PixelSearch(50, 255, 330, 335, 0x6A0000, 1, 2) If Not @error Then If PixelGetColor(258,62) = 13369344 Then ;MouseClick('left',265, 65,1,0) Send("1") MouseClick('left', $Coords[0]+2 , $Coords[1], 1, 0) MouseMove(40, 30,0) Sleep(9) EndIf EndIf $Debug3 += TimerDiff($DebugTimer2) $DebugTimer2=TimerInit() If $TempleBuilt And Not $ConvertNext Then If $Recruits < 10 Then If TimerDiff($ConvertTimer) > 1000 Then $pix = PixelGetColor(365,10) ;PixelSearch(365,10,366,11,0x95D6F9,3);sky If $pix = 9819897 Then $ConvertNext=1 $Recruits = _CountRecruits() WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) ElseIf $pix = 16777215 Then ;PixelSearch(365,10,366,11,0xFFFFFF,3);cloud ;If NOT @error Then $ConvertNext=1 $ConvertNext=1 $Recruits = _CountRecruits() WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) EndIf EndIf EndIf EndIf $Debug4 += TimerDiff($DebugTimer2) $DebugTimer2=TimerInit() If $Recruits > 5 Then If $Level < 14 Then If $ManapoolBuilt Then $Coords = PixelSearch(215, 5,280, 155,0xFFFF75,5) If NOT @error Then MouseClick("left",$Coords[0],$Coords[1],1,0);build mage, no matter how tall the castle MouseMove($Coords[0],$Coords[1],0) $Recruits = _CountRecruits() EndIf EndIf Else If $Dispense = 0 Then If $WorkshopBuilt Then $Coords=PixelSearch(215, 5,550,365,0x35E201,5) If NOT @error Then MouseClick("left",$Coords[0],$Coords[1],1,0);build repairman, no matter how tall the castle MouseMove($Coords[0],$Coords[1],0) $Recruits = _CountRecruits() EndIf EndIf $Dispense += 1 ElseIf $Dispense = 1 Then If $ArcheryBuilt Then $Coords=PixelSearch(215, 5,550,365,0xF66262,5) If NOT @error Then MouseClick("left",$Coords[0],$Coords[1],1,0);build archer, no matter how tall the castle MouseMove($Coords[0],$Coords[1]+20,0) $Recruits = _CountRecruits() EndIf EndIf $Dispense += 1 Else If $ManapoolBuilt Then $Coords = PixelSearch(215, 5,280, 155,0xFFFF75,5) If NOT @error Then MouseClick("left",$Coords[0],$Coords[1],1,0);build mage, no matter how tall the castle MouseMove($Coords[0],$Coords[1],0) $Recruits = _CountRecruits() EndIf EndIf $Dispense = 0 EndIf WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) EndIf EndIf $Debug5 += TimerDiff($DebugTimer2) $DebugTimer2=TimerInit() $Coords = PixelSearch(50, 255, 295, 335, 0x001300, 2,5) If @error Then _CheckState() ContinueLoop EndIf $Debug6 += TimerDiff($DebugTimer2) $DebugTimer2=TimerInit() If NOT @error Then If PixelGetColor(314,59) = 52479 Then ;MouseClick('left',285, 65,1,0) Send("3") MouseClick('left', $Coords[0] , $Coords[1], 1, 0) MouseMove(40, 30,0) Sleep(9) $Recruits = _CountRecruits() WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) ElseIf $ConvertNext=0 Then _MouseClickDrag("left",$Coords[0],$Coords[1],40, 30,0) Else $ConvertNext=0 _MouseClickDrag("left",$Coords[0],$Coords[1],365, 200,0) $ConvertTimer=TimerInit() EndIf EndIf $Debug7 += TimerDiff($DebugTimer2) Else Sleep(200) EndIfWEndEndFuncFunc _CheckState() If PixelGetColor(8,8) = 0 Then Local $s_Cursor = MouseGetCursor() MouseMove(365, 365) Do Sleep(10) Until MouseGetCursor() <> $s_Cursor Sleep(250) MouseClick('left') Switch $Level Case 6 MouseClick('left', 385, 105) $TempleBuilt = True Case 11 MouseClick('left', 385,310) $ManapoolBuilt = True MouseClick('Left',165, 280,Floor($Level/4),0) MouseClick('left', 385,260) Case 16 MouseClick('left', 385,155) $TempleBuilt = False $ConvertNext = False Case Else If Hex(PixelGetColor(245, 25),6) <> 'D90000' Then Do MouseClick('left',170, 140,1,0) Sleep(10) Until Hex(PixelGetColor(245, 25),6) = 'D90000' EndIf If $Level > 12 Then MouseClick('Left',165, 280,Floor($Level/4),0) EndIf EndSwitch Sleep(750) MouseClick('left', 505, 375) While PixelGetColor(8,8) = 0 Sleep(10) WEnd $Level += 1 WinSetTitle($Form1, '', 'Level: ' & $Level & ' - Recruits: ' & $Recruits) $Coords = PixelSearch(215, 5,280, 155,0xFFFF75,5) If NOT @error Then $ManapoolBuilt=True EndIf $Coords=PixelSearch(215, 5,550,365,0xF66262,5) If NOT @error Then $ArcheryBuilt=True EndIf $Coords=PixelSearch(215, 5,550,365,0x35E201,5) If Not @error Then $WorkshopBuilt=True EndIf Return EndIfEndFuncFunc _MouseClickDrag($s_Button, $s_X1,$s_Y1, $s_X2,$s_Y2,$s_Speed) MouseMove($s_X1, $s_Y1,$s_Speed) MouseDown($s_Button) ;Sleep(5) MouseMove($s_X2, $s_Y2,$s_Speed) Sleep(8) Sleep(8) Sleep(8) MouseUp($s_Button) ReturnEndFuncFunc _CountRecruits() Local $s_Rec = 0 Local $x For $x = 0 To 10 If PixelGetColor(355+(18*$x), 45) = 52479 Then $s_Rec += 1 EndIf Next Return $s_RecEndFuncUnfortunately there are currently serious lag issues in debug sections 1,2, & 7. As well as some moderate lag in debug section 3. These lag issues are noticeable starting at around level 16~17 and exponentially increases with each wave.I have some concepts that may prove capable of reducing the lag and possibly improve the effectiveness of the script, but please give me any tips or ideas that you may wish to share
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now