FLYING CORPSE TUTORIAL
By: lophyte <lophyteNO@SPAMgmail.com>
This effect was used throughout Doom 3 to startle the player. You may recall it from the beginning of Delta Labs Sector 1, right near the beginning where you walk up to a locked door, and a body comes crashing through the window next to you.
This tutorial assumes you know the basics of editing with DoomEdit. The
demo map is available for download if you'd like something to take a look at.
First, create a 512x512x256 room. Clone one of the walls and drag it to the middle of the room, thus creating 2 rooms approximately 512x256x256 in size. Add a light into the room where the player spawns. Now, we're gonna want to cut a hole in the middle wall for our window, so resize the middle wall to be 192 units in length. Clone it, then put the new one on the other side, as detailed in the image.
Clone the wall again, but this time resize it to 128 units long. Place this wall in between the two walls we've got now. Press Ctrl+Tab to switch to Front view, and resize the wall until its about jumping height high. Clone the wall again, this time raise the top of it to the ceiling, and the bottom of it to about half-way down.
Switch the 2D view back to the top. Right click on the grid, and go to func, then select func_fracture. Resize it so that it fits perfectly into the cut in our wall. Texture it using a texture from base/textures/glass, and in the Entity Properties window, give it key "health", with a val of "0". Also, set a key of "model" with a val that matches the name of the entity (default "func_fracture_1")
Deselect everything, right click on the grid, and go to env, then select one of the ragdolls - I used env_ragdoll_marine1. Place the ragdoll in the room in which the player is not going to be, and make sure he's on the floor. In the entity properties, give the ragdoll a descriptive name such as "corpse1". Next, we need to create a mover that will move our ragdoll. Right click on the grid, and go to func, then select func_mover. Give the mover a descriptive name as well, like "corpse_mover1". Now go select the ragdoll again, and in the entity properties, add key "bind" with a val matching the name of the mover. Also, add key "bindConstraint name1" wiht a val of "ballAndSocket waist Hips". This means that we'll be binding the ragdolls hips to the mover.
If you'd like to bind another part of the ragdoll's body, go into the map and play around with the g _dragentity cvar. Select different parts of the ragdoll's body and figure out the name for them. Also, I've found that if you leave the ragdoll in its default position, it will hang in mid-air by its waist and spin slowly. The way to fix this is to go into the game, and use the g_dragentity cvar to re-shape the ragdoll. There's more information about ragdoll shaping
here.
Next, we need to make an entity that the mover will move to. Deselect everything, then right click on the grid, go to func, and select func_static.
Texture this entity with base/textures/common/nodraw. In the entity properties, give it a descriptive name, such as "corpse_mover1_movepoint". Place this movepoint around the upper half of the window, on the side with the player start and the light, somewhat like in the image below.
Now it's time for scripting. Open up notepad and write the following code:
Code:
void corpse_move ()
{
$corpse_mover1.time(.4);
$corpse_mover1.moveTo ( $corpse_mover1_movepoint );
sys.waitFor ($corpse_mover1);
$corpse1.unbind();
}
Code explanation: corpse_move is the function we're going to call from a trigger in the next part. The
time command sets how long it will take for the mover to move to its destination point. The
moveTo command causes the mover to move to the location at which the movepoint is. The
sys.waitFor allows the mover to complete its move before executing the next line of code. And finally, we unbind our corpse from the mover so that it falls to the ground, and doesn't hang in the air.
Save the script in the same directory as your map, with the same filename (ie if your map is flyingcorpse.map, the script should be flyingcorpse.script)
Now all that's left to do is create a trigger that will cause the body to fly through the glass. Deselect everything, right click on the grid and go to trigger, then trigger_once. Place this entity next to the window, so that if the player walks by the window, the body will fly through.
Go into the entity properties for the trigger, and set key "call" to the name of the function in our script - "corpse_move". To wrap up, move the mover so that it's directly on top of the ragdoll. This is so that they both start from the same point.
Now fire up Doom and try out your map - but don't jump when the body crashes through the glass! That's all for now.. feedback is appreciated.
- lophyte