PDA

View Full Version : Dvader's Guide to scripted (i.e. working) elevators!


dvader28
06-01-2002, 01:17 PM
Well, i've spent the afternoon fiddling with the scripts for elevator's. Before, I could never get func_plats or func_doors to work properly as elevators. After looking at the sample maps, i've finally managed to get them going, so i thought i'd post a little tut on here to help any would-be lift makers who are having probs. You don't need to work out any heights or anything for this, which is groovy....here goes! This tutorial will let you make a lift that you call down (or up) and then ride to it's destination...

1. Create your elevator...it can be any brush you like. Draw it in the position you want your lift to start.

2. Create a small cuboid brush and put it in the centre of your elevator brush (yes, slap bang in the middle). Load the "system" textures and select the Origin texture. Once this is done, select the elevator brush and the origin brush, right click and select func>func_static.

3. Deselect all brushes (esc). Now, right click the orthographic view and select ref>ref_tag.

4. Position the ref_tag in the dead centre of your origin brush. Then, clone it and move it vertically straight up or down. This is where the lift will end up when you call it. Make sure the two tags are lined up.

5. Next, create your switches. Make a brush, clone it, and place them in the same position, overlapping each other. Select one of the brushes, right click, and select "func_usable"

6. Next, create your trigger. This is what makes everything work when you hit the use key. Draw your trigger, texture it, and make it a trigger_multiple.

7. Create a scriptrunner. Right click, and select target>target_scriptrunner.

8. Create a target_relay. Right click, and select target>target_relay.

Ok, your set to go. The next step depends on what script you use. For this tutorial, i'm using "artus_mine/el_in_hall.ibi". If you've got the latest tools, all the SP scripts are decompiled in a zip file ready for browsing. There are several elevator scripts, and they all work on the basic principles i'll outline below....

9. Select your elevator (the func_static entity), and press N. Add the following key

script_targetname
el_in_hall

10. Select your trigger. Add the following key

target
elevscript1

Tick the playeronly and use_button checkboxes.

11. Select your target_scriptrunner. Add the following keys

targetname
elevscript1

usescript
artus_mine/el_in_hall

12. Select your relay. Add the following keys:

targetname
elevscript1

target
el4butt

13. Select your func_usable brush. Add the following key

targetname
el4butt

14. The final step is naming your tags. This is a good point to look at the script itself:

//Generated by BehavEd

rem ( "The elevator inside the big mashine" );

affect ( "kyle", /*@AFFECT_TYPE*/ INSERT )
{
sound ( /*@CHANNELS*/ CHAN_AUTO, "sound/movers/switches/switch1.mp3" );
}


affect ( "el_in_hall", /*@AFFECT_TYPE*/ FLUSH )
{
use ( "el4butt" );
move ( $tag("el_in_hall_up",ORIGIN)$, $<0 0 0>$, 2000.000 );
wait ( 4000.000 );
move ( $tag("el_in_hall_down",ORIGIN)$, $<0 0 0>$, 2000.000 );
use ( "el4butt" );
}

______________________________

Ok...

affect ( "el_in_hall", /*@AFFECT_TYPE*/ FLUSH )

This line lets the script know what to move

move ( $tag("el_in_hall_up",ORIGIN)$, $<0 0 0>$, 2000.000 );


This line tells the elevator where to go first. Try not to think of it as up and down, but 1st and 2nd. "el_in_hall_up" is the targetname of one of our tags.

wait ( 4000.000 );
move ( $tag("el_in_hall_down",ORIGIN)$, $<0 0 0>$, 2000.000 );


These lines tell the elevator to wait, then go to the other tag.

So, what the script is doing is waiting for the button to be pressed, moving the elevator to a tag, waiting, and moving it to the other tag.

So we need to name our tags accordingly...if i want my el to move down, i still name my ref_tag "el_in_hall_up", because that's where the script wants to go first.

So, name the destination tag "el_in_hall_up" and the return flag "el_in_hall_down" (use targetname)

Ok, compile your map, and all should be well.

This is the basic template for all elevator (and movement) scripts. Fiddle around and see what you can come up with!

:vadar:

remark 666
06-01-2002, 02:01 PM
If I was a mapper then this would come in handy....but I ain't ;)