begintownscript;

variables;
short bmessage,leadchar;

body;

beginstate 0;

	set_crime_tolerance(5);

	if(get_flag(57,0) == 0){
		force_instant_terrain_redraw();
		reset_dialog();
		add_dialog_str(0,"Ah, Kedalvasser.",0);
		add_dialog_str(1,"The military academy for slightly above-par grunts, where particularly concered parents send their children to get non-educations and put them in positions of comparative command.",0);
		add_dialog_str(2,"You went here as well.  You were stationed in a barrack.  It was mundane.  Then one day, you wandered into the Bugbear village and took back the heads of a few guards.",0);
		add_dialog_str(3,"It was a quick graduation.  Your peers hated you.  You moved on, and became who you are now.",0);
		add_dialog_str(4,"Other points of interest in the city are slim, other than the fact that artisans come here to pander their goods, often of high quality.  There's the only inn in North Canopy underground here.",0);
		add_dialog_str(5,"There's Leader's Mansion as well, but absolutely nobody is allowed inside without Leader's explicit permission.  And that includes you.  It is, however, a very lovely house.",0);
		bmessage = run_dialog(1);
		set_flag(57,0,1);
	}

	if(get_flag(57,0) >= 2){
		set_terrain(33,17,33);
	}

	if(get_flag(70,0) == 1){
		make_town_hostile();
	}

break;

beginstate 1;


break;

beginstate START_STATE;

	if(get_crime_level() > 0){
		set_flag(70,0,1);
	}

break;

beginstate 10;

	if(is_combat() == TRUE){
		block_entry(1);
		end();
	}
	move_to_new_town(24,4,8);

break;

beginstate 11;

	if(get_flag(57,0) < 2 && get_crime_level() < 1){
		reset_dialog();
		add_dialog_str(0,"You approach the entrance to the Kedalvasser Military Academy.  The guards seem a bit nervous when they see that you are armed.",0);
		if(party_size() > 1){
			if(party_size() > 1)
				add_dialog_str(1,"_Who are you, and what is your business here?_ asks one of them.  You tell them that you are the Specialists.  The guard seems confused.",0);
			add_dialog_str(2,"_What are the Specialists?_  You tell him to fetch a superior.  Reluctantly, he slips behind the wall.",0);
		}
		else{
			add_dialog_str(1,"_Who are you, and what is your business here?_ asks one of them.  You tell them that you are the Specialist.  The guard seems confused.",0);
			add_dialog_str(2,"_What is the Specialist?_  You tell him to fetch a superior.  Reluctantly, he slips behind the wall.",0);
		}
		add_dialog_str(3,"You hear what can only be described as verbal cannibalism.  The entire town seems to stop for an instant until the noise dies down.  Honestly, it's somewhat flattering.",0);
		if(party_size() > 1)
			add_dialog_str(4,"The guard comes back to his post quaking with fear.  He doesn't even LOOK at you.  _I-I'm sorry for my i-i-ignorance, s-s-s-sirs...  W-welcome to K-k-kedalvasser Military Academy._",0);
		if(party_size() == 1)
			add_dialog_str(4,"The guard comes back to his post quaking with fear.  He doesn't even LOOK at you.  _I-I'm sorry for my i-i-ignorance, s-s-s-sir...  W-welcome to K-k-kedalvasser Military Academy._",0);
		add_dialog_str(5,"The gates are opened.  Time to see if the place has changed any.",0);
		bmessage = run_dialog(1);
		set_flag(57,0,2);
		set_terrain(33,17,33);
		play_sound(99);
	}

break;

beginstate 12;

	if(get_flag(57,0) < 3){
		message_dialog("The place hasn't changed much at all.  You aren't surprised- its only raison d'tre is, after all, getting marginally richer parents to send their children to the military.","The students are miserable; the teachers are miserable.  The nostalgia almost makes you melt with mad pleasure for being beyond it.");
		set_flag(57,0,3);
	}

break;

beginstate 13;
	if(get_crime_level() < 1){
		message_dialog("Based on how many arrows are strewn about on the ground, it would be a safe bet to say that the archers here aren't very good.","Rather than get in their range of fire, you stay safely away.");
		block_entry(1);
	}

break;

beginstate 14;

	if(get_crime_level() < 1){
		message_dialog("This is Leader's Mansion.  It is large, rich, and coveted by all who pass it by.","It is also incredibly well-guarded, and completely off-limits.  One of the guards tells you to go away, and not wanting trouble, you comply.");
		block_entry(1);
	}

break;

beginstate 15;

	if(get_flag(33,9) == 0){
		message_dialog("You are inside of Leader's Mansion.  It is surprisingly humble, given its purpose.  That does not mean it is not gorgeous, however.  You would love to live in a place like this.","Unfortunately, now that you've attacked Kedalvasser, you will probably not live at all.");
		set_flag(33,9,1);
	}

break;

beginstate 20;
	if(get_flag(70,0) == 1){
		message_dialog("You managed to escape Kedalvasser safely.  Unfortunately, however you managed to be convinced yourself that you would be able to escape North Canopy, you were wrong.","You are restrained, imprisoned, and killed slowly and painfully.");
		kill_char(1000,3,0);
	}
break;