// ****************************************************************************
//
// Logic 8: Cliff Edge
//
// ****************************************************************************

#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 == 204) {
   position(ego,44,46);
 }

  animate.obj(o1);
  load.view(15);
  set.view(o1,15);
  ignore.objs(o1);
  position (o1, 70,109);
  wander(o1);
  draw(o1);

  animate.obj(o2);
  load.view(15);
  set.view(o2,15);
  ignore.objs(o2);
  position (o2, 80,80);
  wander(o2);
  draw(o2);

  animate.obj(o3);
  load.view(mangy_doll);
  set.view(o3,mangy_doll);
  set.priority(o3,15);

  reset(done_flag);

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

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

if (said("look")) {
  print("You are on the edge of a cliff.  You can look down across a lush mahogany forest.");
}

if (said("look","cliff")) {
   print("It's pretty steep.  I would advise against getting too close.");
   }

if (said("look","trail")) {
    print("You see a trail leading up to the plateau to the north.");
    }

if (said("look","rock")) {
    print("A pile of rubble among jutting rocks blocks the way to the south.");
    }

if (said("jump")) {
    print("Life is too precious to be wasted.");
    }    

if ((said("throw","mangy doll","cliff") ||
     said("drop","mangy doll","cliff") ||
     said("throw","doll","cliff") ||
     said("drop","doll","cliff") ||
     said("throw","doll") ||
     said("drop","doll"))) {
          if (has("mangy doll")) {
              temp_x=new_ego_x;
              temp_y=new_ego_y;
              temp_y-=10;
              position.v(o3,temp_x,temp_y);
              draw(o3);

              move.obj(o3,20,90,5,done_flag);
              }
          else {
              if (has("voodoo doll")) {
                  print("No, you seem to be missing something important.");
                  }
              else {
                  print("Maybe you need to lie down for a while.  You must be tired.");
                  }
              }
          }

        if (done_flag) {
              drop("mangy doll");
              erase(o3);
              shake.screen(5);
              print("There is a great disturbance in the force, as if a puppet screamed in terror...");
              print("...  and was at once silenced.");
              score+=3;
              reset(twinkie);
              reset(done_flag);
              }

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

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

if (ego_touching_signal_line) { //Fall off cliff
   new.room(204);
   }

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

return();