
#include "defines.txt"

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

  position(ego,28,69);
  stop.motion(ego);
  v6 = 5;
  player.control();
  draw(ego);

  show.pic();

  v255=4;
 
  if(obj.in.room("Candles",v255)) {
  animate.obj(o1);
  load.view(2);
  set.view(o1,2);
  set.loop(o1,3);
  set.cel(o1,0);
  position(o1,92,81);
  set.priority(o1,4);
  ignore.objs(o1);
  stop.cycling(o1);
  draw(o1);
  }

  if(v45==1) {  
    animate.obj(o2);
    load.view(7);
    set.view(o2,7);
    set.loop(o2,0);
    set.cel(o2,0);
    position(o2,59,105);
    set.priority(o2,10);
    ignore.objs(o2);
    stop.cycling(o2);
    draw(o2);
  }

  if(v45==2) {
    animate.obj(o2);
    load.view(7);
    set.view(o2,7);
    set.loop(o2,1);
    set.cel(o2,0);
    position(o2,59,105);
    set.priority(o2,10);
    ignore.objs(o2);
    start.cycling(o2);
    draw(o2);
  }

  if((v45==3 || v45==4)) {
    animate.obj(o2);
    load.view(7);
    set.view(o2,7);
    set.loop(o2,2);
    set.cel(o2,0);
    position(o2,59,105);
    set.priority(o2,10);
    ignore.objs(o2);
    start.cycling(o2);
    draw(o2);
  }

  if(v45==5) {
    animate.obj(o2);
    load.view(7);
    set.view(o2,7);
    set.loop(o2,3);
    set.cel(o2,0);
    position(o2,59,105);
    set.priority(o2,10);
    ignore.objs(o2);
    start.cycling(o2);
    draw(o2);
  }

  if(v45==6) {
    animate.obj(o2);
    load.view(7);
    set.view(o2,7);
    set.loop(o2,6);
    set.cel(o2,0);
    position(o2,59,105);
    set.priority(o2,10);
    ignore.objs(o2);
    start.cycling(o2);
    draw(o2);
  }
}

if(isset(f3)) {
  new.room(2);
}

if (said("look")) {
  print("This is the secret cavern beneath your house in which you practise your magic away from prying eyes.");
}

if (said("look","floor")) {
  print("There's a square marked out in the sandy floor.");
  v255=4;
  if(obj.in.room("Candles",v255)) {
    print("You spot your magic kit in the corner.");
  }
}

if ((said("look","kit") ||
     said("look","magic","kit") ||
     said("look","magic"))) {
   v255=4;
   if(obj.in.room("Candles",v255)) {
      print("It's just your magic kit, containing everything a young sorcerer needs.");
   }
   else {
   print("You took it, remember?");
  }
}    

if ((said("take","kit") ||
     said("take","magic","kit") ||
     said("open","kit") ||
     said("open","magic","kit") ||
     said("open","magic") ||
     said("take","magic"))) {
   v255=4;
   if(obj.in.room("Candles",v255)) {
      if(posn(ego,88,78,104,85)) {
      print("The kit contains some candles, and some blood. You discard the bag and take the rest.");
      erase(o1);
      get("Candles");
      get("Blood");
      }
      else {
       print("Come a little closer!");
     }
   }
   else {
   print("You already took it, remember?");
  }
}    

if (said("look","notes")) {
  if(has("Notebook")) {
   if(v45==0) {
    print("You turn to the appropriate page in your notes and read aloud the first step of your experimental spell.");
    print("\"Step 1: Draw a traditional magic circle on the floor.\"");
   }
   if(v45==1) {
    print("\"Step 2: Arrange lit candles around the circle.\"");
   }
   if(v45==2) {
    print("\"Step 3: Pour a quantity of blood into the circle.\"");
   }
   if(v45==3) {
    print("\"Step 4: Hold a sharp blade over the circle and sprinkle salt onto it.\"");
   }
   if(v45==4) {
    print("\"Step 5: Recite the words of the incantation.\"");
   }
   if(v45==5) {
    print("\"Step 6: Cut open a portal in the air above the circle with the aforementioned blade.\"");
   }
   if(v45==6) {
    print("\"Step 6: Step into the portal!\"");
   }
  }
  else {
   print("Oh yeah, you haven't found those yet.");
  }
}

if ((said("draw","circle") ||
     said("draw","magic","circle") ||
     said("draw","circle","circle") ||
     said("draw","magic","circle","circle") ||
     said("draw","circle","crayon") ||
     said("draw","magic","circle","crayon") ||
     said("draw","magic","circle","circle","crayon"))) {
 if(posn(ego,45,84,99,113)) {
  program.control();
  move.obj(ego,62,90,1,f50);
  }
  else {
  print("Come a little closer!");
  }
}

if(isset(f50)) {
   reset(f50);
 if(has("Crayon")) {
  if(v45==0) {
    v45=1;
    animate.obj(o2);
    load.view(7);
    set.view(o2,7);
    set.loop(o2,0);
    set.cel(o2,0);
    position(o2,59,105);
    set.priority(o2,10);
    ignore.objs(o2);
    stop.cycling(o2);
    draw(o2);
    print("You draw a traditional magic circle in the square with your yellow crayon.");
    player.control();
    }
  else {
    set(f30);
   }
  }
  else {
   print("With what?");
  }
}

if ((said("place","candles","circle") ||
     said("place","candles","magic","circle"))) {
 if(posn(ego,45,84,99,113)) {
  program.control();
  move.obj(ego,62,90,1,f51);
  }
  else {
  print("Come a little closer!");
  }
}

if(isset(f51)) {
   reset(f51);
 if(has("Candles")) {
  if(v45==1) {
    v45=2;
    set.loop(o2,1);
    start.cycling(o2);
    draw(o2);
    print("You arrange the candles nicely around the circle and light them with a small-scale firelighting spell.");
    drop("Candles");
    player.control();
    }
  else {
    set(f30);
   }
  }
  else {
   print("You generally need candles before you can do that.");
  }
}

if ((said("place","blood","circle") ||
     said("place","blood","magic","circle"))) {
 if(posn(ego,45,84,99,113)) {
  program.control();
  move.obj(ego,62,90,1,f52);
  }
  else {
  print("Come a little closer!");
  }
}

if(isset(f52)) {
   reset(f52);
 if(has("Blood")) {
  if(v45==2) {
    v45=3;
    erase(ego);
    animate.obj(o3);
    load.view(6);
    set.view(o3,6);
    set.loop(o3,2);
    set.cel(o3,0);
    position(o3,62,90);
    v255=2;
    cycle.time(o3,v255);
    set.priority(o3,4);
    ignore.objs(o3);
    stop.cycling(o3);
    draw(o3);
    end.of.loop(o3,f53);    
    player.control();
    }
  else {
    set(f30);
   }
  }
  else {
   print("You generally need blood before you can do that.");
  }
}

if(isset(f53)) {
   reset(f53);
   erase(o3);
   set.loop(o2,2);
   draw(ego);
   drop("Blood");
   print("You dribble blood into the centre of the circle. It sizzles slightly like oil going into a pan.");
}

if ((said("place","salt","knife") ||
     said("wield","knife","place","salt") ||
     said("wield","knife","place","salt","knife") ||
     said("wield","knife","circle","place","salt") ||
     said("wield","knife","circle","place","salt","knife"))) {
 if(posn(ego,45,84,99,113)) {
  program.control();
  move.obj(ego,62,90,1,f54);
  }
  else {
  print("Come a little closer!");
  }
}

if(isset(f54)) {
   reset(f54);
 if ((has("Salt")) && (has("Kitchen knife"))) {
  if(v45==3) {
    v45=4;
    erase(ego);
    animate.obj(o3);
    load.view(6);
    set.view(o3,6);
    set.loop(o3,3);
    set.cel(o3,0);
    position(o3,62,90);
    v255=2;
    cycle.time(o3,v255);
    set.priority(o3,4);
    ignore.objs(o3);
    stop.cycling(o3);
    draw(o3);
    end.of.loop(o3,f55);    
    player.control();
    }
  else {
    set(f30);
   }
  }
  else {
   print("You generally need both salt and a sword before you can do that.");
  }
}

if(isset(f55)) {
   reset(f55);
   erase(o3);
   draw(ego);
   drop("Salt");
   print("You sprinkle salt over the knife. The grains land in the circle with a series of little pops.");
}

if ((said("recite","magic") ||
     said("recite","magic","magic") ||
     said("look","magic") ||
     said("look","magic","magic"))) {
 if(posn(ego,45,84,99,113)) {
  program.control();
  move.obj(ego,62,90,1,f56);
  }
  else {
  print("Come a little closer!");
  }
}

if(isset(f56)) {
   reset(f56);
 if (has("Notebook")) {
  if(v45==4) {
    v45=5;
    erase(ego);
    animate.obj(o3);
    load.view(6);
    set.view(o3,6);
    set.loop(o3,4);
    set.cel(o3,0);
    position(o3,62,90);
    v255=2;
    cycle.time(o3,v255);
    set.priority(o3,4);
    ignore.objs(o3);
    stop.cycling(o3);
    draw(o3);
    end.of.loop(o3,f57);    
    player.control();
    }
  else {
    set(f30);
   }
  }
  else {
   print("You'll need your notes. You can't remember the words off hand.");
  }
}

if(isset(f57)) {
   reset(f57);
   erase(o3);
   set.loop(o2,3);
   draw(ego);
   print("You recite the mystical syllables of the spell.");
   print("\"ROL HECATAR KOM BABLIS STOSHEB KOM KOREEB!\"");
   print("... are just some of the many obscure words you read out over the next half hour.");
   print("The magic takes hold and the magic circle bursts into fiery life! You tremble in excitement as you reach the closing stage of the spell.");
}

if ((said("stab","air") ||
     said("stab","air","circle") ||
     said("stab","air","magic","circle") ||
     said("stab","air","knife") ||
     said("stab","air","circle","knife") ||
     said("stab","air","magic","circle","knife"))) {
 if(posn(ego,45,84,99,113)) {
  program.control();
  move.obj(ego,62,90,1,f58);
  }
  else {
  print("Come a little closer!");
  }
}

if(isset(f58)) {
   reset(f58);
 if (has("Kitchen knife")) {
  if(v45==5) {
    v45=6;
    erase(ego);
    animate.obj(o3);
    load.view(6);
    set.view(o3,6);
    set.loop(o3,5);
    set.cel(o3,0);
    position(o3,62,90);
    v255=2;
    cycle.time(o3,v255);
    set.priority(o3,4);
    ignore.objs(o3);
    stop.cycling(o3);
    draw(o3);
    end.of.loop(o3,f59);    
    }
  else {
    set(f30);
   }
  }
  else {
   print("You're going to need a knife for that.");
  }
}

if(isset(f59)) {
   reset(f59);
   set.loop(o2,4);
   draw(ego);
   v27=10;
}

v27--;

if(v27==1) {
  stop.cycling(o2);
   set.loop(o2,5);
  end.of.loop(o2,f60);
}

if(isset(f60)) {
   reset(f60);
   erase(o3);
   draw(ego);
   set.loop(o2,6);
   start.cycling(o2);
   player.control();
  drop("Kitchen knife");
}

if (said("look","square")) {
  if(v45==6) {
    print("A dimensional gateway now occupies the magic circle.");
  }
  if(v45==5) {
    print("The spell is nearly finished. A fiery white halo obscures the raw ingredients of your magic circle.");
  }
  if(v45==4) {
    print("The spell is well under way. The magic circle has been drawn, the candles put in position and a little splatter of blood and salt decorates the centre.");
  }
  if(v45==3) {
    print("The spell is well under way. The magic circle has been drawn, the candles put in position and a little splatter of blood decorates the centre.");
  }
  if(v45==2) {
    print("The spell is well under way. The magic circle has been drawn and the candles put in position.");
  }
  if(v45==1) {
    print("It's the traditional magic circle. In this special engineered magical environment, it almost seems to be humming.");
  }
  if(v45==0) {
  print("The square indicates where you should put your magic circle.");
  }
}

if(posn(ego,56,92,74,106)) {
  if(v45==6) {
   new.room(5);
  }
  if(v45>=1) {
   v45=0;
   set(f30);
  }
}

if(isset(f30)) {
  reset(f30);
  stop.motion(ego);
  erase(ego);
    animate.obj(o3);
    load.view(6);
    set.view(o3,6);
    set.loop(o3,1);
    set.cel(o3,0);
    position(o3,62,90);
    v255=2;
    cycle.time(o3,v255);
    set.priority(o3,4);
    ignore.objs(o3);
    stop.cycling(o3);
    draw(o3);
  print("You have a nagging feeling that you shouldn't have done that.");
  end.of.loop(o3,f31);
}

if(isset(f31)) {
  reset(f31);
  death_type=1;
}

return();
