Call of Duty 4: Elevator Brushes: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
mNo edit summary
 
(Shortened the code)
 
Line 25: Line 25:
main()
main()
{
{
  level.elevatorDown = true;
level.elevatorUp = 1;
  level.elevatorMoving = false;
level.elevatorMoving = false;
  thread elevator_start();
thread elevator_start();
}
}


elevator_start()
elevator_start()
{
{
  elevator = getentarray ("switch","targetname");
elevator = getentarray ("switch","targetname");
  if ( isdefined(elevator) )
if ( isdefined(elevator) )
  for (i = 0; i < elevator.size; i++)
for (i = 0; i < elevator.size; i++)
  elevator[i] thread elevator_think();
elevator[i] thread elevator_think();
}
}


elevator_think()
elevator_think()
{
{
  while (1)
for(;;)
  {
{
  self waittill ("trigger");
self waittill ("trigger");
  if (!level.elevatorMoving)
if (!level.elevatorMoving)
  thread elevator_move();
thread elevator_move();
  }
}
}
}


elevator_move()
elevator_move()
{
{
  elevatormodel = getent ("elevator", "targetname");
elevatormodel = getent ("elevator", "targetname");
  level.elevatorMoving = true;
level.elevatorMoving = true;
  speed = 10;
speed = 10;
  height =581;
height = 581;
  if (level.elevatorDown)
 
  {
elevatormodel playsound ("elevator");
  elevatormodel playsound ("elevator");
elevatormodel movez (height - level.elevatorUp * 2 * height, speed); // When elevator is up, it will go down.
  elevatormodel movez (height, speed);
elevatormodel waittill ("movedone");
  elevatormodel waittill ("movedone");
level.elevatorUp ^= 1; // A smart trick, turns 1 to 0 and vice-versa.
  level.elevatorDown = false;
level.elevatorMoving = false;
  }
  else
  {
  elevatormodel playsound ("elevator");
  elevatormodel movez (height - (height * 2), speed);
  elevatormodel waittill ("movedone");
  level.elevatorDown = true;
  }
  level.elevatorMoving = false;
}</pre>
}</pre>



Latest revision as of 23:16, 22 February 2012

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

Simple Elevator

by nuthowz

Create the elevator as a script_brushmodel then assign the key/values
key   = targetname
value = elevator

Then 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 

Then 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.elevatorUp = 1;
	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()
{
	for(;;)
	{
		self waittill ("trigger");
		if (!level.elevatorMoving)
			thread elevator_move();
	}
}

elevator_move()
{
	elevatormodel = getent ("elevator", "targetname");
	level.elevatorMoving = true;
	speed = 10;
	height = 581;

	elevatormodel playsound ("elevator");
	elevatormodel movez (height - level.elevatorUp * 2 * height, speed); // When elevator is up, it will go down.
	elevatormodel waittill ("movedone");
	level.elevatorUp ^= 1; // A smart trick, turns 1 to 0 and vice-versa.
	level.elevatorMoving = false;
}


Complex Elevator

Invalid Article.