// .txt

beginzonescript;

variables;

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

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();


	add_range_to_group(15672,15678,31);
	set_name(30031,"Crystal Wisp");
	set_level(30031,3);
	set_name(15678,"Glowing Wisp");
	change_max_health(15678,50);
	set_new_abil(15678,15);

	set_name(15679,"Red Radiant Shade");
	set_coloradj(15679,1);
	set_boss_level(15679,1);
	set_new_abil(15679,10);
	place_particle_num(15679,18,12,6);		
	place_particle_num(15679,18,13,6);		

	set_name(15680,"Green Radiant Shade");
	set_coloradj(15680,2);
	set_boss_level(15680,1);
	set_new_abil(15680,3);
	place_particle_num(15680,17,12,6);		
	place_particle_num(15680,17,13,6);		

	set_name(15697,"Ressela");
	set_name(15705,"Sage Angela");
	set_name(15706,"Portmaster Bronner");
	set_name(15707,"Sergeant Ethan");

	set_crime_tolerance(max_crime);

	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((gf(49,6) > 0) && (gf(171,17) == 0) && (gf(170,8) > 0)) {
		sf(171,17,1);
		print_str_color("The pylon in northern Avernum has been completed, and you",3);
		print_str_color("  are now attuned to it.",3);
		}
		
	if ((gf(170,7) > 0) && (gf(145,24) == 0)) {
		counter2 = counter2 + 1;
		if (counter2 == 2) {
			sf(145,24,1);
			begin_talk_mode(19);
			}
		}
	
	if (gf(170,1) >= 6)
		sf(145,10,1);
		
	if ((get_crime_level() >= max_crime) && (im_hostile == 0)) {
		make_zone_hostile(); 
		im_hostile = 1;
		//erase_char(30000);
		begin_talk_mode(299);
		}

	if (gf(145,9) < 7) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"Stop them!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"Get the wisps!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"Those! Kill them!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15706,"Help at last!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15706,"You must help me.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15706,"The wisps are downstairs.");
		}
	if (gf(145,9) >= 7) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"Safe at last.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"It's tricky work.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"Don't touch anything.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15705,"Stay away from there!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15706,"The portal is simple.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15706,"Disasters are rare.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15706,"No need to worry.");
		}
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(15707,"The buzzing ...");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(15707,"Never stops ...");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(15707,"Need more ale.");


	//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;
break;

beginstate 11;
	if (gf(170,1) < 6)
		set_terrain_string_range("The gate into the Portal Keep is closed. As you approach, a guard comes out to question you. Once he learns that you have no orders allowing you to enter, you are turned away.",1);
break;


beginstate 12;
break;

beginstate 13;
	set_terrain_string_range("The sign says - Portalmaster's Office.",1);
break;

beginstate 15;
	//if ((char_ok(7906)) && (get_attitude(7906) >= 10)) {
	//	print_str_color("It's not safe to use the portal when you're in a fight.",2);
	//	end();
		//}
	if (gf(170,2) == 0) 
		begin_talk_mode(11);
	run_teleport();
break;

beginstate 30;
		if (revive_party()) {
			print_str_color("Entering or leaving the Portal Keep heals your wounds",2);
			print_str_color("  and restores your spell energy.",2);
			}
break;

beginstate 20;
	if (is_combat() == FALSE)
		print_str_color("You climb the stairs.",2);
	change_level(359,647,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(355,650,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);
