////////////////
//game_manager//
////////////////
game_manager
{
	spawn
	{
		accum 1 set 0		
		

		// Game rules
		wm_axis_respawntime	30
		wm_allied_respawntime	20
		wm_number_of_objectives 1
		wm_set_round_timelimit	20

		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		0	1
		wm_set_main_objective		1	1

		// Objective overview status indicators
		//wm_objective_status <objective> <team (0=Axis, 1=Allies)> <status (0=neutral 1=complete 2=failed)>
		wm_objective_status 1 0 0

		
		
		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// If the round timer expires, the Axis have won, so set the current winning team
		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 0

		// Set starting spawns
		// The wait command after is VERY IMPORTANT for correct spawns!
		wait 150
		setautospawn "Forward Bunker" 0
   		setautospawn "Allied start" 1
		wait 350





	}




	trigger objective1
	{
		accum 1 set 1
		trigger game_manager checkgame


	}



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


v2rocket
{
	spawn
	{
		wait 300

		constructible_class 3
	}

	death
	{


		trigger game_manager objective1
		
		trigger v2rocket_model remove
		
		wm_announce	"Allies have destroyed the prototype rocket!"

		wm_teamvoiceannounce 0 "axis_obj_destroyed"
		wm_teamvoiceannounce 1 "allies_obj_destroyed"
	}
}

v2rocket_model
{
	trigger remove
	{
		remove
	}
}
////////
//BOOM//
////////
door1 // Base gate
{
	spawn
	{
		wait 200

		constructible_class 3
	}

	death
	{
		wm_announce	"Allies have destroyed the base gate!"
		wm_teamvoiceannounce 0 "axis_main_destroyed"
		wm_teamvoiceannounce 1 "allies_main_destroyed"
	}
}

//////////
//spawn//
////////


forward_spawn
{
	spawn
	{
		wait 200
		accum 0 set 0 // Who has the flag: 0-Axis, 1-Allied
	}

	trigger axis_capture
	{
		accum 0 abort_if_equal 0
		accum 0 set 0

		// Axis takes control of forward flag

		//announcements
		wm_announce	"Axis reclaim the forward bunker!"
		wm_teamvoiceannounce 0 "axis_flag_reclaimed"
		wm_teamvoiceannounce 1 "allies_flag_reclaimed"


		alertentity forwardflag_wobj   
		setautospawn "Forward Bunker" 0
   		setautospawn "Allied start" 1
	}

	trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1

		// Allied takes control of forward flag

		// Some kind of UI pop-up to alert players
   		wm_announce	"Allies have captured the forward bunker!"
  		wm_teamvoiceannounce 0 "axis_flag_captured"
  		wm_teamvoiceannounce 1 "allies_flag_captured"

		alertentity forwardflag_wobj
   		setautospawn "Axis second spawn" 0
   		setautospawn "Forward Bunker" 1
	}
   
	trigger allies_keep
	{
      		//setstate allied_forward_spawnblob invisible
   		setautospawn "Axis second spawn" 0
   		setautospawn "Forward Bunker" 1
      		remove

		accum 0 abort_if_equal 1
		alertentity forwardflag_wobj
		alertentity bunker_spawns
	}
}

door_side // side entrance
{
	spawn
	{
		wait 200

		constructible_class 3
	}

	death
	{
		wm_announce	"Allies have destroyed the side entrance!"
		wm_teamvoiceannounce 0 "axis_side_destroyed"
		wm_teamvoiceannounce 1 "allies_side_destroyed"
	}
}

fence
{
	spawn
	{
		wait 400
		trigger fence setup

		constructible_class 2
	}

	trigger setup
	{
		setstate fence_materials invisible
		setstate fence_materials_clip invisible
		setstate fence_flag invisible
		 

	}

	buildstart final
	{
		setstate fence_materials default
		setstate fence_materials_clip default
		setstate fence_flag default


	}

	built final
	{
		setstate fence_materials invisible
		setstate fence_materials_clip invisible
		setstate fence_flag invisible

		wm_announce "The Fence has been constructed!"

	}

	decayed final
	{
		setstate fence_materials default
		setstate fence_materials_clip default
		setstate fence_flag default

	}

	death
	{
		setstate fence_materials default
		setstate fence_materials_clip default
		setstate fence_flag default
		
		wm_announce "The Fence has been destroyed."

	}


}

/////////////////
//keycard_stuff//
////////////////
keycard
{

	spawn
	{
	wait 200
	setstate keycard_sec invisible
	setstate keycard_red default
	}

	trigger dropped
	{
	}

	
	trigger stolen
	{
	setstate keycard_cm invisible
	setstate keycard_track invisible
	}

	trigger returned
	{
	setstate keycard_cm default
	setstate keycard_track default
	}

	trigger captured
	{
	}
}

keycard_holder
{
	spawn
	{
	}
	death
	{
	wm_teamvoiceannounce 0 "axis_obj_captured"
	wm_teamvoiceannounce 1 "allies_obj_secured"
	
	wm_announce "Allies have secured the keycard!"
	wm_announce "Base door is opening!"
	trigger forward_spawn allies_keep
	wm_announce "Allies have secured the forward bunker!"
	setstate keycard_sec default
	setstate keycard_red invisible
	trigger basedoor_2 move_up
	}
}

basedoor_2
{
	spawn
	{
		wait 200
		gotomarker basedoor_down 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
		gotomarker basedoor_up 35
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav
	}
}


// ========================================
// ============ 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
		
		trigger alliedcpspawns_obj on

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


	}

	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"
		// *---------------------------------------------------------------------------------*
		trigger alliedcpspawns_obj off


	}
}

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

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


	}

}


alliedcpspawns_obj
{
	spawn
	{
		wait 50
		setstate alliedcpspawns_obj invisible
		setstate alliedcpspawns invisible
	}

	trigger on
	{
		setstate alliedcpspawns_obj default
		setstate alliedcpspawns default
		wait 150
		setautospawn "Command post" 1
	}

	trigger off
	{
		setstate alliedcpspawns_obj invisible
		setstate alliedcpspawns invisible
	}
}

alliedcpspawns
{
	spawn
	{
		wait 50
		setstate alliedcpspawns invisible
	}
}

// *---END---*