// .txt

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 5;
short last_abil;
short counter = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	set_name(17088,"Icy Wraith");
	set_new_abil(17088,14);
	set_boss_level(17088,1);

	set_new_abil(17089,20);
	set_boss_level(17089,1);
	set_attack_bonus(17089,20);
	
	set_name(17090,"Damaged Sentinel");
	set_level(17090,3);
	
	if ((gf(158,1) > 0) || (gf(170,1) >= 12))
		sf(158,12,1);
		
	set_name(17091,"Archmage Solberg");
	set_name(17092,"Gladwell");
	if (gf(158,15) > 9) 
		erase_char(17092);
	
	set_name(17093,"Julz");
	set_name(17094,"Sorengard");
	set_name(17095,"Ildiko");
	set_name(17096,"Horyn");
	set_name(17097,"Cheeseball Ten");
	set_name(17098,"Avernite Soldier");
	set_name(17099,"Avernite Soldier");
	set_name(17100,"Avernite Soldier");
	set_name(17101,"Avernite Soldier");


	if (gf(158,12) > 0) {
		erase_char(17091);
		erase_char(17097);
		}
		
//	add_range_to_group(,,groupn);

	set_crime_tolerance(max_crime);

	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
		
	if ((get_crime_level() >= max_crime) && (im_hostile == 0)) {
		make_zone_hostile(); 
		im_hostile = 1;
		//erase_char(30000);
		begin_talk_mode(299);
		}

	if (gf(158,1) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17091,"Are you from the Castle?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17091,"One final experiment.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17091,"I will not rot here.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"Are you here to help?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"Must protect the specimens.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"The experiment is ready.");
		}
	if (gf(158,1) > 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17091,"Time to leave.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17091,"I will depart.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17091,"I will not end here.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"So little hope.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"Must start again.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"Need to clean the cavern.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(17096,"What miserable luck.");
		}
		
	// if (gf(,) == 0) {
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17090,"Bzzzzt.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17090,"Tik. Tik.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17090,"Zzzzzrnk!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17092,"You can aid me.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17092,"Another tedious task ...");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17092,"Plan for the future.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17092,"Avernum's time is ending.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17093,"I do custom brewing.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17093,"Need a potion?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17093,"More warriors! Hooray!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17094,"Tik! Tik! Tik!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17094,"Clang! Clang!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17094,"These infernal creatures.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17094,"Will they never obey?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17095,"Where were those scrolls?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17095,"Don't touch anything!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17095,"Cursed apprentices.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17097,"Grrrrr.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17097,"(Stalk. Stalk.)");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(17097,"I serve the master!");
	//	}

	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 3))) {
		last_abil = get_current_tick();
		
		if (gf(158,9) > 0) {
			inc_flag(158,9,1);
			if (gf(158,9) == 2)
				begin_talk_mode(10);
			if (gf(158,9) == 4)
				begin_talk_mode(11);
			if (gf(158,9) == 6)
				begin_talk_mode(12);
			if (gf(158,9) == 8)
				begin_talk_mode(13);
			}
		}
break;

beginstate 10;
	set_terrain_string_range("The stone says - PATRICK PADRAIG. Wizard of Avernum. Beloved husband.",1);
break;

beginstate 11;
	set_terrain_string_range("The stone says - HATHWISA. Incantatrix of Avernum. Loyal wife.",1);
break;

beginstate 12;
	set_terrain_string_range("The sign says - Administrator's Office.",1);
break;

beginstate 13;
	set_terrain_string_range("The sign says - HOLDING CELLS. DANGER!",1);
break;

beginstate 14;
	set_terrain_string_range("The sign says - Botany.",1);
break;

beginstate 15;
	set_terrain_string_range("The sign says - Library North Wing.",1);
break;

beginstate 16;
	set_terrain_string_range("The sign says - Barracks.",1);
break;

beginstate 17;
	set_terrain_string_range("The sign says - Portal Pylon. Stay clear of arrival point!",1);
break;

beginstate 18;
	set_terrain_string_range("The sign says - Gladwell's Laboratory.",1);
break;

beginstate 19;
	if ((gf(158,16) < 4) && (char_ok(17089)) && (get_attitude(17089) < 10)) {
		print_str_color("The guardian hellhound becomes angry.",2);
		set_attitude(17089,10);
		}
break;


beginstate 20;
	set_terrain_string_range("The sign says - Private Laboratory.",1);
break;

beginstate 22;
		if (revive_party()) {
			print_str_color("Entering or leaving Patrick's Tower heals your wounds",2);
			print_str_color("  and restores your spell energy.",2);
			}
break;

//	print_str("");
//	set_terrain_string_range(".",1);
//	set_terrain_string_range("The sign says - .",1);
