//=============================================================================
// GAME NANAGER
//=============================================================================

game_manager
{
	spawn
	{
		// set scenario information
		wm_axis_respawntime    	5
		wm_allied_respawntime  	5
		wm_set_round_timelimit 	0

		// set objective information
		wm_number_of_objectives 4
		wm_objective_status 1 0 0
		wm_objective_status 1 1 0
		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
		wm_objective_status 3 0 0
		wm_objective_status 3 1 0
		wm_objective_status 4 0 0
		wm_objective_status 4 1 0

		// initialize accumulators
		// (0=head 1=figure 2=objective)
		accum 0 set 0
		accum 1 set 0
		accum 2 set 0

		// initialize global accumulators
		// (0=exit)
		globalaccum 0 set 0
	}

	//-- round end trigger --

	trigger end_round
	{
		wm_announce "Primary objectives completed!"
		wm_announce "Southwest exit is now unlocked."

		wm_teamvoiceannounce 0 exit_unlocked
		wm_teamvoiceannounce 1 exit_unlocked

		globalaccum 0 set 1
	}

        //-- exit triggers --

        trigger exit_locked
        {
                wm_announce "Exit is locked! Objectives not completed."
                wm_teamvoiceannounce 0 exit_locked
                wm_teamvoiceannounce 1 exit_locked
        }

        trigger allied_exit
        {
		wm_setwinner 1
		wm_set_defending_team 0
		wm_endround
        }

        trigger axis_exit
        {
		wm_setwinner 0
		wm_set_defending_team 1
		wm_endround
        }

	//-- target destruction triggers --

	trigger head_destroy
	{
		wm_announce "Box target down."

		wm_teamvoiceannounce 0 target_destroyed
		wm_teamvoiceannounce 1 target_destroyed

		accum 0 inc 1
		accum 0 trigger_if_equal  1 game_manager remain_18
		accum 0 trigger_if_equal  2 game_manager remain_17
		accum 0 trigger_if_equal  3 game_manager remain_16
		accum 0 trigger_if_equal  4 game_manager remain_15
		accum 0 trigger_if_equal  5 game_manager remain_14
		accum 0 trigger_if_equal  6 game_manager remain_13
		accum 0 trigger_if_equal  7 game_manager remain_12
		accum 0 trigger_if_equal  8 game_manager remain_11
		accum 0 trigger_if_equal  9 game_manager remain_10
		accum 0 trigger_if_equal 10 game_manager remain_9
		accum 0 trigger_if_equal 11 game_manager remain_8
		accum 0 trigger_if_equal 12 game_manager remain_7
		accum 0 trigger_if_equal 13 game_manager remain_6
		accum 0 trigger_if_equal 14 game_manager remain_5
		accum 0 trigger_if_equal 15 game_manager remain_4
		accum 0 trigger_if_equal 16 game_manager remain_3
		accum 0 trigger_if_equal 17 game_manager remain_2
		accum 0 trigger_if_equal 18 game_manager remain_1
		accum 0 trigger_if_equal 19 game_manager head_remain_0
	}	

	trigger figure_destroy
	{
		wm_announce "Figure target down."

		wm_teamvoiceannounce 0 target_destroyed
		wm_teamvoiceannounce 1 target_destroyed

		accum 1 inc 1
		accum 1 trigger_if_equal  1 game_manager remain_9
		accum 1 trigger_if_equal  2 game_manager remain_8
		accum 1 trigger_if_equal  3 game_manager remain_7
		accum 1 trigger_if_equal  4 game_manager remain_6
		accum 1 trigger_if_equal  5 game_manager remain_5
		accum 1 trigger_if_equal  6 game_manager remain_4
		accum 1 trigger_if_equal  7 game_manager remain_3
		accum 1 trigger_if_equal  8 game_manager remain_2
		accum 1 trigger_if_equal  9 game_manager remain_1
		accum 1 trigger_if_equal 10 game_manager figure_remain_0
	}

	//-- objective completion triggers --

	trigger head_remain_0
	{
		wm_announce "All box targets destroyed!"

		wm_objective_status 1 0 2
		wm_objective_status 1 1 2

		wm_teamvoiceannounce 0 objective_completed
		wm_teamvoiceannounce 1 objective_completed

		accum 2 inc 1
		accum 2 trigger_if_equal 2 game_manager end_round
	}

	trigger figure_remain_0
	{
		wm_announce "All figure targets destroyed!"

		wm_objective_status 2 0 2
		wm_objective_status 2 1 2

		wm_teamvoiceannounce 0 objective_completed
		wm_teamvoiceannounce 1 objective_completed

		accum 2 inc 1
		accum 2 trigger_if_equal 2 game_manager end_round
	}

	//-- "xx remaining." message triggers --

	trigger remain_1
	{
		wm_announce "^51 ^7remaining."
	}

	trigger remain_2
	{
		wm_announce "^52 ^7remaining."
	}

	trigger remain_3
	{
		wm_announce "^53 ^7remaining."
	}

	trigger remain_4
	{
		wm_announce "^54 ^7remaining."
	}

	trigger remain_5
	{
		wm_announce "^55 ^7remaining."
	}

	trigger remain_6
	{
		wm_announce "^56 ^7remaining."
	}

	trigger remain_7
	{
		wm_announce "^57 ^7remaining."
	}

	trigger remain_8
	{
		wm_announce "^58 ^7remaining."
	}

	trigger remain_9
	{
		wm_announce "^59 ^7remaining."
	}

	trigger remain_10
	{
		wm_announce "^510 ^7remaining."
	}

	trigger remain_11
	{
		wm_announce "^511 ^7remaining."
	}

	trigger remain_12
	{
		wm_announce "^512 ^7remaining."
	}

	trigger remain_13
	{
		wm_announce "^513 ^7remaining."
	}

	trigger remain_14
	{
		wm_announce "^514 ^7remaining."
	}

	trigger remain_15
	{
		wm_announce "^515 ^7remaining."
	}

	trigger remain_16
	{
		wm_announce "^516 ^7remaining."
	}

	trigger remain_17
	{
		wm_announce "^517 ^7remaining."
	}

	trigger remain_18
	{
		wm_announce "^518 ^7remaining."
	}
}


//=============================================================================
// Map end triggers
//=============================================================================

exit_allied
{
	trigger enter
	{
                globalaccum 0 trigger_if_equal 0 game_manager exit_locked
		globalaccum 0 trigger_if_equal 1 game_manager allied_exit
	}
}

exit_axis
{
	trigger enter
	{
                globalaccum 0 trigger_if_equal 0 game_manager exit_locked
		globalaccum 0 trigger_if_equal 1 game_manager axis_exit
	}
}


//=============================================================================
// Command map markers
//=============================================================================

health_ammo_cmm
{
	spawn
	{
		setstate health_ammo_cmm default
	}
}

sw_exit_cmm
{
	spawn
	{
		setstate sw_exit_cmm default
	}
}

array0_cmm
{
	spawn
	{
		setstate array0_cmm default
	}
}

array1_cmm
{
	spawn
	{
		setstate array1_cmm default
	}
}

static_figure_area_cmm
{
	spawn
	{
		setstate static_figure_area_cmm default
	}
}

moving_figure_area_cmm
{
	spawn
	{
		setstate moving_figure_area_cmm default
	}
}

moving_box_area0_cmm
{
	spawn
	{
		setstate moving_box_area0_cmm default
	}
}

moving_box_area1_cmm
{
	spawn
	{
		setstate moving_box_area1_cmm default
	}
}


//=============================================================================
// Box targets, Straight paths 1
//=============================================================================

head0
{
	spawn 
	{
		wait 1000
		trigger head0 move
	}

	trigger move
	{
		gotomarker head0_0 130 wait
		wait 100
		gotomarker head0_1 130 wait
		wait 100
		trigger head0 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}

head1
{
	spawn 
	{
		wait 1000
		trigger head1 move
	}

	trigger move
	{
		gotomarker head1_0 140 wait
		wait 100
		gotomarker head1_1 140 wait
		wait 100
		trigger head1 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}

head2
{
	spawn 
	{
		wait 1000
		trigger head2 move
	}

	trigger move
	{
		gotomarker head2_0 150 wait
		wait 100
		gotomarker head2_1 150 wait
		wait 100
		trigger head2 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}

head3
{
	spawn 
	{
		wait 1000
		trigger head3 move
	}

	trigger move
	{
		gotomarker head3_0 100 wait
		wait 100
		gotomarker head3_1 100 wait
		wait 100
		trigger head3 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}

head4
{
	spawn 
	{
		wait 1000
		trigger head4 move
	}

	trigger move
	{
		gotomarker head4_0 110 wait
		wait 100
		gotomarker head4_1 110 wait
		wait 100
		trigger head4 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}

head5
{
	spawn 
	{
		wait 1000
		trigger head5 move
	}

	trigger move
	{
		gotomarker head5_0 120 wait
		wait 100
		gotomarker head5_1 120 wait
		wait 100
		trigger head5 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}


//=============================================================================
// Box targets, Straight paths 2
//=============================================================================

head6
{
	spawn 
	{
		wait 1000
		trigger head6 move
	}

	trigger move
	{
		gotomarker head6_0 130 wait
		wait 50
		gotomarker head6_1 130 wait
		wait 80
		gotomarker head6_2 130 wait
		wait 50
		gotomarker head6_3 130 wait 
		trigger head6 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}

head7
{
	spawn 
	{
		wait 1000
		trigger head7 move
	}

	trigger move
	{
		gotomarker head7_0 150 wait
		wait 50
		gotomarker head7_1 150 wait
		wait 80
		gotomarker head7_2 150 wait
		wait 50
		gotomarker head7_3 150 wait 
		trigger head7 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}

head8
{
	spawn 
	{
		wait 1000
		trigger head8 move
	}

	trigger move
	{
		gotomarker head8_0 140 wait
		wait 50
		gotomarker head8_1 140 wait
		wait 80
		gotomarker head8_2 140 wait
		wait 50
		gotomarker head8_3 140 wait 
		trigger head8 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}


//=============================================================================
// Box targets, Triangular paths	(clockwise and anti-clockwise)
//=============================================================================

head9
{
	spawn 
	{
		wait 1000
		trigger head9 move
	}

	trigger move
	{
		gotomarker head9_0 130 wait
		gotomarker head9_1 130 wait
		gotomarker head9_2 130 wait
		trigger head9 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}

head10
{
	spawn 
	{
		wait 1000
		trigger head10 move
	}

	trigger move
	{
		gotomarker head10_0 130 wait
		gotomarker head10_1 130 wait
		gotomarker head10_2 130 wait
		trigger head10 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}


//=============================================================================
// Box targets, Curved paths
//=============================================================================

head11
{
	spawn 
	{
		wait 1000
		trigger head11 move
	}

	trigger move
	{
		followspline 0 head11_0 120 wait
		wait 10
		followspline 1 head11_0 120 wait
		wait 10
		trigger head11 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}

head12
{
	spawn 
	{
		wait 1000
		trigger head12 move
	}

	trigger move
	{
		followspline 0 head12_0 120 wait
		wait 10
		followspline 1 head12_0 120 wait
		wait 10
		trigger head12 move
	}

	death
	{
		
		trigger game_manager head_destroy
	}
}

head13
{
	spawn 
	{
		wait 1000
		trigger head13 move
	}

	trigger move
	{
		followspline 0 head13_0 120 wait
		followspline 0 head13_1 120 wait
		wait 10
		followspline 1 head13_1 120 wait
		followspline 1 head13_0 120 wait
		wait 10
		trigger head13 move
	}

	death
	{
		
		trigger game_manager head_destroy
	}
}



//=============================================================================
// Figure targets
//=============================================================================

figure0
{
	spawn 
	{
		wait 1000
		trigger figure0 move
	}

	trigger move
	{
		gotomarker figure0_0 120 wait
		gotomarker figure0_1 120 wait
		trigger figure0 move
	}

	death
	{
		trigger game_manager figure_destroy
	}

}

figure1
{
	spawn 
	{
		wait 1000
		trigger figure1 move
	}

	trigger move
	{
		gotomarker figure1_0 120 wait
		gotomarker figure1_1 120 wait
		trigger figure1 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure2
{
	spawn 
	{
		wait 1000
		trigger figure2 move
	}

	trigger move
	{
		gotomarker figure2_0 120 wait
		gotomarker figure2_1 120 wait
		trigger figure2 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure3
{
	spawn 
	{
		wait 1000
		trigger figure3 move
	}

	trigger move
	{
		gotomarker figure3_0 120 wait
		gotomarker figure3_1 120 wait
		trigger figure3 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure4
{
	spawn 
	{
		wait 1000
		trigger figure4 move
	}

	trigger move
	{
		gotomarker figure4_0 120 wait
		gotomarker figure4_1 120 wait
		trigger figure4 move
	}

	death
	{
		trigger game_manager figure_destroy
	}

}

figure4
{
	spawn 
	{
		wait 1000
		trigger figure4 move
	}

	trigger move
	{
		gotomarker figure4_0 200 wait
		gotomarker figure4_1 200 wait
		trigger figure4 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure5
{
	spawn 
	{
		wait 1000
		trigger figure5 move
	}

	trigger move
	{
		gotomarker figure5_0 200 wait
		gotomarker figure5_1 200 wait
		trigger figure5 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure6
{
	spawn 
	{
		wait 1000
		trigger figure6 move
	}

	trigger move
	{
		gotomarker figure6_0 200 wait
		gotomarker figure6_1 200 wait
		trigger figure6 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure7
{
	spawn 
	{
		wait 1000
		trigger figure7 move
	}

	trigger move
	{
		gotomarker figure7_0 200 wait
		gotomarker figure7_1 200 wait
		trigger figure7 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure8
{
	spawn 
	{
		wait 1000
		trigger figure8 move
	}

	trigger move
	{
		gotomarker figure8_0 200 wait
		gotomarker figure8_1 200 wait
		trigger figure8 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}

figure9
{
	spawn 
	{
		wait 1000
		trigger figure9 move
	}

	trigger move
	{
		gotomarker figure9_0 250 wait
		gotomarker figure9_1 250 wait
		trigger figure9 move
	}

	death
	{		
		trigger game_manager figure_destroy
	}

}





//=============================================================================
// Box targets, Curved paths (with obstacles)
//=============================================================================

head20
{
	spawn 
	{
		wait 1000
		trigger head20 move
	}

	trigger move
	{
		followspline 0 head20_0 120 wait
		followspline 1 head20_0 120 wait
		trigger head20 move
	}

	death
	{
		
		trigger game_manager head_destroy
	}
}


head21
{
	spawn 
	{
		wait 1000
		trigger head21 move
	}

	trigger move
	{
		followspline 0 head21_0 120 wait
		followspline 1 head21_0 120 wait
		trigger head21 move
	}

	death
	{		
		trigger game_manager head_destroy
	}
}

head22
{
	spawn 
	{
		wait 1000
		trigger head22 move
	}

	trigger move
	{
		followspline 0 head22_0 120 wait
		followspline 1 head22_0 120 wait
		trigger head22 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}

head23
{
	spawn 
	{
		wait 1000
		trigger head23 move
	}

	trigger move
	{
		gotomarker head23_0 160 wait
		gotomarker head23_1 160 wait
		trigger head23 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}

head24
{
	spawn 
	{
		wait 1000
		trigger head24 move
	}

	trigger move
	{
		gotomarker head24_0 160 wait
		gotomarker head24_1 160 wait
		trigger head24 move
	}

	death
	{
		trigger game_manager head_destroy
	}
}
