// TOWN SCRIPT
//    Town 37: Gremlin Cave

// 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;

int i,j,k,r1,choice;
int c,d;
string dlgstr;

body;

beginstate INIT_STATE;
c = 41;
d = 3;
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 11;
	teleport_party(get_flag(200,1),get_flag(200,2),0);	
break;
	
beginstate 12;
		reset_dialog();
	clear_buffer();
	if ((c == 41) && (d == 3)) 
	append_string("Someone has etched a glowing, magical rune in the floor here. It glows a bright green, and tiny, red motes of light dance above it.");
	if ((c == 11) && (d == 9)) 
	append_string("Someone has etched a glowing, magical rune in the floor here. It glows a bright green, and tiny, blue motes of light dance above it.");
	if ((c == 3) && (d == 3)) 
	append_string("Someone has etched a glowing, magical rune in the floor here. It glows a bright green, and tiny, purple motes of light dance above it.");
	get_buffer_text(dlgstr);
	add_dialog_str(0,dlgstr,0);

	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Watch the rune.");
	add_dialog_choice(2,"Touch the rune.");
	choice = run_dialog(1);
	
	if (choice == 2) {
	message_dialog("You watch the rune. Nothing happens. It sure is pretty, though.","");
	}
	if (choice == 3) {
	message_dialog("The rune flashes brightly for a moment. You remove your hand, and the light fades.","");
	if ((c == 41) && (d == 3)) {
		c = 11;
		d = 9;
		end();
		}
	if ((c == 11) && (d == 9)) {
		c = 3;
		d = 3;
		end();		
		}
	if ((c == 3) && (d == 3)) {
		c = 41;
		d = 3;
		end();		
		}
	}
break;
	
beginstate 13;
	teleport_party(c,d,0);
break;
