begintownscript;
variables;
short choice;
short i,erase;
short tick;

body;
beginstate init_state;
i = 0;
while(char_ok(i) == 0){
	i = i + 1;
}
if(get_flag(2,15) == 0)
	set_flag(2,15,1);
revive_party();
if(get_flag(2,14) == 0){
	set_terrain(16,13,139);
	set_terrain(15,14,0);
	set_terrain(18,13,139);
	turn_off_training(1);
}
if(get_flag(4,14) == 0){
	set_terrain(15,16,139);
	set_terrain(17,16,0);
	set_terrain(16,17,0);
	set_terrain(18,17,0);
	set_terrain(19,15,139);
}
if((get_flag(2,14) > 0) && (get_flag(4,14) == 0)){
	if(get_flag(3,2) == 0)
		message_dialog("The others arrived ahead of you and are cleaning the cave to get it in a condition suitable for human inhabitation. Or rather, Fabian, Trey and Evrey are cleaning the cave, with Fabian naturally complaigning all the while.","Sleeping mats have been set out for Jamie and Captain Ainsley, Adrianna watches after them and Orrin watches at the cave entrance. Erasmus and Rowly are noticeably missing; they must have gone outside already.");
	set_flag(3,2,1);
	activate_hidden_group(1);
	activate_hidden_group(2);
}
if(get_flag(4,14) > 0){
	activate_hidden_group(3);
	if(get_flag(3,5) == 0){
		set_flag(3,5,1);
		toggle_quest(1,0);
		award_party_xp(200,15);
		reset_dialog();
		add_dialog_str(0,"A somber pall seems to have fallen over the cave, the group has dispersed throughout the cave in an effort to be alone with their thoughts. Even when Orrin returns with the firewood and gets a fire started it does little for the mood.",0);
		add_dialog_str(1,"It does, however, bring everybody to the center of the cave to gather around the blaze. When you're in the mountains you covet any source of warmth like you would a crown of jewels.",0);
		add_dialog_str(2,"You sit by the fire for nearly an hour, but the heat seems to escape your tired body quicker than the fire can keep up.",0);
		add_dialog_str(3,"Eventually you tire of the oppressive silence, and of staring into the warmthless flame.",0);
		add_dialog_choice(0,"OK");
		choice = run_dialog(1);
	}
}
else
	set_terrain(17,15,0);
//Fabian
set_char_dialogue_pic(10,305,0);
set_char_dialogue_pic(12,305,0);
//Jamie
set_char_dialogue_pic(9,306,0);
set_char_dialogue_pic(14,306,0);
//Ainsley
set_char_dialogue_pic(7,1907,0);
set_char_dialogue_pic(17,1907,0);
//Evrey
set_char_dialogue_pic(11,1957,0);
set_char_dialogue_pic(16,1957,0);
//Orrin
set_char_dialogue_pic(6,304,0);
set_char_dialogue_pic(19,304,0);
//Adrianna
set_char_dialogue_pic(13,1959,0);
set_char_dialogue_pic(18,1959,0);
//Burden
set_char_dialogue_pic(8,303,0);
set_char_dialogue_pic(15,303,0);

break;

beginstate start_state;
break;

beginstate exit_state;
break;

beginstate 10;
if((get_flag(4,14) > 0) && (get_flag(3,11) == 0)){
	block_entry(1);
	message_dialog("A storm is brewing outside, this is no time to be leaving the shelter of your cave.","");
	end();
}
if((get_flag(3,3) > 0) && (get_flag(3,4) == 0)){
	toggle_quest(1,1);
	set_flag(254,5,0);
	set_ticks_forward(4940 - get_current_tick());
	begin_talk_mode(10);
}
move_to_new_town(2,6,23);
break;

beginstate 11;
if(get_flag(2,15) <= 1)
	message_dialog("The cave is empty. The only thing that remains of the wolves who once made this their home is a foul stench, and some gnawed bones and old fur. Fabian heaves a sigh of relief, as do you.","_Well this looks as good a place as any to pitch camp. A little bit messy, but we can clear some of this filth and get a nice fire burning here. Let's go find Sarge and the rest, they can't be too far back._");
set_flag(2,15,2);
break;

beginstate 12;
//REST
if((get_flag(3,10) >= 2) && (get_flag(3,11) == 0)){
	reset_dialog();
	add_dialog_str(0,"The wind now whips through the trees outside, sending gusts of cold air and occasionally snow into the cave. The others, with the exception of Orrin who keeps his position by the entrance, are beginning to settle in for the night.",0);
	add_dialog_str(1,"The day has been one long exertion, from fighting wolves and hobgoblins to your mad dash back to the cave. Your body screams at you to lay down to sleep.",0);
	add_dialog_choice(0,"Go to sleep.");
	add_dialog_choice(1,"Stay awake.");
	choice = run_dialog(1);
	if(choice == 2)
		end();
	block_entry(1);
	set_terrain(18,14,1);
	set_terrain(18,15,1);
	set_terrain(18,16,1);
	set_terrain(19,14,1);
	set_terrain(19,16,1);
	set_terrain(20,14,1);
	set_terrain(20,15,1);
	set_terrain(20,16,1);
	force_view_center(19,15);
	relocate_character(i,19,15);
	set_character_pose(i,14);
	force_instant_terrain_redraw();
	pause(5);

	play_sound(20);
	set_flag(3,11,1);

	reset_dialog();
	add_dialog_str(0,"You stand in an old, delapidated graveyard. The only person in sight is a short, grimy hunchbacked man who stands before you. His grim face is illuminated by the dancing light of the lantern he carries.",0);
	add_dialog_str(1,"He motions for you to follow him, and sets off at a slow limp. You are hesitant to follow him, but your feet seem to do so of their own accord.",0);
	add_dialog_str(2,"He takes a winding path through the forest of crumbling headstones, eventually stopping at a obelisk shaped monument. He gives you a toothless grin as you step up cautiously.",0);
	add_dialog_str(3,"The obelisk was once made of a fine marble, but is now old and faded. Moss obscures the worn lettering, and the top of the obelisk ends in a crumbled, jagged peak. Three tombstones lie at the base, each more pitiful than the last.",0);
	add_dialog_str(4,"You turn to ask the hunchback what the meaning of this is, but find him vanished taking your source of light with him. You quickly look about, but see him nowhere. How could he have left so quickly when he can hardly walk?",0);
	add_dialog_str(5,"With a trembling hand you reach out to scratch away the moss covering the obelisk.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);

	reset_dialog();
	add_dialog_str(0,"You pull away the moss carefully, then faster until you almost claw at the marble surface. Eventually you step back and read with dread:",0);
	add_dialog_str(1,"_Dedicated to the memory of the ill-fated Unit 341. Lost in the line of duty in the service of their land. None remember their tale, but all revere their sacrifice._",0);
	add_dialog_str(2,"You quickly uncover the other gravestones -- 'Field Surgeon Scott Ewett, his healing....', 'Professor Erasmus Jordan, wise sage and....', 'Sir Roger Rowly, hunter of...'",0);
	add_dialog_str(3,"You hardly read the epitaphs, taking enough time only to assure yourself of the name on each headstone. The sight fills you with dread.",0);
	add_dialog_str(4,"A noise behind you sends you whirling, but you see nothing. The wind is beginning to pick up, it whirls about you, blowing leaves and dirt form a cyclone about you, and in the midst of it is a wailing voice.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
	set_flag(254,5,0);
	set_ticks_forward(4940 - get_current_tick());

	reset_dialog();
	add_dialog_str(0,"_Viiinnnnceennnttt! Viinnnceennttt! Vincent! Vincent, get up!_ The wailing cry gives way to the more familiar voice of your friend Orrin. You rub the sleep from your eyes and crawl out of your sleeping bag.",0);
	add_dialog_str(1,"The rest of your group are already up and bundled against the cold. The air oustide is like a linen sheet, it's so thick with wind and snow.",0);
	add_dialog_str(2,"Orrin addresses the group, _We can't stay here any longer, if the snow piles any higher in the entrance we will be blocked in, and if the cold doesn't get us the smoke from the fire will._",0);
	add_dialog_str(3,"_Where are we headed?_ Evrey inquires. Orrin looks expectantly at Sergeant Burden, who speaks resignedly, _We will march down the mountain the way we came up. There is nothing else here for us-- nothing we can do but die in vain._",0);
	add_dialog_str(4,"The news is met with various reactions, from muttered complaints to relieved, almost embarrassed, grins. But everybody follows the order without open complaint, and files out of into the blowing wind.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
	set_terrain(18,14,0);
	set_terrain(18,15,0);
	set_terrain(18,16,0);
	set_terrain(19,14,0);
	set_terrain(19,16,0);
	set_terrain(20,14,0);
	set_terrain(20,15,0);
	set_terrain(20,16,0);
	set_terrain(15,16,0);
	set_terrain(16,13,139);
	set_terrain(15,14,0);
	set_terrain(17,15,0);
	set_terrain(18,13,139);
	set_terrain(16,17,0);
	set_terrain(18,17,0);
	set_terrain(19,15,139);
	set_character_pose(i,0);
	erase = 6;
	while(erase <= 19){
		erase_char(erase);
		erase = erase + 1;
	}
	force_instant_terrain_redraw();
}
	
break;

beginstate 13;
//if(get_flag(4,14) > 0) && (get_flag(3,
break;

beginstate 20;
if(get_flag(3,0) == 0){
	set_flag(3,0,1);
	reset_dialog();
	add_dialog_str(0,"An inch thick layer of ice has formed over this corpse, which would explain why the wolves haven't completely devoured it. The body is of a human soldier wearing the armor of an Empire Soldier.",0);
	add_dialog_str(1,"The armor has been worn by the elements, and is hard to identify. Still, you can see that the man wears the clenched fist emblem of House Strongarm who ruled Aizo nearly-- 400 years ago! You chip away the ice to get a better look.",0);
	add_dialog_str(2,"The body and the gear on it are in good condition for being four hundred years old, but not nearly good enough to be used in battle. The only thing of note is a flask on his belt marked _Cryoprev._",0);
	add_dialog_str(3,"Unfortunately it's empty, although another potion, this one unmarked, remains intact. You aren't particularly eager to drink a four hundred year old liquid, but potions will keep almost forever, and this one was even refrigerated!",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}
break;