// Town script for town 32: control chamber / ? ? ? 2

begintownscript;

variables;

int x,i,j,choice;

body;

beginstate INIT_STATE;

	if (get_flag(32,1) == 1) {
			set_terrain(18,14,388);
			set_terrain(18,16,388);
			}

	if (get_flag(32,0) == 1) {
			set_terrain(14,18,480);
			set_terrain(18,9,483);
			set_terrain(19,9,483);
			set_terrain(20,9,483);
			}
			
	if (get_flag(32,0) == 2) {
			set_terrain(18,9,479);
			set_terrain(19,9,479);
			set_terrain(20,9,479);
			set_terrain(18,21,481);
			set_terrain(19,21,481);
			set_terrain(20,21,481);
			set_terrain(14,18,480);
			}
			
	if (get_flag(32,0) == 3) {
			set_terrain(18,21,477);
			set_terrain(19,21,477);
			set_terrain(20,21,477);
			set_terrain(25,14,482);
			set_terrain(25,15,482);
			set_terrain(25,16,482);
			set_terrain(14,18,480);
			}
	
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	move_to_new_town(31,8,15);
break;

beginstate 11;
	move_to_new_town(33,24,43);
break;

beginstate 12;
	move_to_new_town(34,24,4);
break;

beginstate 13;
	move_to_new_town(35,4,32);
break;

beginstate 14;

// For this panel: if (get_flag(32,1) == 0) then the panel is on. If its 1, its off

if (get_flag(32,1) == 1) {
		message_dialog("Currently, there is no power on the control panel. Somewhere should be a place to give it power again, but it seems you didn't find it, or activated the wrong power source.","");
		end();
		}
	reset_dialog();
	add_dialog_str(0,"You stand in front of a small control panel containing only one button. Do you press it?",0);
	add_dialog_choice(0,"Press it");
	add_dialog_choice(1,"Leave it");
	choice = run_dialog(0);

		if (choice == 1) {
				if (get_flag(32,0) == 0) {
						set_terrain(14,18,480);
						set_terrain(18,9,483);
						set_terrain(19,9,483);
						set_terrain(20,9,483);
						set_terrain(18,14,388);
						set_terrain(18,16,388);
						run_animation_sound(169);
						set_flag(32,0,1);
						set_flag(32,1,1);
						end();
						}
						
				if (get_flag(32,0) == 1) {	
						set_terrain(18,9,479);
						set_terrain(19,9,479);
						set_terrain(20,9,479);
						set_terrain(18,21,481);
						set_terrain(19,21,481);
						set_terrain(20,21,481);
						set_terrain(18,14,388);
						set_terrain(18,16,388);
						run_animation_sound(169);
						set_flag(32,0,2);
						set_flag(32,1,1);
						end();
						}
						
				if (get_flag(32,0) == 2) {
						set_terrain(18,21,477);
						set_terrain(19,21,477);
						set_terrain(20,21,477);
						set_terrain(25,14,482);
						set_terrain(25,15,482);
						set_terrain(25,16,482);
						set_terrain(18,14,388);
						set_terrain(18,16,388);
						run_animation_sound(169);
						set_flag(32,0,3);
						set_flag(32,1,1);
						end();
						}
						
				if (get_flag(32,0) == 3) {
						set_terrain(25,14,478);
						set_terrain(25,15,478);
						set_terrain(25,16,478);
						set_terrain(14,18,484);
						set_terrain(18,14,388);
						set_terrain(18,16,388);
						run_animation_sound(169);
						set_flag(32,0,0);
						set_flag(32,1,1);
						end();
						}
				}
break;

beginstate 15;
if (get_flag(32,2) == 1)
		end();
	message_dialog("It's hot, but nice in this small room. Red marble walls are adorned by big pillars. When you also spot the green glowing gates, your heart sinks to your shoes. Not again...","After you have looked at the glowing gates, while becoming more and more depressed, you see a control panel in a small cabin on a heightening. Maybe its something to turn the gates off.");
	set_flag(32,2,1);
break;