// TOWN SCRIPT
//    Town 73: Strange 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;


body;

beginstate INIT_STATE;
	set_name(29,"Windell");

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	teleport_party(get_flag(200,1),get_flag(200,2),0);	
break;

beginstate 11;
	reset_dialog();
	add_dialog_str(0,"You search the desk carefully and are soon rewarded. You find a tiny button hidden at the back of one of the drawers.",0);
	add_dialog_choice(0,"Leave the button alone.");
	add_dialog_choice(1,"Press it.");
	choice = run_dialog(1);
	
	if (choice == 2) {
	set_terrain(33,12,0);
	reset_dialog();
	add_dialog_str(0,"Click.",0);
	choice = run_dialog(1);	
	}
break;

beginstate 12;
	if (get_terrain(33,12) == 0)
	end();
	else {
	if (is_combat() == 1) {
		reset_dialog();
		add_dialog_str(0,"You find a portal, a magical door made of pure energy. Wizards often create them to speed up transportation from one place to another.",0);
		add_dialog_str(1,"You can't enter portals in combat.",0);
	run_dialog(0);
	block_entry(1);
	}

	if (is_combat() != 1) {		
	reset_dialog();
		add_dialog_str(0,"You find a portal, a magical door made of pure energy. Wizards often create them to speed up transportation from one place to another.",0);
		add_dialog_str(1,"They're safe. Usually.",0);		
	add_dialog_choice(0,"Step away from it.");
	add_dialog_choice(1,"Walk into the portal.");
	choice = run_dialog(0);
	if (choice == 1) {
	block_entry(1);
	end();
	}
	if (choice == 2) {	
	block_entry(1);
	teleport_party(33,29,0);	
	}
	}
	}
break;
