begintownscript;
variables;
short choice;
short i,erase,march,steps;
short tick,counter = 0;

body;
beginstate init_state;
i = 0;
while(char_ok(i) == 0){
	i = i + 1;
	}
if(get_flag(9,12) > 0){
	erase_char(6);
	set_terrain(15,33,483);
	put_stain_on_space(16,32,2);
	put_stain_on_space(15,33,1);
	put_stain_on_space(46,33,1);
	put_stain_on_space(50,40,2);
	put_stain_on_space(57,39,1);
	if(get_flag(8,5) == 0){
		set_flag(8,5,1);
		set_flag(254,2,0);
		reset_dialog();
		add_dialog_str(0,"You emerge from the cellars and into the sunlight. Last night's storm faded as abruptly as it came, the sky is sunny and clear, and the snow is beginning to melt away.",0);
		add_dialog_str(1,"There is a strong breeze blowing, but you don't feel at all cold. You feel as fresh as the landscape, gone is the exhaustion of yesterday's mad dash, the leaden feeling in your legs, the terror.",0);
		add_dialog_str(2,"You want to run, jump, cavort, if just to test out this feeling of strength and rejuvenation that you haven't felt since the first day you arrived here.",0);
		add_dialog_choice(0,"OK");
		choice = run_dialog(1);
		alter_stat(i,0,2);
		alter_stat(i,3,2);
		alter_stat(i,8,10);
	}
}
break;

beginstate start_state;
break;

beginstate exit_state;
break;

beginstate 10;
block_entry(1);
message_dialog("It pains you to leave your friend behind, but there is nothing for it but to continue on. Burden and the others need you more than Orrin does.","The tower is not far from here, you can see it jutting over the ridge to the south. A roar from the west tells you that you have little time, but you can make it, even if Orrin only holds it off for a short time.");
break;

beginstate 11;
if(get_flag(8,0) == 0){
	set_flag(8,0,1);
	reset_dialog();
	add_dialog_str(0,"A deep, reverbating, blast of sound echoes through the pass like a hurricane. This is a new sound, not the terrible cry of the Beast.",0);
	add_dialog_str(1,"A triumpahnt sound that moves all the way from your ears to your tired feet, that sends adrenaline coursing through your veins and makes you forget all-- Orrin's horn.",0);
	add_dialog_str(2,"In all the time you've known Orrin you never heard the highlander sound his war horn. Now he sends three great blasts echoing through the mountains, so powerful that surely they can hear it all the way down in Manibor.",0);
	add_dialog_str(3,"You shake thoughts of your friend going toe to toe with that monstrosity out of your head. There is no time to worry about Orrin. You've almost caught up to the others, and the tower is just around the corner.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1); 
}
break;

beginstate 12;
if(get_flag(8,1) == 0){
	set_flag(8,1,1);
	message_dialog("You step through the gates of the ruined tower. There isn't much shelter to be found here, the courtyard ahead is full of debris and rubble, and the tower itself is nothing but a ruined wreck.","You are, however, out of the wind, and you are at long last at your destination. You never thought you'd reach Amon Sul, and now you're here you aren't so sure what to do. Where is there to take refuge from the Beast in these ruins?");
}
break;

beginstate 13;
block_entry(1);
message_dialog("You don't know how tall this tower once stood, but everything except the second and third floor has collapsed, and they look likely to do the same any minute.","Even if you would be safe from the Beast up there, you would be just as likely to break your neck or be killed by falling rubble. You wisely turn back.");

break;

beginstate 14;
if(get_flag(8,2) == 0){
	set_flag(8,2,1);
	message_dialog("This tower is in poor shape. The first floor is in shambles, the second and third are collapsing, and who knows how many floors there once were above those. There are huge holes in the roof where pieces caved in, allowing snow and the weather to enter.","You look around for any place to find refuge, but see nothing. Your companions are somewhere ahead, perhaps Burden has something in mind.");
}
break;

beginstate 15;
if(get_flag(8,3) == 0){
	set_flag(8,3,1);
	reset_dialog();
	add_dialog_str(0,"Fabian stands at the top of the stairway, every muscle in his body is tense and he looks ready to lunge. The effort of holding his sword at the ready is enough to cause his arm to quiver. He's as exhausted as you.",0);
	add_dialog_str(1,"He nearly jumps out of his skin when he somebody round the corner, when he sees it's you he sags with relief. _Orrin-- isn't coming? I hardly believed it, but... Well that thing isn't on your tail, is it?_",0);
	add_dialog_str(2,"You glance behind you, then shake your head. _OK, good. Burden and the others are beneath that ruined building, the one to the northeast. There's a basement there where we can get out of the weather. Now let's hurry._",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
	erase_char(6);
}
break;

beginstate 16;
//trapdoor//
if(get_flag(8,3) == 0){
	set_flag(8,3,1);
	message_dialog("Fabian climbs down the narrow stairs leading into the ground. You follow behind him, the distant sounds of roaring getting gradually closer. You strain to hear whether the clangs of weapons can be heard, but hear nothing.","You climb down the stairs, pulling shut the heavy oaken double doors behind you. You slide a bar through the door handles-- if the Beast can break through this then you truly are dead men.");
}
move_to_new_town(9,37,61);
break;

beginstate 17;
//Gatewheel- opens when strong//
if(get_flag(9,12) == 0){
	message_dialog("You pull on the wheel, but can hardly move it an inch. You throw all your strength into it, but simply can't muster the strength to turn the rusty chain. It would be a difficult task under any circumstances, and you feel like you're about to collapse.","This isn't productive, you should be finding shelter, not exherting what little energy you still have by trying to open the tower gates.");
}
else{
	message_dialog("Last night you never could have turned this rusty old wheel, but today you feel rejuvenated and fit. You have to put your back into it, but you are rewarded by the sound of metal scraping across metal as the gates clink open.","");
	flip_terrain(51,39);
	flip_terrain(51,40);
}
break;

beginstate 18;
//gatewheel- can't turn//
print_str_color("The wheel won't turn, the chain is rusty and the device poorly maintained.",1);
break;

beginstate 19;
if(get_flag(9,12) == 0){
	block_entry(1);
	end();
}
if(get_flag(8,4) == 0){
	set_flag(8,4,1);
	message_dialog("Orrin's body lies here, torn apart by the Beast just as all the others were. There is blood and signs of fighting all around him. Not all of the blood is his, as each of his twin broadswors are crusted with dried blood.","He fought the Beast all the way up from the slopes below, buying time for the rest of the expedition all the way. A pity that it was just delaying their destruction.");
}
break;

beginstate 20;
if(get_flag(9,12) > 0){
	block_entry(1);
	message_dialog("This is the path down from the mountains. Perhaps you will settle your business here and survive to take this path, but for now you have to find Fabian, and kill the Beast.","");
}
break;

beginstate 21;
if(get_flag(9,12) == 0){
	block_entry(1);
	message_dialog("This path leads further into the mountains. Although you aren't sure where exactly, you're confident that you won't find any better shelter than here in the tower.","Burden and the others already took refuge in the building to the north, you'd do well to follow before the Beast is upon you.");
	end();
}
if(get_flag(8,6) == 0){
	set_flag(8,6,1);
	message_dialog("The trail of blood continues on into the mountains. The snow here has begun to melt, obscuring any footprints. You can't tell if there is one set of human prints, or a set of larger, more sinister paws.","Either way your path is clear-- follow the blood.");
}
break;

beginstate 22;
if(get_flag(8,7) == 0){
	set_flag(8,7,1);
	message_dialog("You are starting to feel increasingly warm, so warm that you are tempted to take off your jacket. You've heard that the last stage of frostbite is a feeling of burning heat, but that certainly doesn't seem to apply to you.","You wipe the sweat from your brow and keep going. Your stomache grumbles again, the piece of hardtack you just ate wasn't enough, you're already famished.");
}
break;

beginstate 23;
if(get_flag(8,8) == 0){
	set_flag(8,8,1);
	reset_dialog();
	add_dialog_str(0,"The trail forks here, but from the trail of blood you can tell which way Fabian went.",0);
	add_dialog_str(1,"A cloud of steam billows from your sweat drenched hair as you finally give in to the heat and pull your helmet off.",0);
	add_dialog_str(2,"You don't feel tired, the short run is hardly any exhertion compared to last night's sprint, and you feel like you could run for miles. Yet you are sweating like a baker that just ran a mile.",0);
	add_dialog_str(3,"Apparently the heat isn't your imagination, and it isn't a result of physical strain. Maybe you're finally getting acclamated to these temperatures, after all Orrin never complained of cold, or had to wear a jacket even.",0); 
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}
break;

beginstate 24;
block_entry(1);
message_dialog("You aren't sure where the path ahead leads to, but the blood stains leading to the north make it fairly clear that Fabian didn't pass this way.","");
break;

beginstate 25;
message_dialog("You follow the trail of blood ever higher into the mountains. You are drenched in sweat, and feeling so overheated that you want to throw yourself in the snow just to soothe your skin.","You pull off your jacket to assure yourself that your skin isn't burned to a crisp, and don't bother putting it back on. At first this was a welcome change from shivering in the cold, but now it's starting to get alarming.");
move_to_new_town(0,10,6);
break;