
#include "defines.txt"

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

  if ((prev_room_no == 1 ||    // just come from intro screen
      prev_room_no == 0)) {    // or just started game
    position(ego,99,124);

  animate.obj(o3);
  load.view(4);
  set.view(o3,4);
  set.loop(o3,0);
  set.cel(o3,0);
  position(o3,99,124);
  set.priority(o3,4);
  ignore.objs(o3);
  stop.cycling(o3);
  draw(o3);

  set(f16);
  reset(f17);

  v27=30;
  }

  if (prev_room_no == 4) {
    position(ego,73,109);

  animate.obj(o3);
  load.view(6);
  set.view(o3,6);
  set.loop(o3,0);
  set.cel(o3,6);
  position(o3,73,108);
  set.priority(o3,4);
  ignore.objs(o3);
  stop.cycling(o3);
  draw(o3);

  reverse.loop(o3,f254);
  }

  if (prev_room_no == 3) {
    position(ego,36,116);
    draw(ego);
  }

  show.pic();

  animate.obj(o1);
  load.view(1);
  set.view(o1,1);
  set.loop(o1,0);
  set.cel(o1,0);
  position(o1,75,97);
  set.priority(o1,4);
  ignore.objs(o1);
  if(isset(f16)) {
  draw(o1);
  }

  v255=2;

  if(obj.in.room("Crayon",v255)) {
  animate.obj(o2);
  load.view(2);
  set.view(o2,2);
  set.loop(o2,0);
  set.cel(o2,0);
  position(o2,66,118);
  set.priority(o2,4);
  ignore.objs(o2);
  stop.cycling(o2);
  draw(o2);
  }

  reset(f255);
}

v27--;

if(isset(f254)) {
  reset(f254);
  erase(o3);
  draw(ego);
  stop.motion(ego);
  player.control();
}

if(v27==20) {
   print("Davy Jones is a perfectly ordinary teenager. If a little reclusive, if a little bookish.");
   print("Or at least, things seem that way. Unbeknownst to his parents and to those who know him, Davy Jones has a rather unconventional hobby.");
   print("You've probably guessed what that is already, having read the title.");
}

if(v27==10) {
   print("\"We're off to the toenail convention now, Davy dear,\" calls the mother.");
   print("\"OK mum,\" calls the youthful magician.");
   end.of.loop(o3,f17);
}

if(isset(f17)) {
   reset(f17);
   erase(o3);
   draw(ego);
   print("Now is the time! thinks Davy to himself. They won't be back for a while. Now is the time to finish my greatest work!");
   print("Now is the time to complete the incantation which will put my name up with the greats... Merlin, Slocombe, Johns Dee and Constantine...");
   print("THE DAVY JONES RITUAL OF TRANSDIMENSIONAL TRANSFERENCE!");
   print("... if I can only remember where I put my notes.");
   status.line.on();
   accept.input();
}

if (said("look")) {
  print("You are in the living room of the Jones household. Being religious types they don't have a television, but they do have a bookcase, fireplace and big soft chair.");
  print("Of course, if they ever found out what you got up to with all those candles and goat skulls in the secret basement, you'd be exorcised so fast it'd make your head spin.");
}

if (said("look","chair")) {
  print("It's a very big, very soft chair. It was probably a mistake to test out your 'enlarge' spell on it. Now it even dwarfs your dad. But then, so do you.");
}

if (said("look","bookcase")) {
  print("This expensive oak bookcase is loaded down with various tomes on various subjects. Your personal shelf is full of old, dusty books full of incantations and magic symbols.");
  print("Your parents are religious types. You assured them they were holy books written in Latin and Hebrew, but the reality is a little more unpleasant.");
  v255=2;
  if (obj.in.room("Notebook",v255)) {
       print("You spot your notebook sandwiched between the Liber Paginarum Fulvarum and the Necronomicon.");
  }
}

if (said("look","book")) {
  v255=2;
  if (obj.in.room("Notebook",v255)) {
   print("It's an old school exercise book full of notes on magic.");
  }
  else {
   reset(input_parsed);
  }
}

if (said("get","book")) {
  v255=2;
  if (obj.in.room("Notebook",v255)) {
   if(posn(ego,45,101,66,109)) {
    print("You retrieve your notes.");
    get("Notebook");
    }
    else {
     print("Come a little closer!");
    }
  }
  else {
   print("You don't need any of the other books.");
  }
}

if (said("look","fireplace")) {
  print("It's an old fireplace-effect heater that runs on gas. Your parents think it is, anyway. You have long since adapted it.");
  if(isset(f16)) {
      print("A gas fire is burning merrily in the grate.");
  }
}

if (said("switch","fireplace")) {
  if(posn(ego,65,100,84,109)) {
     if(isset(f16)) {
          print("You twist the knob by the grate, and the fire rapidly dies down.");
          erase(o1);
          reset(f16);
      }
     else {
          draw(o1);
          set(f16);
      }
     }
     else {
     print("Come a little closer!");
   }
}

if (said("look","carpet")) {
  v255=2;
  if(obj.in.room("Crayon",v255)) {
     print("Look at that! Your brother left one of his crayons lying around. How irresponsible.");
  }
  else {
  print("Yuk. The dog's been pissing on it.");
  }
}

if (said("look","crayon")) {
  v255=2;
  if(obj.in.room("Crayon",v255)) {
     print("It's a yellow crayon.");
  }
  else {
  reset(input_parsed);
  }
}

if (said("get","crayon")) {
  v255=2;
  if(obj.in.room("Crayon",v255)) {
      if(posn(ego,61,114,72,123)) {
       erase(o2);
       print("You take the crayon.");
       get("Crayon");
      }
      else {
       print("Come a little closer!");
      }
  }
  else {
  reset(input_parsed);
  }
}

if (said("take","bookcase")) {
  print("Most of these books don't interest you. As for the rest, you don't really need them at the moment.");
}

if ((said("sit") ||
      said("sit","chair"))) {
  print("No thanks. It has a tendency to swallow you up..");
}

if (said("enter","fire")) {
  if(isset(f16)) {
      print("You haven't quite mastered the \"Asbestos Skin\" spell.");
  }
  else {
      print("You drop to your hands and knees and crawl through the fireplace.");
    new.room(4);
  }
}

if(posn(ego,31,103,35,127)) {
  new.room(3);
}

return();