Fueldump Garage Doors

 

Hello,

today: fueldump_garage_doors.

A prefab for this tutorial is available here:prefab_fueldump_garage_doors

TODO What you should know already, tutorials you should know, im lazy sorry

Estimated skilllevel: 3 / 5

Overview
——————–

The fuel dump garage doors consist of 3 major parts: the doors, the lever, and a rotating fly wheel for cool graphics.

The doors
——————–

These are put together quite neatly. There are 9 script_movers, all following each other like a train. They simulate the garage door.

The key command here is found in the spawn event of each of these entities:

attatchtotrain This specifies what the entities follow each other (they attach themself to the origin of some other entity with a specific lenght).

Then this also consists of splines (info_train_spline_main) and one control spline (info_train_spline_control) which smoots out movement.

The flywheel
——————–

This acts like it would be connected to some kind of motor, which pulls the doors up and down. Just looks cool. This is also a scriptmover and it is moved with this key command:

faceangles <duration|gototime> [accel|deccel]

The lever
——————–

This triggers all movement. It is basically the same as in the previous tutorial you should have read (battery_front_doors).

The mapscript
——————–

game_manager
{
spawn
{
wait 200
wm_allied_respawntime 1
wm_axis_respawntime 1
wm_set_round_timelimit 20
wm_setwinner 0// Garage Doors
globalaccum 5 set 0     // Flexible Door 2 status. (0=stationary, 1=moving)
}
}// ===========================================================================================
// Garage Doors for Tank
// ===========================================================================================tbdoor2_trigger1
{
spawn
{
accum 3 set 0           // Initial state of lever. (0=down, 1=up)
}
trigger main
{
trigger tbdoor2_trigger1 up
trigger tbdoor2_trigger1 down
}

trigger up
{
accum 3 abort_if_not_equal 0        // Lever up already ?
globalaccum 5 abort_if_not_equal 0  // Flexible Door moving ?
resetscript

globalaccum 5 set 1         // Door is opening …
accum 3 set 1               // Lever is in up position
trigger tbflywheel2 start           // Set flywheel moving
trigger tbflywheel2 clockwise       // Start turning
trigger tbflywheel2_sound wheel2_run
trigger tbdoor2_lever1 up       // Move lever
trigger tbdoor2-9 open          // Start moving all the door sections
}

trigger down
{
accum 3 abort_if_not_equal 1        // Lever down already ?
globalaccum 5 abort_if_not_equal 0  // Flexible Door moving ?
resetscript

globalaccum 5 set 1         // Door is opening …
accum 3 set 0               // Lever is in up position
trigger tbflywheel2 start       // Set flywheel moving
trigger tbflywheel2 anticlockwise   // Start turning
trigger tbflywheel2_sound wheel2_run
trigger tbdoor2_lever1 down     // Move lever
trigger tbdoor2-9 close         // Start moving all the door sections
}
}

tbdoor2_lever1
{
trigger down
{
gotomarker tbdoor2_lever1_downpos 16
playsound sound/movers/switches/butn2.wav
}
trigger up
{
gotomarker tbdoor2_lever1_uppos 16
playsound sound/movers/switches/switch.wav
}
}

tbflywheel2_sound
{
trigger wheel2_run
{
trigger tbflywheel2 sound_start
wait 400
trigger tbflywheel2 sound_run
}
}

tbflywheel2
{
spawn
{
accum 3 set 0           // Flywheel moving (0=No, 1=Yes)
}

trigger sound_start
{
stopsound
playsound sound/movers/motors/motor_start_01.wav volume 127
}

trigger sound_run
{
playsound sound/movers/motors/motor_loop_01.wav looping volume 512
}

trigger sound_stop
{
stopsound
playsound sound/movers/motors/motor_end_01.wav volume 127
}

trigger clockwise
{
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 90 250 wait
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 180 250 wait
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 270 250 wait
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 0 250 wait

trigger tbflywheel2 clockwise
}

trigger anticlockwise
{
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 270 250 wait
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 180 250 wait
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 90 250 wait
accum 3 abort_if_not_equal 1    // Flywheel moving ?
faceangles 0 0 0 250 wait

trigger tbflywheel2 anticlockwise
}

trigger start
{
accum 3 set 1           // Start wheel moving
}
trigger stop
{
accum 3 set 0           // Stop wheel moving

trigger self sound_stop
}
}

tbdoor2-9
{
spawn
{
wait 200
trigger tbdoor2_trigger1 up
}

trigger open
{
stopsound           // Kill all currently playing sounds belonging to this entity only
playsound sound/movers/misc/garage_door_start_01.wav volume 96
wait 50
playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
followpath 1 tbdrspln2-3 50 wait length 16
followpath 1 tbdrspln2-4 50 wait length 16
trigger tbflywheel2 stop    // Turn off flywheel
globalaccum 5 set 0     // Flexible door 1 has stopped moving
stopsound           // Kill all currently playing sounds belonging to this entity only
playsound sound/movers/misc/garage_door_end_01.wav volume 96
}

trigger close
{
stopsound           // Kill all currently playing sounds belonging to this entity only
playsound sound/movers/misc/garage_door_start_01.wav volume 96
wait 50
playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
followpath 0 tbdrspln2-4 50 wait length 16
followpath 0 tbdrspln2-3 50 wait length 16
trigger tbflywheel2 stop    // Turn off flywheel
globalaccum 5 set 0     // Flexible door 1 has stopped moving
stopsound           // Kill all currently playing sounds belonging to this entity only
playsound sound/movers/misc/garage_door_end_01.wav volume 96
}
}

tbdoor2-8
{
spawn
{
wait 100
attatchtotrain tbdoor2-9 16
}
}

tbdoor2-7
{
spawn
{
wait 100
attatchtotrain tbdoor2-8 16
}
}

tbdoor2-6
{
spawn
{
wait 100
attatchtotrain tbdoor2-7 16
}
}

tbdoor2-5
{
spawn
{
wait 100
attatchtotrain tbdoor2-6 16
}
}

tbdoor2-4
{
spawn
{
wait 100
attatchtotrain tbdoor2-5 16
}
}

tbdoor2-3
{
spawn
{
wait 100
attatchtotrain tbdoor2-4 16
}
}

tbdoor2-2
{
spawn
{
wait 100
attatchtotrain tbdoor2-3 16
}
}

tbdoor2-1
{
spawn
{
wait 100
attatchtotrain tbdoor2-2 16
}
}

Final notes
——————–

Watch out for rotations.

The garage doors: do not rotate these. Only rotate the splines. The garage doors will automatically follow the rotation and position of these splines.

If you rotate the flywheel then you must adjust the faceangles command.

Lever can be rotated pretty much randomly and it always works.

That’s it, have fun, and post questions if you have any.