begintownscript;

variables;

body;

beginstate INIT_STATE;
	set_char_dialogue_pic(8,510,0);
	set_name(9,"Frowney Cook");
	set_char_dialogue_pic(9,511,0);
	set_char_dialogue_pic(10,510,0);
	set_char_dialogue_pic(11,510,0);
	set_char_dialogue_pic(12,511,0);
	set_name(13,"Smiley Priest");
	set_char_dialogue_pic(13,510,0);
	set_name(14,"Captain Frowney");
	set_char_dialogue_pic(14,511,0);
	set_char_dialogue_pic(15,511,0);
	set_name(16,"Lemonhead");
	set_char_dialogue_pic(16,512,0);
	set_name(17,"Prisoner");
	if(get_flag(2,1)==0){
		message_dialog("As you finally reach the Keep, you receive a disappointment. The gate is closed. And you don't doubt that it will stay that way. It's guarded by two positively malicious frowney faces.","It appears, however, that they have been ordered to let you in. The portcullis opens as you approach. You can hear the frowneys grumbling.");
		set_flag(2,1,1);
	}
	if (get_flag(2,7) == 1)
		erase_char(16);
	if (get_flag(4,4) == 1)
		set_state_continue(16);
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	if (get_flag(2,1) == 0) {
		message_dialog("So, now you're in the Smileys' Castle, what are you going to do? You've heard they have a King. Talking to him seems like a good idea.","Now you'll just need to find out where he is...");
		set_flag(2,1,1);
	}
break;

beginstate 11;
	if(get_flag(2,2)==0) {
		message_dialog("You enter the Grand Throne Room of King Smiley. Well, since the Smileys just sort of float and can't sit, there is no throne, but you can't think of a better name.","King Smiley stands -- floats -- on a raised platform, waiting for you to speak first.");
		set_flag(2,2,1);
	}
	if (get_flag(5,2) == 1) {
		message_dialog("You enter the Grand Throne Room of King Smiley once again.","_Ahem,_ says the King. _So you've come to kill me,_ he muses. _Prepare to die, traitor!_");
		set_attitude(8,10);
	}	
break;

beginstate 12;
	if (get_flag(2,4) == 1) {
		message_dialog("You enter the quarters of the Smiley that the Frowney told you about. Your immediate impression is about how much nicer it is.","Whereas the Frowney's room had wood floor, this room is carpeted, and the bed is much nicer. And this Smiley has TWO nice boxes.");
		set_flag(2,4,2);
	}
break;

beginstate 13;
	if(get_flag(2,6)==0){
		message_dialog("You enter the small storeroom containing all of the Keep's supplies. You're really not impressed. A few crude daggers and some rocks, presumably for throwing. Nothing worth taking.","");
		set_flag(2,6,1);
	}
break;

beginstate 14;
	if(get_flag(2,7)==0){
		message_dialog("It appears that your key opens more than the storeroom. This room looks like a cell. But no one is in it. A trail of blood leads to the south wall, and you think you hear digging.","");
		set_flag(2,7,1);
	}
break;

beginstate 15;
	if (get_flag(2,8) == 0) {
		message_dialog("As you are accustomed to do after your travels, you feel this wall to check that it is solid.","You find, to your surprise, it is not.");
		message_dialog("You fall through the wall, and on the other side you see a deep dark pit.","You teeter on the edge, trying to regain your balance. You're about to, when a gust of wind pushes you over, and you begin to fall...");
		move_to_new_town(3,24,43);
	}
	else {
		message_dialog("The wall has become solid. It seems Duck does not want you back.","");
		block_entry(1);
	}
break;

beginstate 16;
	if(get_flag(1,28)==0){
		message_dialog("You return to the Keep with your prisoner. A Frowney guard takes him from your side and moves him to a cell to the west. He then instructs you to go to the prisoner's cell and interrogate him. He gives you the cell key.","");
		change_spec_item(1,1);
		set_flag(1,28,1);
		toggle_quest(4,0);
	}
break;