// .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(1080,"Captured Hellhound");
	set_level(1080,28);
	set_name(1081,"Captured Hellhound");
	set_level(1081,28);
	set_name(1082,"Captured Hellhound");
	set_level(1082,28);

	set_name(1083,"Kian-Ihrno");
	set_name(1084,"Palom");
	set_boss_level(1084,2);
	set_name(1085,"Unici-Tel");
	set_level(1085,35);
	set_boss_level(1085,2);
	
	if ((gf(10,2) > 0) && (gf(10,9) == 0))
		spawn_creature(1086);

	set_name(1086,"Torkia");
	set_boss_level(1086,1);
	set_new_abil(1086,16);
	
	set_name(1087,"Salasi");
	set_level(1087,30);
	
	set_name(1088,"Frozen Slith");

	set_boss_level(1089,1);
	set_boss_level(1090,1);
	set_boss_level(1091,1);
	set_boss_level(1092,1);
	set_boss_level(1093,1);
	set_boss_level(1094,1);
	set_boss_level(1095,1);


	
//	add_range_to_group(,,groupn);

	set_crime_tolerance(max_crime);

	if ((gf(10,19) == 1) || (gf(10,19) == 2))
		sf(10,19,0);
	
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
		
	if ((get_crime_level() >= max_crime) && (im_hostile == 0)) {
		make_zone_hostile();
		im_hostile = 1;
		sf(10,8,1);
		}

	if ((gf(10,19) == 0) && (on_which_layer() == 1) && (party_within_dist(690,25,6))) { // turn on event
		sf(10,19,1);
		
		spawn_creature(1100);
		
		sf(10,21,0);
		sf(10,22,1);
		sf(10,23,0);
		sf(10,24,0);
		sf(10,25,0);
		
		erase_char(1096); // reset pylons
		spawn_creature(1096);
		erase_char(1097);
		spawn_creature(1097);
		erase_char(1098);
		spawn_creature(1098);
		erase_char(1099);
		spawn_creature(1099);
		add_range_to_group(1096,1099,12);
		
		place_particle_num(1096 + gf(10,21),22,12,5);		
		place_particle_num(1096 + gf(10,21),22,13,5);		
		place_particle_num(1096 + gf(10,22),21,12,5);		
		place_particle_num(1096 + gf(10,22),21,13,5);		

		set_resistance(1096 + gf(10,22),0,0);
		set_resistance(1096 + gf(10,22),1,0);
		set_resistance(1096 + gf(10,22),2,0);
		set_resistance(1096 + gf(10,22),3,0);		
		
		begin_talk_mode(14);
		}
	if (((gf(10,19) == 1) || (gf(10,19) == 2)) && (party_within_dist(690,25,8) == FALSE)) { // turn off event
		sf(10,19,0);
		erase_char(1100);

		clean_off_particles(30012);
		set_resistance(30012,0,100);
		set_resistance(30012,1,100);
		set_resistance(30012,2,100);
		set_resistance(30012,3,100);
		
		begin_talk_mode(15);
		}
	
		
	if (gf(10,8) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1083,"You are here.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1083,"We mean well.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1083,"We are no threat.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1083,"We are friends to Avernum.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1084,"Mix?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1084,"Mix! Mix!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1084,"Potion!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1085,"I help.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1085,"Is safe.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1085,"Be care.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1085,"Watch portal. No touch.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1086,"Watching you.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1086,"No theft.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1086,"Kian-Ihrno allows you.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1087,"Watch where you step!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1087,"My precious little children.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1087,"Please grow.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(1087,"I will protect you.");

		}

	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 5))) {
		last_abil = get_current_tick();
		
		if (gf(10,19) == 1) {
			inc_flag(10,23,1);
			}
		}
break;

beginstate 10;
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

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