game_manager
{
	spawn
	{	
		// Game rules
		wm_number_of_objectives 1
		wm_set_round_timelimit	5


		wait 500

		setstate upper_complex_wobj invisible

		// spawns:
		// Axis Barracks
		// Axis Garage
		// Allied Barracks
		// Upper Complex
		setautospawn "Axis Spawn" 0
		setautospawn "Allied Barracks" 1

		// wait for everything to settle
		wait 500

		// *----------------------------------- 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_construct"
		// *---------------------------------------------------------------------------------*
	}

}

axis_barracks_wobj
{
	spawn
	{
		remove
	}
}

axis_barracks_spawns
{
	spawn
	{
		remove
	}
}
axis_garage_wobj
{
	spawn
	{
		remove
	}
}

axis_garage_spawns
{
	spawn
	{
		remove
	}
}

upper_complex_wobj
{
	spawn
	{
		remove
	}
}

upper_complex_spawns
{
	spawn
	{
		remove
	}
}



docs_toi
{
	spawn
	{
		wait 500
		setstate docs_cm_marker invisible
		remove
	}
}

transmitter_toi
{
	spawn
	{
		wait 500
		setstate transmitter_cmd_marker invisible
		remove
	}
}


/////////////////////////////////////////////////
// Doors
/////////////////////////////////////////////////

main_door
{
	spawn
	{
		wait 500
		
		remove
	}
}

main_door_toi
{
	spawn
	{
		wait 500
		
		remove
	}
}

service_door_toi
{
	spawn
	{
		wait 500
		
		remove
	}
}

service_door
{
	spawn
	{
		wait 500
		
		remove
	}
}

storage_wall_toi
{
	spawn
	{
		wait 500
		
		remove
	}
}

wall
{
	spawn
	{
		wait 500
		
		alertentity wall_rubble
		remove
	}
}

storage_door_controls
{
	spawn
	{
		wait 500
		remove
	}
}

moving_storage_door
{
	spawn
	{
		wait 500
		remove
	}
}

storage_button
{
}


/////////////////////////////////////////////////
// Docs
/////////////////////////////////////////////////

docs
{
	spawn
	{
		wait 50
		setstate docs invisible
	}	
}

transmitter
{
	spawn
	{
		remove
	}
}


/////////////////////////////////////////////////
// Spawn stuff
/////////////////////////////////////////////////
spawnpost_built
{
	spawn
	{
		wait 50
		constructible_class	2
		trigger spawnpost_built setup
	}

	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
	{
		trigger spawnpost_built_model trans
		trigger spawnpost_damaged_model hide
		trigger spawnpost_closed_model hide
	}

	built final
	{
		trigger spawnpost_built_model show
		trigger spawnpost_damaged_model enable
		trigger spawnpost_closed_model disable
		trigger spawnpost_built_model enable_allied_features
		//trigger upper_complex_wobj on

		enablespeaker allies_compost_sound
	}

	decayed final
	{
		trigger spawnpost_built_model hide
		trigger spawnpost_damaged_model show
		trigger spawnpost_closed_model show
	}

	death
	{
		trigger spawnpost_built_model hide
		trigger spawnpost_damaged_model show
		trigger spawnpost_built_model disable_allied_features
		//trigger upper_complex_wobj off

		disablespeaker allies_compost_sound
	}
}

spawnpost_closed_model
{
	spawn
	{
		accum 0 set 0
	}

	trigger hide
	{
		setstate spawnpost_closed invisible
		setstate spawnpost_closed_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 1
		setstate spawnpost_closed default
		setstate spawnpost_closed_model default
	}

	trigger disable
	{
		accum 0 set 1
	}
}

spawnpost_damaged_model
{
	spawn
	{
		accum 0 set 0
		wait 200
		setstate spawnpost_damaged invisible		
		setstate spawnpost_damaged_model invisible		
	}

	trigger hide
	{
		setstate spawnpost_damaged invisible
		setstate spawnpost_damaged_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 1
		setstate spawnpost_damaged default
		setstate spawnpost_damaged_model default
	}

	trigger disable
	{
		accum 0 set 1
	}
}

spawnpost_built_model
{
	spawn
	{
		accum 1 set 0
		accum 2 set 0 // state of command post as far as the VO is concerned (0=not built, 1=built) - Wils
		wait 200
		setstate spawnpost_built_model invisible
	}

	trigger show
	{
		setstate spawnpost_built_model default
		enablespeaker spawnpost_sound
	}

	trigger hide
	{
		setstate spawnpost_built_model invisible
		disablespeaker spawnpost_sound
	}

	trigger trans
	{
		setstate spawnpost_built_model underconstruction
	}

	trigger enable_allied_features
	{
		// allies built it
		accum 1 set 1 // Is this ever used? - Wils
		accum 2 set 1 // State of com post as far as VO is concerned (1=built)
		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_objective_status	6 1 1
		wm_objective_status	6 0 2

		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"
		// *---------------------------------------------------------------------------------*
	}

	trigger disable_allied_features
	{
		// allies lost it
		accum 2 set 0 // state of com post as far as VO is concerned (0=destroyed)
		wm_announce	"Axis team has destroyed the Allied Command Post!"

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

		wm_objective_status	6 1 0
		wm_objective_status	6 0 0

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

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *---------------------------------------------------------------------------------*
	}
}

/////////////////////////////////////////////////
// Axis Command Post
/////////////////////////////////////////////////
axis_compost_built
{
	spawn
	{
		wait 50
		constructible_class	2
		trigger axis_compost_built setup
	}

	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
	{
		trigger axis_compost_built_model trans
		trigger axis_compost_damaged_model hide
		trigger axis_compost_closed_model hide
	}

	built final
	{
		trigger axis_compost_built_model show
		trigger axis_compost_damaged_model enable
		trigger axis_compost_closed_model disable
		trigger axis_compost_built_model enable_axis_features

		enablespeaker axis_compost_sound
	}

	decayed final
	{
		trigger axis_compost_built_model hide
		trigger axis_compost_damaged_model show
		trigger axis_compost_closed_model show
	}

	death
	{
		trigger axis_compost_built_model hide
		trigger axis_compost_damaged_model show
		trigger axis_compost_built_model disable_axis_features

		disablespeaker axis_compost_sound
	}
}

axis_compost_closed_model
{
	spawn
	{
		accum 0 set 0
	}

	trigger hide
	{
		setstate axis_compost_closed invisible
		setstate axis_compost_closed_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 1
		setstate axis_compost_closed default
		setstate axis_compost_closed_model default
	}

	trigger disable
	{
		accum 0 set 1
	}
}

axis_compost_damaged_model
{
	spawn
	{
		accum 0 set 0
		wait 200
		setstate axis_compost_damaged invisible		
		setstate axis_compost_damaged_model invisible		
	}

	trigger hide
	{
		setstate axis_compost_damaged invisible
		setstate axis_compost_damaged_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 1
		setstate axis_compost_damaged default
		setstate axis_compost_damaged_model default
	}

	trigger disable
	{
		accum 0 set 1
	}
}

axis_compost_built_model
{
	spawn
	{
		accum 1 set 0
		accum 2 set 0 // state of command post as far as the VO is concerned (0=not built, 1=built) - Wils
		wait 200
		setstate axis_compost_built_model invisible
	}

	trigger show
	{
		setstate axis_compost_built_model default
		enablespeaker axis_compost_sound
	}

	trigger hide
	{
		setstate axis_compost_built_model invisible
		disablespeaker axis_compost_sound
	}

	trigger trans
	{
		setstate axis_compost_built_model underconstruction
	}

	trigger enable_axis_features
	{
		// axis built it
		accum 1 set 1 // Is this ever used? - Wils
		accum 2 set 1 // State of com post as far as VO is concerned (1=built)
		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_objective_status	5 0 1
		wm_objective_status	5 1 2

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

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"

		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"

		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}

	trigger disable_axis_features
	{
		// axis lost it
		accum 2 set 0 // state of com post as far as VO is concerned (0=destroyed)
		wm_announce	"Allied team has destroyed the Axis Command Post!"

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

		wm_objective_status	5 1 0
		wm_objective_status	5 0 0

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

		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *---------------------------------------------------------------------------------*
	}
}


/////////////////////////////////////////////////
// Misc stuff
/////////////////////////////////////////////////

main_door_flag
{
	trigger disable
	{
		disablespeaker main_door_flag_sound
	}
}
transmitter_flag
{
	trigger disable
	{
		disablespeaker transmitter_flag_sound
	}
}
courtyard_flag
{
	trigger disable
	{
		disablespeaker courtyard_flag_sound
	}
}


angled_truck
{
	spawn
	{
		faceangles 0 45 0 1
	}
}


// accum 1
// 0 = original record
// 1 = damaged record
// accum 2
// 0 = off
// 1 = playing
gramophone
{
	spawn
	{
		accum 1 set 0
		accum 2 set 0
	}
	
	trigger damage_record
	{
		accum 1 set 1
		setstate record_broken default
		trigger gramophone damage_music
	}
	trigger damage_music
	{
		accum 2 abort_if_not_equal 1
		togglespeaker record_music
		accum 2 set 0
	}

	trigger fix_record
	{
		accum 1 set 0
		setstate record_broken invisible
		trigger gramophone fix_music
	}
	trigger fix_music
	{
		accum 2 abort_if_not_equal 1
		togglespeaker record_music_broken
		accum 2 set 0
	}
	
	trigger activate
	{
		trigger gramophone turn_off
		trigger gramophone turn_on
	}
	
	trigger turn_off
	{
		accum 2 abort_if_equal 0
		resetscript
		accum 2 set 0
		trigger gramophone original_off
		trigger gramophone broken_off
	}
	
	trigger original_off
	{
		accum 1 abort_if_equal 1
		resetscript
		trigger record stop
		togglespeaker record_music
		togglespeaker record_scratch
	}
	
	trigger broken_off
	{
		accum 1 abort_if_equal 0
		resetscript
		trigger record_broken stop
		togglespeaker record_music_broken
	}

	trigger turn_on
	{
		accum 2 abort_if_equal 1
		resetscript
		accum 2 set 1
		trigger gramophone original_on
		trigger gramophone broken_on
	}
	
	trigger original_on
	{
		accum 1 abort_if_equal 1
		resetscript
		trigger record start
		togglespeaker record_scratch
		wait 430
		togglespeaker record_music
	}
	
	trigger broken_on
	{
		accum 1 abort_if_equal 0
		resetscript
		trigger record_broken start
		togglespeaker record_music_broken
	}
	
	
}


record
{
    	spawn
    	{
	        constructible_class 1
	        constructible_chargebarreq 0.3
		constructible_constructxpbonus 0
		constructible_destructxpbonus 0
		constructible_health 10
		constructible_weaponclass 1
		constructible_duration 2500
	}

	trigger start
	{
		setrotation 0 -80 0
	}

	trigger stop
	{
		stoprotation
	}
	
	death
	{
		trigger record stop
		trigger gramophone damage_record
	}
	
	built
	{
		trigger gramophone fix_record
	}
}

record_broken
{
	spawn
	{
		setstate record_broken invisible
	}

	trigger start
	{
		setrotation 0 -80 0
	}

	trigger stop
	{
		stoprotation
	}
	
}


gramophone_toi
{
	spawn
	{
		//setstate gramophone_toi invisible
	}
}



// ============================================================================
// Platform MG42 Nest
// ============================================================================
platformmg42_script 
{ 
   spawn 
   { 
      wait 200 
      constructible_class 2 
      trigger self startup 
   } 

   buildstart final 
   { 
   } 

   built final 
   { 
      setstate platformmg42_sbags default 
      setstate platformmg42 default 
      setstate platformmg42_materials invisible 

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

   decayed final 
   { 
      trigger self startup 
   } 

   death 
   { 
      trigger self startup 
      // Some kind of UI pop-up to alert players 
	wm_announce	"Allied team has destroyed the Platform MG Nest!"
   } 

   trigger startup 
   { 
      setstate platformmg42_sbags invisible 
      setstate platformmg42 invisible 
      setstate platformmg42_materials default 
      repairmg42 platformmg42 
   } 
} 




