food.c

./lib/inherit/food.c · 1.5 KB

From the archive h7v3.0a.tar.gz

Download the archive   « Back to the archive contents

#include <mudlib.h>
inherit "inherit/base/consume";

string query_object_type() { return "Food"; }
status query_food()        { return 1;      }

mapping query_specs() {
  return ([
	"strength" 		: strength, 
	"room_msg" 		: room_msg,
	"consumer_msg" 	: consumer_msg,
  ]);
}



#ifdef NATIVE_MODE
void create() {
#else
void reset(status arg) {

  /* Default values */
  if(arg) return;
#endif /* native */

  set_sell_destruct(1);
  set_name("bread");
  set_short("A stale loaf of bread");
  set_long("It looks a little moldy.\n");
  set_room_msg(
    "@@query_name:$this_player()$@@ munches on some "+
    "@@query_name:$this_object()$@@.\n");
  set_consumer_msg("Yum yum!!\n");
  set_strength(2);
}

void init() {
  ::init();
  if(environment() != this_player()) return;
  add_action("eat", "eat");
}

status eat(string str) {
  object tp, ob;

  tp = this_player();

  if(!str) { 
    write("Eat what?\n");
    return 1;
  }
  
  if(!(ob = present(str,tp))) {
    if(!str) str = "food";
    write("You don't have any "+ str +" to eat.\n");
    return 1;
  }

  if(ob != this_object()) return 0;

  if((int)tp->query_constitution() * 8 < strength) {
    write("You realize even before trying that you'll never be able\n"+ 
       "to eat all this.\n");
    return 1;
  }
  if(!tp->eat_food(strength)) return 1;
  ::consume(str);
  destruct(this_object());
  return 1;
}

void set_eater_mess(string str) { set_consumer_msg(str); }
void set_eating_mess(string str){ set_room_msg(str);     }



Site Stats

Snippets: 1791
Codebases: 571