// Script for Door, by Kent "Loffy" Lofgren, Sweden.
// July 2013.

game_manager
{
	spawn
	{
		remapshaderflush
		wm_set_round_timelimit	15
		wm_axis_respawntime 10
		wm_allied_respawntime	10
		wm_number_of_objectives 1
		wm_objective_status 1 0 0 // The gold
		wm_objective_status 1 1 0
		wm_setwinner 1 // Allies win at full time.
		wait 50
		setautospawn "Axis spawn" 0 	// Name comes from description in team_WOLF_objective entity.
		setautospawn "Allied spawn" 1
		wait 50
		setstate gold_end_scene invisible // Hide the gold that is visible only at the end. (It is seen in the end-camera.)
		setstate goldbox_goal default // Show goldbox (transparent red) at the goal.
		wait 50
		setstate tm_alliedmessage default // Show Allied trigger at the goldbox' original location.
		setstate wallfence default // A piece of the fence ontop of the Axis wall.
		wait 50
		setstate toi_door1 default // Map icon for the Axis. The door.
		wait 50
		setstate mcm_goldbars default // Map icon. The gold.
		setstate toi_goldbars default // Map icon. The gold.
		wait 1000
		wm_teamvoiceannounce 1 "the_gold_allies" // Allied voice: "The Gold!"
		wm_teamvoiceannounce 0 "the_gold_axis" // Axis voice: "The Gold!"
	} // End of game_manager spawn

	trigger objective
	{
		trigger game_manager checkgame // Check for end of game.
	}

	trigger checkgame
	{
		wm_setwinner 0
		wm_announce "^1Allied Base self-destructs"
		wm_teamvoiceannounce 0 "axis_positive"
		wm_teamvoiceannounce 1 "axis_positive"
		wm_teamvoiceannounce 0 "axis_capturesong_marlene"
		wm_teamvoiceannounce 1 "axis_capturesong_marlene"
		alertentity ts_endbang // Sound and smoke sfx at the delivery point (Axis base) for the end camera.
		wait 2000
		alertentity ts_endsmoke // Sound sfx plus explosion at the horizon (Allied Base) for the end camera.
		trigger sm_wilsflame2 show // Fire at the horizon (Allied Base) for the end camera.
		wm_endround
	}
}  // End of game_manager


tst_endtest
{
	spawn
	{
	}

	trigger execute
	{
		alertentity ts_endsmoke // Sound sfx plus explosion at the horizon (Allied Base) for the end camera.
		trigger sm_wilsflame2 show // Fire at the horizon (Allied Base) for the end camera.
	}
}


tst_endtestreset
{
	spawn
	{
	}

	trigger execute2
	{
		alertentity ts_endsmoke // Sound sfx plus explosion at the horizon (Allied Base) for the end camera.
		trigger sm_wilsflame2 hide // Fire at the horizon (Allied Base) for the end camera.
	}
}


the_gold // The scriptname for the goldbox.
{
	spawn
	{
	}

	trigger stolen	// Gold is stolen.
	{
		setstate tm_alliedmessage invisible // Hide Allied trigger at the goldbox' original location.
		setstate mcm_goldbars_axis invisible // Map icon for the Axis. The gold.
		setstate toi_goldbars_axis invisible // Map icon for the Axis. The gold.
		setstate mcm_goldbars invisible // Map icon. The gold.
		setstate toi_goldbars invisible // Map icon. The gold.
		trigger sm_redblink show // A red, blinking effect.
		alertentity ts_goldalarm // Sound sfx at Gold box.
	}

	trigger returned // Gold is returned.
	{
		setstate tm_alliedmessage default // Show Allied trigger at the goldbox' original location.
		setstate mcm_goldbars_axis default // Map icon for the Axis. The gold.
		setstate toi_goldbars_axis default // Map icon for the Axis. The gold.
		setstate mcm_goldbars default // Map icon. The gold.
		setstate toi_goldbars default // Map icon. The gold.
		trigger sm_redblink hide // A red, blinking effect.
	}

	trigger captured // Gold is captured.
	{
		alertentity ts_delivery // Sound sfx at delivery point.
		setstate tm_alliedmessage invisible // Hide Allied trigger at the goldbox' original location.
		setstate goldbox_goal invisible // Hide goldbox (transparent red).
		setstate gold_end_scene default // Show goldbox.
		wait 2000
		trigger game_manager objective
		trigger sm_redblink hide // A red, blinking effect.
	}
}

axis_triggerzone // Trigger area. Where Axis must take the gold, to win.
{
	death
	{
		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
		wm_teamvoiceannounce 1 "allies_hq_objective_lost"
	}
}

door  // The func_explosive.
{
	spawn
	{
		wait 200
		constructible_class 3
	}

	death
	{
		trigger sm_flydoor flyaway
		setstate wallfence invisible	
		alertentity te_watercover // Small explosion sfx for water tunnel.
		wait 500
		wm_teamvoiceannounce 0 "wall_breached_axis"
		wm_teamvoiceannounce 1 "wall_breached_allies"
		wm_announce "^8The Axis have dynamited the door!"
	}
}

sm_flydoor // A script mover. The door.
{
	spawn
	{
	wait 5000
	trigger sm_flydoor inplace
	}

	trigger inplace
	{
	stopsound
	playsound sound/movers/doors/door4_endcq.wav volume 1024
	playsound sound/movers/doors/door4_closeq.wav looping volume 512
	gotomarker pc_inplace 10 wait
	stopsound
	playsound sound/movers/doors/door6_endc.wav volume 128
	alertentity doorsmoke // Dust effect.
	}
	
	trigger flyaway
	{
	gotomarker pc_away 500
	faceangles 0 0 90 100
	trigger sm_rotatingbox rotate
	}
}

sm_rotatingbox // A script mover. Small box (crate).
{
	trigger rotate
	{
	wait 500
	faceangles 5 43 0 100 // Rotates the box.
	alertentity te_rotatingbox // Small, wooden explosion effect.
	alertentity pd_rotatingbox // Dust effect.
	}
}

wallfence
{
	spawn
	{
	}

	death
	{
	}
}

sm_redblink // A script mover. Red, blinking effect.
{
	spawn
	{
	wait 5000
	trigger sm_redblink hide
	}

	trigger hide
	{
	gotomarker pc_redblinkhidden 500 wait
	}
	
	trigger show
	{
	gotomarker pc_redblinkshown 500 wait
	}
}

sm_wilsflame2 // A script mover. Large fire in the Allied Base, after game is over.
{
	spawn
	{
	wait 6000
	trigger sm_wilsflame2 hide
	}

	trigger hide
	{
	gotomarker pc_flamelower 500 wait
	}
	
	trigger show
	{
	gotomarker pc_flameupper 500 wait
	}
}



// ***********************************************************



