// .txt

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 200;
short last_abil;
short counter = 0;
short made_ker = 0;
short alert1 = 0;
short end_spawn = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

//	set_name(,"");
//	add_range_to_group(,,groupn);

	set_crime_tolerance(max_crime);

	sf(40,20,1);
	sf(40,21,1);
	sf(40,13,0);
	sf(40,16,0);
	sf(40,17,1);
	sf(40,18,1);
	
	set_obj_act_at_dist(7204,1);
	set_obj_act_at_dist(7207,1);
	set_obj_act_at_dist(7299,1);
	set_obj_act_at_dist(7300,1);
	set_obj_act_at_dist(7301,1);
	set_obj_act_at_dist(7312,1);
	
	if (gf(40,0) > 0)
		set_terrain(1,827,132,0);

	sf(40,5,0);
	sf(41,23,0);
	
	set_name(4330,"Castle Servant");
	set_name(4331,"Castle Servant");
	set_name(4332,"Horde Cultist");
	
	add_range_to_group(4339,4346,37);
	set_name(30037,"Horde Castle Guard");
	set_name(4344,"Horde Warlizard");
	set_name(4345,"Horde Warlizard");
	set_level(30037,25);

	set_name(4375,"Shaman Kshhh");
	set_level(4375,30);
	set_boss_level(4375,1);

	set_name(4380,"Horde Warlizard");
	set_name(4381,"Horde Warlizard");
	set_name(4382,"Horde Warlizard");

	add_range_to_group(4392,4398,39);
	set_name(30039,"Arena Spectator");
	set_level(30039,28);
	if (gf(170,7) > 0)
		erase_char(30039);

	set_name(4399,"Ghavassa-Oss");
	set_resistance(4399,0,100);
	set_resistance(4399,1,100);
	set_resistance(4399,2,100);
	set_resistance(4399,6,100);
	set_char_unkillable(4399,1);
	if (gf(170,7) > 0)
		erase_char(4399);
		
	if (gf(170,7) == 0) {
		sf(40,6,0);
		sf(40,15,0);
		}
		
	if (gf(170,6) > 0)
		kill_object(7271,1);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((made_ker == 0) && (gf(41,20) == 2) && (on_which_layer() == 0)) {
		spawn_creature(4333);
		made_ker = 1;
		}
		
	// start khrez event
	if ((gf(170,6) == 0) && (gf(41,23) == 0) && (on_which_layer() == 1) && (party_within_dist(794,170,15))) {
		spawn_creature(4320);
		sf(41,23,1);
		sf(40,20,0);
		sf(40,21,0);
		begin_talk_mode(15);
		}
	
	if ((alert1 == 0) && (gf(40,13) > 0)) {
		alert1 = 1;
		set_act_at_dist(4347,1);
		set_act_at_dist(4348,1);
		set_act_at_dist(4349,1);
		set_act_at_dist(4350,1);
		set_act_at_dist(4351,1);
		set_act_at_dist(4352,1);
		}
		
	if ((on_which_layer() == 0) && (gf(40,13) > 0) && (party_dist_to_spot(772,156) > 10)) {
		
		if (char_ok(4353) == FALSE)
			spawn_creature(4353);
		if (char_ok(4354) == FALSE)
			spawn_creature(4354);
		}
		
	if ((on_which_layer() == 0) && (gf(40,13) > 0) && (party_dist_to_spot(801,187) > 10)) {
		
		if (char_ok(4355) == FALSE)
			spawn_creature(4355);
		if (char_ok(4356) == FALSE)
			spawn_creature(4356);
		if (char_ok(4357) == FALSE)
			spawn_creature(4357);
		}
	
	if ((end_spawn == 0) && (gf(170,7) > 0) && (on_which_layer() == 0)) {
		end_spawn = 1;
		activate_hidden_group(38);
		set_name(4358,"Horde Warlizard");
		set_name(4359,"Horde Warlizard");
		set_name(4360,"Young Horde Warrior");
		set_name(4361,"Young Horde Warrior");
		set_courage(4360,40);
		set_courage(4361,40);	
		}
	
	// arena spawns
	if (gf(40,16) > 0) {
		if (gf(170,7) == 0) {
			if (party_dist_to_spot(820,139) > 10) {
				if (char_ok(4383) == FALSE)
					spawn_creature(4383);
				if (char_ok(4384) == FALSE)
					spawn_creature(4384);
				if (char_ok(4385) == FALSE)
					spawn_creature(4385);
				
				}
				else if (gf(40,15) == 1) {
					if ((char_ok(4383) == FALSE) && (char_ok(4384) == FALSE) && (char_ok(4385) == FALSE)) {
						spawn_creature(4383);
						spawn_creature(4384);
						spawn_creature(4385);
						begin_talk_mode(19);
						}
					}
			}
			
		}
		
	//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))) {
	//	last_abil = get_current_tick();
	//	}
break;

beginstate 10;
	sf(40,13,1);
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(784,132,6);
	// direction - 0,1 - north 2,3 - west 4,5 - south 6,7 - east
break;

beginstate 21;
	if (is_combat() == FALSE)
		print_str_color("You climb the stairs.",2);
	change_level(782,132,2);
	// 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);
