
-- attackers from west

ATTACK_DELAY_TOWER1 = 5

createArmyTower1 = function()

	ArmyTower1 = UnlimitedArmy.New({
					Player = 5,
					Area = 3000,
					AutoDestroyIfEmpty = false,
					TransitAttackMove = true,
					Formation = UnlimitedArmy.Formations.Lines,
					LeaderFormation = 4,
					AIActive = true,
					AutoRotateRange = true,
					DoNotNormalizeSpeed = true,
					})
	attackercontroller1 = 0
	ACTIVETOWER1DELAY = ATTACK_DELAY_TOWER1
	
	--	job		
		
		StartJob("SetupArmyTower1")

	end



	
-----------------------------------------------------------------------------------------------------------------------	
--
--	JOB: "SetupArmyTower1"
--
-----------------------------------------------------------------------------------------------------------------------	
	-------------------------------------------------------------------------------------------------------------------
	Condition_SetupArmyTower1 = function()
	-------------------------------------------------------------------------------------------------------------------
		
		return Counter.Tick2("SetupArmyTower1",10)
		
		end
		
	-------------------------------------------------------------------------------------------------------------------
	Action_SetupArmyTower1 = function()
	-------------------------------------------------------------------------------------------------------------------
	
		if IsDead("tower1a") and IsDead("tower1b") then
		return true
		end
		
		if	ACTIVETOWER1DELAY > 0 then
		
		ACTIVETOWER1DELAY = ACTIVETOWER1DELAY - 1
		
		return false
		
		end
		
		if ACTIVETOWER1DELAY == 0 then
		
			if attackercontroller1 == 0 and ArmyTower1:IsDead() and doorsopen == 0 then
		
				for i=1,3,1 do
				ArmyTower1:CreateLeaderForArmy(Entities.PU_LeaderSword3, 8, GetPosition("spawn1"), 0)
				end
				for i=1,3,1 do
				ArmyTower1:CreateLeaderForArmy(Entities.PU_LeaderBow2, 8, GetPosition("spawn1"), 0)
				end
				for i=1,2,1 do
				ArmyTower1:CreateLeaderForArmy(Entities.PV_Cannon2, 0, GetPosition("spawn1"), 0)
				end
				attackercontroller1 = 1
				
				ArmyTower1:AddCommandMove(GetPosition("HQ_Crawford"))
				ArmyTower1:AddCommandWaitForIdle(false)
				
			elseif attackercontroller1 == 0 and ArmyTower1:IsDead() and doorsopen == 1 then
			
				for i=1,3,1 do
				ArmyTower1:CreateLeaderForArmy(Entities.PU_LeaderSword3, 8, GetPosition("spawn1"), 3)
				end
				for i=1,3,1 do
				ArmyTower1:CreateLeaderForArmy(Entities.PU_LeaderBow3, 8, GetPosition("spawn1"), 3)
				end
				for i=1,2,1 do
				ArmyTower1:CreateLeaderForArmy(Entities.PV_Cannon3, 0, GetPosition("spawn1"), 3)
				end
			
				attackercontroller1 = 1
				
				ArmyTower1:AddCommandMove(GetPosition("HQ_Crawford"))
				ArmyTower1:AddCommandWaitForIdle(false)
				
			elseif attackercontroller1 == 1 and ArmyTower1:IsDead() and doorsopen == 0 then
				
				ArmyTower1:ClearCommandQueue()
				
				ACTIVETOWER1DELAY = ATTACK_DELAY_TOWER1			
				attackercontroller1 = 0
				
			elseif attackercontroller1 == 1 and ArmyTower1:IsDead() and doorsopen == 1 then
				
				ArmyTower1:ClearCommandQueue()
				
				ACTIVETOWER1DELAY = 3		
				attackercontroller1 = 0
		
			end
		
		end
		
		return false
	end