game_manager
{
 spawn
 {  
  // Game rules
  wm_axis_respawntime 20
  wm_allied_respawntime 15
  wm_number_of_objectives 8
  wm_set_round_timelimit 30
  
  wm_objective_status 1 1 0  // COMMAND POST
  wm_objective_status 1 0 0  
  wm_objective_status 2 1 0  // FULE DUMP DEFENCES
  wm_objective_status 2 0 0  
  wm_objective_status 3 1 0  // FORWARD SPAWN
  wm_objective_status 3 0 0  
  wm_objective_status 4 1 0  // FRONT DOOR
  wm_objective_status 4 0 0  
  wm_objective_status 5 1 0  // FUEL DUMP
  wm_objective_status 5 0 0    
  wm_objective_status 6 1 0  // BLOCKADE
  wm_objective_status 6 0 0 
  wm_objective_status 7 1 0  // WATER
  wm_objective_status 7 0 0
  wm_objective_status 8 1 0  // DOOR
  wm_objective_status 8 0 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


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

 trigger allies_win // this is called from the objectives deathpart to end the game.
 {
  wm_setwinner 1
  wm_announce "Allied team has destroyed Axis Fuel Dump"

  wait 1500
  wm_endround
 }

}
//////////
// DOOR //
/////////
cteamdoor1
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class 2			// Dyno+Satchel
	}

	trigger setup
	{
		setstate cteamdoor1_materials default	// Crate Models
		setstate cteamdoor1_clip default		// Clip brushes
		setstate cteamdoor1_flag default
		setstate cteamdoor1_fake invisible	// only used during building

		setstate axisteamdoor1 invisible		// team door entity
	}

	built final
	{
		setstate cteamdoor1_materials invisible	// Crate Models
		setstate cteamdoor1_clip invisible		// Clip brushes
		setstate cteamdoor1_flag invisible
		setstate cteamdoor1_fake invisible	// fake team door

		setstate axisteamdoor1 default		// team door entity
		wm_announce "Axis Team have built the Old Mine Team Door"
  		wm_objective_status 7 0 1
 		wm_objective_status 7 1 2
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		trigger self setup
		wm_announce "Allies have destroyed the Axis Old Mine Team Door!!" 
  		wm_objective_status 7 1 1
 		wm_objective_status 7 0 2
	}
}
////////////
// WATER //	
//////////
waterpump1
{
	spawn
	{
		wait 1000
		constructible_class 2	// Dyno+Satchel
		trigger self setup
	}

	trigger setup
	{
		setstate waterpump1_materials default
		setstate waterpump1_materials_clip default
		setstate waterpump1_flag default

		setstate waterpump1_base default
		setstate waterpump1_wheel invisible
		setstate waterpump1_clip default

		disablespeaker waterpump1_sound
	}

	built final
	{
		setstate waterpump1_materials invisible
		setstate waterpump1_materials_clip invisible
		setstate waterpump1_flag invisible

		setstate waterpump1_wheel default
		setstate waterpump1_clip invisible

		enablespeaker waterpump1_sound

		trigger water1 down
		wm_announce "Allies have built the Water Pump! Old mines Clearing."
  		wm_objective_status 7 1 1
 		wm_objective_status 7 0 2

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "oasis_axis_pump_disable"
		wm_teamvoiceannounce 0 "oasis_axis_caves_drain"

		wm_teamvoiceannounce 1 "oasis_allies_pump_repaired"
		wm_teamvoiceannounce 1 "oasis_allies_caves_drain"

		wm_removeteamvoiceannounce 0 "oasis_axis_pump_stop"
		wm_removeteamvoiceannounce 1 "oasis_allies_pump_repair"
		// *---------------------------------------------------------------------------------*
	}

	death
	{
		trigger self setup

		trigger water1 up
		wm_announce "Axis have damaged the Water Pump! Old mines flooding."
  		wm_objective_status 7 1 2
 		wm_objective_status 7 0 1

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "oasis_axis_pump_stop"
		wm_addteamvoiceannounce 1 "oasis_allies_pump_repair"

		wm_teamvoiceannounce 0 "oasis_axis_pump_disabled"
		wm_teamvoiceannounce 0 "oasis_axis_caves_flood"

		wm_teamvoiceannounce 1 "oasis_allies_pump_disabled"
		wm_teamvoiceannounce 1 "oasis_allies_caves_flood"
		// *---------------------------------------------------------------------------------*

	}

	decayed final
	{
		trigger self setup
	}
}

waterpump1_wheel
{
	spawn
	{
		startanimation 0 40 20 nolerp
	}
}

water1
{
	trigger up
	{
		gotomarker water1_top 5 wait
	}
	trigger down
	{
		gotomarker water1_bottom 5 wait
	}
}


// ================================================
// ============ 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!"
  wm_objective_status 1 1 1
  wm_objective_status 1 0 2

  // *----------------------------------- 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
 {
  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!"
  wm_objective_status 1 1 2
  wm_objective_status 1 0 2

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


 }
}

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!"
  wm_objective_status 1 0 1
  wm_objective_status 1 1 2

  // *----------------------------------- vo ------------------------------------------*
  wm_teamvoiceannounce 0 "axis_hq_compost_constructed"

  wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"

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

 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!"
  wm_objective_status 1 0 2
  wm_objective_status 1 1 2


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

 }

}
// ================================================
// ============ FUEL DUMP DEFENCES ================
// ================================================
construction_script 
{ 
   spawn 
   { 
      wait 200 
      constructible_class 2 
      trigger self startup 
   } 

   buildstart final 
   { 
   } 

   built final 
   { 
      setstate fuel invisible 

      // Some kind of UI pop-up to alert players 
      wm_announce   "Axis Have Built the Fuel Dump Defences" 
  wm_objective_status 2 0 1
  wm_objective_status 2 1 2
   } 

   decayed final 
   { 
      trigger self startup 
   } 

   death 
   { 
      trigger self startup 
      // Some kind of UI pop-up to alert players 
      wm_announce   "Allied team has destroyed Fuel Dump Defences #1!" 
  wm_objective_status 2 0 2
  wm_objective_status 2 1 1
   } 

   trigger startup 
   { 
      setstate fuel default 

   } 
} 
////////////////////////
/// BUNKER BLOCKADE ///
//////////////////////
bunker_blockade 
{ 
   spawn 
   { 
      wait 200 
      constructible_class 3 
      trigger self startup 
   } 

   buildstart final 
   { 
   } 

   built final 
   { 
      setstate bunkerbuild invisible 

      // Some kind of UI pop-up to alert players 
      wm_announce   "Axis Have built the Bunker Blockade" 
  wm_objective_status 6 0 1
  wm_objective_status 6 1 2
   } 

   decayed final 
   { 
      trigger self startup 
   } 

   death 
   { 
      trigger self startup 
      // Some kind of UI pop-up to alert players 
      wm_announce   "Allies have Destroyed the Bunker Blockade" 
  wm_objective_status 6 0 2
  wm_objective_status 6 1 1
   } 

   trigger startup 
   { 
      setstate bunkerbuild default 
   } 
} 

// ================================================
// ============ Blow up Shit! =====================
// ================================================
fule
{ 
   spawn 
   { 
      wait 200 
      constructible_class 3 
   } 

   death 
   { 
      alertentity "smoke"
      wm_announce "The Allies have destroyed the Fuel Dump" 
      wm_teamvoiceannounce 1 "allies_hq_objective_destroyed" 
  wm_objective_status 5 0 2
  wm_objective_status 5 1 1
      trigger game_manager allies_win
   } 

}
frontdoor
{ 
   spawn 
   { 
      wait 200 
      constructible_class 3 
   } 

   death 
   { 
      wm_announce "The Allies have breached the Fortress Doors!" 
      wm_teamvoiceannounce 1 "allies_hq_objective_destroyed" 
  wm_objective_status 4 0 2
  wm_objective_status 4 1 1 
   } 

}
//////////////////////
// Forward spawn   //
////////////////////

forward_spawn
{
 spawn
 {
  wait 200
  setstate forwardflag_wobj invisible
  accum 0 set 0
 }

 trigger forwardflagblue
 {
  wm_announce "Allies capture the forward spawn!"
  wm_objective_status 5 0 2
  wm_objective_status 5 1 1
 }

 trigger forwardflagred
 {
  wm_announce "Axis capture the forward spawn!"
  wm_objective_status 5 0 1
  wm_objective_status 5 1 2
 }

 trigger axis_capture
 {
  trigger self forwardflagred
  trigger self setaxis
  setautospawn "Forward spawn" 0
 }

 trigger allied_capture
 {
  trigger self forwardflagblue
  trigger self setallies
  setautospawn "Forward spawn" 1
 }

 trigger setaxis
 {
  setstate forwardflag_wobj default
  accum 0 abort_if_equal 0
  accum 0 set 0
  globalaccum 0 set 0
  alertentity forwardflag_wobj
  setautospawn "Forward spawn" 0
 }

 trigger setallies
 {
  setstate forwardflag_wobj default
  accum 0 abort_if_equal 1
  accum 0 set 1
  globalaccum 0 set 1
  alertentity forwardflag_wobj
  setautospawn "Forward spawn" 1
 }

 trigger force_allied
 {
  setstate forwardflag_wobj default
  globalaccum 0 abort_if_equal 1
  alertentity forwardflag_wobj
  alertentity forward_spawn
  setautospawn "Forward spawn" 1
 }


 trigger kill
 {
  remove
  setstate forward invisible
 }
 trigger force
 {
  trigger self force_allied
  trigger self kill
 }
}


