/
lib/banish/
lib/d/coronos/
lib/d/coronos/w/alena/
lib/d/coronos/w/angel/
lib/d/coronos/w/angel/caves/
lib/d/coronos/w/angel/caves/monst/
lib/d/coronos/w/angel/city/chambers/
lib/d/coronos/w/angel/city/monst/
lib/d/coronos/w/angel/city/obj/
lib/d/coronos/w/angel/city/streets/
lib/d/coronos/w/angel/farms/plains/
lib/d/coronos/w/angel/monst/
lib/d/tempus/
lib/d/tempus/w/angel/
lib/d/tempus/w/kingbill/
lib/d/tempus/w/mirak/
lib/d/tempus/w/mirak/monst/
lib/d/tempus/w/mirak/obj/
lib/d/tempus/w/relgar/planes/baat/
lib/d/tempus/w/sarak/
lib/d/tempus/w/serepion/mon/
lib/d/tempus/w/valrejn/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/include/fn_specs/
lib/info/
lib/inherit/base/
lib/log/
lib/log/mailbox/
lib/log/main/
lib/news/
lib/obj/party/
lib/objects/componen/
lib/open/
lib/open/party/
lib/open/paste/
lib/open/spells/
lib/open/valrejn/
lib/players/
lib/players/alena/
lib/players/alena/obj/
lib/players/alena/open/
lib/players/alena/private/
lib/players/angel/
lib/players/angel/obj/
lib/players/ash/
lib/players/biggs/
lib/players/biggs/food/
lib/players/biggs/gobkeep/
lib/players/biggs/mnstr/
lib/players/biggs/town/caves/
lib/players/biggs/town/tower/
lib/players/biggs/wpns/
lib/players/calris/
lib/players/deathurg/
lib/players/deathurg/open/
lib/players/deathurg/private/thief/
lib/players/dogberry/
lib/players/dogberry/library/
lib/players/dogberry/open/
lib/players/epsilon/
lib/players/epsilon/private/
lib/players/farewell/
lib/players/hippo/
lib/players/hippo/open/
lib/players/hippo/tools/
lib/players/jimpa/
lib/players/josh/
lib/players/josh/room/
lib/players/josh/room/mage/dungeon/
lib/players/josh/room/mage/dungeon/obj/
lib/players/josh/wep/
lib/players/kingbill/
lib/players/metatron/
lib/players/miette/
lib/players/mirak/
lib/players/mirak/open/
lib/players/parsilan/
lib/players/relgar/
lib/players/relgar/private/
lib/players/sarak/
lib/players/sarak/bugs/
lib/players/sarak/feelings/
lib/players/sarak/magical/
lib/players/sarak/minotaur/island/
lib/players/sarak/open/
lib/players/sarak/private/
lib/players/serepion/
lib/players/serepion/open/
lib/players/serepion/private/
lib/players/spike/
lib/players/spike/open/
lib/players/spike/private/
lib/players/spike/seaworld/
lib/players/valrejn/
lib/players/valrejn/open/
lib/players/valrejn/private/
lib/players/virus/
lib/players/wrath/
lib/players/wrath/arm/
lib/players/wrath/mon/
lib/players/wrath/room/
lib/players/wrath/room/entry/
lib/players/wrath/room/zolgath/
lib/players/wrath/weap/
lib/players/zil/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/library/
lib/room/city/library/open/books/
lib/room/city/shop/
lib/room/death/
lib/room/death/open/
lib/room/island/
lib/room/keeps/
lib/room/registry/
lib/room/ships/crew/
lib/room/ships/open/
lib/room/ships/open/types/bounty/
lib/room/ships/open/types/nebula/
lib/room/ships/open/types/phoenix/
lib/secure/udp_cmd_/
lib/skills/
lib/skills/fighter/
lib/skills/psionici/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/no_banis/
lib/usr/players/
/* action bin for pick/get/etc... for parse_command */

/******************************************************************************
 * The ACTIONS object. v2.0
 *
 * In conjunction with the parse.c/parse_old.c object from the driver we can
 * get items we never could before!
 * Check also the command_centre in player.c
 * Angel. Aug, '96
 */

#include <mudlib.h>
#include <i_to_str.h>


#define AMT_MONEY  (int)this_player()->query_money()
#define NAME       (string)this_player()->query_name()
#define LEVEL      (int)this_player()->query_level()

/*
put x in y -> give x to y
get (or pick_up) x from y
give x to y 
drop_thing (x) (in y)
*/

/******************************************************************************
 * get x FROM y (a room or bag) and put them in me! 
 */

status get_things(object *items, string prep, object container) {
  int i, abort, wt, haveGet;
  string from, item_name;

  if(this_player()->query_ghost()) {
    tell_object(this_player(),"It passes straight through your hands...\n");
    return 1; 
  } 

  if((int)this_player()->query_real_light() < 1) {
    tell_object(this_player(), "It's too dark to do that.\n");
    return 1;
  }

  if(!prep) {
    switch(query_verb()) {
      case "get" : case "take" : prep = "from"; break;
      default : prep = "from"; break;
    }
  }
  if(container && !sizeof(items)) {
    write("That's not in "+lower_case(container->short())+"\n");
    return 1;
  }

  if(!sizeof(items)) {
    tell_object(this_player(),"Usage: get <item|all>\n"+
    "       get <item|all> from <container>\n"); 
    return 1; 
  } 
  
  if(container) {
    if(living(container)) {
      write("I don't think "+container->short()+" will give that away.\n");
      return 1;
    }
  }
  if(!container) {
    container = environment(this_player());
  }


  if(!container->can_put_and_get(0)) {
    tell_object(this_player(),"You can't get anything from that!\n");
    return 1;
  }


  for(i=0; i<sizeof(items); i++) {
    if(items[i] == this_player()) continue;
    if(!items[i]->get()) {
      write(items[i]->short()+" won't budge a millimeter!\n");
      continue; 
    }
    if(present(items[i], this_player())) continue; /* dont get what we have! */
    if(!objectp(items[i]) || living(items[i])) {
      write(items[i]->short()+" wouldn't be too happy about that.\n");
      continue;
    }
    if(living(environment(items[i])) && 
      present(items[i], environment(items[i]))) {
      continue;
    }

    if(!(item_name = (string)items[i]->short())) continue;

    item_name = lower_case(item_name);

    if(++abort > 30) {
      tell_object(this_player(), "You "+query_verb()+" only "+int_to_str(30)+
      " "+items[i]->query_short()+"\n");
      return 1;
    }

    wt = (int)items[i]->query_weight();
    if(!this_player()->add_weight(wt)) {
      write("You're not strong enough to carry "+ item_name +".\n");
      say(NAME+" attempts to carry "+item_name+".\n"); 
      continue;
    }

    environment(items[i])->add_weight(-wt);
      
/* move it to me! */
#ifdef NATIVE_MODE
    items[i]->move(this_player()); 
#else
    move_object(items[i], this_player());
#endif /* NATIVE_MODE */

    item_name = lower_case(item_name);
    if(environment(this_player()) == container) {
      write("You "+query_verb()+" "+ item_name +".\n");
      say(NAME+" "+query_verb()+" "+ item_name +".\n");
      haveGet = 1;
    }
    else {
      write("You "+query_verb()+" "+item_name+" "
	+prep+" "+container->short()+"\n");
      say(NAME+" "+query_verb()+"s "+item_name+" "
	+prep+" "+container->short()+"\n");
      haveGet = 1;    
    } 
  }
  if(!haveGet)  {
    tell_object(this_player(), capitalize(query_verb())+" what? "+
    "You move the air about.\n");
  }
  return 1;
}


/* put something in something else */
status drop_things(object *items, string prep, object container) {
  int i, abort, wt, haveGive;
  string from, item_name;

  if(!prep) {
    switch(query_verb()) {
      case "drop" : prep = "in"; break;
      case "give" : prep = "to"; break;
      default : prep = "to"; break;
    }
  }



  if(this_player()->query_ghost()) {
    tell_object(this_player(),"It passes straight through your hands...\n");
    return 1; 
  } 

  if((int)this_player()->query_real_light() < 1) {
    tell_object(this_player(), "It's too dark to do that.\n");
    return 1;
  }

  if(!sizeof(items)) {
    tell_object(this_player(),"Usage: put|drop <item|all>\n"+
    "       put|drop <item|all> in <container>\n");
    return 1; 
  } 
  

  if(!container) container = environment(this_player());
  for(i=0; i<sizeof(items); i++) {
    if(items[i] == container) {
      write("You can't do that.\n");
      continue; 
    }

    if(!objectp(items[i]) || living(items[i]))   continue; /* no move living */ 
    if(!(item_name = (string)items[i]->short())) continue; /* no move invis  */

    if(!present(items[i], this_player())) {
      continue;
    }

    if(++abort > 30) {
      tell_object(this_player(), "You "+query_verb()+" only "+int_to_str(30)+
      " "+items[i]->query_short()+"\n");
      return 1;
    }

    item_name = (string)items[i]->short();
    item_name = lower_case(item_name);

    if((this_player() == environment(items[i]) && items[i]->drop()) ||
      (this_player() != environment(items[i]) && !items[i]->get())) {
      write ("You cannot "+query_verb()+" "+ item_name +".\n");
      continue;
    } 
     
    wt = (int)items[i]->query_weight();
    if(!container->add_weight(wt)) {
      write(container->short()+" cannot carry "+ item_name +".\n");
      say(NAME+" attempts "+query_verb()+" "+ item_name +" "+prep+" "+
               container->short()+".\n", container); 
      tell_object(container,NAME+" trys to "+query_verb()+" you "+ item_name
                           +" but you cannot carry it.\n");
      continue;
    }

    if(!container->can_put_and_get(0) &&
      (string)query_verb() != "give") {
        tell_object(this_player(),"You cannot do that!\n");
        return 1;
    }

    environment(items[i])->add_weight(-wt);
      

#ifdef NATIVE_MODE
    items[i]->move(container);
#else
    move_object(items[i], container);
#endif /* NATIVE_MODE */


    if(container == this_player()) {
      write("You "+query_verb()+" "+item_name+" "+prep+" yourself.\n");
      say(NAME+" "+query_verb()+" "+item_name+" "+prep+" "+
      (string)this_player()->query_objective()+"self.\n");
      haveGive = 1;
    }
    else {
      write("You "+query_verb()+" "+item_name+" "+prep+" "+
          lower_case(container->short())+"\n");
      say(NAME+" "+query_verb()+" "+item_name+" "+prep+" "+
        lower_case(container->short())+"\n", container);
      tell_object(container, NAME+" "+query_verb()+" you "+item_name+"\n");
      haveGive = 1;    
    }
  } 

  if(!haveGive) {
    tell_object(this_player(), capitalize(query_verb())+
    " what? You move the air about.\n");
  }
  return 1;
}