October 21, 2017, 06:02:54 AM

Author Topic: Making a working elevator?  (Read 53956 times)

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Making a working elevator?
« on: August 01, 2014, 05:20:27 PM »
Can anyone tell me how to make a working elevator? I need three of them, one that goes to three floors and two that go to two floors. I tried this before from a tut i found online but it didn't work. I think maybe the reason it didn't work was because it didn't show anything about scripting the elevator. All it showed me was how to make it in radiant.

Nukem

  • Hooker
  • *
  • Posts: 129
  • Karma: 22
  • TMG http://tmg-nukem.blogspot.co.uk/
    • View Profile
Re: Making a working elevator?
« Reply #1 on: August 02, 2014, 06:43:16 PM »
ok two things to look at

1
Implementation

First place a script_model or create a script_brushmodel to be used for the elevator platform.
Make a trigger_use if you want a switch operated elevator. Make a trigger_multiple if you want a Quake style elevator.
Give this trigger a targetname of elevator_trigger.
If making a switch operated elevator, place a script_model or script_brushmodel in the map where you want the switch. Make the trigger target the newly created switch entity.
If making a Quake style elevator, make the trigger target the elevator platform entity.
Place a script_struct dead center of the platform entity at the bottom point in the platform's route. Place a script_struct dead center of the platform entity at the next point in the platform's route. Continue placing script_structs dead center of the platform entity at the next point in the platform's route.
Give the bottom script_struct a script_noteworthy of platform_start. Make the platform entity target this script_struct. Make this script_struct target the next script_struct in the elevator's path. Continue making the elevator's path by targeting the path script_structs to each other. These can be placed in any direction, not just straight up and down. Just ensure the platform will center on them.

Hydraulic Sounds (Optional)

If you want to play hydraulic or machinery sounds for the elevator, place a script_struct where you want the sound to play. Make the platform target this script_struct. Give this script_struct a script_noteworthy of audio_point. Define a variable in your level script of level.scr_sound["description"] = "actual_sound_alias". The "description" can be any description you want to use, such as "hydraulics". the "actual_sound_alias" must be an actual sound alias defined in your level's csv or a common csv. Give this script_struct a script_sound of whatever you defined as "description". You can place as many script_structs this way as you want.

Alarm Sound (Optional)

If you want an alarm sound to play when the elevator is activated, place a script_model or script_brushmodel where you want the sound to play. Make the platform target this entity. Give this entity a script_noteworthy of elevator_klaxon_speaker. Define a variable in your level script of level.scr_sound["description"] = "actual_sound_alias". The "description" can be any description you want to use, such as "alarm_sound". the "actual_sound_alias" must be an actual sound alias defined in your level's csv or a common csv. Give this entity a script_sound of whatever you defined as "description". You can place as many entities this way as you want.

Gates (Optional)

If you want a gate or gates to animate when the elevator is activated, place a script_model or script_brushmodel to use as the gate. Do NOT rotate the gate or place it where you want the gate to be. This will be handled by the _elevator.gsc utility script. Make the platform target this gate. Give this gate a script_noteworthy of elevator_gate. Give this gate a script_int equal to the amount of degrees you want it to rotate, ie: 90 Place a script_struct where you want the gate to be centered and have the gate target this script_struct. Rotate this script_struct in the direction you want the gate to move. You can place as many gates per elevator this way as you want.
Define a variable in your level script of level.scr_sound["description"] = "actual_sound_alias". The "description" can be any description you want to use, such as "gate_rotate". the "actual_sound_alias" must be an actual sound alias defined in your level's csv or a common csv. Give this gate a script_sound of whatever you defined as "description".

Speed Point-To-Point (Optional)

If you dont specify a value for level.elevator_speed in your level script, it will default to 5. This is how many seconds the platform will take to move from point to point along its path.
If you dont specify a value for level.elevator_gate_speed in your level script, it will default to 1. This is how many seconds the platform gates, if you included any in your level, will take to rotate when they are raised or lowered.

Speed Movement (Optional)

If you donít specify a speed for your elevator platform in Radiant, it will default to 100. To set the speed, make a K/V pair of speed / 100 (or whatever speed you want). Each individual platform can have a different speed set to it if you want. This is the speed of the platform in MPH. Do NOT set a speed K/V pair only on the script_struct that the platform targets; set it on THAT script_struct's target as well; it MUST be set on at least this script_struct. You can then set any positive whole number value for speed on the rest of the script_structs that make up the elevator's path if you want to.

If you donít specify an amount of degrees for your elevator platform gates to rotate in Radiant, it will default to 90. To set the desired amount of angles, make a K/V pair of script_int / 90 (or whatever angle you want). Each individual platform can have a different angle set to it if you want.

If you donít specify a speed for your elevator platform gates in Radiant, it will default to 1. This is how many seconds the platform gates, if you included any in your level, will take to rotate when they are raised or lowered. To set the speed, make a K/V pair of script_delay / 1 (or whatever speed you want). This speed should be defined in seconds, not actual speed in MPH like the platforms.

Notes of Interest

Platforms and platform switches must be either a script_model or a script_brushmodel. You can use a prefab for the platform that actually moves, but you must stamp it into your level. You cannot have a trigger or switch target a prefab.
You can setup the elevator and all its parts, then save this as a prefab, and copy and paste this prefab into the level where ever you want to. Be certain that your platform triggers inside the prefab retain their targetname of elevator_trigger though, as it may change when you make the prefab and paste it around the level.

Souce: Treyarch's Wiki
Category: Call of Duty 5


Nukem

  • Hooker
  • *
  • Posts: 129
  • Karma: 22
  • TMG http://tmg-nukem.blogspot.co.uk/
    • View Profile
Re: Making a working elevator?
« Reply #2 on: August 02, 2014, 06:45:46 PM »
2nd

******** Simple elevator *******
Create the elevator as a script_brushmodel then assign the key/values
Code: [Select]
key = targetname
value = elevator
Create the triggers
go to triggers use_touch create 2 of these 1 for the beginning and 1 for the end
Assign key/values
Code: [Select]
key = targetname
value = switch
Connect them by selecting your brushmodel then trigger then hit the ®W® key to weld them. That's it for the map side
Now create your script for the elevator to move.

Code: [Select]
main()
{
  level.elevatorDown = true;
  level.elevatorMoving = false;
  thread elevator_start();
}
 
elevator_start()
{
  elevator = getentarray ("switch","targetname");
  if ( isdefined(elevator) )
  for (i = 0; i < elevator.size; i++)
  elevator[i] thread elevator_think();
}
 
elevator_think()
{
  while (1)
  {
   self waittill ("trigger");
   if (!level.elevatorMoving)
   thread elevator_move();
  }
}
 
elevator_move()
{
  elevatormodel = getent ("elevator", "targetname");
  level.elevatorMoving = true;
  speed = 10;
  height =581;
  if (level.elevatorDown)
  {
   elevatormodel playsound ("elevator");
   elevatormodel movez (height, speed);
   elevatormodel waittill ("movedone");
   level.elevatorDown = false;
  }
  else
  {
   elevatormodel playsound ("elevator");
   elevatormodel movez (height - (height * 2), speed);
   elevatormodel waittill ("movedone");
   level.elevatorDown = true;
  }
  level.elevatorMoving = false;
}


******** Complex Elevator *********

By MB

This elevator has doors on top floor and bottom floor to keep people out of elevator shaft. it also has doors that for the elevator to keep those who are inside...inside!!! this is more like a hotel elevator.

Code: [Select]
top left door = topleftdoor
top right door= toprightdoor
bottom left door= bottomleftdoor
bottom right door = bottomrightdoor
left inner door= leftindoor
right inner door=rightindoor
use-touch trigger (4) = ups

Make your elevator...select all the brushes for it and make script - brushmodel. targetname - elevator

Code: [Select]
main()
{
  level.elevDown=true;
  level.elevMove=false;
  switchTOP=getentarray("ups","targetname");
  for(i=0; i<switchTOP.size; i++)
   switchTOP[i] thread elev_think();
}
 
elev_think()
{
  IdoorLEFT=getent("leftindoor", "targetname");
  IdoorRIGHT=getent("rightindoor", "targetname");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "targetname");
  thread door_open(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
  while(1)
  {
   self waittill ("trigger");
   if(level.elevMove==false)
    {
     level.elevMove=true;
     thread elev_move();
    }
  }
}
 
elev_move()
{
  etime=5;
  zdirec="z";
  zdist1=440;
  zdist2=-440;
  IdoorLEFT=getent("leftindoor", "targetname");
  IdoorRIGHT=getent("rightindoor", "targetname");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "targetname");
  Elevator=getent("elevator", "targetname");
  if(level.elevDown==true)
   {
    door_close(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
    wait(.1);
    Elevator thread move_func(zdist1, etime, zdirec);
    IdoorLEFT thread move_func(zdist1, etime, zdirec);
    IdoorRIGHT thread move_func(zdist1, etime, zdirec);
    Elevator waittill ("movedone");
    door_open(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR);
    level.elevDown=false;
    level.elevMove=false;
   }
  else
  {
   door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR);
   wait(.1);
   Elevator thread move_func(zdist2, etime, zdirec);
   IdoorLEFT thread move_func(zdist2, etime, zdirec);
   IdoorRIGHT thread move_func(zdist2, etime, zdirec);
   Elevator waittill ("movedone");
   door_open(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
   level.elevDown=true;
   level.elevMove=false;
  }
  wait(.1);
}
 
door_close(leftIN, rightIN, leftOUT, rightOUT)
{
  LDclose=41;
  RDclose=-41;
  ydirec="x";
  dtime=1.1;
  leftIN thread move_func(LDclose,dtime, ydirec);
  rightIN thread move_func(RDclose,dtime, ydirec);
  wait(1);
  leftOUT thread move_func(LDclose,dtime, ydirec);
  rightOUT thread move_func(RDclose,dtime, ydirec);
  wait(1);
 }
 
door_open(leftyIN, rightyIN, leftyOUT, rightyOUT)
{
  LDopen=-41;
  RDopen=41;
  ydirec="x";
  dtime=1.1;
  leftyOUT thread move_func(LDopen,dtime, ydirec);
  rightyOUT thread move_func(RDopen,dtime, ydirec);
  wait(1);
  leftyIN thread move_func(LDopen,dtime, ydirec);
  rightyIN thread move_func(RDopen,dtime, ydirec);
 }
 
move_func(dist,time,direc)
{
  if(direc=="z")
  self movez (dist, time, (time/2), (time/2));
  if(direc=="x")
   self movex (dist, time, (time/2), (time/2));
   self waittill ("movedone");
}

credits to modsrepository
« Last Edit: August 02, 2014, 06:48:17 PM by Nukem »

Nukem

  • Hooker
  • *
  • Posts: 129
  • Karma: 22
  • TMG http://tmg-nukem.blogspot.co.uk/
    • View Profile
Re: Making a working elevator?
« Reply #3 on: August 02, 2014, 06:53:48 PM »
you will need to edit this to have the stops at the floors you want but you should be able to work it out if not ask im sure people can help
 :P

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #4 on: August 04, 2014, 03:26:40 PM »
Thanks for the quick reply Nukem. Does the code go in my mapname.gsc? I guess just paste it at the bottom?

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #5 on: August 05, 2014, 05:55:41 PM »
Okay, this is my first time scripting a elevator. I have edited this to have three floors in stead of two. Could someone tell me if the script looks like it would work or any suggestions of changes that should be made. I know I still need to adjust these numbers below to the floors on my map in radiant but am wondering if I'm missing anything.

  zdist1=440;  updated to zdist1=376;
  zdist2=-440; updated to zdist2=248;
  zdist3=-880; updated to zdist3=0;

  LDclose=41;
  RDclose=-41;   

  LDopen=-41;
  RDopen=41;

Code: [Select]
main()
{
  level.elevDown=true;
  level.elevMove=false;
  switchTOP=getentarray("ups","targetname");
  for(i=0; i<switchTOP.size; i++)
   switchTOP[i] thread elev_think();
}
 
elev_think()
{
  IdoorLEFT=getent("leftindoor", "targetname");
  IdoorRIGHT=getent("rightindoor", "targetname");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorMR=getent("middlerightdoor", "targetname");
  OdoorMR=getent("middleleftdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "targetname");
  thread door_open(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
  while(1)
  {
   self waittill ("trigger");
   if(level.elevMove==false)
    {
     level.elevMove=true;
     thread elev_move();
    }
  }
}
 
elev_move()
{
  etime=5;
  zdirec="z";
  zdist1=376;
  zdist2=248;
  zdist3=0;
  IdoorLEFT=getent("leftindoor", "targetname");
  IdoorRIGHT=getent("rightindoor", "targetname");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorML=getent("middleleftdoor", "targetname");
  OdoorMR=getent("middlerightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "targetname");
  Elevator=getent("elevator", "targetname");
  if(level.elevDown==true)
   {
    door_close(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
    wait(.1);
    Elevator thread move_func(zdist2, etime, zdirec);
    IdoorLEFT thread move_func(zdist2, etime, zdirec);
    IdoorRIGHT thread move_func(zdist2, etime, zdirec);
    Elevator waittill ("movedone");
    door_open(IdoorLEFT, IdoorRIGHT, OdoorML, OdoorMR);
    level.elevDown=false;
    level.elevMove=false;
   }
  else
  {
   door_close(IdoorLEFT, IdoorRIGHT, OdoorML, OdoorMR);
   wait(.1);
   Elevator thread move_func(zdist1, etime, zdirec);
   IdoorLEFT thread move_func(zdist1, etime, zdirec);
   IdoorRIGHT thread move_func(zdist1, etime, zdirec);
   Elevator waittill ("movedone");
   door_open(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR);
   level.elevDown=false;
   level.elevMove=false;
  }
  else
  {
   door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR);
   wait(.1);
   Elevator thread move_func(zdist3, etime, zdirec);
   IdoorLEFT thread move_func(zdist3, etime, zdirec);
   IdoorRIGHT thread move_func(zdist3, etime, zdirec);
   Elevator waittill ("movedone");
   door_open(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
   level.elevDown=true;
   level.elevMove=false;
  }
  wait(.1);
}
 
door_close(leftIN, rightIN, leftOUT, rightOUT)
{
  LDclose=41;
  RDclose=-41;
  ydirec="x";
  dtime=1.1;
  leftIN thread move_func(LDclose,dtime, ydirec);
  rightIN thread move_func(RDclose,dtime, ydirec);
  wait(1);
  leftOUT thread move_func(LDclose,dtime, ydirec);
  rightOUT thread move_func(RDclose,dtime, ydirec);
  wait(1);
 }
 
door_open(leftyIN, rightyIN, leftyOUT, rightyOUT)
{
  LDopen=-41;
  RDopen=41;
  ydirec="x";
  dtime=1.1;
  leftyOUT thread move_func(LDopen,dtime, ydirec);
  rightyOUT thread move_func(RDopen,dtime, ydirec);
  wait(1);
  leftyIN thread move_func(LDopen,dtime, ydirec);
  rightyIN thread move_func(RDopen,dtime, ydirec);
 }
 
move_func(dist,time,direc)
{
  if(direc=="z")
  self movez (dist, time, (time/2), (time/2));
  if(direc=="x")
   self movex (dist, time, (time/2), (time/2));
   self waittill ("movedone");
}
« Last Edit: August 05, 2014, 10:21:42 PM by joshs1982 »

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #6 on: August 05, 2014, 08:06:24 PM »

Implementation

First place a script_model or create a script_brushmodel to be used for the elevator platform.
Make a trigger_use if you want a switch operated elevator. Make a trigger_multiple if you want a Quake style elevator.
Give this trigger a targetname of elevator_trigger.
If making a switch operated elevator, place a script_model or script_brushmodel in the map where you want the switch. Make the trigger target the newly created switch entity.
If making a Quake style elevator, make the trigger target the elevator platform entity.
Place a script_struct dead center of the platform entity at the bottom point in the platform's route. Place a script_struct dead center of the platform entity at the next point in the platform's route. Continue placing script_structs dead center of the platform entity at the next point in the platform's route.
Give the bottom script_struct a script_noteworthy of platform_start. Make the platform entity target this script_struct. Make this script_struct target the next script_struct in the elevator's path. Continue making the elevator's path by targeting the path script_structs to each other. These can be placed in any direction, not just straight up and down. Just ensure the platform will center on them.


Here's a pic of my elevator so far. I'm wondering if it's looking right. I haven't made the walls and doors for it yet, just trying to make sure I'm moving in the right direction. Below are the kvp's so far for the elevator,structs and triggers. If my kvp's are wrong or missing a kvp please let me know.

KVP'S

script_brushmodel for the elevator platform
targetname | elevator
target | basement

trigger_use

target | elevator
targetname | elevator_trigger

script_struct basement
target | 1st_floor
targetname | basement
script_noteworthy | platform_start

script_struct 1st floor
target | 2nd_floor
targetname | 1st_floor

script_struct 2nd floor
targetname | 2nd_floor

Now I have a question. Should there be a kvp for the script_struct 2nd floor of " target | basement " to make the elevator return to the basement, or should I not give it a target?

WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #7 on: August 05, 2014, 10:49:32 PM »
Do you just want the elevator to cycle round?

so it will always go up 1 floor unless it's at top floor and it moves to the bottom floor?

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #8 on: August 06, 2014, 02:42:33 PM »
Do you just want the elevator to cycle round?

so it will always go up 1 floor unless it's at top floor and it moves to the bottom floor?
I would like to have three buttons b,1 and 2. So you could choose to go up or down from the 2nd floor or have the option to go from the basement to the top floor. As I was editing the script I realized it would be making it go up 1 floor as you hit the button and back to the basement when leaving the top floor but for it to do that, wouldn't I have to make the top floor script_struct target the basement script_struct? Also I would like to have a call elevator button on each floor so when the elevator is on another floor you can call it to your floor.


WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #9 on: August 06, 2014, 06:45:38 PM »
So how you want the players to choose?

two buttons inside the elevator?

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #10 on: August 06, 2014, 07:03:30 PM »
So how you want the players to choose?

two buttons inside the elevator?
Three if it's possible. One for basement, one for 1st floor and one for 2nd floor. Inside the elevator and one outside the elevator on each floor as well, for call the elevator.

WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #11 on: August 06, 2014, 07:38:57 PM »
You will have to make a menu for selecting which floor.

Since multiple triggers in a small area (aka a elevator) dose not work well since they will overlap each other.

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #12 on: August 06, 2014, 07:55:53 PM »
You will have to make a menu for selecting which floor.

Since multiple triggers in a small area (aka a elevator) dose not work well since they will overlap each other.
Okay a menu would be great. How would I go about making one?
« Last Edit: August 06, 2014, 08:00:55 PM by joshs1982 »

WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #13 on: August 06, 2014, 08:42:56 PM »
Menu files are simple once you understand them.

They are just a collection of items, drawn in the order the occur in the .menu file.

Here is a example of a menu with 2 items, items can be images or solid blocks of color and can be made clickable.
Code: [Select]
menuDef
{
   name "elevator_menu"
    ....

   itemDef {
     ....
   }

   itemDef {
     ....
   }
}

Note: '....' just show where info for that item needs to be.

I suggest you look at exsisting .menu files to see how they are layed out.
You can look at my music box's menu file since I made that without the use of macro's to make it more simple for other people to understand.

joshs1982

  • Infected
  • ***
  • Posts: 157
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #14 on: August 07, 2014, 03:10:55 PM »
I'm trying do use your menu file to make mine but I don't really understand what I'm trying to do.
Do I need to make all the window line you made or just make 3 since I only want 3 options to select from?
If so I would make 3 execKey as well. Correct?