Jump to content
Sign in to follow this  
BOLUDOZ

Automatic update camps. (Updated)

Recommended Posts

Automatically update the camps.
 

Free for those who want to use it and improve it.

 

He will verify it only once so that the spells can be trained, then you will not notice, he will verify each time he makes a troop and update the GUI inclusive.

Source

Automatic update camps.

COCBot\functions\Read Text\getOcr.au3

Find:

Func getArmyCapacityOnTrainTroops($x_start, $y_start) ;  -> Gets quantity of troops in army Window
	Return getOcrAndCapture("coc-NewCapacity", $x_start, $y_start, 67, 14, True)
EndFunc   ;==>getArmyCapacityOnTrainTroops

Remplace by it:

Func _getArmyCapacityOnTrainTroops($x_start, $y_start) ;  -> Gets quantity of troops in army Window

Local $aResult[3] = [0, 0, 0]
	$aResult[0] = getOcrAndCapture("coc-NewCapacity", $x_start, $y_start, 67, 14, True)
	Local $dbg = 0
		Local $aTempResult = StringSplit($aResult[0], "#", $STR_NOCOUNT)
		$aResult[1] = Number($aTempResult[0]) 
		$aResult[2] = Number($aTempResult[1])
		$aResult[2] = $aResult[2] / 2
		; Spell
		If $aResult[2] <= 11 Then
		GUICtrlSetData($g_hTxtTotalCountSpell, $aResult[2])
		$g_iTotalSpellValue = $aResult[2]
		; Army
		ElseIf $aResult[2] >= 15 Then
		GUICtrlSetData($g_hTxtTotalCampForced, $aResult[2])
		$g_iTotalCampForcedValue = $aResult[2]
		
	If $dbg = 1 Then Setlog($aResult[0])
	If $dbg = 1 Then Setlog($g_iTotalSpellValue)
	If $dbg = 1 Then Setlog($g_iTotalCampForcedValue)

	EndIf
	
	Return $aResult[0]
EndFunc   ;==>_getArmyCapacityOnTrainTroops

Func CheckAutoCamp() ; Only first Run and th5 + (Then every time he does the troops he will do it alone.)
	Local $dbg = 0
	If $dbg = 1 Then Setlog($g_iTotalSpellValue)
	Local $iCmpSpell = StringCompare($g_iTotalSpellValue, "0")
        If $iCmpSpell = 0 And $g_iTownHallLevel >= 5 Then ; Spell camp
            click(30, 584)
            if _sleep(1000) then return 
            click(407, 132)
            if _sleep(1000) then return 
			Local $NewSpellOCR = getArmyCapacityOnTrainTroops(48, 160) ; Check spell camps
            click(280, 132)
            if _sleep(1000) then return 
			Local $NewCampOCR = getArmyCapacityOnTrainTroops(48, 160) ; Check army camps
				click(825, 122)
			if _sleep(1000) then return 
		Endif
EndFunc   ;==>CheckAutoCamp

; INFO ! ======================
	;		; full & forced Total Camp values
	;		$g_iTrainArmyFullTroopPct = Int(GUICtrlRead($g_hTxtFullTroop))
	;		$g_bTotalCampForced = (GUICtrlRead($g_hChkTotalCampForced) = $GUI_CHECKED)
	;		$g_iTotalCampForcedValue = Int(GUICtrlRead($g_hTxtTotalCampForced))
	;		; spell capacity and forced flag
	;		$g_iTotalSpellValue = GUICtrlRead($g_hTxtTotalCountSpell)
	;		$g_bForceBrewSpells = (GUICtrlRead($g_hChkForceBrewBeforeAttack) = $GUI_CHECKED)
; ====================
          
Func getArmyCapacityOnTrainTroops($x_start, $y_start)
Local $g_campSpaceAuto = 1
	if $g_campSpaceAuto = 1 Then
			Return _getArmyCapacityOnTrainTroops($x_start, $y_start)
	Else
			Return getOcrAndCapture("coc-NewCapacity", $x_start, $y_start, 67, 14, True)
	Endif
EndFunc   ;==>getArmyCapacityOnTrainTroops

MyBot.run.au3 (Optional:)

 

find:

Case "DonateCC,Train"

remplace:

		Case "DonateCC,Train"
				   CheckAutoCamp()

And compile.

Edited by BOLUDOZ
  • Like 1
  • Upvote 4

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...