game_manager
{
	spawn 
   	{
		remapshaderflush

		wm_axis_respawntime	1
		wm_allied_respawntime	1
		wm_number_of_objectives	4
		wm_set_round_timelimit	30

		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
		wm_objective_status 6 0 0
		wm_objective_status 6 1 0

		accum 0 set 2 //status of forward flag
		accum 1 set 0 //Overall Allied status
		accum 2 set 0 //Overall Axis status

		wm_set_defending_team	1

		wm_setwinner	-1

		wait 2000

		setautospawn	"Forward Spawn"	1 
		setautospawn	"Forward Spawn"	0

   	}

//Objective Flags

	trigger alliedobjectivecounter  //Destruction of Allied objectives
           	 {
                 	//Set accum to increase by 1 so we know that the objective has been completed
                 	accum 1 inc 1

                       	//Call function called checkgame in game_manager to check if the round has been won
                       	trigger game_manager alliedcheckgame
           	}

	trigger axisobjectivecounter  //Destruction of Axis objectives
           	 {
                       	//Set accum to increase by 1 so we know that the objective has been completed
                       	accum 2 inc 1

                       	//Call function called checkgame in game_manager to check if the round has been won
                       	trigger game_manager axischeckgame
           	}

	trigger alliedcheckgame // checks to see if Allied win requirements have been met
            	{
                       	accum 1 abort_if_not_equal 2
                       	wm_setwinner 1
			wait 1500
                       	wm_endround
           	}

	trigger axischeckgame // checks to see if Axis win requirements have been met
            	{
                       	accum 2 abort_if_not_equal 2
                       	wm_setwinner 0
			wait 1500
                       	wm_endround
           	}

	trigger forwardflagblue
	{
		// Change the objective state internally, so UI can update, etc.
		// Allied takes control of forward flag

		// Some kind of UI pop-up to alert players
		wm_announce	"Allies capture the forward spawn!"

		wm_objective_status	3 1 1
		wm_objective_status	3 0 2
	}

	trigger forwardflagred
	{
		// Change the objective state internally, so UI can update, etc.
		// Axis takes control of forward flag

		// Some kind of UI pop-up to alert players
		wm_announce	"Axis capture the forward spawn!"

		wm_objective_status	3 1 2
		wm_objective_status	3 0 1
	}
} 

//End of Game_manager section

// FORWARD SPAWN POINT ================================================
forward_spawn
{
	spawn
	{
		wait 200
		setstate forwardflag_wobj invisible
		accum 0 set 0
	}

	trigger axis_capture
	{
		trigger game_manager forwardflagred
		trigger forward_spawn setaxis
	}

	trigger allied_capture
	{
		trigger game_manager forwardflagblue
		trigger forward_spawn setallies
	}

	trigger setaxis
	{
		wm_axis_respawntime	7
		wm_allied_respawntime	1
		setstate forwardflag_wobj default
		accum 0 abort_if_equal 0
		accum 0 set 0
		alertentity forwardflag_wobj
	}

	trigger setallies
	{
		wm_axis_respawntime	1
		wm_allied_respawntime	7
		setstate forwardflag_wobj default
		accum 0 abort_if_equal 1
		accum 0 set 1
		alertentity forwardflag_wobj
	}
}

// CONSTRUCTIBLE OBJECTIVES ================================================
//Axis constructible

axisconstruct_script
{ 
	spawn 
	{ 
		wait 200 
		constructible_class 2 
		trigger self startup 
	} 
	
	buildstart final 
	{ 
	} 

	built final 
	{ 
		setstate axisconstruct_target default 
		setstate axisconstruct_materials invisible 
		wm_announce "The Axis wall has been constructed" 
	} 

	decayed final 
	{ 
		trigger self startup 
	} 

	death 
	{ 
		trigger self startup 
		wm_announce "The Axis wall has been breached" 
		setstate axisconstruct_materials default
	} 

	trigger startup 
	{ 
		setstate axisconstruct_target invisible
		setstate axisconstruct_materials default 
	} 
}

//allied constructible

alliedconstruct_script
{ 
	spawn 
	{ 
		wait 200 
		constructible_class 2 
		trigger self startup 
	} 
	
	buildstart final 
	{ 
	} 

	built final 
	{ 
		setstate alliedconstruct_target default
		setstate alliedconstruct_materials invisible 
		wm_announce "The Allied wall has been built" 
	} 

	decayed final 
	{ 
		trigger self startup 
	} 

	death 
	{ 
		trigger self startup 
		wm_announce "The Axis have destroyed the Allied wall" 
		setstate alliedconstruct_materials default
	} 

	trigger startup 
	{ 
		setstate alliedconstruct_target invisible
		setstate alliedconstruct_materials default 
	} 
}

// DESTRUCTIBLE OBJECTIVES ================================================

//North Door
northdoor_script
{
	spawn 
	{
		wait 200
		constructible_class 3 
	}

	death 
	{
		wm_announce "Axis have destroyed the Allied Generator"

		wm_objective_status 2 0 1
		wm_objective_status 2 1 2

                trigger game_manager axisobjectivecounter
	}
}

//South Door
southdoor_script
{
	spawn 
	{
		wait 200
		constructible_class 3 
	}

	death 
	{
		wm_announce "Axis have destroyed the Allied Battery"

		wm_objective_status 1 0 1
		wm_objective_status 1 1 2

                trigger game_manager axisobjectivecounter
	}
}

//East Door
eastdoor_script
{
	spawn 
	{
		wait 200
		constructible_class 3 
	}

	death 
	{
		wm_announce "Allies have destroyed the Axis Generator!!!"

		wm_objective_status 5 0 2
		wm_objective_status 5 1 1

                trigger game_manager alliedobjectivecounter
	}
}

//West Door
westdoor_script
{
	spawn 
	{
		wait 200
		constructible_class 3 
	}

	death 
	{
		wm_announce "Allies have destroyed the the Axis Battery"

		wm_objective_status 6 0 2
		wm_objective_status 6 1 1

                trigger game_manager alliedobjectivecounter
	}
}

// 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.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 4 0 1
		wm_objective_status 4 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 4 0 0
		wm_objective_status 4 1 0
	}
}

//Constructable MG positions

//Allied MG

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

   	buildstart final 
   	{ 
   	} 

   	built final 
   	{ 
      		setstate alliedmg_extra default 
      		setstate alliedmg_mg42  default 
      		setstate alliedmg_materials invisible 

      		wm_announce   "Allied MG nest constructed!" 
   	} 

   	decayed final 
   	{ 
      		trigger self startup 
   	} 

   	death 
   	{ 
      		trigger self startup 

      		wm_announce   "Axis team has destroyed the Allied MG nest!" 
	} 

	trigger startup 
   	{ 
		setstate alliedmg_extra invisible 
		setstate alliedmg_mg42  invisible 
		setstate alliedmg_materials default 
      		repairmg42 construction_mg42 
   	} 
} 

//Axis MG

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

   	buildstart final 
   	{ 
   	} 

   	built final 
   	{ 
      		setstate axismg_extra default 
      		setstate axismg_mg42  default 
      		setstate axismg_materials invisible 

      		wm_announce   "Axis MG nest constructed!" 
   	} 

   	decayed final 
   	{ 
      		trigger self startup 
   	} 

   	death 
   	{ 
      		trigger self startup 

      		wm_announce   "Allied team has destroyed the Axis MG nest!" 
	} 

	trigger startup 
   	{ 
		setstate axismg_extra invisible 
		setstate axismg_mg42  invisible 
		setstate axismg_materials default 
      		repairmg42 construction_mg42 
   	} 
}
//Lift Allied side

script1
{
	trigger function1
	{
		gotomarker path1 300
		wait 5000
		gotomarker path2 1000
	}
}

//Lift Axis side

script2
{
	trigger function2
	{
		gotomarker path3 300
		wait 5000
		gotomarker path4 1000
	}
}

//Catapult

catapult_script
{
	trigger run
	{
		trigger catapult fire
	}
}

catapult
{
	spawn
	{
		wait 500
		accum 9 set 0
		setstate catapult_push_trig invisible
	}

	trigger fire
	{
		accum 9 abort_if_equal 1
		accum 9 set 1
		playsound sound/movers/switches/switch_01.wav
		wait 500
		setstate catapult_trigger invisible
		playsound sound/weapons/rocket/rocket_fire.wav
		setstate catapult_push_trig default
		faceangles -90 0 0 500
		alertentity catapult_dust
		setstate catapult_push_trig invisible
		wait 2000
		playsound sound/movers/doors/door4_closeq.wav volume 600
		faceangles 0 0 0 4000
		playsound sound/movers/doors/door4_endcq.wav volume 500
		wait 1000
		setstate catapult_trigger default
		accum 9 set 0
	}
}