// ****************************************************************************
//
// Logic 59:  Hallway of Horror III
//
// ****************************************************************************

#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 == 56) {
   position(ego,73,44);
 }
 if (prev_room_no == 65) {
   position(ego,132,85);
   }
 if (prev_room_no == 58) {
   position(ego,17,85);
   }
 if (prev_room_no == 62) {
   position(ego,73,137);
   }

if (food_puzzle < 3) {
  if (escaped == 5) {

      animate.obj(o1); //The orderly
      load.view(111);
      set.view(o1,111);
      position(o1,80,80);
      wander(o1);
      draw(o1);

      animate.obj(o2); //The inmates
      animate.obj(o3);
      animate.obj(o4);
      animate.obj(o5);
      animate.obj(o6);
      load.view(120);
      set.view(o2,120);
      set.view(o3,120);
      set.view(o4,120);
      set.view(o5,120);
      set.view(o6,120);
      position(o2,60,60);
      position(o3,100,100);
      position(o4,110,110);
      position(o5,60,100);
      position(o6,100,60);
      wander(o2);
      wander(o3);
      wander(o4);
      wander(o5);
      wander(o6);
      draw(o2);
      draw(o3);
      draw(o4);
      draw(o5);
      draw(o6);

      }

  if (open_office &&
      food_puzzle <2) {
      animate.obj(o7);
      load.view(124);
      set.view(o7, 124);
      position(o7,80, 100);
      wander(o7);
      draw(o7);
      }
  }

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

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

if (said("look")) {
  print("This is a hallway filled with the shadows of tears and screams.");
  if (escaped == 5) {
      print("There's some kind of commotion going on!  The orderly, the inmates, and Nursie are all running around, chasing each other.");
      }
}

if ((said("look","man") ||
     said("look","woman") ||
     said("look","people") ||
     said("look","creature") ||
     said("look","thing"))) {
        if (escaped == 5) {
          print("It is all a chaotic morass.  You are hardly able to tell everyone apart in the confusion.");
          }
        else {
          print("There is no one here right now.");
          }
        }

if ((said("talk","man") ||
     said("talk","woman") ||
     said("talk","people") ||
     said("talk","creature") ||
     said("talk","thing"))) {
         if (escaped == 5) {
             print("Inmates: \"La la la...  Freedom is so sweet!  And once we knock out Nursie, Oh won't that be so sweet!\"");
             print("Nursie: \"Stop this insolent chatter at ONCE!\"");
             print("Orderly: \"Aaargh!!!  I said BACK TO YOUR CELLS!\"");
             }
         else {
             print("No one's home.");
             }
         }

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

if (food_puzzle < 3) {
  if (ego_on_water) {
    if (escaped == 5) {
    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(56);
    }

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

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

return();