game_manager
{
	spawn
	{		
		// Game rules
		wm_axis_respawntime	15
		wm_allied_respawntime	25
		wm_number_of_objectives 6
		wm_set_round_timelimit	20

		// Objectives
		// 1: The Tunnel Entrance
		// 2: 
		// 3: The Forward Spawn (North Pole)
		// 4: 
		// 5: Christmas Star
		// 6: 
		// 7: 

		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		1	0
		wm_set_main_objective		1	1

		wm_objective_status 1 1 0
		wm_objective_status 1 0 0
		wm_objective_status 2 1 0
		wm_objective_status 2 0 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_set_main_objective		1	0
		wm_set_main_objective		1	1

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

		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner	1


		// Set start spawnpoints
		wait 500
		setautospawn "Forward Spawn" 1
		setautospawn "Axis Spawn" 0
	}

	trigger allies_win
	{
		wm_setwinner	1
		wm_announce "Allied team has stopped the Axis from stealing the Christmas Star!"

		wm_objective_status 5 0 2
		wm_objective_status 5 1 1

		wait 1500
		wm_endround
	}

	trigger axis_win
	{
		wm_setwinner	0
		wm_announce "The Axis team have escaped with the Christmas Star!"

		wm_objective_status 5 1 2
		wm_objective_status 5 0 1

		wait 1500
		wm_endround
	}

}

// ================================================
// ============ 	    CABLE CAR   	 ==============
// ================================================

cable_trigger
{
	spawn
	{
	}

	trigger cable_move
	{
	trigger cablecar move
	}

}

cablecar
{
	spawn
		{
		accum 1 set 0
		}

	trigger move
		{
		accum 1 abort_if_not_equal 0
		accum 1 set 1
		stopsound
		playsound sound/movers/misc/garage_door_start_01.wav volume 96
		wait 50
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker corner1 100 wait
		gotomarker corner2 110 wait
		gotomarker corner3 120 wait
		gotomarker corner4 130 wait
		gotomarker corner5 140 wait
		gotomarker corner6 150 wait
		faceangles 0 90 0 1500
		gotomarker corner7 140 wait
		gotomarker corner8 130 wait
		gotomarker corner9 120 wait
		gotomarker corner10 110 wait
		gotomarker corner11 100 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 96
		wait 5000
		trigger cablecar return
		}

	trigger return
		{
		stopsound
		playsound sound/movers/misc/garage_door_start_01.wav volume 96
		wait 50
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker corner10 110 wait
		gotomarker corner9 120 wait
		gotomarker corner8 130 wait
		gotomarker corner7 140 wait
		gotomarker corner6 150 wait
		faceangles 0 0 0 1500
		gotomarker corner5 140 wait
		gotomarker corner4 130 wait
		gotomarker corner3 120 wait
		gotomarker corner2 110 wait
		gotomarker corner1 100
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 96
		accum 1 set 0
		}
}

// ================================================
// ============ 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 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 3 0 2
		wm_objective_status 3 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 3 0 0
		wm_objective_status 3 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 3 0 1
		wm_objective_status 3 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 3 0 0
		wm_objective_status 3 1 0
	}
}

//==============================================
//======        Town Door        =======
//==============================================
town_door // The Town Door
{
	spawn
	{
set
{
spawnflags 9
}
		wait 400
		trigger town_door setup

		constructible_class 2
	}

	trigger setup
	{
		setstate town_door_materials invisible
		setstate town_door_materials_clip invisible
		setstate town_door_flag invisible


		setstate town_door default

	}

	buildstart final
	{
		setstate town_door_materials default
		setstate town_door_materials_clip default
		setstate town_door_flag default


		setstate town_door underconstruction
	}

	built final
	{
		setstate town_door_materials invisible
		setstate town_door_materials_clip invisible
		setstate town_door_flag invisible


		setstate town_door default

		wm_announce "The Town Door have been built."

	}

	decayed final
	{
		setstate town_door_materials default
		setstate town_door_materials_clip default
		setstate town_door_flag default


		setstate town_door invisible

	}

	death
	{
		setstate town_door_materials default
		setstate town_door_materials_clip default
		setstate town_door_flag default


		setstate town_door invisible

		wm_announce "The Town Door have been destroyed!"

	}

	trigger remove
	{
		setstate town_door_toi invisible
		setstate town_door_materials invisible
		setstate town_door_materials_clip invisible
		setstate town_door_flag invisible
		setstate town_door invisible

		remove
	}
}

//==============================================
//======        High GuardTower         =======
//==============================================
town_barb // The Guard Tower
{
	spawn
	{
		wait 400
		trigger town_barb setup

		constructible_class 2
	}

	trigger setup
	{
		setstate town_barb_materials default
		setstate town_barb_materials_clip default
		setstate town_barb_flag default

		setstate town_barb invisible
		setstate hill_shoot_mg invisible

	}

	buildstart final
	{
		setstate town_barb_materials default
		setstate town_barb_materials_clip default
		setstate town_barb_flag default


		setstate town_barb underconstruction
		setstate hill_shoot_mg underconstruction
	}

	built final
	{
		setstate town_barb_materials invisible
		setstate town_barb_materials_clip invisible
		setstate town_barb_flag invisible


		setstate town_barb default
		setstate hill_shoot_mg default

		wm_announce "The high Guardtower have been built."

	}

	decayed final
	{
		setstate town_barb_materials default
		setstate town_barb_materials_clip default
		setstate town_barb_flag default


		setstate town_barb invisible
		setstate hill_shoot_mg invisible

	}

	death
	{
		setstate town_barb_materials default
		setstate town_barb_materials_clip default
		setstate town_barb_flag default


		setstate town_barb invisible
		setstate hill_shoot_mg invisible
		repairmg42 hill_shoot_mg

		wm_announce "The high Guardtower have been destroyed!"

	}

	trigger remove
	{
		setstate town_barb_toi invisible
		setstate town_barb_materials invisible
		setstate town_barb_materials_clip invisible
		setstate town_barb_flag invisible
		setstate town_barb invisible
		setstate hill_shoot_mg invisible

		remove
	}
}

// ============================================================================
// Allied MG42 Nest - on Allied side of the map
// ============================================================================
alliedbarnmg42nest
{
	spawn
	{
		wait 200

		constructible_class 2

		setstate alliedbarnmg42 invisible
		setstate alliedbarnmg42materials default
	}

	buildstart final
	{
		setstate alliedbarnmg42 underconstruction
	}

	built final
	{
		setstate alliedbarnmg42 default
		setstate alliedbarnmg42materials invisible

		// Some kind of UI pop-up to alert players
		wm_announce	"Allied team has constructed the Road MG Nest!"
	}

	decayed final
	{
		setstate alliedbarnmg42 invisible
		setstate alliedbarnmg42materials default
	}

	death
	{
		setstate alliedbarnmg42 invisible
		setstate alliedbarnmg42materials default
		repairmg42 alliedbarnmg42

		// Some kind of UI pop-up to alert players
		wm_announce	"Axis team has destroyed the Road MG Nest!"
	}
}

// ============================================================================
// Tunnel Entrance - The snow that has to be blasted
// ============================================================================
the_wall
{	
	spawn
	{
	}

	trigger remove
	{
		remove
	}
}

wall // The Concrete Wall
{
	spawn
	{
		wait 50
		constructible_class	3
	}

	death
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_announce	"Axis team have breached the Tunnel Entrance!"

		
		wait 1000
		trigger the_wall remove
		// *---------------------------------------------------------------------------------*
	}
}

// ============================================================================
// Forward Spawn - The North Pole
// ============================================================================

roadbunker
{
	spawn
	{
		accum 0 set 1	// 0-Axis, 1-Allied
	}

	trigger axis_capture	// Flag has been claimed by an axis player
	{
		accum 0 abort_if_equal 0 // Do Axis already own the flag?

		accum 0 set 0 // Axis own the flag
		wm_announce	"Axis capture the North Pole!"


		wm_objective_status 3 1 2
		wm_objective_status 3 0 1

		// spawns:
		// Trucks
		// Forward Bunker
		// Town
		setautospawn "Town Spawn" 1
		setautospawn "Forward Spawn" 0

		alertentity forward_spawn

	}

	trigger allied_capture	// Flag has been claimed by an allied player
	{
		accum 0 abort_if_equal 1 // Do Allies already own flag?

		accum 0 set 1 // Allied own the flag
		wm_announce	"Allies capture the North Pole!"

		wm_objective_status 3 1 1
		wm_objective_status 3 0 2

		// spawns:
		// Trucks (Axis Spawn
		// North Pole ( Forward Spawn )
		// Town ( Town Spawn)
		setautospawn "Forward Spawn" 1
		setautospawn "Axis Spawn" 0

		alertentity forward_spawn

	}

	trigger kill
	{
		remove


		wm_removeteamvoiceannounce 0 "radar_axis_bunker_stop"
		wm_removeteamvoiceannounce 1 "radar_allies_bunker_capture"
	}

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

		wm_objective_status 3 1 1
		wm_objective_status 3 0 2

		// spawns:
		// Trucks (Axis Spawn
		// North Pole ( Forward Spawn )
		// Town ( Town Spawn)
		setautospawn "Forward Spawn" 1
		setautospawn "Town Spawn" 0

		//alertentity forward_spawn
		trigger forward_spawn_spawn kill
	}

}

// ============================================
// The Christmas Star
// ============================================

star_toi
{
	spawn
	{
		wait 200
		setstate star_toi default
	}

	trigger invisible
	{
		setstate star_toi invisible
		wait 100
	}

	trigger visible
	{
		setstate star_toi default
		wait 100
	}
}

star_dropoff
{
	spawn
	{
		wait 200
		setstate star_dropoff invisible
	}

	trigger invisible
	{
		setstate star_dropoff invisible
		wait 100
	}

	trigger visible
	{
		setstate star_dropoff default
		wait 100
	}
}

star
{
	spawn
	{
	}

	trigger stolen
	{
		trigger star_toi invisible
		trigger star_dropoff visible

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_announce	"Axis has stolen the Christmas Star!"
		// *---------------------------------------------------------------------------------*
	}

	trigger returned
	{
		trigger star_toi visible
		trigger star_dropoff invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_announce	"Allies has secured the Christmas Star!"

		wm_teamvoiceannounce 0 "axis_hq_objective_secured"
		wm_teamvoiceannounce 1 "allies_hq_objective_secured"
		// *---------------------------------------------------------------------------------*
	}

	trigger captured
	{
		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_announce	"Axis have escaped with the Christmas Star!"

		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"
		// *---------------------------------------------------------------------------------*

		trigger game_manager axis_win
	}
}

