
#include "defines.txt"

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

  show.pic();

  if(v1==10) {
  reset(f18);
  position(ego,109,93);
  load.view(0);
  set.view(ego,0);
  draw(ego);
  v46=0;
  }
  if(v1==9) {
  position(ego,130,90);
  draw(ego);
  }

   animate.obj(o1);
   load.view(7);
   set.view(o1,7);
   set.cel(o1,0);
   position(o1,60,98);
   set.priority(o1,9);
   stop.cycling(o1);
  if(v46==1) {
     set.loop(o1,0);
     draw(o1);
  }
  if(v46==2) {
     load.view(22);
     set.view(o1,22);
     set.loop(o1,0);
     start.cycling(o1);
     draw(o1);
  }
  if(v46==3) {
     load.view(22);
     set.view(o1,22);
     set.loop(o1,1);
     start.cycling(o1);
     draw(o1);
  }
  if(v46==4) {
     load.view(22);
     set.view(o1,22);
     set.loop(o1,1);
     start.cycling(o1);
     draw(o1);
  }
  if(v46==5) {
     set.loop(o1,3);
     start.cycling(o1);
     draw(o1);
  }
  if(v46==6) {
     set.loop(o1,6);
     start.cycling(o1);
     draw(o1);
  }

}

if(isset(f3)) {
   get.dir(ego,v6);
    if((v6==8  ||
       v6==7 ||
       v6==6)) {
     load.view(14);
     set.view(ego,14);
    }
    if((v6==2  ||
       v6==3 ||
       v6==4)) {
     load.view(0);
     set.view(ego,0);
    }
}

if (said("look")) {
  print("You are exploring a small cave. It seems to be mostly filled with water but a rock islet sticks out in the middle. Some kind of shiny yellow gem is embedded in the west wall.");
}

if (said("look","gem")) {
  print("It's a very deep yellow, and almost perfectly round.");
  if((posn(ego,19,83,36,102)) && (!has("Viogra spell"))) {
    print("Now that you can take a closer look, you see some kind of sparkly stuff glittering in the centre of the orb. It's very pretty. You're reminded of a magical experiment you conducted not long ago.");
    print("You were working on a spell that induced suicidal tendencies in animals. It was a single-word spell. What was that word? The glittery gem seems to be jogging your memory...");
    print("VIOGRA. That was it. You could probably recite if off hand.");
    get("Viogra spell");
   }
}

if (said("get","gem")) {
  print("The crystal is too deeply embedded into the rock, you have no chance of removing it.");
}

if (said("look","water")) {
  print("The pool of oddly-coloured water makes occasional glopping and blupping noises. A little islet is in the middle.");
}

if (said("look","islet")) {
  if(v46==6) {
     print("The portal is open! Waste no time!");
  }
  if(v46==5) {
     print("The circle has become engulfed in white flame as the spell sequence reaches the crucial point.");
  }
  if(v46==4) {
     print("Glowing crystal bits have been arranged around the magic circle drawn upon the rock islet, and alien blood and bone powder has been splattered into the centre.");
  }
  if(v46==3) {
     print("Glowing crystal bits have been arranged around the magic circle drawn upon the rock islet, and alien blood has been splattered into the centre.");
  }
  if(v46==2) {
     print("Glowing crystal bits have been arranged around the magic circle drawn upon the rock islet.");
  }
  if(v46==1) {
     print("Your magic circle has been drawn on top of the little rock islet.");
  }
  if(v46==0) {
     print("It's a big lump of rock with a flat top sticking up out of the water.");
  }
}

if ((said("exit","cave") ||
     said("get") ||
     said("get","cave") ||
     said("exit"))) {
  print("The entrance is over there. Try using it.");
}

if ((said("cast","fissop") ||
     said("fissop") ||
     said("fissop","cave") ||
     said("fissop","dark"))) {
  print("You don't need to do it again.");
}

if(posn(ego,133,77,142,104)) {
  new.room(9);
}

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(v46==0) {
   if(posn(ego,54,87,78,94)) {
      move.obj(ego,64,93,1,f17);
     }
     else {
      print("Move closer to where you want to draw it.");
     }
     }
   else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f17)) {
   reset(f17);
   v46=1;
   set.loop(o1,0);
   draw(o1);
   print("You draw a magic circle on the raised stone. Here we go again.");
}

if ((said("put","crystals","circle") ||
     said("put","crystal","circle"))) {
  if(v46==1) {
   if(posn(ego,54,87,78,94)) {
      if(has("Glowing crystals")) {
      move.obj(ego,64,93,1,f20);
      }
      else {
       print("What crystal? The one on the wall? No can do.");
      }
     }
     else {
      print("Move closer to the circle.");
     }
     }
   else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f20)) {
   reset(f20);
   v46=2;
   load.view(22);
   set.view(o1,22);
   set.loop(o1,0);
   start.cycling(o1);
   print("You arrange glowing crystals around your circle. They should suffice as candles. Just don't blame me if you turn green or grow another head or something.");
   drop("Glowing crystals");
}

if ((said("put","blood","circle") ||
     said("put","blood","shard","circle"))) {
  if(v46==2) {
   if(posn(ego,54,87,78,94)) {
      if(has("Bloody shard")) {
      move.obj(ego,64,93,1,f21);
      }
      else {
       print("What crystal? The one on the wall? No can do.");
      }
     }
     else {
      print("Move closer to the circle.");
     }
     }
   else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f21)) {
   reset(f21);
   v46=3;
   set.loop(o1,1);
   print("You dribble the alien blood into the circle. It splats pleasingly.");
   drop("Bloody shard");
   get("Metal shard");
}

if ((said("place","bone","shard") ||
     said("wield","shard","place","bone") ||
     said("wield","shard","place","bone","shard") ||
     said("wield","shard","circle","place","bone") ||
     said("wield","shard","circle","place","bone","shard"))) {
  if(v46==3) {
   if(posn(ego,54,87,78,94)) {
      if((has("Skull powder")) && (has("Metal shard"))) {
      move.obj(ego,64,93,1,f22);
      }
      else {
       print("You're going to need both powdered bone and a sharp thing.");
      }
     }
     else {
      print("Move closer to the circle.");
     }
     }
   else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f22)) {
   reset(f22);
   v46=4;
   print("You pour bone powder over the metal shard. It sizzles nicely into the circle.");
   drop("Metal shard");
   drop("Skull powder");
}

if ((said("recite","magic") ||
     said("recite","magic","magic") ||
     said("look","magic") ||
     said("look","magic","magic"))) {
  if(v46==4) {
    if(posn(ego,54,87,78,94)) {
    move.obj(ego,64,93,1,f23);
    }
    else {
    print("Come a little closer!");
    }
   }
  else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f23)) {
   reset(f23);
   v46=5;
   print("You recite the words once again. Isn't this more fun than doing your homework?");
   print("The magic takes hold and the circle bursts into white flame.");
   load.view(7);
   set.view(o1,7);
   set.loop(o1,3);
}

if ((said("stab","air") ||
     said("stab","air","circle") ||
     said("stab","air","magic","circle") ||
     said("stab","air","shard") ||
     said("stab","air","circle","shard") ||
     said("stab","air","magic","circle","shard"))) {
 if(v46==5) {
 if(posn(ego,54,87,78,94)) {
  move.obj(ego,64,93,1,f25);
  }
  else {
  print("Come a little closer!");
  }
  }
  else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f25)) {
   reset(f25);
   v46=6;
   print("You've done this before, haven't you.");
   set.loop(o1,6);
}

if ((said("enter","circle") ||
     said("jump","circle"))) {
 if(v46==6) {
 if(posn(ego,54,87,78,94)) {
  move.obj(ego,64,93,1,f26);
  }
  else {
  print("Come a little closer!");
  }
  }
  else {
    print("You have a funny feeling that you shouldn't have done that.");
    set(f18);
  }
}

if(isset(f26)) {
   print("Weeee!");
   new.room(19);
}

if(isset(f18)) {
   reset(f18);
   animate.obj(o2);
   load.view(15);
   set.view(o2,15);
   set.loop(o2,0);
   set.cel(o2,0);
   v255=2;
   cycle.time(o2,v255);
   get.posn(ego,v40,v41);
   position.v(o2,v40,v41);
   set.priority(o2,4);
   stop.cycling(o2);
   erase(ego);
   draw(o2);
   end.of.loop(o2,f19);
}

if(isset(f19)) {
   death_type=1;
}

return();

