// ****************************************************************************
//
// Logic 80: Underwater Treasure
//
// ****************************************************************************

#include "defines.txt"

if (new_room) {
  load.pic(room_no);
  draw.pic(room_no);
  discard.pic(room_no);
  set.horizon(1);


// Check what room the player came from and position them on the
// screen accordingly here, e.g:
// if (prev_room_no == 5) {
//   position(ego,12,140);
// }
  if (!has("fragment one") &&
      !has("amulet") &&
      !chthugone) {
      animate.obj(o1);
      load.view(fragment_one);
      set.view(o1,fragment_one);
      set.loop(o1,1);
      position(o1,125,158);
      draw(o1);
      }


        load.sound(12);
  sound(12, sound_flag);

  draw(ego);
  show.pic();
}

distance(o1,ego,range);

if (said("look")) {
  print("You are deep in the artificial night of these Stygian waters.");
  if (range<=25 &&
      !has("fragment one") &&
      !has("amulet") &&
      !chthugone) {
          print("There seems to be a fragment of an amulet down here!");
          }
}

if ((said("take","amulet") ||
     said("take","shard"))) {
    if (range<=10 &&
        !has("fragment one") &&
        !has("amulet") &&
        !chthugone) {
             get("fragment one");
             print("You pick the fragment up off the sea floor.");
             new.room(80);
             }
        else {
            print("You need to come up for air, you're obviously delusional.");
            }
        }

if ((said("look","fragment") ||
     said("look","shard"))) {
        if (!has("fragment one")) {
            print("You see a glittering golden fragment.");
            }
        else {
            show.obj(fragment_one);
            }
        }

if (ego_edge_code == horizon_edge) {  // ego touching horizon
  new.room(76);
}

//if (ego_edge_code == right_edge) {    // ego touching right edge of screen
  //new.room(75);
//}

//if (ego_edge_code == bottom_edge) {   // ego touching bottom edge of screen
  //new.room(78);
//}

if (ego_edge_code == left_edge) {     // ego touching left edge of screen
  new.room(79);
}

call (201);

return();