game_manager
{
	spawn
	{

		// Set the respawn times

		wm_allied_respawntime		20
		wm_axis_respawntime		20
		wm_set_round_timelimit		12
		wm_number_of_objectives		6

		// Objectives
		wm_objective_status 1 1 0 //Door
		wm_objective_status 1 0 1 //Door
		wm_objective_status 2 1 0 //Gate
		wm_objective_status 2 0 1 //Gate
		wm_objective_status 3 1 0 //Grab Docs
		wm_objective_status 3 0 1 //Grab Docs
		wm_objective_status 4 1 0 //Cap Docs
		wm_objective_status 4 0 1 //Cap Docs
		wm_objective_status 5 1 0 //Flag
		wm_objective_status 5 0 1 //Flag 
		wm_objective_status 6 1 0 //CP
		wm_objective_status 6 0 0 //CP
		
		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		4	0
		wm_set_main_objective		4	1
		
		// Set Defending Team for SW Mode

		wm_set_defending_team	0

		// If the round timer expires, the Axis have won, so set the current winning team
		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 0

		// Accum #1 will be the state of objective number one
		accum 1 set 0
		// Accum #2 is set after either wall is breached, so that the sirens are set only once
		accum 2 set 0
		
		wait 1000
		
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "radar_axis_entrances_defend"
		wm_addteamvoiceannounce 0 "radar_axis_bunker_stop"
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 0 "axis_steal_obj"

		wm_addteamvoiceannounce 1 "radar_allies_entrances_destroy"
		wm_addteamvoiceannounce 1 "radar_allies_bunker_capture"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_secure_obj"

		wm_teamvoiceannounce 0 "radar_axis_entrances_defend"
		wm_teamvoiceannounce 0 "radar_axis_bunker_stop"
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_steal_obj"

		wm_teamvoiceannounce 1 "radar_allies_entrances_destroy"
		wm_teamvoiceannounce 1 "radar_allies_bunker_capture"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_secure_obj"
		// *---------------------------------------------------------------------------------*
		
		setautospawn "Flag" 1
		
		setstate siren invisible
		
		wait 2000
	}

	trigger objective2
	{
		// Change the objective state internally, so UI can update, etc.
		// Allied takes control of objective #1
		wm_objective_status	4 1 1
		wm_objective_status	4 0 2		

		// Change the variable within the script so that we can check if someone wins the round
		accum 1 set 1

		// UI pop-up to alert players
		wm_announce	"Allies transmitted the documents!"

		// Call function to check if the round has been won
		trigger game_manager checkgame
	}

	trigger axis_object_stolen
	{
		// Change the objective state internally, so UI can update, etc.
		// Allied have stolen the documents (0 == AXIS, 1 == ALLIED)
		wm_objective_status	3 1 1
		wm_objective_status	3 0 2
	}

	trigger axis_object_returned
	{
		// Change the objective state internally, so UI can update, etc.
		// Axis have returned the documents (0 == AXIS, 1 == ALLIED)
		wm_objective_status	3 1 0
		wm_objective_status	3 0 0
	}

	trigger checkgame
	{
		accum 1 abort_if_not_equal 1

		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 1

		// End the round
		wm_endround
	}
}


gate
{
	spawn
	{
		wait 200
		constructible_class 3
	}

	death
	{
		// Change the objective state internally, so UI can update, etc.
		// Allied takes control of objective #1
		wm_objective_status	2 1 1
		wm_objective_status	2 0 2
		
		wm_announce "^1Allies have breached the Gate!"
		
		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "radar_axis_entrances_defend"

		wm_removeteamvoiceannounce 1 "radar_allies_entrances_destroy"
		// *---------------------------------------------------------------------------------*

		//turn on sirens
		setstate siren default
	}
}

door
{
	spawn
	{
		wait 200
		constructible_class 3
	}

	death
	{
		// Change the objective state internally, so UI can update, etc.
		// Allied takes control of objective #1
		wm_objective_status	1 1 1
		wm_objective_status	1 0 2
		
		wm_announce "^1Allies have breached the Door!"
		
		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "radar_axis_entrances_defend"

		wm_removeteamvoiceannounce 1 "radar_allies_entrances_destroy"
		// *---------------------------------------------------------------------------------*

		//turn on sirens
		setstate siren default
	}
}

allied_obj2 //The war documents being transmitted.
{
	spawn
	{
	}

	death
	{
		trigger game_manager objective2
	}
}


//-----Flag Objective 6----------

truck_spawn
{
	spawn
	{
	}
}

truck_spawn_bleh
{
	spawn
	{
	}
}

flag_spawn
{
	spawn
	{
	}
}

flag_bleh
{
	spawn
	{
	}
}

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

	trigger allied_capture
	{
		accum 0 abort_if_equal 1	//do Allies own flag?
		accum 0 set 1
		
		wm_announce		"^1Allies captured the Flag!"
		
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_bunker_captured"

		wm_teamvoiceannounce 1 "radar_allies_bunker_captured"
		
		
		wm_removeteamvoiceannounce 0 "radar_axis_bunker_stop"

		wm_removeteamvoiceannounce 1 "radar_allies_bunker_capture"
		// *---------------------------------------------------------------------------------*

		wm_objective_status	5 1 1
		wm_objective_status	5 0 2
		
		alertentity flag_bleh
		alertentity flag_spawn
		
		wait 500
	}

	trigger axis_capture
	{
		accum 0 abort_if_equal 0	//do Axis own flag?
		accum 0 set 0

		wm_announce		"^1Axis captured the Flag!"
		
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_bunker_reclaimed"

		wm_teamvoiceannounce 1 "radar_allies_bunker_reclaimed"
		
		wm_addteamvoiceannounce 0 "radar_axis_bunker_stop"

		wm_addteamvoiceannounce 1 "radar_allies_bunker_capture"
		// *---------------------------------------------------------------------------------*

		wm_objective_status	5 1 0
		wm_objective_status	5 0 1
		
		alertentity flag_bleh
		alertentity flag_spawn
		
		wait 500
	}
	
	trigger check_obj
	{
		accum 0 abort_if_equal 1 // Do Allies own the flag?

		wm_objective_status 		5 0 2
		wm_objective_status 		5 1 1
	}	
}

//---END FLAG------------

// NEUTRAL COMMAND POST
// FROM Goldrush Thx SD!!! prefab by seven 2003
// Map in a box by Ifurita (owny)

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
		
		trigger cp_spawn_bleh on
	}

	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
		
		trigger cp_spawn_bleh off
	}
}

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

//-------------[Objective]------------------
// The Code Book
book
{
	spawn
	{
	}

	// Allies snatch the book
	trigger stolen
	{
		// Hide objectivce marker on command map
		setstate book_toi invisible
		setstate book_map_marker invisible

		// Mark objective as in Allied control
		wm_objective_status 3 1 1
		wm_objective_status 3 0 2
	}

	// Axis return the book
	trigger returned
	{
		// Show objectivce marker on command map
		setstate book_toi default
		setstate book_map_marker default

		// Mark objective as in Axis control
		wm_objective_status 3 1 0
		wm_objective_status 3 0 1
	}

	// Allies transmitted the book
	trigger captured
	{
		// Mark objective as completed

		// Mark axis as the winners
		wm_setwinner 1

		wm_objective_status 4 1 1
		wm_objective_status 4 0 2

		// Tell everyone
		wm_announce "^1Allies have transmitted the code book!"

		// Wait a few seconds
		wait 1000

		// End the round
		wm_endround
	}
}