The time now is Wed Feb 21, 2018 11:07 am
All times are UTC + 0
Lin Kuei Ominae
Joined: 16 Aug 2006
|Posted: Thu Dec 13, 2012 7:58 am Post subject:
How to create a fully working train transport (**)
Subject description: with working passenger wagons
|Lin Kuei Ominae wrote: |
During a short excursion of mine into mapping to see the capabilities of this kind of modding, i gave myself a try at scripting a working train using the already existing tutorial How to add a moving train to your map.
Knowing of the many problems other people had while doing intensive train research, i wanted to give it a try myself too and create a working train transport. And luckily i found a solution.
How to create a working train transport:
1. Create a working train course with a train consisting of a locomotive (assigned to Group 0), 2 wagons (wagon1 as Group 11 and wagon2 as Group 12) and a cargowagon (Group 13). Then make sure the whole train is connected via the follow IDs. (see the tutorial in the first link)
Make sure the whole train is house Neutral.
:excl: Neutral is necessary, so the train doesn't stops for any unit on the tracks (which it would do if it belongs to Special house) and simply ignores and crushes them. :excl:
2. Give the train course 2 waypoints (in my example waypoints 10 and 11).
These will later be the train-stations at which the train unloads its passengers and allows others to enter it.
:excl: It is important that all train-stations are either diagonal or vertical/horizontal. :excl:
Due to the different distance between diagonal adjacent cells and vertical/horizontal adjacent cell, do the wagons get problems to stop exactly on the cell when the train reaches the next different oriented train-station, thus causing trouble with them allowing to enter/unload passengers.
3. Create one new Local Variable.
A variable with the name "Train Wagons Unload" with Preset value 0.
4. Create 3 new Taskforces.
One "Train task force" with one LOCOMOTIVE as the only unit
One "Wagon task force" with one TRAINCAR as the only unit
One "CargoWagon task force" with one CARGOCAR as the only unit
5. Create 2 new Scripts.
One "Wagon Unload script" that has the following Action:
0: Unload... 3 Lose Transports, Lose Units
One "Train script" that has the following Actions:
0: Move to waypoint... 10
1: Change House... 3 Special
2: Unload... 1 Keep Transports, Lose Units
3: Set Local... "Train Wagons Unload"
4: Guard Area (timer ticks)... 30
5: Change house... 2 Neutral
6: Move to waypoint... 11
7: Change House... 3 Special
8: Unload... 1 Keep Transports, Lose Units
9: Set Local... "Train Wagons Unload"
10: Guard Area (timer ticks)... 30
11: Change house... 2 Neutral
12: Jump to line #... 1
Explanation: At each train-station we change the house from Neutral to Special so units see the train as an allied unit and can enter the transport.
The local variable is used to trigger the unload of the wagons (see point 7).
The train guards the area for some time, to give the player time to let his infantry units enter the train transport.
The train house is changed back to Neutral, so it ignores units on the track and won't stop it's running script.
The house changing is done for the whole train automatically. Unfortunately is this not true for the Unload command, why we have to do the workaround with the local variable that triggers each wagon to be assigned to an individual team with its own unload script.
6. Create 4 new Teamtypes.
One "Train teamtype", House Neutral and with the "Train task force" assigned. Give this one Group 0 and as Script the "Train script".
One "Wagon1 teamtype", House Special and with the "Wagon task force" assigned. Give this one Group 11 and as Script the "Wagon Unload script".
Another "Wagon2 teamtype", House Special and with the "Wagon task force" assigned. Give this one Group 12 and as Script the "Wagon Unload script".
One "CargoWagon teamtype", House Special and with the "CargoWagon task force" assigned. Give this one Group 13 and as Script the "Wagon Unload script".
Make sure that all of these have Loadable checked and no other ability.
7. Create 2 new Triggers.
A "Train" Trigger Type 0 for house Neutral with the Event "AnyEvent" and the one Action 0 "Create Team" with the "Train teamtype" assigned.
This Trigger is run only once in the beginning and starts the train following its script.
A "Train Wagons Unload" Trigger Type 2 (repeating) for house Special with the Event "36 Local is set..." and the variable "Train Wagons Unload". Give this one 4 Actions:
Action 0: "57 Local Clear..." as variable "Train Wagons Unload"
Action 1: "4 Create Team..." with the teamtype "Wagon1 teamtype"
Action 2: "4 Create Team..." with the teamtype "Wagon2 teamtype"
Action 3: "4 Create Team..." with the teamtype "CargoWagon teamtype"
This Trigger creates at each train-station for each wagon a team with the Unload command. Since the train would be disconnected if wagons and locomotive would be in different teams, the Unload command is using the 4th option "Lose Transports, Lose Units" as this way the wagons are also freed from their individual team again.
I've tried to use only one team with 2 wagons and the cargowagon too, but unfortunately is this not reliable and very often the wagons team wasn't created. However if their team was created, only one of the 3 wagons unloaded the passengers.
8. Test the train ingame.
If you've done everything right, the train should now be able to load and unload your troops in a multiplayer map.
If following these steps takes too long for you, you can take a look at my attached example map, that has the working train included.
Train testmap: LKOtrainTestmap.zip
This tutorial is sponsored by tibweb.
Key Words: #Tutorials #Mapping #TiberianSun #Firestorm #FinalSun
SHP Artist of Twisted Insurrection: Nod buildings
X-Mech Calendar (28 Mechs for GDI and Nod)
5 GDI, 5 Nod, 1 Mutant, 1 Scrin unit, 1 GDI building
Image Shaper______TMP Shop______C&C Executable Modifier
||You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Powered by phpBB © phpBB Group
[ Time: 0.1114s ][ Queries: 12 (0.0035s) ][ Debug on ]