Results 1 to 3 of 3

Thread: Making a moving door (non-rotating)

  1. #1
    Private pollo's Avatar
    Join Date
    Jul 2012
    Location
    Spain
    Posts
    116
    Thanks
    93
    Thanked 69 Times in 35 Posts

    Making a moving door (non-rotating)

    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

    Code:
    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:

    Code:
    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.

    Code:
    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

  2. The Following 2 Users Say Thank You to pollo For This Useful Post:

    EvoloZz (2nd December 2012),kung foo man (2nd December 2012)

  3. #2
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    Nice tutorial, explains everything

  4. #3
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Thinking same


    Great first post
    timescale 0.01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •