Half-Life 2 Deathmatch Tutorial II: Round Gameplay

Babel Babel Logo

This is the second in my series of HL2DM mapping tutorials. Today, I will demonstrate a way to restart your map in HL2DM, without losing the teams’ scores and resetting physics objects that might be scattered around your map. We needed such a game mechanic in our mod, because it’s based on “rounds”, where each team can score, and then the map should reset. This is very specific to our mod, but I think you can always use parts of the techniques explained here for your own map. Again, there might be easier ways to do this, but this one works for me so far.

  1. Create a game_score entity, and in its properties, set the name to “round_score.” The Points To Add field contains the amount of points you want to give the winning team, so enter whatever you deem appropriate. In the Flags section, enable Team Points.
  2. Create a second game_score entity and call this one “equalizer_score.” This entity will be used as a remedy to regain the points all players lose when they’re killed at the end of the round.
  3. I assume you already have a map complete with spawn points and everything else you need. Now, to make your map reset, you have to create a large brush that covers your entire map. Make it a trigger_hurt, and open its properties. Name it something like “kill_trigger.” Set Start Disabled to Yes and Damage to 1000. In the Outputs section, set the Output to OnHurtPlayer, the Target is equalizer_score and the input should be ApplyScore. This gives all players the -1 score back they got for being killed via the trigger.
  4. For testing purposes, we will include a physics object in our map that should be reset to its original spawning position once the level resets. So create a prop_physics and choose whatever World Model you like. Give it a name, for example “the_prop.”
  5. To make our prop respawnable, we need to add two entities in our map: an env_entity_maker and a point_template. Name the point_template “prop_template,” and under Template 1, choose “the_prop.” Give the env_entity_maker a name like “prop_spawner.” In the Point_template to spawn drop-down list, choose prop_template. Now go to the Flags tab, and make sure Autospawn: Wait for entity destruction is the only activated flag. This takes care of the respawning of the physics object.
  6. Now we need some event that activates our kill_trigger. In our mod, it’s simply a trigger on top of a platform that one player has to touch. So create a brush and make it a trigger_multiple and give it a name like “round_restart.” Next click on the Outputs tab. We have to enter a couple of events now. The first one is to apply the score for this round to the winning team, so select the output OnStartTouch targeting round_score via the input ApplyScore. To reset the physics prop to its original position, simply add the output OnStartTouch, targeting the_prop this time and change the input to Kill. To make all players return to their spawn points, we have to activate our trigger_hurt. So select OnStartTouch again, with the target kill_trigger and the input Enable. Of course we can’t let the kill_trigger enabled all the time, because then everybody would die and respawn indefinitely. Add another OnStartTouch output targeting kill_tigger again, set the input to Disable and enter 0.2 in the After a delay in seconds of-field. The last event we need is to make sure our prop really respawns – so add an OnStartTouch output again with the target prop_spawner this time and the input ForceSpawn. Here’s a screenshot for a quick overview of the outputs we just added.
  7. Outputs of round_restart

This should be it – after compiling the map, the player who touches the trigger should reset the map, returning the players and physics prop to their spawning positions as well as scoring for his or her team. Optional game mechanics you might want to include are a round counter, which ends the game after round_restart has been activated a certain amount of times, and a game_text that displays which team has won the round.

Also check out the previous chapter of this tutorial series:

Part I: Making Sure Players Are Ready

Tags: , ,

Leave a Reply

Enter this code