// ****************************************************************************
//
// Logic 64: The Shock Room
//
// ****************************************************************************

#include "defines.txt"

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


// Check what room the player came from and position them on the
// screen accordingly here, e.g:
 if (prev_room_no == 63) {
   position(ego,102,87);
 }

 if (prev_room_no == 107) {
   position(ego,80,80);
   }

 if (prev_room_no == 108) {
   position(ego, 80, 80);
   }

  animate.obj(o1); //switch
  load.view(handle);
  set.view(o1, handle);
  set.cel(o1, 0);
  stop.cycling(o1);
  position(o1, 46, 122);
  draw(o1);

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

if (said("look")) {
  print("This is the shock room.  The restraint chair is in the middle of the room, and a large machine looms out of the wall.");

}

if (said("look","chair")) {
    print("That is a restraint chair.  It doesn't look very comfortable.");
    }

if (said("look","machine")) {
    print("According to the label, it's a BrainMelter 3000.");
    print("Wow, that's the top of the line BrainMelter.");
    }

if (said("look","switch")) {
    print("Hmm, there's a label on it that says \"Back to Reality\".");
    }

    if (said("look","vent")) {
    print("There's a stale draft blowing from the vent.  The screws are loose.");
    }

if (said("attack","vent")) {
    print("The cover just slips off.  There's no need to break it.");
    }

if ((said("take","vent") ||
     said("remove","vent"))) {
    print("Three of the screws are loose, but the fourth is still in place.  Moreover, it's a left-handed womple drive, which is impossible to get on Voodoo Island.");
    print("You can probably just open it and climb through.");
    }


if ((said("enter","vent") ||
     said("use","vent") ||
     said("climb","vent") ||
     said("open","vent") ||
     said("get","vent"))) {
    if (obj.in.box(ego, 38, 53, 101, 63)) {
       new.room(107);
      }
    else {
       print("What?!  From here?  Get closer.");
       }
    }
    
if (ego_touching_signal_line) {
    new.room(63);
    }


if (said("use","switch")) {
  distance(o1, ego, range);
  if (range <= 10) {
    if (shattered) {
      set.cel(o1, 1);
      erase(ego);
      animate.obj(o2);
      load.view(24);
      set.view(o2, 24);
      position.v(o2, new_ego_x, new_ego_y);
      draw(o2);
      end.of.loop(o2, done_flag);
      }
    else {
      set.cel(o1, 1);
      erase(ego);
      animate.obj(o2);
      load.view(24);
      set.view(o2, 24);
      position.v(o2, new_ego_x, new_ego_y);
      draw(o2);
      end.of.loop(o2, more_done_flag);
    }
  }
  else {
    print("Perhaps some sort of arm-lengthening exercise would be in order.");
    }

 }

if (done_flag) {
    new.room(108);
    }

if (more_done_flag) {
    new.room(5);
    }

return();