begintownscript;

variables;
short bmessage, Luckskill, chance;

body;
beginstate INIT_STATE;

reset_dialog();
add_dialog_str(0,"You've landed in the stable. Above you, you an an here the door to your room being smashed in.",0);
add_dialog_str(1,"What you should probably do now is head to the chapel. Churches are good places to go when attacked by horrible monsters.",0);
add_dialog_choice(0,"Okay.");
bmessage = run_dialog(1);

add_char_to_group(5,1);
add_char_to_group(6,1);
add_char_to_group(7,1);
add_char_to_group(8,1);
add_char_to_group(9,1);
//add_char_to_group(10,1);
add_char_to_group(11,1);
add_char_to_group(12,1);

break;

beginstate START_STATE;
break;

beginstate EXIT_STATE;
break;

beginstate 10;
	if(get_flag(3,1) == 0){
	reset_dialog();
	add_dialog_str(0,"You think it would be better to seek refuge in the chapel than be out in the dark without shelter or defense. You turn back.",0);
	bmessage = run_dialog(1);
	block_entry(1);
	}
	if(get_flag(3,1) == 1){
	reset_dialog();
	add_dialog_str(0,"Better to stand and fight than be cut down running through the trees and snow in the dark. You turn back.",0);
	bmessage = run_dialog(1);
	block_entry(1);
	}
break;

beginstate 11;
if(get_flag(3,1) == 0){
	reset_dialog();
	add_dialog_str(0,"You come running up to where you think the chapel is, only to find a slightly raised area of snow. Shattered remains of a wall are barely visible in one corner.",0);
	add_dialog_str(1,"One thing is for sure, this church wasn't destroyed recently. The stone has been worn down by years of wind and snow. The whole town looks different, actually. What's going on here?.",0);
	add_dialog_str(2,"You don't have much time to ponder on this though. You think you can hear Jen's voice coming from in the inn. You'd better go see if she's okay.",0);
	bmessage = run_dialog(1);
	set_flag(3,1,1);
	march_party(24,36);
}
break;

beginstate 12;
if(get_flag(3,1) == 0){
	reset_dialog();
	add_dialog_str(0,"Given a choice between a building full of monsters and the nice (hopefully) safe church, which would you rather go to?.",0);
	add_dialog_str(1,"Here's a hint. Most people would take the church.",0);
	bmessage = run_dialog(1);
	block_entry(1);
}
break;

beginstate 13;
	if(get_flag(3,2) == 0){
		reset_dialog();
		add_dialog_str(0,"You here Jen in the inn calling for help, but something isn't right.",0);
		add_dialog_str(1,"When you get closer you can see what it is. She's paler than before, has fangs, and seems to be standing about two inches off the ground.",0);
		add_dialog_choice(0,"A vampire!");
		bmessage = run_dialog(1);
		alert_char(1001);
		set_flag(3,2,1);
		}
	if(get_flag(2,5) == 1){
		reset_dialog();
		add_dialog_str(0,"Looking inside the inn, you notice that the large barrel of _whiskey_ is broken open and it's contents are spilled across the floor. You've still got that torch.",0);
		add_dialog_choice(0,"Blow some stuff up");
		add_dialog_choice(1,"Not right now");
		bmessage = run_dialog(1);
		if (bmessage == 1) {
			set_total_visibility(1);
			set_character_facing(0,2);
			set_character_pose(0,1);
			force_instant_terrain_redraw();
			pause(2);
			set_character_pose(0,2);
			force_instant_terrain_redraw();
			pause(10);
			force_view_center(14,37);
			force_instant_terrain_redraw();
			chance =  get_ran(1,0,3) - 2;
			Luckskill = get_skill_total(18) + chance; 
			if (Luckskill >= 6){
				put_boom_on_space(13,38,1,0);
				put_field_on_space(13,38,1);
				put_field_on_space(13,39,1);
				put_field_on_space(13,37,1);
				put_field_on_space(12,38,1);
				put_field_on_space(14,38,1);
				put_field_on_space(11,38,1);
				put_field_on_space(15,39,1);
				put_field_on_space(14,39,1);
				put_field_on_space(12,39,1);
				put_field_on_space(14,38,1);
				put_field_on_space(12,37,1);
				put_field_on_space(13,37,1);
				put_field_on_space(13,36,1);
				put_field_on_space(13,40,1);
				run_animation();
				damage_near_loc(13,38,15,3,1);
				force_instant_terrain_redraw();
				take_all_of_item(447);
				}
			else{
				put_boom_on_space(14,38,1,0);
				put_field_on_space(14,38,1);
				put_field_on_space(14,39,1);
				put_field_on_space(14,37,1);
				put_field_on_space(13,38,1);
				put_field_on_space(15,38,1);
				run_animation();
				damage_near_loc(14,38,12,3,1);
				force_instant_terrain_redraw();
				take_all_of_item(447);
				}
			pause(10);
			force_view_center(24,37);
			set_total_visibility(0);
			}
		set_flag(2,5,2);
		}
break;

beginstate 14;
	reset_dialog();
	add_dialog_str(0,"There is a trap door leading down to the cellers. There are rather unpleasant noises coming from down below. You pile some crates on top of it.",0);
	bmessage = run_dialog(1);
	block_entry(1);
break;

beginstate 15;
	move_to_new_town(2,14,12);
break;