/
lib/banish/
lib/d/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/doc/examples/
lib/doc/examples/armour/
lib/doc/examples/contain/
lib/doc/examples/food/
lib/doc/examples/magic/
lib/doc/examples/monster/
lib/doc/examples/room/
lib/doc/examples/weapons/
lib/function/
lib/include/
lib/include/fn_specs/
lib/include/skills/
lib/info/
lib/inherit/base/
lib/log/
lib/manuals/312/
lib/news/
lib/obj/party/
lib/objects/components/
lib/open/
lib/open/library/
lib/open/party/
lib/players/
lib/players/zilanthius/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/obj/
lib/room/city/shop/
lib/room/death/
lib/room/registry/
lib/secure/
lib/secure/UDP_CMD_DIR/
lib/skills/
lib/skills/fighter/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/players/
#include <mudlib.h>
#define NAME   capitalize((string)this_player()->query_name(1))
#define SCROLL "room/city/obj/scroll"
inherit ROOM;

static string quester;
static int counter;

void quest_hint();
void reset(status arg) {
  object obj;
  if(!present("clerk") && !this_player()->query_npc()) {
    obj = clone_object("room/city/monst/clerk");
    move_object(obj,this_object());
  }
  load_door(({
    "file", "room/city/t_hall3",
    "direction", "north door",
    "long", "A solid door made of oak.\n",
    "key id", "city key",
  }));
  reset_doors(arg);
  if(arg) return;
  set_short("the city clerk's office");
  set_long(
     "The Tempus city clerk's office.\n");
  set_weather(2,1,0);
  quester = 0;
  counter = 0;
}

void init() {
  if(present("clerk") && !this_player()->query_npc()) {
    if(!this_player()->query_current_quest() && this_player()->assign_quest()){
      quester = NAME;
    }  
    call_out("quest1", 1);
  }  
  ::init();
  add_action("check", "", 1);
}

status check() {
  if((quester == NAME) && (query_verb() != "update")) { /* failsafe */
    tell_object(this_player(), 
     "Clerk says: Hey, I haven't finished yet!\n");
    return 1;
  }
}

void quest1() {
  if(quester && (quester != NAME)) {
    tell_object(this_player(),
      "Clerk says: Just a moment "+NAME+", I'll be with "+
     "you in a second.\n");
    return;
  }
  if(this_player()->query_current_quest() && (NAME != quester)) {
    tell_object(this_player(),
     "Clerk says: Welcome back, "+NAME+". I see you still have not \n"+
     "            completed your current assignment for the city council.\n"+
     "            Your quest still is...\n\n");
    this_player()->quest_hint();
    return;
  }
  if(!this_player()->query_current_quest()) {
    tell_room(this_object(),
      "Clerk says: I'm sorry, "+NAME+", but we have nothing for you "+
      "at this stage.\n");
    return;
  }

  tell_room(this_object(), "Clerk smiles happily.\n"+
     "Clerk begins to sift through mounds of papers and official documents.\n");
  call_out("quest2", 1);
  return;
}

void quest2() {
  mixed *messages;
  messages = ({
     ({ "Clerk says: It's so good to see you "+NAME+".\n",
        "Clerk says: It's been a while since I've seen you, "+NAME+".\n",
        "Clerk asks: Why haven't you come in sooner, "+NAME+".\n",
         "Clerk finds something amid the mess of papers and scrolls.\n",
     }),


     ({
       "Clerk says: I have heard you are an adventurer of great prowess.\n",
       "Clerk says: News of your power is spreading through the city.\n",
       "Clerk says: You have become quite famous in these parts.\n",
       "Clerk says: You're such a mighty adventurer.\n",
     }),

     ({
       "Clerk says: I was once a mighty mage myself.\n",
       "Clerk says: Did you know I was once a famous magic-user?\n",
       "Clerk recalls her memories of her adventuring days...\n",
       "Clerk begins to daydream about her past adventuring life.\n",
       "Clerk says: The life of the adventurer is filled with such joys.\n",
     }),

      ({
        "Clerk says: now, onto business.\n",
         "Clerk atlast finds the paper she was looking for.\n",
         "Clerk smiles with relief as she finds the necesary papers.\n",
      }),

      ({
     "Clerk says: The Tempus Council is always in need of brave adventurers.\n", 
     "Clerk says: The mayor is always in needs of people to aid the council.\n",
     "Clerk reads a brief proclamation of the Tempus City Council.\n",
      }),
     ({
     "Clerk says: It is my duty to see that you aid us whenever possible.\n",
     "Clerk says: As a citizen of Tempus, you are required to aid the city\n"+
     "            in times of need.\n",
      }),
      ({
     "Clerk says: In exchange, we offer you the freedom to come and go \n"+
     "            in our fair city, using its facilities as you need.\n",
     "Clerk says: In return, you have at your desposal all the guilds and\n"+
     "            training facilities within our city walls.\n",
      }),

     ({
       "Clerk says: "+NAME+", this time I charge you with this duty.\n",
       "Clerk says: "+NAME+", the mayor has asked me to send you on a \n"+
       "            a quest of vital importance to the safety of Tempus.\n",
       "Clerk says: The mayor himself has personally asked me to send you\n"+
       "            on this vital quest.\n",
       "Clerk says: I have a quest for you to undertake.\n",
       "Clerk says: I must ask you to embark on a private quest for us.\n",
     }),
  });

  if(counter < sizeof(messages)) {
    if(sizeof(messages[counter]))
      tell_room(this_object(),
        messages[counter][random(sizeof(messages[counter]))]);
    else 
      tell_room(this_object(), messages[counter]);
    counter ++;
    call_out("quest2", 1);
  }
  else {
      quest_hint();
      quester = 0;
      counter = 0;
  }
  return;
} 

void quest_hint() {
  object scroll;

  tell_object(this_player(),
     "Clerk says: Your quest is...\n\n");
  this_player()->quest_hint();

  if(!present("quest hint", this_player())) {
    tell_object(this_player(), "Clerk hands you a scroll.\n");
    say("Clerk hands "+NAME+" a scroll.\n",this_player());
    scroll = clone_object(SCROLL);
    if(!this_player()->add_weight(1)) {
      tell_object(this_player(), "Clerk notices you can't carry anymore.\n"+
      "Clerk places the scroll back in the drawer of her desk.\n"+
      "Clerk says: Come back when you put on some more muscle.\n");
      destruct(scroll);
      return;
    }
    else
      move_object(scroll, this_player());
  }
  return;
}

string query_quester() {
  return quester;
}