add_portrait("Moravator Captain", "captain.png", 0);
add_portrait("Admiral Vadas", "admiral_vadas.png", 0);
add_portrait("Artilian Admiral", "windstille_sophie.png", 1);

cut_scene_on();
wait(30);

set_portrait("Moravator Captain");
portrait_text("There it is, Telephus Prime! Most of its land covered in one huge city.", "there_it_is.ogg");
wait_for_portrait();

set_portrait("Admiral Vadas");
portrait_text("Indeed, Captain. Victory is close.", "indeed.ogg");
wait_for_portrait();

set_viewpoint(23169, 18671);
set_portrait("Moravator Captain");
portrait_text("But first we will have to get past the huge fleet that is undoubtedly guarding the planet...", "but_first.ogg");
wait_for_portrait();

set_portrait("Admiral Vadas");
portrait_text("Quite. Man battlestations.", "quite.ogg");
wait_for_portrait();

cut_scene_off();

set_portrait("Artilian Admiral");
portrait_text("I cannot believe the audacity of this! Destroy all Morellian ships.", "i_cannot.ogg");
wait_for_portrait();

while (true) {
	wait(-1);
	local wakeup_reason = wakeup_reason();	
	if (wakeup_reason == "custom_ai_task_0")
		player_failed_mission("At least two capital ships must\nsurvive in order to invade Telephus Prime");
	else
		break;
}

set_portrait("Moravator Captain");
portrait_text("Fantastic! The final battle is won! The war is all but over!", "test.ogg");
wait_for_portrait();

set_portrait("Admiral Vadas");
portrait_text("Yes, we need now only to invade Telephus Prime itself. All capital ships, move into range for planetary bombardment", "test.ogg");

while (true) {
	wait_for_task("custom_ai_task_1", 900);
	if (wakeup_reason() == "custom_ai_task_1")
		break;
	portrait_text("Repeat, all capital ships, move into range for planetary bombardment", "test.ogg");
}

cut_scene_on();
foreach(squad in my_squads) {
	type = squad.get_type();
	if (type == 2 || type == 3)
		squad.select();
}
order_halt();

wait(60);

portrait_text("Initiate planetary bombardment.", "test.ogg");
wait_for_portrait();

planetary_bombardment_anim();
wait(310);
end_anim();

portrait_text("Their ground forces are decimated. Begin landing our troops.", "test.ogg");
wait_for_portrait();

planetary_invasion_anim();
wait(220);
mission_complete();

set_portrait("Moravator Captain");
portrait_text("And so another chapter in history comes to a close.", "test.ogg");
wait_for_portrait();

wait(150);
end_mission();

