Box dropper

From Valve Developer Community
Revision as of 20:00, 4 May 2011 by Nicky397 (talk | contribs)
Jump to: navigation, search

In this tutorial, the procedure of creating a box dropping device will be shown. The box dropping device will create a new box whenever the old one is destroyed.

Creating the device

In this part, the design, the looks of the dropper will be created.

They should look like this.

Step 1

For creating the tube for the standard box dropper, props will be used, which will eventually form a box transportation tube.

Create two prop_dynamics. The first one's world model is models/props/box_dropper.mdl. Set the second one's name to box_dropper_cover and set its world model to models/props/box_dropper_cover.mdl. Now, move the two models so that the second one is at the bottom of the first one. Refer to the screenshot for placement picture.

A long way down.

Step 2

Note.png Note: This step is optional. You may change most of the textures mentioned in this step - they are only used as an example.

First, 8 brushes which form a cube of the size 128x128x16 with an about 88x88x16 size 8-sided cylinder shaped hole in the middle. These sizes are optimized for the size of the tube prop and the cube. This is going to be a part of the ceiling of your room and where the cube enters the room.

Note.png Note: Alternatively you may carve an 8-sided, 88x88x16 cylinder from the 128x128x16 brush, but it is advised not to do this. Also, you might have to shrink the grid to the size of 4 to do this step.

Create 2 128x16x128 and 2 16x128x128 brushes. This is going to be the bottom part of the long corridor down. Use these four brushes to create a corridor. Put a metal/metalwall048c texture on the inner face and tools/nodraw on the outer faces of each brush.

Helping the cube down.

Create 2 128x16x256 and 2 16x128x256 brushes and place them together on top of the previous brushes. Texture them exactly the same way except that the inner faces should have a the texture metal/metalwall048c_gradient. Shift these textures so that the orange ends are on the top and the black ends are on the bottom of the faces.

To seal this hole, create a 128x128x16 brush and place it on top of the corridor. The inner face's texture is lights/light_orange001 and the outer faces' texture is tools/nodraw.
Additionally, you may want to place extra brushes textured with tools/nodraw on top of the bottom piece to ensure that the box will fall down into the tube. Make sure all these brushes are tied to a func_detail entity. Refer to picture 3.

Finally, place the two models which you created in the previous step so that the cube falls through the cylinder right into the tube.

Creating the dropper

In this part of the tutorial, the triggers behind the dropper are created.

Note.png Note: This part of the tutorial assumes that you did not skip Step 2 of the last part.
The weighted sealed room.

Step 1

Create a sealed room separately from any other part of the world. This sealed room should be a cube sealed by six brushes with each face of each brush textured with tools/nodraw. Inside this sealed room, place a prop_physics with the name template_box and the world model models/props/metal_box.mdl. Additionally, you may change the Skin keyvalue of this prop to 1, in which case the cube will look like a weighted companion cube.

In this very same sealed room, create a point_template. Set the name field to template_box_drop and the Template 1 field to template_box. This entity will assist in creating a new box whenever required.

Note.png Note: If you have multiple box droppers in your level, only need to create one prop_physics and one point_template. Just create more env_entity_makers all spawning the same box.

Step 2

Place an env_entity_maker entity in the center of the long way down, about 48 units below the top piece. Set its name to box_maker and the Point_template to spawn field to template_box_drop. Hang in there. It's almost done.

The final piece of the puzzle which controls the whole mess and forms it into a box dropper. Create a logic_relay entity anywhere near the contraption and name it logic_drop_box. Add three outputs.

Output named Target entities Via this input Parameter Delay
OnTrigger box_dropper_cover SetAnimation open 0.00
OnTrigger box_dropper_cover SetAnimation close 2.00
OnTrigger box_maker ForceSpawn 2.00

How it works

Cubes can be detected by creating a filter_activator_name with the Filter name field set to the same string as your box template - in this tutorial, it is template_box. Set it's name to, for example, filter_box. Create a trigger_multiple with the filter field set to filter_box to check whether the box is in a place you don't want it to be (for example acid). Make sure that the 'Physics Objects' flag is checked and add two outputs to this trigger.

Output named Target entities Via this input Parameter Delay
OnStartTouch !activator Kill 0.00
OnStartTouch logic_drop_box Trigger 0.00

You might want to spawn a cube when the map is loaded. To do this, create a logic_auto entity, and with the OnMapSpawn output, send a Trigger input to the logic_drop_box entity. It is advised that if you do this, set the delay to at least 4 seconds to avoid any problems.

Additionally, you can disable the recreation of the box when, for example, you destroy the box permanently. This is done by sending a Disable input to the logic_drop_box entity.

See also

External links

  • Example map Example map using this tutorial. VMF included.