Making Tunnels with Curves Work
January 29, 2004 - 23:16
I was asked to provide a tutorial on how to make working tunnels that have turns in them, so here it is.

For those of you who have tried this already, you'll know that making curvy tunnels is no easy matter. It's quite painstaking and requires competence in editing maps from a text editor. Also, I HIGHLY suggest using FinalSun 0.98 as this version actually shows where all the tunnels that you've placed are.
With that said, here's how to do it:

First thing is first, start a map. Make a cliff and a tunnel like you ordinarily would.
Go to Tunnels in the object browser and select Create Tunnel. Each tunnel entrance requires its own path for this task, so you'll end up making double the amount of paths you normally would for a straight tunnel. For this tutorial, I used three paths for each entrance, giving a total of six.
Each path must meet with its corresponding path at the opposite tunnel entrance, meaning the paths will meet each other, most likely at a 90 degree angle. This will technically leave you with three paths, even though these paths have not merged together.
This step is only to get a reference for what's coming next.

Move your mouse over each red box at the end of each path and look at its coordinates. Remember these coordinates as they will be necessary with the text editor.
Save your map and open it with the text editor of your choice. Leave the map open in FinalSun as you will refer back to it occasionally.
Before you continue, it is important to understand what you're doing when you change the values inside the text document. I suggest you read this bit of info about tubes before continuing further.
Just scroll down to where it says Tunnel Fix.

Once you're done reading that, find the [Tubes] entry in the text document of your map.
It is vital that you do not alter the values of any tubes except the ones involved in your curved tunnel. Using the coordinates of your paths, find the tube entry corresponding to that specific path.
The first two numbers of each entry are the coordinates of the start of a path. The fourth and fifth numbers are the end of a path.
The end coordinates of your curved paths are currently set at the corner.  You'll want to change this so the end coordinates are at the opposite tunnel entrance.
Keep in mind that the coordinates in the text document are backwards according to FinalSun.
The third number is the direction the tunnel begins to move in. 0 is northeast, 2 is southeast, 4 is southwest, and 6 is northwest.
All the numbers after the fifth one are the actual path itself. Count how many boxes long one of the paths is up to the corner. Count the corner box as well but do NOT count the end box at the entrance. The example I'll use is a path with a length of 8 and running northeast. After the fifth number, put in eight 0s, each separated by a comma. Count how long the path is after the corner, again including the corner box but not the end box. An example would be a path with a length of 9 and heading southeast. After the 0s, put nine 2s, each separated by a comma.  Leave the -1s alone. This is the end of your first curve.
You must do the opposite for another tube so that the path is a two-way instead of a one-way. Otherwise, units will go through one side but will not be able to re-enter the tunnel from the other side. This is the entry from the example I'm using:

Code:
[Tubes]
0=48,56,0,57,48,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,-1,[90 times ,-1],-1
1=57,48,6,48,56,6,6,6,6,6,6,6,6,6,4,4,4,4,4,4,4,4,-1,[90 times ,-1],-1


Notice the coordinates of the two paths. This makes a complete, two-way tunnel path. One path starts at 48,56 (or 56,48 according to FinalSun) and ends at 57,48 (again, backwards in FinalSun). The other starts at the previous path's end point and ends at its start point.

When you have completed all your curved paths, you'll end up having many obsolete tubes. These are all the tubes that begin at the corner box in your paths. It is recommended that you find these tubes and delete them, as they may cause problems.
When you are done with your tubes, delete all of the curved tunnel paths in FinalSun and save your map. Then save your text document. When you re-open your map in FinalSun, you'll see the tunnel paths as they should be, single lines with no box in the corners.

Since I'm not very good at explaining things and you're probably confused by now, I have provided the complete tunnel of the example I was using. If you are confused, try studying these entries as well as the photo attached at the bottom of this tutorial and see if you can understand it (The photograph has been deleted and I don't have another copy to upload. I'm sorry for the inconvenience.)

This is the entry I began with. There were twelve tubes, two for each path. Look at this one and compare it to the next entry.

Code:
[Tubes]
0=48,56,0,48,48,0,0,0,0,0,0,0,-1,-1,[90 Times -1],-1
1=48,48,4,48,56,4,4,4,4,4,4,4,4,-1,[90 Times -1],-1
2=48,48,2,57,48,2,2,2,2,2,2,2,2,-1,[90 Times -1],-1
3=57,48,6,48,48,6,6,6,6,6,6,6,6,6,[90 Times -1],-1
4=49,56,0,49,49,0,0,0,0,0,0,-1,-1,-1,[90 Times -1],-1
5=49,49,4,49,56,4,4,4,4,4,4,4,-1,-1,[90 Times -1],-1
6=49,49,2,57,49,2,2,2,2,2,2,2,-1,-1,[90 Times -1],-1
7=57,49,6,49,49,6,6,6,6,6,6,6,6,-1,[90 Times -1],-1
8=57,50,6,50,50,6,6,6,6,6,6,-1,-1,-1,[90 Times -1],-1
9=50,50,2,57,50,2,2,2,2,2,2,2,-1,-1,[90 Times -1],-1
10=50,56,0,50,50,0,0,0,0,0,-1,-1,-1,-1,[90 Times -1],-1
11=50,50,4,50,56,4,4,4,4,4,4,-1,-1,-1,[90 Times -1],-1

This is the finished entry.
Notice how most of the tubes have been deleted.  Those were the tubes that started at a tunnel path's corner. Also notice that there are now two number sequences, equaling two directions that the line travels in. The above entry only has one sequence for each tube.

Code:
[Tubes]
0=48,56,0,57,48,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,[82 times -1],-1
1=57,48,6,48,56,6,6,6,6,6,6,6,6,6,4,4,4,4,4,4,4,4,[82 times -1],-1
2=49,56,0,57,49,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,-1,-1,[82 times -1],-1
3=57,49,6,49,56,6,6,6,6,6,6,6,6,4,4,4,4,4,4,4,-1,-1,[82 times -1],-1
4=50,56,0,57,50,0,0,0,0,0,0,2,2,2,2,2,2,2,-1,-1,-1,-1,[82 times -1],-1
5=57,50,6,50,56,6,6,6,6,6,6,6,4,4,4,4,4,4,-1,-1,-1,-1,[82 times -1],-1

If you have questions about a specific part, feel free to ask me.

I'd like to thank dEw_MaN for his tutorial on tubes. Without it, I wouldn't have learned all of this tunnel jargon as quickly as I did.