// TOWN SCRIPT
//    Town 25: Iron Mines

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	set_name(6,"Scyld");
	set_name(7,"Scyld");
		set_state_continue(26);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate 10;
	if (get_flag(100,0) >= 15)
		set_state_continue(13);
	set_state_continue(11);
break;

beginstate 11;
	message_dialog("Fallen rubble has completely blocked off this passage.","");
	block_entry(1);
break;

beginstate 12;
	block_entry(1);
	reset_dialog_preset_options(5);
	choice = run_dialog(0);
	if (choice == 2) {
		move_to_new_town(26,24,6);
		end();
		}
break;

beginstate 13;
	print_str("You climb over the rubble.");
break;

beginstate 14;
	if (get_flag(100,0) >= 15)
		set_state_continue(19);
break;

beginstate 16;
	if (get_flag(100,0) >= 17)
	message_dialog("_Go now. We have cleared a path to the roots of the mountains, from the northwest of these mines. We will follow you._","");
	set_flag(100,0,16);
break;

beginstate 19;
	if (get_flag(100,0) >= 17)
		set_state_continue(20);
	activate_hidden_group(1);
break;

beginstate 20;
	activate_hidden_group(2);
	set_terrain(23,30,0);
	set_floor(22,29,80);
	set_floor(23,29,80);
	set_floor(24,29,80);
break;

beginstate 21;
	if (get_flag(100,0) >= 17)
		set_state_continue(23);
	set_state_continue(22);
break;

beginstate 22;
	if (get_flag(25,4) == 250)
		end();
	message_dialog("A dark, deep pit opens here. Must be an aspect of mining.","");
	set_flag(25,4,250);
break;

beginstate 23;
	reset_dialog();
	add_dialog_str(0,"A deep pit opens here. It looks awfully deep. From far below comes an unearthly glow.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Step In.");
	choice = run_dialog(1);
	if (choice == 2) {
		message_dialog("There is a nervous moment as you step over the opening. You drop. As you reach ever accelerating speeds, you begin to rethink your decision to step in.",
	  "Then you hit earth. Unharmed.");
		block_entry(1);
		move_to_new_town(26,24,6);
		end();
	}	
break;

beginstate 26;
	if (has_special_item(4) > 0)
		set_state_continue(27);
	set_state_continue(14);
break;

beginstate 27;
	set_flag(100,0,17);
	set_state_continue(14);
break;

beginstate 28;
	message_dialog("Something tells you that this isn't the right way to go.","");
	block_entry(1);
break;

