game_manager
{
	spawn
	{
		// Game rules
		wm_axis_respawntime	01
		wm_allied_respawntime	01
		wm_number_of_objectives 5
		wm_set_round_timelimit	20

		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

		// Set start spawnpoints
		wait 500
		setautospawn "Axis Spawn" 0
		setautospawn "Allied Spawn" 1

		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner	-1

		// Set flag owner at start (0= No one owns it)
		globalaccum 1 set 0
		globalaccum 2 set 0
		globalaccum 3 set 0
		globalaccum 4 set 0
		globalaccum 5 set 0
		globalaccum 7 set 0
		globalaccum 8 set 0

		trigger game_manager timer
	}

	trigger timer
	{
		// Every 60 seconds tell score!
		wait 60000
		wm_announce "^21 minute has passed, the score is now:"
		trigger game_manager counter_axis0
		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5
		trigger game_manager counter_allies0
		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5
		trigger game_manager timer
	}

	trigger axis_win
	{
		// check if all 5 flags is owned
		globalaccum 1 abort_if_not_equal 1
		globalaccum 2 abort_if_not_equal 1
		globalaccum 3 abort_if_not_equal 1
		globalaccum 4 abort_if_not_equal 1
		globalaccum 5 abort_if_not_equal 1


		wm_setwinner	0
		wm_announce "^1Axis ^6team secured all 5 flags!"


		wait 1500
		wm_endround
	}

	trigger allies_win
	{
		// check if all 5 flags is owned
		globalaccum 1 abort_if_not_equal 2
		globalaccum 2 abort_if_not_equal 2
		globalaccum 3 abort_if_not_equal 2
		globalaccum 4 abort_if_not_equal 2
		globalaccum 5 abort_if_not_equal 2
		wm_setwinner	1
		wm_announce "^4Allied ^6team secured all 5 flags!"


		wait 1500
		wm_endround
	}


	// Axis Counter System
	trigger counter_axis_remove
	{
		// Remove 1 flag from count
		globalaccum 7 inc -1
		trigger game_manager counter_axis0
		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5
	}

	trigger counter_axis0
	{
		// Tell how many flags each team is holding
		globalaccum 7 abort_if_not_equal 0
		wm_announce "^1Axis ^6does not own any flag"			
	}

	trigger counter_axis1
	{
		// Tell how many flags each team is holding
		globalaccum 7 abort_if_not_equal 1
		wm_announce "^1Axis ^6now owns 1 flag out of 5"			
	}

	trigger counter_axis2
	{
		// Tell how many flags each team is holding
		globalaccum 7 abort_if_not_equal 2
		wm_announce "^1Axis ^6now owns 2 flags out of 5"			
	}

	trigger counter_axis3
	{
		// Tell how many flags each team is holding
		globalaccum 7 abort_if_not_equal 3
		wm_announce "^1Axis ^6now owns 3 flags out of 5"			
	}

	trigger counter_axis4
	{
		// Tell how many flags each team is holding
		globalaccum 7 abort_if_not_equal 4
		wm_announce "^1Axis ^6now owns 4 flags out of 5"
	}

	trigger counter_axis5
	{
		// Tell how many flags each team is holding
		globalaccum 7 abort_if_not_equal 5
		wm_announce "^1Axis ^6now owns 5 flags out of 5"			
	}


	// Allies Counter System
	trigger counter_allies_remove
	{
		// Remove 1 flag from count
		globalaccum 8 inc -1
		trigger game_manager counter_allies0
		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5
	}

	trigger counter_allies0
	{
		// Tell how many flags each team is holding
		globalaccum 8 abort_if_not_equal 0
		wm_announce "^4Allies ^6does not own any flag"
	}

	trigger counter_allies1
	{
		// Tell how many flags each team is holding
		globalaccum 8 abort_if_not_equal 1
		wm_announce "^4Allies ^6now owns 1 flag out of 5"
	}

	trigger counter_allies2
	{
		// Tell how many flags each team is holding
		globalaccum 8 abort_if_not_equal 2
		wm_announce "^4Allies ^6now owns 2 flags out of 5"
	}

	trigger counter_allies3
	{
		// Tell how many flags each team is holding
		globalaccum 8 abort_if_not_equal 3
		wm_announce "^4Allies ^6now owns 3 flags out of 5"
	}

	trigger counter_allies4
	{
		// Tell how many flags each team is holding
		globalaccum 8 abort_if_not_equal 4
		wm_announce "^4Allies ^6now owns 4 flags out of 5"
	}

	trigger counter_allies5
	{
		// Tell how many flags each team is holding
		globalaccum 8 abort_if_not_equal 5
		wm_announce "^4Allies ^6now owns 5 flags out of 5"
	}
}

// ============================================================================
// Checkpoints, 5 different flags to own to end the game!
// ============================================================================

flag1
{
	spawn
	{
		accum 0 set 0 // No one owns the flag
	}

	trigger axis_capture	// Flag has been claimed by an axis player
	{
		accum 0 abort_if_equal 1 // Do Axis already own the flag?

		wm_objective_status 1 1 2
		wm_objective_status 1 0 1

		// Set ownage for flag for endgame check.
		globalaccum 1 set 1

		wm_announce	"^1Axis ^6capture the South Flag"
		trigger game_manager axis_win

		globalaccum 7 inc 1

		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5

		accum 0 trigger_if_equal 2 game_manager counter_allies_remove
		accum 0 set 1 // Axis own the flag
	}

	trigger allied_capture	// Flag has been claimed by an allied player
	{
		accum 0 abort_if_equal 2 // Do Allies already own flag?

		wm_objective_status 1 1 1
		wm_objective_status 1 0 2

		// Set ownage for flag for endgame check.
		globalaccum 1 set 2

		wm_announce	"^4Allies ^6capture the South Flag"
		trigger game_manager allies_win

		globalaccum 8 inc 1

		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5

		accum 0 trigger_if_equal 1 game_manager counter_axis_remove
		accum 0 set 2 // Allied own the flag
	}
}

flag2
{
	spawn
	{
		accum 0 set 0 // No one owns the flag
	}

	trigger axis_capture	// Flag has been claimed by an axis player
	{
		accum 0 abort_if_equal 1 // Do Axis already own the flag?

		wm_objective_status 2 1 2
		wm_objective_status 2 0 1

		// Set ownage for flag for endgame check.
		globalaccum 2 set 1

		wm_announce	"^1Axis ^6capture the West Flag"
		trigger game_manager axis_win

		globalaccum 7 inc 1

		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5

		accum 0 trigger_if_equal 2 game_manager counter_allies_remove
		accum 0 set 1 // Axis own the flag
	}

	trigger allied_capture	// Flag has been claimed by an allied player
	{
		accum 0 abort_if_equal 2 // Do Allies already own flag?

		wm_objective_status 2 1 1
		wm_objective_status 2 0 2

		// Set ownage for flag for endgame check.
		globalaccum 2 set 2

		wm_announce	"^4Allies ^6capture the West Flag"
		trigger game_manager allies_win

		globalaccum 8 inc 1

		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5

		accum 0 trigger_if_equal 1 game_manager counter_axis_remove
		accum 0 set 2 // Allied own the flag
	}
}

flag3
{
	spawn
	{
		accum 0 set 0 // No one owns the flag
	}

	trigger axis_capture	// Flag has been claimed by an axis player
	{
		accum 0 abort_if_equal 1 // Do Axis already own the flag?

		wm_objective_status 3 1 2
		wm_objective_status 3 0 1

		// Set ownage for flag for endgame check.
		globalaccum 3 set 1

		wm_announce	"^1Axis ^6capture the Center Flag"
		trigger game_manager axis_win

		globalaccum 7 inc 1

		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5

		accum 0 trigger_if_equal 2 game_manager counter_allies_remove
		accum 0 set 1 // Axis own the flag
	}

	trigger allied_capture	// Flag has been claimed by an allied player
	{
		accum 0 abort_if_equal 2 // Do Allies already own flag?

		wm_objective_status 3 1 1
		wm_objective_status 3 0 2

		// Set ownage for flag for endgame check.
		globalaccum 3 set 2

		wm_announce	"^4Allies ^6capture the Center Flag"
		trigger game_manager allies_win

		globalaccum 8 inc 1

		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5

		accum 0 trigger_if_equal 1 game_manager counter_axis_remove
		accum 0 set 2 // Allied own the flag
	}
}

flag4
{
	spawn
	{
		accum 0 set 0 // No one owns the flag
	}

	trigger axis_capture	// Flag has been claimed by an axis player
	{
		accum 0 abort_if_equal 1 // Do Axis already own the flag?

		wm_objective_status 4 1 2
		wm_objective_status 4 0 1

		// Set ownage for flag for endgame check.
		globalaccum 4 set 1

		wm_announce	"^1Axis ^6capture the East Flag"
		trigger game_manager axis_win

		globalaccum 7 inc 1

		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5

		accum 0 trigger_if_equal 2 game_manager counter_allies_remove
		accum 0 set 1 // Axis own the flag
	}

	trigger allied_capture	// Flag has been claimed by an allied player
	{
		accum 0 abort_if_equal 2 // Do Allies already own flag?

		wm_objective_status 4 1 1
		wm_objective_status 4 0 2

		// Set ownage for flag for endgame check.
		globalaccum 4 set 2

		wm_announce	"^4Allies ^6capture the East Flag"
		trigger game_manager allies_win

		globalaccum 8 inc 1

		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5

		accum 0 trigger_if_equal 1 game_manager counter_axis_remove
		accum 0 set 2 // Allied own the flag
	}
}

flag5
{
	spawn
	{
		accum 0 set 0 // No one owns the flag
	}

	trigger axis_capture	// Flag has been claimed by an axis player
	{
		accum 0 abort_if_equal 1 // Do Axis already own the flag?

		wm_objective_status 5 1 2
		wm_objective_status 5 0 1

		// Set ownage for flag for endgame check.
		globalaccum 5 set 1

		wm_announce	"^1Axis ^6capture the North Flag"
		trigger game_manager axis_win

		globalaccum 7 inc 1

		trigger game_manager counter_axis1
		trigger game_manager counter_axis2
		trigger game_manager counter_axis3
		trigger game_manager counter_axis4
		trigger game_manager counter_axis5

		accum 0 trigger_if_equal 2 game_manager counter_allies_remove
		accum 0 set 1 // Axis own the flag
	}

	trigger allied_capture	// Flag has been claimed by an allied player
	{
		accum 0 abort_if_equal 2 // Do Allies already own flag?

		wm_objective_status 5 1 1
		wm_objective_status 5 0 2

		// Set ownage for flag for endgame check.
		globalaccum 5 set 2

		wm_announce	"^4Allies ^6capture the North Flag"
		trigger game_manager allies_win

		globalaccum 8 inc 1

		trigger game_manager counter_allies1
		trigger game_manager counter_allies2
		trigger game_manager counter_allies3
		trigger game_manager counter_allies4
		trigger game_manager counter_allies5

		accum 0 trigger_if_equal 1 game_manager counter_axis_remove
		accum 0 set 2 // Allied own the flag
	}
}