// .txt

beginzonescript;

variables;

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

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	if (gf(114,1) == 1)
		sf(114,1,2);
	
	set_obj_act_at_dist(20583,1);
	set_obj_act_at_dist(20584,1);
	set_obj_act_at_dist(20592,1);
	set_obj_act_at_dist(20593,1);
	if (gf(114,1) == 0) {
		sf(114,25,1);
		sf(114,26,0);
		}
		else {
			sf(114,25,1);
			sf(114,26,1);
			}
			
//	set_name(,"");

	add_range_to_group(12312,12316,49);
	set_name(30049,"Sewer Rat");
	set_level(30049,5);
	set_new_abil(30049,10);
	
	set_name(12327,"Sssolak");
	if (gf(114,20) > 0)
		erase_char(12327);
		
	set_name(12328,"Ketzel Firebrand");
	set_name(12329,"Duffy Firebrand");

	add_range_to_group(12330,12333,53);
	set_name(30053,"Firebrand Clansman");
	add_range_to_group(12334,12337,51);
	set_name(30051,"Firebrand Clanwoman");

	add_range_to_group(12344,12351,52);
	
	set_crime_tolerance(max_crime);

	set_level(12368,4);
	set_level(12369,4);
	set_level(12370,4);
	set_level(12371,4);
	
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((summ1 == 0) && (gf(128,11) == 1) && (gf(114,13) == 0)) {
		summ1 = 1;
		activate_hidden_group(49);
		add_range_to_group(12322,12326,50);
		set_level(30050,8);
		}
		
	if ((get_crime_level() >= max_crime) && (im_hostile == 0)) {
		sf(114,0,1);
		
		sf(114,15,1); // ketzel not talk now
		make_zone_hostile();
		im_hostile = 1;
		}

	// if (gf(,) == 0) {
	if (get_ran(1,0,100) < 20)
		give_char_text_bubble(12327,"No entry.");
	if (get_ran(1,0,100) < 20)
		give_char_text_bubble(12327,"I control the gate.");
	if (get_ran(1,0,100) < 20)
		give_char_text_bubble(12327,"Ahhsss. Talk to me.");
	//	}

	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(12328,"Don't step on that!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(12328,"Leave the fruit alone.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(12328,"Curse this Blight!");
	if (gf(114,1) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12329,"We need help.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12329,"I was a fool.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12329,"Was all my fault.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12329,"Spare my clan.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"So hungry.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"Shhhhh.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"Please spare us.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"It's a soldier ...");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"Curse Mangan.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"Talk to Duffy.");

		}
	if (gf(114,1) > 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12329,"We are grateful.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12329,"I thank you.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"Thank you!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"We are so grateful.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"Free at last!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(12330 + get_ran(1,0,7),"We're saved!");

		}		


	if ((gf(114,1) == 0) && (party_within_dist(149,515,6)) && (gf(114,26) == 0)) {	
		sf(114,25,0);
		sf(114,26,1);
		begin_talk_mode(16);
		}
		
	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(114,1) == 1) {
			if (gf(114,16) < 100) {
				inc_flag(114,16,1);
				if (gf(114,16) == 5)
					begin_talk_mode(17);	
				}
			}
		}
break;

beginstate 10;
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

beginstate 20;
	if (is_combat() == FALSE)
		print_str_color("You climb the stairs.",2);
	change_level(181,550,6);
	// direction - 0,1 - north 2,3 - west 4,5 - south 6,7 - east
break;

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