VERC: Creating A Usable And Destructible Mortar Last edited 15 years ago2003-06-15 14:48:00 UTC by Penguinboy Penguinboy

This article was recovered from an archive and needs to be reviewed

  1. The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
  2. Some information may be out of date as it was written before Half-Life was available on Steam
  3. After the article is re-formatted and updated for Steam HL, remove this notice
  4. Please do not remove the archive notice from the bottom of the article.
  5. Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
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.

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 (Link: index.php?go=hammer_beta) 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.

| (Link: mortar_picture_1.jpg)

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...

| (Link: mortar_picture_2.jpg)

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.
This article was originally published on the Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.