
// -----------------------------------------------------------------------
// loderunner - authored by tbh|bloodwire
// 
// I've mostly based this script on Drakirs CTG map, with ofcourse my own 
// touch.
//

game_manager
{
	spawn
	{
		wait 500
		wm_axis_respawntime 25
		wm_allied_respawntime 20
		wm_set_round_timelimit 21
		
		wm_number_of_objectives 3

		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		3	0
		wm_set_main_objective		3	1

		// Objective overview status indicators
		//wm_objective_status <objective> <team (0=Axis, 1=Allies)> <status (0=neutral 1=complete 2=failed)>

		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
	
		// axis is the default winner	
		wm_setwinner 0

		// zero bars collected at any level
		accum 1 set 0
		accum 2 set 0
		accum 3 set 0
	
		wait 2000

		setautospawn "allied spawn" 1
		setautospawn "axis spawn" 0
			
		// on each level we play a little tune
		enablespeaker level1sound
	}

// -----------------------------------------------------------------------
// ------  LEVEL 1

	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 Bar!"
	}

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

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

	trigger allies_win
	{
		wm_announce "^8Allied forces has built the ladder to the second level!"
		wm_announce "^8Allied forces has built the ladder to the second level!"
		wm_announce "^8Allied forces has built the ladder to the second level!"
		trigger ladder_script construct
		trigger barrier_axis2 remove
		trigger barrier_allied2 remove
		disablespeaker level1sound
		wait 2000
		enablespeaker level2sound
		wm_objective_status 1 0 2 
		wm_objective_status 1 1 1
	}

// -----------------------------------------------------------------------
// ------  LEVEL 2

	trigger add_allies2_goldbar
	{
		accum 2 inc 1

		trigger game_manager allies2_secured

		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"

		trigger gold_allies2_full_1 show
		trigger gold_allies2_trans_1 hide

		accum 2 abort_if_less_than 2

		trigger gold_allies2_full_2 show
		trigger gold_allies2_trans_2 hide

		accum 2 abort_if_less_than 3
	
		trigger gold_allies2_full_3 show
		trigger gold_allies2_trans_3 hide

		trigger game_manager allies2_win					
	}

	trigger allies2_secured
	{
		accum 2 trigger_if_equal 1 game_manager allies2_secured1
		accum 2 trigger_if_equal 2 game_manager allies2_secured2
		accum 2 trigger_if_equal 3 game_manager allies2_secured3	
	}

	trigger allies2_secured1
	{
		wm_announce "Allied team has secured the first Gold Bar!"
	}

	trigger allies2_secured2
	{
		wm_announce "Allied team has secured the second Gold Bar!"
	}

	trigger allies2_secured3
	{
		wm_announce "Allied team has secured the last Gold Bar!"
	}

	trigger allies2_win
	{
		wm_announce "^8Allied forces has built the ladder to the third level!"
		wm_announce "^8Allied forces has built the ladder to the third level!"
		wm_announce "^8Allied forces has built the ladder to the third level!"
		trigger ladder_script2 construct
		trigger barrier_axis3 remove
		trigger barrier_allied3 remove
		disablespeaker level2sound
		wait 2000
		enablespeaker level3sound
		wm_objective_status 2 0 2 
		wm_objective_status 2 1 1
	}

// -----------------------------------------------------------------------
// ------  LEVEL 3

	trigger add_allies3_goldbar
	{
		accum 3 inc 1

		trigger game_manager allies3_secured

		wm_teamvoiceannounce 0 "axis_hq_objective_captured"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"

		trigger gold_allies3_full_1 show
		trigger gold_allies3_trans_1 hide

		accum 3 abort_if_less_than 2

		trigger gold_allies3_full_2 show
		trigger gold_allies3_trans_2 hide

		accum 3 abort_if_less_than 3
	
		trigger gold_allies3_full_3 show
		trigger gold_allies3_trans_3 hide

		trigger game_manager allies3_win				
	}

	trigger allies3_secured
	{
		accum 2 trigger_if_equal 1 game_manager allies3_secured1
		accum 2 trigger_if_equal 2 game_manager allies3_secured2
		accum 2 trigger_if_equal 3 game_manager allies3_secured3	
	}

	trigger allies3_secured1
	{
		wm_announce "Allied team has secured the first Gold Bar!"
		trigger ladder_script3 construct
	}

	trigger allies3_secured2
	{
		wm_announce "Allied team has secured the second Gold Bar!"
	}

	trigger allies3_secured3
	{
		wm_announce "Allied team has secured the last Gold Bar!"
	}

	trigger allies3_win
	{
		wm_objective_status 2 0 2 
		wm_objective_status 2 1 1

		wm_announce "^8Allied forces has stolen all the gold!"
		wm_announce "^8Allied forces has stolen all the gold!"
		wm_announce "^8Allied forces has stolen all the gold!"
		wm_setwinner 1
		wait 2000
		wm_endround
	}
	
}

// -----------------------------------------------------------------
// fix the rotation on the teleporter orbs

orb_axis1
{
	spawn
	{
		wait 400
		trigger orb_axis1 movem
	}
	trigger movem
	{
		setrotation -155 -55 -55
		wait 1
		trigger	orb_axis1 movem
	}
}
orb_axis2
{
	spawn
	{
		wait 450
		trigger orb_axis2 movem
	}
	trigger movem
	{
		setrotation -255 -55 -55
		wait 1
		trigger	orb_axis2 movem
	}
}
orb_axis3
{
	spawn
	{
		wait 500
		trigger orb_axis3 movem
	}
	trigger movem
	{
		setrotation -355 -55 -55
		wait 1
		trigger	orb_axis3 movem
	}
}

orb_allies1
{
	spawn
	{
		wait 400
		trigger orb_allies1 movem
	}
	trigger movem
	{
		setrotation 155 55 55
		wait 1
		trigger	orb_allies1 movem
	}
}
orb_allies2
{
	spawn
	{
		wait 450
		trigger orb_allies2 movem
	}
	trigger movem
	{
		setrotation 255 55 55
		wait 1
		trigger	orb_allies2 movem
	}
}
orb_allies3
{
	spawn
	{
		wait 500
		trigger orb_allies3 movem
	}
	trigger movem
	{
		setrotation 355 55 55
		wait 1
		trigger	orb_allies3 movem
	}
}



// -----------------------------------------------------------------------
// ------  LEVEL 1 

ladder_script
{
	spawn
	{
		wait 200
		trigger self startup
	}
	
	trigger construct
	{
		setstate ladder_target default
	}

	trigger startup
	{
		setstate ladder_target 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
	}
}

allied_gold_flag
{
	death
	{
		trigger game_manager add_allies_goldbar
	}
}

axis_gold_crate
{
	spawn
	{
	}

	trigger stolen
	{
		setstate axis_gold_crate invisible
	}

	trigger secured
	{
		setstate axis_gold_crate default
	}

	trigger returned
	{
	}
}

// -----------------------------------------------------------------------
// ------  LEVEL 2

barrier_allied2
{
	spawn
	{
		wait 200
		trigger self startup
	}
	
	trigger remove
	{
		setstate barrier_allied_target2 invisible
	}

	trigger startup
	{
		setstate barrier_allied_target2 default
	}
}


barrier_axis2
{
	spawn
	{
		wait 200
		trigger self startup
	}
	
	trigger remove
	{
		setstate barrier_axis_target2 invisible
	}

	trigger startup
	{
		setstate barrier_axis_target2 default
	}
}

ladder_script2
{
	spawn
	{
		wait 200
		trigger self startup
	}
	
	trigger construct
	{
		setstate ladder_target2 default
	}

	trigger startup
	{
		setstate ladder_target2 invisible
	}
}

gold_allies2_full_1
{
	spawn
	{
		setstate gold_allies2_full_1 invisible
	}

	trigger show
	{
		setstate gold_allies2_full_1 default
	}
}

gold_allies2_full_2
{
	spawn
	{
		setstate gold_allies2_full_2 invisible
	}

	trigger show
	{
		setstate gold_allies2_full_2 default
	}
}

gold_allies2_full_3
{
	spawn
	{
		setstate gold_allies2_full_3 invisible
	}

	trigger show
	{
		setstate gold_allies2_full_3 default
	}
}

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

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

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

allied2_gold_flag
{
	death
	{
		trigger game_manager add_allies2_goldbar
	}
}

axis2_gold_crate1
{
	spawn
	{
	}

	trigger stolen
	{
		setstate axis2_gold_crate invisible
	}

	trigger secured
	{
		setstate axis2_gold_crate default
	}

	trigger returned
	{
	}
}

axis2_gold_crate2
{
	spawn
	{
	}

	trigger stolen
	{
		setstate axis2_gold_crate invisible
	}

	trigger secured
	{
		setstate axis2_gold_crate default
	}

	trigger returned
	{
	}
}

axis2_gold_crate3
{
	spawn
	{
	}

	trigger stolen
	{
		setstate axis2_gold_crate invisible
	}

	trigger secured
	{
		setstate axis2_gold_crate default
	}

	trigger returned
	{
	}
}

// -----------------------------------------------------------------------
// ------  LEVEL 3

ladder_script3
{
	spawn
	{
		wait 200
		trigger self startup
	}
	
	trigger construct
	{
		setstate ladder_target3 default
	}

	trigger startup
	{
		setstate ladder_target3 invisible
	}
}

barrier_allied3
{
	spawn
	{
		wait 200
		trigger self startup
	}

	trigger remove
	{
		setstate barrier_allied_target3 invisible
	}

	trigger startup
	{
		setstate barrier_allied_target3 default
	}
	
}

barrier_axis3
{
	spawn
	{
		wait 200
		trigger self startup
	}

	trigger remove
	{
		setstate barrier_axis_target3 invisible
	}

	trigger startup
	{
		setstate barrier_axis_target3 default
	}
	
}

gold_allies3_full_1
{
	spawn
	{
		setstate gold_allies3_full_1 invisible
	}

	trigger show
	{
		setstate gold_allies3_full_1 default
	}
}

gold_allies3_full_2
{
	spawn
	{
		setstate gold_allies3_full_2 invisible
	}

	trigger show
	{
		setstate gold_allies3_full_2 default
	}
}

gold_allies3_full_3
{
	spawn
	{
		setstate gold_allies3_full_3 invisible
	}

	trigger show
	{
		setstate gold_allies3_full_3 default
	}
}

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

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

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

allied3_gold_flag
{
	death
	{
		trigger game_manager add_allies3_goldbar
	}
}

axis3_gold_crate
{
	spawn
	{
	}

	trigger stolen
	{
		setstate axis3_gold_crate invisible
	}

	trigger secured
	{
		setstate axis3_gold_crate default
	}

	trigger returned
	{
	}
}


