Call of Duty 5: Elevator Tutorial: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
mNo edit summary
 
Line 23: Line 23:
*Now create your script for the elevator to move.
*Now create your script for the elevator to move.


<pre>
<syntaxhighlight>
main()
main()
{
{
Line 70: Line 70:
   }
   }
   level.elevatorMoving = false;
   level.elevatorMoving = false;
}</pre>
}
</syntaxhighlight>


== Complex Elevator ==
== Complex Elevator ==
Line 89: Line 90:
*Make your elevator...select all the brushes for it and make script - brushmodel.  targetname - elevator
*Make your elevator...select all the brushes for it and make script - brushmodel.  targetname - elevator


<pre>
<syntaxhighlight>
main()
main()
{
{
Line 194: Line 195:
   self waittill ("movedone");
   self waittill ("movedone");
}
}
</pre>
</syntaxhighlight>


[[Category:Call of Duty 5]]
[[Category:Call of Duty 5]]

Latest revision as of 15:14, 16 December 2010

This tutorial is borrowed from COD4 but should work fine in CODWAW.

This tutorial assumes that you already know how to create, compile & create GSCs,CSVs & FastFiles for your maps

Simple Elevator

by Zaphax


  • Create the elevator as a script_brushmodel then assign the key/values
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
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.
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.

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
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");
}