lophyte@Posted: Wed Aug 11, 2004 10:49 am :
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.

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.

Image

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.

Image


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.

Image


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



BNA!@Posted: Wed Aug 11, 2004 1:11 pm :
Accompany your post with a screenie please :)



bljohnson@Posted: Wed Aug 11, 2004 4:47 pm :
BNA! wrote:
Accompany your post with a screenie please :)


I just ran through the tutorial. Very nice! An excellent effect I'll tell ya. One thing though - I would suggest placing your movepoint in the lower half of the window instead of the upper half. That way the corpse flies right past you at eye level. Here's my screenshot as I tested the tutorial results:

Image



rich_is_bored@Posted: Wed Aug 11, 2004 5:12 pm :
That's sweet. Great job. :)



bullet@Posted: Wed Aug 11, 2004 5:18 pm :
Awesome! I gotta try this on a larger scale..



goliathvt@Posted: Wed Aug 11, 2004 7:18 pm :
Yeah, I'm itching to get home and try this....

Perhaps a re-enactment of a few scenes from Hitchcock's "Birds"... except it'll be aptly named, "Dead People"...

G



rich_is_bored@Posted: Wed Aug 11, 2004 7:26 pm :
Yeah, now just set this up so the guy flys out the outboard facing window on a highrise and it will be great. :)



goliathvt@Posted: Wed Aug 11, 2004 7:40 pm :
You know, that'd be a great camera/cinematics tutorial... tossing a corpse out a window of a tower/high-rise and have the camera follow them down the fall, with various camera movements on the way...

GAH... so many tutorials... so little time.

G



rich_is_bored@Posted: Wed Aug 11, 2004 7:55 pm :
Yeah that would be cool. You'd need one tall ass map though.



Crawdad_Cletis@Posted: Thu Aug 12, 2004 3:54 am :
My trigger isn't working.

I verified that Doom is looking at my script by putting some garbage that won't compile in it. Doom complains when I try to load the map.

Then I added a
Code:
sys.print("here");
to the script to let me know if it was being run. It never prints "here" to the console.

I made a trigger_once trigger and set a key "call" with a value of "corpse_move". (Yes, I've checked a zillion times that I spelled everything the same in my script and trigger.)

Why isn't the trigger calling my script?



l7oc@Posted: Thu Aug 12, 2004 9:28 am :
I am having the same problem. If I create a trig once trigger type and have a call to a function, but it will not do anything. The *.script and *.map are in the same dir and have the same name. I know that the script works b/c I added a main() to the *.script and that worked. So, I know its not the function. What am I doing wrong? Is there a step missing in the tutorial?

Thanks!!!!



lophyte@Posted: Thu Aug 12, 2004 12:06 pm :
Is the trigger big enough and in a position that the player would walk through it?



l7oc@Posted: Thu Aug 12, 2004 4:21 pm :
Quote:
Is the trigger big enough and in a position that the player would walk through it?


Yeah, it is definently big enought. I tried making server differnt size zones. Then I even tried...... ohh shit it works. I think the problem was the I had not defined the a "model" key for the zone with the same name as the zone.

I'm guessing the engine doesn't know what piece of geometry to look for in the level to tie the call too. But make sure that you have done this and it will work.

If you get stuck, sleep on it. Thats what I just did and it worked. BTW, great tutorial.



k40t1k_g3m1n1@Posted: Thu Aug 12, 2004 10:15 pm :
My trigger wont work, I'm sure i have the *.script correct but it keeps telling me that my trigger "calls unknown function 'corpse_move' ". Can anyone please give me some help.



Crawdad_Cletis@Posted: Thu Aug 12, 2004 10:39 pm :
The model key? That could be my problem too. I'll check it when I get home.



Crawdad_Cletis@Posted: Thu Aug 12, 2004 11:23 pm :
Outstanding! That did it.

Thanks for the help.



3xodus@Posted: Thu Aug 12, 2004 11:25 pm :
How could you make this where a live enemy such as a zombie or a demon jumps through the window on the opposite side and attacks?



k40t1k_g3m1n1@Posted: Thu Aug 12, 2004 11:35 pm :
what should i have the model value set to for the trigger? I'm sorry i'm really new to mapping :oops:



lophyte@Posted: Thu Aug 12, 2004 11:41 pm :
The model key in the trigger should be set to the name of the trigger.
I must've overlooked this when writing the tutorial, apologies :D



Razputin@Posted: Thu Aug 12, 2004 11:42 pm :
The model value should equal the name of the trigger.
I had this problem just last night, and recreating a trigger fixed it.

It seems sometimes the model value is populated and sometimes not.