// TOWN SPECIAL ENCOUNTERS
//    Town 15: Portal Fortress

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 200;
short last_abil;
short counter = 0;
short set_ter = 0;

body;

//123 45


beginstate INIT_STATE;
	last_abil = get_current_tick();

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

	set_aggression(30001,60);
	set_aggression(30002,60);
	set_aggression(30003,60);
	set_aggression(30004,60);
	set_aggression(30005,60);
	set_aggression(30006,60);
	set_aggression(30007,60);
	
	set_name(1545,"Commander Fuqua");
	
	set_name(1510,"Cultist Analay");
	set_boss_level(1510,1);
	
	set_name(1517,"Crystalworker Alane");
	set_boss_level(1517,1);
	set_name(1518,"Crystalworker Bai");
	set_boss_level(1518,1);

	set_name(30007,"Mutant Burnhound");
	set_boss_level(30007,1);
	set_attack_bonus(30007,25);

	set_name(12601,"Portalmaster Chael");
	set_name(12602,"Portalmaster Tyus");
	set_new_abil(12602,9);
	set_name(12603,"Portalmaster Foran");
	set_new_abil(12603,20);
	
	set_boss_level(12601,2);
	set_boss_level(12602,2);
	set_boss_level(12603,2);
	set_attack_bonus(12601,20);
	set_attack_bonus(12602,20);
	set_attack_bonus(12603,20);
	set_resistance(12601,0,80);
	set_resistance(12602,1,80);
	set_resistance(12602,2,80);
	set_resistance(12603,6,80);
	
	set_boss_level(12600,1);
	set_boss_level(12609,1);
	
	set_crime_tolerance(max_crime);

	if (gf(15,11) > 0) {
		kill_object(6126,1);
		kill_object(6129,1);
		
		set_terrain(0,31,55,204);
		set_terrain(0,34,55,205);
		
		set_terrain(0,30,38,204);
		set_terrain(0,30,39,0);
		set_terrain(0,30,40,0);
		set_terrain(0,30,41,205);
		
		set_terrain(0,35,44,204);
		set_terrain(0,35,45,0);
		set_terrain(0,35,46,0);
		set_terrain(0,35,47,205);

		set_terrain(0,14,56,204);
		set_terrain(0,15,56,0);
		set_terrain(0,16,56,0);
		set_terrain(0,17,56,205);

		set_terrain(0,48,56,204);
		set_terrain(0,49,56,0);
		set_terrain(0,50,56,0);
		set_terrain(0,51,56,205);
		
		set_terrain(0,11,18,71);
		set_terrain(0,12,18,72);
		set_terrain(0,13,18,73);
		}
	break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
	if ((set_ter == 0) && (gf(15,11) > 0)) {
		set_ter = 1;
		kill_object(6292,1);
		set_terrain(0,51,15,204);
		set_terrain(0,43,7,204);
		set_terrain(0,59,7,204);
		}

	if ((gf(15,11) == 0) && (gf(15,8) > 0)) {
		if ((gf(126,20) == 0) && (gf(15,8) < 145)) {
			sf(126,20,1);
			run_game_hardcode(1);
			}
		if ((gf(126,21) == 0) && (gf(15,8) < 100)) {
			sf(126,21,1);
			run_game_hardcode(1);
			}
		if ((gf(126,22) == 0) && (gf(15,8) < 60)) {
			sf(126,22,1);
			run_game_hardcode(1);
			}
		if ((gf(126,23) == 0) && (gf(15,8) < 30)) {
			sf(126,23,1);
			run_game_hardcode(1);
			}
		if ((gf(126,24) == 0) && (gf(15,8) < 10)) {
			sf(126,24,1);
			run_game_hardcode(1);
			}
		}
break;

beginstate 10;
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

beginstate 14;
break;

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

