// Script for the custom map "dom_attack", which is based on "Loffy's Madness".
// Game: Enemy Territory. Mod: Domination, Powerball and CTF.
// By Loffy, Sweden (http://www.loffy.tk), August 2005.

game_manager
{
	spawn
	{
		// Set scenario information
		wm_axis_respawntime		2
		wm_allied_respawntime		2
		wm_set_round_timelimit		20
		wm_number_of_objectives		1
		globalaccum 1 set 0 // Counter. Allied total score.
		globalaccum 2 set 0 // Counter. Axis total score.
		wait 200
		setstate sm_sign_pb_al default // Show powerball sign
		setstate sm_sign_pb_ax default
		setstate sm_sign_ctf_al invisible // Hide ctf sign.
		setstate sm_sign_ctf_ax invisible

		setautospawn	"Axis First Spawn" 0
		setautospawn	"Allied First Spawn" 1
		wait 50

		setstate two_alli_1stspawn default // team_WOLF_objective (yellow box)
		setstate two_alli_2ndspawn default
		setstate two_alli_3rdspawn default
		setstate two_alli_4thspawn default

		setstate two_axis_1stspawn default
		setstate two_axis_2ndspawn default
		setstate two_axis_3rdspawn default
		setstate two_axis_4thspawn default

		setstate alli_1stspawn_right default // team_CTF_bluespawn and team_CTF_redspawn (blue and red spawn boxes)
		setstate alli_2ndspawn_right default
		setstate alli_3rdspawn_right default
		setstate alli_4thspawn_right default

		setstate axis_1stspawn_right default
		setstate axis_2ndspawn_right default
		setstate axis_3rdspawn_right default
		setstate axis_4thspawn_right default

		disablespeaker allies_compost_sound
		disablespeaker axis_compost_sound

		// Hide the ctf entities
		setstate axis_flag invisible
		setstate axis_flag_toi invisible
		setstate axis_flag_marker invisible

		setstate allies_flag invisible
		setstate allies_flag_toi invisible
		setstate allies_flag_marker invisible
		wait 200

		// Show the powerball entities
		setstate rotatorblock default
		wait 200

		alertentity powerball // power ball
		wait 200
		setstate powerball_allied_goal_toi default // Allied 1st goal.
		setstate powerball_allied_goal_tbm default
		setstate powerball_allied_goal default
		setstate powerball_allied_goal_marker default
		setstate powerball_allied_goal_clip default
		wait 200
		setstate powerball_axis_goal_toi default // Axis 1st goal.
		setstate powerball_axis_goal_tbm default
		setstate powerball_axis_goal default
		setstate powerball_axis_goal_marker default
		setstate powerball_axis_goal_clip default
		wait 50

		enablespeaker red_east
		enablespeaker red_west
		enablespeaker blue_east
		enablespeaker blue_west

		setstate rotator1 default

		accum 1 set 0 // Elevators.
		accum 2 set 0
		accum 3 set 0
		accum 4 set 0

		cvar g_gametype trigger_if_equal 6 game_manager gtype6

		wait 50
		alertentity signexpl

	} // End spawn section in game_manager

     trigger gtype6
		{
		wm_announce   "^3Console: Game-type 6 initiated: Domination, Powerball-mode."
		wm_announce   "^3         Both teams kill and die for a small ball. Steal it, and score with it in the enemy's goal!"
		wait 100
		setautospawn	"Axis First Spawn" 0
		setautospawn	"Allied First Spawn" 1
		}

	trigger timelimit_hit
	{
		wm_announce "^1Acta est fabula."
	}

	trigger allinewspawntime // This function is called whenever the allies score.
	{
		// alertentity en speaker
		trigger game_manager alli_1sectext
		trigger game_manager alli_perma10
		trigger game_manager alli_set3
		trigger game_manager alli_set4
		trigger game_manager alli_set5
		trigger game_manager alli_set6
		trigger game_manager alli_set7
		trigger game_manager alli_set8
		trigger game_manager alli_set9
		trigger game_manager alli_set10
	}

	trigger alli_1sectext
	{
		globalaccum 1 abort_if_greater_than 8
		wm_announce	"^1Allied respawntime increased by 1 second."
	}

	trigger alli_perma10
	{
		globalaccum 1 abort_if_less_than 8
		wm_announce	"^1Allied respawntime set permanently to 10 seconds."
	}

	trigger alli_set3
	{
		globalaccum 1 abort_if_not_equal 1
		wm_allied_respawntime 3
		wait 50
	}

	trigger alli_set4
	{
		globalaccum 1 abort_if_not_equal 2
		wm_allied_respawntime 4
	}

	trigger alli_set5
	{
		globalaccum 1 abort_if_not_equal 3
		wm_allied_respawntime 5
		setautospawn	"Allied Second Spawn" 1  // New main spawnpoint for the allies (further away from the axis base).
		alertentity alli_1stspawn_right // this toggles the startactive-function for this entity (turns the startactive off).
		setstate alli_1stspawn_right invisible // and this turns it invisible.
		setstate two_alli_1stspawn invisible // makes the team_WOLF_objective (yellow box) invisible.
	}

	trigger alli_set6
	{
		globalaccum 1 abort_if_not_equal 4
		wm_allied_respawntime 6
	}

	trigger alli_set7
	{
		globalaccum 1 abort_if_not_equal 5
		wm_allied_respawntime 7
		setautospawn	"Allied Third Spawn" 1  // New main spawnpoint for the allies (further away from the axis base).
		alertentity alli_2ndspawn_right // this toggles the startactive-function for this entity (turns the startactive off).
		setstate alli_2ndspawn_right invisible // and this turns it invisible.
		setstate two_alli_2ndspawn invisible // makes the team_WOLF_objective (yellow box) invisible.
	}

	trigger alli_set8
	{
		globalaccum 1 abort_if_not_equal 6
		wm_allied_respawntime 8
	}

	trigger alli_set9
	{
		globalaccum 1 abort_if_not_equal 7
		wm_allied_respawntime 9
		setautospawn	"Allied Fourth Spawn" 1  // New main spawnpoint for the allies (further away from the axis base).
		alertentity alli_3rdspawn_right // this toggles the startactive-function for this entity (turns the startactive off).
		setstate alli_3rdspawn_right invisible // and this turns it invisible.
		setstate two_alli_3rdspawn invisible // makes the team_WOLF_objective (yellow box) invisible.
	}

	trigger alli_set10
	{
		globalaccum 1 abort_if_not_equal 8
		wm_allied_respawntime 10
	}


	trigger axisnewspawntime // This function is called whenever the axis score.
	{
		// alertentity en speaker
		alertentity powerball
		trigger game_manager axis_1sectext
		trigger game_manager axis_perma10
		trigger game_manager axis_set3
		trigger game_manager axis_set4
		trigger game_manager axis_set5
		trigger game_manager axis_set6
		trigger game_manager axis_set7
		trigger game_manager axis_set8
		trigger game_manager axis_set9
		trigger game_manager axis_set10
	}

	trigger axis_1sectext
	{
		globalaccum 2 abort_if_greater_than 8
		wm_announce	"^1Axis respawntime increased by 1 second."
	}

	trigger axis_perma10
	{
		globalaccum 2 abort_if_less_than 8
		wm_announce	"^1Axis respawntime set permanently to 10 seconds."
	}

	trigger axis_set3
	{
		globalaccum 2 abort_if_not_equal 1
		wm_axis_respawntime 3
	}

	trigger axis_set4
	{
		globalaccum 2 abort_if_not_equal 2
		wm_axis_respawntime 4
	}

	trigger axis_set5
	{
		globalaccum 2 abort_if_not_equal 3
		wm_axis_respawntime 5
		setautospawn	"Axis Second Spawn" 0 // New main spawnpoint for the axis (further away from the allied base).
		alertentity axis_1stspawn_right // this toggles the startactive-function for this entity (turns the startactive off).
		setstate axis_1stspawn_right invisible // and this turns it invisible.
		setstate two_axis_1stspawn invisible // makes the team_WOLF_objective (yellow box) invisible.
	}

	trigger axis_set6
	{
		globalaccum 2 abort_if_not_equal 4
		wm_axis_respawntime 6
	}

	trigger axis_set7
	{
		globalaccum 2 abort_if_not_equal 5
		wm_axis_respawntime 7
		setautospawn	"Axis Third Spawn" 0 // New main spawnpoint for the axis (further away from the allied base).
		alertentity axis_2ndspawn_right // this toggles the startactive-function for this entity (turns the startactive off).
		setstate axis_2ndspawn_right invisible // and this turns it invisible.
		setstate two_axis_2ndspawn invisible // makes the team_WOLF_objective (yellow box) invisible.
	}

	trigger axis_set8
	{
		globalaccum 2 abort_if_not_equal 6
		wm_axis_respawntime 8
	}

	trigger axis_set9
	{
		globalaccum 2 abort_if_not_equal 7
		wm_axis_respawntime 9
		setautospawn	"Axis Fourth Spawn" 0 // New main spawnpoint for the axis (further away from the allied base).
		alertentity axis_3rdspawn_right // this toggles the startactive-function for this entity (turns the startactive off).
		setstate axis_3rdspawn_right invisible // and this turns it invisible.
		setstate two_axis_3rdspawn invisible // makes the team_WOLF_objective (yellow box) invisible.
	}

	trigger axis_set10
	{
		globalaccum 2 abort_if_not_equal 8
		wm_axis_respawntime 10
	}
} // End game_manager

signexpl
{
	spawn
	{
		wait 1000
		trigger signexpl action
	}

   trigger action
	{
		alertentity signexpl
	}
}


powerball // Powerball no. 1.
{
	spawn
	{
		wait 50
	}

	trigger stolen	// The poweball is stolen.
	{
		wm_announce	"^3The powerball is stolen from its original respawn-point!"
	}

	trigger returned // The poweball is returned.
	{
		wm_announce	"^3The powerball is returned to its original respawn-point!"
	}

	trigger captured // // The poweball is captured (a player scores with it).
	{
		// This section is triggered when a player runs into the goal with ball in hand, ie a touchdown.
	}
}

//Powerball trigger area for all allied goals and all axis goals.

powerball_allied_goal_tbm
{
	death // Called when an axis player scores
	{
		wm_announce	"^1The Axis score!"
		globalaccum 2 inc 1
		trigger game_manager axisnewspawntime
	}
}

powerball_axis_goal_tbm
{
	death // This function is called when an allied player scores.
	{
		wm_announce	"^1The Allied Forces score!"
		globalaccum 1 inc 1
		trigger game_manager allinewspawntime
	}
}


// Allied elevators 1 and 2 below.

tst_allilift1
{
	spawn
	{
		wait 50
	}

   trigger action
	{
		trigger allilift1 move
	}
}

allilift1
{
	spawn
	{
		wait 500
		gotomarker pc_allilift1_down 100 wait
	}

   trigger move
	{
		accum 3 abort_if_equal 1 // Is the elevator running at the moment? 0 = No. 1 = Yes.
		accum 3 set 1
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 1000
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_allilift1_up 300 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		wait 1000
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_allilift1_down 500 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		stopsound
		wait 3000
		accum 3 set 0
	}
}

tst_allilift2
{
	spawn
	{
		wait 50
	}

   trigger action
	{
		trigger allilift2 move
	}
}

allilift2
{
	spawn
	{
		wait 500
		gotomarker pc_allilift2_down 100 wait
	}

   trigger move
	{
		accum 4 abort_if_equal 1 // Is the elevator running at the moment? 0 = No. 1 = Yes.
		accum 4 set 1
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 1000
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_allilift2_up 300 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		wait 1000
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_allilift2_down 500 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		stopsound
		wait 3000
		accum 4 set 0
	}
}


// Axis elevator 1 and 2 below.

tst_axislift1
{
	spawn
	{
		wait 50
	}

   trigger action
	{
		trigger axislift1 move
	}
}

axislift1
{
	spawn
	{
		wait 500
		gotomarker pc_axislift1_down 100 wait
	}

   trigger move
	{
		accum 1 abort_if_equal 1 // Is the elevator running at the moment? 0 = No. 1 = Yes.
		accum 1 set 1
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 1000
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_axislift1_up 300 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		wait 1000
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_axislift1_down 500 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		stopsound
		wait 3000
		accum 1 set 0
	}
}

tst_axislift2
{
	spawn
	{
		wait 50
	}

   trigger action
	{
		trigger axislift2 move
	}
}

axislift2
{
	spawn
	{
		wait 500
		gotomarker pc_axislift2_down 100 wait
	}

   trigger move
	{
		accum 2 abort_if_equal 1 // Is the elevator running at the moment? 0 = No. 1 = Yes.
		accum 2 set 1
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 1000
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_axislift2_up 300 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		wait 1000
		stopsound
		playsound sound/world/steam_02.wav volume 200
		wait 500
		playsound sound/movers/misc/garage_door_start_01.wav volume 200
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker pc_axislift2_down 500 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 200
		stopsound
		wait 3000
		accum 2 set 0
	}
}

// Command post script. From GoldRush by SD and prefab:ed by seven.
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
		alertentity cpexpl
	}
}

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	"^4ALLIED ^3command post constructed!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"
		// *---------------------------------------------------------------------------------*

	}

	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	"^4ALLIED ^3command post destroyed!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *---------------------------------------------------------------------------------*
	}
}

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

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	"^1AXIS ^3command post constructed!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		// *---------------------------------------------------------------------------------*
	}

	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	"^1AXIS ^3command post destroyed!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}
}
