Half-Life Re-imagined competition results on their way...
Check out Skewing textures in Hammer, our newest tutorial!
Welcome, neophus775, our newest member!


Site Stuff






Feeling Blue

What's your favourite shade of blue?














2 mins


3 mins


10 mins


12 mins


14 mins


20 mins

Dr. Orange

22 mins



A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

Creating A Usable And Destructible Mortar

By Tim Holt

Several of the Day of Defeat 1.0 maps include mortars that can be used by one team to bombard a part of the map with simulated mortars. This article explains the basics of creating a mortar which can be fired, but also destroyed. This article will give you the details you need to know in order to put them in your own map. At the end of the article, there is an example map (with source) you can download to try out.

Entities used

Here is a basic list of entities that will be used to create the fireable and destructible mortar.

  • Two env_models: used to put a model of the mortar (broken and unbroken) in the map.
  • func_button: used as what the player 'uses' to fire the mortar (invisible).
  • func_breakable: used to give a target so players may shoot the mortar to destroy it.
  • func_mortar_field: used to create the random explosions in an area when the player uses the mortar.
  • env_state: used as a master of the func_button to enable or disable it after the mortar been broken.
  • Two env_renders: used to alter the visibility of the mortar models(both broken and unbroken)
  • trigger_relay: used to set the env_state to "off" to disable the func_button.
  • ambient_generic: used to play a "fire" sound when the mortar is used.
  • env_sprite: used to make a "flash" of flame when the mortar is fired.

How to put a mortar in a map

To put the mortar in the map, you need to add an env_model in the map where the mortar is located. The model used in most Day of Defeat maps is models/mapmodels/hk_mortar.mdl. Orient the model so that the mortar points towards the direction of where you'll have the mortar field.

How to make the mortar fire

Here are some basic steps to make the mortar model fireable.

  1. Place a small brush (texture doesn't matter) where the mortar is located. It can be an 8x8x8 cube placed on the ground at the base of the mortar. Make this brush a func_button. Set it to render mode additive and amount 0 so it will be invisible. Set it to trigger "fire_mortar" when used. You may wish to set it so that only one team or another may use it.
  2. Place an env_sprite right at the tip of the mortar tube. If you are using version 3.5 or greater of the Hammer editor, you will be able to directly view the mortar model to get this position just right. Name the sprite "fire_mortar", set it to show sprite "sprites/muzzleflash2.spr", and check the "Play Once" option and uncheck "Start On" for the entity.
  3. Place an ambient_generic at the same location as the env_sprite. Name it "fire_mortar", and set it to play the sound "weapons/mortarload.wav" and check off the options "Medium Radius", "Is NOT looped" and "Start Silent".
  4. Place a brush done with the AAA texture covering the area where you want the mortar to fire. Make it a func_mortar_field entity, and name it "fire_mortar". When triggered, it will randomly "drop" a mortar somewhere in the area of this brush.

Now that you've done this, you will have a working mortar. When a player "uses" the mortar, they really "use" the func_button, which in turn triggers the muzzle flash, the "fire" sound, and the mortar explosion. Figure 1 shows how this will all look in the editor.

Figure 1: Basic mortar layout (click for full sized version)

How to make it destructible

If you want to, you can make the mortar destructible. This lets one team destroy it with gunfire, grenades, and/or a bazooka to make it not available for the enemy.

To make the mortar breakable, you'll need to add a second mortar model in the map. The second model will be the broken state of the mortar. Here are the basic steps to make the mortar breakable.

  1. Create a small brush using the cr_matmetal texture. Making it with this texture will make it act like metal when shot at. Make the brush a func_breakable, give it a strength of about 150, and set it to trigger "break_mortar" when broken. Set it's render mode to "additive" and amount "0" so it will be invisible. Make it totally cover the func_button, so that a player won't shoot the button instead of the breakable.
  2. Add a second env_model at the same location as the first env_mortar. Make this mortar to show the model "models/mapmodels/hk_busted_mortar.mdl", name it "mortar_bad", and set it's render mode to "additive" and amount 0 (so it will start invisible).
  3. Name the first mortar model "mortar_good".
  4. Add a new env_state entity. Name it "mortar_state" and set it to initially be on.
  5. Modify the original func_button to have the master value "mortar_state". The func_button will now only work if the "mortar_good" env_state is set to "on".
  6. Add a trigger_relay and name it "break_mortar". Set it to target the env_state "mortar_state" we just made. Set it to set the env_state to "off" when triggered. If triggered, it will set the env_state to off, and thus disable the func_button and not let the mortar fire anymore.
  7. Add an env_render named "break_mortar", set it to target the env_model named "mortar_good", and set it's render mode to "additive" and amount 0. If triggered, it will make the "good" mortar invisible.
  8. Add another env_render named "break_mortar", set it to target the env_model named "mortar_bad", and set it's render mode to "normal" and amount 0. If triggered, it will make the "bad" mortar visible.

Here is an illustration of how the new entity setup looks...

Figure 2: Breakable mortar layout (click to view full sized)

How it all works

First of all, we have a func_button at the mortar. If a player gets close enough to it and "uses" it, it will...

  1. trigger the sprite muzzle flash to flash once
  2. trigger the "shoot" sound to play once
  3. trigger the mortar field which will randomly set off a mortar explosion somewhere in the area covered by the func_mortar_field entity

The button will only work if the env_state is "on". If the env_state is "off", then the button will not activate when used.

Second, if someone shoots and breaks the breakable, it will...

  1. trigger the trigger_relay that will turn off the env_state and thus disable the func_button (so the mortar can't fire anymore)
  2. trigger the first env_render that will hide the "good" mortar model
  3. trigger the second env_render that will show the "bad" mortar model

If you wish, you might add a "game_text" entity named "break_mortar". Set it to show the text "The mortar has been destroyed!" so that players will know this has happened. The Day of Defeat map DOD_CHARLIE has this.

Example map

Here is an example map file. It includes two spawns (allied and axis), and a mortar that can be fired and destroyed by either team. The zip file contains the map source and precompiled bsp file.