Tutorial #7: The Func_train entity |
W
A V E L E N G T H |
by HellBringer |
January 20, 1999 |
 |
 |
Yes, its the long-awaited Tutorial #7 - This tutorial will be covering one main thing: "Func_train"s. I'm going to keep the intro short (yet again); but as always, feel free to email me (link at the bottom of the page) with any questions or comments. Don't be shy if something confuses you or raises any questions you want answered right away. Blue statements are the functions I want you to perform. NOTE: I AM going to assume that by now you've mastered how to perform the functions we've done in the previous tutorials.
You came here for the tutorial -so without further ado, why don't you load up Worldcraft now. All tutorials are going to assume you have the latest version, and use the default setup with a 2-button mouse - you should also have all of the proper directories and tools configured before using this tutorial. Refer to the documentation, my WC Setup guide, and my Compile FAQ for details. I will be covering individual WorldCraft commands each time we execute a new command for the first time.
Once Worldcraft has been loaded, go up to the "File"
menu item and click on "open". Choose the map from tutorial number 3 (If you didn't complete Tutorial 3 you can obtain the map file here: Tutorial 3 Map file), and be sure the textures load up properly! In Half-Life, all textures are stored OUTSIDE of the map in .WAD files. These
must be loaded by the map-editor so that you can apply them to various brushes. Without
textures, your shapes and levels would be done in single colors; and who wants that??
Also, I personally like to have all of the menus and status bars turned on (you can select
which ones are displayed from the "View | Screen Elements" menu). You may not
want this if you have a small screen or are running at lower than 800x600 resolution; but
at least note this: ALL Worldcraft menus and toolbars are DOCKABLE.
So I
have mine arranged like this (Note: this screenshot was from v1.6; but I still suggest something similar to this setup) - it gives me a large main
workspace for my maps, and an organized area for referring to textures, VISgroups, and
some entity controls. Feel free to experiment around and find what's comfortable for you -
as it is important that you have an arrangement that allows you to work freely and without
frustration.
Okay, first on the list is to open up some space; so let's get rid of that door. In selection mode, choose our door, and press "delete". Then, set your grid spacing to 8 units. You may also want to zoom in some with the zoom tool on the "eastern" room. Switch to Block creation mode; and in the object box, choose the "Primitive" type "Wedge". I want you to be able to see that the train has a specific orientation; and doesn't rotate or change... with a square block that's harder to see. Go to the texture browser and select the texture "-0BABFL". Now, create our brush in the XY view, starting at Coordinates (-80,96) and going to Coordinates (-48,64). In the XZ or YZ views, adjust the Z coordinates so the brush is 16 units above the "floor" brush, and 8 units tall. Then confirm the brush with the "ENTER" key.
Here's a Screenshot showing this brush all set up.
Now we're ready to make this brush our func_train. In Selection mode, choose our wedge brush and hit the "ToEntity" button. Select "func_train" in the dialog box that pops up. We also need to edit a few of the default attributes of the func_train. Change the "sound" keys to whatever you like. Also, the "first stop target" key should be set to "stop1". Lastly, the "Speed" key should be set to "100" (NOTE: I will be setting different "speed" values throughout the tutorial - this is to provide an additional visual cue that the func_train has passed a new path_corner; you don't have to typically mess with them if you don't want to in a "real" level). Now close the entity properties box.
Here's a Screenshot showing this func_train and its attributes.
Once our train is defined, its time to set the path that it will follow. Not surprisingly, we use "path_corner" entities for this. Switch to entity mode, and adjust the grid spacing to 16 units. Then select the entity type "path_corner" in the object box. Place a path_corner entity at XY coordinates (0, 80); and in the Z axis, center the entity at 16 units above the "floor" brush . Switch to selection mode and choose the path_corner. Then bring up the entity properties window. Set the "name" key to "stop1". The "Next stop target" key should be "stop2". Under the "wait" key, enter a value of "0". Lastly, set the "new train speed" to "100". Close the entity properties window. You now have the first path_corner completely set up. We've defined the train speed, where it should head next, and all the other important attributes.
This Shot shows this path_corner and its attributes.
We've defined the FIRST path_corner; but after that, the train has no destination. We need to fix that with another path_corner. Switch to entity mode. Then select the entity type "path_corner" in the object box. Place a path_corner entity at XY coordinates (-80, -80); and for the Z-axis, align this path_corner with the previous one. Switch to selection mode and choose the path_corner. Then bring up the entity properties window. Set the "name" key to "stop2". The "Next stop target" key should be "stop1" (so that the train "loops" back). Under the "wait" key, enter a value of "1" (I want to demonstrate the func_train's ability to stop at a spot, then continue on automatically). Lastly, set the "new train speed" to "50". Close the entity properties window. You now have the second path_corner completely set up. The train now has a "complete" path, because it will start at "stop1", go to "stop2", go BACK to "stop1", and repeat indefinitely.
Here's a Screenshot showing the path_corners and func_train.
Compile and run your map, and test this new train! NOTE: The func_train doesn't START where you had it in Worldcraft; but rather at the "First stop target". This "move" is done after the level is lighted; but before the game runs - that way the func_train can be in one area for lighting and effects; and then show up somewhere ELSE in the level.
Now, we will expand the set of path_corners, and examine several more things that can be done with func_trains and path_corners. Switch to entity mode. Then select the entity type "path_corner" in the object box. Place a path_corner entity at XY coordinates (-80, -32); and anywhere you want in the Z axis, AS LONG AS THE ENTITY IS COMPLETELY INSIDE THE ROOM. Switch to selection mode and choose the path_corner. Then bring up the entity properties window. Set the "name" key to "stop3". The "Next stop target" key should be "stop1". Under the "wait" key, enter a value of "0". Lastly, set the "new train speed" to "100". Close the entity properties window. This sets us up to have a third path_corner; but our SECOND path corner needs to be edited to direct the train to it, instead of back to the FIRST corner. So, Switch to selection mode, and choose the "stop2" path_corner. Bring up the Entity properties window, and change the "Next Stop Target" key from "stop1" to "stop3". Then close the properties window. This is beginning to get complex; so let me introduce you to a nifty tool. Under the "View" menu, there is an item called "Show connections". This will draw a thin line between objects (like path_corners) that target each other, allowing you to get a rough idea of how its all connected, and how the path shapes out to be. Feel free to turn this off and on throughout the tutorial; BUT remember that it ONLY updates when you deselect things; so the screen can get messy if you're doing some moving around of your objects with this feature turned on.
Here's a Screenshot showing the 3 path_corners and "Show Connections".
Compile and run your map, and test this new path! Note that the train smoothly moves between points in a direct, straight line.
Func_trains don't HAVE to move continuously. They can stop and wait to be triggered at certain points. Let's try an example. Switch to selection mode. Choose the "stop3" path_corner. Open the entity properties window, and click the "Flags" tab. Check the box labeled "Wait for Retrigger". This will make our train wait at this corner - but NOW we need to be able to trigger the train; which means naming it and adding some sort of object we can use to trigger it. I chose to use a button to do the job. First, select the func_train and open up the entity properties window. Then choose "Name", and type in "train1". Next, switch to brush creation mode. Use the texture browser to select texture "+0BUTTON1". Make sure in the object box that you are going to add a primitive type "Block". Now, create the brush in the XY view starting at coordinates (96, 16); and going to (112, -16). In the XZ or YZ view, adjust the Z coordinates so that the brush is centered inside the room and is 32 units tall. This should create a brush up against a wall in our level. Texture alignment is optional; it doesn't matter. In selection mode, select our new brush. Hit the "ToEntity" button, and select the entity type to be a "func_button". We must also edit the following attributes: The "Targeted object" key should be set to "train1", the "Delay before reset" should be "2", and lastly under the "Flags", CHECK the "Don't Move" box.
Here's a Screenshot showing the func_button.
Compile and run your map, and test this new setup. NOTE: You may need to hit the button to set it in motion at the very beginning; after that you should only need to re-trigger it when it hits path_corner "stop3".
Click here to continue...
Half-Life, and the Half-Life logo are
trademarks of Valve Software and Sierra Online, used with permission. All screenshots and
drawings of Half-Life are (c) copyright Valve Software, 1998. All rights reserved. All
original content (text and art) are (c) copyright Wavelength, 1998, and may not be
reproduced without permission. |