lima-1.0b5/
lima-1.0b5/driver/
lima-1.0b5/driver/ChangeLog.old/
lima-1.0b5/driver/Win32/
lima-1.0b5/driver/compat/
lima-1.0b5/driver/include/
lima-1.0b5/driver/testsuite/
lima-1.0b5/driver/testsuite/clone/
lima-1.0b5/driver/testsuite/command/
lima-1.0b5/driver/testsuite/data/
lima-1.0b5/driver/testsuite/etc/
lima-1.0b5/driver/testsuite/include/
lima-1.0b5/driver/testsuite/inherit/
lima-1.0b5/driver/testsuite/inherit/master/
lima-1.0b5/driver/testsuite/log/
lima-1.0b5/driver/testsuite/single/
lima-1.0b5/driver/testsuite/single/tests/compiler/
lima-1.0b5/driver/testsuite/single/tests/efuns/
lima-1.0b5/driver/testsuite/single/tests/operators/
lima-1.0b5/driver/testsuite/u/
lima-1.0b5/driver/tmp/
lima-1.0b5/etc/
lima-1.0b5/lib/WWW/help/
lima-1.0b5/lib/cmds/
lima-1.0b5/lib/cmds/create/
lima-1.0b5/lib/cmds/player/attic/
lima-1.0b5/lib/contrib/bboard/
lima-1.0b5/lib/contrib/boards/
lima-1.0b5/lib/contrib/marriage/
lima-1.0b5/lib/contrib/roommaker/
lima-1.0b5/lib/contrib/transient_effect/
lima-1.0b5/lib/daemons/channel/
lima-1.0b5/lib/daemons/imud/
lima-1.0b5/lib/data/
lima-1.0b5/lib/data/config/
lima-1.0b5/lib/data/links/
lima-1.0b5/lib/data/news/
lima-1.0b5/lib/data/players/
lima-1.0b5/lib/data/secure/
lima-1.0b5/lib/domains/
lima-1.0b5/lib/domains/std/2.4.5/maze1/
lima-1.0b5/lib/domains/std/2.4.5/npc/
lima-1.0b5/lib/domains/std/2.4.5/post_dir/
lima-1.0b5/lib/domains/std/2.4.5/sub/
lima-1.0b5/lib/domains/std/camera/
lima-1.0b5/lib/domains/std/config/
lima-1.0b5/lib/domains/std/cult/
lima-1.0b5/lib/domains/std/effects/
lima-1.0b5/lib/domains/std/misc/
lima-1.0b5/lib/domains/std/monsters/
lima-1.0b5/lib/domains/std/recorder/
lima-1.0b5/lib/domains/std/rooms/
lima-1.0b5/lib/domains/std/rooms/beach/
lima-1.0b5/lib/domains/std/rooms/labyrinth/
lima-1.0b5/lib/domains/std/school/
lima-1.0b5/lib/domains/std/school/O/
lima-1.0b5/lib/domains/std/spells/
lima-1.0b5/lib/domains/std/spells/stock-mage/
lima-1.0b5/lib/domains/std/spells/stock-priest/
lima-1.0b5/lib/help/
lima-1.0b5/lib/help/admin/
lima-1.0b5/lib/help/hints/General_Questions/
lima-1.0b5/lib/help/hints/Pirate_Quest/
lima-1.0b5/lib/help/player/
lima-1.0b5/lib/help/player/bin/
lima-1.0b5/lib/help/player/quests/
lima-1.0b5/lib/help/wizard/
lima-1.0b5/lib/help/wizard/coding/guilds/
lima-1.0b5/lib/help/wizard/coding/rooms/
lima-1.0b5/lib/help/wizard/lib/daemons/
lima-1.0b5/lib/help/wizard/lib/lfun/
lima-1.0b5/lib/help/wizard/lib/std/
lima-1.0b5/lib/help/wizard/mudos_doc/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/interactive/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/concepts/
lima-1.0b5/lib/help/wizard/mudos_doc/driver/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/arrays/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/buffers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/compile/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/filesystem/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/floats/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/functions/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/general/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mappings/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mixed/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/numbers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/constructs/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/types/
lima-1.0b5/lib/include/driver/
lima-1.0b5/lib/log/
lima-1.0b5/lib/obj/admtool/
lima-1.0b5/lib/obj/admtool/internal/
lima-1.0b5/lib/obj/admtool/mudinfo/
lima-1.0b5/lib/obj/admtool/secure/
lima-1.0b5/lib/obj/secure/
lima-1.0b5/lib/obj/secure/cmd/
lima-1.0b5/lib/obj/secure/mailers/
lima-1.0b5/lib/obj/secure/shell/
lima-1.0b5/lib/obj/secure/shell/classes/
lima-1.0b5/lib/obj/tasktool/
lima-1.0b5/lib/obj/tasktool/internal/
lima-1.0b5/lib/open/
lima-1.0b5/lib/secure/
lima-1.0b5/lib/secure/cgi/
lima-1.0b5/lib/secure/modules/
lima-1.0b5/lib/secure/simul_efun/
lima-1.0b5/lib/std/adversary/
lima-1.0b5/lib/std/adversary/advancement/
lima-1.0b5/lib/std/adversary/armor/
lima-1.0b5/lib/std/adversary/blows/
lima-1.0b5/lib/std/adversary/death/
lima-1.0b5/lib/std/adversary/formula/
lima-1.0b5/lib/std/adversary/health/
lima-1.0b5/lib/std/adversary/pulse/
lima-1.0b5/lib/std/adversary/wield/
lima-1.0b5/lib/std/classes/event_info/
lima-1.0b5/lib/std/container/
lima-1.0b5/lib/std/living/
lima-1.0b5/lib/std/modules/contrib/
lima-1.0b5/lib/std/patterns/
lima-1.0b5/lib/std/race/
lima-1.0b5/lib/std/race/restricted/
lima-1.0b5/lib/std/room/
lima-1.0b5/lib/tmp/
lima-1.0b5/lib/trans/
lima-1.0b5/lib/trans/admincmds/
lima-1.0b5/lib/trans/obj/
lima-1.0b5/lib/wiz/
/* Do not remove the headers from this file! see /USAGE for more info. */


/* Do not remove the headers from this file! see /USAGE for more info. */

#include <hooks.h>
inherit M_PARSING;

int is_visible();
string short();
string is_relation_alias(string al);
int valid_relation(string relation);

varargs mixed call_hooks(string, int, mixed);

//:FUNCTION check_permission
//check_permission(what) calls who->allow(what) in our owner, if one exists.
//Used by many of the verb routines to keep players from fiddling with things
//in other player's/monster's inventories.
mixed check_permission(string what) {
    object who = owner(this_object());

    if (!who || who->allow(what))
	return 1;
    return "#Rather impolite to do that without asking, don't you think?\n";
}

//:FUNCTION default_object_checks
//Nearly all direct/indirect parsing functions should call this.  It checks to 
//make sure that the object is visible to the enactor, amongst other things.
int default_object_checks()
{
  if(!is_visible())
    return 0;
  if(!short())
    return 0;
  return 1;
}
  
//:FUNCTION direct_verb_rule
//The default method of handling direct objects with verbs.
mixed direct_verb_rule(string verb,string rule,mixed args...)
{
  mixed temp;
  if(this_object()->is_container())
  {
    string aliased_to;
    if(rule=="WRD OBJ")
    {
      args[0]=PREPOSITION_D->translate_preposition(args[0]);
      aliased_to=is_relation_alias(args[0]);
      if(!valid_relation(args[0]))
      {
        if(!aliased_to)
          return 0;
        args[0]=aliased_to;
	    }
    }
  } else if(this_object()->is_exit()){
    temp=this_object()->complex_exit_direct_verb_rule(verb,rule,args...);
    if(!temp||stringp(temp))
      return temp;
  } else {
    return 0;
  }
  return default_object_checks();
}

//:FUNCTION do_verb_rule
//The default handling for all verbs.
int do_verb_rule(string verb,string rule,mixed args...)
{
  if(this_object()->is_container())
  {
    string aliased_to;
    if(rule=="WRD OBJ")
    {
      args[0]=PREPOSITION_D->translate_preposition(args[0]);
      aliased_to=is_relation_alias(args[0]);
      if(!valid_relation(args[0]))
	    {
        args[0]=aliased_to;
      }
    }
  }
  if(this_object()->is_exit())
    this_object()->complex_exit_do_verb_rule(verb,rule,args...);
}

//:FUNCTION direct_get_obj
//Do some checks for the parser when we are the OBJ of the "get OBJ" rule
mixed direct_get_obj(object ob)
{
    object who = owner(ob);

    if ( environment() == this_body() )
	return "#You already have it!\n";
    if ( who && who != this_body() )
	return "#Too bad you're not a skilled pickpocket.\n";
    if ( this_object() == this_body() )
	return "#You make an advance on yourself.\n";
    if (environment(this_object())!=environment(this_body()))
      return "#You cannot get that.";
    if(!default_object_checks())
      return 0;

    //:HOOK prevent_get
    //A yes/no/error hook called by direct_get_obj() if the standard conditions
    //succeed
    return call_hooks("prevent_get", HOOK_YES_NO_ERROR);
}

//:FUNCTION direct_get_obj_from_obj
//Handle parser checks for "get OBJ from OBJ"
//From doesn't care what relation Object 1 is in.
mixed direct_get_obj_from_obj(object ob1, object ob2)
{
  if (ob2 != 0 && environment(ob1) != ob2) return 0;
  return call_hooks("prevent_get", HOOK_YES_NO_ERROR);
}

//:FUNCTION direct_get_obj_from_wrd_obj
//Handle parser checks for "get OBJ from WRD OBJ"
//Leave the relation checks to indirect_
mixed direct_get_obj_from_wrd_obj(object ob1, string rel, object ob2)
{
  return direct_get_obj_from_obj(ob1, ob2);
}

//:FUNCTION direct_put_obj_wrd_obj
//Handle parser checks for "put OBJ WRD OBJ"     
mixed direct_put_obj_wrd_obj(object ob1, object ob2)
{
  return check_permission("put");
}

//:FUNCTION direct_get_obj_with_obj
//Handle parser checks for "get OBJ with OBJ"
mixed direct_get_obj_with_obj(object ob1, object ob2) {
    return direct_get_obj(ob1);
}

//:FUNCTION need_to_have
//Do some sanity checks for verbs that auto-take objects, or only allow
//you to use objects you are carrying.
//Most of the work is done in try_to_acquire.
mixed need_to_have() {
  mixed res = direct_get_obj(this_object());
  if(!default_object_checks())
    return 0;
  if (res == "#You already have it!\n")
    return 1;
  return res;
}

//:FUNCTION direct_look_at_obj
//Whether or not an object can be looked at.  If there's no short description, 
//or it's not visible to the looker, return 0.
mixed direct_look_at_obj(object ob) {
  return default_object_checks();
}

//:FUNCTION direct_look_obj
//Whether or not an object can be looked at.  If there's no short description, 
//or it's not visible to the looker, return 0.
mixed direct_look_obj(object ob) {
  return default_object_checks();
}

//:FUNCTION direct_look_for_obj
//Always allow "look for OBJ" to succeed by default.
mixed direct_look_for_obj(object ob) {
    return 1;
}

//:FUNCTION direct_look_wrd_obj
//Set "look WRD OBJ" to fail by default.
mixed direct_look_wrd_obj(object ob) {
    return "#You can't look there";
}

//:FUNCTION direct_sell_obj
//Handle parser checks for "sell OBJ"
mixed direct_sell_obj(object ob) {
  return need_to_have();
}

//:FUNCTION direct_smell_obj
//Handle parser checks for "smell OBJ" rule.
mixed direct_smell_obj(object ob)
{
    if(!default_object_checks())
      return 0;
    return check_permission("smell");
}

//:FUNCTION direct_give_obj_to_liv
//Handle parser checks for "give OBJ to LIV" rule, where we are the object
//being given.
mixed direct_give_obj_to_liv( object obj, object liv )
{
  return need_to_have();
}

//:FUNCTION direct_eat_obj
//Handle parser checks for "eat OBJ" rule.
mixed direct_eat_obj(object ob) {
    if(!default_object_checks())
      return 0;
    return "I don't think " + this_object()->the_short() + " would agree with you.\n";
}

//### shouldn't these to only be in coins?
mixed direct_give_wrd_str_to_liv()
{
    return 1;
}

//### This DEFINATELY shouldn't be here.  Should be in living.c
mixed indirect_give_wrd_str_to_liv()
{
    return 1;
}

mixed direct_look_str_obj(string prep, object ob) {
    return "There is nothing " + prep + " " + this_object()->the_short() + ".\n";
}



//:FUNCTION direct_sell_obj_to_liv
//Handle parser checks for "sell OBJ to LIV"
mixed direct_sell_obj_to_liv(object ob, object liv, mixed foo) {
    return need_to_have();
}

//:FUNCTION direct_buy_obj_from_liv
//Handle parser checks for "buy OBJ from LIV"
mixed direct_buy_obj_from_liv(object ob, object liv) {
    if (owner(ob) != liv)
	return liv->query_possessive() + "doesn't have that!\n";
    if(!default_object_checks())
      return 0;
    return 1;
}

//:FUNCTION direct_drop_obj
//Handle parser checks for "drop OBJ" 
mixed direct_drop_obj(object ob)
{
    if(!default_object_checks())
      return 0;
    if ( environment() != this_body() )
	return "#You don't have it!\n";

    //:HOOK prevent_drop
    //A yes/no/error hook called by direct_drop_obj() if the standard conditions
    //succeed

    return call_hooks("prevent_drop", HOOK_YES_NO_ERROR);
}

//:FUNCTION direct_flip_obj
//Handle parser checks for "flip OBJ"
mixed direct_flip_obj(object ob) {
  if(!default_object_checks())
    return 0;
  //:HOOK direct_flip
  //A yes/no/error hook called by direct_flip_obj(); if no hooks exists, the
  //useless message will be used.
  
  return call_hooks("direct_flip", HOOK_YES_NO_ERROR,
		    useless( "Fiddling with " + ob->the_short()));
}

//:FUNCTION direct_throw_obj
//Handle parser checks for "throw OBJ"
mixed direct_throw_obj(object ob1, object ob2)
{
    return need_to_have();
}

//:FUNCTION direct_throw_obj_at_obj
//Handle parser checks for "throw OBJ at OBJ"
mixed direct_throw_obj_at_obj(object ob1, object ob2)
{
    return need_to_have();
}

//:FUNCTION indirect_throw_obj_at_obj
//Handle parser checks for "throw OBJ at OBJ"
mixed indirect_throw_obj_at_obj(object ob1, object ob2)
{
  return default_object_checks();
}

//:FUNCTION direct_pull_obj
// Handle parser checks for "pull OBJ"
mixed direct_pull_obj( object ob )
{
    if(!default_object_checks())
      return 0;
    return useless( "Pulling " + ob->the_short() );
}

//:FUNCTION direct_press_obj
// Parser check for "press OBJ"
mixed direct_press_obj( object ob )
{
    if(!default_object_checks())
      return 0;
    return useless( "Pushing " + ob->the_short());
}

//:FUNCTION direct_search_obj
// Parser check for "search OBJ"
mixed direct_search_obj( object ob )
{
  return default_object_checks();
}


//:FUNCTION direct_search_obj_for_obj
//Default
mixed direct_search_obj_for_obj( object ob1, object ob2 )
{
  return default_object_checks();
}

//:FUNCTION indirect_search_obj_for_obj
//Default
mixed indirect_search_obj_for_obj( object ob1, object ob2 )
{
  return default_object_checks();
}

//FUNCTION direct_search_for_str
//Default
mixed direct_search_for_str( string str )
{
    return 1;
}

//:FUNCTION indirect_search_obj_with_obj
//Default.
mixed indirect_search_obj_with_obj( object ob1, object ob2 )
{
  if(!default_object_checks())
      return 0;
    if( environment(ob2) != this_body())
	return "Maybe you should search it with something you're holding.";
    return 1;
}

//:FUNCTION direct_search_obj_with_obj
//Default
mixed direct_search_obj_with_obj( object ob1, object ob2 )
{
    if(!default_object_checks())
      return 0;
    return 1;
}

//:FUNCTION direct_search_for_str_in_obj
//Default
mixed direct_search_for_str_in_obj( string str, object ob )
{
    return 1;
}

//:FUNCTION direct_search_obj_for_str
//Default
mixed direct_search_obj_for_str( object ob, string str )
{
    if(!default_object_checks())
      return 0;
    return 1;
}

//:FUNCTION direct_search_obj_with_obj_for_str
//Default
mixed direct_search_obj_with_obj_for_str( object ob, string str )
{
    if(!default_object_checks())
      return 0;
    return 1;
}

//:FUNCTION indirect_search_obj_with_obj_for_str
mixed indirect_search_obj_with_obj_for_str( object ob1, object ob2,  string str )
{
    if(!default_object_checks())
      return 0;
    if( environment(ob2) != this_body())
	return "Maybe you should search it with something you're holding.";
    return 1;
}

//:FUNCTION direct_search_for_str_in_obj_with_obj
//Default
mixed direct_search_for_str_in_obj_with_obj( string str, object ob1, object ob2 )
{
    return 1;
}

//:FUNCTION indirect_search_for_str_in_obj_with_obj
//Default 
mixed indirect_search_for_str_in_obj_with_obj( string str, object ob1, object ob2 )
{
    if(!default_object_checks())
      return 0;
    if( environment( ob2 ) != this_body() )
	return "Maybe you should search it with something you're holding.";
    return 1;
}

//:FUNCTION direct_search_obj_for_str_with_obj
//Default
mixed direct_search_obj_for_str_with_obj( object ob1, string str, object ob2 )
{
    if(!default_object_checks())
      return 0;
    return 1;
}

//:FUNCTION indirect_search_obj_for_str_with_obj
//Default
mixed indirect_search_obj_for_str_with_obj( object ob1, string str, object ob2 )
{
    if(!default_object_checks())
      return 0;
    if( environment( this_object()) != this_body())
	return "Maybe you should search it with something you're holding.";
    return 1;
}

//FUNCTION do_search
// Default searching.
varargs void do_search( object with, string search_for )
{
    string str = "$N $vsearch ";
    if( this_object() == environment( this_body()))
	str += "around";
    else str += "the $o0";
    if( with ) str += " with $p $o1";
    str += ", but $vdiscover nothing.";
    this_body()->simple_action( str, this_object(), with );
}


//:FUNCTION direct_listen_to_obj
//Default
mixed direct_listen_to_obj( object obj )
{
    if(!default_object_checks())
      return 0;
    return "You hear nothing special.";
}