Sup guys I'm a path editor for trains in San Andreas.
Ok, simply, The trains which spawn, either in MP scripts (SAMP) or the normal game script, (normal game play) follow an invisible path. This path simulates the train being attached to the track and therefore follows the track when in motion.
It's a fact that the train in San Andreas moves in a circuit. It does not terminate. So in the design of the train paths, they used the same process as in GTA 3. Grid co ordinates. The invisible path is made up of a list of XYZ co ordinates. This structure of code for the train path lies in the file Tracks.dat Tracks2.dat Tracks3.dat and Tracks4.dat. Because the grid co ordinates are in the form of a text document. When we read the document we see lines of text which move down the page in a format. here is an example of a path document i made.
121.32 123.32 12.32 0
121.35 123.33 12.32 0
121.36 123.39 13.32 0
121.39 123.36 14.32 0
121.31 123.35 14.32 0
This is the format of the document.
The GTA loading script at loading stage loads the grid references while the objects load from the game image files. The document loads in the same way we would read it. From Top To Bottom.
Now here's information that should clear up the words "terminating trains" in San Andreas.
A train in San Andreas will complete a Circuit. This happens because when the train has reached the last grid reference in the associated path file, It starts again. So the train will move back to the 1st reference. Thus completing a circuit.
Here's how trains spawn in San Andreas.
When a player has moved inside the radius of a grid reference associated with the train path file, A train may spawn at a grid reference point at the horizon point of the player. The last note is used loosely as technically the train spawns at a set distance from the player and on an existing grid reference. This way trains don't appear in front of your face at random.
The train code then sets the speed of the train and what train combination. In the game there are 15 different combinations of train which incorporate the Freight engine Freight kart Freight box kart Passenger train engine and passenger train kart and also the tram. 3 of these combinations are set for the tram. The tram is much like the train. All the same except the tram has different audio and specifications for making it move without stopping and the interception of a player such as: shooting the driver or trying to get in.
In SA MP someone was saying in an earlier post that a train can spawn in SAMP at the docs or something along the lines as that. Heres relevant info about that.
The train must spawn at a set location on the associated path file. If the train is just sitting on the track not moving, The script simply says that the train must spawn with the center point of the train engine at the grid reference point with the carriages following if any, and in a foward or reverse direction.
Anything you can do with the train is set in the script. Now the train someone said moves in mid air. The train will move along the track from the terminating platform at Cranberry Station and make its way to the end of the track underneath the crane at the nearby docks. From each end there are grid co ordinates which make the train stay on the track. But because at each end, the track stops, the train moves in a straight line from the last grid reference at the docks to the first grid reference at the platform at Cranberry station.
The exact thing happens in the mission "Snail Trail". Same reason. When following the train on the mission Snail Trail, the script orders trains to spawn at a distance ahead of the player and head towards the player so that the Play must dodge the 2 trains. The trains which spawn spawn onto grid references which are sourced from one of the 4 tracks.dat documents. The document which it is sourced from is only needed for the mission snail trail and Wrong Side Of the tracks, And also the opening scene when Officer Tenpany stops to let a freight train past.
In all 3 situations, the trains which get spawned do not need to make a full circuit around San Andreas. So when the designers made the game, they just made a path file that can be used for all 3 situations and start from Cranverry station and finish at a point north of Los Santos but below the bridge joining Los Santos to Las Venturus.
Here's a list of the path file documents for the trains and trams inGTA San Andreas:
Main File. Used for most rail transport. Making a full circuit around San Andreas. Used in a couple of missions
File used for rail transport going from Cranberry Station at the Easter Basin car transport docks. NOT USED IN ANY NORMAL GAME SCRIPTS
Used for trams on tram circuit.
Used for rail transport. File makes part of a circuit beggining at Crandberry Station ending at the north side of Los Santos.
Used in few missions EG Snail Trail. Wrong side of the tracks
The combination of a train and how many karts spawn is decided by the file GTA.exe. There is embeded code in the EXE which in our language is 15 different combinations of train sets and tram sets. In the train.scm file it is decided what one train set will spawn.
In normal game play it is combo 1, 2, 3, 4, 5, 6, 7 for trains to spawn on the train track and combo 9 14 and 15 for trams spawning on the tram track.
Note: In no way can a train choose a diferent path to be on such as at the points where trains in real life could change tracks if they wanted to take a different route. There is only 1 way to do this but it involves many script scenes to do the transition between path files and a large amount of code to align the train and make it run smooth after the process of changing files.
Edited by dj_chrismanno, 08 January 2008 - 12:49 PM.