// globalaccum 0 	Axis spawn control
//			0	: paras cannot attack (AA gun and controls built)
//			>0	: paras can attack (AA gun or controls damaged)
// globalaccum 1 	Axis Victory conditions marker
//			0-1	: axis not done enough to win
//			2	: axis victory (plans delivered and CP built)
// globalaccum 2 	trap 1 axis timer
// globalaccum 3 	trap 1 allied timer
// globalaccum 4 	trap 2 axis timer
// globalaccum 5 	trap 2 allied timer

game_manager
{
	spawn
	{
		wm_axis_respawntime	20
		wm_allied_respawntime	21
		wm_set_round_timelimit	18
		wm_number_of_objectives 8

		wait 500

		// 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 1

	//	Objectives from Axis viewpoint
	//	1	Destroy the AA gun
	//	2	Destroy the AA gun controls
	//	3	Destroy the main door
	//	4	Destroy the side door(s)
	//	5	Destroy the Study door(s)
	//	6	Steal the key and take it to the safe
	//	7	Steal the plans and take them to the CP
	//	8	Build the CP

		// obj nbr, team, status (0=none, 1=passed, 2=failed)
		wm_objective_status 1 0 0
		wm_objective_status 1 1 0
		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
		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

		setautospawn "Scullery" 1

	//	Hide the plans pickup (can't hide the plans CTF entity)
		setstate plans_toi invisible
		setstate plans_mcm invisible

	//	Hide the plans dropoff
		setstate plans_dropoff_tfm invisible

	//	Hide the ladder kickdown and fire fuel triggers
		setstate ladder_shrub_up_fiu invisible
		setstate fuel_fiu invisible

	//	Hide the pavilion spawn
		setstate pavilion_wobj invisible

	//	Hide trap defuse triggers, clues and detonators
		setstate allied_defuse1_tm invisible
		setstate allied_defuse1_msg_tm invisible
		setstate trap1_clue invisible
		setstate trap1_detonator_tm invisible

		setstate allied_defuse2_tm invisible
		setstate allied_defuse2_msg_tm invisible
		setstate trap2_clue invisible
		setstate trap2_detonator_tm invisible

	//	Change the obj and cursor icons
		remapshader "sprites/objective" "textures/chartwell/objective_key"		
		remapshader "ui/assets/3_cursor3" "textures/chartwell/cursor"
		remapshaderflush

	//	Initial speech
		wm_teamvoiceannounce 0 "axis_destroy_gun"
		wm_teamvoiceannounce 0 "axis_destroy_gun_controls"
		wm_teamvoiceannounce 0 "axis_destroy_maindoor"
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_protect_gun"
		wm_teamvoiceannounce 1 "allies_protect_gun_controls"
		wm_teamvoiceannounce 1 "allies_protect_maindoor"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
	}

	trigger axis_victory_check
	{
		globalaccum 1 abort_if_less_than 2 // abort if they haven't delivered the plans AND have the CP built
		trigger self axis_win
	}

	trigger axis_win
	{
		wm_setwinner 0
		wm_announce "^3*** ^7Axis have transmitted the D-Day plans! ^3***"

		wait 3000
		wm_endround
	}

	trigger timelimit_hit
	{
		alertentity winston
		wait 1000
		trigger winston_window4 remove
	}
}

// ================================================
AA_gun
{
	spawn
	{
		wait 150
		trigger self repaired
		constructible_class	3	// 2=Satchel 3=Dyna
	}

	trigger repaired
	{
		setstate AA_gun_smoke invisible
		globalaccum 0 abort_if_not_equal 0
		trigger AA_gun_sm rotate_on
	}

	trigger damaged
	{
		setstate AA_gun_smoke default
		trigger AA_gun_sm rotate_off
	}

	built final
	{
		globalaccum 0 inc -1
		trigger self repaired

		wm_announce "^3*** ^7The Allies have repaired the AA gun! ^3***"

		wm_objective_status 1 0 2
		wm_objective_status 1 1 1

		globalaccum 0 abort_if_not_equal 0
		wm_announce "^3*** ^7The Axis paratroops cannot attack! ^3***"
	}

	decayed final
	{
		trigger self damaged
	}

	death
	{
		globalaccum 0 inc 1
		trigger self damaged
		wm_announce "^3*** ^7Axis have destroyed the AA gun - Axis paratroops can attack! ^3***"

		wm_objective_status 1 0 1
		wm_objective_status 1 1 2

		wm_teamvoiceannounce 0 "axis_gun_destroyed"
		wm_teamvoiceannounce 1 "allies_gun_destroyed"
	}
}

// ================================================
AA_gun_controls
{
	spawn
	{
		wait 150
		trigger self repaired
		constructible_class	2	// 2=Satchel 3=Dyna
	}

	trigger repaired
	{
		trigger spark1 stop
		setstate AA_gun_controls_smoke invisible
		globalaccum 0 abort_if_not_equal 0
		trigger AA_gun_sm rotate_on
	}

	trigger damaged
	{
		trigger spark1 start
		setstate AA_gun_controls_smoke default
		trigger AA_gun_sm rotate_off
	}

	built final
	{
		globalaccum 0 inc -1
		trigger self repaired

		wm_announce "^3*** ^7The Allies have repaired the AA gun controls! ^3***"

		enablespeaker speaker_aa_gun_controls

		wm_objective_status 2 0 2
		wm_objective_status 2 1 1

		globalaccum 0 abort_if_not_equal 0
		wm_announce "^3*** ^7The Axis paratroops cannot attack! ^3***"

	}

	decayed final
	{
		trigger self damaged
	}

	death
	{
		globalaccum 0 inc 1
		trigger self damaged
		wm_announce "^3*** ^7Axis have destroyed the AA gun controls - Axis paratroops can attack! ^3***" 

		disablespeaker speaker_aa_gun_controls

		wm_objective_status 2 0 1
		wm_objective_status 2 1 2

		wm_teamvoiceannounce 0 "axis_gun_controls_destroyed"
		wm_teamvoiceannounce 1 "allies_gun_controls_destroyed"
	}
}

// ================================================
AA_gun_sm
{
	spawn
	{
		wait 150
		trigger self rotate_on
	}

	trigger rotate_on
	{
		setrotation 0 25 0
	}

	trigger rotate_off
	{
		stoprotation
	}
}

// ================================================
allied_cp_open
{
	spawn
	{
		wait 100
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
	}

	trigger disable_cp_features
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1

		sethqstatus 1 0			// Landmines team warning message
		disablespeaker speaker_allied_cp		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		setstate allied_cp_open_model default	// Show open CP model

		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			// Landmines team warning message
		enablespeaker speaker_allied_cp		// Enable morse code sound
	}

	buildstart final
	{
		trigger neutral_cp_toi hide_neutral_cabinet	// Hide Neutral CP model+clip brush
	}

	built final
	{
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "^3*** ^7Allied Command Post constructed. Charge speed increased! ^3***"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"
		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 8 0 2
		wm_objective_status 8 1 1
	}

	decayed final
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
	}

	death
	{
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "^3*** ^7Axis have destroyed the Allied Command Post! ^3***"
		// *----------------------------------- 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"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 8 0 0
		wm_objective_status 8 1 0
	}
}

// ================================================
allied_defuse1_tst
{
	trigger run
	{
		globalaccum 3 set 0 // stop the timer from cancelling the trap defusing
		trigger trap1 defuse
	}
}

allied_defuse1_cancel_tst
{
	trigger run
	{
		globalaccum 3 inc 1
		globalaccum 3 abort_if_not_equal 2
		trigger trap1 cancel_defuse
		globalaccum 3 set 0
	}
}

// ================================================
allied_defuse2_tst
{
	trigger run
	{
		globalaccum 5 set 0 // stop the timer from cancelling the trap defusing
		trigger trap2 defuse
	}
}

allied_defuse2_cancel_tst
{
	trigger run
	{
		globalaccum 5 inc 1
		globalaccum 5 abort_if_not_equal 2
		trigger trap2 cancel_defuse
		globalaccum 5 set 0
	}
}

// ================================================
allied_MG
{
	spawn
	{
		wait 50
		constructible_class 2			// Dyno+Satchel

	//	Can't build until the window is removed
		setstate allied_MG_toi invisible
		setstate allied_MG_materials invisible	// Crate Models
		setstate allied_MG_clip invisible	// Clip brushes
		setstate allied_MG_flag invisible
		setstate allied_MG_mg42 invisible	// MG42 entity
	}

	trigger allowed
	{
		setstate allied_MG_toi default
		setstate allied_MG_msg_tm invisible
		trigger self setup
	}

	trigger setup
	{
		setstate allied_MG_materials default	// Crate Models
		setstate allied_MG_clip default	// Clip brushes
		setstate allied_MG_flag default

		setstate allied_MG_mg42 invisible	// MG42 entity
		repairmg42 allied_MG_mg42
	}

	built final
	{
		setstate allied_MG_materials invisible	// Crate Models
		setstate allied_MG_clip invisible	// Clip brushes
		setstate allied_MG_flag invisible

		setstate allied_MG_mg42 default	// MG42 entity

		wm_announce "^3*** ^7Allies have built the MG emplacement! ^3***"
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		trigger self setup
		wm_announce "^3*** ^7Axis have destroyed the MG emplacement ^3***!" 
	}
}

// ================================================
axis_cp_open
{
	spawn
	{
		wait 100
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
	}

	trigger disable_cp_features
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1

		sethqstatus 0 0			// Landmines team warning message
		disablespeaker speaker_axis_cp		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		setstate axis_cp_open_model default	// Show open CP model

		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			// Landmines team warning message
		enablespeaker speaker_axis_cp		// Enable morse code sound
	}

	buildstart final
	{
		trigger neutral_cp_toi hide_neutral_cabinet	// Hide Neutral CP model+clip brush
	}

	built final
	{
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "^3*** ^7Axis Command Post constructed. Charge speed increased! ^3***"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 8 0 1
		wm_objective_status 8 1 2

		globalaccum 1 inc 1
		trigger game_manager axis_victory_check
	}

	decayed final
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
	}

	death
	{
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "^3*** ^7The Allies have destroyed the Axis Command Post! ^3***"
		// *----------------------------------- 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"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 8 0 0
		wm_objective_status 8 1 0

		globalaccum 1 inc -1
	}
}

// ================================================
axis_trap1_tst
{
	trigger run
	{
		globalaccum 2 set 0 // stop the timer from cancelling the trap setting
		trigger trap1 set
	}
}

axis_trap1_cancel_tst
{
	trigger run
	{
		globalaccum 2 inc 1
		globalaccum 2 abort_if_not_equal 2
		trigger trap1 cancel_set
		globalaccum 2 set 0
	}
}

// ================================================
axis_trap2_tst
{
	trigger run
	{
		globalaccum 4 set 0 // stop the timer from cancelling the trap setting
		trigger trap2 set
	}
}

axis_trap2_cancel_tst
{
	trigger run
	{
		globalaccum 4 inc 1
		globalaccum 4 abort_if_not_equal 2
		trigger trap2 cancel_set
		globalaccum 4 set 0
	}
}

// ================================================
bucket_tst
{
	trigger main
	{
	//	put the fire out
		setstate fire_hurt1 invisible
		setstate fire_hurt2 invisible
		setstate fire_hurt3 invisible
		setstate fire_hurt4 invisible

		setstate fire_smoke1 invisible
		setstate fire_smoke2 invisible
		setstate fire_smoke3 invisible

		setstate flames invisible

		disablespeaker speaker_fire

		setstate bucket_fiu invisible
		setstate fuel_fiu default
	}
}

// ================================================
eastdoor
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class 2			// Dyno+Satchel
	}

	trigger setup
	{
		setstate eastdoor_materials default	// Crate Models
		setstate eastdoor_clip default		// Clip brushes
		setstate eastdoor_flag default
		setstate eastdoor_fake invisible	// only used during building

		setstate allied_eastdoor invisible		// team door entity
	}

	built final
	{
		setstate eastdoor_materials invisible	// Crate Models
		setstate eastdoor_clip invisible		// Clip brushes
		setstate eastdoor_flag invisible
		setstate eastdoor_fake invisible	// fake team door

		setstate allied_eastdoor default		// team door entity
		wm_announce "^3*** ^7Allies have built the east stairwell door! ^3***"
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		trigger self setup
		wm_announce "^3*** ^7Axis have destroyed the east stairwell door! ^3***" 
	}
}

// ================================================
fuel_tst
{
	trigger main
	{
	//	ignite the fire
		setstate fire_hurt1 default
		setstate fire_hurt2 default
		setstate fire_hurt3 default
		setstate fire_hurt4 default

		setstate fire_smoke1 default
		setstate fire_smoke2 default
		setstate fire_smoke3 default

		setstate flames default

		enablespeaker speaker_fire

		setstate bucket_fiu default
		setstate fuel_fiu invisible
	}
}

//========================================
hard_front_window1
{
	death
	{
		trigger allied_MG allowed
	}
}

//========================================
keyondesk
{
	trigger captured
	{
		wm_announce "^3*** ^7Axis got the Key to the Safe - the Safe is opening! ^3***"
		wm_teamvoiceannounce 0 "axis_objective_captured"
		wm_teamvoiceannounce 1 "allies_objective_captured"

		wm_objective_status 6 0 1
		wm_objective_status 6 1 2

	//	Change the obj icon to the plans
		remapshader "sprites/objective" "textures/chartwell/objective_plans"
		remapshaderflush		

	//	Hide pickup and dropoff toi
		setstate key_toi invisible
		setstate key_mcm invisible

		setstate key_dropoff_tfm invisible
		setstate key_dropoff_toi invisible
		setstate key_dropoff_mcm invisible

	//	Show key in lock, and open the safe
		setstate keyinlock default
		wait 1000
		trigger safe_handel turn
		wait 8000
		trigger safe_door open

	//	Allow the docs to be taken...

	//	Show the plans pickup
		setstate plans_toi default
		setstate plans_mcm default

	//	Show the plans dropoff
		setstate plans_dropoff_tfm default
	}

	trigger dropped
	{
		wm_announce "^3*** ^7Axis have dropped the Key to the Safe! ^3***"
		wm_teamvoiceannounce 0 "axis_objective_lost"
		wm_teamvoiceannounce 1 "allies_objective_lost"
	}

	trigger returned
	{
		wm_announce "^3*** ^7The Allies have returned the Safe Key to the Dining Room! ^3***"
	}

	trigger stolen
	{
	//	"Objective taken" is spoken
		wm_announce "^3*** ^7Axis have stolen the Key to the Safe! ^3***"
	}
}

//========================================
keyinlock
{
	spawn
	{
		wait 100
		attachtotag safe_door tag_key
		setstate keyinlock invisible
	}
}

//========================================
ladder_shrub_down_tst
{
	trigger main
	{
		setstate ladder_shrub_down_fiu invisible

		setstate ladder_shrub_down underconstruction
		setstate ladder_shrub_up underconstruction
		wait 3000

		setstate ladder_shrub_down invisible

		setstate ladder_shrub_up default
		setstate ladder_shrub_up_fiu default
	}
}

//========================================
ladder_shrub_up_tst
{
	trigger main
	{
		setstate ladder_shrub_up_fiu invisible

		setstate ladder_shrub_down underconstruction
		setstate ladder_shrub_up underconstruction
		wait 3000

		setstate ladder_shrub_up invisible

		setstate ladder_shrub_down default
		setstate ladder_shrub_down_fiu default
	}
}

// =================================================
maindoor
{
	spawn
	{
		wait 150
		constructible_class 3
	}

	death
	{
		alertentity maindoor_bits
		trigger maindoor_toi remove

		wm_announce "^3*** ^7Axis have destroyed the Main Door! ^3***"

		wm_objective_status 3 0 1
		wm_objective_status 3 1 2

		wm_teamvoiceannounce 0 "axis_maindoor_destroyed"
		wm_teamvoiceannounce 1 "allies_maindoor_destroyed"
	}
}

maindoor_toi
{
	trigger remove
	{
		remove
	}
}

// ================================================
neutral_cp_toi
{
	trigger show_neutral_cabinet			// Show Neutral Closed CP
	{
		setstate neutral_cp_closed default
		setstate neutral_cp_closed_model default
	}

	trigger hide_neutral_cabinet			// Hide Neutral Closed CP
	{
		setstate neutral_cp_closed invisible
		setstate neutral_cp_closed_model invisible
	}
}

// ============================================================================
// Pavilion Spawn point - Only for Allies
// ============================================================================
pavilion_flag
{
	spawn
	{
		accum 0 set 0				// Who owns flag: 0-Axis, 1-Allied
	}

	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 "^3*** ^7Axis have taken the Pavilion! ^3***"

		setstate pavilion_wobj invisible
	}

	trigger allied_capture				// 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 "^3*** ^7The Allies have captured the Pavilion! ^3***"

		setstate pavilion_wobj default
	}
}

//========================================
plans
{
	trigger captured
	{
		wm_announce "^3*** ^7Axis have secured the D-Day Plans at the transmitter! ^3***"
		wm_teamvoiceannounce 0 "axis_objective_captured"
		wm_teamvoiceannounce 1 "allies_objective_captured"

		wm_objective_status 7 0 1
		wm_objective_status 7 1 2

	//	Hide pickup and dropoff toi
		setstate plans_toi invisible
		setstate plans_mcm invisible

		setstate plans_dropoff_tfm invisible
		setstate plans_dropoff_toi invisible
		setstate plans_dropoff_mcm invisible

		globalaccum 1 inc 1
		trigger game_manager axis_victory_check
	}

	trigger dropped
	{
		wm_announce "^3*** ^7Axis have dropped the D-Day Plans! ^3***"
		wm_teamvoiceannounce 0 "axis_objective_lost"
		wm_teamvoiceannounce 1 "allies_objective_lost"
	}

	trigger returned
	{
		wm_announce "^3*** ^7The D-Day Plans have been returned to the Study! ^3***"
	}

	trigger stolen
	{
	//	"Objective taken" is spoken
		wm_announce "^3*** ^7Axis have stolen the D-Day Plans! ^3***"
	}
}

//========================================
safe_door
{
	spawn
	{
		wait 500
	//	safe door is spawned elsewhere to allow plans CTF entity to fall onto safe shelf
		setposition safe_door_start_position
	}

	trigger open
	{
		faceangles 0 75 0 2000
		setstate safe_door_plug invisible
	}
}

//========================================
safe_handel
{
	spawn
	{
		wait 100
		attachtotag safe_door tag_handel
	}

	trigger turn
	{
		setrotation 90 0 0
		wait 7000
		stoprotation		
	}
}

safe_top
{
	spawn
	{
		wait 500
	//	safe_top starts invis to allow plans CTF entity to fall onto safe shelf
		setstate safe_top default
	}
}

//========================================
scriptblock1
{
// accum 1	axis spawn location (0=base)
	spawn
	{
		wait 18000
		trigger self axis_spawn_loop
	}

	trigger alert_axis_spawns
	{
		accum 1 trigger_if_equal 0 scriptblock1 alert_axis_spawns_0
		accum 1 trigger_if_equal 1 scriptblock1 alert_axis_spawns_1
		accum 1 trigger_if_equal 2 scriptblock1 alert_axis_spawns_2
		accum 1 trigger_if_equal 3 scriptblock1 alert_axis_spawns_3
		accum 1 trigger_if_equal 4 scriptblock1 alert_axis_spawns_4
		accum 1 trigger_if_equal 5 scriptblock1 alert_axis_spawns_5
		accum 1 trigger_if_equal 6 scriptblock1 alert_axis_spawns_6
		accum 1 trigger_if_equal 7 scriptblock1 alert_axis_spawns_7
		accum 1 trigger_if_equal 8 scriptblock1 alert_axis_spawns_8
		accum 1 trigger_if_equal 9 scriptblock1 alert_axis_spawns_9
	}

	trigger alert_axis_spawns_0
	{
	//	wm_announce "alert_axis_spawns_0"
		alertentity axis_spawn_0
	}

	trigger alert_axis_spawns_1
	{
	//	wm_announce "alert_axis_spawns_1"
		alertentity axis_spawn_1
	}

	trigger alert_axis_spawns_2
	{
	//	wm_announce "alert_axis_spawns_2"
		alertentity axis_spawn_2
	}

	trigger alert_axis_spawns_3
	{
	//	wm_announce "alert_axis_spawns_3"
		alertentity axis_spawn_3
	}

	trigger alert_axis_spawns_4
	{
	//	wm_announce "alert_axis_spawns_4"
		alertentity axis_spawn_4
	}

	trigger alert_axis_spawns_5
	{
	//	wm_announce "alert_axis_spawns_5"
		alertentity axis_spawn_5
	}

	trigger alert_axis_spawns_6
	{
	//	wm_announce "alert_axis_spawns_6"
		alertentity axis_spawn_6
	}

	trigger alert_axis_spawns_7
	{
	//	wm_announce "alert_axis_spawns_7"
		alertentity axis_spawn_7
	}

	trigger alert_axis_spawns_8
	{
	//	wm_announce "alert_axis_spawns_8"
		alertentity axis_spawn_8
	}

	trigger alert_axis_spawns_9
	{
	//	wm_announce "alert_axis_spawns_9"
		alertentity axis_spawn_9
	}

	trigger axis_spawn_at_base
	{
	//	wm_announce "axis_spawn_at_base"
		accum 1 set 0
		trigger self enable_axis_spawns
	}

	trigger axis_spawn_by_para
	{
	//	select dropzone randomly
	//	wm_announce "axis_spawn_by_para"
		accum 1 random 9 // 0-8
		accum 1 inc 1    // 1-9
		trigger self enable_axis_spawns
	}

	trigger axis_spawn_loop
	{
	//	set the axis spawn depending on the status of the AA gun and controls

	//	Cancel the current spawns
		trigger self alert_axis_spawns

	//	These routines do not return
		globalaccum 0 trigger_if_equal 0 scriptblock1 axis_spawn_at_base
		globalaccum 0 trigger_if_equal 1 scriptblock1 axis_spawn_by_para
		globalaccum 0 trigger_if_equal 2 scriptblock1 axis_spawn_by_para
	}

	trigger enable_axis_spawns
	{
		trigger self alert_axis_spawns
		wait 20000
		trigger self axis_spawn_loop
	}
}

//=============================================
spark1
{
	trigger start
	{
		alertentity spark1

		wait random 1000 2500
		trigger self start
	}

	trigger stop
	{
		resetscript
	}
}

// =================================================
studydooreast
{
	spawn
	{
		wait 150
		constructible_class 2
	}

	pain // rather than death due to class 2
	{
		trigger studydooreast_toi remove

		wm_announce "^3*** ^7Axis have destroyed the East Study Door! ^3***"

		wm_objective_status 5 0 1
		wm_objective_status 5 1 2
	}
}

studydooreast_toi
{
	trigger remove
	{
		remove
	}
}

// =================================================
studydoorsouth
{
	spawn
	{
		wait 150
		constructible_class 3
	}

	death
	{
		trigger studydoorsouth_toi remove

		wm_announce "^3*** ^7Axis have destroyed the South Study Door! ^3***"

		wm_objective_status 5 0 1
		wm_objective_status 5 1 2
	}
}

studydoorsouth_toi
{
	trigger remove
	{
		remove
	}
}

//=============================================
tibet
{
	spawn
	{
		wait 500
		faceangles 0 0 90 1000
		wait 500
	//	setrotation 0 -50 0
		gotomarker tibet_p2 300 wait

		remove
	}
}

// ================================================
trap1
// accum 0	: 1=trap being set
//		  2=trap being defused
{
	trigger cancel_defuse
	{
		accum 0 abort_if_not_equal 2

		resetscript
		abortmove
		gotomarker trap1_set 5000 wait
		accum 0 set 0

	//	Hide the progress bar
		setstate trap1 invisible
	}

	trigger cancel_set
	{
		accum 0 abort_if_not_equal 1

		resetscript
		abortmove
		gotomarker trap1_defuse 5000 wait
		accum 0 set 0
	}

	trigger defuse
	{

		accum 0 abort_if_equal 2 // abort if the trap is already being defused
		accum 0 set 2

	//	Show the progress bar
		setstate trap1 default

		gotomarker trap1_defuse 10 wait
		accum 0 set 0

		trigger self reset_trap
	}

	trigger reset_trap_completely
	{
		resetscript
		abortmove
		gotomarker trap1_defuse 50000
		accum 0 set 0
		trigger self reset_trap
	}

	trigger reset_trap
	{
	//	Hide the trap defuse trigger and msg
		setstate allied_defuse1_tm invisible
		setstate allied_defuse1_msg_tm invisible

	//	Reveal the trap set trigger and msg
		setstate axis_trap1_tm default
		setstate axis_trap1_msg_tm default

	//	Hide the trap clue
		setstate trap1_clue invisible

	//	Remove the trap!
		setstate trap1_detonator_tm invisible
	}

	trigger set
	{

		accum 0 abort_if_equal 1 // abort if the trap is already being set
		accum 0 set 1

		gotomarker trap1_set 10 wait
		accum 0 set 0

	//	Hide the trap setting trigger and msg
		setstate axis_trap1_tm invisible
		setstate axis_trap1_msg_tm invisible

	//	Reveal the trap defusing trigger and msg
		setstate allied_defuse1_tm default
		setstate allied_defuse1_msg_tm default

	//	Hide the progress bar and show the trap clue
		setstate trap1 invisible
		setstate trap1_clue default

	//	Set the trap!
		setstate trap1_detonator_tm default
	}
}

trap1_detonator_tst
{
	trigger run
	{
	//	Trap detonated!
		setstate trap1_detonator_tm invisible

		alertentity trap1_explosion
		trigger trap1 reset_trap_completely
	}
}

// ================================================
trap2
// accum 0	: 1=trap being set
//		  2=trap being defused
{
	trigger cancel_defuse
	{
		accum 0 abort_if_not_equal 2

		resetscript
		abortmove
		gotomarker trap2_set 5000 wait
		accum 0 set 0

	//	Hide the progress bar
		setstate trap2 invisible
	}

	trigger cancel_set
	{
		accum 0 abort_if_not_equal 1

		resetscript
		abortmove
		gotomarker trap2_defuse 5000 wait
		accum 0 set 0
	}

	trigger defuse
	{

		accum 0 abort_if_equal 2 // abort if the trap is already being defused
		accum 0 set 2


	//	Show the progress bar
		setstate trap2 default

		gotomarker trap2_defuse 10 wait
		accum 0 set 0

		trigger self reset_trap
	}

	trigger reset_trap_completely
	{
		resetscript
		abortmove
		gotomarker trap2_defuse 50000
		accum 0 set 0
		trigger self reset_trap
	}

	trigger reset_trap
	{
	//	Hide the trap defuse trigger and msg
		setstate allied_defuse2_tm invisible
		setstate allied_defuse2_msg_tm invisible

	//	Reveal the trap set trigger and msg
		setstate axis_trap2_tm default
		setstate axis_trap2_msg_tm default

	//	Hide the trap clue
		setstate trap2_clue invisible

	//	Remove the trap!
		setstate trap2_detonator_tm invisible
	}

	trigger set
	{

		accum 0 abort_if_equal 1 // abort if the trap is already being set
		accum 0 set 1

		gotomarker trap2_set 10 wait
		accum 0 set 0

	//	Hide the trap setting trigger and msg
		setstate axis_trap2_tm invisible
		setstate axis_trap2_msg_tm invisible

	//	Reveal the trap defusing trigger and msg
		setstate allied_defuse2_tm default
		setstate allied_defuse2_msg_tm default

	//	Hide the progress bar and show the trap clue
		setstate trap2 invisible
		setstate trap2_clue default

	//	Set the trap!
		setstate trap2_detonator_tm default
	}
}

trap2_detonator_tst
{
	trigger run
	{
	//	Trap detonated!
		setstate trap2_detonator_tm invisible

		alertentity trap2_explosion
		trigger trap2 reset_trap_completely
	}
}

// ================================================
westdoor
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class 2			// Dyno+Satchel
	}

	trigger setup
	{
		setstate westdoor_materials default	// Crate Models
		setstate westdoor_clip default		// Clip brushes
		setstate westdoor_flag default
		setstate westdoor_fake invisible	// only used during building

		setstate allied_westdoor invisible		// team door entity
	}

	built final
	{
		setstate westdoor_materials invisible	// Crate Models
		setstate westdoor_clip invisible		// Clip brushes
		setstate westdoor_flag invisible
		setstate westdoor_fake invisible	// fake team door

		setstate allied_westdoor default		// team door entity
		wm_announce "^3*** ^7Allies have built the west stairwell door! ^3***"
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		trigger self setup
		wm_announce "^3*** ^7Axis have destroyed the west stairwell door! ^3***" 
	}
}

winston_window1
{
	trigger remove
	{
		remove
	}
}

winston_window2
{
	trigger remove
	{
		remove
	}
}

winston_window3
{
	trigger remove
	{
		remove
	}
}

winston_window4
{
	trigger remove
	{
		remove
	}
}