Jump to content
TheRevenor

[Snippet] - Deleted Wrong Troops In Army Overview

Recommended Posts

Deleted Wrong Troops In Army Overview

I just trying make this features to help other user in accordance with the limits of my ability, so if there is a mistake please forgive me :P

And I'am Sorry for My bad English ;p

 

iDXIUgL.png

 

About Delete Wrong Troops In Army Overview Feature ;p

[6:44:48 AM]  »» Deleting Queued Troops!!
[6:44:50 AM]  » Barrack nº 1 Max Capacity is: 80
[6:44:52 AM]  » Barrack nº 2 Max Capacity is: 85
[6:44:54 AM]  » Barrack nº 3 Max Capacity is: 85
[6:44:54 AM]  »» Deleting Queued Dark Troops!!
[6:44:56 AM]  » Dark Barrack nº 1 Max Capacity is: 100
[6:44:57 AM]  » Dark Barrack nº 2 Max Capacity is: 100
[6:44:57 AM] Checking if Village needs Rearming..
[6:45:00 AM] Rearm not needed!
[6:45:03 AM] No Tombs Found!
[6:45:05 AM] Collecting Resources
[6:45:11 AM] Searching for a Loot Cart..
[6:45:12 AM] No Loot Cart found, Yard is clean!
[6:45:14 AM] Checking for Donate Requests in Clan Chat
[6:45:18 AM] ----------------------------------
[6:45:18 AM] Chat Request: terry
[6:45:18 AM] Chat Troops: 25/25, Spells: 0/1
[6:45:18 AM] Clan Castle troops are full, skip troop donation...
[6:45:21 AM] ----------------------------------
[6:45:21 AM] Chat Request: Jogo
[6:45:21 AM] Chat Troops: 0/25, Spells: 1/1
[6:45:21 AM] Clan Castle spells are full, skip spell donation...
[6:45:22 AM] Custom Donation Keyword found: jogo
[6:45:22 AM] Donating 4 Archers
[6:45:22 AM]  » Donated Archer 1
[6:45:23 AM]  » Donated Archer 2
[6:45:24 AM]  » Donated Archer 3
[6:45:25 AM]  » Donated Archer 4
[6:45:26 AM] Donating 2 Barbarians
[6:45:26 AM]  » Donated Barbarian 1
[6:45:28 AM]  » Donated Barbarian 2
[6:45:29 AM] -----------End Donate-----------
[6:45:30 AM]  »» Checking Wrong Troops In ArmyOverview !!
[6:45:33 AM] Total Army Camp capacity: 234/240 (97%)
[6:45:41 AM]  - No. of Barbarians: 93
[6:45:41 AM]  - No. of Archers: 90
[6:45:42 AM]  - No. of Goblins: 9
[6:45:42 AM]  - No. of Wall Breakers: 6
[6:45:42 AM]  - No. of Wizards: 3
[6:45:42 AM]  - No. of Minions: 4
[6:45:42 AM]  - No. of Hog Riders: 2
[6:45:42 AM]  - Barbarian King available
[6:45:42 AM]  - Archer Queen available
[6:45:42 AM] Total Spell(s) Capacity: 11/11
[6:45:42 AM]  - No. of Lightning Spells: 5
[6:45:42 AM]  - No. of Haste Spells: 1
[6:45:47 AM]  » Deleted 6 Wall Breaker
[6:45:50 AM]  » Deleted 9 Goblin
[6:45:51 AM]  » Deleted 3 Wizard
[6:45:53 AM]  » Deleted 4 Minion
[6:45:54 AM]  » Deleted 2 Hog Rider
[6:45:56 AM]  »» Deleting Troops In ArmyOverview Finish..
[6:46:03 AM] Requesting Clan Castle Troops
[6:46:13 AM] Training Troops & Spells
[6:46:16 AM] Total Army Camp capacity: 183/240 (76%)
[6:46:18 AM]  - No. of Barbarians: 93
[6:46:19 AM]  - No. of Archers: 90
[6:46:19 AM]  - Barbarian King available
[6:46:19 AM]  - Archer Queen available
[6:46:19 AM] Total Spell(s) Capacity: 11/11
[6:46:19 AM]  - No. of Lightning Spells: 5
[6:46:19 AM]  - No. of Haste Spells: 1
[6:46:19 AM] CC request time: 14.83 minutes
[6:46:23 AM]  » Let's make a new Army before attack!
[6:46:24 AM]  » Total Barrack Space to be Train: 57
[6:46:24 AM]  » Existent Army: 183 To train : 57 | [T]: 240
[6:46:24 AM]  »» Preparing to Train 30 Archers
[6:46:24 AM]  »» Preparing to Train 27 Barbarians

I set train troops for 120 barb and 120 arch, but in army overview there are wrong troops like WB, GOB, WIZ, MIN, and HOG.. so wrong troops must be deleted before training corect troops ;p

[6:45:47 AM]  » Deleted 6 Wall Breaker
[6:45:50 AM]  » Deleted 9 Goblin
[6:45:51 AM]  » Deleted 3 Wizard
[6:45:53 AM]  » Deleted 4 Minion
[6:45:54 AM]  » Deleted 2 Hog Rider

[6:45:56 AM]  »» Deleting Troops In ArmyOverview Finish..

 

You can use My MOD v2.0.5 for this feature ;p

Or If You want adding code by yourself, follow my instructions ;)

Step 1:  Open MBR GUI Design Child Attack - Troops.au3 (Folder 'COCBot\GUI') 

Spoiler

Added code in line 213

		$y += 33
		$chkDeleteTroops = GUICtrlCreateCheckbox("Deleted Wrong Troops!!",$x - 158, $y + 5, -1, -1) ; Delete Troops In Army Overview
			_GUICtrlSetTip(-1, GetTranslated(612, 20, "Deleted Wrong Troops in Army Overview before train troops"))
			GUICtrlSetState(-1, $GUI_UNCHECKED)

 

Step 2: Open  MBR Global Variables.au3 (Folder 'CocBot')

Spoiler

Added code in line 1497

; Deleted Wrong Troops - Added by TheRevenor
Global $ichkDeleteTroops

 

Step 3: Open MBR Functions.au3 (Folder 'CocBot')

Spoiler

Added code in line 264

; DeleteTroopsInArmyOverview - Added by TheRevenor
#include "functions\Other\DeleteTroopsInArmyOverview.au3"

 

Step 4: Open applyConfig.au3 (Folder 'COCBot\functions\Config')

Spoiler

Added code in line 2578

	; Deleted Wrong Troops - Added by TheRevenor
	If $ichkDeleteTroops = 1 Then
		GUICtrlSetState($chkDeleteTroops, $GUI_CHECKED)
	Else
		GUICtrlSetState($chkDeleteTroops, $GUI_UNCHECKED)
	EndIf

 

Step 5: Open readConfig.au3 (Folder 'COCBot\functions\Config')

Spoiler

Added code in line 1000

		; Deleted Wrong Troops - Added by TheRevenor
		$ichkDeleteTroops = IniRead($config, "Mod", "DeletedTroops", "0")

 

Step 6: Open saveConfig.au3 (Folder 'COCBot\functions\Config')

Spoiler

Added code in line 2461

	; Deleted Wrong Troops - Added by TheRevenor
	If GUICtrlRead($chkDeleteTroops) = $GUI_CHECKED Then
		IniWrite($config, "Mod", "DeletedTroops", 1)
	Else
		IniWrite($config, "Mod", "DeletedTroops", 0)
	EndIf

 

Step 7: Open MyBot.run.au3 (Folder 'MyBot')

Spoiler

Replace line 602

		Case "DonateCC,Train"
			DonateCC()
			If _Sleep($iDelayRunBot1) = False Then checkMainScreen(False)
			Train()
			_Sleep($iDelayRunBot1)

With:

		Case "DonateCC,Train"
			DonateCC()
			If _Sleep($iDelayRunBot1) = False Then checkMainScreen(False)
			If $ichkDeleteTroops = 1 Then DeleteTroopsInArmyOverview()
			Train()
			_Sleep($iDelayRunBot1)

 

Step 8: Add DeleteTroopsInArmyOverview.au3 to (folder 'COCBot\functions\Other')

Spoiler
; #FUNCTION# ====================================================================================================================
; Name ..........: DeleteTroopsInArmyOverview
; Description ...: Opens and waits for Army Overiew window and Delete Wrong Troops
; Syntax ........: DeleteTroopsInArmyOverview()
; Parameters ....:
; Return values .: None
; Author ........: TheRevenor (09-2016)
; Modified ......:
; Remarks .......: This file is part of MyBot, previously known as ClashGameBot. Copyright 2015-2016
;                  MyBot is distributed under the terms of the GNU GPL
; Related .......:
; Link ..........: https://github.com/MyBotRun/MyBot/wiki
; Example .......: No
; ===============================================================================================================================
Func DeleteTroopsInArmyOverview()
	SetLog(" »» Checking Wrong Troops In ArmyOverview !!", $COLOR_ORANGE)

	If _Sleep($iDelayTrain3) Then Return
	;OPEN ARMY OVERVIEW WITH NEW BUTTON
	openArmyOverview()
	If _Sleep($iDelayTrain3) Then Return

	If WaitforPixel(762, 328 + $midOffsetY, 763, 329 + $midOffsetY, Hex(0xF18439, 6), 10, 10) Then
		If $debugsetlogTrain = 1 Then SetLog("Wait for ArmyOverView Window", $COLOR_PURPLE)
		If IsTrainPage() Then 
			GetArmyCapacity()
			If _Sleep($iDelaycheckArmyCamp6) Then Return ; 10ms improve pause button response
			getArmyTroopCount()
			If _Sleep($iDelaycheckArmyCamp6) Then Return ; 10ms improve pause button response
			getArmyHeroCount()
			If _Sleep($iDelaycheckArmyCamp6) Then Return ; 10ms improve pause button response
			getArmySpellCapacity()
			If _Sleep($iDelaycheckArmyCamp6) Then Return ; 10ms improve pause button response
			getArmySpellCount()
			If _Sleep($iDelaycheckArmyCamp6) Then Return ; 10ms improve pause button response
		EndIf
	EndIf
	If _Sleep($iDelayTrain3) Then Return

	Click(640, 500, 1, 0, "Click Edit Troops")
	If _Sleep($iDelayTrain3) Then Return

	DeletedTroops()

	If _ColorCheck(_GetPixelColor(710, 432 + $midOffsetY, True), Hex(0x70BC20, 6), 20) Then ; Click Okay
		Click(710, 462, 1, 0, "Click Okay") 
		If _Sleep($iDelayTrain3) Then Return
	EndIf

	If _ColorCheck(_GetPixelColor(550, 406 + $midOffsetY, True), Hex(0x66B40F, 6), 20) Then ; Click Confirm Deletion
		Click(550, 436, 1, 0, "Click Confirm")
		If _Sleep($iDelayTrain3) Then Return
		$fullArmy = False
		SetLog(" »» Deleting Troops In ArmyOverview Finish..", $COLOR_GREEN)
	Else
		SetLog(" »» Not Found Wrong Troops, Checking Finish..", $COLOR_GREEN)
	EndIf

	ClickP($aAway, 1, 0, "#0000") ;Click Away
	If _Sleep(4000) Then Return

EndFunc   ;==>DeleteTroopsInArmyOverview

Func DeletedTroops()

	If $debugSetlog = 1 Then SetLog("Troops in excess!...", $COLOR_PURPLE)
	If $debugsetlogTrain = 1 Then SetLog("Start-Loop Regular Troops Only To Donate ")
	For $i = 0 To UBound($TroopName) - 1
		If $debugsetlogTrain = 1 Then SetLog("Troop :" & NameOfTroop(Eval("e" & $TroopName[$i])))
		If (Eval("Cur" & $TroopName[$i]) * -1) > Eval($TroopName[$i] & "Comp") Then ; verify if the exist excess of troops

			$Delete = (Eval("Cur" & $TroopName[$i]) * -1) - Eval($TroopName[$i] & "Comp") ; existent troops - troops selected in GUI
			If $debugsetlogTrain = 1 Then SetLog("$Delete :" & $Delete)
			$SlotTemp = Eval("SlotInArmy" & $TroopName[$i])
			If $debugsetlogTrain = 1 Then SetLog("$SlotTemp :" & $SlotTemp)

			If _Sleep(250) Then Return
			If _ColorCheck(_GetPixelColor(170 + (62 * $SlotTemp), 235 + $midOffsetY, True), Hex(0xD40003, 6), 10) Then ; Verify if existe the RED [-] button
				Click(170 + (62 * $SlotTemp), 235 + $midOffsetY, $Delete, 300)
				SetLog(" » Deleted " & $Delete & " " & NameOfTroop(Eval("e" & $TroopName[$i])), $COLOR_RED)
				Assign("Cur" & $TroopName[$i], Eval("Cur" & $TroopName[$i]) + $Delete) ; Remove From $CurTroop the deleted Troop quantity
			EndIf
		EndIf
	Next

	If $debugsetlogTrain = 1 Then SetLog("Start-Loop Dark Troops Only To Donate ")
	For $i = 0 To UBound($TroopDarkName) - 1
		If $debugsetlogTrain = 1 Then SetLog("Troop :" & NameOfTroop(Eval("e" & $TroopDarkName[$i])))
		If (Eval("Cur" & $TroopDarkName[$i]) * -1) > Eval($TroopDarkName[$i] & "Comp") Then ; verify if the exist excess of troops

			$Delete = (Eval("Cur" & $TroopDarkName[$i]) * -1) - Eval($TroopDarkName[$i] & "Comp") ; existent troops - troops selected in GUI
			If $debugsetlogTrain = 1 Then SetLog("$Delete :" & $Delete)
			$SlotTemp = Eval("SlotInArmy" & $TroopDarkName[$i])
			If $debugsetlogTrain = 1 Then SetLog("$SlotTemp :" & $SlotTemp)

			If _Sleep(250) Then Return
			If _ColorCheck(_GetPixelColor(170 + (62 * $SlotTemp), 235 + $midOffsetY, True), Hex(0xD40003, 6), 10) Then ; Verify if existe the RED [-] button
				Click(170 + (62 * $SlotTemp), 235 + $midOffsetY, $Delete, 300)
				SetLog(" » Deleted " & $Delete & " " & NameOfTroop(Eval("e" & $TroopDarkName[$i])), $COLOR_RED)
				Assign("Cur" & $TroopDarkName[$i], Eval("Cur" & $TroopDarkName[$i]) + $Delete) ; Remove From $CurTroop the deleted Troop quantity
			EndIf
		EndIf
	Next

EndFunc    ;==>DeletedTroops

DeleteTroopsInArmyOverview.au3

 

Finish.. And dont forget to enjoy :thumbsup::P

 

Edited by TheRevenor
Fixed Typo
  • Upvote 8

Share this post


Link to post
Share on other sites
3 hours ago, TheRevenor said:

I just trying make this features to help other user in accordance with the limits of my ability, so if there is a mistake please forgive me :P

And I'am Sorry for My bad English ;p

Hi dude,

Great work!!

Could we apply at any mod?

I ask this because mod that I use train army is not by number of troops how new train system,  but by %.

Thanks in advance.

Regards

Share this post


Link to post
Share on other sites
1 hour ago, AnDrOmEdA said:

Hi dude,

Great work!!

Could we apply at any mod?

I ask this because mod that I use train army is not by number of troops how new train system,  but by %.

Thanks in advance.

Regards

I think this feature can apply at any MOD bro, you can try :thumbsup:

Share this post


Link to post
Share on other sites
5 hours ago, AnDrOmEdA said:

Hi dude,

Great work!!

Could we apply at any mod?

I ask this because mod that I use train army is not by number of troops how new train system,  but by %.

Thanks in advance.

Regards

Yes you can apply to any mod

Share this post


Link to post
Share on other sites

Hi guys ...

Every thing is correct but there is a tiny problem that you should have caution:

Apparently @TheRevenor has made this tutorial base on his MOD version.

 

In all steps he has referred to the location: "functions\Mod\DeletedTroops\DeleteTroopsInArmyOverview.au3"

but at the end (Step 8):   "Add DeleteTroopsInArmyOverview.au3 to (folder 'COCBot\functions\Other')"

So if you are using the official version you should create these folders (Mod\DeletedTroops) and put the '.au3' on that

or edit the codes.

 

 

Edited by Eloy

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×