// .txt

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 200;
short last_abil;
short counter = 0;
short delay1 = 0;
short delay2 = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	set_name(17290,"Cleaver Crog");
	set_boss_level(17290,1);
	set_new_abil(17920,10);
	
	add_range_to_group(17299,17304,37);
	set_aggression(30037,40);
	
	add_range_to_group(17305,17308,38);

	set_name(17316,"Drexa Eyebite");
	set_boss_level(17316,1);

	set_name(17330,"Hrrrma");
	set_level(17330,3);
	change_max_health(17330,25);
	set_new_abil(17330,10);
	
	add_range_to_group(17340,17343,39);
	set_name(17343,"Warmaster Gella");
	set_boss_level(17343,1);
	set_new_abil(17343,20);
	
	set_crime_tolerance(max_crime);

	add_range_to_group(17384,17387,40);

	sf(160,10,0);
	sf(160,11,0);
	sf(160,12,0);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	// vanderin stuff
	if ((gf(160,2) == 3) && (char_ok(17298)) && (char_present(17298) == FALSE)) {
		telep_char_to_char(17298,random_group_member(0),0);
		}
		
	//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 ((char_ok(17368)) && (get_health(17368) < get_max_health(17368) - 20)) {
               print_str_color("Once he realizes that you can hurt him from here, Trinket",3);
               print_str_color("  backs away a bit.",3);
               erase_char(17368);
               }

	if (tick_difference(last_abil,get_current_tick()) > 0) {
		last_abil = get_current_tick();
		
		// track 1
		if ((gf(160,10) > 0) && (gf(160,10) < 10)) {
			if (delay1 == 0) { // kludge in an extra turn
				delay1 = 1;
				end();
				}
			
			play_sound(255);
			shift_game_rect(744,413,748,426,3);
			set_terrain(1,413,745,252);
			set_terrain(1,413,747,252);
			set_terrain(1,428,745,0);
			set_terrain(1,428,747,0);

			inc_flag(160,10,1);
			print_str_color("The platform slowly moves along the tracks.",2);
			
			if (gf(160,13) == 0) {
				if (gf(160,10) == 2) {
					print_str_color("More bats fly down to the platform.",2);
					spawn_creature(17349);
					telep_char_to_char(17349,random_group_member(0),0);
					spawn_creature(17350);
					telep_char_to_char(17350,random_group_member(0),0);
					}
				if (gf(160,10) == 3) {
					spawn_creature(17351);
					telep_char_to_char(17351,random_group_member(0),0);
					spawn_creature(17352);
					telep_char_to_char(17352,random_group_member(0),0);
	
					spawn_creature(17367);
					spawn_creature(17368);
					set_name(17368,"Lord Trinket");
					change_max_health(17368,50);
					set_boss_level(17368,2);
					set_char_unkillable(17368,1);
					
					begin_talk_mode(175);
					}
				if (gf(160,10) == 4) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17353);
					telep_char_to_char(17353,random_group_member(0),0);
					spawn_creature(17354);
					telep_char_to_char(17354,random_group_member(0),0);
					
					set_level(17353,1);
					set_level(17354,1);
					}
				if (gf(160,10) == 5) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17355);
					telep_char_to_char(17355,random_group_member(0),0);
					spawn_creature(17356);
					telep_char_to_char(17356,random_group_member(0),0);
					
					set_level(17355,1);
					set_level(17356,1);
					}
				if (gf(160,10) == 6) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17357);
					telep_char_to_char(17357,random_group_member(0),0);
					spawn_creature(17358);
					telep_char_to_char(17358,random_group_member(0),0);
					
					set_level(17357,1);
					set_level(17358,1);
					}
				if (gf(160,10) == 7) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17359);
					telep_char_to_char(17359,random_group_member(0),0);
					spawn_creature(17360);
					telep_char_to_char(17360,random_group_member(0),0);
					
					erase_char(17367);
					erase_char(17368);

					set_level(17359,1);
					
					begin_talk_mode(176);
					}
				
				if (gf(160,10) == 8) {
					print_str_color("More bats fly down to the platform.",2);
					spawn_creature(17361);
					telep_char_to_char(17361,random_group_member(0),0);
					spawn_creature(17362);
					telep_char_to_char(17362,random_group_member(0),0);
					}
				
				if (gf(160,10) == 9) {
					print_str_color("More bats fly down to the platform.",2);
					spawn_creature(17363);
					telep_char_to_char(17363,random_group_member(0),0);
					spawn_creature(17364);
					telep_char_to_char(17364,random_group_member(0),0);
					spawn_creature(17365);
					telep_char_to_char(17365,random_group_member(0),0);
					}
				if (gf(160,10) == 10) {
					award_party_xp(200,2);
					sf(160,13,1);
					begin_talk_mode(179);
					}
				}
			}
			
		// track 2
		if ((gf(160,11) > 0) && (gf(160,11) < 10)) {
			if (delay2 == 0) { // kludge in an extra turn
				delay2 = 1;
				end();
				}
				
			play_sound(255);
			shift_game_rect(726,437,740,441,0);
			set_terrain(1,438,740,251);
			set_terrain(1,440,740,251);
			set_terrain(1,438,725,0);
			set_terrain(1,440,725,0);

			inc_flag(160,11,1);
			print_str_color("The platform slowly moves along the tracks.",2);
			
			if (gf(160,14) == 0) {
				if (gf(160,11) == 4) {
					print_str_color("More goblins leap onto the platform.",2);
					spawn_creature(17353);
					telep_char_to_char(17353,random_group_member(0),0);
					spawn_creature(17354);
					telep_char_to_char(17354,random_group_member(0),0);

					begin_talk_mode(185);
					}
				if (gf(160,11) == 5) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17355);
					telep_char_to_char(17355,random_group_member(0),0);
					spawn_creature(17356);
					telep_char_to_char(17356,random_group_member(0),0);
					}


				if (gf(160,11) == 6) {
					spawn_creature(17374);
					telep_char_to_char(17374,random_group_member(0),1);
					set_name(17374,"Oozing Zombie");
					set_level(17374,2);
					set_coloradj(17374,512);
					
					begin_talk_mode(186);
					}
					

				if (gf(160,11) == 7) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17357);
					telep_char_to_char(17357,random_group_member(0),0);
					spawn_creature(17358);
					telep_char_to_char(17358,random_group_member(0),0);
					}
				if (gf(160,11) == 8) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17359);
					telep_char_to_char(17359,random_group_member(0),0);
					spawn_creature(17360);
					telep_char_to_char(17360,random_group_member(0),0);
					begin_talk_mode(176);
					}
				
				if ((gf(160,11) == 9) && ((char_ok(17353) == FALSE) || (char_ok(17354) == FALSE))) {
					print_str_color("More goblins try to leap across the chasm.",2);
					print_str_color("Some of them actually succeed.",2);
					spawn_creature(17361);
					telep_char_to_char(17361,random_group_member(0),0);
					spawn_creature(17362);
					telep_char_to_char(17362,random_group_member(0),0);
					}
				if (gf(160,11) == 10) {
					award_party_xp(200,2);
					sf(160,14,1);
					erase_char(17369);
					erase_char(17370);
					erase_char(17371);
					erase_char(17372);
					erase_char(17373);
					begin_talk_mode(187);
					}
				}
			}


		}
break;

beginstate 10;
	set_terrain_string_range("Miners used to live in this stone hut. Then the goblins moved in.",1);
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

beginstate 20;
	change_level(398,753,4);
break;

beginstate 21;
	change_level(396,761,0);
break;

beginstate 22;
	change_level(391,727,2);
break;

beginstate 23;
	change_level(395,742,6);
break;

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