nightmare3_fluffos_v2/
nightmare3_fluffos_v2/bin/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/ChangeLog.old/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/Win32/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/simuls/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/clone/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/command/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/data/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/etc/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/master/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/log/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/compiler/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/efuns/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/operators/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/u/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/tmp/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/windows/
nightmare3_fluffos_v2/lib/cmds/ambassador/
nightmare3_fluffos_v2/lib/cmds/database/
nightmare3_fluffos_v2/lib/cmds/hm/
nightmare3_fluffos_v2/lib/cmds/soul/
nightmare3_fluffos_v2/lib/daemon/cfg/
nightmare3_fluffos_v2/lib/daemon/cfg/mon_races/
nightmare3_fluffos_v2/lib/daemon/cfg/races/
nightmare3_fluffos_v2/lib/daemon/include/
nightmare3_fluffos_v2/lib/daemon/save/
nightmare3_fluffos_v2/lib/daemon/services/
nightmare3_fluffos_v2/lib/daemon/soul/
nightmare3_fluffos_v2/lib/doc/
nightmare3_fluffos_v2/lib/doc/TestPlans/
nightmare3_fluffos_v2/lib/doc/approval/
nightmare3_fluffos_v2/lib/doc/approval/QC/
nightmare3_fluffos_v2/lib/doc/approval/balance/
nightmare3_fluffos_v2/lib/doc/build/
nightmare3_fluffos_v2/lib/doc/build/armours/
nightmare3_fluffos_v2/lib/doc/build/economy/
nightmare3_fluffos_v2/lib/doc/build/etc/
nightmare3_fluffos_v2/lib/doc/build/monster/
nightmare3_fluffos_v2/lib/doc/build/room/
nightmare3_fluffos_v2/lib/doc/build/virtual/
nightmare3_fluffos_v2/lib/doc/build/weapon/
nightmare3_fluffos_v2/lib/doc/classes/
nightmare3_fluffos_v2/lib/doc/efun/
nightmare3_fluffos_v2/lib/doc/etc/
nightmare3_fluffos_v2/lib/doc/help/creator/
nightmare3_fluffos_v2/lib/doc/help/hm/
nightmare3_fluffos_v2/lib/doc/law/
nightmare3_fluffos_v2/lib/doc/lpc/basic/
nightmare3_fluffos_v2/lib/doc/lpc/data_types/
nightmare3_fluffos_v2/lib/doc/lpc/etc/
nightmare3_fluffos_v2/lib/doc/lpc/intermediate/
nightmare3_fluffos_v2/lib/doc/lpc/types/
nightmare3_fluffos_v2/lib/doc/mudlib/
nightmare3_fluffos_v2/lib/doc/mudlib/features/
nightmare3_fluffos_v2/lib/domains/Examples/etc/
nightmare3_fluffos_v2/lib/domains/Examples/room/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaA/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaB/
nightmare3_fluffos_v2/lib/domains/Examples/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/
nightmare3_fluffos_v2/lib/domains/Praxis/adm/
nightmare3_fluffos_v2/lib/domains/Praxis/attic/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/mon/
nightmare3_fluffos_v2/lib/domains/Praxis/data/
nightmare3_fluffos_v2/lib/domains/Praxis/death/
nightmare3_fluffos_v2/lib/domains/Praxis/mountains/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/armour/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/magic/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/orc_valley/
nightmare3_fluffos_v2/lib/domains/Praxis/quests/
nightmare3_fluffos_v2/lib/domains/Praxis/standardOld/
nightmare3_fluffos_v2/lib/include/
nightmare3_fluffos_v2/lib/log/
nightmare3_fluffos_v2/lib/log/errors/
nightmare3_fluffos_v2/lib/log/reports/
nightmare3_fluffos_v2/lib/log/watch/
nightmare3_fluffos_v2/lib/news/
nightmare3_fluffos_v2/lib/secure/cfg/
nightmare3_fluffos_v2/lib/secure/cmds/ambassador/
nightmare3_fluffos_v2/lib/secure/cmds/mortal/
nightmare3_fluffos_v2/lib/secure/save/users/d/
nightmare3_fluffos_v2/lib/secure/std/
nightmare3_fluffos_v2/lib/std/hm/
nightmare3_fluffos_v2/lib/std/living/
nightmare3_fluffos_v2/lib/std/room/
nightmare3_fluffos_v2/lib/std/user/
nightmare3_fluffos_v2/lib/std/virtual/
nightmare3_fluffos_v2/lib/www/
nightmare3_fluffos_v2/lib/www/errors/
nightmare3_fluffos_v2/lib/www/gateways/
nightmare3_fluffos_v2/win32/
//      /std/room/senses.c
//      from the Nightmare Mudlib
//      allows players to search, hide, smell, listen in every room
//      created by Descartes of Borg 18 june 1993
//      modified to save MAJOR memory by Descartes of Borg 930830

#include <config.h>
#include <rooms.h>

object __Search_Obj;
private mapping __Smells, __Listens, __Searches;

void set_search(string item, mixed desc);
void set_smell(string item, mixed desc);
void set_listen(string item, mixed desc);
void remove_search(string item);
void remove_smell(string item);
void remove_listen(string item);
mixed query_search(string item);
mixed query_smell(string item);
mixed query_listen(string item);

#ifdef __OLD_ROOM_BEHAVIOUR
#define __SENSES_C
#include <old_room.h>
#endif /* __OLD_ROOM_BEHAVIOUR */

void create() {
    __Search_Obj = 0;
    __Smells = ([]);
    __Listens = ([]);
    __Searches = ([]);
}

void init() {
    add_action("hide_something", "hide");
    add_action("search_room", "search");
    add_action("smell_things", "smell");
    add_action("do_listen", "listen");
}

int hide_something(string str) {
    int tmp, tmp_wt;
    object ob;

    if(this_player()->query_paralyzed())
      return notify_fail("You cannot move.\n");
    if(!str) return notify_fail("Hide what?\n");
    if(effective_light(this_player()) < -1) 
      return notify_fail("It is too dark.\n");
    if(effective_light(this_player()) > 8)
      return notify_fail("It is too bright to do that.\n");
    if(!(ob = present(lower_case(str), this_player())))
      return notify_fail("You do not have that.\n");
    if(living(ob) || ob->query_property("no hide"))
      return notify_fail("You cannot hide that.\n");
    if(this_player()->query_disable()) return 1;
    this_player()->set_disable();
    tmp_wt = (int)ob->query_weight();
    tmp = 25*(tmp_wt/1000);
    this_player()->add_sp(-10);
    if(random(tmp) > random((int)this_player()->query_skill("stealth"))) {
        notify_fail("You are unable to hide "+str+".\n");
        return 0;
    }
    if(__Search_Obj) {
        message("my_action", sprintf("You are unable to hide %s.", str),
          this_player());
        return 1;
    }
    this_player()->add_skill_points("stealth", random(tmp_wt));
    message("my_action", "You hide it in the shadows.", this_player());
    if(random(101) > (int)this_player()->query_skill("stealth"))
        message("other_action", sprintf("%s hides something.",
          (string)this_player()->query_cap_name()), environment(this_player()),
          ({ this_player() }));
    __Search_Obj = ob;
    ob->move(ROOM_CACHE);
    return 1;
}

int search_room(string str) {
    int i;

    if(this_player()->query_paralyzed())
      return notify_fail("You are unable to move.\n");
    if(effective_light(this_player()) < 0)
      return notify_fail("It is too dark.\n");
    if(effective_light(this_player()) > 7)
      return notify_fail("It is too bright to see anything.\n");
    if(__Search_Obj && str == "shadows") {
        message("my_action", sprintf("You find %s",
          (string)__Search_Obj->query_name()), this_player());
        message("other_action", sprintf("%s finds something in the shadows.",
          (string)this_player()->query_cap_name()), environment(this_player()),
          ({ this_player() }));
        __Search_Obj->move(this_object());
        __Search_Obj = 0;
        return 1;
    }
    if(!__Searches) return notify_fail("You find nothing of interest.\n");
    if(str == "default") return notify_fail("What is a default?\n");
    if(!str || str == "") str = "default";
    if(functionp(__Searches[str])) (*__Searches[str])(str);
    else if(stringp(__Searches[str])) {
        message("my_action", __Searches[str], this_player());
        message("other_action", (string)this_player()->query_cap_name() +
          " searches around.", this_object(), ({ this_player() }) );
    }
    else message("my_action", "You find nothing odd.", this_player());
    return 1;
}

status smell_things(string str) {
    if(!str || str == "") str = "default";
    if(!__Smells || !__Smells[str]) {
        if(!this_object()->id(str))
          return notify_fail("You do not notice that here.\n");
        else message("smell", "You smell no odd odors.", this_player());
        return 1;
    }
    if(functionp(__Smells[str]))
      message("smell", (string)((*__Smells[str])(str)), this_player());
    else if(stringp(__Smells[str])) {
        message("smell", __Smells[str], this_player());
        if(str == "default") message("other_action",
          (string)this_player()->query_cap_name()+" smells around.",
          this_object(), ({ this_player() }));
        else message("other_action", (string)this_player()->query_cap_name()+
          " smells the "+str+".", this_object(), ({this_player()}));
    }
    else message("smell","You notice no interesting odors.",this_player());
    return 1;
}

status do_listen(string str) {
    if(!str || str == "") str = "default";
    else if(sscanf(str, "to %s", str) != 1)
      return notify_fail("Listen to what?\n");
    if(!__Listens || !__Listens[str]) {
        if(!this_object()->id(str))
          return notify_fail("You do not notice that here.\n");
        else message("listen", "You hear nothing unusual.",this_player());
        return 1;
    }
    if(functionp(query_listen(str)))
      message("listen", (string)((*__Listens[str])(str)), this_player());
    else if(stringp(__Listens[str])) {
        message("listen", __Listens[str], this_player());
        if(str == "default") message("other_action",
          (string)this_player()->query_cap_name()+" listens intently.",
          this_object(), ({ this_player() }) );
        else message("other_action", (string)this_player()->query_cap_name()+
          " listens intently to "+str+".", this_object(),({this_player()}));
    }
    else message("listen", "You hear nothing unusual.", this_player());
    return 1;
}

void set_search(mixed item, mixed desc) {
    int i;

    if(!item) item = "default";
    else if(pointerp(item)) {
        i = sizeof(item);
        while(i--) set_search(item[i], desc);
        return;
    }
    else if(!stringp(item)) error("Bad argument 1 to set_searc().\n");
    if(functionp(desc) && (int)master()->valid_function(desc))
      __Searches[item] = copy(desc);
    else if(stringp(desc)) __Searches[item] = desc;
    else error("Bad argument 2 to set_search().\n");
}

void remove_search(string item) { map_delete(__Searches, item); }

void set_smell(mixed item, mixed desc) {
    int i;

    if(!item) item = "default";
    else if(pointerp(item)) {
        i = sizeof(item);
        while(i--) set_smell(item[i], desc);
        return;
    }
    else if(!stringp(item)) error("Bad argument 1 to set_smell().\n");
    if(functionp(desc) && (int)master()->valid_function(desc))
      __Smells[item] = copy(desc);
    else if(stringp(desc)) __Smells[item] = desc;
    else error("Bad argument 2 to set_smell().\n");
}

void remove_smell(string item) { map_delete(__Smells, item); }

void set_listen(mixed item, mixed desc) {
    int i;

    if(!item) item = "default";
    else if(pointerp(item)) {
        i = sizeof(item);
        while(i--) set_listen(item[i], desc);
        return;
    }
    else if(!stringp(item)) error("Bad argument 1 to set_listen().\n");
    if(functionp(desc) && (int)master()->valid_function(desc))
      __Listens[item] = copy(desc);
    else if(stringp(desc)) __Listens[item] = desc;
    else error("Bad argument 2 to set_listen().\n");
}

void remove_listen(string item) { map_delete(__Listens, item); }

mixed query_search(string item) { 
    if(functionp(__Searches[item])) return copy(__Searches[item]);
    else return __Searches[item];
}

mixed query_smell(string item) {
    if(functionp(__Smells[item])) return copy(__Smells[item]);
    else return __Smells[item];
}

mixed query_listen(string item) {
    if(functionp(__Listens[item])) return copy(__Listens[item]);
    else return __Listens[item];
}