// ****************************************************************************
//
// Logic 57:  Hallway of Horror I
//
// ****************************************************************************

#include "defines.txt"

if (new_room) {
  universe=55;
  load.pic(universe);
  draw.pic(universe);
  discard.pic(universe);
  set.horizon(37);

// Check what room the player came from and position them on the
// screen accordingly here, e.g:
 if (prev_room_no == 54) {
   position(ego,73,44);
 }
 if (prev_room_no == 58) {
   position(ego,132,85);
   }
 if (prev_room_no == 63) {
   position(ego,17,85);
   }
 if (prev_room_no == 60) {
   position(ego,73,137);
   }
 if (food_puzzle < 3) {
  if (escaped == 1) {

      animate.obj(o1); //Inmate
      load.view(120);
      set.view(o1,120);
      position(o1,80,80);
      wander(o1);
      draw(o1);

       animate.obj(o3); //Orderly
      load.view(111);
      set.view(o3,111);
      position(o3,60,60);
      wander(o3);
      draw(o3);
      }

  if (escaped == 2) {

       animate.obj(o1); //Inmate
      load.view(120);
      set.view(o1,120);
      position(o1,80,80);
      wander(o1);
      draw(o1);

      animate.obj(o2); //Inmate
      set.view(o2,120);
      position(o2,100,100);
      wander(o2);
      draw(o2);

      animate.obj(o3); //Orderly
      load.view(111);
      set.view(o3,111);
      position(o3,60,60);
      wander(o3);
      draw(o3);
      }
   }

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

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

if (said("look")) {
  print("This is a hallway filled with the echoes of tortured souls.");
  if ((escaped == 1 ||
       escaped == 2)) {
         print("You see that Orderly thing chasing about the inmate(s).");
         }
}

if ((said("look","man") ||
     said("look","creature") ||
     said("look","thing") ||
     said("look","people"))) {
     if ((escaped == 1 ||
          escaped == 2)) {
              print("All involved seem to be having a grand time...  except for the Orderly, who is furious.");
              }
         }

if ((said("attack","man") ||
     said("attack","creature") ||
     said("attack","thing"))) {
          if ((escaped == 1 ||
               escaped == 2)) {
                   print("No, you shouldn't do that.  Besides, the inmates are keeping him busy.");
                   }
          else {
              print("There is no one here!");
              }
          }

if ((said("talk","man") ||
     said("talk","creature") ||
     said("talk","thing"))) {
        if ((escaped == 1 ||
             escaped == 2)) {
          print("Inmates: \"La la la...  we're free, you silly needle!\"");
          print("Orderly: \"Get back in your cells!  NOW!\"");
          }
        else {
           print("Echo...  echo...  echo...");
           }
        }

if (ego_touching_signal_line) {
    if (new_ego_x>90) {
        new.room(58);
        }
    if (new_ego_x<90) {
        new.room(63);
        }
    }

if (food_puzzle < 3) {
  if (ego_on_water) {
    if ((escaped == 1 ||
         escaped == 2)) {
         print("He won't let you past!!");
          if (ego_dir == 1) { ego_dir = 5; }
             else { if (ego_dir == 5) { ego_dir = 1; }}
             if (ego_dir == 2) { ego_dir = 6; }
             else { if (ego_dir == 6) { ego_dir = 2; }}
             if (ego_dir == 3) { ego_dir = 7; }
             else { if (ego_dir == 7) { ego_dir = 3; }}
             if (ego_dir == 4) { ego_dir = 8; }
             else { if (ego_dir == 8) { ego_dir = 4; }}
 //          range = room_no;
 //          new.room(204);
         }
    }
   }

if (new_ego_y<44) {
    new.room(54);
    }

if (new_ego_y>140) {
    new.room(60);
    }

if (sound_flag) {
    sound(36, sound_flag);
    }

return();