// ======================================
// = .script file initial version	=
// = Creator	:	dFx		=
// = sources taken from			=
// =		: 	Adlernest	=
// =		:	Et_beach	=
// =		:	eponavillage	=
// = thx at creators.			=
// ======================================

game_manager
{
	spawn
	{
		// axis spawn time
		wm_axis_respawntime	25
		// allied spawn time
		wm_allied_respawntime	20
		// timelimit
		wm_set_round_timelimit  15

		// objectives sets
		wm_number_of_objectives 6
	
		// 	0=neutral 1=succedeed 2=failed
		// 	Obj 	iniax	inial 	name
		// 	1	1	2	take docs
		// 	2	1	2	cap docs
		// 	3	1	2	main
		// 	4	1	2	flag
		// 	5	1	2	side
		// 	6	0	0	cp	

		//Take docs
		wm_objective_status 1 1 2
		wm_objective_status 1 0 1
		//Cap docs
		wm_objective_status 2 1 2
		wm_objective_status 2 0 1
		//main
		wm_objective_status 3 1 2
		wm_objective_status 3 0 1
		//flag
		wm_objective_status 4 1 2
		wm_objective_status 4 0 1
		//side
		wm_objective_status 5 1 2
		wm_objective_status 5 0 1
		//cp
		wm_objective_status 6 1 0
		wm_objective_status 6 0 0

		//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
		// Flag
		accum 5 set 0

		// axis is defending
		wm_set_defending_team	0
		// axis win if not wm_endround
		wm_setwinner 0

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "sideentr_axis_defend"
		wm_teamvoiceannounce 1 "sideentr_allies_destroy"
		// *---------------------------------------------------------------------------------*
	
	}
	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 decrypted documents!"
		trigger game_manager checkgame
	}

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

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

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

	trigger flag_allier
	{
		// Change the objective state internally, so UI can update, etc.
		// Allied takes control of checkpoint #1
		wm_objective_status		4	1	2
		wm_objective_status		4	0	1
	}

	trigger flag_axis
	{		// Change the objective state internally, so UI can update, etc.
		// Axis takes control of checkpoint #1
		wm_objective_status		4	1	1
		wm_objective_status		4	0	2
	}
}


// ===============
// BRICK WALL CODE
// ===============

mur2
{
	spawn
	{
		wait 200
		constructible_class 3
	}

	death
	{
		wm_objective_status 5 1 1
		wm_objective_status 5 0 2
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "sidewall_axis_breach"
		wm_teamvoiceannounce 1 "sidewall_allies_breach"
		// *---------------------------------------------------------------------------------*
		wm_announce "Allies have blow the Brick Wall"
	}
}

// ==========
// MAIN DOORS
// ==========

portes
{
	spawn
	{
		wait 200
		constructible_class 3
	}

	death
	{
		wm_objective_status 3 1 1
		wm_objective_status 3 0 2
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "mainwall_axis_breach"
		wm_teamvoiceannounce 1 "mainwall_allies_breach"
		// *---------------------------------------------------------------------------------*
		wm_announce "Allies have blow the Main Doors"
		kill portes
		setstate portes invisible
	}
}

// ==============================
// DOCUMENTS TAKEN FROM ADLERNEST
// ==============================

transmitter_obj
{
	spawn
	{
		wait 200
	}
	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"
		// *---------------------------------------------------------------------------------*
	}
}

// ====
// FLAG
// ====

flag_script
{
	spawn
	{
		accum 5 set 0	// Who has the flag: 0-Axis, 1-Allier
	}

	trigger axis_capture
	{
		accum 5 	abort_if_equal 			0
		accum 5 	set 				0
		trigger 	game_manager 	flag_axis
		alertentity 	flag_wobj
		setautospawn	"Forward Flag"			0
		setautospawn	"Allies start"			1
		wm_announce	"Forward Flag Reclaimed"
		wm_teamvoiceannounce 1 "allies_hq_objective_lost"
		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
	}

	trigger allied_capture
	{
		accum 5 	abort_if_equal 			1
		accum 5 	set 				1
		trigger 	game_manager flag_allier
		alertentity 	flag_wobj
		setautospawn	"Forward Flag"			1
		setautospawn	"Axis Back"			0
		wm_announce	"Forward Flag Captured"
		wm_teamvoiceannounce 	1 	"allies_hq_objective_captured"
		wm_teamvoiceannounce 	0 	"axis_hq_objective_lost"
	}

	trigger kill
	{
		remove
	}
}

// ==================================
// NEUTRAL COMMAND POST FROM ET_BEACH
// ==================================

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 team_compost_open default
		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
		setstate team_compost_open 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 6 0 2
		wm_objective_status 6 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 6 0 0
		wm_objective_status 6 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
		setstate team_compost_open default
	}

	built final
	{
		setstate axis_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
		setstate team_compost_open 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 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

		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
	}
}