// Town 19: Sacrifice Fields
begintownscript;

variables;

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

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	change_outdoor_location(0,6,47,26);
	
	if (get_flag(19,1) < 2) {
		change_blocked(27,34,1);
		change_blocked(27,35,1);
		change_blocked(27,36,1);
		change_blocked(27,37,1);
		change_blocked(27,38,1);
		change_blocked(28,34,1);
		change_blocked(29,34,1);
		change_blocked(29,35,1);
		change_blocked(29,36,1);
		change_blocked(29,37,1);
		change_blocked(29,38,1);
		}
	
	change_blocked(27,39,1);
	change_blocked(28,39,1);
	change_blocked(29,39,1);
	
	if ((get_flag(19,1) == 2) && (get_flag(19,2) == 0)) {
		activate_hidden_group(5);
		char_give_item(43,99);
		if (get_flag(19,3) == 0) {
			force_instant_terrain_redraw();
			reset_dialog();
			add_dialog_str(0,"You descend into the Sacrifice Fields again, determined to find out if there is an exit through here out of the Lava Ocean. When you reach the bottom of the stairs, you notice that you can hear the voice of your demon host from the west.",0);
			add_dialog_str(1,"He probably still doesn't realize that you've survived. He is speaking to a drone about an appropriate sacrifice. If he sees you, he will most likely not be happy.",0);
			add_dialog_str(2,"But then, he is also standing in the way of the one exit from the Sacrifice Fields.",0);
			set_flag(19,3,run_dialog(1));
			}
		set_terrain(7,41,453);
		set_terrain(6,41,453);
		set_terrain(5,41,453);
		set_terrain(4,41,453);
		set_terrain(3,41,453);
		set_terrain(2,41,453);
		set_terrain(1,41,453);
		}
	
	set_name(39,"Dalaghant");
	
if (get_flag(19,0) != 0)
	end();
	
	set_flag(19,0,1);
	
	force_view_center(32,15);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 2);
	
	activate_hidden_group(4);
	march_party(32,12);
	march_party(32,13);
	march_party(32,14);
	march_party(32,15);
	
	put_boom_on_char(6,2,0);
	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);
	run_animation_sound(51);
	
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	
	message_dialog("You appear in the middle of a sizable cave filled with vegetation. Undead vahnatai tend the growing fungus, and several herd packs of giant lizards. This must be a supply of food, but for whom? Neither undead nor demons eat.","");
	
	text_bubble_on_char(38,"These are the Sacrifice Fields.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"Here we grow food, feeding the lizards");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"whom we sacrifice to our God.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	relocate_character(38,31,19);
	set_character_facing(38,3);
	march_party(31,16);
	force_view_center(31,16);
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"The blood gives him strength,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,20);
	set_character_facing(38,4);
	march_party(31,17);
	force_view_center(31,17);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,21);
	march_party(31,18);
	force_view_center(31,18);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,22);
	march_party(31,19);
	force_view_center(31,19);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,23);
	march_party(31,20);
	force_view_center(31,20);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,24);
	march_party(31,21);
	force_view_center(31,21);
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"so that someday, he will break free");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,25);
	march_party(31,22);
	force_view_center(31,22);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,26);
	march_party(31,23);
	force_view_center(31,23);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,27);
	march_party(31,24);
	force_view_center(31,24);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,28);
	march_party(31,25);
	force_view_center(31,25);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,29);
	march_party(31,26);
	force_view_center(31,26);
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"from his terrible prison,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,30);
	march_party(31,27);
	force_view_center(31,27);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,31,31);
	march_party(31,28);
	force_view_center(31,28);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,30,32);
	set_character_facing(38,3);
	march_party(30,29);
	force_view_center(30,29);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,29,33);
	march_party(29,30);
	force_view_center(29,30);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,28,34);
	march_party(28,31);
	force_view_center(28,31);
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"but until then, we must keep the rites");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,28,35);
	set_character_facing(38,4);
	march_party(28,32);
	force_view_center(28,32);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,28,36);
	march_party(28,34);
	force_view_center(28,34);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,28,37);
	march_party(28,35);
	force_view_center(28,35);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(38,28,38);
	march_party(28,36);
	force_view_center(28,36);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	text_bubble_on_char(38,"");
	text_bubble_on_char(38,"and hold the faith.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	set_character_facing(38,0);
	text_bubble_on_char(38,"");
	force_instant_terrain_redraw();
	
	message_dialog("_The vahnatai here are mindless shells,_ he continues. _They are drones, no more. But there is one more thing that you must see._","He proceeds up the stairs, and you feel compelled to follow him.");
	
	erase_char(38);
	march_party(28,37);
	force_view_center(28,37);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	march_party(28,38);
	force_view_center(28,38);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(19,1) == 0) {
	set_flag(19,1,1);
	move_to_new_town(18,54,32);
	}
break;

beginstate 11;
	if (get_flag(19,1) == 0) {
		set_flag(19,1,1);
		move_to_new_town(18,54,32);
		}
	
	block_entry(1);	
	reset_dialog();
	add_dialog_str(0,"You have reached the stairs going up to the main level of the former laboratory. What do you do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Climb the stairs.");
	if (run_dialog(1) == 2)
		move_to_new_town(18,29,7);
break;

beginstate 12; // Dalaghant teleports out
	reset_dialog();
	add_dialog_str(0,"Bathed in flames, now, the demon king roars bitterly. _My magic is failing, but my vow will hold!_ He speaks a few sparse words of magic. _There! I have ordered my servants to seal off the tunnel out of here._",0);
	add_dialog_str(1,"Falling to his knees in agony, he continues, _You have defeated me, but you will not succeed here! The path is shut, and you cannot use it. Thus the curse of Dalaghant will haunt you!_ He speaks more words of magic, and rather than dying, he vanishes!",0);
	add_dialog_str(2,"You have no way of knowing what happened to him, nor can you know from this if his threats were empty. You must check the passage south if you are to return to the expedition with any certainty.",0);
	add_dialog_str(3,"But you can be sure of this: you have made a powerful enemy here.",0);
	set_flag(19,2,run_dialog(1));
	erase_char(39);
	set_terrain(7,41,0);
	set_terrain(6,41,0);
	set_terrain(5,41,0);
	set_terrain(4,41,0);
	set_terrain(3,41,0);
	set_terrain(2,41,0);
	set_terrain(1,41,0);
	put_boom_on_space(7,41,1,0);
	put_boom_on_space(6,41,1,0);
	put_boom_on_space(5,41,1,0);
	put_boom_on_space(4,41,1,0);
	put_boom_on_space(3,41,1,0);
	put_boom_on_space(2,41,1,0);
	put_boom_on_space(1,41,1,0);
	run_animation();
break;