//
// Map: U-Boot
// BSP: uboot
// Author: Ringa
// Script: SteelRat

game_manager
{
	spawn
	{
		// Game rules
		wm_number_of_objectives 5
		wm_set_round_timelimit	20
		wm_set_defending_team	0	 // Axis is defending team
		// 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


		// Objectives
		
		// Obj1: Sub
		// Obj2: Dock Door 
		// Obj3: Shipping Gate
		// Obj4: Forward Spawn

		wm_set_main_objective 1 0 1
		wm_set_main_objective 1 1 0
		wm_objective_status 1 0 1  // Obj1, Axis Sub OK
		wm_objective_status 1 1 0  // Obj1, Allies, Sub not destroyed.
		wm_objective_status 2 0 1  // Obj2, Axis have prevented Allies from destroying Dock Door.
		wm_objective_status 2 1 0  // Obj2, Allies have not destroyed the Dock Door.
		wm_objective_status 3 0 1  // Obj3, Axis have prevented Allies from destroying Shipping Gate.
		wm_objective_status 3 1 0  // Obj3, Allies have not destroyed the Shipping Gate.
		wm_objective_status 4 0 2  // Obj4, Axis forward spawn not taken
		wm_objective_status 4 1 2  // Obj4, Allied forward spawn not taken
		accum 1 set 0			// Will be set to 1 if Allies have destroyed the Sub
		accum 2 set 0			// Controls forward spawn
		wait 200
		
	}

	trigger timelimit_hit 
	{ 
	trigger game_manager axis_endgame 
	}		
	trigger allied_endgame
	{
	wm_setwinner 1
	setstate planks invisible
	trigger sub1 move_sub
	wait 50
	wm_endround
	}
	trigger axis_endgame
	{
	wm_setwinner 0
	setstate planks invisible
	trigger ldoor move_left
	trigger rdoor move_right
	trigger sub1 move_sub2
	wait 1500
	wm_endround
	}
	trigger objective1
	{
	wm_announce "Allies have destroyed the U-Boot!"
	wm_objective_status 1 0 0
	wm_objective_status 1 1 1
	accum 1 set 1
	wm_set_main_objective 1 0 0
	wm_set_main_objective 1 1 1
	wait 200
	trigger sub1 move_sub
	trigger game_manager allied_endgame
	}

	trigger objective2
	{
	wm_announce "Allies have destroyed the Dock Door!"
	wm_objective_status 2 0 0
	wm_objective_status 2 1 1
	wait 200
	}

	trigger objective3
	{
	wm_announce "Allies have destroyed the Shipping Gate!"
	wm_objective_status 3 0 0
	wm_objective_status 3 1 1
	wait 200
	}

	trigger allies_flag
	{

		wm_objective_status 4 0 2  // Obj4, Axis have not captured the shipping area.
		wm_objective_status 4 1 1  // Obj4, Allies have captured the shipping area.
		wm_announce	"Allies captures the Shipping Area!"

	}
	
	trigger axis_flag
	{
		wm_objective_status 4 0 1  // Obj4, Axis have captured the shipping area.
		wm_objective_status 4 1 2  // Obj4, Allies have not captured the shipping area.
		wm_announce	"Axis captures the Shipping Area!"
	}
}
gate
{	
	spawn
	{
	wait 50
	setstate gatedebris invisible
	constructible_class 3
	}
	death
	{
	setstate gatedebris default
	trigger game_manager objective3
	}
}
dockdoor
{	
	spawn
	{
	wait 50
	setstate doordebris invisible
	constructible_class 3
	}
	death
	{
	setstate doordebris default
	trigger game_manager objective2
	}
}
uboot
{	
	spawn
	{
	wait 50
	constructible_class 3
	}
	death
	{
	trigger game_manager objective1
	}
}


// ============================================================================
// Forward Spawn point - Initially neutral
//
// ============================================================================
forwardspawn1_flag
{
	spawn
	{
		wait 200
		accum 2 set 2			// Who owns flag: 0-Axis, 1-Allied
		accum 9 set 0			// Axis have not captures flag once yet
		accum 8 set 0			// Allies have not captured flag once yet
		setstate forwardspawn1_wobj invisible //remove Axis flag command map marker until captured
		setautospawn "Allied Spawn" 1
		setautospawn "Axis Spawn" 0
	}
	trigger axis_capture				// Touched by an Axis player
	{
		accum 0 abort_if_equal 0 		// do Axis own flag?
		accum 0 set 0 				// Axis own the flag
		wm_announce "Axis capture the Tower Spawn!"
		setstate forwardspawn1_wobj invisible
		setautospawn "Allied Spawn" 1       // Set Allies Spawn
		alertentity forwardspawn1_wobj		// Switch command map marker
		accum 8 abort_if_equal 1			// Abort if Allies have captured flag once
		accum 9 abort_if_equal 1			//Abort if axis have captured flag once
		alertentity forwardspawn1_wobj
		accum 9 set 1					//Allies have captured at least once
	}

	trigger allied_capture				// Touched by an allied player
	{
		accum 0 abort_if_equal 1 		// do Allies own flag?
		accum 0 set 1 				// Allies own the flag
		wm_announce "Allies capture the Tower Spawn!"
		setstate forwardspawn1_wobj default
		alertentity forwardspawn1_wobj	// Switch command map marker
		setautospawn "Forward Spawn"	1	// Set Allies to forward spawn
		accum 8 set 1				//Allies have captured flag at least once
	}
}


// ================================================
// ============ NEUTRAL COMMAND POST ==============
// ================================================
// FROM GOldRush Thx SD!!! prefab by seven 2003 

allied_compost_built
{
	spawn
	{
		wait 400
		trigger allied_compost_built setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 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 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75
		sethqstatus 1 1

		wm_announce	"Allied 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 6 0 2
		wm_objective_status 6 1 1
	}

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

		wm_announce	"Axis 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 6 0 0
		wm_objective_status 6 1 0
	}
}

axis_compost_built
{
	spawn
	{
		wait 400
		trigger axis_compost_built setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 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 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75
		sethqstatus 0 1

		wm_announce	"Axis 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 7 0 1
		wm_objective_status 7 1 2
	}

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

		wm_announce	"Allied 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 7 0 0
		wm_objective_status 7 1 0
	}
}
sub1
{
	spawn
	{
	wait 400
	}
	trigger move_sub
	{
	wait 50
	alertentity subsmoke
	gotomarker pointa 10 wait
	}
	trigger move_sub2
	{
	stopsound
	playsound maps/subdive.wav volume 150
	wait 1000
	playsound maps/uboot.wav volume 700
	wait 50
	gotomarker pointb 20 wait
	wait 50
	gotomarker pointc 50 wait
	}
}
ldoor
{	
	spawn
	{
	wait 50
	}
	trigger move_left
	{
	stopsound
      playsound sound/movers/misc/garage_door_start_01.wav volume 600
      wait 50
      playsound sound/movers/misc/garage_door_loop_01.wav looping volume 600
	gotomarker doorb 25 wait
      stopsound
      playsound sound/movers/misc/garage_door_end_01.wav volume 600
	}
}
rdoor
{
	spawn
	{
	wait 50
	}
	trigger move_right
	{
	wait 50
	gotomarker doora 25 wait
	}
}