// Town 45: Avernoss Camp
// Two pens are 6 x 8 and 8 x 8; lizard pen is 5 x 4
// All tents and portables are 4 x 4
begintownscript;

variables;

short choice,i,j,k;
string dlgstr;

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	change_outdoor_location(1,12,19,18);
	
	if (get_flag(213,0) == 1) {
		i = 0;
		while (i <= 119) {
			erase_char(i);
			i = i + 1;
			}
		force_instant_terrain_redraw();
		message_dialog("The camp is deserted! They must have followed you towards Danatha. You should probably go there, too.","");
		end();
		}
	
	set_name(6,"Pithoss"); // type 112
	set_char_dialogue_pic(6,580,0);
	set_name(7,"Kass"); // type 36
	set_char_dialogue_pic(7,583,0);
	set_name(8,"Machrone"); // type 78
	set_char_dialogue_pic(9,585,0); // Phaedra
	set_name(10,"Ethass"); // type 111
	set_char_dialogue_pic(10,584,0);
	set_name(11,"Talas"); // type 112
	set_char_dialogue_pic(11,582,0);
	set_name(12,"Silthokh"); // type 111
	set_name(13,"Ithik"); // type 112
	set_level(13,60);
	set_name(14,"Britha"); // type 113
	set_name(15,"Bitey");
	set_name(16,"Hissy");
	set_name(17,"Snarly");
	
	if (get_flag(290,7))
		make_town_hostile();
	
	if ((char_ok(9) == 0) && (character_in_party(105) < 0))
		activate_hidden_group(1);
	
	if (get_flag(45,0) == 0) {
		set_flag(45,0,1);
		message_dialog("The expedition has already set up camp here, and all its members have situated themselves carefully. The shrine for the Goddess -- for Althanazaria -- has not been moved here, nor has Legare's portable room.","Pithoss should know what you are to do now.");
		}
	
	if (get_flag(51,1) == 0)
		end();
	if (get_flag(45,3) == 1)
		end();
	
	set_flag(45,3,1);
	
	put_boom_on_char(0,2,0);
	put_boom_on_char(1,2,0);
	put_boom_on_char(2,2,0);
	put_boom_on_char(3,2,0);
	put_boom_on_char(4,2,0);
	run_animation_sound(10);
	
	if (character_in_party(105)) {
		message_dialog("You arrive back in camp! A crowd quickly gathers around you as you tell your story, the story of the events in the Land of the Dead. Everyone nods as each one hears Legare's final words, and slowly all disperse, still talking about it.","Phaedra flashes you another one of her bright grins. _Great working with you again,_ she says. _If you don't mind, I'll be patching up my wounds over by my tent._ She heads south with a wave and a smile.");
		remove_char_from_party(105);
		}
	else
		message_dialog("You arrive back in camp! A crowd quickly gathers around you as you tell your story, the story of the events in the Land of the Dead. Everyone nods as each one hears Legare's final words, and slowly all disperse, still talking about it.","You notice that Phaedra is there, too. _Sorry that I couldn't make it the whole way with you,_ she says, smiling sheepishly. _I'm fine, though. I got back here in time, and Kass was able to heal me._ She heads south to her tent with a wave and a smile.");
	
	toggle_quest(13,0);
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	award_party_xp(get_level(i),500);
	
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
if (get_crime_level() == 0)
	end();
if (get_flag(290,7) > 0)
	end();
	
	print_str_color("You have made the expedition angry with you.",1);
	make_town_hostile();
	set_flag(290,7,1);
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0,"You have returned to your tent. What would you like to do?",0);
	add_dialog_choice(0,"Nothing.");
	add_dialog_choice(1,"Rest.");
	if (run_dialog(1) == 1)
		end();
	
	force_view_center(7,7);
	force_instant_terrain_redraw();
	
	block_entry(1);
	
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	march_party(28,39);
	march_party(29,39);
	march_party(30,39);
	march_party(31,39);
	
	revive_party();
	play_sound(20);
	
	message_dialog("You lay down in your tent and sleep uneventfully for a short time. When you wake, you are fully revived.","");
	
	force_view_center(char_loc_x(i),char_loc_y(i));
	force_instant_terrain_redraw();
break;