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

		// Objectives
		// 1: Capture Flag
		// 2: Blow Security Doors
		// 3: Disable Bomb
		// 4: Construct CP
		// 5: Prevent Construct CP
		

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

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

		accum 1 set 0		// Bomb status

		wait 500
		setautospawn	"Office"	0
		setautospawn	"Office"	1
               

                

		// start triggered loops on/off as required (eg: command post radio sounds)
		disablespeaker allies_compost_sound
		disablespeaker axis_compost_sound
		disablespeaker allies_compost_sound_lms
		disablespeaker axis_compost_sound_lms



		wait 2000

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

		
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		
		wm_addteamvoiceannounce 0 "warehouse_axis_doors_stop"

		
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"


		wm_teamvoiceannounce 0 "warehouse_axis_doors_stop"

		// *---------------------------------------------------------------------------------*
	}


	trigger security_door_destroyed
	{
		wm_objective_status 2 1 1
		wm_objective_status 2 0 2

		wm_set_main_objective		3	0
		wm_set_main_objective		3	1
                trigger officeflag force_allied // Switch forward spawn to Allied ONLY

		trigger officeflag check_obj

		trigger officeflag kill //Remove flag

		wm_announce "Allies have breached the security door"

		// *----------------------------------- vo ------------------------------------------*
                
		wm_teamvoiceannounce 0 "warehouse_axis_doors_destroyed"

		wm_teamvoiceannounce 1 "warehouse_allies_doors_destroyed"

		wm_removeteamvoiceannounce 0 "warehouse_axis_doors_stop"

                // *---------------------------------------------------------------------------------*


	}

	trigger bomb_disabled
	{
		accum 1 inc 1 // Bomb disabled
		wm_objective_status 3 1 1
		wm_objective_status 3 0 2

		
		wm_announce "Allies have disabled the bomb"

		// *----------------------------------- vo ------------------------------------------*
                
		wm_teamvoiceannounce 0 "axis_hq_objective_destroyed"

		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"

                // *---------------------------------------------------------------------------------*
                trigger self checkgame
                
	}

	trigger checkgame
	{
		accum 1 abort_if_not_equal 1
		wm_setwinner 1
		wait 1500
		wm_endround
	}

}


// OBJECTIVES =============================================================================================

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

	trigger axis_capture	// Flag has been touched by an Axis player
	{
		accum 0 abort_if_equal 0 // do Axis own flag?

		accum 0 set 0 // Axis own the pole
		
		wm_announce	"Axis reclaim the offices!"
                
                
		wm_objective_status 		1 0 1
		wm_objective_status 		1 1 2
                wm_set_main_objective 2 0
		wm_set_main_objective 2 1
                alertentity office_wobj
		
	}

	trigger allied_capture	// Flag has been 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	"Allies capture the offices!"
                
                
                wm_objective_status 		1 0 2
		wm_objective_status 		1 1 1
                wm_set_main_objective 1 0
		wm_set_main_objective 1 1
		alertentity office_wobj
               
	}

        trigger check_obj
	{
		accum 0 abort_if_equal 1 // Do Allied own the flag?

		wm_objective_status 		2 0 2
		wm_objective_status 		2 1 1

	}

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

		alertentity office_wobj
		alertentity officespawns
	}

	trigger kill
	{
		remove
	}
}

	


security_door
{
	spawn
	{
		wait 50
		constructible_class	3
                setstate door_pieces invisible
	}

	death
	{
		trigger game_manager security_door_destroyed
                setstate axis_door1 invisible
                setstate door_pieces default
	}
}

bomb
{
	spawn
	{
		wait 200
		constructible_class	3
                
	}

	death
	{
               trigger game_manager bomb_disabled
        }
}





// CONSTRUCTION ==================================================================

MG42
{ 
   spawn 
   { 
      wait 200 
      constructible_class 2
      trigger self startup 
       
   } 

   buildstart final 
   { 
   } 

   built final 
   {  
      setstate MG42_model default 
      setstate MG42_materials invisible 

      // Some kind of UI pop-up to alert players 
      wm_announce   "Axis team has built the mg42!" 
   } 

   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 mg42!" 
   } 

   trigger startup 
   {  
      setstate MG42_model invisible 
      setstate MG42_materials default 
      repairmg42 MG42_model
   } 
} 

service_door
{ 
   spawn 
   { 
      wait 200 
      constructible_class 2 
      setstate service_door_materials invisible
   } 

   buildstart final 
   { 
   } 

   built final 
   {  
      setstate service_door_materials invisible 

      // Some kind of UI pop-up to alert players
      wm_announce   "Axis team has rebuilt the Service Door!"  
       
   } 

   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 Service Door!"
   } 

   trigger startup 
   {  
       
      setstate service_door_materials default 
      
   } 
} 


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 4 0 2
		wm_objective_status 4 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 4 0 0
		wm_objective_status 4 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 5 0 1
		wm_objective_status 5 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 5 0 0
		wm_objective_status 5 1 0
	}
}


// MOVERS ==============================================================================================

lift_trigger
{
	spawn
	{
		accum 5 set 1			// Initial state is down
		wait 500			// Wait for everything to settle
		trigger lift_trigger main	// Move switch into correct position
	}
	trigger main
	{
		trigger lift_trigger up
		trigger lift_trigger down
		
	}	
	trigger up
	{
			accum 5 abort_if_not_equal 1	// Ready to run up routine == 1
			resetscript			// wont return to trigger that called it

			trigger lift_lever up
			
			accum 5 set 0			// Setup accum for up routine
	}
	trigger down
	{
			accum 5 abort_if_not_equal 0	// Ready to run down routine == 0
			resetscript			// wont return to trigger that called it

			trigger lift_lever down
			
			accum 5 set 1			// Setup accum for up routine
	}
}


lift_lever
{
	spawn
	{
	}
	trigger down
	{
		gotomarker lift_lever_downpos 16
		playsound sound/movers/switches/butn2.wav
		trigger lift down
		
	}
	trigger up
	{
		gotomarker lift_lever_uppos 16
		playsound sound/movers/switches/switch.wav
		trigger lift up
		
	}
}



lift
{
	spawn
	{
	}

	trigger down
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker lift_pos2 15 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
                
	}

	trigger up
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker lift_pos1 15 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
               
	}
}

door_trigger1
{
	spawn
	{
		accum 5 set 1			// Initial state is down
		wait 500			// Wait for everything to settle
		trigger door_trigger1 main	// Move switch into correct position
	}
	trigger main
	{
		trigger door_trigger1 up
		trigger door_trigger1 down
		
	}	
	trigger up
	{
			accum 5 abort_if_not_equal 1	// Ready to run up routine == 1
			resetscript			// wont return to trigger that called it

			trigger door_lever1 up
			trigger door_lever2 up
			accum 5 set 0			// Setup accum for up routine
	}
	trigger down
	{
			accum 5 abort_if_not_equal 0	// Ready to run down routine == 0
			resetscript			// wont return to trigger that called it

			trigger door_lever1 down
			trigger door_lever2 down
			accum 5 set 1			// Setup accum for up routine
	}
}


door_lever1
{
	spawn
	{
	}
	trigger down
	{
		gotomarker door_lever1_downpos 16
		playsound sound/movers/switches/butn2.wav
		trigger door_left open
		trigger door_right open
	}
	trigger up
	{
		gotomarker door_lever1_uppos 16
		playsound sound/movers/switches/switch.wav
		trigger door_left close
		trigger door_right close
	}
}

door_lever2
{
	spawn
	{
	}

	trigger down
	{
		gotomarker door_lever2_downpos 16
		playsound sound/movers/switches/butn2.wav
	}

	trigger up
	{
		gotomarker door_lever2_uppos 16
		playsound sound/movers/switches/switch.wav
	}
}


door_left
{
	spawn
	{
	}

	trigger open
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker door_leftpos2 15 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
	}

	trigger close
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker door_leftpos1 15 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
	}
}

door_right
{
	spawn
	{
	}

	trigger open
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker door_rightpos2 18 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
	}

	trigger close
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker door_rightpos1 18 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
	}
}

hatch_controller
{
	activate
	{
		trigger hatch use
	}
}

hatch
{
	trigger use
	{
		trigger hatch open
		trigger hatch close
	}

	trigger open
	{
		accum 1 abort_if_equal 1
		accum 0 abort_if_equal 1
		accum 1 set 1
		accum 0 set 1

		wait 50
		playsound sound/movers/doors/door5_open.wav
		faceangles 0 0 270 1500

		accum 0 set 0
	}

	trigger close
	{
		accum 1 abort_if_equal 0
		accum 0 abort_if_equal 1
		accum 1 set 0
		accum 0 set 1

		wait 50
		playsound sound/movers/doors/door5_close.wav
		faceangles 0 0 0 1500
		playsound sound/movers/doors/door5_endc.wav

		accum 0 set 0
	}
}

ceilingfan
{
	spawn
	{
		wait 100
		setrotation	0 300 0
	}
}
