//Townscript for town 2: level -2

begintownscript;

variables;
int choice;
short j,loc_x,loc_y;

body;

beginstate INIT_STATE;
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;

if (get_flag(2,7) == 1) {
		j = 0;

		while (j < 10) { // place fields and do it ten times a turn
			loc_x = get_ran(1,4,42);
			loc_y = get_ran(1,4,42);
			if (get_floor(loc_x,loc_y) != 255 && is_field_on_space(3,3,6) == 0) {
					put_field_on_space(loc_x,loc_y,4);
					}
			j = j + 1;
			}
		}

break;

beginstate 10;
	move_to_new_town(1,43,39);
break;

beginstate 11;
	move_to_new_town(1,39,16);
break;

beginstate 12;
reset_dialog();
add_dialog_str(0,"It's a bookshelf. It's not broken and contains scrolls. We need answers. The scrolls are readable. Not torn. Readable. Read them?",0);
add_dialog_choice(0,"Read them");
add_dialog_choice(1,"Leave them");
choice = run_dialog(1);

if (choice == 1) {
		reset_dialog();

		if (get_flag(1,9) == 1)
				add_dialog_str(0,"This seems to be a letter. A letter from John. John, the man from whom we found a letter earlier? We'll see.",0);

		if (get_flag(1,9) == 0)
				add_dialog_str(0,"This seems to be a letter. The letter is by some bloke called John. Wonder what he has to tell us...",0);

		add_dialog_str(1,"God Conrad, I hoped you'd come. You have no idea what's happening. We try to talk to it, but it doesn't want to. It keeps trapping people, trying to kill them. It's its mind, we think it has been damaged while we were doing tests on it.",20);
		add_dialog_str(2,"If you still decide to come, I left you this letter here so you know where I've gone too. I'm now at level -1, but I'll shortly go up to it at level 0. Please come quick, maybe you can help me out. You may then also tell me how's it going at level -4.",20);
		add_dialog_str(3,"Signed, John",20);
		add_dialog_str(4,"Conrad was working at level -4? We saw a body with a tag lying next to it with the name _Conrad_ on it. It may have been the same guy. Let's hope we are wrong, and that Conrad is still fitter, happier and more productive then the Conrad we saw.",0);
		choice = run_dialog(1);
		if (get_flag(2,9) == 0) {
				award_party_xp(25,20);
				set_flag(2,9,1);
				}
		set_flag(2,0,1);
		}
break;

beginstate 13;
	move_to_new_town(3,18,30);
break;

beginstate 14;
	move_to_new_town(3,19,13);
break;

beginstate 15;
	if (get_flag(2,1) == 0) {
			message_dialog("We stand at the entrance to some building. Walls seem to have collapsed, and it might not be safe to go in at all. We look at a gleaming plaque at our right and read it.","_Mine Utility Development_");
			set_flag(2,1,1);
			}
break;

beginstate 16;
	if (get_flag(2,2) == 0) {
			message_dialog("This room has been quite badly damaged. Machinery is standing along the walls of the room, although one of the expensive machines has been flattened by a boulder. Though everything is empty, there is a rack filled with scrolls.","");
			set_flag(2,2,1);
			}
break;

beginstate 17;
	if (get_flag(2,3) == 0) {
			message_dialog("_Hey. Guests can't go in there. Go away. I repeat, go away. The welcoming committee is looking for you. Tea and biscuits. Fitter and happier with tea and biscuits. Go back, or I'll have to kill you._","The welcoming committee. Kill us? It can't. I is nowhere and everywhere, these poor miners, knives out. We'll get HIM.");
			set_flag(2,3,1);
			}
break;

beginstate 18;
	if (get_flag(2,4) == 0) {
			message_dialog("These machines once were probably pleasantly humming. Now, they collect dust. Looking around, we spot a small tag on the wall. Reading it, it says _Databanks beta._ If these stuff contained any valuable information about HIM, it's gone now.","The machines consist of a great metallic base, with arms holding a crystal. Touching the crystal, we get teleported elsewhere: a big hall, with huge pillars holding up a cracked roof, a smallish room, with chairs, and a strange creature. Now we are back.");
			set_flag(2,4,1);
			}
break;

beginstate 19;
	message_dialog("This old, rusted control panel is out of order. It probably did something with the machines to our right, but pushing the buttons, nothing happens.","");
break;

beginstate 20;
	if (get_flag(2,5) == 0) {
			message_dialog("We walk through this small tunnel and emerge in a small cavernous chamber, only to see that our way is blocked. We'll have to find another way.","");
			set_flag(2,5,1);
			}
break;

beginstate 21;
	if (get_flag(2,6) == 0) {
			message_dialog("This seems to be a storage depot. Most crates and boxes are empty, though. The moment we go into the depot, we feel a slight tremble.","Stone sliding over stone, but for the rest nothing. We wait for some creepy howling, rocks flattening us, but nothing happens. Seems we got away with it okay. This time.");
			set_terrain(3,3,0);
			set_flag(2,6,1);
			}
break;

beginstate 22;
	if (get_flag(2,7) == 0) {
			message_dialog("We walk up to the door, but before we can open it, we hear that voice again: _No. You can't go there, because you are guests. Don't you have some message? Otherwise, just go to your quarters._","We look around and see nothing, the voice has gone away, so we turn our attention to the door. The voice comes back: _That area is prohibited for guests. I shall have to hurt you now._");
			set_flag(2,7,1);
			}
break;

beginstate 23;
	if (get_flag(2,7) == 0) {
			message_dialog("We walk up this cavernous path, but before we can walk through it, we hear that voice again: _No. You can't go there, because you are guests. Don't you have some message? Otherwise, just go to your quarters._","We look around and see nothing, the voice has gone away, so we turn our attention to the path. The voice comes back: _That area is prohibited for guests. I shall have to hurt you now._");
			set_flag(2,7,1);
			}
break;

beginstate 24;
	if (get_flag(2,8) == 0) {
			message_dialog("We enter a storage depot. A random pick or torch is still to be found, but any food or stuff is gone. We might find anything useful still, but it seems we are doomed.","Knives out cause we are doomed.");
			set_flag(2,8,1);
			}
break;