// .txt

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 200;
short last_abil;
short counter = 0;
short set_wall = 0;
short i;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

//	set_name(,"");

	sf(12,25,0);

	sf(12,26,0);
	sf(12,27,0);
	sf(12,28,0);
	sf(12,29,0);
	
	add_range_to_group(1405,1410,7);
	set_name(30007,"Scourge Flinger");
	set_level(30007,35);
	set_attack_bonus(30007,20);
	alter_stat(30007,28,10);
	alter_stat(30007,29,5);

	add_range_to_group(1411,1418,8);
	set_level(30008,35);
	set_name(1411,"Scourge Defender");
	set_name(1412,"Scourge Defender");
	set_name(1413,"Scourge Defender");
	set_name(1414,"Scourge Defender");
	set_name(1415,"Scourge Cultist");
	set_name(1416,"Scourge Cultist");
	set_name(1417,"Augmented Warlizard");
	set_name(1418,"Augmented Warlizard");
	alter_stat(1417,29,5);
	alter_stat(1418,29,5);
	
	set_name(1419,"Warped Vahnavoi");
	set_name(1420,"Warped Vahnavoi");
	set_name(1421,"Warped Vahnavoi");
	set_name(1422,"Warped Vahnavoi");
	set_name(1423,"Warped Vahnavoi");
	set_name(1424,"Warped Vahnavoi");
	set_name(1425,"Warped Vahnavoi");
	set_name(1426,"Warped Vahnavoi");
	set_name(1427,"Warped Vahnavoi");
	set_name(1428,"Warped Hraithe");
	set_name(1429,"Warped Hraithe");
	set_new_abil(1428,9);
	set_new_abil(1429,9);
	
	set_name(1430,"Vahnatai Revenant");
	set_boss_level(1430,2);
	set_coloradj(1430,128);
	set_aggression(1430,30);
	set_new_abil(1430,5);

	add_range_to_group(1439,1446,9);
	set_name(30009,"Scourge Flinger");
	set_level(30009,35);
	set_attack_bonus(30009,20);
	alter_stat(30009,28,10);
	alter_stat(30009,29,5);

	set_name(1447,"Servant Infernal");
	set_name(1448,"Servant Infernal");
	set_name(1449,"Servant Infernal");
	set_name(1450,"Servant Infernal");
	set_level(1447,32);
	set_level(1448,32);
	set_level(1449,32);
	set_level(1450,32);
	set_new_abil(1447,11);
	set_new_abil(1448,11);
	set_new_abil(1449,11);
	set_new_abil(1450,11);

	set_name(1451,"Augmented Warlizard");
	set_name(1452,"Augmented Warlizard");
	set_level(1451,35);
	set_level(1452,35);

	add_range_to_group(1462,1469,10);
	set_boss_level(30010,2);
	set_new_abil(30010,12);
	set_attack_bonus(30010,25);
	set_act_at_dist(30010,1);
	if (gf(13,12) > 0)
		erase_char(30010);
	
	if (gf(13,9) < 2)
		sf(13,1,0);
		
	set_crime_tolerance(max_crime);

	if ((gf(13,9) > 1) && (set_wall == 0)) {
		set_wall = 1;
			erase_char(30007);
		
		kill_object(2346,1);
			kill_object(2347,1);
			kill_object(2348,1);
			kill_object(2349,1);
			set_terrain(0,840,34,204 + get_ran(1,0,1));
			set_terrain(0,842,34,204 + get_ran(1,0,1));
			set_terrain(0,843,34,204 + get_ran(1,0,1));
			set_terrain(0,841,37,204 + get_ran(1,0,1));
			set_terrain(0,842,37,204 + get_ran(1,0,1));
			set_terrain(0,844,37,204 + get_ran(1,0,1));
			set_terrain(0,839,35,204 + get_ran(1,0,1));
			set_terrain(0,839,36,204 + get_ran(1,0,1));
			set_terrain(0,845,35,204 + get_ran(1,0,1));
			set_terrain(0,845,36,204 + get_ran(1,0,1));
		
			}

	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((is_talking() == FALSE) && (gf(13,10) == 0) && (gf(13,11) > 0) && (gf(13,12) > 0) && (gf(13,13) > 0)) {
		sf(13,10,1);
		award_party_xp(500,40);
		begin_talk_mode(27);
		}
		
	// dragon
	if ((gf(13,9) == 1) && (char_ok(1404) == FALSE) && (on_which_layer() == 0) && (party_dist_to_spot(850,54) <= 6)) {
		spawn_creature(1404);
		begin_talk_mode(12);
		}
		
	
	if (gf(12,26) > 0) {
		if (gf(12,28) > 0) {
			i = 1456;
			while (i <= 1458) {
				if (char_ok(i) == FALSE) {
					spawn_creature(i);
					place_particle_num(i,1,1,8);
					set_level(i,30);
					set_summon_level(i,1);
					set_attack_bonus(i,50);
					set_name(i,"Heartripper Imp");
					set_resistance(i,7,100);
					set_new_abil(i,8);
					force_char_status(i,24,3);
					}
				i = i + 1;
				}
			}
		if (gf(12,29) > 0) {
			i = 1459;
			while (i <= 1461) {
				if (char_ok(i) == FALSE) {
					spawn_creature(i);
					place_particle_num(i,1,1,8);
					set_level(i,30);
					set_summon_level(i,1);
					set_attack_bonus(i,50);
					set_name(i,"Heartripper Imp");
					set_resistance(i,7,100);
					set_new_abil(i,8);
					force_char_status(i,24,3);
					}
				i = i + 1;
				}
			}
		}
		
	//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 (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 5))) {
		counter = counter + 1;
		if (counter == 5) {
			counter = 0;
			if (gf(13,13) == 0) {
				sf(12,23,1);
				sf(12,24,1);
				}
		}
		
		last_abil = get_current_tick();
		}
break;

beginstate 10;
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

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

beginstate 22;
	if (is_combat() == FALSE)
		print_str_color("You climb the stairs.",4);
	change_level(870,36,4);
	// 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);
