// ****************************************************************************
//
// Logic 20: Toolshed in cemetery
//
// ****************************************************************************

#include "defines.txt"
#define window o1
#define tool o2

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

  if (prev_room_no == 16) {
    position(ego,72,132);
  }

  draw(ego);
  show.pic();

  animate.obj(window);
  load.view(38);
  set.view(window,38);
  set.loop(window,2);
  stop.cycling(window);
  ignore.objs(window);
  ignore.blocks(window);
  ignore.horizon(window);
  position(window,109,97);
  draw(window);

  v255 = 20;
  if (obj.in.room("knife",v255)) {
    animate.obj(tool);
    load.view(40);
    set.view(tool,40);
    set.loop(tool,0);
    stop.cycling(tool);
    ignore.objs(tool);
    position(tool,51,89);
    draw(tool);
  }

}

if (shed_window) {
  set.cel(window,1);
}
else {
  set.cel(window,0);
}

v255 = 20;
if (obj.in.room("knife",v255)) {
  draw(tool);
}

if (said("take","knife")) {
  v255 = 20;
  if (obj.in.room("knife",v255)) {
    if (posn(ego,41,100,69,110)) {
      print("Ok."); get("knife");
      erase(tool);
    }
    else {
      print("You're not close enough.");
    }
  }
  else {
    reset(input_parsed);
  }
}



if (said("look","knife")) {
  v255 = 20;
  if (obj.in.room("knife",v255)) {
    print("The knife is lying on the table.");
  }
  else {
    reset(input_parsed);
  }
}

if (said("open","window")) {
  if (posn(ego,98,103,116,125)) {
    toggle(shed_window);
  }
  else {
    print("You're not close enough.");
  }
}

if (said("look","window")) {
  if (shed_window) {
    print("The window is open.");
  }
  else {
    print("The window is closed.");
  }
}

if ((said("throw","knife","window") || said("use","knife","window"))) {
  if (has("knife")) {
    if (shed_window) {
      if (posn(ego,98,103,116,125)) {
        print("You toss the knife through the open window.");
        v255 = 16;
        put("knife",v255);
        score++;
      }
      else {
        print("You're not close enough.");
      }
    }
    else {
      print("The window is closed.");
    }
  }
  else {
    reset(input_parsed);
  }
}

if (said("look","table")) {
  v255 = 20;
  if (obj.in.room("knife",v255)) {
    print("There is a butcher knife lying on the table for some reason.");
    print("What?  A knife could be useful in a cemetery...");
    print("Yes.  It'll be somewhere else in the full version.");
  }
  else {
    print("There is nothing on the table.");
  }
}

if (said("look","board")) {
  print("The peg board is used for hanging tools up.  Currently, there is only a weed eater hanging up.");
}

if (said("take","weed eater")) {
  print("You don't want to lug around a heavy weed whacker.");
}

if (said("take","mower")) {
  print("While it has been proven that a lawnmower can be an effective instrument for killing zombies, you are not going to take one with you.");
}

if (said("look","mower")) {
  print("The caretaker's lawnmower is here.  It's used to cut grass.");
}

if (said("look","weed eater")) {
  print("The weed eater is hanging on the board.  It's used to trim tall grass where the mower can't go.");
}

if ((said("look") || said("look","house"))) {
  print("You are in the cemetery's toolshed.  There is a table, a lawnmower, and a peg board on the back wall.");
}


if (f3) {
  if (has("knife") && !isset(got_tool)) {
    print("The caretaker shouts at you, 'Don't steal my tools!'");
    v255 = 20;
    put("knife",v255);
  }
  else {
    new.room(16);
  }
}

return();