Team score with brushes

From Valve Developer Community
Jump to: navigation, search

Overview

The purpose of this tutorial is to show how to activate team scoring in a HL2DM (Half-life 2 Deathmatch) using only brushes and logic entities. This will allow the creation of games similar to football or CTF by using physics objects and triggers to award points.

Note.pngNote:This tutorial assumes knowledge of basic Hammer operations, brush creation, texturing, and entity modification.

Preparation

To help test that all entities are functioning properly, a simple, single-room map with the necessary entities is recommended at first. Once the operation of all entities is tested and confirmed as correct, they can then be moved to their appropriate location and the rest of the map built up around them.

Alternatively, if the testing map is left separate, it could be used as a prefab for future maps beyond just the originally intended map. This would increase it's re-usability and decrease the amount of time needed to test a new setup each time.

Don't forget to include team-specific info_player_deathmatchs in your map.

Step 1 - Create your trigger object

First insert the object you want to trigger the team score with; this will most likely be a ball, or some kind of flag for CTF.
One method of achieving this is to create a brush in the shape needed (i.e. spherical for a ball) and clicking the To Entity button on the right hand (by default) tool panel in Hammer. When the brush is turned into an entity, the default setting is usually a func_detail. This can be changed to whatever entity type necessary, and for this tutorial it should be set as a func_physbox.

It is recommended that you name your func_physbox something meaningful so you can easily recognize it later from the entity list.

Note.pngNote:You may use a prop_physics instead of a func_physbox. Make sure the model you choose never breaks and can be picked up by the gravity gun!

Step 2 - Setup your goal areas

To set up the zones that cause the team score to be altered, select the trigger texture (use the phrase "tools" in filter to help find it) and make a brush that covers your goal/capture area completely. For example for a football (soccer) goal, make the brush completely fill the interior of the goal.

Turn this brush into an entity (as in step 1), but select the trigger_multiple entity instead. Also name this brush so it can be recognized easily. Since this will be the rebel goal, name it goal_rebel.

Repeat the above steps to create another trigger_multiple. Since this is the opposing goal, it should be located opposite of the first (unless you have an unusual game type in mind) Name this one goal_combine.

Once two goal triggers are setup, change the filter name option to our ball object called game_ball. This should be done for both triggers. This is necessary to keep other objects (such as players, grenades, or gibs) from triggering the goals.

Note.pngNote:You should now have two trigger_multiple boxes; one for each team, and a single ball object.

Step 3 - Make a score entity

A game_score entity is used to tell the engine, in-game, when to add points - and to which team. First, create a game_score entity, preferably located somewhere where it can be found easily. It will not be rendered or displayed in the game, so players will not see it. A recommended location is in the center of the map, near the ball.

Under the game_score's properties, input the point value given for a successful goal/capture. It can be set as high or as low as the mapper chooses. Since this map will be played in team deathmatch, the awarded score should be high enough to give a team attempting goals a points advantage over a team merely attempting to kill for points. A value of 5 or 10 should be adequate, depending on the difficulty of scoring, since a kill is only 1 point.

Name the game_score entity score_add, so it can be referenced by that name by the triggers.

Finally, tick the Team Score checkbox in the properties of the game_score. This enables the team to be given the score, instead of the player.

Step 4 - Make the team filters

Something is needed to tell the two teams apart when deciding who gets the score. Creating two filter_activator_team entities and naming them filter_rebel and filter_combine will solve this problem. Open the properties of filter_rebels and change the team filter setting to rebels. Do the same for the filter_combine by changing the team setting to combine.

Step 5 - Setup the team triggers

Last thing needed is the actual triggers that we use to give the team score. These are trigger_multiple brushes that cover the entire map (anywhere the players can go at least) and there should be one for each team. Name these triggers trig_rebel and trig_combine. Make sure only clients can activate both of these triggers by un-ticking all other activation options.

Next, open the trig_rebel properties and change the filter option to use filter_rebel. Also go to the start disabled option and select yes. Do the same for trig_combine but use filter_combine. It must also start disabled.

These triggers will be used to activate the game_score. Go to outputs in trig_rebel and add a new output OnTrigger. Make it activate score_add (the game_score entity) and the action should be to AddScore. Do this again for the trig_combine in exactly the same way.

Step 5 - Putting it together

All that is needed to do now is to go back to the goals made earlier (goal_combine and goal_rebel) and add outputs that will activate the triggers to apply the score when a goal is scored.

Start with goal_rebel and add the output OnTrigger and make it activate trig_rebel. The action should be Enable. Make another output OnTrigger and make it activate trig_rebel with the action Disable with a delay of 1 second. In this way, the trigger is enabled for a second and the score is applied, then the trigger is returned to a disabled state.

Do the same for the goal_combine instead using the trig_combine with the same outputs as above. Don't forget the 1 second delay for the disable action.

Now a working, brush-triggered, team scoring system is set in place! This technique can be used in many different ways to make other game styles without altering HL2DM itself.

External links