// Town 16: Lava Lizard Cave
begintownscript;

variables;

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

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	change_outdoor_location(0,5,6,40);
	set_flag(17,2,0);
	
	set_name(8,"Danren-Bok");
	set_char_dialogue_pic(8,1941,0);
	if (char_ok(8) == 0)
		activate_hidden_group(2);
	set_name(38,"Danren-Bok");
	set_char_dialogue_pic(38,1941,0);
	add_range_to_group(21,25,1);
	add_range_to_group(16,20,2);
	add_range_to_group(26,30,3);
	
	if (get_flag(14,1) == 1) {
		set_terrain(5,10,0);
		if (get_flag(17,0) == 0) {
			activate_hidden_group(1);
			set_name(6,"Talas"); // type 112
			set_char_dialogue_pic(6,582,0);
			}
		}
	
	if (get_flag(16,0) == 0) {
		force_instant_terrain_redraw();
		message_dialog("In this strange cave, you can hear the growling of monsters. It sounds like reptiles, but it is hard to tell for sure.","You think that you can feel the tinge of powerful magic to the southwest, but you cannot identify its source.");
		set_flag(16,0,1);
		}
		
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	message_dialog("You strike the last, devastating blow against the naga. It emits a terrible psycho-audio death shriek, blasting your ears and your mind with its fury.","Once the death cry has passed, you look around. You doubt that any other creatures who were anywhere near that scream will stay around for very long. You've cleared the way through this part of the cave. Now to take a look at that control panel.");
	set_flag(16,2,1);
	clear_town();
	activate_hidden_group(2);
break;

beginstate 11;
	if (get_flag(16,2) == 0) {
		message_dialog("You bump into the control panel. It looks very interesting and potentially useful, but the naga is still around, and you can't look at it carefully while you're in this kind of danger.","");
		end();
		}
	if (get_flag(14,1) == 0) {
		reset_dialog();
		add_dialog_str(0,"With the naga dead, you take a long, careful look at the control panel. You can see a few ancient slith words written here, proof that the sliths once came through this way. They were probably the ones who set up the rock paths between the islands.",0);
		add_dialog_str(1,"There must be some appropriate combination of buttons to press and switches to pull in order to open a path in this wall, and this wall must lead out of the ocean of lava. However, you have no idea what any of the buttons or switches do.",0);
		add_dialog_str(2,"You have a strong hunch that an engineer would know exactly what to do here, but your mechanical knowledge isn't enough. Talas would be able to figure it out, though.",0);
		if (get_flag(14,0) == 1)
			add_dialog_str(3,"You have scouted as much as you can. The expedition can come this way and rest on the island while Talas comes here and opens the path. Then everyone can proceed out of here. You should go back to Thassaka and tell them what you have found.",0);
		else
			add_dialog_str(3,"But while Talas clears this blocked way, the expedition needs to stop somewhere. If you could only find an island that seemed hospitable enough to host the expedition for a time, you could tell Pithoss that you have scouted enough, but you haven't yet.",0);
		set_flag(16,1,run_dialog(1));
		}
	else
		message_dialog("You have absolutely no idea what Talas did, as the configuration of buttons and switches is still seemingly random, but somehow he figured it out.","For not the first time, you marvel at the resourcefulness of the members of the expedition.");
break;

beginstate 12;
if (char_ok(8) == 0)
	end();
if (get_flag(16,3) == 0) {
	set_flag(16,3,1);
	message_dialog("As you enter this room, your breath catches in your throat. Before you are several more of the blue crystal pillars that you've seen before, but there is also something much more significant: a crystal soul!","These are vahnatai life-forms. No other known race can become them. This proves without a doubt that the vahnatai have interacted with the sliths of the homeland, perhaps even very recently. Perhaps this crystal soul can give you some answers, finally!");
	}
break;

beginstate 14;
	reset_dialog_preset_options(9);
	if (run_dialog(1) == 2)
		move_to_new_town(17,46,43);
break;

beginstate 15;
	message_dialog("Like the control panel on the other side of the wall, this control panel is completely inexplicable to you. It has a wide variety of buttons and switches, and you have no idea what any of it does.","");
break;

beginstate 16;
if (get_flag(16,6) == 0) {
	set_flag(16,6,1);
	message_dialog("The room beyond the wall is very messy. It's hard to tell what was going on here, but the machinery looks damaged, the remnants of several hostile spells from a very long time ago still sit here, and the crystals still glow with a dim half-light.","");
	}
break;

beginstate 17;
	set_flag(16,8,1);
break;

beginstate 18;
	message_dialog("You have committed a terrible crime against the expedition! When this member fails to return from his mission, your dark deed will surely be found out. You may find yourself unwelcome back at camp.","");
	set_flag(290,7,1);
break;