begintownscript;

variables;

int i,j,k,r1,choice;

body;

beginstate INIT_STATE;
        put_item_on_spot(39,8,214);
        put_item_on_spot(41,14,214);
        put_item_on_spot(38,16,214);
        put_item_on_spot(36,12,214);
        put_item_on_spot(37,13,214);
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
        //code called every turn
break;

beginstate 10;
        //code
break;

beginstate 11;
        //code
break;

beginstate 12;
        set_terrain(10,6,0);
        set_terrain(6,6,0);
        set_terrain(6,10,0);
        set_terrain(10,10,0);
        if (get_flag(0,0) == 0) {
                reset_dialog();
                add_dialog_str(0,"The unicorns have piled tons of stuff in this part of the cavern. There may be something useful in the piles, but it would take about an hour to search them.",0);
                add_dialog_choice(0,"Search.");
                add_dialog_choice(1,"Leave.");
                choice = run_dialog(0);
        }
        if (choice == 1) {
                reset_dialog();
                add_dialog_str(0,"Near the top of one of the piles, you find a key of an odd design. There are no markings to indicate who made it or where it is supposed to be used. You pocket the key.",0);
                change_spec_item(0,1);
                if (get_skill_total(18) >= 10) {
                        add_dialog_str(1,"Additionally, you find some gems near the bottom of another pile, which are easily worth several hundred coins. You take those as well. Nothing else in this cave is worth having.",0);
                        change_coins(800);
                }
                set_ticks_forward(210);
                set_flag(0,0,1);
                add_dialog_str(4,"Meanwhile...",0);
                run_dialog(1);
                set_total_visibility(1);
                force_view_center(8,8);
                force_instant_terrain_redraw();
                text_bubble_on_char(12,"Humanssss!");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(12,"");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(8,"The Empire must not");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(8,"");
                text_bubble_on_char(8,"become aware of usssss.");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(8,"");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(14,"Their fate will match that");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(14,"");
                text_bubble_on_char(14,"of the earlier groups.");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(14,"");
                text_bubble_on_char(14,"But we shall remain hidden.");
                force_instant_terrain_redraw();
                pause(10);
                text_bubble_on_char(14,"");
                text_bubble_on_char(11,"Yesssss, Sulfras.");
                force_instant_terrain_redraw();
                pause(10);
                force_view_center(char_loc_x(0),char_loc_y(0));
                set_total_visibility(0);
                erase_text_bubbles();
                force_instant_terrain_redraw();
                set_flag(0,1,1);
                set_flag(0,16,1);
                inc_flag(0,18,1);
        }
        if (choice == 2)
                end();
break;

beginstate 13;
        if (get_flag(0,26) != 1) {
                reset_dialog();
                add_dialog_str(0,"You find a cave containing several patches of Healing Herbs, and some fast-growing plants. If you took some of the herbs and came back later, you'd find a new patch.",0);
                set_flag(0,26,1);
                run_dialog(1);
        }
break;