// .txt

beginzonescript;

variables;

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

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	if (gf(148,10) > 0) {
		set_terrain(1,542,663,15);
		set_terrain(1,543,663,16);
		set_terrain(1,544,663,17);
		}
		
	sf(148,11,0);
	sf(148,14,0);
	sf(148,15,0);
	sf(148,16,0);
	sf(148,17,0);
	
	set_level(16024,13);
	set_name(16024,"Cultist Amla");		
	if (gf(148,1) > 0)
		erase_char(16024);
	
	set_aggression(16025,75);
	set_aggression(16026,75);
	set_aggression(16027,75);
	set_aggression(16028,75);
	set_name(16032,"Ratcaller Demon");
	set_level(16032,20);
	
	set_name(16037,"Mayor Regan");
	set_name(16038,"Edmund");
	set_name(16039,"Edgar");
	set_name(16040,"Abbot Erlanger");
	set_name(16041,"Noam");
	set_name(16042,"Kelagan");
	if ((gf(149,18) == 0) && (gf(163,1) > 0))
		erase_char(16042);
		
	set_name(16043,"Tardiff");
	set_name(16044,"Gate Guard");
	set_name(16045,"Gate Guard");
	set_name(16046,"Commander Horrmarin");
	set_name(16047,"Tancrid");
	set_name(16048,"Serilda");

	
	add_range_to_group(16012,16016,31);

	add_range_to_group(16049,16056,32);
	add_range_to_group(16057,16062,33);
	set_name(30032,"Almaria Guard");
	set_name(30033,"Almaria Guard");

	add_range_to_group(16063,16068,34);
	set_name(30034,"Merchant");

	add_range_to_group(16069,16075,35);
	set_name(30035,"Refugee");

	set_crime_tolerance(max_crime);

	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
		
	if ((get_crime_level() >= max_crime) && (im_hostile == 0)) {
		make_zone_hostile(); 
		im_hostile = 1;
		//erase_char(30000);
		begin_talk_mode(299);
		}

	if (gf(149,21) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"I am very busy.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"I can't talk to you.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"Don't make me call the guards.");
		}
	if (gf(149,21) == 1) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"They will kill the prisoners.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"You must be careful.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"Gather more information.");
		}

	if (gf(149,21) == 2) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"You have saved us.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16037,"We are all grateful.");
		}


	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16038,"Be calm.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16038,"We must be patient.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16038,"Here. Take this.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16038,"I will speak with you.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16038,"We must not panic.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16039,"Spare a copper?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16039,"Please?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16039,"I am so hungry.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16040,"We will always fight.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16040,"Ah! A warrior!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16040,"No surrender!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16040,"You are welcome here.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16040,"I can teach you.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16041,"Care for some wine?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16041,"Sample our wares.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16041,"It's truly bearable!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16041,"It is in no way poison!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16043,"I watch the gate.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16043,"Hee hee!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16043,"Ten for people.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16043,"Fifteen for wagons.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16046,"What is it?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16046,"What now?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16046,"Hrrrrr.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16046,"Mrrrr?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16047,"Why are you in here?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16047,"You're moving on soon?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16047,"No rooms free.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16048,"The roads are deadly!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16048,"So much danger!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16048,"Let me help you!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(16048,"Best to be armed.");
	if (gf(170,1) < 12) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"When is the lottery?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"Go to the portal.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"I'm going to the surface.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"I'm hungry.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"New food shipment arrived?");
		}
	if (gf(170,1) >= 12) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"We're doomed!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"So hungry.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"There's no hope.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"Edmund can't help us.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16069 + get_ran(1,0,6),"We've been forgotten.");
		}


	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();
		
		timer = timer + 1;
		if (timer >= 10) {
			timer = 0;
			if (gf(149,16) == 0)
				sf(149,16,1);
				else sf(149,16,0);
			}
		}
break;

beginstate 10;
break;

beginstate 11;
	set_terrain_string_range("The sign says - MERCHANT'S BAZAAR.",1);
break;

beginstate 12;
	set_terrain_string_range("The sign says - Training Hall.",1);
break;

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

beginstate 14;
	set_terrain_string_range("The sign says - Pay Bridge Toll Here. No haggling!",1);
break;

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

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