// ****************************************************************************
//
// Logic 58:  Hallway of Horror II
//
// ****************************************************************************

#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 == 55) {
   position(ego,73,44);
 }
 if (prev_room_no == 59) {
   position(ego,132,85);
   }
 if (prev_room_no == 57) {
   position(ego,17,85);
   }
 if (prev_room_no == 61) {
   position(ego,73,137);
   }

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

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

  if (escaped == 3) {

        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);

        load.view(120);
        set.view(o2,120);
        set.view(o3,120);
        set.view(o4,120);

        position(o2,100,100);
        position(o3,120,120);
        position(o4,60,60);

        wander(o2);
        wander(o3);
        wander(o4);

        draw(o2);
        draw(o3);
        draw(o4);

        }

if (escaped == 4) {
        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);
        load.view(120);
        set.view(o2,120);
        set.view(o3,120);
        set.view(o4,120);
        set.view(o5,120);
        position(o2,100,100);
        position(o3,120,120);
        position(o4,60,60);
        position(o5,80,80);
        wander(o2);
        wander(o3);
        wander(o4);
        wander(o5);
        draw(o2);
        draw(o3);
        draw(o4);
        draw(o5);
    }
  }

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

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

if (said("look")) {
  print("This is the stained and gray hallway connecting the horrific cells in this institution.");
    if (escaped == 0) {
        print("You see some kind of needle monster prowling around.");
        }
    if ((escaped == 3 ||
         escaped == 4)) {
         print("The Orderly is being harrassed by the inmates you have freed, but you're still not sure that it's safe to cross the hall.");
         }
}

if ((said("look","man") ||
     said("look","creature") ||
     said("look","thing") ||
     said("look","people"))) {
          if (escaped == 0) {
              print("This must be The Orderly.  He is a giant, walking syringe full of mind-numbing chemicals.  It would be best to keep your distance.");
              }
          if ((escaped == 3 ||
               escaped == 4)) {
          print("The inmates seem to be having a heck of a time.  Part of you feels sorry for the Orderly...  but not a very large part.");
          }
      }

if ((said("attack","man") ||
     said("attack","creature") ||
     said("attack","thing"))) {
          if (escaped == 0) {
              print("Ooooh, I don't think so.  He looks rather scary.");
              }
          if ((escaped == 3 ||
               escaped == 4)) {
                  print("The inmates seem to be doing a great job of keeping him occupied.");
                  }
             }

if ((said("talk","man") ||
     said("talk","creature") ||
     said("talk","thing"))) {
          if (escaped == 0) {
              print("Orderly: \"I am the Orderly.  None shall pass this hallway without my approval.  Get back to your cell, little one.\"");
              }
          if ((escaped == 3 ||
               escaped == 4)) {
                 print("Inmates: \"La la la...  we're free!  We're free!\"");
                 print("Orderly: \"Aargh!  Get back to your cells, you fools!\"");
                 }
          }



if (ego_touching_signal_line) {
    if (new_ego_x>90) {
        new.room(59);
        }
    if (new_ego_x<90) {
        new.room(57);
        }
    }

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

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

if (food_puzzle < 3) {
  if (ego_on_water) {
    if ((escaped == 0 ||
         escaped == 3 ||
         escaped == 4)) {
         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 (sound_flag) {
    sound(36, sound_flag);
    }

return();