game_manager
{
	spawn
	{
		// Set scenario information

		wm_axis_respawntime		15
		wm_allied_respawntime		15
		wm_set_round_timelimit		30
		wm_number_of_objectives		4


		// accum 0 holds status of each flag as a bit
		// capped = set, not capped = reset
		accum 0 set 0
		accum 1 set 0

		// If the round timer expires, no one has won
		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner -1

	}

	trigger add_axis_goldbar
	{
		accum 0 inc 1

		trigger game_manager axis_secured

		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"

		trigger gold_axis_full_1 show
		trigger gold_axis_trans_1 hide

		accum 0 abort_if_less_than 2

		trigger gold_axis_full_2 show
		trigger gold_axis_trans_2 hide

		accum 0 abort_if_less_than 3
	
		trigger gold_axis_full_3 show
		trigger gold_axis_trans_3 hide

		trigger game_manager axis_win				
	}

	trigger axis_secured
	{
		accum 0 trigger_if_equal 1 game_manager axis_secured1
		accum 0 trigger_if_equal 2 game_manager axis_secured2
		accum 0 trigger_if_equal 3 game_manager axis_secured3
	}

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

	trigger axis_secured2
	{
		wm_announce "Axis team has secured the second Gold Crate!"
	}
		
	trigger axis_secured3
	{
		wm_announce "Axis team has secured the last Gold Crate!"
	}

	trigger add_allies_goldbar
	{
		accum 1 inc 1

		trigger game_manager allies_secured

		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"

		trigger gold_allies_full_1 show
		trigger gold_allies_trans_1 hide

		accum 1 abort_if_less_than 2

		trigger gold_allies_full_2 show
		trigger gold_allies_trans_2 hide

		accum 1 abort_if_less_than 3
	
		trigger gold_allies_full_3 show
		trigger gold_allies_trans_3 hide

		trigger game_manager allies_win					
	}

	trigger allies_secured
	{
		accum 1 trigger_if_equal 1 game_manager allies_secured1
		accum 1 trigger_if_equal 2 game_manager allies_secured2
		accum 1 trigger_if_equal 3 game_manager allies_secured3	
	}

	trigger allies_secured1
	{
		wm_announce "Allied team has secured the first Gold Crate!"
	}

	trigger allies_secured2
	{
		wm_announce "Allied team has secured the second Gold Crate!"
	}

	trigger allies_secured3
	{
		wm_announce "Allied team has secured the last Gold Crate!"
	}

	trigger allies_win
	{
		wm_setwinner	1

		wait 1500
		wm_endround
	}

	trigger axis_win
	{
		wm_setwinner	0

		wait 1500
		wm_endround
	}
}

gold_axis_full_1
{
	spawn
	{
		setstate gold_axis_full_1 invisible
	}

	trigger show
	{
		setstate gold_axis_full_1 default
	}
}

gold_axis_full_2
{
	spawn
	{
		setstate gold_axis_full_2 invisible
	}

	trigger show
	{
		setstate gold_axis_full_2 default
	}
}

gold_axis_full_3
{
	spawn
	{
		setstate gold_axis_full_3 invisible
	}

	trigger show
	{
		setstate gold_axis_full_3 default
	}
}

gold_axis_trans_1
{
	spawn
	{
		setstate gold_axis_trans_1 default
	}

	trigger hide
	{
		setstate gold_axis_trans_1 invisible
	}
}

gold_axis_trans_2
{
	spawn
	{
		setstate gold_axis_trans_2 default
	}

	trigger hide
	{
		setstate gold_axis_trans_2 invisible
	}
}

gold_axis_trans_3
{
	spawn
	{
		setstate gold_axis_trans_3 default
	}

	trigger hide
	{
		setstate gold_axis_trans_3 invisible
	}
}

gold_allies_full_1
{
	spawn
	{
		setstate gold_allies_full_1 invisible
	}

	trigger show
	{
		setstate gold_allies_full_1 default
	}
}

gold_allies_full_2
{
	spawn
	{
		setstate gold_allies_full_2 invisible
	}

	trigger show
	{
		setstate gold_allies_full_2 default
	}
}

gold_allies_full_3
{
	spawn
	{
		setstate gold_allies_full_3 invisible
	}

	trigger show
	{
		setstate gold_allies_full_3 default
	}
}

gold_allies_trans_1
{
	spawn
	{
		setstate gold_allies_trans_1 default
	}
	
	trigger hide
	{
		setstate gold_allies_trans_1 invisible
	}
}

gold_allies_trans_2
{
	spawn
	{
		setstate gold_allies_trans_2 default
	}
	
	trigger hide
	{
		setstate gold_allies_trans_2 invisible
	}
}

gold_allies_trans_3
{
	spawn
	{
		setstate gold_allies_trans_3 default
	}
	
	trigger hide
	{
		setstate gold_allies_trans_3 invisible
	}
}

axis_gold_flag
{
	death
	{
		trigger game_manager add_axis_goldbar
	}
}

allied_gold_flag
{
	death
	{
		trigger game_manager add_allies_goldbar
	}
}

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

	trigger stolen
	{
		setstate axis_gold_crate invisible
	}

	trigger secured
	{
		setstate axis_gold_crate default
	}

	trigger returned
	{
	}
}

