// Town 46: Small Cave
begintownscript;

variables;

short choice,i,j,k;
string dlgstr;

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	if (get_flag(46,0) == 0) {
		set_flag(46,0,1);
		force_instant_terrain_redraw();
		message_dialog("This cave is eerily silent and still. There is nothing in it but a shimmering portal, the entrance to the hellish realms of the damned. If what you've been told is true, if you enter this portal, you will not be able to get out the same way.","The sign on the wall is very simple. It says: _Thaanithathoi pefeirithakoi._ That is, the condemned dead.");
		}
		
	if (get_flag(51,1) == 0)
		end();
	if (get_flag(46,1) == 1)
		end();
	
	set_flag(46,1,1);
	
	activate_hidden_group(1);
	march_party(19,18);
	march_party(19,17);
	march_party(19,16);
	march_party(19,15);
	march_party(19,14);
	put_boom_on_char(0,2,0);
	put_boom_on_char(1,2,0);
	put_boom_on_char(2,2,0);
	put_boom_on_char(3,2,0);
	put_boom_on_char(4,2,0);
	put_boom_on_char(6,2,0);
	run_animation_sound(10);
	
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	
	message_dialog("You are suddenly back at the entrance to the realms of the damned! Legare looks around, and, recognizing where he is, he turns back to you.","_Thank you,_ he says. _This rescue is much appreciated. Nathaganth was... not a gracious host._");
	
	text_bubble_on_char(6,"Now I can go to the heavenly realms,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"where I belong.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	set_character_facing(6,6);
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 2);
	
	text_bubble_on_char(i,"Wait!");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 4);
	
	set_character_facing(6,2);
	text_bubble_on_char(i,"");
	text_bubble_on_char(6,"Yes?");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 4);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(i,"We seek guidance,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(i,"");
	text_bubble_on_char(i,"some answers about what to do.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(i,"");
	text_bubble_on_char(i,"What would you have done,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(i,"");
	text_bubble_on_char(i,"if you had lived?");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(i,"");
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"Legare considers for a long moment before he answers. _If I had lived, I think I would have finished the journey to the homeland, and then... and then I would have gone home.",0);
	add_dialog_str(1,"_Yes, I am sure of it. I have found an answer of sorts on this journey. All my life, I was seeking a home, wondering where I could truly belong. In Bahssikava, where I was raised, everyone was convinced that the place we belonged was the homeland.",0);
	add_dialog_str(2,"_But what is a homeland? I think that it is not, as Kass would have it, the very land itself, the place where our ancestors lived until they were cast out. If I were to see it today, it would be grand, but it would not be home. I did not live there.",0);
	add_dialog_str(3,"_Is it, as Ithik would have it, the culture and traditions of our ancestors? I think not. Ancient customs in the modern day may be fascinating, but they are not my own. I have not practiced them.",0);
	add_dialog_str(4,"_So what is home, then? It must be where we have come to live, either by our own design or that of the gods. That place, for me, was Avernum, although it was hard for me to accept it.",0);
	add_dialog_str(5,"_But I am sure of it, now. My home was Avernum. The expedition carries my body still; tell them to bury it not in the ancestral homeland, but in my homeland. Bury me in Avernum, in Bahssikava._ He pauses.",0);
	run_dialog(1);
	
	message_dialog("_See the homeland,_ he continues. _It is good to learn the ways of our ancestors. But there is no reason that we must forever follow them._","With that, he leaves, finally transcending to the realms of wisdom and light where he will live forever after.");
	
	erase_char(6);
	
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(51,1) == 0) {
	reset_dialog_preset_options(3);
	if (run_dialog(1) == 2)
		move_to_new_town(48,42,24);
	}
else
	message_dialog("This portal appears dead now. You cannot go through.","");
break;