game_manager
{
spawn
{
// Set scenario information
wm_axis_respawntime 30
wm_allied_respawntime 20
wm_number_of_objectives 5
wm_set_round_timelimit 15

//Adlernest mapscript by Dersaidin

// 0  is axis
wm_set_defending_team 0
wm_setwinner 0

//Take docs
wm_objective_status 1 1 0
wm_objective_status 1 0 0
//Cap docs
wm_objective_status 2 1 0
wm_objective_status 2 0 0
//CP
wm_objective_status 3 1 0
wm_objective_status 3 0 0
//Doors
wm_objective_status 4 1 0
wm_objective_status 4 0 0
//Maindoor
wm_objective_status 5 1 0
wm_objective_status 5 0 1

//main opjective is to cap docs
wm_set_main_objective 2 1
wm_set_main_objective 2 0

// Cap docs
accum 1 set 0
//Take docs
accum 2 set 0
//Allied CP built once
accum 3 set 0
//Maindoorr, 1=open 0=closed 2=working
accum 4 set 0
//Maindoorl, 1=open 0=closed 2=working
accum 5 set 0
//Allied CP _IS_ built
globalaccum 6 set 0

wait 4000
trigger game_manager startvos

wait 500
trigger tank_turret facewall

}

trigger startvos
{
	// *----------------------------------- vo ------------------------------------------*
	wm_addteamvoiceannounce 0 "adlernest_axis_controls_defend"
	//wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

	wm_addteamvoiceannounce 1 "adlernest_allies_controls_destroy"
	wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

	wm_teamvoiceannounce 0 "adlernest_axis_controls_defend"
	//wm_teamvoiceannounce 0 "axis_hq_compost_construct"

	wm_teamvoiceannounce 1 "adlernest_allies_controls_destroy"
	wm_teamvoiceannounce 1 "allies_hq_compost_construct"
	// *---------------------------------------------------------------------------------*
}

trigger cap_docs
{
	//cap docs: true
	wm_objective_status 2 1 1
	wm_objective_status 2 0 2
	//cap docs: true
	accum 1 set 1
	wm_announce "Allied team has transmitted the documents!"
	trigger game_manager checkgame
}

trigger axis_object_stolen
{
	//wm_announce	"Allies have stolen the documents!"
	wm_objective_status 1 1 1
	accum 2 set 1
}

trigger axis_object_returned
{
	//wm_announce	"The documents have been returned!"
	wm_objective_status 1 1 0
	accum 2 set 0
	accum 1 set 0
}

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

transmitter_obj
{
	spawn
	{
	}
	death
	{
		trigger game_manager cap_docs
	}
}

documents
{
    spawn
    {
	    wait 200
    }
    trigger stolen 
    {
    	//when the objective is taken 
    	// Hide command map marker of docs at table
    	setstate documents_CMM invisible 
	}
	trigger dropped
	{
		//when the player carrying the objective is killed 
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_objective_lost"
		// *---------------------------------------------------------------------------------*
	}
	trigger returned
	{
		//when defending team touches the dropped objective
		// Show command map marker of docs at table
		setstate documents_CMM default
	} 
	trigger captured
	{
		//when the objective is delivered to its deliverypoint 
		
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_objective_lost"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"
		// *---------------------------------------------------------------------------------*
	}
}

doorcontrols
{
	spawn
	{
		wait 200
		
		constructible_class 3
	}
	death
	{
		wm_announce "The Doors are opening!!"
		
		trigger phasedoor1 move_up
		trigger phasedoor2 move_up
						
		wm_objective_status 4 1 1		
		wm_objective_status 4 0 2
		// Open phase doors
				
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"

		wm_removeteamvoiceannounce 0 "adlernest_axis_controls_defend"
		wm_removeteamvoiceannounce 1 "adlernest_allies_controls_destroy"
		
		// "Construct the command post!" voice over, unless its already been done.
        globalaccum 6 abort_if_equal 1
        		
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}
}

phasedoor1
{
	spawn
	{
		wait 200
		gotomarker phasedoor1_pc2 1000
	}
	
	trigger move_up
	{
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav
		wait 400
		playsound sound/movers/misc/garage_door_loop_01.wav looping forever
		gotomarker phasedoor1_pc1 80 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav
	}
}

phasedoor2
{
	spawn
	{
		wait 200
		gotomarker phasedoor2_pc2 1000
	}
	
	trigger move_up
	{
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav
		wait 400
		playsound sound/movers/misc/garage_door_loop_01.wav looping forever
		gotomarker phasedoor2_pc1 80 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav
	}
}

maindoor_button
{
	spawn
	{
		wait 200
	}
	
	activate
	{		
		trigger maindoorr move_up
		trigger maindoorl move_up
		
		trigger maindoorr move_down
		trigger maindoorl move_down
	}
}

maindoor_lever
{
	spawn
	{
		wait 200
		trigger maindoor_lever move_down
	}
	
	trigger move_down
	{
		wait 200
		faceangles 0 0 -1 750
	}
	
	trigger move_up
	{
		wait 200
		faceangles 0 0 -25 750
	}
}

maindoor_lever1
{
	spawn
	{
		wait 200
		trigger maindoor_lever1 move_down
	}
	
	trigger move_down
	{
		wait 200
		faceangles -1 0 0 750
	}
	
	trigger move_up
	{
		wait 200
		faceangles -25 0 0 750
	}
}

maindoorr
{
	spawn
	{
		wait 200
		gotomarker maindoorr_pc2 1000
	}
	
	trigger move_up
	{
		// open
		// abort if working or opened
		accum 4 abort_if_equal 2
		accum 4 abort_if_equal 1
		// set status working
		accum 4 set 2
		
		trigger maindoor_lever move_up
		trigger maindoor_lever1 move_up
		wm_objective_status 5 1 1
		wm_objective_status 5 0 0
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorr_pc1 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status opened
		accum 4 set 1
	}
	
	trigger move_down
	{
		// close
		// abort if working or closed
		accum 4 abort_if_equal 2
		accum 4 abort_if_equal 0
		// set status working
		accum 4 set 2
		
		trigger maindoor_lever move_down
		trigger maindoor_lever1 move_down
		wm_objective_status 5 1 0
		wm_objective_status 5 0 1
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorr_pc2 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status closed
		accum 4 set 0
	}
}

maindoorl
{
	spawn
	{
		wait 200
		gotomarker maindoorl_pc2 1000
	}
	
	trigger move_up
	{
		// open
		// abort if working or opened
		accum 5 abort_if_equal 2
		accum 5 abort_if_equal 1
		// set status working
		accum 5 set 2
		
		wm_announce "Main blast door opening!"
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorl_pc1 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status opened
		accum 5 set 1
	}
	
	trigger move_down
	{
		// close
		// abort if working or closed
		accum 5 abort_if_equal 2
		accum 5 abort_if_equal 0
		// set status working
		accum 5 set 2
		
		wm_announce "Main blast door closing!"
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorl_pc2 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status closed
		accum 5 set 0
	}
}


//
//
//  CP CP CP CP
//
//

allied_radio_built
{
   spawn
   {
      wait 400

      constructible_class 2

      trigger allied_radio_built setup
      
      disablespeaker allied_compost_sound    
   }

   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 allied_radio_built_model trans
      trigger neutral_radio_closed_model  hide
   }

   built final
   {
      trigger allied_radio_built_model show
      trigger allied_radio_built_model enable_allied_features

      enablespeaker allied_compost_speaker
   }

   decayed final
   {
      trigger allied_radio_built_model hide
      trigger neutral_radio_closed_model show
   }

   death
   {
      trigger allied_radio_built_model hide
      trigger allied_radio_built_model disable_allied_features
      trigger neutral_radio_closed_model show

      disablespeaker allied_compost_sound
   }
}

allied_radio_built_model
{
   spawn
   {
      wait 400
      setstate allied_radio_built_model invisible
      accum 3 set 0
   }

   trigger show
   {
      setstate allied_radio_built_model default
      setstate allied_radio_built default
      
      setstate alliedhqradio_toi default
   }

   trigger hide
   {
      setstate allied_radio_built_model invisible
      //setstate allied_radio_built invisible
      //setstate alliedhqradio_toi invisible
   }

   trigger trans
   {
      setstate allied_radio_built_model underconstruction
      setstate allied_radio_built default
      
      //setstate alliedhqradio_toi 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!"
      
      globalaccum 6 set 1
            
      // *----------------------------------- vo ------------------------------------------*
      wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
      
      wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

	  wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
      // *----------------------------------- vo ------------------------------------------*

      wm_objective_status 3 0 2
      wm_objective_status 3 1 1
      
      // ENABLE NEW SPAWN
      trigger cp_spawn_wobj on
      
      // If first time, then set new spawn as default
      accum 3 abort_if_equal 1
      accum 3 set 1      
      
      setautospawn    "CP Spawn"   1
   }

   trigger disable_allied_features
   {
      // Some kind of UI pop-up to alert players
      wm_announce   "Axis team has destroyed the Allied Command Post!"

      //DISABLE NEW SPAWN
      trigger cp_spawn_wobj off
      
      globalaccum 6 set 0
      
      // *----------------------------------- vo ------------------------------------------*    
      wm_addteamvoiceannounce 1 "allies_hqt_compost_construc"

	  wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
      // *----------------------------------- vo ------------------------------------------*

      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 3 0 0
      wm_objective_status 3 1 0
   }
} 

neutral_radio_closed_model
{
   spawn
   {
      wait 400
      //setstate neutral_radio_closed_model default
      trigger neutral_radio_closed_model show
                  
      sethqstatus 0 0

      wm_objective_status 3 1 0
      wm_objective_status 3 0 0     
      
      //setstate alliedhqradio_toi default
      //setstate alliedhqradio_toi invisible
      
   }

   trigger show
   {
      setstate neutral_radio_closed_model default
      //setstate neutral_radio_closed default
      
      //setstate alliedhqradio_toi invisible
   }

   trigger hide
   {
      setstate neutral_radio_closed_model invisible
      //setstate neutral_radio_closed invisible
   }
} 

neutral_radio_closed
{
   spawn
   {
      wait 400    
   }
}

cp_spawn_spawns
{
   	spawn
	{
	  wait 50
	  setstate cp_spawn_spawns invisible
	}
} 

cp_spawn_wobj
{
   	spawn
	{
	  wait 200
	  setstate cp_spawn_wobj invisible
	}
	trigger off
    {
      setstate cp_spawn_wobj invisible
      setstate cp_spawn_spawns invisible
	  alertentity cp_spawn_spawns
	  wm_announce "Allied Command Post spawn disabled!"
    }
    trigger on
    {
      setstate cp_spawn_wobj default
      setstate cp_spawn_spawns default
	  alertentity cp_spawn_spawns
      wm_announce "Allied Command Post spawn active!"
    }
	trigger allied_capture 
	{
		//
	}
    trigger axis_capture
    {
	    //
    }
} 

allied_spawn
{
   	spawn
	{
	  wait 200
	}
} 

allied_spawn_flag
{
   	spawn
	{
	  wait 200
	}
	trigger allied_capture 
	{
		//
	}
    trigger axis_capture
    {
	    //
    }
} 

tank_turret
{
	spawn
	{
		wait 200
	}
	
	trigger facewall
	{
		trigger tank_turret spin_start
		faceangles 0 150 0 1000
		trigger tank_turret spin_stop
		trigger tank_turret spin_fire
		alertentity sidewall
	}
	
	trigger spin_fire
	{
		playsound sound/vehicles/tank/tank_fire.wav volume 560
	}

	trigger spin_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 155
	}

	trigger spin_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 135
	}
}

sidewall
{
	spawn
	{
		wait 200
	}
	death
	{
		alertentity sidewall_explo
	}
}

sidewall_explo
{
	spawn
	{
		wait 200
	}
}