MODSonline Subscriptions
View in iTunes
Please help us to raise in the ranks of podcasting and subscribe to our itunes feed using the link above.
The next MODSonair show will air LIVE on:
03/21/2010 12:03 EDT

Time remaining:
We Dontated to PixelEquity
"A total overhaul mod changes or redefines the gameplay style of the original game, while keeping it in the original game's universe or plot." 3
 
Site News   |   Aggregated News   |   Forums   |   Tutorials   |   Downloads   |   Projects   |   Weblinks
Latest Forum Threads 
CoD4 MP Mapping.. Posts: (19) Views: (459) by Darfyddi
CoD2 MP Mapping.. Posts: (2) Views: (13) by IvanFilip
CoD2 MP Mapping.. Posts: (5) Views: (32) by DemonSeed
News Around the .. Posts: (14) Views: (105) by vT-Ownage
CoD4 MP Mapping.. Posts: (1) Views: (23) by Infern4ll
CoD4 Map + Mod R.. Posts: (25) Views: (195) by voidsource
CoD4 Scripting.. Posts: (2) Views: (42) by DemonSeed
CoD2 SP Mapping.. Posts: (11) Views: (131) by IvanFilip
CoD4 Scripting.. Posts: (4) Views: (78) by Samuel033
CoD4 Scripting.. Posts: (1) Views: (41) by j4cken
Back to Home Page
MODSCON 2010 L4D2 Contest
Register/Login to Add a Tutorial
Tutorials
CoD Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Elevator in Multiplayer
Versions: You must be logged in to view history.
This tutorial will show you how to add an elevator in your multiplayer map.

Elevator in Multiplayer

This tutorial will show you how to add an elevator in your multiplayer map.

The majority of the process of putting an elevator in your map is script work - however i will walk you through the entire process.

First create your elevator out of brushes.

Select them all and right click in the 2d window and make them a script_brushmodel.

Press "N" to bring up the entity editor and give them the key targetname and the value elevatormodel.

Now we will add the button. Right click in the 2d window and click misc then model. Close the browser window and in the entity editor enter the key model and the value xmodel/switch1. (I accidentally created mine as a script_model - but it will work either way). Move the button into position.

Then, using textures common/trigger, draw out the trigger area. (this is where the button will be pressable).

Right click in the 2d view and click trigger and use.

Press "N" to bring up the entity editor and give the trigger_use the key of targetname and the value elevatorswitch.

Texture the visible faces of your elevator.

That is it for the map...now onto the scripting

First, for sounds - create a .csv file using the following information.



name,sequence,file,vol_min,vol_max,pitch_min,pitch_max,dist_min,dist_max,channel
,type,probability,loop,masterslave,loadspec,subtitle

null,,null.wav,,,,,,,,,,,,,

# Personal Sounddefinitions,,,,,,,,,,,,,,,
elevator1,,misc/elevator_med.wav,,,,,,,auto,,,,,,


.csv information courtesy of Sgt. Skywalker

Now we need a .gsc to make the elevator work...you can save it as whatever you want - just make sure you call on it in yourmap.gsc.


main() {
level.elevatorDown = true; // elevator starts at bottom: true/false
level.elevatorMoving = false; // elevator is not currently moving
thread elevator_start();
}

elevator_start() {
elevator = getentarray ("elevatorswitch","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 ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 2;
height = 192;
wait (1);
if (level.elevatorDown) { // moves to top
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1); // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
}
else { // moves to bottom
elevatormodel playsound ("elevator1"); // sound definition for soundaliases.csv
wait (1);  // wait a second to hear the motor start and then start the movement of the lift - feels more realistic
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;
}


.gsc courtesy of LordBlank, enhanced by Snakeshift and modified by Sgt. Skywalker

Also note:

If you put in

movez(320,5,2,2)


it'll move upwards 320 units (z axis) in 5 seconds, however the elevator will accelerate the first two seconds then move one second at top speed and then take the last two seconds to slow down, i suggest you use that to make your elevator more realistic, ofcourse remember that you cant put in

movez(320,3,2,2)

because 2+2 is 4 and since that's more then three you'll get a script compile error

see the tutorial Getting Started in Scripting for more information on this.