PDA

View Full Version : Making a moving door (non-rotating)



pollo
2nd December 2012, 17:24
Hi all, I am Pollo (I am in ZK clan). Maybe some of you know me. Well, I am posting this because a lot of people will read these tutorials, and I would like to post one ^^ (asked kung foo man and allowed me to post here :) )

Well, let's start. I'll try to explain this as better as I could.

1-Open CoD2Radiant and make a simple brush.
2-Select that brush and make it script_brushmodel (right click in 2d view -> script -> brushmodel)
3-With the entity still selected, press N. You will see the entity menu. Fill these fields


key: targetname
value: door

Where "door", you could put anything.

4-Now make a trigger (right click on 2d view->trigger->choose one). The triggers will exec the brush movement. There are some types of triggers:

-lookat: the brush moves when you look at it

-use_touch: works when you press "F"

-multiple: works when you "touch" it. E.g. Think about automated doors.

-damage: works when you do damage on the trigger, so when you shoot/bash/nade it, it will work. You could edit these preferences by pressing N.

-Other triggers that we won't need... (Note: don't know what's trigger_use, hope other players know this xD)

5-Well, for this door we will use a trigger_use_touch. Once we made it, with the entity still selected, press N and fill these fields:


key: targetname
value: trig_door

Where trig_door you could put whatever you want (I advice you to put "trig_" before to avoid confusion).

6-The mapping part is done. Now let's make the script.


main()
{
thread door();
}

door()
{
door = getent("door","targetname");
trig = getent("trig_door","targetname");

while(1)
{
trig waittill("trigger");
door movex(180,2,1,1);
door waittill("movedone");
wait(5);
door movex(-180,2,1,1);
door waittill("movedone");
wait(5);
}


Explaining part.

We call the function door (the command "thread" will carry out the function called "door" independently from others, not in this case).

The "getent" command will get entities with the assigned targetname. Before the "=" you could put whatever you want.

The While(1) loop will loop the script forever.

"trig waittill("trigger")"; will stop the script until we activate the trigger.

"door movex(180,2,1,1);" the door will move on X axis. These are the function parameters: (units,total time, acceleration time, decceleration time);. Accel time and deccel time must NOT be more than total time, or will result in a script compile error.

"door waittill ("movedone"); will wait till the door has completely moved.

"wait(5);" self explanatory xD. The number in brackets is the time in seconds (could use decimal numbers, but mark them with "." NOT with "," eg: wait(4.5); )

Once you did it, save it into a .gsc file (_door.gsc, for example) and in your main script (mp_yourmapname.gsc) call your door script below "maps\mp\_load::main();"

maps\mp\_door::main();

Now you have a working door!

Hope it helped you, thanks for reading!

Pollo.

P.S. If I have commit mistakes, I'm sorry ;)

EvoloZz
2nd December 2012, 17:58
Nice tutorial, explains everything :D

kung foo man
2nd December 2012, 18:42
Thinking same :D


Great first post :)