//game manager//
//map by ETc|gouki & ETc|Jay//

game_manager
{
	spawn
	{
						
		// Game rules
		wm_axis_respawntime	8
		wm_allied_respawntime	8
		wm_number_of_objectives 7
		wm_set_round_timelimit	35
		
		// Objectives
		// 1: open Main Gate
		// 2: open Fortress Gates
		// 3: Steal Vault code
		// 4: secure the Vault Code
		// 5: Allies Command post
		// 6: Axis Command post
		// 7: Axis steal gold
		// 8: Axis secure the gold
		
 		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		0	1
		wm_set_main_objective		0	0
		
		wm_objective_status 1 1 0	
		wm_objective_status 1 0 0
		wm_objective_status 2 1 0
		wm_objective_status 2 0 0
		wm_objective_status 3 1 0
		wm_objective_status 3 0 0
		wm_objective_status 4 1 0
		wm_objective_status 4 0 0
		wm_objective_status 5 1 0
		wm_objective_status 5 0 0
		wm_objective_status 6 1 0
		wm_objective_status 6 0 0


		wm_set_main_objective		0	1
		wm_set_main_objective		0	0

		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	1
		
		
		
		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner	1
		
		wait 500
		
		//wm_teamvoiceannounce 1 "axis_lose" 
		//wm_teamvoiceannounce 0 "axis_lose" 
		
		setautospawn	"Barrack Spawn"		0
		setautospawn	"Forward Spawn"		1
		
		setstate middle_allied_spawn_wobj invisible
		setstate lastalliedspawn_wobj invisible
		setstate backspawn_wobj invisible
		
		
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "winterbase_axis_blowup_def"
		wm_addteamvoiceannounce 1 "winterbase_allied_defence_stop"

		wm_teamvoiceannounce 0 "winterbase_axis_steal_vaultcode"
		wm_teamvoiceannounce 0 "winterbase_axis_blowup_def"

		wm_teamvoiceannounce 1 "winterbase_allied_defence_stop"
		wm_teamvoiceannounce 1 "winterbase_allied_stop_steal_docs"
		wm_teamvoiceannounce 1 "winterbase_allied_stop_getgold"
		
		wm_removeteamvoiceannounce 0 "winterbase_axis_blowup_def"
		wm_removeteamvoiceannounce 0 "winterbase_axis_steal_vaultcode"
		
		wm_removeteamvoiceannounce 1 "winterbase_axis_blowup_def"
		wm_removeteamvoiceannounce 1 "winterbase_allied_defence_stop"
		wm_removeteamvoiceannounce 1 "winterbase_allied_stop_getgold"
		// *----------------------------------- vo ------------------------------------------*
	}
	//--------Axis win-------//
	trigger axis_win
	{
		wm_setwinner	0
		

		wm_objective_status 6 1 2
		wm_objective_status 6 0 1

		wait 1500
		wm_announce "^1The Axis team has escaped with the Gold!"
		wm_endround
	}
}
//////////////////////////////////////////
/////////////allied_def_fence/////////////
//////////////////////////////////////////

allied_def_fence
{
	spawn
	{
		wait 200
		constructible_class 3
	}
	
	
	death
	{
		wm_announce "^1Allied Defence has been destroyed!"

	// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "winterbase_axis_hq_constr_dest"

		wm_addteamvoiceannounce 1 "winterbase_allied_defence_destroyed"

		wm_teamvoiceannounce 0 "winterbase_axis_hq_constr_dest"

		wm_teamvoiceannounce 1 "winterbase_allied_defence_destroyed"

		wm_removeteamvoiceannounce 0 "winterbase_axis_hq_constr_dest"
		wm_removeteamvoiceannounce 0 "winterbase_axis_hq_constr_dest"
		
		wm_removeteamvoiceannounce 1 "winterbase_allied_defence_destroyed"
		wm_removeteamvoiceannounce 1 "winterbase_allied_defence_destroyed"
		// *----------------------------------- vo ------------------------------------------*
	}
	
	trigger remove
	{
		remove
	}
}
//////////////////////////////////////////
//////////////Main gate Controls//////////
//////////////////////////////////////////

button1_trigger
{
	activate
	{
		trigger button1 activate
	}
	
	trigger remove
	{
		remove
	}
}

button1
{
    spawn
    {
        wait 360
        faceangles 0 0 0 20
    }
    
    trigger activate
    {
		playsound sound/movers/switches/switch_02.wav 
		faceangles 0 0 35 50
		wait 500
		
		trigger doormover1 open
		trigger doormover2 open
		trigger doormover3 open
		trigger doormover4 open
		setstate button1_trigger invisible
		wm_announce "^1The Axis have Opened the Main Gate!"
		
	
	// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "winterbase_axis_opendoor1"

		wm_addteamvoiceannounce 1 "winterbase_allied_door1_opened"

		wm_teamvoiceannounce 0 "winterbase_axis_opendoor1"

		wm_teamvoiceannounce 1 "winterbase_allied_door1_opened"

		wm_removeteamvoiceannounce 0 "winterbase_axis_opendoor1"
		wm_removeteamvoiceannounce 0 "winterbase_axis_opendoor1"

		wm_removeteamvoiceannounce 1 "winterbase_allied_door1_opened"
		wm_removeteamvoiceannounce 1 "winterbase_allied_door1_opened"
		// *----------------------------------- vo ------------------------------------------*		
    }
}


///////////////////////////////////////////////////
////////////////////////Main Gate doors////////////
///////////////////////////////////////////////////
doormover1
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover1_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2600
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
	}

}

doormover2
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover2_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2600
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
    }
}

doormover3
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover3_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2600
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
    }
}
doormover4
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover4_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2600
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
    }
}
///////////////////////////////////////////////////
///////// ///Fortress Gate Controls/// ////////////
///////////////////////////////////////////////////

button2_trigger
{
	activate
	{
		trigger button2 activate
		
	}
	
	trigger remove
	{	
		
		remove
	}
}

button2
{
    spawn
    {
		faceangles 0 0 0 50
		wait 500
    }
    
    trigger activate
    {
		playsound sound/movers/switches/switch_02.wav 
		faceangles 0 0 35 50
		wait 500
		trigger doormover5 open
		trigger doormover6 open
		trigger doormover7 open
		trigger doormover8 open
		setstate button2_trigger invisible
		
	// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "winterbase_axis_opendoor2"

		wm_addteamvoiceannounce 1 "winterbase_allied_door2_opened"

		wm_teamvoiceannounce 0 "winterbase_axis_opendoor2"

		wm_teamvoiceannounce 1 "winterbase_allied_door2_opened"

		wm_removeteamvoiceannounce 0 "winterbase_axis_opendoor2"
		wm_removeteamvoiceannounce 0 "winterbase_axis_opendoor2"

		wm_removeteamvoiceannounce 1 "winterbase_allied_door2_opened"
		wm_removeteamvoiceannounce 1 "winterbase_allied_door2_opened"
		// *----------------------------------- vo ------------------------------------------*		
    }
}
///////////////////////////////////////////////////
//////////////SD////////fortress Gate's////////////
///////////////////////////////////////////////////
doormover5
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover5_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2100
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
    }
}

doormover6
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover6_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2100
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
    }
}

doormover7
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover7_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2100
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
	
    }
}
doormover8
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker doormover8_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2100
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
	
    }
}
//////////////////////////////////////////////////////////
////////////////////Commanders log////////////////////////
//////////////////////////////////////////////////////////
commanders_log
{
	spawn
	{	
		accum 3 set 0 // Log counter
	}

	trigger stolen
	{
		accum 0 inc 1
		accum 0 trigger_if_equal 1 commanders_log stolen
		
		wait 1000
		
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_stolen_vaultcode"
		wm_teamvoiceannounce 1 "winterbase_allied_stolen_docs"

		wm_removeteamvoiceannounce 0 "winterbase_axis_stolen_vaultcode"
		wm_removeteamvoiceannounce 1 "winterbase_allied_stolen_docs"
		// *----------------------------------- vo ------------------------------------------*
			
	}

	trigger secured
	{
		accum 0 trigger_if_equal 1 commanders_log secured
		
		setstate middlespawn_wobj default
		setstate lastalliedspawn_wobj default
		setstate goldbar_holder default
		
		wait 1000
		
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_secured_vaultcode"
		wm_removeteamvoiceannounce 0 "winterbase_axis_secured_vaultcode"

		wm_teamvoiceannounce 1 "winterbase_allied_docs_lost"
		// *----------------------------------- vo ------------------------------------------*
		
		
	}

	trigger returned
	{
		accum 0 inc -1
		accum 0 trigger_if_equal 0 commanders_log returned
		
		wait 1000
		
		wm_announce "^1Vault Code's were returned"
		wm_addteamvoiceannounce 0 "winterbase_axis_returned_vaultcode"
		wm_addteamvoiceannounce 1 "winterbase_allied_docs_returned"
		
	}
}
/////////////////////////////////////////
//////////////Vault Door/////////////////
/////////////////////////////////////////
trigger_vault_door
{

	spawn
	{
		wait 500
	}
	death
	{		
		wait 200
		trigger vault_door open
	}
}
vault_door
{

	spawn
	{
		
		faceangles 0 0 0 20 2000
		
		wait 500
	}
	
	trigger open
	{	
		
		wm_teamvoiceannounce 0 "winterbase_axis_secured_vaultcode"
		wm_teamvoiceannounce 1 "winterbase_allied_stop_getgold"
		
		wm_announce "^1Axis have opened the Vault!"
		wait 100
		playsound sound/movers/doors/door5_open.wav volume 345
		faceangles 0 -95 0 5000	

		wm_teamvoiceannounce 0 "winterbase_axis_secured_vaultcode"
		wm_removeteamvoiceannounce 0 "winterbase_axis_secured_vaultcode"
		
		wait 300
		alertentity lastalliedspawn
		alertentity middle_allied_spawn
		
		setautospawn "lastalliedspawn" 1
		
		setstate lastalliedspawn_wobj default
		setstate middle_allied_spawn_wobj default
		wm_announce "^1noob_protection ^7set inactive"
		wait 200
	
		trigger truck_door open
		wm_removeteamvoiceannounce 0 "winterbase_axis_secured_vaultcode"
	
    }
}

truck_door
{

	spawn
	{
	}
	
	trigger open
	{
		wait 900
		gotomarker truck_door_dest 50
		playsound sound/movers/misc/big_gate2.wav looping  volume 255
		wait 2100
		stopsound
        playsound sound/movers/misc/big_gate3.wav  volume 355
        wait 1968    // wait for wav to play		
		stopsound
	
    }
}

truck
{
	spawn
	{
		faceangles 0 90 0 50
	}

	// ========================================
	// ========================================

	trigger add_goldbar
	{
		accum 0 inc 1

		trigger gold_full_0 show
		trigger gold_trans_0 hide
		trigger gold_crate secured

		accum 0 abort_if_less_than 2
		

		trigger gold_full_1 show
		trigger gold_trans_1 hide

		trigger self truck_escape_msg
		trigger game_manager axis_win

		wm_announce "Axis team is escaping with the Gold Crates!"

		wm_objective_status 8 0 1
		wm_objective_status 8 1 2

		wm_set_main_objective		8	1
		wm_set_main_objective		8	0
	}
	

}
// *********************************************
// ******************gold bar holder************
// *********************************************

goldbar_holder
{
	
	death
	{
		trigger truck add_goldbar
	}
}


// *********************************************
// ****************** GOLD STUFF ***************
// *********************************************

gold_crate
{
	spawn
	{
		accum 0 set 0 // gold counter
	}

	trigger stolen
	{
		accum 0 inc 1
		accum 0 trigger_if_equal 1 gold_crate stolen1
		accum 0 trigger_if_equal 2 gold_crate stolen2
	}

	trigger secured
	{
		accum 0 trigger_if_equal 1 gold_crate secured1
		accum 0 trigger_if_equal 2 gold_crate secured2
	}

	trigger returned
	{
		accum 0 inc -1
		accum 0 trigger_if_equal 0 gold_crate returned1
		accum 0 trigger_if_equal 1 gold_crate returned2
	}

	trigger stolen1
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_gold1_stolen"

		wm_teamvoiceannounce 1 "winterbase_axis_gold1_stolen"
		// *----------------------------------- vo ------------------------------------------*
	}

	trigger stolen2
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_gold2_stolen"

		wm_teamvoiceannounce 1 "winterbase_axis_gold2_stolen"
		// *----------------------------------- vo ------------------------------------------*
	}

	trigger secured1
	{
		wm_announce "Axis team has secured the first Gold Crate!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "winterbase_axis_gold1_secured"
		wm_teamvoiceannounce 0 "winterbase_axis_gold1_secured"


		wm_teamvoiceannounce 1 "winterbase_allied_gold_lost1"
		// *---------------------------------------------------------------------------------*
	}

	trigger secured2
	{
		wm_announce "Axis team has secured the second Gold Crate!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_gold2_secured"

		wm_teamvoiceannounce 1 "winterbase_allied_gold_lost2"

		// *---------------------------------------------------------------------------------*
		
		wait 400
		
	}

	trigger returned1
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_gold1_returned"
		wm_teamvoiceannounce 1 "goldrush_allies_gold1_returned"

		
		wm_removeteamvoiceannounce 1 "goldrush_allies_gold1_returned"
		wm_removeteamvoiceannounce 0 "winterbase_axis_gold1_returned"
		// *----------------------------------- vo ------------------------------------------*
	}

	trigger returned2
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "winterbase_axis_gold2_returned"
		wm_removeteamvoiceannounce 0 "winterbase_axis_gold2_returned"



		wm_teamvoiceannounce 1 "winterbase_allied_retrieved_gold"
		wm_removeteamvoiceannounce 1 "winterbase_allied_retrieved_gold"
		
		// *----------------------------------- vo ------------------------------------------*
	}
}

gold_full_0
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 50

		setstate gold_full_0 invisible
	}

	trigger show
	{
		setstate gold_full_0 default
	}
}

gold_full_1
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj2
		faceangles 0 90 0 50

		setstate gold_full_1 invisible
	}

	trigger show
	{
		setstate gold_full_1 default
	}
}

gold_trans_0
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 50
	}

	trigger hide
	{
		setstate gold_trans_0 invisible
	}
}

gold_trans_1
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj2
		faceangles 0 90 0 50
	}

	trigger hide
	{
		setstate gold_trans_1 invisible
	}
}

fan1
{
	spawn
	{
		wait 50
		setrotation	0 0 -600
	}
}

// ================================================
// ============ 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!"

		// *----------------------------------- 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 5 0 2
		wm_objective_status 5 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 5 0 0
		wm_objective_status 5 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
		
		
		setstate	backspawn_wobj	 default
		alertentity backspawns

		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 6 0 1
		wm_objective_status 6 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
		
		alertentity backspawns
		
		setstate backspawn_wobj invisible
		
		
		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 6 0 0
		wm_objective_status 6 1 0
	}
}
