// .txt

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 200;
short last_abil;
short counter = 0;
short i,j;
short ozimus = 0;
short mess1 = 0;
short did_spawn = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

//	set_name(,"");

	add_range_to_group(6697,6702,19);
	set_name(30019,"Marauder Warrior");
	set_aggression(30019,60);
	set_name(6702,"Firecaster Marauder");
	add_range_to_group(6703,6708,20);
	set_aggression(30020,60);
	set_name(30020,"Marauder Warrior");
	set_name(6708,"Firecaster Marauder");
	
	set_name(6709,"Cultist Dreva");
	set_boss_level(6709,1);
	
	add_range_to_group(6712,6718,21);
	set_aggression(30021,60);
	set_name(30021,"Marauder Guard");
	set_name(6718,"Marauder Tergia");
	set_boss_level(6718,1);
	
	sf(62,24,0);
	sf(62,8,0);
	sf(62,16,0);
	sf(62,18,0);
	sf(62,20,0);
		
	set_name(6744,"Vicious Quickghast");
	set_name(6745,"Vicious Quickghast");
	set_level(6744,30);
	set_level(6745,30);
	set_new_abil(6744,20);
	set_new_abil(6745,20);
	alter_stat(6744,19,12);
	alter_stat(6744,28,4);
	alter_stat(6745,19,12);
	alter_stat(6745,28,4);
	
	set_aggression(6744,75);
	set_aggression(6745,75);
	set_aggression(6746,75);
	set_aggression(6747,75);
	set_aggression(6748,75);
	set_aggression(6749,75);
	
	set_name(6763,"Mindwarp Hellhound");
	set_name(6764,"Lightning Hellhound");
	set_level(6763,30);
	set_boss_level(6763,1);
	set_level(6764,30);
	set_boss_level(6764,1);
	
	set_crime_tolerance(max_crime);

	sf(62,9,0);
	
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	
	if ((char_ok(6719) == FALSE) && (char_ok(6720) == FALSE) && (char_ok(6721) == FALSE) && (char_ok(6722) == FALSE) && (gf(62,21) == 0)) {
		sf(62,21,1);
		print_str_color("Now that the apprentices are dead, the magic barrier they",3);
		print_str_color("  were maintaining crumbles.",3);
		
		}
		
	//if ((get_crime_level() >= max_crime) && (im_hostile == 0)) {
	//	make_zone_hostile();
	//	im_hostile = 1;
	//	}

	// if (gf(,) == 0) {
	//if (get_ran(1,0,100) < 10)
	//	give_char_text_bubble(,"");
	//	}

	if ((on_which_layer() == 1) && (gf(62,22) > 0) && (gf(62,1) == 0) && (did_spawn == 0)) {
		did_spawn = 1;
		spawn_creature(6734);
		spawn_creature(6735);
		spawn_creature(6736);
		spawn_creature(6737);
		set_level(6735,18);
		set_level(6736,18);
		set_level(6737,18);
		}
		
	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();
		
		// upper apprentices
		if (gf(62,24) >= 5) {
			sf(62,24,0);
			
			if (char_ok(6723) == FALSE) {
				print_str_color("The apprentices have called a demon!",3);
				spawn_creature(6723);
				set_level(6723,20);
				place_particle_num(6723,1,1,8);
				}
			else if (char_ok(6724) == FALSE) {
				print_str_color("The apprentices have called a demon!",3);
				spawn_creature(6724);
				set_level(6724,20);
				place_particle_num(6724,1,1,8);
				}
			else if (char_ok(6725) == FALSE) {
				print_str_color("The apprentices have called a huge, terrifying demon!",3);
				spawn_creature(6725);
				set_level(6725,25);
				set_name(6725,"Infernal Reaper");
				set_boss_level(6725,2);
				set_new_abil(6725,20);
				place_particle_num(6725,1,1,8);
				}
			}
		
		// lower shards
		if ((gf(62,8) > 0) && (on_which_layer() == 1)) {
			i = 0;
			j = 0;

			if ((gf(62,26) == 0) && (get_ran(1,0,100) < 50) && (party_dist_to_spot(405,293) <= 30) && (i == 0)) {
				if (char_ok(6726) == FALSE)
					i = 6726;
					else if (char_ok(6727) == FALSE)
						i = 6727;
				if (party_dist_to_spot(405,293) <= 8)
					j = 1;
				}

			if ((gf(62,27) == 0) && (get_ran(1,0,100) < 30) && (party_dist_to_spot(412,306) <= 30) && (i == 0)) {
				if (char_ok(6728) == FALSE)
					i = 6728;
					else if (char_ok(6729) == FALSE)
						i = 6729;
				if (party_dist_to_spot(412,306) <= 8)
					j = 1;
				}

			if ((gf(62,28) == 0) && (gf(62,9) > 0) && (get_ran(1,0,100) < 70) && (party_dist_to_spot(423,312) <= 35) && (i == 0)) {
				if (char_ok(6730) == FALSE)
					i = 6730;
					else if (char_ok(6731) == FALSE)
						i = 6731;
				if (party_dist_to_spot(423,312) <= 8)
					j = 1;
				}

			if ((gf(62,29) == 0) && (gf(62,9) > 0) && (get_ran(1,0,100) < 70) && (party_dist_to_spot(427,300) <= 30) && (i == 0)) {
				if (char_ok(6732) == FALSE)
					i = 6732;
					else if (char_ok(6733) == FALSE)
						i = 6733;
				if (party_dist_to_spot(427,300) <= 8)
					j = 1;
				}

			if (i > 0) {
				spawn_creature(i);
				set_boss_level(i,-1);
				set_summon_level(i,1);
				place_particle_num(i,1,1,8);
				print_str_color("You hear a sharp, lightning sound. The air gets even colder.",2);
				if (j > 0)
					print_str_color("  A nearby crystal pulls another shade out of the pit.",2);
				}

			}
		
		// noc hunters
		if ((char_ok(6750)) && (gf(62,16) > 0)) {
			i = get_ran(1,0,3);
			if (char_ok(6751 + i) == FALSE) {
				spawn_creature(6751 + i);
				set_name(6751 + i,"Hunter of Nociduas");
				set_boss_level(6751 + i,-1);
				set_summon_level(6751 + i,1);
				place_particle_num(6751 + i,1,1,8);
				
				}
			}
		
		// party servants
		if ((gf(62,16) > 0) && (gf(62,6) == 0) && (char_ok(6755) == FALSE) &&  (char_ok(6756) == FALSE) &&  (char_ok(6757) == FALSE) &&  (char_ok(6758) == FALSE) && (party_dist_to_spot(425,285) <= 1)) {	
			i = get_ran(1,0,3);
			if (char_ok(6759 + i) == FALSE) {
				spawn_creature(6759 + i);
				place_particle_num(6759 + i,1,1,8);
				set_level(6759 + i,30);
				set_boss_level(6759 + i,-1);
				set_attack_bonus(6759 + i,15);
				}
			if (mess1 == 0) {
				mess1 = 1;
				begin_talk_mode(18);
				}
			}
		}
	
	if ((gf(62,18) == 1) && (is_talking() == FALSE)) {
		sf(62,18,2);
		begin_talk_mode(17);
		
		}
break;

beginstate 10;
	sf(62,8,1);
break;

beginstate 11;
	if ((ozimus == 0) && (char_ok(6734))) {
		ozimus = 1;
		set_attitude(6734,11);
		set_attitude(6735,10);
		set_attitude(6736,10);
		set_attitude(6737,10);
		begin_talk_mode(16);
		}
break;

beginstate 12;
	sf(62,20,1);
break;

beginstate 13;
	sf(62,9,1);
break;

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