//     Raid Final - 02.01.2015
// IR4: 25.04.2014
// formatted, general clean up
// trigger bomb fragment removed
// leutnant is deprcated - using fieldops instead
// sounds fixed and added
// Magic : 03.05.2014
// added wm_announce on trigger_run B5 - get the keycard
// added wm_teamvoiceannounce on trigger cap_keycard - get/defend gold
// removed wm_teamvoiceannounce get/defend gold from start
// removed wm_teamvoiceannounce defend/destroy wall - when wall is destroyed
// added wm_announce trigger_run 24 - Truck has arrived at the city gate
game_manager
{
	spawn
	{
		disablespeaker allied_gold_taken
		wm_axis_respawntime 20
		wm_allied_respawntime 15

		wm_number_of_objectives 8
		wm_set_round_timelimit 25
		wait 500
		
		// Objectives
		// 1: City Fence
		// 2: Command Post
		// 3: Restaurant Door
		// 4: Biblioteca Main Door
		// 5: Biblioteca Side Entrance
		// 6: Key
		// 7: Gold
		// 8: Switch
		
		// spawns
		
		setautospawn "Old City"			1
		setautospawn "Old City"			0
		
		wm_objective_status 1 0 0
		wm_objective_status 1 1 0
		wm_objective_status 2 0 0 // status: 0 = default
		wm_objective_status 2 1 0 //		 2 = failed
		wm_objective_status 3 0 0
		wm_objective_status 3 1 0
		wm_objective_status 4 0 0
		wm_objective_status 4 1 0
		wm_objective_status 5 0 0
		wm_objective_status 5 1 0
		wm_objective_status 6 0 0
		wm_objective_status 6 1 0
		wm_objective_status 7 0 0
		wm_objective_status 7 1 0
		wm_objective_status 8 0 0
		wm_objective_status 8 1 0

		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner 0
		wait 450
	    wm_announce	"^1Raid final"

		wait 2000

		// *----------------------------------- vo ------------------------------------------*

		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 0 "oasis_axis_city_defend"
		wm_addteamvoiceannounce 0 "oasis_axis_wall_defend"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_addteamvoiceannounce 1 "oasis_allies_city_capture"
		wm_addteamvoiceannounce 1 "oasis_allies_wall_destroy"
		
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 0 "oasis_axis_city_defend"
		wm_teamvoiceannounce 0 "oasis_axis_wall_defend"

		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 1 "oasis_allies_city_capture"
		wm_teamvoiceannounce 1 "oasis_allies_wall_destroy"
		
		// *---------------------------------------------------------------------------------*

		trigger truck disable_stage1
		setstate goldbar_holder invisible
	}

	trigger checkgame
	{ 
		wm_announce "^3Allied team escaped with the Gold Crate!"
		wm_setwinner 1
		wait 2000
		wm_endround
	}
	
	trigger cap_keycard
	{
		// Cap keycard: true
		wm_objective_status 6 1 1
		wm_objective_status 6 0 2
		// Cap keycard: true
		accum 2 set 1
	
		wm_announce "^3Allied team has used the keycard!"
		
		
		trigger basementgate move_up
		wait 1000
		setstate keycard_cap invisible
		wait 200
		wm_teamvoiceannounce 0 "goldrush_axis_gold_defend"
		wm_teamvoiceannounce 1 "goldrush_allies_gold_get"
		setstate goldbar_holder default
	}

	trigger axis_object_stolen
	{
		//wm_announce	"^3Allies have stolen the Keycard!"
		
		accum 2 set 1
	}

	trigger axis_object_returned
	{
		//wm_announce	"^3The keycard has been returned!"
		
		accum 2 set 0
	}
}

keycard_CMM
{
	spawn
	{
	}
}

keycard_cap
{
	spawn
	{
	}
	death
	{
		trigger game_manager cap_keycard
		trigger keycard_capmodel_red hide
		trigger keycard_capmodel show
	}
}

keycard_capmodel_red
{
	spawn
	{
		wait 100
		trigger self show
	}
	trigger show
	{
		setstate keycard_capmodel_red default
	}
	trigger hide
	{
		setstate keycard_capmodel_red invisible
	}
}

keycard_capmodel
{
	spawn
	{
		wait 100
		trigger self hide
	}
	trigger show
	{
		setstate keycard_capmodel default
	}
	trigger hide
	{
		setstate keycard_capmodel invisible
	}
}

keycard_flag
{
    spawn
    {
	    wait 200
    }
    trigger stolen 
    {
    	// when the objective is taken 
    	// Hide command map marker of keycard at table
    	setstate keycard_CMM invisible 
	}
	trigger dropped
	{
		// when the player carrying the objective is killed 
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_objective_lost"
	}
	trigger returned
	{
		// when defending team touches the dropped objective
		// Show command map marker of keycard at table
		setstate keycard_CMM default
	} 
	trigger captured
	{
		// when the objective is delivered to its deliverypoint 
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_objective_lost"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"
	}
}

oldcityflag
{
	spawn
	{
		accum 0 set 0	// Who has the flag: 0-Axis, 1-Allied
	}

	trigger axis_capture	// Flag has been touched by an Axis player
	{
		accum 0 abort_if_equal 0 // do Axis own flag?

		accum 0 set 0 // Axis own the pole
		wm_announce	"^3Axis reclaim the Old City command room!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "oasis_axis_city_defend"
		wm_addteamvoiceannounce 1 "oasis_allies_city_capture"

		wm_teamvoiceannounce 0 "oasis_axis_city_captured"
		wm_teamvoiceannounce 1 "oasis_allies_city_lost"

		wm_removeteamvoiceannounce 0 "oasis_axis_wall_defend"
		wm_removeteamvoiceannounce 1 "oasis_allies_wall_destroy"

		//wm_objective_status 		4 0 1
		//wm_objective_status 		4 1 2

		alertentity old_city_wobj
	}

	trigger allied_capture	// Flag has been touched by an allied player
	{
		accum 0 abort_if_equal 1 // do Allies own flag?

		accum 0 set 1 // Allied own the flag
		wm_announce	"^3Allies capture the Old City command room!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "oasis_axis_wall_defend"

		wm_addteamvoiceannounce 1 "oasis_allies_wall_destroy"

		wm_teamvoiceannounce 0 "oasis_axis_city_lost"
		wm_teamvoiceannounce 0 "oasis_axis_wall_defend"

		wm_teamvoiceannounce 1 "oasis_allies_city_captured"
		wm_teamvoiceannounce 1 "oasis_allies_wall_destroy"

		wm_removeteamvoiceannounce 0 "oasis_axis_city_defend"

		wm_removeteamvoiceannounce 1 "oasis_allies_city_capture"

		wm_removeteamvoiceannounce 0 "oasis_axis_city_defend"
		wm_removeteamvoiceannounce 1 "oasis_allies_city_capture"

		//wm_objective_status 		4 0 2
		//wm_objective_status 		4 1 1

		alertentity old_city_wobj
	}

	trigger check_obj
	{
		accum 0 abort_if_equal 1 // Do Allied own the flag?

		//wm_objective_status 		4 0 2
		//wm_objective_status 		4 1 1

	}

	trigger force_allied
	{
		accum 0 abort_if_equal 1 // Do Allied own the flag?

		alertentity old_city_wobj
		alertentity oldcityspawns
	}

	trigger kill
	{
		remove
	}
}

basementgate
{
	spawn
	{
		wait 200
		gotomarker basementgate_down 1000
	}
	
	trigger move_up
	{
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav
		wait 400
		playsound sound/movers/misc/garage_door_loop_01.wav looping forever
		gotomarker basementgate_up 50 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav
	}
}	

// **********************************************
// ****************** TRUCK STUFF ***************
// **********************************************

truck_smoke
{
	spawn
	{
		wait 300
		attachtotag truck tag_wfront
		setstate truck_smoke invisible
	}
}

// sound "thread"
truck_engine
{
	spawn
	{
		wait 200
		attachtotag truck tag_wfront

		trigger truck_engine sound_idle
	}

	trigger start
	{
		trigger truck_engine sound_start
		wait 950
		trigger truck_engine sound_move
	}

	trigger stop
	{
		trigger truck_engine sound_stop
		wait 950
		trigger truck_engine sound_idle
	}

	// sound events
	trigger sound_idle
	{
		playsound sound/vehicles/truck/truck_idle.wav looping
	}

	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/truck/truck_revup.wav volume 96
	}

	trigger sound_move
	{
		playsound sound/vehicles/truck/truck_move.wav looping
	}

	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/truck/truck_revdown.wav volume 96
	}

	trigger sound_death
	{
		stopsound
		playsound sound/vehicles/truck/truck_stop.wav volume 96
	}
}

truck_build
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback
	}
}

truck_construct
{
	spawn
	{
		constructible_class 2
		constructible_health 1100
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
	}

	built final
	{
		alertentity truck

		wm_announce "^3The Truck has been repaired!"
	}
}

// digibob: ok, for once i'm gonna PLAN this one, so NOTHING WILL BREAK EVAR
// ============================================================================
// accum 0, gold bars collected
// accum 1
//  - bit 0: barrier 1 status 	( 0 = destroyed, 	1 = built 		)
//  - bit 1: barrier 2 status   ( 0 = destroyed, 	1 = built 		)
//  - bit 2: spline status 		( 0 = not moving, 	1 = moving 		)
//  - bit 3: stuck check flag 	( 0 = not stuck, 	1 = stuck 		)
//  - bit 4: script lockout 	( 0 = no lockout, 	1 = lockout		)
//  - bit 5: Barrier 4 status	( 0 = no lockout, 	1 = lockout		)
//  - bit 6: temp register 		(XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
//  - bit 7: death status 		( 0 = alive, 		1 = dead		)
//  - bit 8: player check 		( 0 = players, 		1 = no players	)
//  - bit 9: visible state		( 0 = alive, 		1 = dead		)
// accum 2, 
// accum 3, current movement loop position
// accum 4, stop counter
// accum 5, blank
// accum 6, blank
// accum 7, blank
// ============================================================================
// spline points are tspln_X with X = 1 to 23
// ============================================================================
// wheel events:
//  - wheels_forward
//  - wheels_backward
//  - wheels_stop

truck
{
	spawn
	{
		faceangles 0 0 0 0
	}

	// ========================================
	// wheeeeeeeeeeeeeeels. eeels. ls.
	trigger wheels_forward
	{
		trigger truck_bwheel2 forward
		trigger truck_fwheel forward
	}

	trigger wheels_backward
	{
		trigger truck_bwheel2 backward
		trigger truck_fwheel backward
	}

	trigger wheels_stop
	{
		trigger truck_bwheel2 stop
		trigger truck_fwheel stop
	}

	// ========================================
	// ========================================

	trigger add_gold
	{
		accum 0 set 1

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "goldrush_axis_gold1_taken"
		wm_removeteamvoiceannounce 1 "goldrush_allies_gold1_taken"

		wm_teamvoiceannounce 0 "goldrush_axis_gold1_secured"
		wm_teamvoiceannounce 1 "goldrush_allies_gold1_secured"

		trigger gold_full show
		trigger gold_trans hide
		trigger clip_gold hide
	}

	// ========================================
	// movement

	trigger move_check
	{
		trigger truck stuck_check
		accum 1 abort_if_bitset 3

		trigger truck dispatch
	}

	trigger move
	{
		trigger truck move_check

		wait 500

		trigger truck move
	}

	// ========================================
	// ========================================

	trigger run_continue
	{
		trigger truck deathcheck
		trigger truck stopcheck
		trigger truck move
	}

	trigger run_1
	{
		accum 1 bitset 2
		followspline 0 tspln_1 100 wait length 304 wait roll 0 2 dampin
		accum 1 bitreset 2

		accum 3 set 1

		trigger truck run_continue
	}
	trigger run_2
	{
		accum 1 bitset 2
		followspline 0 tspln_2 100 wait length 304 wait roll 2 -1 dampout
		accum 1 bitreset 2

		accum 3 set 2
		trigger truck run_continue
	}
	trigger run_3
	{
		accum 1 bitset 2
		followspline 0 tspln_3 100 wait length 304 wait roll 1 -1 dampout
		accum 1 bitreset 2

		accum 3 set 3

		trigger truck run_continue
	}
	trigger run_4
	{
		accum 1 bitset 2
		followspline 0 tspln_4 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 4
		trigger truck run_continue
	}
	trigger run_5
	{
		accum 1 bitset 2
		followspline 0 tspln_5 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 5
		trigger truck run_continue
	}
	trigger run_6
	{
		accum 1 bitset 2
		followspline 0 tspln_6 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 6
		trigger truck run_continue
	}
	trigger run_7
	{
		accum 1 bitset 2
		followspline 0 tspln_7 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 7
		trigger truck run_continue
	}
	trigger run_8
	{
		accum 1 bitset 2
		followspline 0 tspln_8 100 wait length 304
		accum 1 bitreset 2
		accum 3 set 8
		trigger truck run_continue
	}
	trigger run_9
	{
		accum 1 bitset 2
		followspline 0 tspln_9 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 9
		trigger truck run_continue
	}
	trigger run_10
	{
		accum 1 bitset 2
		followspline 0 tspln_10 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 10
		trigger truck run_continue
	}
	trigger run_11
	{
		accum 1 bitset 2
		followspline 0 tspln_11 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 11
		trigger truck run_continue
	}
	trigger run_12
	{
		accum 1 bitset 2
		followspline 0 tspln_12 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 12
		trigger truck run_continue
	}
	trigger run_13
	{
		accum 1 bitset 2
		followspline 0 tspln_13 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 13
		trigger truck run_continue
	}
	trigger run_14
	{
		accum 1 bitset 2
		followspline 0 tspln_14 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 14
		trigger truck run_continue
	}
	trigger run_15
	{
		accum 1 bitset 2
		followspline 0 tspln_15 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 15
		trigger truck run_continue
	}
	trigger run_16
	{
		accum 1 bitset 2
		followspline 0 tspln_16 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 16
		trigger truck run_continue
	}
	trigger run_17
	{
		accum 1 bitset 2
		followspline 0 tspln_17 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 17
		trigger truck run_continue
	}
	trigger run_18
	{
		accum 1 bitset 2
		followspline 0 tspln_18 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 18
		trigger truck run_continue
	}
	trigger run_19
	{
		accum 1 bitset 2
		followspline 0 tspln_19 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 19
		trigger truck run_continue
	}
	trigger run_20
	{
		accum 1 bitset 2
		followspline 0 tspln_20 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 20
		trigger truck run_continue
	}
	trigger run_21
	{
		accum 1 bitset 2
		followspline 0 tspln_21 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 21
		trigger truck run_continue
	}
	trigger run_22
	{
		accum 1 bitset 2
		followspline 0 tspln_22 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 22
		trigger truck run_continue
	}
	trigger run_23
	{
		accum 1 bitset 2
		followspline 0 tspln_23 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 23
		trigger truck run_continue
	}
	trigger run_24
	{
		accum 1 bitset 2
		followspline 0 tspln_24 100 wait length 304 
		accum 1 bitreset 2
		
		wm_announce	 "Truck has arrived at the city gate"
		wm_teamvoiceannounce 0 "oasis_axis_wall_defend"
		wm_teamvoiceannounce 1 "oasis_allies_wall_destroy"

		accum 3 set 24
		trigger truck run_continue
	}
	trigger run_25
	{
		accum 1 bitset 2
		followspline 0 tspln_25 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 25
		trigger truck run_continue
	}
	trigger run_26
	{
		accum 1 bitset 2
		followspline 0 tspln_26 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 26
		trigger truck run_continue
	}
	trigger run_27
	{
		accum 1 bitset 2
		followspline 0 tspln_27 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 27
		trigger truck run_continue
	}
	trigger run_28
	{
		accum 1 bitset 2
		followspline 0 tspln_28 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 28
		trigger truck run_continue
	}
	trigger run_29
	{
		accum 1 bitset 2
		followspline 0 tspln_29 100 wait length 304 
		accum 1 bitreset 2
		
		accum 3 set 29
		trigger truck run_continue
	}
	trigger run_30
	{
		accum 1 bitset 2
		followspline 0 tspln_30 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 30
		trigger truck run_continue
	}
	trigger run_31
	{
		accum 1 bitset 2
		followspline 0 tspln_31 100 wait length 304 
		accum 1 bitreset 2
		
		accum 3 set 31
		trigger truck run_continue
	}
	trigger run_32
	{
		accum 1 bitset 2
		followspline 0 tspln_32 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 32
		trigger truck run_continue
	}
	trigger run_33
	{
		accum 1 bitset 2
		followspline 0 tspln_33 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 33
		trigger truck run_continue
	}
	trigger run_34
	{
		accum 1 bitset 2
		followspline 0 tspln_34 100 wait length 304 
		
		trigger truck_engine stop
		trigger truck wheels_stop
		//wait 600
		
		accum 1 bitreset 2
		accum 3 set 34
		accum 6 set 1			// set reverse flag
		trigger truck run_continue
		
		// reverse path .....
	}
	trigger run_b1
	{
		trigger truck wheels_backward	// start wheels backward
		accum 1 bitset 2
		followspline 1 tspln_spb0 50 wait length 304
		accum 1 bitreset 2
		
		accum 3 set 35
		trigger truck run_continue
	}
	trigger run_b2
	{	
		trigger truck wheels_backward
		accum 1 bitset 2
		followspline 1 tspln_spb1 50 wait length 304 
		accum 1 bitreset 2
		
		accum 3 set 36
		trigger truck run_continue
	}
	trigger run_b3
	{	
		trigger truck wheels_backward
		accum 1 bitset 2
		followspline 1 tspln_spb2 50 wait length 304 
		accum 1 bitreset 2
		
		//wm_teamvoiceannounce 1 "sound/vo/general/allies/hq_truckesc_b.wav"
		accum 3 set 37
		trigger truck run_continue
	}
	trigger run_b4
	{	
		trigger truck wheels_backward
		accum 1 bitset 2					// set spline flag to moving
		followspline 1 tspln_spb3 50 wait length 304 
		accum 1 bitreset 2
		accum 3 set 38						// increment run flag
		
		trigger truck run_continue
	}
	trigger run_b5
	{	
		trigger truck wheels_backward
		accum 1 bitset 2					// set spline flag to moving
		followspline 1 tspln_spb4 50 wait length 304 
		accum 6 set 1
		accum 1 bitreset 2
		trigger keypanel move_side2
		wm_announce  "The truck has arrived at the library. The keycard safe is open now."
		wm_announce	"^3Steal the keycard"
		accum 3 set 39						// increment run flag
	
		trigger truck run_continue
		//trigger truck_engine sound_death
		//trigger self wheels_stop
		
	}
	
	trigger run_39
	{
		//trigger truck wheels_forward
		accum 1 bitset 2
		followspline 0 tspln_39 100 wait length 304 
		
		accum 1 bitreset 2

		accum 3 set 40
		trigger truck run_continue
	}
	trigger run_40
	{
		accum 1 bitset 2
		followspline 0 tspln_40 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 41
		trigger truck run_continue
	}
	trigger run_41
	{
		accum 1 bitset 2
		followspline 0 tspln_41 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 42
		trigger truck run_continue
	}
	trigger run_42
	{
		accum 1 bitset 2
		followspline 0 tspln_42 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 43
		//trigger switch_invtrig1 enable
		trigger truck run_continue
	}
	trigger run_43
	{
		accum 1 bitset 2
		followspline 0 tspln_43 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 44
		trigger truck run_continue
	}
	trigger run_44
	{
		trigger switch_invtrig1 disable
		accum 1 bitset 2
		followspline 0 tspln_44 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 45
		trigger truck run_continue
	}
	trigger run_45
	{
		accum 1 bitset 2
		followspline 0 tspln_45 100 wait length 304
		accum 1 bitreset 2
		wm_removeteamvoiceannounce 1 "railgun_allies_switch_raise"
		wm_removeteamvoiceannounce 0 "railgun_axis_switch_lower"
		accum 3 set 46
		trigger truck run_continue
	}
	trigger run_46
	{
		accum 1 bitset 2
		followspline 0 tspln_46 100 wait length 304
		accum 1 bitreset 2
		wm_teamvoiceannounce 0 "sound/vo/general/axis/hq_truckstop_b.wav"
		accum 3 set 47
		trigger truck run_continue
	}
	trigger run_47
	{
		accum 1 bitset 2
		followspline 0 tspln_47 100 wait length 304
		accum 1 bitreset 2
		wm_teamvoiceannounce 0 "sound/vo/general/axis/hq_truckstop_a.wav"
		accum 3 set 48
		trigger truck run_continue
	}
	trigger run_48
	{
		accum 1 bitset 2
		followspline 0 tspln_48 100 wait length 304
		accum 1 bitreset 2
		wm_teamvoiceannounce 0 "sound/chat/axis/942b.wav"
		wm_teamvoiceannounce 1 "sound/chat/allies/77b.wav"
		accum 3 set 49
		trigger truck run_continue
	}
	trigger run_49
	{
		accum 1 bitset 2
		followspline 0 tspln_49 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 50
		trigger truck run_continue
	}
	trigger run_50
	{
		accum 1 bitset 2
		followspline 0 tspln_50 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 51
		trigger truck run_continue
	}
	trigger run_51
	{
		accum 1 bitset 2
		followspline 0 tspln_51 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 52
		trigger truck run_continue
	}
	trigger run_52
	{
		accum 1 bitset 2
		followspline 0 tspln_52 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 53
		trigger truck run_continue
	}
	trigger run_53
	{
		accum 1 bitset 2
		followspline 0 tspln_53 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 54
		trigger truck run_continue
	}
	trigger run_54
	{
		accum 1 bitset 2
		followspline 0 tspln_54 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 55
		trigger truck run_continue
	}
	trigger run_55
	{
		accum 1 bitset 2
		followspline 0 tspln_55 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 56
		trigger truck run_continue
	}
	trigger run_56
	{
		accum 1 bitset 2
		followspline 0 tspln_56 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 57
		trigger truck run_continue
	}
	trigger run_57
	{
		accum 1 bitset 2
		followspline 0 tspln_57 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 58
		trigger truck run_continue
	}
	trigger run_58
	{
		accum 1 bitset 2
		followspline 0 tspln_58 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 59
		trigger truck run_continue
	}
	trigger run_59
	{
		accum 1 bitset 2
		followspline 0 tspln_59 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 60
		trigger truck run_continue
	}
	trigger run_60
	{
		accum 1 bitset 2
		followspline 0 tspln_60 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 61
		trigger truck run_continue
	}
	trigger run_61
	{
		accum 1 bitset 2
		followspline 0 tspln_61 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 62
		trigger truck run_continue
	}
	trigger run_62
	{
		accum 1 bitset 2
		followspline 0 tspln_62 100 wait length 304 
		accum 1 bitreset 2

		accum 3 set 63
		trigger truck run_continue
	}
	trigger run_63
	{
		accum 1 bitset 2
		followspline 0 tspln_63 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 64
		trigger truck run_continue
	}
	trigger run_64
	{
		accum 1 bitset 2
		followspline 0 tspln_64 100 wait length 304
		accum 1 bitreset 2
					
		accum 3 set 65
		trigger truck run_continue
	}
	trigger run_65
	{
		accum 1 bitset 2
		followspline 0 tspln_65 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 66
		trigger truck run_continue
	}
	trigger run_66
	{
		accum 1 bitset 2
		followspline 0 tspln_66 100 wait length 304
		accum 1 bitreset 2
		trigger truck stuck_check_barrier4_built_msg
		accum 3 set 67
		trigger truck run_continue
	}
	trigger run_67
	{
		trigger defense4 remove
		accum 1 bitset 2
		followspline 0 tspln_67 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 68
		trigger truck run_continue
	}
	trigger run_68
	{
		accum 1 bitset 2
		followspline 0 tspln_68 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 69
		trigger truck run_continue
	}
	trigger run_69
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_truck_barrier2"

		wm_teamvoiceannounce 1 "goldrush_allies_truck_barrier2"

		accum 1 bitset 2
		followspline 0 tspln_69 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 70
		trigger truck run_continue
	}
	trigger run_70
	{
		accum 1 bitset 2
		followspline 0 tspln_70 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 71
		trigger truck run_continue
	}
	trigger run_71
	{
		accum 1 bitset 2
		followspline 0 tspln_71 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 72
		trigger truck run_continue
	}
	trigger run_72
	{
		accum 1 bitset 2
		followspline 0 tspln_72 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 73
		trigger truck run_continue
	}
	trigger run_73
	{
		accum 1 bitset 2
		followspline 0 tspln_73 100 wait length 304
		accum 1 bitreset 2
		accum 3 set 74
		trigger truck run_continue
	}
	trigger run_74
	{
		accum 1 bitset 2
		followspline 0 tspln_74 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 75
		trigger game_manager checkgame
		trigger truck run_continue
	}
	trigger run_75
	{
		accum 1 bitset 2
		followspline 0 tspln_75 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 76
		trigger truck run_continue
	}
	trigger run_76
	{
		accum 1 bitset 2
		followspline 0 tspln_76 100 wait length 304
		accum 1 bitreset 2

		accum 3 set 77
		trigger truck wheels_stop
	}
	
	trigger dispatch
	{
		accum 3 trigger_if_equal 0 	truck run_1
		accum 3 trigger_if_equal 1 	truck run_2
		accum 3 trigger_if_equal 2	truck run_3
		accum 3 trigger_if_equal 3 	truck run_4
		accum 3 trigger_if_equal 4 	truck run_5
		accum 3 trigger_if_equal 5 	truck run_6
		accum 3 trigger_if_equal 6 	truck run_7
		accum 3 trigger_if_equal 7 	truck run_8
		accum 3 trigger_if_equal 8 	truck run_9
		accum 3 trigger_if_equal 9 	truck run_10
		accum 3 trigger_if_equal 10	truck run_11
		accum 3 trigger_if_equal 11	truck run_12
		accum 3 trigger_if_equal 12	truck run_13
		accum 3 trigger_if_equal 13	truck run_14
		accum 3 trigger_if_equal 14	truck run_15
		accum 3 trigger_if_equal 15 truck run_16
		accum 3 trigger_if_equal 16 truck run_17
		accum 3 trigger_if_equal 17 truck run_18
		accum 3 trigger_if_equal 18 truck run_19
		accum 3 trigger_if_equal 19 truck run_20
		accum 3 trigger_if_equal 20	truck run_21
		accum 3 trigger_if_equal 21	truck run_22
		accum 3 trigger_if_equal 22	truck run_23
		accum 3 trigger_if_equal 23	truck run_24
		accum 3 trigger_if_equal 24	truck run_25
		accum 3 trigger_if_equal 25 truck run_26
		accum 3 trigger_if_equal 26 truck run_27
		accum 3 trigger_if_equal 27 truck run_28
		accum 3 trigger_if_equal 28 truck run_29
		accum 3 trigger_if_equal 29 truck run_30
		accum 3 trigger_if_equal 30	truck run_31
		accum 3 trigger_if_equal 31	truck run_32
		accum 3 trigger_if_equal 28 truck run_29
		accum 3 trigger_if_equal 29 truck run_30
		accum 3 trigger_if_equal 30	truck run_31
		accum 3 trigger_if_equal 31	truck run_32
		accum 3 trigger_if_equal 32	truck run_33
		accum 3 trigger_if_equal 33	truck run_34

		accum 3 trigger_if_equal 34	truck run_b1
		accum 3 trigger_if_equal 35	truck run_b2
		accum 3 trigger_if_equal 36	truck run_b3
		accum 3 trigger_if_equal 37	truck run_b4
		accum 3 trigger_if_equal 38	truck run_b5
		
		accum 3 trigger_if_equal 39 truck run_39
		accum 3 trigger_if_equal 40 truck run_40
		accum 3 trigger_if_equal 41 truck run_41
		accum 3 trigger_if_equal 42 truck run_42
		accum 3 trigger_if_equal 43 truck run_43
		accum 3 trigger_if_equal 44 truck run_44 
		accum 3 trigger_if_equal 45 truck run_45
		accum 3 trigger_if_equal 46 truck run_46
		accum 3 trigger_if_equal 47 truck run_47
		accum 3 trigger_if_equal 48	truck run_48
		accum 3 trigger_if_equal 49	truck run_49
		accum 3 trigger_if_equal 50	truck run_50
		accum 3 trigger_if_equal 51	truck run_51
		accum 3 trigger_if_equal 52	truck run_52
		accum 3 trigger_if_equal 53	truck run_53
		accum 3 trigger_if_equal 54	truck run_54
		accum 3 trigger_if_equal 55	truck run_55
		accum 3 trigger_if_equal 56	truck run_56
		accum 3 trigger_if_equal 57	truck run_57
		accum 3 trigger_if_equal 58	truck run_58
		accum 3 trigger_if_equal 59	truck run_59
		accum 3 trigger_if_equal 60	truck run_60
		accum 3 trigger_if_equal 61	truck run_61
		accum 3 trigger_if_equal 62	truck run_62
		accum 3 trigger_if_equal 63	truck run_63
		accum 3 trigger_if_equal 64	truck run_64
		accum 3 trigger_if_equal 65	truck run_65
		accum 3 trigger_if_equal 66	truck run_66
		accum 3 trigger_if_equal 67	truck run_67
		accum 3 trigger_if_equal 68	truck run_68
		accum 3 trigger_if_equal 69	truck run_69
		accum 3 trigger_if_equal 70	truck run_70
		accum 3 trigger_if_equal 71	truck run_71
		accum 3 trigger_if_equal 72	truck run_72
		accum 3 trigger_if_equal 73	truck run_73
		accum 3 trigger_if_equal 74	truck run_74
		accum 3 trigger_if_equal 75	truck run_75
		accum 3 trigger_if_equal 76	truck run_76
	}

	// ========================================
	// barrier checking
	// digibob: since we cant return variables, just use bit 3 of accum 1 as a register... mmmm assembly......

	trigger stuck_check
	{
		accum 1 bitreset 3
		trigger truck stuck_check_gold
		trigger truck stuck_check_door
		trigger truck stuck_check_scriptlockout
		trigger truck stuck_check_barrier_moving
		trigger truck stuck_check_barrier4
		trigger truck stuck_check_finished
	}

	trigger stuck_check_finished
	{
		accum 3 abort_if_not_equal 75

		accum 1 bitset 3
	}

	trigger stuck_check_scriptlockout
	{
		accum 1 abort_if_not_bitset 4

		accum 1 bitset 3
	}

	trigger stuck_check_gold
	{
		accum 3 abort_if_not_equal 39

		accum 0 abort_if_not_equal 0

		accum 1 bitset 3
	}

	trigger stuck_check_door
	{
		accum 3 abort_if_not_equal 24

		accum 5 abort_if_not_equal 0

		accum 1 bitset 3
	}
	trigger stuck_check_barrier_moving
	{
		accum 3 abort_if_not_equal 44

		accum 1 abort_if_not_bitset 1

		accum 1 bitset 3
	}
	
	trigger stuck_check_barrier4
	{
		accum 3 abort_if_not_equal 67

		accum 1 abort_if_not_bitset 5

		accum 1 bitset 3
	}

	trigger stuck_check_barrier4_built_msg
	{
		accum 1 abort_if_not_bitset 5

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_truckbar_destroy"
	}

	// ========================================
	// stop check

	trigger stopcheck_setup
	{
		accum 1 bitset 6				// stop if we're stuck/no-one's pushing :)

		accum 1 abort_if_bitset 8		// no one in the trigger, abort

		trigger truck stuck_check		// call the stop check function
		accum 1 abort_if_bitset 3		// we're stuck so break out

		accum 1 bitreset 6				// we're free to keep going
	}

	trigger stopcheck
	{
		trigger truck stopcheck_setup
		accum 1 abort_if_not_bitset 6

		trigger truck script_lockout

		// Any just stopped moving stuff goes here
		trigger truck_engine stop
		trigger truck 		wheels_stop
		// <<<<< stop animation goes here

		trigger truck script_lockout_stop
		resetscript
	}

	// ========================================
	// ========================================

	// ========================================
	// script lockouts

	trigger script_lockout
	{
		accum 1 bitset 4
	}

	trigger script_lockout_stop
	{
		accum 1 bitreset 4
	}

	// ========================================
	// ========================================

	// ========================================
	// enable/disable

	trigger truck_enable
	{
		trigger truck stuck_check
		accum 1 abort_if_bitset 3 	// stuck check

		accum 4 set 0				// reset stop counter
		accum 1 bitreset 8			// reset stop check

		accum 1 abort_if_bitset 2 	// already following spline
		accum 1 abort_if_bitset 4 	// script lockout

		accum 1 abort_if_bitset 7 	// death check

		// Any just started moving stuff goes here
		trigger truck_engine start
		trigger truck wheels_forward
		// <<<<< start animation goes here
		trigger truck move
	}

	trigger truck_disable
	{
		accum 4 inc 1				// up the stop counter
		accum 4 abort_if_less_than 2

		accum 1 bitset 8			// set stop check

		trigger truck deathcheck
	}

	// ========================================
	// ========================================

	// ========================================
	// death / rebirth

	rebirth
	{
		accum 1 bitreset 7 // we're alive again
		accum 1 bitreset 9 // we're visibly alive

		changemodel models/mapobjects/blitz_sd/blitzbody.md3

		setstate truck_smoke invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_truck_repaired_allies"

		wm_teamvoiceannounce 1 "allies_hq_truck_repaired"

		trigger truck move
	}

	death
	{
		accum 1 bitset 7
	}

	trigger deathcheck
	{
		accum 1 abort_if_not_bitset 7	// are we dead?
		accum 1 abort_if_bitset 9		// are we not already visibly dead?
		accum 1 abort_if_bitset 2		// are we not following a spline?
		accum 1 abort_if_bitset 4		// are we not in a script lockout?

		accum 1 bitset 9				// we're now visibly dead

		wm_announce "^3The Truck has been damaged!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_truck_damaged"

		wm_teamvoiceannounce 1 "allies_hq_truck_damaged_axis"

		setstate truck_smoke default
		kill truck_construct

		trigger truck_engine sound_death
		//trigger truck tracks_stop		// truck with tracks? i don't think so
		trigger truck wheels_stop
		// <<<< stop anim goes here

		changemodel models/mapobjects/blitz_sd/blitzbody_damaged.md3

		resetscript
	}

	// ========================================
	// Switch	
	// ========================================

	trigger switch_open
	{
		accum 1 bitreset 1
	}

	trigger switch_closed
	{
		accum 1 bitset 1
	}

	// ========================================
	// Barrier 4
	// ========================================
	trigger enable_stage2
	{
		accum 1 bitreset 5
	}

	trigger disable_stage2
	{
		accum 1 bitset 5
	}

	// ========================================

	trigger door_destroyed
	{
		accum 5 set 1
	}

	// ========================================
}

truck_bwheel2
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback
	}

	trigger forward
	{
		setrotation 130 0 0
	}

	trigger backward
	{
		setrotation -130 0 0
	}

	trigger stop
	{
		stoprotation
	}
}

truck_fwheel
{
	spawn
	{
		wait 500

		attachtotag truck tag_wfront
	}

	trigger forward
	{
		setrotation 130 0 0
	}

	trigger backward
	{
		setrotation -130 0 0
	}

	trigger stop
	{
		stoprotation
	}
}

truck_trigger
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback
	}
}

truck_disabler
{
	trigger run
	{
		trigger truck truck_disable
	}
}

truck_enabler
{
	trigger run
	{
		trigger truck truck_enable
	}
}

// *********************************************
// ****************** Gold STUFF ***************
// *********************************************

goldbar_holder
{
	spawn
	{
		wait 500
		attachtotag truck tag_wback
	}
	death
	{
		wait 200
		trigger truck add_gold
		disablespeaker allied_gold_taken
	}
}

//------------
//--- Gold ---
//------------

gold
{
	spawn
	{
		wait 500
	}
	trigger stolen
	{
		enablespeaker allied_gold_taken
		setstate gold_toi invisible
		setstate gold_cm_marker invisible
		setstate clip_gold_stat invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "goldrush_axis_gold_defend"
		wm_addteamvoiceannounce 0 "goldrush_axis_gold1_taken"

		wm_removeteamvoiceannounce 1 "goldrush_allies_gold_get"
		wm_addteamvoiceannounce 1 "goldrush_allies_gold1_taken"

		wm_teamvoiceannounce 0 "goldrush_axis_gold1_taken"

		wm_teamvoiceannounce 1 "goldrush_allies_gold1_taken"
		// *---------------------------------------------------------------------------------*
		
		wm_objective_status 7 0 2
		wm_objective_status 7 1 1
	}
	trigger returned
	{
		disablespeaker allied_gold_taken
		setstate gold_toi default
		setstate gold_cm_marker default
		setstate clip_gold_stat default

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_gold_defend"
		wm_removeteamvoiceannounce 0 "goldrush_axis_gold1_taken"

		wm_addteamvoiceannounce 1 "goldrush_allies_gold_get"
		wm_removeteamvoiceannounce 1 "goldrush_allies_gold1_taken"

		wm_teamvoiceannounce 0 "goldrush_axis_gold1_returned"
		wm_teamvoiceannounce 0 "goldrush_axis_gold_defend"

		wm_teamvoiceannounce 1 "goldrush_allies_gold1_returned"
		wm_teamvoiceannounce 1 "goldrush_allies_gold_get"
		// *---------------------------------------------------------------------------------*
		
		wm_objective_status 7 0 1
		wm_objective_status 7 1 2
	}
	trigger captured
	{
	}
}

//--------------
//--- Models ---
//--------------

gold_full
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 1
		
		setstate gold_full invisible
	}

	trigger show
	{
		setstate gold_full default
	}
}
gold_trans
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 1
	}

	trigger hide
	{
		setstate gold_trans invisible
	}
}
clip_gold
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 1

		setstate clip_gold invisible
	}

	trigger hide
	{
		setstate clip_gold default
	}
}

// ================================================
// ============ NEUTRAL COMMAND POST ==============
// ================================================

allied_compost_built
{
	spawn
	{
		wait 400
		trigger allied_compost_built setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 fieldops 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0
	}

	buildstart final
	{
		setstate allied_compost_built_model underconstruction
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
	}

	built final
	{
		setstate allied_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible

		trigger allied_compost_built_model enable_allied_features

		enablespeaker allies_compost_sound
	}

	decayed final
	{
		setstate allied_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default
	}

	death
	{
		setstate allied_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default

		trigger allied_compost_built_model disable_allied_features

		disablespeaker allies_compost_sound
	}
}

allied_compost_built_model
{
	spawn
	{
		wait 400
		setstate allied_compost_built_model invisible
	}

	trigger enable_allied_features
	{
		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 fieldops 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75
		sethqstatus 1 1

		wm_announce	"^3Allied Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_objective_status 2 0 2
		wm_objective_status 2 1 1
	}

	trigger disable_allied_features
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 fieldops 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0

		wm_announce	"^3Axis team has destroyed the Allied Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"

		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
	}
}

axis_compost_built
{
	spawn
	{
		wait 400
		trigger axis_compost_built setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 fieldops 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0
	}

	buildstart final
	{
		setstate axis_compost_built_model underconstruction
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
	}

	built final
	{
		setstate axis_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible

		trigger axis_compost_built_model enable_axis_features

		enablespeaker axis_compost_sound
	}

	decayed final
	{
		setstate axis_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default
	}

	death
	{
		setstate axis_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default

		trigger axis_compost_built_model disable_axis_features

		disablespeaker axis_compost_sound
	}
}

axis_compost_built_model
{
	spawn
	{
		wait 400
		setstate axis_compost_built_model invisible
	}

	trigger enable_axis_features
	{
		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 fieldops 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75
		sethqstatus 0 1

		wm_announce	"^3Axis Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_objective_status 2 0 1
		wm_objective_status 2 1 2
	}

	trigger disable_axis_features
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 fieldops 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0

		wm_announce	"^3Allied team has destroyed the Axis Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"

		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
	}
}

// =====================================
// ============ Main Door ==============
// =====================================
dynadoor
{ 
	spawn 
	{ 
		wait 200 
		constructible_class 3
		accum 3 set 0
		setstate door1 default
		setstate dynadoor_destroyed invisible
	} 

	death 
	{ 
		setstate dynadoor_destroyed default
		setstate door1 invisible
		setautospawn "Axis Courtyard"			0
		
		trigger oldcityflag force_allied // Switch forward spawn to Allied ONLY

		trigger oldcityflag check_obj

		trigger oldcityflag kill

		trigger truck door_destroyed

		wm_announce "^3Allies have breached the fence!" 
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "hq_objdest_axis"
		wm_teamvoiceannounce 1 "hq_objdest_allies"
		
		wm_removeteamvoiceannounce 0 "oasis_axis_wall_defend"
		wm_removeteamvoiceannounce 1 "oasis_allies_wall_destroy"
		
		wm_objective_status 1 0 2
		wm_objective_status 1 1 1
	}
}



//----------------------
//--- Moving barrier ---
//----------------------

switchlever
{
	spawn
	{
		trigger self init	// display of any subsequent "Track Barrier closed!" messages - tim
	}

	trigger init
	{
		faceangles 0 0 0 1000
		trigger switchbarrier close
	}

	trigger close
	{
		faceangles 0 0 0 1000
		playsound sound/movers/switches/butn2.wav
		trigger switchbarrier close

		wm_announce	"^3Track Switch lowered!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 1 "railgun_allies_switch_raise"
		wm_removeteamvoiceannounce 0 "railgun_axis_switch_lower"
		wm_teamvoiceannounce 0 "railgun_axis_switch_lowered"

		wm_teamvoiceannounce 1 "railgun_allies_switch_lowered"
		wm_teamvoiceannounce 1 "railgun_allies_switch_raise"
		
	 	wm_objective_status 8 0 1
	 	wm_objective_status 8 1 2
	}

	trigger open
	{
		faceangles -90 0 0 1000
		playsound sound/movers/switches/switch.wav
		trigger switchbarrier open

		wm_announce	"^3Track Switch raised!"

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 1 "railgun_allies_switch_raise"
		wm_addteamvoiceannounce 0 "railgun_axis_switch_lower"

		wm_teamvoiceannounce 0 "railgun_axis_switch_raised"
		wm_teamvoiceannounce 0 "railgun_axis_switch_lower"

		wm_teamvoiceannounce 1 "railgun_allies_switch_raised"
		
		wm_objective_status 8 0 2
		wm_objective_status 8 1 1
	}
}

switchbarrier
{
	spawn
	{
		trigger self close
	}

	trigger close
	{
		faceangles 90 0 0 2000
		wait 2000
		trigger switch_invtrig1 enable
		trigger truck switch_closed
	}

	trigger open
	{
		faceangles 0 0 0 2000
		wait 2000
		trigger switch_invtrig1 enable
		trigger truck switch_open
	}
}

switch_invtrig1
{
	spawn
	{
		wait 1000
		trigger truck switch_closed
		accum 3 set 0 // Which team is the switch being closed beneficial to? (0=Axis, 1=Allies)
		accum 4 set 0
	}

	trigger enable
	{
		accum 0 set 0
	}

	trigger disable
	{
		accum 0 set 1
	}

	activate axis
	{
		accum 0 abort_if_equal 1
		trigger self axisclose
	}

	activate allies
	{
		accum 0 abort_if_equal 1
		trigger self alliesopen
	}

	trigger axisclose
	{
		accum 4 abort_if_not_equal 1		
		accum 3 abort_if_not_equal 1
		accum 3 set 0
		trigger self close
	}
	trigger alliesopen
	{
		accum 3 abort_if_not_equal 0
		accum 3 set 1
		accum 4 set 1
		trigger self open
	}
	trigger open
	{
		accum 0 abort_if_equal 1
		trigger self disable
		trigger switchlever open
	}
	trigger close
	{
		accum 0 abort_if_equal 1
		trigger self disable
		trigger switchlever close
	}
}

gate1
{
	spawn
	{
		wait 200
		constructible_class 2
		constructible_chargebarreq 1.2
		trigger self startup
	}

	built final
	{
		setstate gate1_mat invisible

		wm_announce "^3Axis team have constructed the Restaurant Door"
		// TODO: add sound
		wm_objective_status 3 0 1
		wm_objective_status 3 1 2
	}

	decayed final
	{
		trigger self startup
	}

	death
	{
		trigger self startup

		wm_announce "^3Allied team have destroyed the Restaurant Door"
		// TODO: add sound
		wm_objective_status 3 0 2
		wm_objective_status 3 1 1
	}

	trigger startup
	{
		setstate gate1_mat default
	}
}

lib2
{
	spawn
	{
		wait 200
		constructible_class 2
		constructible_chargebarreq 1.2
		setstate lib2_mat invisible
	}

	built final
	{
		setstate lib2_mat invisible

		wm_announce "^3Axis team have constructed the Biblioteca Side Entrance"
		// TODO: add sound
		wm_objective_status 5 0 1
		wm_objective_status 5 1 2
	}

	decayed final
	{
		trigger self startup
	}

	death
	{
		trigger self startup
		setstate lib2_mat default

		wm_announce "^3Allied team have destroyed the Biblioteca Side Entrance"
		// TODO: add sound
		wm_objective_status 5 0 2
		wm_objective_status 5 1 1
	}

	
}

/////Keypanel

    keypanel
{
	spawn
	{
		wait 200
		gotomarker keypanel_locked 1000
	}
	
	trigger move_side2
	{
		wait 500
		gotomarker keypanel_open 50 wait
	}
}

//**************
//**** Door ****
//**************

ldoor
{ 
	spawn 
	{ 
		wait 200 
		constructible_class 2 
		constructible_constructxpbonus 10
		constructible_destructxpbonus 8
		trigger self startup 
	} 

	buildstart final 
	{ 
	} 

	built final 
	{  
		setstate doorlib_materials invisible
		setstate libdoor_destroyed invisible 
		setstate constlib_door default
		setstate libdoor default
		wm_announce "^3Axis team has built the Library Main door!" 
		// TODO: add sound
		wm_objective_status 4 0 1
		wm_objective_status 4 1 2
	} 

	decayed final 
	{ 
		trigger self startup 
	} 

	death 
	{ 
		trigger self startup 
		wm_announce "^3Allied team has destroyed the Library Main Door!" 
		// TODO: add sound
		wm_objective_status 4 0 2
		wm_objective_status 4 1 1
	} 

	trigger startup 
	{ 
		setstate constlib_door invisible
		setstate libdoor invisible
		setstate doorlib_materials default
		setstate libdoor_destroyed default  
	} 
}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Sewer Door Allied
//////////////////////////////////////////////////////////////////////////////////////////////////
allyright_dummy_script
{
	spawn
	{
    	wait 200
    	constructible_class 2
    	setstate allyright invisible
    	setstate axisright_dummy_trigger invisible
    	setstate allyright_dummy_trigger default
   	}

	buildstart final
	{
		wm_announce   "^1Allied team is engineering on the Sewer door!"
		// TODO: add sound
	}

	built final
	{
	    setstate allyright default
    	setstate axisright invisible
    	wm_announce   "^1Allied team has locked the Sewer door!"
    	// TODO: add sound
    	alertentity axisright_dummy
    	setstate axisright_dummy_trigger default
    	setstate allyright_dummy_trigger invisible
	}

	death
	{
		setstate axisright default
    	setstate allyright invisible
    	wm_announce   "^1Allied team has locked the Sewer door!"
    	// TODO: add sound
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Sewer Door Axis
//////////////////////////////////////////////////////////////////////////////////////////////////
axisright_dummy_script
{
	spawn
	{
    	wait 200
    	constructible_class 2
   	}

	buildstart final
	{
		wm_announce   "^1Axis team is engineering on the Sewer door!"
		// TODO: add sound
	}

	built final
	{
	    setstate axisright default
    	setstate allyright invisible
    	alertentity allyright_dummy
    	setstate axisright_dummy_trigger invisible
    	setstate allyright_dummy_trigger default
    	wm_announce   "^1Axis team has locked the Sewer door!"
    	// TODO: add sound
	}

	death
	{
		setstate allyright default
    	setstate axisright invisible
    	wm_announce   "^1Axis team has locked the Sewer door!"
    	// TODO: add sound
	}
}

// Axis ONLY
mg42_clip_2
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class	2
	}

	trigger setup
	{
		setstate mg42_2 invisible

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	buildstart final
	{
		setstate mg42_2 underconstruction

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	built final
	{
		setstate mg42_2 default

		setstate mg42_materials_2 invisible
		setstate mg42_materials_clip_2 invisible
		setstate mg42_flag_2 invisible
		wm_announce "The Axis Churchtower MG Nest has been constructed."
	}

	decayed final
	{
		setstate mg42_2 invisible

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	death
	{
		setstate mg42_2 invisible
		repairmg42 mg42_2
		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
		wm_announce "The Axis Churchtower MG Nest has been destroyed."
	}
}


defense4
{
	spawn
	{
		wait 400
		trigger defense4 setup

		constructible_class 3
	}

	trigger setup
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default

		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible
	}

	buildstart final
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default

		setstate defense4_wire underconstruction
		setstate defense4_hurt underconstruction
		setstate defense4_teeth1 underconstruction
		setstate defense4_teeth2 underconstruction
	}

	built final
	{
		setstate defense4_materials invisible
		setstate defense4_materials_clip invisible
		setstate defense4_flag invisible

		setstate defense4_wire default
		setstate defense4_hurt default
		setstate defense4_teeth1 default
		setstate defense4_teeth2 default

		trigger truck disable_stage2

		wm_announce "^3Truck Barrier has been constructed."
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_truckbar_constructed"

		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbars_construct"
	}

	decayed final
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default

		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible
	}

	death
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default

		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible

		trigger truck enable_stage2

		wm_announce "^3Truck Barrier has been destroyed."
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_truckbar_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_truckbar_destroyed"
		wm_teamvoiceannounce 1 "goldrush_allies_truckbar_destroyed"
	}

	trigger remove
	{
		setstate defense4_toi invisible
		setstate defense4_materials invisible
		setstate defense4_materials_clip invisible
		setstate defense4_flag invisible
		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbars_construct"

		wm_removeteamvoiceannounce 1 "goldrush_allies_truckbar_destroy"
		wm_removeteamvoiceannounce 1 "goldrush_allies_truckbars_destroy"
	}
}
