--Starbuck takes on all eight level - v0 (05/17/2006)

GUID = 
	{ 110, 91, 157, 190, 18, 23, 250, 78, 144, 20, 41, 246, 181, 128, 214, 12, }
GameRulesName = "Starbuck takes on all eight"
Directories =
{
    Levels = "data:LevelData\\Multiplayer\\StarbuckTakesOnAllEight\\",
}
Description = "Starbuck takes on all eight"
GameSetupOptions = 
	{ 
	{ 
		name = "resources", 
		locName = "$3240", 
		tooltip = "This setting affects resource yield of asteroids. (Low = 0.5x, Standard = 1.0x, High = 2.0x)", 
		default = 1, 
		visible = 0, 
		choices = 
			{ "$3241", "0.5", "$3242", "1.0", "$3243", "2.0", }, }, 
	{ 
		name = "unitcaps", 
		locName = "$3214", 
		tooltip = "$3234", 
		default = 0, 
		visible = 0, 
		choices = 
			{ "$3215", "Normal", }, }, 
	{ 
		name = "resstart", 
		locName = "$3205", 
		tooltip = "Select starting RU levels. Starting off with some RUs in the supply chain is proper for a prepared engagement.", 
		default = 0, 
		visible = 0, 
		choices = 
			{ "$3209", "3000", }, }, 
	{ 
		name = "lockteams", 
		locName = "$3220", 
		tooltip = "$3235", 
		default = 0, 
		visible = 0, 
		choices = 
			{ "$3221", "yes", "$3222", "no", }, }, 
	{ 
		name = "startlocation", 
		locName = "$3225", 
		tooltip = "Lock starting locations: As PDS is meant as a wargame and not a free-for-all, Fixed is recommended for pseudo-scenario-based gameplay.", 
		default = 1, 
		visible = 0, 
		choices = 
			{ "$3226", "random", "$3227", "fixed", }, }, 
	}

function OnInit()
	ATI_LoadTemplates("data:LevelData\\ATI.lua")
	SobGroup_Create("sg_Survivors")
	Player_SetDefaultShipTactic(0, AggressiveTactics)
	Player_SetDefaultShipTactic(1, AggressiveTactics)
	Rule_AddInterval("Rule_Briefing", 8)
	Camera_SetLetterboxStateNoUI(1, 2)
end

function Rule_Briefing()
	Subtitle_Add(Actor_FleetIntel, "Get back to the barn, nuggets!", 5)
	iCountdown = 224
	iContact = 5
	Rule_AddInterval("Rule_Contact", 1)
	Rule_Remove("Rule_Briefing")
end

function StartPlay()
	Camera_SetLetterboxStateNoUI(0, 2)
        Rule_AddInterval("Rule_StarbuckWins", 5)
	Rule_AddInterval("Rule_Reinforce", 1)
	Rule_AddInterval("Rule_WatchGalactica", 1)
	CPU_Enable(1, 0)
	local tVol1 = randomVector(90, 20, 0, 20, 3000)
	Volume_AddSphere("vol_Cylon1", {tVol1[1], tVol1[2], tVol1[3],}, 2000)
	SobGroup_ExitHyperSpace("sg_Cylon_1", "vol_Cylon1")
	SobGroup_AttackPlayer("sg_Cylon_1", 0)
	local tVol2 = tVol1
--	local tVol2 = randomVector(0, 360, 0, 360, 7000)
	Volume_AddSphere("vol_Cylon1", {tVol2[1], tVol2[2], tVol2[3],}, 2000)
end

function Rule_Contact()
	iContact = iContact - 1
	if iContact > 0  then
--		local m = floor(iContact/60)
--		local s = iContact - m*60
--		local message = format("%02d:%02d", m, s)
--		local rect = {0.49, 0.2, 0, 0}
--		Display_Message(message, rect)
	else
		StartPlay()
		Rule_Remove("Rule_Contact")
	end
end

function Rule_StarbuckWins()
	if ( SobGroup_Empty("sg_Cylon_1") == 1 ) then
	        Subtitle_Add(Actor_FleetIntel, "Eight Fraking Cylons!", 5)
		Rule_AddInterval("Rule_End", 5)	
		Rule_Remove("Rule_StarbuckWins")
	end
end
	

function Rule_Reinforce()
	iCountdown = iCountdown - 1
	if iCountdown > 0 then
		local m = floor(iCountdown/60)
		local s = iCountdown - m*60
		local message = format("REMAINING TIME: %02d:%02d", m, s)
		local rect = {0.41, 0.18, 0, 0}
		Display_Message(message, rect)
		LocationCard(message, 3)
	else 
		Rule_AddInterval("Rule_Reinforcement", 5)
		Rule_Remove("Rule_Reinforce")
	end
end

function Rule_Reinforcement()
	SobGroup_EnterHyperSpaceOffMap("Player_Ships0")
	Camera_SetLetterboxStateNoUI(1, 2)
	LocationCard("You've been reinforced!", 4)
	Rule_AddInterval("Rule_End", 2)
	Rule_Remove("Rule_Reinforcement")
end

function Rule_WatchGalactica()
	if SobGroup_Empty("sg_Galactica") == 1 then
		Rule_Remove("Rule_Reinforce")
		local rect = {0.41, 0.18, 0, 0}
		Display_Message(" ", rect)
		Rule_AddInterval("Rule_End", 5)
	end
end

function Rule_End()
	Player_Kill(0)
	setGameOver()
	Rule_Remove("Rule_End")
end


function randomVector(azimuth, azimuth_var, site, site_var, length)
	local li_si = (site - site_var) + random(site_var*2)
	local li_az = (azimuth - azimuth_var) + random(azimuth_var*2)
	local t_vector = {}
	t_vector[1] = floor(length * cos(li_si) * cos(li_az))
	t_vector[3] = floor(length * cos(li_si) * sin(li_az))
	t_vector[2] = floor(length * sin(li_si))
	return t_vector
end

function Display_Message(message, rect)
	ATI_Clear()
	ATI_CreateParameters(1)
	ATI_AddString(0, message)
	ATI_Display2D("Message", rect, 0)
end
