Guest User

Clash of Clans

a guest
Dec 12th, 2014
865
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #RequireAdmin
  2. #include <ButtonConstants.au3>
  3. #include <ComboConstants.au3>
  4. #include <GUIConstantsEx.au3>
  5. #include <EditConstants.au3>
  6. #include <WindowsConstants.au3>
  7. #include <TrayConstants.au3>
  8. #include <Misc.au3>
  9. #include <Tesseract.au3>
  10.  
  11. Opt ("MouseClickDelay", 10)
  12. Opt ("MouseClickDownDelay", 10)
  13. Opt ("MouseCoordMode", 0)
  14. Opt ('PixelCoordMode', 0)
  15.  
  16. $Title = "BlueStacks App Player"
  17. $Full = WinGetTitle ($Title)
  18. $HWnD = WinGetHandle ($Full)
  19. WinActivate ($HWnD)
  20.  
  21. Global $Left = 45, $Top = 70, $Right = 660, $Bottom = 490
  22. Global $BSsize = WinGetClientSize($hWnd)
  23. Global $x_ratio = $BSsize[0]/800, $y_ratio = $BSsize[1]/600
  24.  
  25. Global $Gold, $Elixir, $MinGold = 50000, $MinElixir = 50000
  26. Global $SearchMode = 1, $SearchCheck = 0, $ErrorCheck = 0
  27.  
  28. Global $UpLeft[5][2] = [[350*$x_ratio,51*$y_ratio],[230*$x_ratio,100*$y_ratio],[186*$x_ratio,160*$y_ratio],[144*$x_ratio,187*$y_ratio],[125*$x_ratio,200*$y_ratio]]
  29. Global $UpRight[5][2] = [[460*$x_ratio,62*$y_ratio],[520*$x_ratio,97*$y_ratio],[570*$x_ratio,134*$y_ratio],[647*$x_ratio,186*$y_ratio],[692*$x_ratio,211*$y_ratio]]
  30. Global $LowLeft[5][2] = [[77*$x_ratio, 306*$y_ratio],[130*$x_ratio,353*$y_ratio],[181*$x_ratio,395*$y_ratio],[214*$x_ratio,415*$y_ratio],[250*$x_ratio,442*$y_ratio]]
  31. Global $LowRight[5][2] = [[734*$x_ratio,290*$y_ratio],[685*$x_ratio,318*$y_ratio],[630*$x_ratio,350*$y_ratio],[600*$x_ratio,369*$y_ratio],[535*$x_ratio,425*$y_ratio]]
  32.  
  33. Global $Troop[5][2] = [[60*$x_ratio,505*$y_ratio],[130*$x_ratio,505*$y_ratio],[200*$x_ratio,505*$y_ratio],[265*$x_ratio,505*$y_ratio],[372*$x_ratio,505*$y_ratio]]
  34. Global $Barbarian[2] = [0,0], $Archer[2] = [0,0], $Golbin[2] =[0,0], $Giant[2] = [0,0]
  35.  
  36. Global $B1Pos[2] = [0,0], $B2Pos[2] = [0,0], $B3Pos[2] = [0,0], $B4Pos[2] = [0,0]
  37. Global $B1Troop, $B2Troop, $B3Troop, $B4Troop
  38.  
  39. HotKeySet("+{ESC}","Terminate")
  40.  
  41. #Region ### GUI ###
  42. $BotGUI = GUICreate("Clash of Clans Bot", 280, 170)
  43. GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
  44. $MeetAll = GUICtrlCreateCheckbox("Meet all conditions", 150, 20, 140, 17)
  45. GUICtrlCreateLabel("Min Gold:", 150, 48, 58, 17)
  46. $MinGoldInput = GUICtrlCreateInput("", 200, 44, 55, 21, $ES_NUMBER)
  47. GUICtrlSetLimit(-1, 6)
  48. GUICtrlCreateLabel("Min Elixir:", 150, 72, 57, 17)
  49. $MinElixirInput = GUICtrlCreateInput("", 200, 68, 55, 21, $ES_NUMBER)
  50. GUICtrlSetLimit(-1, 6)
  51. $Barrack01 = GUICtrlCreateCombo("Barrack 01", 30, 16, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  52. GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
  53. $Barrack02 = GUICtrlCreateCombo("Barrack 02", 30, 40, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  54. GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
  55. $Barrack03 = GUICtrlCreateCombo("Barrack 03", 30, 64, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  56. GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
  57. $Barrack04 = GUICtrlCreateCombo("Barrack 04", 30, 88, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  58. GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
  59. $StartButton = GUICtrlCreateButton("START (Shift+ESC to Exit)", 30, 120, 220, 40)
  60. GUISetState(@SW_SHOW)
  61. #EndRegion ### GUI ###
  62.  
  63. While 1
  64.    $Msg = GUIGetMsg()
  65.    Switch $Msg
  66.       Case $GUI_EVENT_CLOSE
  67.          $ExitCheck = MsgBox(4+65536, "Confirm Exit", "Are you sure you want to exit?", 0, $BotGUI)
  68.          If $ExitCheck = 6 Then
  69.             Exit
  70.          EndIf
  71.       Case $StartButton
  72.          Start()
  73.    EndSwitch
  74.  WEnd
  75.  
  76. Func Start()
  77.    Sleep(1000)
  78.    ;While 1
  79.       CheckIdle()   ;Check disconnect message and click on reload
  80.       GetInput()    ;Read user's input
  81.       ZoomOut()
  82.       LocateBarrack()   ;If barrack not located, ask user to manually click on barrack to locate position
  83.       Train()           ;Train troop according to user's input
  84.       ;Sleep(900000)    ;Wait 15 mins for troops training
  85.       ;AssignTroop()    ;Assign troop type to troop position in attack (unfinished)
  86.       PrepareAttack()   ;Click Attack
  87.       VillageSearch()   ;Search gold & elixir according to input
  88.       ;DropTroop()  ;Drop troop in order: Giant, Barbarian, Archer (unfinished)
  89.       DropAll() ;Drop everything
  90.       Sleep(180000) ;Wait 3 mins
  91.       ControlClick ($HWnD, "","", "left", "1", 400*$x_ratio, 450*$y_ratio)  ;Click Return Home
  92.       ;Sleep(10000)
  93.    ;WEnd
  94. EndFunc
  95.  
  96. Func CheckIdle()
  97.    WinActivate($HWnD)
  98.    $ColorCheck = PixelGetColor(560*$x_ratio, 333*$y_ratio, $HWnD)
  99.    If Hex($ColorCheck,6) = 282828 Then
  100.       ControlClick ($HWnD, "","", "left", "1", 205*$x_ratio, 330*$y_ratio)
  101.       Sleep(10000)
  102.    EndIf
  103. EndFunc
  104.  
  105. Func GetInput()
  106.    $B1Troop = GUICtrlRead($Barrack01)
  107.    $B2Troop = GUICtrlRead($Barrack02)
  108.    $B3Troop = GUICtrlRead($Barrack03)
  109.    $B4Troop = GUICtrlRead($Barrack04)
  110.    $MinGold = Number(GUICtrlRead($MinGoldInput))
  111.    $MinElixir = Number(GUICtrlRead($MinElixirInput))
  112.    If GUICtrlRead($MeetAll) = $GUI_CHECKED Then
  113.       $SearchMode = 2
  114.    Else
  115.       $SearchMode = 1
  116.    EndIf
  117. EndFunc
  118.  
  119. #Region ##### TRAIN #####
  120. Func FindPos(ByRef $Pos)
  121.    Local $x = 1
  122.       While $x = 1
  123.          If _IsPressed("01") Then
  124.             $Pos = MouseGetPos()
  125.             $x = 0
  126.          EndIf
  127.       WEnd
  128.    EndFunc
  129.  
  130. Func LocateBarrack()
  131.    Local $ClickCheck, $LocateCheck = 0
  132.    While 1
  133.       While 1
  134.          If $B1Pos[0] = 0 Then
  135.             $ClickCheck = MsgBox(6+65536, "Locate first barrack", "Click Continue then click on your first barrack. Cancel if not available", 0, $BotGUI)
  136.             If $ClickCheck = 11 Then
  137.                WinActivate ($HWnD)
  138.                FindPos($B1Pos)
  139.             ElseIf $ClickCheck = 10 Then
  140.                $B1Pos[0] = 0
  141.                $B2Pos[0] = 0
  142.                $B3Pos[0] = 0
  143.                $B4Pos[0] = 0
  144.                ExitLoop
  145.             EndIf
  146.             Sleep(500)
  147.          EndIf
  148.  
  149.          If $B2Pos[0] = 0 Then
  150.             $ClickCheck = MsgBox(6+65536, "Locate second barrack", "Click Continue then click on you second barrack. Cancel if not available", 0, $BotGUI)
  151.             If $ClickCheck = 11 Then
  152.                WinActivate ($HWnD)
  153.                FindPos($B2Pos)
  154.             ElseIf $ClickCheck = 10 Then
  155.                $B1Pos[0] = 0
  156.                $B2Pos[0] = 0
  157.                $B3Pos[0] = 0
  158.                $B4Pos[0] = 0
  159.                ExitLoop
  160.             EndIf
  161.             Sleep(500)
  162.          EndIf
  163.  
  164.          If $B3Pos[0] = 0 Then
  165.             $ClickCheck = MsgBox(6+65536, "Locate third barrack", "Click Continue then click on your third barrack. Cancel if not available", 0, $BotGUI)
  166.             If $ClickCheck = 11 Then
  167.                WinActivate ($HWnD)
  168.                FindPos($B3Pos)
  169.             ElseIf $ClickCheck = 10 Then
  170.                $B1Pos[0] = 0
  171.                $B2Pos[0] = 0
  172.                $B3Pos[0] = 0
  173.                $B4Pos[0] = 0
  174.                ExitLoop
  175.             EndIf
  176.             Sleep(500)
  177.          EndIf
  178.  
  179.          If $B4Pos[0] = 0 Then
  180.             $ClickCheck = MsgBox(6+65536, "Locate fourth barrack", "Click Continue then click on your fourth barrack. Cancel if not available", 0, $BotGUI)
  181.             If $ClickCheck = 11 Then
  182.                WinActivate ($HWnD)
  183.                FindPos($B4Pos)
  184.             ElseIf $ClickCheck = 10 Then
  185.                $B1Pos[0] = 0
  186.                $B2Pos[0] = 0
  187.                $B3Pos[0] = 0
  188.                $B4Pos[0] = 0
  189.                ExitLoop
  190.             EndIf
  191.             Sleep(500)
  192.          EndIf
  193.          ExitLoop(2)
  194.       WEnd
  195.    WEnd
  196. EndFunc
  197.  
  198. Func TrainBarrack($x, $y, $z)
  199.    ControlClick ($HWnD, "","", "left", "1", $x, $y)
  200.    Sleep(1000)
  201.    ControlClick ($HWnD, "","", "left", "1", 560*$x_ratio, 490*$y_ratio)
  202.    Sleep(1000)
  203.    Select
  204.    Case $z = "Barbarian"
  205.       For $i = 1 To 65 Step 1
  206.          ControlClick ($HWnD, "","", "left", "1", 220*$x_ratio, 270*$y_ratio)
  207.          Sleep(50)
  208.       Next
  209.    Case $z = "Archer"
  210.       For $i = 1 To 65 Step 1
  211.          ControlClick ($HWnD, "","", "left", "1", 310*$x_ratio, 270*$y_ratio)
  212.          Sleep(50)
  213.       Next
  214.    Case $z = "Goblin"
  215.       For $i = 1 To 65 Step 1
  216.          ControlClick ($HWnD, "","", "left", "1", 490*$x_ratio, 270*$y_ratio)
  217.          Sleep(50)
  218.       Next
  219.    Case $z = "Giant"
  220.       For $i = 1 To 15 Step 1
  221.          ControlClick ($HWnD, "","", "left", "1", 400*$x_ratio, 270*$y_ratio)
  222.          Sleep(50)
  223.       Next
  224.    EndSelect
  225.    Sleep(1000)
  226.    ControlClick ($HWnD, "","", "left", "1", 656*$x_ratio, 113*$y_ratio)
  227.    Sleep(1000)
  228. EndFunc
  229.  
  230. Func Train()
  231.    If $B1Pos[0] <> 0 Then
  232.       TrainBarrack($B1Pos[0],$B1Pos[1],$B1Troop)
  233.    EndIf
  234.    If $B2Pos[0] <> 0 Then
  235.       TrainBarrack($B2Pos[0],$B2Pos[1],$B2Troop)
  236.    EndIf
  237.    If $B3Pos[0] <> 0 Then
  238.       TrainBarrack($B3Pos[0],$B3Pos[1],$B3Troop)
  239.    EndIf
  240.    If $B4Pos[0] <> 0 Then
  241.       TrainBarrack($B4Pos[0],$B4Pos[1],$B4Troop)
  242.    EndIf
  243. EndFunc
  244.  
  245. #EndRegion ##### TRAIN #####
  246.  
  247. #Region ##### ATTACK #####
  248. Func PrepareAttack()
  249.    ;TrayTip ("Attack mode started!","Minimum Gold: " & $MinGold & ". Minimum Elixir: " & $MinElixir & ". Search Mode: " & $SearchMode, 0, $TIP_ICONASTERISK)
  250.    ControlClick ($HWnD, "","", "left", "1", 50*$x_ratio, 500*$y_ratio) ;Click Attack
  251.    Sleep(2000)
  252.    ControlClick ($HWnD, "","", "left", "1", 190*$x_ratio, 420*$y_ratio) ;Click Find a Match
  253.    Sleep(2000)
  254.    ControlClick ($HWnD, "","", "left", "1", 470*$x_ratio, 330*$y_ratio) ;Click Break Shield
  255. EndFunc
  256.  
  257. Func CheckScreen()
  258.    Local $Check = ""
  259.    $i = 0
  260.    While $Check = "" And $ErrorCheck = 0
  261.       $Check = _TesseractWinCapture($HWnD,"",0,"",1,2,$Left*$x_ratio,$Top*$y_ratio,$Right*$x_ratio,$Bottom*$y_ratio,0)
  262.       $Check = StringStripWS($Check, 8)
  263.       Sleep(200)
  264.       $i += 1
  265.       If $i > 150 Then
  266.          $ErrorCheck = 1
  267.          Exit
  268.       EndIf
  269.    WEnd
  270. EndFunc
  271.  
  272. Func VillageSearch()
  273.    CheckScreen()
  274.    ReadValue()
  275.    CompareValue()
  276.    While $SearchCheck = 0 And $ErrorCheck = 0
  277.       ControlClick ($HWnD, "","", "left", "1", 715*$x_ratio, 405*$y_ratio) ;Click Next
  278.       CheckScreen()
  279.       ReadValue()
  280.       CompareValue()
  281.    WEnd
  282.    If $ErrorCheck = 1 Then
  283.       Restart()
  284.       Attack()
  285.    Else
  286.       TrayTip ("Enemy Found!","Requirement met:  Gold: " & $Gold & ". Elixir: " & $Elixir, 0, $TIP_ICONASTERISK)
  287.       Sleep(20000)
  288.    EndIf
  289. EndFunc
  290.  
  291. Func CheckTroop($a)
  292.    If $B1Troop = $a Or $B2Troop = $a Or $B3Troop = $a Or $B4Troop = $a Then
  293.       Return True
  294.    Else
  295.       Return False
  296.    EndIf
  297. EndFunc
  298.  
  299. Func AssignTroop()
  300.    If CheckTroop("Barbarian") Then
  301.       $Barbarian[0] = $Troop[0][0]
  302.       #Barbarian[1] = $Troop[0][1]
  303.       If CheckTroop("Archer") Then
  304.          $Archer[0] = $Troop[1][0]
  305.          $Archer[1] = $Troop[1][1]
  306.          If CheckTroop("Goblin") Then
  307.             $Goblin[0] = $Troop[2][0]
  308.             $Goblin[1] = $Troop[2][1]
  309.             If CheckTroop("Giant") Then
  310.                $Giant[0] = $Troop[3][0]
  311.                $Giant[1] = $Troop[3][1]
  312.             EndIf
  313.          ElseIf CheckTroop("Giant") Then
  314.             $Giant[0] = $Troop[2][0]
  315.             $Giant[1] = $Troop[2][1]
  316.          EndIf
  317.       ElseIf CheckTroop("Goblin") Then
  318.          $Goblin[0] = $Troop[1][0]
  319.          $Goblin[1] = $Troop[1][1]
  320.          If CheckTroop("Giant") Then
  321.             $Giant[0] = $Troop[2][0]
  322.             $Giant[1] = $Troop[2][1]
  323.          EndIf
  324.       ElseIf CheckTroop("Giant") Then
  325.          $Giant[0] = $Troop[1][0]
  326.          $Giant[1] = $Troop[1][1]
  327.       EndIf
  328.    ElseIf CheckTroop("Archer") Then
  329.       $Archer[0] = $Troop[0][0]
  330.       $Archer[1] = $Troop[0][1]
  331.       If CheckTroop("Goblin") Then
  332.          $Goblin[0] = $Troop[1][0]
  333.          $Goblin[1] = $Troop[1][1]
  334.          If CheckTroop("Giant") Then
  335.             $Giant[0] = $Troop[2][0]
  336.             $Giant[1] = $Troop[2][1]
  337.          EndIf
  338.       ElseIf CheckTroop("Giant") Then
  339.          $Giant[0] = $Troop[1][0]
  340.          $Giant[1] = $Troop[1][1]
  341.       EndIf
  342.    ElseIf CheckTroop("Goblin") Then
  343.       $Goblin[0] = $Troop[0][0]
  344.       $Goblin[1] = $Troop[0][1]
  345.       If CheckTroop("Giant") Then
  346.          $Giant[0] = $Troop[1][0]
  347.          $Giant[1] = $Troop[1][1]
  348.       EndIf
  349.    ElseIf CheckTroop("Giant") Then
  350.       $Giant[0] = $Troop[0][0]
  351.       $Giant[1] = $Troop[0][1]
  352.    EndIf
  353. EndFunc
  354.  
  355. Func DropAll()
  356.    ControlClick ($HWnD, "","", "left", "1", $Troop[2][0], $Troop[2][1])
  357.    Sleep(500)
  358.    For $i = 0 to 4 Step 1
  359.       ControlClick ($HWnD, "","", "left", "1", $UpLeft[$i][0], $UpLeft[$i][1])
  360.       Sleep(100)
  361.    Next
  362.    Sleep(500)
  363.    ControlClick ($HWnD, "","", "left", "1", $Troop[0][0], $Troop[0][1])
  364.    Sleep(300)
  365.    For $x = 0 to 15 Step 1
  366.       For $i = 0 to 4 Step 1
  367.          ControlClick ($HWnD, "","", "left", "1", $UpLeft[$i][0], $UpLeft[$i][1])
  368.          Sleep(100)
  369.       Next
  370.       Sleep(300)
  371.    Next
  372.    Sleep(500)
  373.    ControlClick ($HWnD, "","", "left", "1", $Troop[1][0], $Troop[1][1])
  374.    Sleep(300)
  375.    For $x = 0 to 8 Step 1
  376.       For $i = 0 to 4 Step 1
  377.          ControlClick ($HWnD, "","", "left", "1", $UpLeft[$i][0], $UpLeft[$i][1])
  378.          Sleep(100)
  379.       Next
  380.       Sleep(300)
  381.    Next
  382.    Sleep(500)
  383.    ControlClick ($HWnD, "","", "left", "1", $Troop[2][0], $Troop[2][1])
  384.    Sleep(500)
  385.    For $i = 0 to 4 Step 1
  386.       ControlClick ($HWnD, "","", "left", "1", $UpRight[$i][0], $UpRight[$i][1])
  387.       Sleep(100)
  388.    Next
  389.    Sleep(500)
  390.    ControlClick ($HWnD, "","", "left", "1", $Troop[0][0], $Troop[0][1])
  391.    Sleep(300)
  392.    For $x = 0 to 15 Step 1
  393.       For $i = 0 to 4 Step 1
  394.          ControlClick ($HWnD, "","", "left", "1", $UpRight[$i][0], $UpRight[$i][1])
  395.          Sleep(100)
  396.       Next
  397.       Sleep(300)
  398.    Next
  399.    Sleep(500)
  400.    ControlClick ($HWnD, "","", "left", "1", $Troop[1][0], $Troop[1][1])
  401.    Sleep(300)
  402.    For $x = 0 to 8 Step 1
  403.       For $i = 0 to 4 Step 1
  404.          ControlClick ($HWnD, "","", "left", "1", $UpRight[$i][0], $UpRight[$i][1])
  405.          Sleep(100)
  406.       Next
  407.       Sleep(300)
  408.    Next
  409.    Sleep(500)
  410. EndFunc
  411.  
  412. Func DropTroop()
  413.    DropCombo($UpLeft)
  414.    DropCombo($UpRight)
  415. EndFunc
  416.  
  417. Func DropCombo($Wing)
  418.    If CheckTroop("Giant") Then
  419.       ControlClick ($HWnD, "","", "left", "1", $Giant[0], $Giant[1])
  420.       Sleep(300)
  421.       For $i = 1 to 3 Step 1
  422.          ControlClick ($HWnD, "","", "left", "1", $Wing[$i][0], $Wing[i][1])
  423.          Sleep(100)
  424.       Next
  425.       Sleep(300)
  426.    EndIf
  427.    If CheckTroop("Barbarian") Then
  428.       ControlClick ($HWnD, "","", "left", "1", $Barbarian[0], $Barbarian[1])
  429.       Sleep(300)
  430.       For $x = 0 to 2 Step 1
  431.          For $i = 0 to 4 Step 1
  432.             ControlClick ($HWnD, "","", "left", "1", , $Wing[$i][0], $Wing[i][1])
  433.             Sleep(100)
  434.          Next
  435.       Next
  436.       Sleep(300)
  437.    EndIf
  438.    If CheckTroop("Archer") Then
  439.       ControlClick ($HWnD, "","", "left", "1", $Archer[0], $Archer[1])
  440.       Sleep(300)
  441.       For $x = 0 to 2 Step 1
  442.          For $i = 0 to 4 Step 1
  443.             ControlClick ($HWnD, "","", "left", "1", , $Wing[$i][0], $Wing[i][1])
  444.             Sleep(100)
  445.          Next
  446.       Next
  447.       Sleep(300)
  448.    EndIf
  449.    If CheckTroop("Goblin") Then
  450.       ControlClick ($HWnD, "","", "left", "1", $Goblin[0], $Goblin[1])
  451.       Sleep(300)
  452.       For $x = 0 to 2 Step 1
  453.          For $i = 0 to 4 Step 1
  454.             ControlClick ($HWnD, "","", "left", "1", , $Wing[$i][0], $Wing[i][1])
  455.             Sleep(100)
  456.          Next
  457.       Next
  458.       Sleep(30)
  459.    EndIf
  460. EndFunc
  461.  
  462. Func ReadValue()
  463.    $Read = _TesseractWinCapture($HWnD,"",0,"",1,2,$Left*$x_ratio,$Top*$y_ratio,$Right*$x_ratio,$Bottom*$y_ratio,0)  ;Capture screen region with gold and elixir
  464.    ;MsgBox(0,"Read",$Read)
  465.    $Read = StringRegExpReplace(StringRegExpReplace($Read, "(\v)+", @CRLF), "\A\v|\v\Z", "")
  466.    ;MsgBox(0,"Read",$Read)
  467.    $Read = StringSplit($Read, @CRLF, 1) ;Strip whitespaces & blank lines and split into array
  468.    ;MsgBox(0,"Read",$Read[2] & @CR & $Read[3])
  469.    $Gold = Number(StringRegExpReplace($Read[2], "[^[:digit:]]", ""))    ;Convert gold to number
  470.    $Elixir = Number(StringRegExpReplace($Read[3], "[^[:digit:]]", ""))  ;Convert exlir to number
  471.    ;$Dark = Number(StringStripWS($Read[4], $STR_STRIPALL))
  472.    ;MsgBox(0,"Result", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Dark: " & $Dark)
  473.    ;TrayTip ("Current Search","Gold: " & $Gold & ". Elixir: " & $Elixir, 0, $TIP_ICONASTERISK)
  474.    ;SplashTextOn("Current Search","Gold: " & $Gold & @CR & "Elixir: " & $Elixir,200,70)
  475.  
  476. EndFunc
  477.  
  478. Func CompareValue()
  479.    If $Gold >= $MinGold Then
  480.       If $Elixir >= $MinElixir Then
  481.          ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Requirement met.")
  482.          Select
  483.             Case $SearchMode = 1
  484.                $SearchCheck = 1
  485.             Case $SearchMode = 2
  486.                $SearchCheck = 1
  487.             Case Else
  488.                $SearchCheck = 0
  489.          EndSelect
  490.       Else
  491.          ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR &  "Not enough " & $MinElixir & " Elixir.")
  492.          Select
  493.             Case $SearchMode = 1
  494.                $SearchCheck = 1
  495.             Case $SearchMode = 2
  496.                $SearchCheck = 0
  497.             Case Else
  498.                $SearchCheck = 0
  499.          EndSelect
  500.       EndIf
  501.    Else
  502.       If $Elixir >= $MinElixir Then
  503.          ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Not enough " & $MinGold & " Gold.")
  504.          Select
  505.             Case $SearchMode = 1
  506.                $SearchCheck = 1
  507.             Case $SearchMode = 2
  508.                $SearchCheck = 0
  509.             Case Else
  510.                $SearchCheck = 0
  511.          EndSelect
  512.       Else
  513.          ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Not enough " & $MinGold & " Gold and " & $MinElixir & " Elixir." )
  514.          Select
  515.             Case $SearchMode = 1
  516.                $SearchCheck = 0
  517.             Case $SearchMode = 2
  518.                $SearchCheck = 0
  519.             Case Else
  520.                $SearchCheck = 0
  521.          EndSelect
  522.       EndIf
  523.    EndIf
  524. EndFunc
  525. #EndRegion ##### ATTACK #####
  526.  
  527. Func Initiate()
  528.    ControlClick ($HWnD, "","", "left", "1", 290, 150) ;Click BlueStacks
  529.    Sleep(60000)
  530.    ZoomOut()
  531.    Sleep(10000)
  532. EndFunc
  533.  
  534. Func ZoomOut()
  535.    For $i = 1 To 20 Step 1
  536.       ControlSend($HWnD, "", "", "{DOWN}", 0)
  537.       Sleep(500)
  538.    Next
  539. EndFunc
  540.  
  541. Func Restart()
  542.    ControlClick ($HWnD, "","", "left", "1", 125, 575)
  543.    Sleep(2000)
  544.    ControlClick ($HWnD, "","", "left", "1", 125, 577)
  545.    Sleep(2000)
  546.    ControlClick ($HWnD, "","", "left", "1", 205, 575)
  547.    Sleep(2000)
  548.    MouseClickDrag("left", 700, 300, 700, 120)
  549.    Sleep(2000)
  550.    ControlClick ($HWnD, "","", "left", "1", 290, 160)
  551.    Sleep(50000)
  552. EndFunc
  553.  
  554. Func Pause()
  555.    $Paused = NOT $Paused
  556.    While $Paused
  557.       Sleep(100)
  558.    TrayTip("Script Paused","Press Space to Unpause", 0, $TIP_ICONASTERISK)
  559.    WEnd
  560. EndFunc
  561.  
  562. Func Terminate()
  563.    Exit
  564. EndFunc
RAW Paste Data