2Bit's Mapping Corner on www.PythonOnline.co.uk
ET Mapping Tutorial

Lesson 38


The Tank
Creating the Tank
Plotting the route
Making a tank barrier
Writing the script
Back to main menu
Creating the Tank [Top]
The tank is the biggest single element that you definitely don't want to create from scratch.  The Jagdpanther I first used was taken from the sample Goldrush map supplied by Radiant.  It took some time to even recognize some of the tank components as being tank components, especially those that the author didn't happen to put immediately adjacent to the tank.  It took even longer to understand what the sizeable script was doing and rework it to do what I wanted.

So to save you a lot of time and grief, I have made a self-contained map (we won't be using the tutorial map for this) and script, which includes a fully operational tank and tank barrier.  I will explain all the components so that you can get them working in your own map.  I have rationalized and re-ordered the script components (eg arranged them alphabetically, improved the comments, re-coded some elements for clarity) in an effort to make the scripting side as easy as possible.  Note that even this minimal example tank script is 715 lines long - happily you only need to understand a fraction of it to make it work for you.  :)

Download the tank.zip file and put the tank.map and tank.script in your etmain/maps folder.

Run Radiant and open tank.map.  You will see the tank (smothered in trigger boxes), which is repairable by the allies, and a barrier, which is constructible by the axis.

If you want to immediately see what the tank will do in this sample map, compile it and have a go in ET.  You should build the barrier, mend the tank and drive it to the barrier, destroy the barrier and then escort the tank (in an oval route back to the start) until it stops and fires the gun.  Then come back to Radiant.

Hide the ceiling brush, it will make examining the tank easier.  We'll look at each component - get a 3D view that shows all the tank elements, like this:

Note that it doesn't matter where the tank or any of its components is actually placed in the map - it will be immediately placed on the first point of the route it will follow, when the map starts.

Use shift+alt+click to select the largest trigger box.  We need to use shift+alt+click quite a bit because many of these components have origin brushes inside and we want to include them when we examine and hide each element.

Press N, close the window, press N again.

This is the tank_trigger - when an allied soldier stands within it, the tank is enabled to move (notwithstanding other reasons why it can't, such as damage or a barrier).

Just use a regular mouse click on the 3D pane and press H to hide the trigger while leaving the entities window open, and shift+alt+click the remaining big trigger box.  We'll use the same technique for selecting and hiding each component.

The tank_build trigger is used to allow allied engineers to repair the tank.

As this tank is to be esorted by the Allies, the allied_objective box is ticked.

The shortname will be shown on the command map.

infoAxis, infoAllied and override are redundant, and have never been changed since their use in Goldrush.

The track is shown along with "You are near".

This trigger is actually associated, via the target, to a func_constructible called tank_construct.  To the player it appears that the plier-waving is for the tank, when in fact there is an invisible box in the air (the nodraw non-solid yellow box) which he is repairing (because the tank is not a func_constructible).

The customimages tell ET which icon to show on the command map.

Hide the trigger and shift+alt+click the yellow box.

It's shown as a func_constructible.  The health is a dummy value and doesn't matter what it is.  The tank's health will be specified elsewhere.

Hide it, and shift+alt+click the tank brushes.

This is the principal tank component.  It is a script_mover collection of brushes, because the brushes have to be capable of movement.  The brushes are all clip weapon metal textured, to make the bullet ping sound when shot.

By default, script_movers are non-solid, so that players would pass through them; so the solid box is ticked.

We only want explosives to harm this script_mover, so the explosivedamageonly box is ticked.

When the script_mover is destroyed, we want it to be able to start again with full health, so the resurectable box is ticked.

It should appear on the compass, and it can only be destroyed by the axis, so the allied box is ticked.  Yes, a bit odd.  Think of it as an allied tank.

The tank has a mounted_gun.

The model2 specifies that this tank-shaped collection of brushes should actually be visible as the jagdpanther tracks, which is a model.

The health is 1200 which is the standard tank health value.

The description is what is shown when the player looks at the tank and sees its health bar.

The tagent is used to tell ET where the player using the mounted gun should sit, ie in another entity called the tank_shell.

Hide it and select the tank model:

This is the tank_shell, ie the hull of the tank.  The model sits on the tracks.  Hide it and select the gun barrel.

The tank turret is a separate entity, as it has to be able to turn to the side.  Hide it and select the yellow target_script_trigger on the left.

This is the tank_trigger target_script_trigger.  It tells ET which script element to run when someone stands near the tank.  Hide it and select the mauve func_timer box.

This is a timer, which executes every second (wait = 1).  Each time it executes, it causes the script element specified in the yellow target_script_trigger shown on its right, to run.  Its purpose is to halt the tank if no-one has been near it for a few seconds.  Hide it and select the yellow box.

You can see this is the tank_disabler.  Hide it and select the big red box on the left.

This is the smoke to be shown when the tank is damaged.  It will show black smoke.  Hide it and select the gun flash model.  You will probably need to view the model from the back to select it.

This is shown for a moment at the gun tip when the gun fires.  Hide it and select the big red box next to it.

This is something I've added.  I thought it would be nice to have a puff of smoke at the tip of the gun barrel when it fires, so I added this smoke entity and called it tank_gunsmoke.  Hide it and select the little green box.

This is just a placeholder entity to allow the script to manipulate sounds associated with the tank.  It gives the script a named procedure it can use, called tank_sound.

Hide it and select the last red box.  This is a sound entity.  I used a different noise to the usual - I don't remember why now, it was while I was getting 2 tanks to work in the 2tanks map  - so you could put this back to the standard gunfire sound: sound/vehicles/tank/tank_fire.wav

Unhide everything again.  That completes the examination of all the parts that make up the tank.

Plotting the route [Top]
You control where the tank goes by plotting a route for it.  Select the green box near the front of the tank.

The boxes are splines, an entity called info_train_spline_main.  Each spline points to the next spline along the track, by using the target key.

I have made an oval circuit.  Normally the splines define a winding route, not a circuit, and the last spline does not have a target key, as there is no next spline.

The origin of the tank tracks will follow the origins of the splines.

When you're making the route, the easiest way is to copy the last spline in the track so far, move it into place, and rename its targetname and target.  Repeat as necessary.

These example splines are actually too far apart.  As a rule of thumb, they should be about 3 intersections apart at grid scale 7.  This is because when the tank is damaged, it won't actually halt and smoke until it reaches the next spline.  If you put them too far apart, a wrecked tank will go on too far.

The pink boxes are info_train_spline_controls, and they are used to smooth the turning from one spline to the next.  Without them, the tank will turn quite abruptly.  Don't add them until you've laid out your route with some confidence that it won't change, because re-doing the spline controls is really tiresome and best avoided - so leave them to last.

Select one and press N - you will see the only thing of interest is its name.  I name them with the same name as the spline they are controlling, plus "_c".  Select a spline, like one of those at the pointy end of the circuit, and press N.  You will see it has a control key.  Splines only need a control key when you decide the tank movement from this spline to the next needs smoothing.

In the picture above, the centre spline leads diagonally up to the left to the next spline.  It has a control, the pink box to the left.  So the tank won't go straight along the green arrow, it will bow out towards the pink box and then back to the target spline.

This is best seen when you activate the plot splines feature.  Click this button:   Nothing seems to happen.  Press ESC.

This shows with the white line, the path that the tank will actually follow.  Handy to spot lumpy plots that need smoothing out with control splines.

Making a tank barrier [Top]
I have put a fairly standard tank barrier in this map - it's just a func_constructible, like any other.  This one has been made an axis constructible.  It's the script that will make the tank react to the barrier - without the script barrier detection, the tank would otherwise just drive straight through it.
Writing the script [Top]
Open the tank.script with Wordpad or similar.  I've arranged the scripting elements alphabetically.  I'll explain just those elements of note or those you'll need to amend to make the tank script work in your own map.

Look at the barrier procedure.  There are a number of teamvoiceannounce commands - remember you will need to include their definition in your etmain/sounds/scripts/<yourmapname>.sounds file.  You can copy them straight out of the goldrush.sounds file.

If you made the barrier an explicit objective, you'd need to add a limbo camera and the objective ticking/crossing code.

Scroll down to the tank procedure.

All the accum comments are pretty much what came with the goldrush script, and you can more or less ignore them until you get more proficient with scripting.

Scroll down to see each of the next sections as they get described:

spawn : (for your info) This puts the tank onto the start of the route, and gets it facing the right way (ie the way to go from spln0 to spln1) by running the tank forwards and then backwards along the first spline.

followspline 0 spln0 50000 length 32 wait Move the tank along a spline route
followspline 0 spln0 50000 length 32 wait Go forwards along this spline.  1 means go to the next spline and move backwards to this one.
followspline 0 spln0 50000 length 32 wait Identifies the spline to follow.
followspline 0 spln0 50000 length 32 wait The speed to move at.  Normally speeds are 50-80.  50 is the speed used in Goldrush.  80 is used in Fueldump.  50000 is extremely fast and is used just for positioning at game start.
followspline 0 spln0 50000 length 32 wait Tells ET that the tank origin is not at its actual centre, and to compensate for this during turning.
followspline 0 spln0 50000 length 32 wait Tells ET to wait until the movement is completed before executing the next script line.

Scroll down to trigger dispatch.

You'll need one of these lines per spline.  Make sure the numbers match, eg accum 3 trigger_if_equal 7 tank run_7

Scroll down to trigger run_0.

You'll need one like this for each normal spline, ie a spline that isn't the last spline or a point at which a barrier may impede tank progress.  Change run_0 to run_<the next number>.  Changle spln0 to spln<the next number>.

Look at trigger run_3.

If the tank starts along spline 3, it means it has passed the barrier - so remove the barrier.

Look at trigger run_7.

This would be your last spline.  You can see the tracks stop, the engine stops, the tank shudders to a stop (the animations) and then the turret will turn to fire.  If you don't want the tank turret to turn and fire, delete the line trigger tank_turret turn.

Scroll down to trigger stuck_check_finished.

The 8 is the value of the last spln number + 1.  Change it to your last spln number + 1.

Scroll down to trigger stuck_check_barrier

The abort_if_not_equal 3 is being compared to the spln number in front of the barrier, ie the point at which the tank should stop if the barrier is built.  Change the 3 to wherever your barrier is.  If you have more than one barrier, clone the trigger stuck_check_barrier procedure with a different name, and set the abort_if_not_equal value accordingly.  You'll also need to clone the line trigger self stuck_check_barrier into the name of the new procedure, in the trigger stuck_check routine.

You can ignore the rest of the script, it will work just fine as it is.

Now go play with your tank - experiment with changing the route and get the hang of control splines.

Next lesson - not yet ready.