/*
Script file for Lift 3, all done by Raichu
For the game Star Trek Elite Force 2

Do not use or pirate under penalty of getting your ass kicked to hell ( just kidding )

You may use the script in your map or whatever if
(1) its not for commercial purposes, no profit is involved
(2) you give me credit (if you use a big chunk of it)

If you dont agree to (1) and (2) dont use the script.

If there is a problem and this map crashes look at the debug function to find out where and what happened
*/

//Functions

//------------------------------------------
//Set up map functions----------------------
//------------------------------------------
void main();

float DEBUG_FUNC = 0;
/*
DEBUG_FUNC FUNCTION!!!
To activate DEBUG_FUNC, turn the variable to 1

This will print DEBUG_FUNC information in your console.
If you encounter a bug activate this function to get some info about where are the bugs

NOTE: THIS IS ONLY A PARTIAL FUNCTION! ONLY EXPERMENTIAL FUNCTIONS WILL BE DEBUG_FUNCGED!
*/

//------------------------------------------
//Lift functions----------------------------
//------------------------------------------
void lift_main();
void biodoor_trigger();
	float biodoor0_state = 0;
void ringtran_trigger();
	float gate_t1_state = 0;
void ringtran_trigger1();
	float gate_t5_state = 0;
void weapon_trigger();
	float weapon_l0_state = 0;
void gate_wh_trigger();
	float chev1a_1_state = 1;
void gate_wh_trig1();
	float chev1a_3_state = 1;
void ring_trigger1();
	float rings_5_state = 1;
void lift_controldoor_trigger();
	float lift_controldoor_state = 0;
void lift_up_trigger();
void lift_down_trigger();
void lift_move();
	float lift_pos = 0;
	float move_dir = 0;
	float move_speed = 0;
void lift_sound( float s );
void lift_rotatedoorR_trigger();
	float lift_rotatedoorR_state = 0;
void lift_rotatedoorL_trigger();
	float lift_rotatedoorL_state = 0;
void lift_replicator_trigger();
	float lift_replicator_state = 0;

//------------------------------------------
//Lift Turret functions---------------------
//------------------------------------------
void lift_turret_main();
void lift_turret_quantum_trigger();
void lift_turret_right_trigger();
void lift_turret_left_trigger();

//------------------------------------------
//Includes----------------------------------
//------------------------------------------
#include "maps/global_scripts/global_common.scr"
#include "maps/global_scripts/global_debugUtils.scr"
#include "maps/global_scripts/global_math.scr"
#include "maps/global_scripts/global_archetype.scr"
#include "maps/global_scripts/global_acceleratedMovement.scr"

//Actual function and codes
void main()
{
//Bind Setup

//Archetype Setup

//World Setup
$t33.open ( $t33 );
$t37.open ( $t33 );
$t38.open ( $t33 );
$t48.open ( $t33 );
$t46.open ( $t33 );

//Spawners Setup

//Characters Setup

//Call the functions for each deck
thread lift_main();
thread lift_turret_main();
}

//**************
//Lift Functions
//**************
void lift_main()
{
//Bind Setup
$lift_ladder.bind ( $lift );

$Weapon_l0.bind ( $lift );
$Weapon_l1.bind ( $lift );
$Weapon_l2.bind ( $lift );
$Weapon_l3.bind ( $lift );
$weapon_door1.bind ( $lift );

$chev1a_1.bind ( $lift );
$chev1b_1.bind ( $lift );
$chev2a_1.bind ( $lift );
$chev2b_1.bind ( $lift );
$chev3a_1.bind ( $lift );
$chev3b_1.bind ( $lift );
$chev4a_1.bind ( $lift );
$chev4b_1.bind ( $lift );
$chev5a_1.bind ( $lift );
$chev5b_1.bind ( $lift );
$chev6a_1.bind ( $lift );
$chev6b_1.bind ( $lift );
$chev7a_1.bind ( $lift );
$chev7b_1.bind ( $lift );
$chev8a_1.bind ( $lift );
$chev8b_1.bind ( $lift );
$chev9a_1.bind ( $lift );
$chev9b_1.bind ( $lift );
$chev1a_3.bind ( $lift );
$chev1b_3.bind ( $lift );
$chev2a_3.bind ( $lift );
$chev2b_3.bind ( $lift );
$chev3a_3.bind ( $lift );
$chev3b_3.bind ( $lift );
$chev4a_3.bind ( $lift );
$chev4b_3.bind ( $lift );
$chev5a_3.bind ( $lift );
$chev5b_3.bind ( $lift );
$chev6a_3.bind ( $lift );
$chev6b_3.bind ( $lift );
$chev7a_3.bind ( $lift );
$chev7b_3.bind ( $lift );
$chev8a_3.bind ( $lift );
$chev8b_3.bind ( $lift );
$chev9a_3.bind ( $lift );
$chev9b_3.bind ( $lift );
$gsymb01_1.bind ( $lift );
$gsymb01_3.bind ( $lift );
$gsymb02_1.bind ( $lift );
$gsymb02_3.bind ( $lift );
$gsymb03_1.bind ( $lift );
$gsymb03_3.bind ( $lift );
$gsymb04_1.bind ( $lift );
$gsymb04_3.bind ( $lift );
$gsymb05_1.bind ( $lift );
$gsymb05_3.bind ( $lift );
$gsymb06_1.bind ( $lift );
$gsymb06_3.bind ( $lift );
$gsymb07_1.bind ( $lift );
$gsymb07_3.bind ( $lift );
$gsymb08_1.bind ( $lift );
$gsymb08_3.bind ( $lift );
$gsymb09_1.bind ( $lift );
$gsymb09_3.bind ( $lift );
$gsymb10_1.bind ( $lift );
$gsymb10_3.bind ( $lift );
$gsymb11_1.bind ( $lift );
$gsymb11_3.bind ( $lift );
$gsymb12_1.bind ( $lift );
$gsymb12_3.bind ( $lift );
$gsymb13_1.bind ( $lift );
$gsymb13_3.bind ( $lift );
$gsymb14_1.bind ( $lift );
$gsymb14_3.bind ( $lift );
$gsymb15_1.bind ( $lift );
$gsymb15_3.bind ( $lift );
$gsymb16_1.bind ( $lift );
$gsymb16_3.bind ( $lift );
$gsymb17_1.bind ( $lift );
$gsymb17_3.bind ( $lift );
$gsymb18_1.bind ( $lift );
$gsymb18_3.bind ( $lift );
$gsymb19_1.bind ( $lift );
$gsymb19_3.bind ( $lift );
$gsymb20_1.bind ( $lift );
$gsymb20_3.bind ( $lift );
$gsymb21_1.bind ( $lift );
$gsymb21_3.bind ( $lift );
$gsymb22_1.bind ( $lift );
$gsymb22_3.bind ( $lift );
$gsymb23_1.bind ( $lift );
$gsymb23_3.bind ( $lift );
$gsymb24_1.bind ( $lift );
$gsymb24_3.bind ( $lift );
$gsymb25_1.bind ( $lift );
$gsymb25_3.bind ( $lift );
$gsymb26_1.bind ( $lift );
$gsymb26_3.bind ( $lift );
$gsymb27_1.bind ( $lift );
$gsymb27_3.bind ( $lift );
$gsymb28_1.bind ( $lift );
$gsymb28_3.bind ( $lift );
$gsymb29_1.bind ( $lift );
$gsymb29_3.bind ( $lift );
$gsymb30_1.bind ( $lift );
$gsymb30_3.bind ( $lift );
$gsymb31_1.bind ( $lift );
$gsymb31_3.bind ( $lift );
$gsymb32_1.bind ( $lift );
$gsymb32_3.bind ( $lift );
$gsymb33_1.bind ( $lift );
$gsymb33_3.bind ( $lift );
$gsymb34_1.bind ( $lift );
$gsymb34_3.bind ( $lift );
$gsymb35_1.bind ( $lift );
$gsymb35_3.bind ( $lift );
$gsymb36_1.bind ( $lift );
$gsymb36_3.bind ( $lift );
$eventh_0.bind ( $lift );
$eventh_2.bind ( $lift );
$gate_t0.bind ( $lift );
$gate_t2.bind ( $lift );
$gate_t3.bind ( $lift );
$gate_t4.bind ( $lift );
$gate_sd1.bind ( $lift );
$gate1_sd1.bind ( $lift );
$gateunst10.bind ( $lift );
$port1_1.bind ( $lift );
$port2_1.bind ( $lift );
$port3_1.bind ( $lift );
$port4_1.bind ( $lift );

$rings_5.bind ( $lift );
$rings_6.bind ( $lift );
$rings_7.bind ( $lift );
$rings_8.bind ( $lift );
$rings_9.bind ( $lift );
$rings_11.bind ( $lift );
$rings_12.bind ( $lift );
$biodoor0.bind ( $lift );
$biodoor1.bind ( $lift );
$gate_t1.bind ( $lift );
$gate_t5.bind ( $lift );
$ring_trig1.bind ( $lift );
$ring_trig3.bind ( $lift );
$ring_trig4.bind ( $lift );
$ring_trig5.bind ( $lift );

$lift_controldoor_R.bind ( $lift );
$lift_controldoor_L.bind ( $lift );
$lift_controldoor_control.bind ( $lift );
$lift_controldoor_ind.bind ( $lift );
$lift_controldoor_L_steam.bind ( $lift_controldoor_L );
$lift_controldoor_R_steam.bind ( $lift_controldoor_R );

$lift_indmove.bind ( $lift );
$lift_indstop.bind ( $lift );

$lift_ind.bind ( $lift );

$lift_up_control.bind ( $lift );
$lift_down_control.bind ( $lift );

$lift_ind_u2.hide ();
$lift_ind_u1.hide ();
$lift_ind_d1.hide ();
$lift_ind_d2.hide ();

$lift_ind_u2.bind ( $lift );
$lift_ind_u1.bind ( $lift );
$lift_ind_d1.bind ( $lift );
$lift_ind_d2.bind ( $lift );
	
$lift_rotatedoorR.bind ( $lift );
$lift_rotatedoorR_control.bind ( $lift );
$lift_rotatedoorR_ind.bind ( $lift );
$lift_rotatedoorL.bind ( $lift );
$lift_rotatedoorL_control.bind ( $lift );
$lift_rotatedoorL_ind.bind ( $lift );

$lift_turret.bind ( $lift );

$lift_replicator_ind.bind ( $lift );
$lift_replicator_control.bind ( $lift );
$lift_replicator_drink.bind ( $lift );

//Archetype Setup

//World Setup
thread weapon_trigger ();
thread gate_wh_trigger ();
thread gate_wh_trig1 ();
thread ring_trigger1 ();
thread biodoor_trigger ();
thread ringtran_trigger ();
thread ringtran_trigger1 ();
thread lift_controldoor_trigger ();
$lift_controldoor_L_steam.hide ();
$lift_controldoor_R_steam.hide ();

$lift_indmove.hide ();

$lift_replicator_drink.hide ();

//Spawners Setup

//Characters Setup

}
//*-*-*-*-*-*-*-
//Bio Door
//*-*-*-*-*-*-*-
void biodoor_trigger()
{
	if ( biodoor0_state == 0 )		//Door is open
	{
	$biodoor1.time ( 2 );
	$biodoor1.moveEast ( 48 );

	$biodoor0.time ( 2 );
	$biodoor0.moveWest ( 48 );

	biodoor0_state = 1;
	}
	else							//Door is closed
	{
	$biodoor1.time ( 2 );
	$biodoor1.moveWest ( 48 );

	$biodoor0.time ( 2 );
	$biodoor0.moveEast ( 48 );

	biodoor0_state = 0;
	}

$biodoor0.playsound ( "sound/doors/sfa_glassdoor1.wav", 1, 128 );
$biodoor1.playsound ( "sound/doors/sfa_glassdoor1.wav", 1, 128 );

}


//*-*-*-*-*-*-*-
//Rings
//*-*-*-*-*-*-*-
void ring_trigger1()
{
	if ( rings_5_state == 0 )
	{
	$rings_9.time ( .5 );
	$rings_9.moveUp ( 136 );

	$ring_trig1.nottriggerable ();
	$ring_trig3.nottriggerable ();
	$ring_trig4.nottriggerable ();
	$ring_trig5.nottriggerable ();

	wait ( .15 );

	$rings_8.time ( .5 );
	$rings_8.moveUp ( 136 );

	wait ( .15 );

	$rings_7.time ( .5 );
	$rings_7.moveUp ( 136 );

	wait ( .15 );

	$rings_6.time ( .5 );
	$rings_6.moveUp ( 136 );

	wait ( .15 );

	$rings_5.time ( .5 );
	$rings_5.moveUp ( 136 );

	wait ( 3.5 );

	$rings_5.time ( .5 );
	$rings_5.moveDown ( 136 );

	wait ( .15 );

	$rings_6.time ( .5 );
	$rings_6.moveDown ( 136 );

	wait ( .15 );

	$rings_7.time ( .5 );
	$rings_7.moveDown ( 136 );

	wait ( .15 );

	$rings_8.time ( .5 );
	$rings_8.moveDown ( 136 );

	wait ( .15 );

	$rings_9.time ( .5 );
	$rings_9.moveDown ( 136 );

	wait ( 2 );

	$ring_trig1.triggerable ();
	$ring_trig3.triggerable ();
	$ring_trig4.triggerable ();
	$ring_trig5.triggerable ();

	rings_5_state = 1;
	}
	else
	{
	$rings_9.time ( .5 );
	$rings_9.moveUp ( 136 );

	$ring_trig1.nottriggerable ();
	$ring_trig3.nottriggerable ();
	$ring_trig4.nottriggerable ();
	$ring_trig5.nottriggerable ();

	wait ( .15 );

	$rings_8.time ( .5 );
	$rings_8.moveUp ( 136 );

	wait ( .15 );

	$rings_7.time ( .5 );
	$rings_7.moveUp ( 136 );

	wait ( .15 );

	$rings_6.time ( .5 );
	$rings_6.moveUp ( 136 );

	wait ( .15 );

	$rings_5.time ( .5 );
	$rings_5.moveUp ( 136 );

	wait ( .5 );

	$rings_11.time ( .3 );
	$rings_511.moveUp ( 136 );
	$rings_12.time ( .3 );
	$rings_12.moveUp ( 136 );

	wait ( 1 );

	$rings_11.time ( .3 );
	$rings_11.moveDown ( 136 );
	$rings_12.time ( .3 );
	$rings_12.moveDown ( 136 );

	wait ( 1.9 );

	$rings_5.time ( .5 );
	$rings_5.moveDown ( 136 );

	wait ( .15 );

	$rings_6.time ( .5 );
	$rings_6.moveDown ( 136 );

	wait ( .15 );

	$rings_7.time ( .5 );
	$rings_7.moveDown ( 136 );

	wait ( .15 );

	$rings_8.time ( .5 );
	$rings_8.moveDown ( 136 );

	wait ( .15 );

	$rings_9.time ( .5 );
	$rings_9.moveDown ( 136 );

	wait ( 2 );

	$ring_trig1.triggerable ();
	$ring_trig3.triggerable ();
	$ring_trig4.triggerable ();
	$ring_trig5.triggerable ();

	rings_5_state = 0;
	}
}
//*-*-*-*-*-*-*-
//Transport Triggers
//*-*-*-*-*-*-*-
void ringtran_trigger()
{
	if ( gate_t1_state == 0 )
	{
	wait ( 2.5 );

	$gate_t1.triggerable ();

	wait ( 2 );

	$gate_t1.nottriggerable ();

	gate_t1_state = 1;
	}
	else
	{
	wait ( 2.5 );

	$gate_t1.triggerable ();

	wait ( 2 );

	$gate_t1.nottriggerable ();

	gate_t1_state = 0;
	}
}

void ringtran_trigger1()
{
	if ( gate_t5_state == 0 )
	{
	wait ( 2.5 );

	$gate_t5.triggerable ();

	wait ( 2 );

	$gate_t5.nottriggerable ();

	gate_t5_state = 1;
	}
	else
	{
	wait ( 2.5 );

	$gate_t5.triggerable ();

	wait ( 2 );

	$gate_t5.nottriggerable ();

	gate_t5_state = 0;
	}
}

//*-*-*-*-*-*-*-
//weapon door
//*-*-*-*-*-*-*-
void weapon_trigger()
{
	if ( weapon_l0_state == 0 )		//Door is Locked
	{
	$Weapon_l0.show ();
	$Weapon_l1.hide ();
	$Weapon_l2.show ();
	$Weapon_l3.hide ();
	$weapon_door1.nottriggerable ();

	weapon_l0_state = 1;
	}
	else						//Door is unlocked
	{
	$Weapon_l0.hide ();
	$Weapon_l1.show ();
	$Weapon_l2.hide ();
	$Weapon_l3.show ();
	$weapon_door1.triggerable ();

	weapon_l0_state = 0;
	}
}

//*-*-*-*-*-*-*-*
//Main Stargate
//*-*-*-*-*-*-*-*
void gate_wh_trigger()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Forcefield triggered \n" );
	}


	if ( chev1a_1_state == 0 )		//Gate is offline
	{


	$chev1a_1.playsound ( "sound/sub/stargate/Dialstart.wav", 1, 32 );

	$gsymb26_1.hide ();
	$gsymb26_3.hide ();
	$gsymb27_1.show ();
	$gsymb27_3.show ();

	wait ( .15 );

	$gsymb27_1.hide ();
	$gsymb27_3.hide ();
	$gsymb28_1.show ();
	$gsymb28_3.show ();

	wait ( .15 );

	$gsymb28_1.hide ();
	$gsymb28_3.hide ();
	$gsymb29_1.show ();
	$gsymb29_3.show ();

	wait ( .15 );

	$gsymb29_1.hide ();
	$gsymb29_3.hide ();
	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb33_1.show ();
	$gsymb33_3.show ();

	wait ( .15 );

	$gsymb33_1.hide ();
	$gsymb33_3.hide ();
	$gsymb34_1.show ();
	$gsymb34_3.show ();

	wait ( .15 );

	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb35_1.show ();
	$gsymb35_3.show ();

	wait ( .15 );

	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb36_1.show ();
	$gsymb36_3.show ();

	wait ( .15 );

	$gsymb36_1.hide ();
	$gsymb36_3.hide ();
	$gsymb01_1.show ();
	$gsymb01_3.show ();

	wait ( .15 );

	$gsymb01_1.hide ();
	$gsymb01_3.hide ();
	$gsymb02_1.show ();
	$gsymb02_3.show ();

	wait ( .15 );

	$gsymb02_1.hide ();
	$gsymb02_3.hide ();
	$gsymb03_1.show ();
	$gsymb03_3.show ();

	wait ( .15 );

	$gsymb03_1.hide ();
	$gsymb03_3.hide ();
	$gsymb04_1.show ();
	$gsymb04_3.show ();

	wait ( .15 );

	$gsymb04_1.hide ();
	$gsymb04_3.hide ();
	$gsymb05_1.show ();
	$gsymb05_3.show ();
	$chev9a_1.hide ();
	$chev9b_1.show ();
	$chev9a_3.hide ();
	$chev9b_3.show ();
	
	$chev1a_1.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb01_1.show ();
	$gsymb01_3.show ();

	wait ( .15 );

	$gsymb01_1.hide ();
	$gsymb01_3.hide ();
	$gsymb02_1.show ();
	$gsymb02_3.show ();

	wait ( .15 );

	$gsymb02_1.hide ();
	$gsymb02_3.hide ();
	$gsymb03_1.show ();
	$gsymb03_3.show ();

	wait ( .15 );

	$gsymb03_1.hide ();
	$gsymb03_3.hide ();
	$gsymb04_1.show ();
	$gsymb04_3.show ();

	wait ( .15 );

	$gsymb04_1.hide ();
	$gsymb04_3.hide ();

	wait ( .15 );

	$gsymb06_1.show ();
	$gsymb06_3.show ();

	wait ( .15 );

	$gsymb06_1.hide ();
	$gsymb06_3.hide ();
	$gsymb07_1.show ();
	$gsymb07_3.show ();

	wait ( .15 );

	$gsymb07_1.hide ();
	$gsymb07_3.hide ();
	$gsymb08_1.show ();
	$gsymb08_3.show ();

	wait ( .15 );

	$gsymb08_1.hide ();
	$gsymb08_3.hide ();
	$gsymb09_1.show ();
	$gsymb09_3.show ();

	$chev8a_1.hide ();
	$chev8b_1.show ();
	$chev8a_3.hide ();
	$chev8b_3.show ();

	$chev1a_1.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb19_1.show ();
	$gsymb19_3.show ();

	wait ( .15 );

	$gsymb19_1.hide ();
	$gsymb19_3.hide ();
	$gsymb18_1.show ();
	$gsymb18_3.show ();

	wait ( .15 );

	$gsymb18_1.hide ();
	$gsymb18_3.hide ();
	$gsymb17_1.show ();
	$gsymb17_3.show ();

	wait ( .15 );

	$gsymb17_1.hide ();
	$gsymb17_3.hide ();
	$gsymb16_1.show ();
	$gsymb16_3.show ();

	wait ( .15 );

	$gsymb16_1.hide ();
	$gsymb16_3.hide ();
	$gsymb15_1.show ();
	$gsymb15_3.show ();

	wait ( .15 );

	$gsymb15_1.hide ();
	$gsymb15_3.hide ();
	$gsymb14_1.show ();
	$gsymb14_3.show ();

	wait ( .15 );

	$gsymb14_1.hide ();
	$gsymb14_3.hide ();
	$gsymb13_1.show ();
	$gsymb13_3.show ();

	$chev7a_1.hide ();
	$chev7b_1.show ();
	$chev7a_3.hide ();
	$chev7b_3.show ();

	$chev1a_1.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb14_1.show ();
	$gsymb14_3.show ();

	wait ( .15 );

	$gsymb14_1.hide ();
	$gsymb14_3.hide ();
	$gsymb15_1.show ();
	$gsymb15_3.show ();

	wait ( .15 );

	$gsymb15_1.hide ();
	$gsymb15_3.hide ();
	$gsymb16_1.show ();
	$gsymb16_3.show ();

	wait ( .15 );

	$gsymb16_1.hide ();
	$gsymb16_3.hide ();
	$gsymb17_1.show ();
	$gsymb17_3.show ();

	wait ( .15 );

	$gsymb17_1.hide ();
	$gsymb17_3.hide ();
	$gsymb18_1.show ();
	$gsymb18_3.show ();

	wait ( .15 );

	$gsymb18_1.hide ();
	$gsymb18_3.hide ();
	$gsymb19_1.show ();
	$gsymb19_3.show ();

	wait ( .15 );

	$gsymb19_1.hide ();
	$gsymb19_3.hide ();
	$gsymb20_1.show ();
	$gsymb20_3.show ();

	wait ( .15 );

	$gsymb20_1.hide ();
	$gsymb20_3.hide ();
	$gsymb21_1.show ();
	$gsymb21_3.show ();

	wait ( .15 );

	$gsymb21_1.hide ();
	$gsymb21_3.hide ();
	$gsymb22_1.show ();
	$gsymb22_3.show ();

	wait ( .15 );

	$gsymb21_1.hide ();
	$gsymb21_3.hide ();
	$gsymb22_1.show ();
	$gsymb22_3.show ();

	wait ( .15 );

	$gsymb22_1.hide ();
	$gsymb22_3.hide ();
	$gsymb23_1.show ();
	$gsymb23_3.show ();

	wait ( .15 );

	$gsymb23_1.hide ();
	$gsymb23_3.hide ();
	$gsymb24_1.show ();
	$gsymb24_3.show ();

	wait ( .15 );

	$gsymb24_1.hide ();
	$gsymb24_3.hide ();
	$gsymb25_1.show ();
	$gsymb25_3.show ();
	$chev4a_1.hide ();
	$chev4b_1.show ();
	$chev4a_3.hide ();
	$chev4b_3.show ();

	$chev1a_1.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb36_1.show ();
	$gsymb36_3.show ();

	wait ( .15 );

	$gsymb36_1.hide ();
	$gsymb36_3.hide ();
	$gsymb35_1.show ();
	$gsymb35_3.show ();

	wait ( .15 );

	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb34_1.show ();
	$gsymb34_3.show ();

	wait ( .15 );

	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb33_1.show ();
	$gsymb33_3.show ();

	wait ( .15 );

	$gsymb33_1.hide ();
	$gsymb33_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb29_1.show ();
	$gsymb29_3.show ();
	$chev3a_1.hide ();
	$chev3b_1.show ();
	$chev3a_3.hide ();
	$chev3b_3.show ();

	$chev1a_1.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb33_1.show ();
	$gsymb33_3.show ();
	$chev2a_1.hide ();
	$chev2b_1.show ();
	$chev2a_3.hide ();
	$chev2b_3.show ();

	$chev1a_1.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb28_1.show ();
	$gsymb28_3.show ();

	wait ( .15 );

	$gsymb28_1.hide ();
	$gsymb28_3.hide ();

	wait ( .15 );

	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();

	wait ( .15 );

	$gsymb34_1.show ();
	$gsymb34_3.show ();

	wait ( .15 );

	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb35_1.show ();
	$gsymb35_3.show ();

	wait ( .15 );

	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb36_1.show ();
	$gsymb36_3.show ();

	wait ( .15 );

	$gsymb36_1.hide ();
	$gsymb36_3.hide ();
	$gsymb01_1.show ();
	$gsymb01_3.show ();
	$chev1a_1.hide ();
	$chev1b_1.show ();
	$chev1a_3.hide ();
	$chev1b_3.show ();

	$gateunst10.time ( 1 );
	$gateunst10.moveSouth ( 750 );
	$gateunst10.notsolid ();
	$gateunst10.show ();

	$chev1a_1.playsound ( "sound/sub/stargate/Gateactive.wav", 1, 32 );

	$port3_1.show ();
	$port3_1.notsolid ();

	wait ( .1 );

	$port4_1.show ();
	$port4_1.notsolid ();

	wait ( .1 );

	$port2_1.show ();
	$port2_1.notsolid ();

	wait ( .1 );

	$port1_1.show ();
	$port1_1.notsolid ();

	$eventh_2.show ();
	$eventh_2.notsolid ();

	$gate_t9.triggerable ();
	$gate_t2.nottriggerable ();
	$gate_t3.triggerable ();
	$gate_t4.nottriggerable ();

	$gate_sd1.triggerable ();
	$gate1_sd1.nottriggerable ();

	wait ( 1.3 );

	$gateunst10.time ( 1 );
	$gateunst10.moveNorth ( 750 );
	$gateunst10.notsolid ();
	$gateunst10.show ();

	wait ( 1.3 );

	$gsymb01_3.show ();
	$gsymb02_3.show ();
	$gsymb03_3.show ();
	$gsymb04_3.show ();
	$gsymb05_3.show ();
	$gsymb06_3.show ();
	$gsymb07_3.show ();
	$gsymb08_3.show ();
	$gsymb09_3.show ();
	$gsymb10_3.show ();
	$gsymb11_3.show ();
	$gsymb12_3.show ();
	$gsymb13_3.show ();
	$gsymb14_3.show ();
	$gsymb15_3.show ();
	$gsymb16_3.show ();
	$gsymb17_3.show ();
	$gsymb18_3.show ();
	$gsymb19_3.show ();
	$gsymb20_3.show ();
	$gsymb21_3.show ();
	$gsymb22_3.show ();
	$gsymb23_3.show ();
	$gsymb24_3.show ();
	$gsymb25_3.show ();
	$gsymb26_3.show ();
	$gsymb27_3.show ();
	$gsymb28_3.show ();
	$gsymb29_3.show ();
	$gsymb30_3.show ();
	$gsymb31_3.show ();
	$gsymb32_3.show ();
	$gsymb33_3.show ();
	$gsymb34_3.show ();
	$gsymb35_3.show ();
	$gsymb36_3.show ();
	$gsymb01_1.show ();
	$gsymb02_1.show ();
	$gsymb03_1.show ();
	$gsymb04_1.show ();
	$gsymb05_1.show ();
	$gsymb06_1.show ();
	$gsymb07_1.show ();
	$gsymb08_1.show ();
	$gsymb09_1.show ();
	$gsymb10_1.show ();
	$gsymb11_1.show ();
	$gsymb12_1.show ();
	$gsymb13_1.show ();
	$gsymb14_1.show ();
	$gsymb15_1.show ();
	$gsymb16_1.show ();
	$gsymb17_1.show ();
	$gsymb18_1.show ();
	$gsymb19_1.show ();
	$gsymb20_1.show ();
	$gsymb21_1.show ();
	$gsymb22_1.show ();
	$gsymb23_1.show ();
	$gsymb24_1.show ();
	$gsymb25_1.show ();
	$gsymb26_1.show ();
	$gsymb27_1.show ();
	$gsymb28_1.show ();
	$gsymb29_1.show ();
	$gsymb30_1.show ();
	$gsymb31_1.show ();
	$gsymb32_1.show ();
	$gsymb33_1.show ();
	$gsymb34_1.show ();
	$gsymb35_1.show ();
	$gsymb36_1.show ();


	wait ( 1 );

	$eventh_0.loopsound ( "sound/sub/stargate/gate_o.wav", 1, 128 );
	$gateunst10.hide ();

	chev1a_1_state = 1;
	}
	else							//Gate is online
	{

	$chev1a_1.playsound ( "sound/sub/stargate/Gateshutdown.wav", 1, 32 );
	$chev1a_3.playsound ( "sound/sub/stargate/Gateshutdown.wav", 1, 32 );

	wait ( 1 );

	$chev1a_1.stoploopsound ();

	$port4_1.hide ();
	$port4_1.notsolid ();
	$port3_1.hide ();
	$port3_1.notsolid ();
	$port2_1.hide ();
	$port2_1.notsolid ();
	$port1_1.hide ();
	$port1_1.notsolid ();
	$eventh_2.hide ();
	$eventh_2.notsolid ();

	$gate_t9.nottriggerable ();
	$gate_t2.nottriggerable ();
	$gate_t3.nottriggerable ();
	$gate_t4.nottriggerable ();

	$gate_sd1.nottriggerable ();
	$gate1_sd1.nottriggerable ();

	wait ( 3 );

	$chev1a_1.show ();
	$chev1b_1.hide ();
	$chev1a_3.show ();
	$chev1b_3.hide ();
	$chev9a_1.show ();
	$chev9b_1.hide ();
	$chev9a_3.show ();
	$chev9b_3.hide ();
	$chev8a_1.show ();
	$chev8b_1.hide ();
	$chev8a_3.show ();
	$chev8b_3.hide ();
	$chev7a_1.show ();
	$chev7b_1.hide ();
	$chev7a_3.show ();
	$chev7b_3.hide ();
	$chev4a_1.show ();
	$chev4b_1.hide ();
	$chev4a_3.show ();
	$chev4b_3.hide ();
	$chev3a_1.show ();
	$chev3b_1.hide ();
	$chev3a_3.show ();
	$chev3b_3.hide ();
	$chev2a_1.show ();
	$chev2b_1.hide ();
	$chev2a_3.show ();
	$chev2b_3.hide ();

	$gsymb01_1.hide ();
	$gsymb01_3.hide ();
	$gsymb02_1.hide ();
	$gsymb02_3.hide ();
	$gsymb03_1.hide ();
	$gsymb03_3.hide ();
	$gsymb04_1.hide ();
	$gsymb04_3.hide ();
	$gsymb05_1.hide ();
	$gsymb05_3.hide ();
	$gsymb06_1.hide ();
	$gsymb06_3.hide ();
	$gsymb07_1.hide ();
	$gsymb07_3.hide ();
	$gsymb08_1.hide ();
	$gsymb08_3.hide ();
	$gsymb09_1.hide ();
	$gsymb09_3.hide ();
	$gsymb10_1.hide ();
	$gsymb10_3.hide ();
	$gsymb11_1.hide ();
	$gsymb11_3.hide ();
	$gsymb12_1.hide ();
	$gsymb12_3.hide ();
	$gsymb13_1.hide ();
	$gsymb13_3.hide ();
	$gsymb14_1.hide ();
	$gsymb14_3.hide ();
	$gsymb15_1.hide ();
	$gsymb15_3.hide ();
	$gsymb16_1.hide ();
	$gsymb16_3.hide ();
	$gsymb17_1.hide ();
	$gsymb17_3.hide ();
	$gsymb18_1.hide ();
	$gsymb18_3.hide ();
	$gsymb19_1.hide ();
	$gsymb19_3.hide ();
	$gsymb20_1.hide ();
	$gsymb20_3.hide ();
	$gsymb21_1.hide ();
	$gsymb21_3.hide ();
	$gsymb22_1.hide ();
	$gsymb22_3.hide ();
	$gsymb23_1.hide ();
	$gsymb23_3.hide ();
	$gsymb24_1.hide ();
	$gsymb24_3.hide ();
	$gsymb25_1.hide ();
	$gsymb25_3.hide ();
	$gsymb26_1.hide ();
	$gsymb26_3.hide ();
	$gsymb27_1.hide ();
	$gsymb27_3.hide ();
	$gsymb28_1.hide ();
	$gsymb28_3.hide ();
	$gsymb29_1.hide ();
	$gsymb29_3.hide ();
	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb33_1.hide ();
	$gsymb33_3.hide ();
	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb36_1.hide ();
	$gsymb36_3.hide ();

	$chev6a_1.show ();
	$chev6b_1.hide ();
	$chev6a_3.show ();
	$chev6b_3.hide ();
	$chev5a_1.show ();
	$chev5b_1.hide ();
	$chev5a_3.show ();
	$chev5b_3.hide ();

	chev1a_1_state = 0;
	}
}

//*-*-*-*-*-*-*-*
//Stargate 1
//*-*-*-*-*-*-*-*
void gate_wh_trig1()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Forcefield triggered \n" );
	}


	if ( chev1a_3_state == 0 )		//Gate is offline
	{

	$chev1a_3.playsound ( "sound/sub/stargate/Dialstart.wav", 1, 32 );

	$gsymb26_1.hide ();
	$gsymb26_3.hide ();
	$gsymb27_1.show ();
	$gsymb27_3.show ();

	wait ( .15 );

	$gsymb27_1.hide ();
	$gsymb27_3.hide ();
	$gsymb28_1.show ();
	$gsymb28_3.show ();

	wait ( .15 );

	$gsymb28_1.hide ();
	$gsymb28_3.hide ();
	$gsymb29_1.show ();
	$gsymb29_3.show ();

	wait ( .15 );

	$gsymb29_1.hide ();
	$gsymb29_3.hide ();
	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb33_1.show ();
	$gsymb33_3.show ();

	wait ( .15 );

	$gsymb33_1.hide ();
	$gsymb33_3.hide ();
	$gsymb34_1.show ();
	$gsymb34_3.show ();

	wait ( .15 );

	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb35_1.show ();
	$gsymb35_3.show ();

	wait ( .15 );

	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb36_1.show ();
	$gsymb36_3.show ();

	wait ( .15 );

	$gsymb36_1.hide ();
	$gsymb36_3.hide ();
	$gsymb01_1.show ();
	$gsymb01_3.show ();

	wait ( .15 );

	$gsymb01_1.hide ();
	$gsymb01_3.hide ();
	$gsymb02_1.show ();
	$gsymb02_3.show ();

	wait ( .15 );

	$gsymb02_1.hide ();
	$gsymb02_3.hide ();
	$gsymb03_1.show ();
	$gsymb03_3.show ();

	wait ( .15 );

	$gsymb03_1.hide ();
	$gsymb03_3.hide ();
	$gsymb04_1.show ();
	$gsymb04_3.show ();

	wait ( .15 );

	$gsymb04_1.hide ();
	$gsymb04_3.hide ();
	$gsymb05_1.show ();
	$gsymb05_3.show ();
	$chev9a_1.hide ();
	$chev9b_1.show ();
	$chev9a_3.hide ();
	$chev9b_3.show ();
	
	$chev1a_3.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_3.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb01_1.show ();
	$gsymb01_3.show ();

	wait ( .15 );

	$gsymb01_1.hide ();
	$gsymb01_3.hide ();
	$gsymb02_1.show ();
	$gsymb02_3.show ();

	wait ( .15 );

	$gsymb02_1.hide ();
	$gsymb02_3.hide ();
	$gsymb03_1.show ();
	$gsymb03_3.show ();

	wait ( .15 );

	$gsymb03_1.hide ();
	$gsymb03_3.hide ();
	$gsymb04_1.show ();
	$gsymb04_3.show ();

	wait ( .15 );

	$gsymb04_1.hide ();
	$gsymb04_3.hide ();

	wait ( .15 );

	$gsymb06_1.show ();
	$gsymb06_3.show ();

	wait ( .15 );

	$gsymb06_1.hide ();
	$gsymb06_3.hide ();
	$gsymb07_1.show ();
	$gsymb07_3.show ();

	wait ( .15 );

	$gsymb07_1.hide ();
	$gsymb07_3.hide ();
	$gsymb08_1.show ();
	$gsymb08_3.show ();

	wait ( .15 );

	$gsymb08_1.hide ();
	$gsymb08_3.hide ();
	$gsymb09_1.show ();
	$gsymb09_3.show ();

	$chev8a_1.hide ();
	$chev8b_1.show ();
	$chev8a_3.hide ();
	$chev8b_3.show ();

	$chev1a_3.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_3.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb19_1.show ();
	$gsymb19_3.show ();

	wait ( .15 );

	$gsymb19_1.hide ();
	$gsymb19_3.hide ();
	$gsymb18_1.show ();
	$gsymb18_3.show ();

	wait ( .15 );

	$gsymb18_1.hide ();
	$gsymb18_3.hide ();
	$gsymb17_1.show ();
	$gsymb17_3.show ();

	wait ( .15 );

	$gsymb17_1.hide ();
	$gsymb17_3.hide ();
	$gsymb16_1.show ();
	$gsymb16_3.show ();

	wait ( .15 );

	$gsymb16_1.hide ();
	$gsymb16_3.hide ();
	$gsymb15_1.show ();
	$gsymb15_3.show ();

	wait ( .15 );

	$gsymb15_1.hide ();
	$gsymb15_3.hide ();
	$gsymb14_1.show ();
	$gsymb14_3.show ();

	wait ( .15 );

	$gsymb14_1.hide ();
	$gsymb14_3.hide ();
	$gsymb13_1.show ();
	$gsymb13_3.show ();

	$chev7a_1.hide ();
	$chev7b_1.show ();
	$chev7a_3.hide ();
	$chev7b_3.show ();

	$chev1a_3.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_3.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb14_1.show ();
	$gsymb14_3.show ();

	wait ( .15 );

	$gsymb14_1.hide ();
	$gsymb14_3.hide ();
	$gsymb15_1.show ();
	$gsymb15_3.show ();

	wait ( .15 );

	$gsymb15_1.hide ();
	$gsymb15_3.hide ();
	$gsymb16_1.show ();
	$gsymb16_3.show ();

	wait ( .15 );

	$gsymb16_1.hide ();
	$gsymb16_3.hide ();
	$gsymb17_1.show ();
	$gsymb17_3.show ();

	wait ( .15 );

	$gsymb17_1.hide ();
	$gsymb17_3.hide ();
	$gsymb18_1.show ();
	$gsymb18_3.show ();

	wait ( .15 );

	$gsymb18_1.hide ();
	$gsymb18_3.hide ();
	$gsymb19_1.show ();
	$gsymb19_3.show ();

	wait ( .15 );

	$gsymb19_1.hide ();
	$gsymb19_3.hide ();
	$gsymb20_1.show ();
	$gsymb20_3.show ();

	wait ( .15 );

	$gsymb20_1.hide ();
	$gsymb20_3.hide ();
	$gsymb21_1.show ();
	$gsymb21_3.show ();

	wait ( .15 );

	$gsymb21_1.hide ();
	$gsymb21_3.hide ();
	$gsymb22_1.show ();
	$gsymb22_3.show ();

	wait ( .15 );

	$gsymb21_1.hide ();
	$gsymb21_3.hide ();
	$gsymb22_1.show ();
	$gsymb22_3.show ();

	wait ( .15 );

	$gsymb22_1.hide ();
	$gsymb22_3.hide ();
	$gsymb23_1.show ();
	$gsymb23_3.show ();

	wait ( .15 );

	$gsymb23_1.hide ();
	$gsymb23_3.hide ();
	$gsymb24_1.show ();
	$gsymb24_3.show ();

	wait ( .15 );

	$gsymb24_1.hide ();
	$gsymb24_3.hide ();
	$gsymb25_1.show ();
	$gsymb25_3.show ();
	$chev4a_1.hide ();
	$chev4b_1.show ();
	$chev4a_3.hide ();
	$chev4b_3.show ();

	$chev1a_3.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_3.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb36_1.show ();
	$gsymb36_3.show ();

	wait ( .15 );

	$gsymb36_1.hide ();
	$gsymb36_3.hide ();
	$gsymb35_1.show ();
	$gsymb35_3.show ();

	wait ( .15 );

	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb34_1.show ();
	$gsymb34_3.show ();

	wait ( .15 );

	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb33_1.show ();
	$gsymb33_3.show ();

	wait ( .15 );

	$gsymb33_1.hide ();
	$gsymb33_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb29_1.show ();
	$gsymb29_3.show ();
	$chev3a_1.hide ();
	$chev3b_1.show ();
	$chev3a_3.hide ();
	$chev3b_3.show ();

	$chev1a_3.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_3.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb33_1.show ();
	$gsymb33_3.show ();
	$chev2a_1.hide ();
	$chev2b_1.show ();
	$chev2a_3.hide ();
	$chev2b_3.show ();

	$chev1a_3.playsound ( "sound/sub/stargate/Chevlock.wav", 1, 32 );

	wait ( 1 );

	$chev1a_3.playsound ( "sound/sub/stargate/Dialling.wav", 1, 32 );

	$gsymb28_1.show ();
	$gsymb28_3.show ();

	wait ( .15 );

	$gsymb28_1.hide ();
	$gsymb28_3.hide ();

	wait ( .15 );

	$gsymb30_1.show ();
	$gsymb30_3.show ();

	wait ( .15 );

	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.show ();
	$gsymb31_3.show ();

	wait ( .15 );

	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.show ();
	$gsymb32_3.show ();

	wait ( .15 );

	$gsymb32_1.hide ();
	$gsymb32_3.hide ();

	wait ( .15 );

	$gsymb34_1.show ();
	$gsymb34_3.show ();

	wait ( .15 );

	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb35_1.show ();
	$gsymb35_3.show ();

	wait ( .15 );

	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb36_1.show ();
	$gsymb36_3.show ();

	wait ( .15 );

	$gsymb36_1.hide ();
	$gsymb36_3.hide ();
	$gsymb01_1.show ();
	$gsymb01_3.show ();
	$chev1a_1.hide ();
	$chev1b_1.show ();
	$chev1a_3.hide ();
	$chev1b_3.show ();

	$chev1a_3.playsound ( "sound/sub/stargate/Gateactive.wav", 1, 32 );

	$port4_1.show ();
	$port4_1.notsolid ();
	$port3_1.show ();
	$port3_1.notsolid ();
	$port2_1.show ();
	$port2_1.notsolid ();
	$port1_1.show ();
	$port1_1.notsolid ();
	$eventh_2.show ();
	$eventh_2.notsolid ();

	$gate_t9.nottriggerable ();
	$gate_t2.triggerable ();
	$gate_t3.nottriggerable ();
	$gate_t4.triggerable ();

	$gate_sd1.nottriggerable ();
	$gate1_sd1.triggerable ();

	wait ( 1.3 );

	$gsymb01_1.show ();
	$gsymb02_1.show ();
	$gsymb03_1.show ();
	$gsymb04_1.show ();
	$gsymb05_1.show ();
	$gsymb06_1.show ();
	$gsymb07_1.show ();
	$gsymb08_1.show ();
	$gsymb09_1.show ();
	$gsymb10_1.show ();
	$gsymb11_1.show ();
	$gsymb12_1.show ();
	$gsymb13_1.show ();
	$gsymb14_1.show ();
	$gsymb15_1.show ();
	$gsymb16_1.show ();
	$gsymb17_1.show ();
	$gsymb18_1.show ();
	$gsymb19_1.show ();
	$gsymb20_1.show ();
	$gsymb21_1.show ();
	$gsymb22_1.show ();
	$gsymb23_1.show ();
	$gsymb24_1.show ();
	$gsymb25_1.show ();
	$gsymb26_1.show ();
	$gsymb27_1.show ();
	$gsymb28_1.show ();
	$gsymb29_1.show ();
	$gsymb30_1.show ();
	$gsymb31_1.show ();
	$gsymb32_1.show ();
	$gsymb33_1.show ();
	$gsymb34_1.show ();
	$gsymb35_1.show ();
	$gsymb36_1.show ();
	$gsymb01_3.show ();
	$gsymb02_3.show ();
	$gsymb03_3.show ();
	$gsymb04_3.show ();
	$gsymb05_3.show ();
	$gsymb06_3.show ();
	$gsymb07_3.show ();
	$gsymb08_3.show ();
	$gsymb09_3.show ();
	$gsymb10_3.show ();
	$gsymb11_3.show ();
	$gsymb12_3.show ();
	$gsymb13_3.show ();
	$gsymb14_3.show ();
	$gsymb15_3.show ();
	$gsymb16_3.show ();
	$gsymb17_3.show ();
	$gsymb18_3.show ();
	$gsymb19_3.show ();
	$gsymb20_3.show ();
	$gsymb21_3.show ();
	$gsymb22_3.show ();
	$gsymb23_3.show ();
	$gsymb24_3.show ();
	$gsymb25_3.show ();
	$gsymb26_3.show ();
	$gsymb27_3.show ();
	$gsymb28_3.show ();
	$gsymb29_3.show ();
	$gsymb30_3.show ();
	$gsymb31_3.show ();
	$gsymb32_3.show ();
	$gsymb33_3.show ();
	$gsymb34_3.show ();
	$gsymb35_3.show ();
	$gsymb36_3.show ();


	$eventh_2.loopsound ( "sound/sub/stargate/gate_o.wav", 1, 32 );

	chev1a_3_state = 1;
	}
	else							//Gate is online
	{

	$chev1a_1.playsound ( "sound/sub/stargate/Gateshutdown.wav", 1, 32 );
	$chev1a_3.playsound ( "sound/sub/stargate/Gateshutdown.wav", 1, 32 );

	wait ( 1 );

	$chev_1_1.stoploopsound ();

	$eventh_2.hide ();
	$eventh_2.notsolid ();
	$port4_1.hide ();
	$port4_1.notsolid ();
	$port3_1.hide ();
	$port3_1.notsolid ();
	$port2_1.hide ();
	$port2_1.notsolid ();
	$port1_1.hide ();
	$port1_1.notsolid ();

	$gate_t9.nottriggerable ();
	$gate_t2.nottriggerable ();
	$gate_t3.nottriggerable ();
	$gate_t4.nottriggerable ();

	$gate_sd1.nottriggerable ();
	$gate1_sd1.nottriggerable ();

	wait ( 3 );

	$chev1a_1.show ();
	$chev1b_1.hide ();
	$chev1a_3.show ();
	$chev1b_3.hide ();
	$chev9a_1.show ();
	$chev9b_1.hide ();
	$chev9a_3.show ();
	$chev9b_3.hide ();
	$chev8a_1.show ();
	$chev8b_1.hide ();
	$chev8a_3.show ();
	$chev8b_3.hide ();
	$chev7a_1.show ();
	$chev7b_1.hide ();
	$chev7a_3.show ();
	$chev7b_3.hide ();
	$chev4a_1.show ();
	$chev4b_1.hide ();
	$chev4a_3.show ();
	$chev4b_3.hide ();
	$chev3a_1.show ();
	$chev3b_1.hide ();
	$chev3a_3.show ();
	$chev3b_3.hide ();
	$chev2a_1.show ();
	$chev2b_1.hide ();
	$chev2a_3.show ();
	$chev2b_3.hide ();
	$chev6a_1.show ();
	$chev6b_1.hide ();
	$chev6a_3.show ();
	$chev6b_3.hide ();
	$chev5a_1.show ();
	$chev5b_1.hide ();
	$chev5a_3.show ();
	$chev5b_3.hide ();

	$gsymb01_1.hide ();
	$gsymb01_3.hide ();
	$gsymb02_1.hide ();
	$gsymb02_3.hide ();
	$gsymb03_1.hide ();
	$gsymb03_3.hide ();
	$gsymb04_1.hide ();
	$gsymb04_3.hide ();
	$gsymb05_1.hide ();
	$gsymb05_3.hide ();
	$gsymb06_1.hide ();
	$gsymb06_3.hide ();
	$gsymb07_1.hide ();
	$gsymb07_3.hide ();
	$gsymb08_1.hide ();
	$gsymb08_3.hide ();
	$gsymb09_1.hide ();
	$gsymb09_3.hide ();
	$gsymb10_1.hide ();
	$gsymb10_3.hide ();
	$gsymb11_1.hide ();
	$gsymb11_3.hide ();
	$gsymb12_1.hide ();
	$gsymb12_3.hide ();
	$gsymb13_1.hide ();
	$gsymb13_3.hide ();
	$gsymb14_1.hide ();
	$gsymb14_3.hide ();
	$gsymb15_1.hide ();
	$gsymb15_3.hide ();
	$gsymb16_1.hide ();
	$gsymb16_3.hide ();
	$gsymb17_1.hide ();
	$gsymb17_3.hide ();
	$gsymb18_1.hide ();
	$gsymb18_3.hide ();
	$gsymb19_1.hide ();
	$gsymb19_3.hide ();
	$gsymb20_1.hide ();
	$gsymb20_3.hide ();
	$gsymb21_1.hide ();
	$gsymb21_3.hide ();
	$gsymb22_1.hide ();
	$gsymb22_3.hide ();
	$gsymb23_1.hide ();
	$gsymb23_3.hide ();
	$gsymb24_1.hide ();
	$gsymb24_3.hide ();
	$gsymb25_1.hide ();
	$gsymb25_3.hide ();
	$gsymb26_1.hide ();
	$gsymb26_3.hide ();
	$gsymb27_1.hide ();
	$gsymb27_3.hide ();
	$gsymb28_1.hide ();
	$gsymb28_3.hide ();
	$gsymb29_1.hide ();
	$gsymb29_3.hide ();
	$gsymb30_1.hide ();
	$gsymb30_3.hide ();
	$gsymb31_1.hide ();
	$gsymb31_3.hide ();
	$gsymb32_1.hide ();
	$gsymb32_3.hide ();
	$gsymb33_1.hide ();
	$gsymb33_3.hide ();
	$gsymb34_1.hide ();
	$gsymb34_3.hide ();
	$gsymb35_1.hide ();
	$gsymb35_3.hide ();
	$gsymb36_1.hide ();
	$gsymb36_3.hide ();

	chev1a_3_state = 0;
	}
}

//*-*-*-*-*-*-*-*-*-*-*-*-*-*
//Lift Control Room Main Door
//*-*-*-*-*-*-*-*-*-*-*-*-*-*
void lift_controldoor_trigger()
{
$lift_controldoor_control.nottriggerable ();

$lift_controldoor_L_steam.show ();
$lift_controldoor_R_steam.show ();

	if ( DEBUG_FUNC == 1 )
	{
	print ( "Control Room Door moving..." );
	}

	if ( lift_controldoor_state == 0 )		//Door is open
	{
	$lift_controldoor_R.time ( 3 );
	$lift_controldoor_R.moveEast ( 120 );

	$lift_controldoor_L.time ( 3 );
	$lift_controldoor_L.moveWest ( 120 );

	lift_controldoor_state = 1;
	}
	else							//Door is closed
	{
	$lift_controldoor_R.time ( 3 );
	$lift_controldoor_R.moveWest ( 120 );

	$lift_controldoor_L.time ( 3 );
	$lift_controldoor_L.moveEast ( 120 );

	lift_controldoor_state = 0;
	}

$lift_controldoor_R.loopsound ( "sound/doors/attrex_door_long1.wav", 1, 128 );
$lift_controldoor_L.loopsound ( "sound/doors/attrex_door_long1.wav", 1, 128 );

$lift_controldoor_ind.playsound ( "sound/ships/attrexian/att-beepconfirm.wav", 3, 1, 500 );

waitfor ( $lift_controldoor_R );
waitfor ( $lift_controldoor_L );

	if ( DEBUG_FUNC == 1 )
	{
	print ( "DONE \n" );
	}

$lift_controldoor_R.stoploopsound ();
$lift_controldoor_L.stoploopsound ();

$lift_controldoor_R.playsound ( "sound/doors/attrex_door_long1stop.wav", 3, 1, 128 );
$lift_controldoor_L.playsound ( "sound/doors/attrex_door_long1stop.wav", 3, 1, 128 );

$lift_controldoor_L_steam.hide ();
$lift_controldoor_R_steam.hide ();

wait ( 1 );

$lift_controldoor_control.triggerable ();
}

//*-*-*-*-*-*-
//Lift Move Up
//*-*-*-*-*-*-
void lift_up_trigger()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Lift move up--Verifing lift position:" + lift_pos + "\n" );
	print ( "Lift move up--Verifing lift speed:" + move_speed + "\n" );
	}

	if ( move_speed == 2 )
	{
	$lift_ind.playsound ( "sound/ships/romulan/rom_beep_no.wav", 3, 1, 128 );
	return;
	}

	if ( lift_pos == 3648 && move_speed >= 0 )
	{
	$lift_ind.playsound ( "sound/ships/romulan/rom_beep_no.wav", 3, 1, 128 );
	return;
	}

move_speed = move_speed ++;

$lift_ind.playsound ( "sound/ships/romulan/rom_beep_yes.wav", 3, 1, 128 );

	if ( move_speed == 2 )
	{
	$lift.time ( 0.005 );
	move_dir = 1;
	$lift_ind_u2.show ();
	}

	if ( move_speed == 1 )
	{
	$lift.time ( 0.075 );
	move_dir = 1;
	thread lift_move ();
	lift_sound ( 1 );
	$lift_ind_u1.show ();
	}

	if ( move_speed == 0 )
	{
	move_dir = 0;
	$lift_ind_u1.hide ();
	$lift_ind_d1.hide ();
	lift_sound ( 2 );
	}

	if ( move_speed == -1 )
	{
	$lift.time ( 0.075 );
	move_dir = 2;
	$lift_ind_d2.hide ();
	}
}

//*-*-*-*-*-*-*-
//Lift Move Down
//*-*-*-*-*-*-*-
void lift_down_trigger()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Lift move up--Verifing lift position:" + lift_pos + "\n" );
	print ( "Lift move up--Verifing lift speed:" + move_speed + "\n" );
	}

	if ( move_speed == -2 )
	{
	$lift_ind.playsound ( "sound/ships/romulan/rom_beep_no.wav", 3, 1, 128 );
	return;
	}

	if ( lift_pos == 0 && move_speed <= 0 )
	{
	$lift_ind.playsound ( "sound/ships/romulan/rom_beep_no.wav", 3, 1, 128 );
	return;
	}

move_speed = move_speed --;

$lift_ind.playsound ( "sound/ships/romulan/rom_beep_yes.wav", 3, 1, 128 );

	if ( move_speed == 1 )
	{
	$lift.time ( 0.075 );
	move_dir = 1;
	$lift_ind_u2.hide ();
	}

	if ( move_speed == 0 )
	{
	move_dir = 0;
	$lift_ind_u1.hide ();
	$lift_ind_d1.hide ();
	lift_sound ( 2 );
	}

	if ( move_speed == -1 )
	{
	$lift.time ( 0.075 );
	move_dir = 2;
	thread lift_move ();
	lift_sound ( 1 );
	$lift_ind_d1.show ();
	}

	if ( move_speed == -2 )
	{
	$lift.time ( 0.005 );
	move_dir = 2;
	$lift_ind_d2.show ();
	}
}

//*-*-*-*-*-*
//Lift Sounds
//*-*-*-*-*-*
void lift_sound( float s )
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Lift effects triggered\n" );
	}

	if ( s == 1 )
	{
	$lift.playsound ( "sound/ships/enterprise/ent_turbolift_run.wav", 3, 2, 512 );
	$lift.loopsound ( "sound/ships/enterprise/ent_turbolift_runloop.wav", 2, 512 );
	$lift_indmove.show ();
	$lift_indstop.hide ();
	}

	if ( s == 2 )
	{
	$lift.stoploopsound ();
	$lift.playsound ( "sound/ships/enterprise/ent_turbolift_stop.wav", 3, 2, 512 );
	$lift_indmove.hide ();
	$lift_indstop.show ();
	}
}

//*-*-*-*-*-*-*-*-*-*-*-*
//Lift Move-Base Function
//*-*-*-*-*-*-*-*-*-*-*-*
void lift_move()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Lift move--Verifing lift position:" + lift_pos + "\n" );
	}

	if ( lift_pos == 0 && move_dir == 2 )
	{
	$lift_ind_u2.hide ();
	$lift_ind_u1.hide ();
	$lift_ind_d1.hide ();
	$lift_ind_d2.hide ();
	move_speed = 0;
	move_dir = 0;
	lift_sound ( 2 );
	return;
	}

	if ( lift_pos == 3648 && move_dir == 1 )
	{
	$lift_ind_u2.hide ();
	$lift_ind_u1.hide ();
	$lift_ind_d1.hide ();
	$lift_ind_d2.hide ();
	move_speed = 0;
	move_dir = 0;
	lift_sound ( 2 );
	return;
	}

	if ( move_dir == 1 )
	{
	$lift.moveUp ( 1 );
		
	waitfor ( $lift );

	lift_pos ++;

	thread lift_move ();
	}

	if ( move_dir == 2 )
	{
	$lift.moveDown ( 1 );
	
	waitfor ( $lift );

	lift_pos --;

	thread lift_move ();
	}
}

//*-*-*-*-*-*-*-*-*-*-*-*
//Lift Roof Hatch (Right)
//*-*-*-*-*-*-*-*-*-*-*-*
void lift_rotatedoorR_trigger()
{
$lift_rotatedoorR_control.nottriggerable ();

	if ( lift_rotatedoorR_state == 0 )		//Door is open
	{
	$lift_rotatedoorR.time ( 3 );
	$lift_rotatedoorR.rotateZup ( 170 );

	lift_rotatedoorR_state = 1;
	}
	else							//Door is closed
	{
	$lift_rotatedoorR.time ( 3 );
	$lift_rotatedoorR.rotateZdown ( 170 );

	lift_rotatedoorR_state = 0;
	}

$lift_rotatedoorR.loopsound ( "sound/doors/drull_smldoor_01.wav", 1, 128 );

$lift_rotatedoorR_ind.playsound ( "sound/ships/romulan/rom_beep_activate.wav", 3, 1, 500 );

waitfor ( $lift_rotatedoorR );

$lift_rotatedoorR.stoploopsound ();

$lift_rotatedoorR.playsound ( "sound/doors/drull_smldoor_stop_01.wav", 3, 1, 128 );

wait ( 1 );

$lift_rotatedoorR_control.triggerable ();
}

//*-*-*-*-*-*-*-*-*-*-*-
//Lift Roof Hatch (Left)
//*-*-*-*-*-*-*-*-*-*-*-
void lift_rotatedoorL_trigger()
{
$lift_rotatedoorL_control.nottriggerable ();

	if ( lift_rotatedoorL_state == 0 )		//Door is open
	{
	$lift_rotatedoorL.time ( 3 );
	$lift_rotatedoorL.rotateZup ( 170 );

	lift_rotatedoorL_state = 1;
	}
	else							//Door is closed
	{
	$lift_rotatedoorL.time ( 3 );
	$lift_rotatedoorL.rotateZdown ( 170 );

	lift_rotatedoorL_state = 0;
	}

$lift_rotatedoorL.loopsound ( "sound/doors/drull_smldoor_01.wav", 1, 128 );

$lift_rotatedoorL_ind.playsound ( "sound/ships/romulan/rom_beep_activate.wav", 3, 1, 500 );

waitfor ( $lift_rotatedoorL );

$lift_rotatedoorL.stoploopsound ();

$lift_rotatedoorL.playsound ( "sound/doors/drull_smldoor_stop_01.wav", 3, 1, 128 );

wait ( 1 );

$lift_rotatedoorL_control.triggerable ();
}

//*-*-*-*-*-*-*-*
//Lift Replicator
//*-*-*-*-*-*-*-*
void lift_replicator_trigger()
{
	if ( lift_replicator_state == 0 )		//Drink is not replicated
	{
	$lift_replicator_drink.show ();
	$lift_replicator_drink.displayeffect( "TransportIn", "Romulan" );

	$lift_replicator_ind.playsound ( "sound/ships/romulan/rom_beep_activate.wav", 3, 1, 500 );

	lift_replicator_state = 1;
	}
	else									//Drink is already replicated
	{
	$lift_replicator_drink.displayeffect( "TransportOut", "Romulan" );

	$lift_replicator_ind.playsound ( "sound/ships/romulan/rom_beep_activate.wav", 3, 1, 500 );

	wait ( 3 );

	$lift_replicator_drink.hide ();

	lift_replicator_state = 0;
	}
}

//*********************
//Lift Turret Functions
//*********************

void lift_turret_main()
{
//Bind Setup
$lift_turret_quantum_ind.bind ( $lift_turret );
$lift_turret_quantum_control.bind ( $lift_turret );
$lift_turret_quantum_origin1.bind ( $lift_turret );
$lift_turret_quantum_origin2.bind ( $lift_turret );

$lift_turret_right_ind.bind ( $lift_turret );
$lift_turret_right_control.bind ( $lift_turret );

$lift_turret_left_ind.bind ( $lift_turret );
$lift_turret_left_control.bind ( $lift_turret );

//Archetype Setup

//World Setup

//Spawners Setup

//Characters Setup

}

//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
//Lift Turret Fire Quantum Torpedo
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
void lift_turret_quantum_trigger()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Firing Quantum Torpedo \n" );
	}

$lift_turret_quantum_origin1.projectileattackentity ( "models/weapons/projectile_photonball.tik", "$lift_turret_quantum_origin2" );

$lift_turret_quantum_ind.playsound ( "sound/ships/enterprise/ent_qfire.wav", 3, 1, 128 );
}

//*-*-*-*-*-*-*-*-*-*-*-*-
//Lift Turret Rotate Right
//*-*-*-*-*-*-*-*-*-*-*-*-
void lift_turret_right_trigger()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Rotate lift turret - Rotate right \n" );
	}

$lift_turret_right_control.nottriggerable ();
$lift_turret_left_control.nottriggerable ();
$lift_turret_quantum_control.nottriggerable ();

$lift_turret.time ( .15 );
$lift_turret.rotateYdown ( 5 );

$lift_turret.loopsound ( "sound/doors/lrg_01_start.wav", 1, 128 );

waitfor ( $lift_turret );

$lift_turret.stoploopsound ();

$lift_turret_right_control.triggerable ();
$lift_turret_left_control.triggerable ();
$lift_turret_quantum_control.triggerable ();
}

//*-*-*-*-*-*-*-*-*-*-*-*
//Lift Turret Rotate Left
//*-*-*-*-*-*-*-*-*-*-*-*
void lift_turret_left_trigger()
{
	if ( DEBUG_FUNC == 1 )
	{
	print ( "Rotate lift turret - Rotate left \n" );
	}

$lift_turret_right_control.nottriggerable ();
$lift_turret_left_control.nottriggerable ();
$lift_turret_quantum_control.nottriggerable ();

$lift_turret.time ( .15 );
$lift_turret.rotateYup ( 5 );

$lift_turret.loopsound ( "sound/doors/lrg_01_start.wav", 1, 128 );

waitfor ( $lift_turret );

$lift_turret.stoploopsound ();

$lift_turret_right_control.triggerable ();
$lift_turret_left_control.triggerable ();
$lift_turret_quantum_control.triggerable ();
}