// ****************************************************************************
//
// Logic 15: Cemetery A2
//
// ****************************************************************************

#include "defines.txt"
#define zombie o1
#define water o2

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

//  if (prev_room_no == 14) {
//    position(ego,97,120);
//  }

  draw(ego);
  show.pic();

  animate.obj(water);
  load.view(30);
  set.view(water,30);
  set.loop(water,1);
  v255 = 3;
  cycle.time(water,v255);
  ignore.objs(water);
  ignore.horizon(water);
  ignore.blocks(water);
  position(water,88,92);
  set.priority(water,10);
  start.cycling(water);
  draw(water);

  if (!isset(cemetery_zombie1)) {
    animate.obj(zombie);
    load.view(22);
    set.view(zombie,22);
    if (prev_room_no == 247) {
      reset(m1_attacks);
      position.v(zombie,v244,v245);
      if (monster == 0) {
        set(cemetery_zombie1);
        load.view(28);
        set.view(zombie,28);
        set.loop(zombie,4);
        stop.motion(zombie);
      }
      else {
        get.posn(ego,v254,v255);
        if (v254 > v244) {
          v254 = 0; v255 = 240;
          reposition(ego,v255,v254);
        }
        else {
          v254 = 0; v255 = 16;
          reposition(ego,v255,v254);
        }
      }
    }
    else {
      position(zombie,78,100);
    }
    draw(zombie);
  }
  if (!isset(cemetery_zombie1)) {
    v255 = 2; step.time(zombie,v255);
    v255 = 4; cycle.time(zombie,v255);
    ignore.objs(zombie);
    follow.ego(zombie,6,m1_attacks);
  }


}

if (m1_attacks) {
  stop.motion(zombie);
  get.posn(zombie,v244,v245);
  monster = 4;
  scenery = 1;
  new.room(247);
}

if ((said("look","fountain") || said("look","water"))) {
  print("Clear, sparkling water pours out from the statue.  How beautiful, yet eerie as well.");
}

if (said("look","corpse")) {
  if (!isset(cemetery_zombie1)) {
    print("It's coming right for you, arms outstretched, its soul aching for your blood.");
  }
  else {
    print("There are no zombies here.");
  }
}

if ((said("drink","water") || said("drink","fountain","water") || said("drink","fountain"))) {
  print("You're not drinking any nasty grave water.");
}

if (said("look","fence")) {
  print("The fence is high and made up of bars.  It reminds you of a prison.");
}

if (said("look","hole")) {
  print("Something escaped its earthen prison.");
}

if (said("look","monument")) {
  print("You're not interested.  They're all the same in death.");
}

if ((said("look","ground") || said("look","grave"))) {
  print("The ground hides many things here.  Not the least of which is hordes of dead people.  They're all probably scratching at their coffins, eager to dig their gnashing teeth  into your throat and clutching claws into your eyesockets.");
  print("On second thought, you'd prefer not to think about it.");
}

if ((said("look") || said("look","cemetery"))) {
  print("Be careful.  A cemetery isn't the safest place to be when the dead are restless.");
}

if (ego_edge_code == 3) {
  new.room(14);
}

if (ego_edge_code == right_edge) {
  new.room(18);
}

if (ego_edge_code == left_edge) {
  new.room(16);
}

return();