// TheCave script file
// So you have intress about my 1024^3 competition map
// Please take a look I do not mind.
// game manager starts here
game_manager
{

	// Initialising

	// When game starts
	spawn
	{
		// Level initialisation
		remapshaderflush		

		wm_set_round_timelimit 10
		wm_setwinner 0		
		wm_axis_respawntime 15
		wm_allied_respawntime 15

		// Set Defending Team for SW Mode
		wm_set_defending_team 0

		// Set objectives
		// 0:blank|1:tick|2:cross
		// Allies = 1, Axis = 0
		// Objectives
		// 1: bridge		
		// 2: pump
		// 3: end		
		
		
		
		wm_number_of_objectives 3


		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						
					
		wait 500	
		
		trigger water1 reset				
		
		
		
	}
	
	trigger allies_win
	{
		wm_setwinner	1			
		
		wm_endround
	}
	

	
	
}

// Allied bridge!
construction_script
{
   spawn
   {
      wait 200
      constructible_class 2
      trigger self startup
   }

   buildstart final
   {
   }

   built final
   {
      
      setstate construction_materials invisible

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

   decayed final
   {
      trigger self startup
   }

   death
   {
      trigger self startup      
      wm_announce   "Axis team has destroyed the Bridge!"
   }

   trigger startup
   {
      
      setstate construction_materials default
     
   }

}

// Axis pump generator
construction_script2
{
   spawn
   {
      wait 200
      constructible_class 2
      setstate construction_materials2 invisible
	
   }

   buildstart final
   {
   }

   built final
   {
      
      setstate construction_materials2 invisible
      alertentity smoke1
      // Some kind of UI pop-up to alert players
      wm_announce   "Axis team has built the Water pump Generator!"
      enablespeaker machine1
      trigger water1 down
      setstate gentoi default 
   }

   decayed final
   {
      trigger self startup
   }

   death
   {
      trigger self startup 
      alertentity smoke1     
      wm_announce   "Allied team has destroyed the Water pump Generator!"
      setstate gentoi invisible
      disablespeaker machine1
      trigger water1 up
   }

   trigger startup
   {
      
      setstate construction_materials2 default
     
   }

}

// water
water1
{
	trigger up
	{
		enablespeaker water1
		enablespeaker water2
		gotomarker wup 6 
		trigger water2 up		
	}

	trigger down
	{
		gotomarker middle 6 wait 	
		gotomarker wdown 6 	
		trigger water2 down	
	}

	trigger reset
	{
		gotomarker wdown 900 
		trigger water2 reset		
	}
}

// water2 controlled by water 1 do not touch!!
water2
{
	trigger up
	{
		gotomarker wup2 6 	
	}

	trigger down
	{
		gotomarker wdown2 6 wait
		disablespeaker water1 
		disablespeaker water2 	
	}

	trigger reset
	{
		gotomarker wdown2 900 	
	}
}

allied_win
{
	trigger allied_win
	{
		trigger game_manager allies_win
	}	
}

// Opens door switch!
opdoor
{
	trigger opdoor
	{
		trigger door dooraction
	}	
}

// the final door
door
{
	spawn
	{
		wait 500
		accum 1 set 1
	}
	
	trigger check_up
	{
		accum 1 abort_if_not_equal 1
		trigger door up
		
	}

	trigger check_down
	{
		accum 1 abort_if_not_equal 0
		trigger door down
		
	}
	
	trigger dooraction
	{
		trigger door check_up 	
		trigger door check_down 	
	}
	
	trigger up
	{
		accum 1 set 0
		gotomarker door_t2 6
		trigger lever down		
		resetscript 	
	}

	trigger down
	{
		accum 1 set 1
		gotomarker door_t1 6 
		trigger lever up
		resetscript	
	}	
}

// lever controlled by door do not touch!!
lever
{
	trigger up
	{		
		wm_announce   "The escape door has been shut!"
		enablespeaker door1
		togglespeaker sw1
		gotomarker lever_t1 6 wait
		wait 8500
		disablespeaker door1
		togglespeaker end1
	}

	trigger down
	{
		wm_announce   "The escape door has been opened!"
		enablespeaker door1
		togglespeaker sw1
		gotomarker lever_t2 6 wait
		wait 8500
		disablespeaker door1
		togglespeaker end1 	
	}
	
}

ladlms
{
	spawn
	{
		wait 200
		setstate ladlms invisible 
		
	}
}

ladlms2
{
	spawn
	{
		wait 200
		setstate ladlms2 invisible 
		
	}
}

