// Town 52: Temple of Sothana
begintownscript;

variables;

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

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	set_name(6,"Zasthen");
	set_name(12,"Iakhthoss");
	set_name(13,"Shethoss");
	set_name(14,"Sasha");
	set_name(15,"Veinor");
	set_name(16,"Thena");
	
	if (get_flag(52,11) != 0)
		set_terrain(5,20,284);
	
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	if ((char_loc_y(i) > 17) && (char_loc_y(i) < 23))
		if (get_flag(52,11) == 0) {
			set_terrain(5,20,284);
			force_instant_terrain_redraw();
			message_dialog("You climb up the ladder and discover that it leads to the burial area of the temple. Might Zektoth have been planning to raise an army of undead by desecrating the graves of these sliths? It is not unlikely.","You emerge through a trapdoor that you had not noticed before.");
			set_flag(52,11,1);
			}
	
	if (get_flag(52,0) == 0) {
		set_flag(52,0,1);
		message_dialog("When you approach this small crack in the wall, you notice that it widens considerably just beyond. You notice that the signs say, _Sothana,_ the name of the ancient goddess Sothana, slith goddess of wisdom.","This place is set so far back from the river that it may still be intact, despite the attacks of barbarians on everything else nearby.");
		}
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	if (get_flag(52,1) == 0) {
		force_instant_terrain_redraw();
		set_flag(52,1,1);
		message_dialog("This place is indeed still intact. You can see a number of sliths around, homeland sliths conducting their worship of their goddess as they must have done for ages, unaffected by the changing times.","Well, that's not quite right. Everyone here seems a bit on edge, and not just because you are strange outsiders. Something is wrong here, although it is not immediately evident what.");
		}
break;

beginstate 11;
if (get_flag(52,2) == 0) {
	reset_dialog();
	add_dialog_str(0,"On the pedestal in front of you is a mind crystal. Mind crystals are vahnatai inventions. They instantly train their user in a skill. Which skill varies from crystal to crystal.",0);
	add_dialog_str(1,"Staring into strange mind crystals can be dangerous: they can carry curses or other terrible effects. However, they can also have great spells recorded within.",0);
	add_dialog_str(2,"What do you do?",0);
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Attempt to use it.");
	if (run_dialog(1) == 2) {
		reset_dialog();
		add_dialog_str(0,"As you stare deep into the Mind Crystal, you start to hear strange, whispering voices in your mind. The words are barely audible, but they seem to be trying to teach you something.",0);
		// Requires Arcane Lore of 25.
		if (get_skill_total(42) >= 25) {
			add_dialog_str(1,"The voices speak in a strange, ancient tongue, but fortunately, due to your knowledge of Arcane Lore, you can understand it. You concentrate, and you start to get an impression of what ability the item is trying to teach you.",0);
			// Requires some skill in the spell already.
			if (get_flag(292,1) > 0) {
				set_flag(52,2,1);
				add_dialog_str(2,"They are describing how to cast Bind Foe in the most efficient fashion possible. You listen to their instructions carefully.",0);
				set_flag(292,1,3); // flag for spell
				}
			else
				add_dialog_str(1,"They are describing how to cast a complex spell, Bind Foe, in a very efficient manner. Unfortunately, you are completely unfamiliar with the spell, so the description is too hard for you to understand.",0);
			run_dialog(1);
			}
		else
			message_dialog("The voices speak in a strange, ancient tongue, and unfortunately, you can't understand it. Perhaps if you knew more about Arcane Lore, you would be able to.","");
		}
	}
else
	message_dialog("You approach the mind crystal, but now it is completely silent. You have learned all that you can from it.","");
break;

beginstate 12;
	reset_dialog_preset_options(9);
	if (run_dialog(1) == 1)
		block_entry(1);
	else
		move_to_new_town(53,6,5);
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"There is a small, simple pool of purple water here. What do you do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Drink some.");
	add_dialog_choice(2,"Wash yourself.");
	choice = run_dialog(1);
	if (choice == 2)
		message_dialog("The water tastes bitter. You can't tell if anything happens, though.","");
	if (choice == 3) {
		if (get_flag(52,4) == 1) {
			set_flag(52,4,2);
			message_dialog("The water is cold and soothing. You can't tell if anything happens, though.","Zasthen nodds approvingly. _Now cross the fire,_ he says.");
			}
		else
			message_dialog("The water is cold and soothing. You can't tell if anything happens, though.","");
		}
break;

beginstate 14;
if (get_flag(52,4) == 2)
	set_flag(52,4,3);
break;

beginstate 15;
if (get_flag(52,4) == 3)
	set_flag(52,4,4);
break;

beginstate 16;
if (get_flag(52,4) == 4) {
	set_flag(52,4,5);
	message_dialog("_Good!_ Zasthen says. _Now wash yourself in the water over there!_","");
	}
break;

beginstate 17;
	reset_dialog();
	add_dialog_str(0,"There is a small, simple pool of light blue water here. What do you do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Drink some.");
	add_dialog_choice(2,"Wash yourself.");
	choice = run_dialog(1);
	if (choice == 2)
		message_dialog("The water tastes bitter. You can't tell if anything happens, though.","");
	if (choice == 3) {
		if (get_flag(52,4) == 5) {
			set_flag(52,4,6);
			message_dialog("The water is cold and soothing. You can't tell if anything happens, though.","Zasthen nodds approvingly. _Now kneel at the mat before the altar to the south and worship,_ he says.");
			}
		else
			message_dialog("The water is cold and soothing. You can't tell if anything happens, though.","");
		}
break;

beginstate 18;
	reset_dialog();
	add_dialog_str(0,"There is a small, simple altar to the goddess Sothana here. What do you do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Pray.");
	if (run_dialog(1) == 2) {
		if (get_flag(52,4) == 6) {
			message_dialog("You offer up a simple prayer to the slith goddess Sothana. Nothing happens as far as you can tell, but you do feel good about yourself.","Zasthen applauds when you are finished. _Sothana smiles upon you,_ he says, _and I have a reward for you. Return and speak to me._");
			set_flag(52,4,7);
			}
		else
			message_dialog("You offer up a simple prayer to the slith goddess Sothana. Nothing happens as far as you can tell, but you do feel good about yourself.","");
		}
break;

beginstate 19;
	if (get_flag(52,5) == 0) {
		reset_dialog();
		add_dialog_str(0,"You enter this large building, and the first room that you find is a feast hall. This is where everyone eats and drinks every day. You notice that these sliths eat only vegetables, as far as you can tell.",0);
		add_dialog_str(1,"There is hushed chatter among the people at the tables. You can make out very little of it, but one phrase -- _He's crazy!_ -- comes out a little louder than the others. Everyone shifts uncomfortably, and the speaker becomes instantly silent.",0);
		add_dialog_str(2,"It isn't immediately obvious what, but something is making these people very uncomfortable.",0);
		set_flag(52,5,run_dialog(1));
		}
break;

beginstate 20;
	reset_dialog();
	add_dialog_str(0,"On this pedestal, there is a faded and rotten book. A very small bit of the writing is still legible, and you read it. The language is unfathomably ancient, older than the Khalthanad. It picks up in the middle of a paragraph.",0);
	add_dialog_str(1,"_But we must go into Resting soon, and we are not sure that the temple will be done before we sleep. We have told the sliths how to maintain the temple, but I am not sure that they understand. They are such foolish creatures, fit for servile tasks only.",0);
	add_dialog_str(2,"_Nevertheless, we have little choice. We can only hope that the thing is still intact when we wake. Sothana willing, it may be.",0);
	add_dialog_str(3,"_I have overheard a thing that troubles me. There is a cult among the workers here of a goddess of whom I have never heard. They call her, 'Hathnazriakh.' I asked one of them about it, and he refused to answer, even after he was whipped._",0);
	add_dialog_str(4,"Very strange. Someone here might be interested to know about this.",0);
	set_flag(52,7,run_dialog(1));
	if (get_flag(53,3))
		message_dialog("Very peculiar. Zektoth's record book downstairs also mentioned some activity of the goddess Hathnazriakh here. This cannot merely be coincidence.","");
break;

beginstate 21;
	if (get_flag(52,9) == 0) {
		set_flag(52,9,1);
		message_dialog("You enter Zektoth's room, and you can see nothing obviously amiss. There is a small trapdoor in the corner, though.","");
		}
break;

beginstate 22;
	if (get_terrain(5,20) == 284) {
		reset_dialog_preset_options(9);
		if (run_dialog(1) == 2)
			move_to_new_town(53,7,20);
		}
break;

beginstate 23;
if (get_flag(52,13) == 0) {
	message_dialog("Strange. One of the houses here looks different from the others. It looks much, much older, with a strange architecture.","Perhaps someone around here knows something about it.");
	set_flag(52,13,1);
	}
break;