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

		

		accum 3 set 2	


		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_objective_status 1 1 0
		wm_objective_status 2 1 0
		wm_objective_status 6 0 0
		wm_objective_status 6 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

		wait 2000

		setautospawn	"main"	0
		setautospawn	"alliesmain"	1

	}

	trigger allies_flag
	{

		wm_objective_status 		6 1 1
		wm_objective_status 		6 0 0
		
		wm_announce	"^5Allies capture the forward shack!"

	}
	
	trigger axis_flag
	{

		wm_objective_status 		6 0 1
		wm_objective_status 		6 1 0

		wm_announce	"^5Axis capture the forward Shack!"



	}
// Axis object taken (objective 1)
  trigger axis_object_stolen
  {
    wm_objective_status 1 1 1
    wm_announce "^5ALLIES HAVE TAKE THE L.S.D Synth!!!!!!!!!!!!!!!!!"
  }

  // Axis object returned (objective 1)
  trigger axis_object_returned
  {
    wm_objective_status 1 1 0
 wm_announce "^5AXIS HAVE RETURNED THE SYNTH!!!!!!!!!!!!!!!!!"
  }

  // Objective 2 has been taken to destination
  trigger objective_2_done
  {
    // Mark objective as delivered
    accum 1 set 1
    wm_objective_status 2 1 1
    wm_announce "^5Allies Loaded the L.S.D synth aboard the getaway truck and escaped!"

    // Check if game won
    trigger game_manager objectives_complete
	
  }

  // Are objectives complete?
  trigger objectives_complete
  {
    // Abort this function if objective 1 has not been destroyed
    accum 1 abort_if_not_equal 1

    // Mark Allies as the winners
    wm_setwinner 1

    // End the level
    wm_endround
  }
}

// ================================================
// ============    FORWARD SPAWN     ==============
// ================================================

forward_spawn
{
	spawn
	{
	// accum 3 set 2	// 0-Axis, 1-Allied
	}


	trigger axis_capture
	{

		accum 3 abort_if_not_equal 1

		accum 3 set 0

		trigger game_manager axis_flag

		setautospawn	"Forward Spawn"	0
		setautospawn	"alliesmain"	1

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		  wm_addteamvoiceannounce 0 "battery_axis_bunker_defend" 

      wm_addteamvoiceannounce 1 "battery_allies_bunker_capture" 

      wm_teamvoiceannounce 0 "battery_axis_bunker_captured" 

      wm_teamvoiceannounce 1 "battery_allies_bunker_lost" 

      wm_removeteamvoiceannounce 0 "battery_axis_bunker_capture" 

      wm_removeteamvoiceannounce 1 "battery_allies_controls_destroy" 

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

	trigger allied_capture
	{

		accum 3 abort_if_not_equal 0

		accum 3 set 1

		trigger game_manager allies_flag

		setautospawn	"main"	0
		setautospawn	"Forward Spawn"	1

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "battery_axis_controls_defend" 
      wm_addteamvoiceannounce 0 "battery_axis_bunker_capture" 

      wm_addteamvoiceannounce 1 "battery_allies_controls_destroy" 

      wm_teamvoiceannounce 0 "battery_axis_bunker_lost" 
      wm_teamvoiceannounce 0 "battery_axis_controls_defend" 

      wm_teamvoiceannounce 1 "battery_allies_bunker_captured" 
      wm_teamvoiceannounce 1 "battery_allies_controls_destroy" 

      wm_removeteamvoiceannounce 0 "battery_axis_bunker_defend" 

      wm_removeteamvoiceannounce 1 "battery_allies_bunker_capture" 
		// *---------------------------------------------------------------------------------*

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

		wm_objective_status 		4 0 2
		wm_objective_status 		4 1 1

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

		
		alertentity forward_spawn
	}

	
}
// ================================================
// ============ NEUTRAL COMMAND POST ==============
// ================================================
// FROM GOldRush Thx SD!!! prefab by seven 2003 

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.50
		setchargetimefactor 1 lieutenant 0.65
		setchargetimefactor 1 medic 0.50
		setchargetimefactor 1 engineer 0.60
		setchargetimefactor 1 covertops 0.50
		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 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	"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 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	"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 7 0 1
		wm_objective_status 7 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 7 0 0
		wm_objective_status 7 1 0
	}
}
construction_script 
{ 
   spawn 
   { 
      wait 200 
      constructible_class 2 
      trigger self startup 
   } 

   buildstart final 
   { 
   } 

   built final 
   { 
      setstate construction_extra default 
      setstate construction_mg42  default 
      setstate const_tower        invisible 

      // Some kind of UI pop-up to alert players 
      wm_announce   "COMMAND POST MG CONSTRUCTED" 
   } 

   decayed final 
   { 
      trigger self startup 
   } 

   death 
   { 
      trigger self startup 
      // Some kind of UI pop-up to alert players 
      wm_announce   "Command Post MG DESTROYED!" 
   } 

   trigger startup 
   { 
      setstate construction_extra invisible 
      setstate construction_mg42  invisible 
      setstate const_tower        default 
      repairmg42 construction_mg42 
   } 
} 
 

// The Allies have taken the Axis object to it's destination
lsddrop
{
  spawn
  {
  }

  death
  {
    trigger game_manager objective_2_done
  }
} 



tunnelwall
{
   spawn
   {
      wait 200
      constructible_class 3
   }
   death
   {
     		 wm_announce "^4Allies have blown up the Tunnel wall!"
		trigger forward_spawn force_allied // Switch forward spawn to Allied ONLY

		trigger forward_spawn check_obj

		trigger forward_spawn kill

   }
}
labdoor
{
   spawn
   {
      wait 200
      constructible_class 3
   }
   death
   {
      wm_announce "Allies Have Blow the Lab Door!"
   }
}

