dsIIr4/bin/
dsIIr4/extra/creremote/
dsIIr4/extra/wolfpaw/
dsIIr4/lib/cmds/admins/
dsIIr4/lib/cmds/common/
dsIIr4/lib/cmds/creators/include/
dsIIr4/lib/cmds/creators/include/SCCS/
dsIIr4/lib/daemon/services/
dsIIr4/lib/doc/
dsIIr4/lib/domains/Ylsrim/
dsIIr4/lib/domains/Ylsrim/adm/
dsIIr4/lib/domains/Ylsrim/armor/
dsIIr4/lib/domains/Ylsrim/broken/
dsIIr4/lib/domains/Ylsrim/fish/
dsIIr4/lib/domains/Ylsrim/meal/
dsIIr4/lib/domains/Ylsrim/npc/
dsIIr4/lib/domains/Ylsrim/virtual/
dsIIr4/lib/domains/Ylsrim/weapon/
dsIIr4/lib/domains/campus/adm/
dsIIr4/lib/domains/campus/etc/
dsIIr4/lib/domains/campus/meals/
dsIIr4/lib/domains/campus/npc/
dsIIr4/lib/domains/campus/save/
dsIIr4/lib/domains/campus/txt/
dsIIr4/lib/domains/campus/txt/ai/charles/
dsIIr4/lib/domains/campus/txt/ai/charles/bak2/
dsIIr4/lib/domains/campus/txt/ai/charles/bak2/bak1/
dsIIr4/lib/domains/campus/txt/ai/charly/
dsIIr4/lib/domains/campus/txt/ai/charly/bak/
dsIIr4/lib/domains/campus/txt/jenny/
dsIIr4/lib/domains/default/creator/
dsIIr4/lib/domains/default/doors/
dsIIr4/lib/domains/default/etc/
dsIIr4/lib/domains/default/virtual/
dsIIr4/lib/domains/default/weap/
dsIIr4/lib/domains/town/virtual/
dsIIr4/lib/lib/comp/
dsIIr4/lib/lib/lvs/
dsIIr4/lib/lib/user/
dsIIr4/lib/lib/virtual/
dsIIr4/lib/log/
dsIIr4/lib/obj/book_source/
dsIIr4/lib/obj/include/
dsIIr4/lib/realms/template/
dsIIr4/lib/realms/template/adm/
dsIIr4/lib/realms/template/area/armor/
dsIIr4/lib/realms/template/area/npc/
dsIIr4/lib/realms/template/area/obj/
dsIIr4/lib/realms/template/area/room/
dsIIr4/lib/realms/template/area/weap/
dsIIr4/lib/realms/template/bak/
dsIIr4/lib/realms/template/cmds/
dsIIr4/lib/save/
dsIIr4/lib/save/kills/o/
dsIIr4/lib/secure/cfg/classes/
dsIIr4/lib/secure/cmds/creators/include/
dsIIr4/lib/secure/cmds/players/
dsIIr4/lib/secure/cmds/players/include/
dsIIr4/lib/secure/daemon/include/
dsIIr4/lib/secure/lib/
dsIIr4/lib/secure/lib/include/
dsIIr4/lib/secure/lib/net/include/
dsIIr4/lib/secure/lib/std/
dsIIr4/lib/secure/modules/
dsIIr4/lib/secure/npc/
dsIIr4/lib/secure/obj/include/
dsIIr4/lib/secure/room/
dsIIr4/lib/secure/save/
dsIIr4/lib/secure/save/boards/
dsIIr4/lib/secure/save/players/g/
dsIIr4/lib/secure/tmp/
dsIIr4/lib/secure/verbs/creators/
dsIIr4/lib/shadows/
dsIIr4/lib/spells/
dsIIr4/lib/std/board/
dsIIr4/lib/std/lib/
dsIIr4/lib/tmp/
dsIIr4/lib/verbs/admins/include/
dsIIr4/lib/verbs/common/
dsIIr4/lib/verbs/common/include/
dsIIr4/lib/verbs/creators/include/
dsIIr4/lib/verbs/players/include/SCCS/
dsIIr4/lib/verbs/rooms/
dsIIr4/lib/verbs/rooms/include/
dsIIr4/lib/www/
dsIIr4/v22.2b14-dsouls2/
dsIIr4/v22.2b14-dsouls2/ChangeLog.old/
dsIIr4/v22.2b14-dsouls2/Win32/
dsIIr4/v22.2b14-dsouls2/compat/
dsIIr4/v22.2b14-dsouls2/compat/simuls/
dsIIr4/v22.2b14-dsouls2/include/
dsIIr4/v22.2b14-dsouls2/mudlib/
dsIIr4/v22.2b14-dsouls2/testsuite/
dsIIr4/v22.2b14-dsouls2/testsuite/clone/
dsIIr4/v22.2b14-dsouls2/testsuite/command/
dsIIr4/v22.2b14-dsouls2/testsuite/data/
dsIIr4/v22.2b14-dsouls2/testsuite/etc/
dsIIr4/v22.2b14-dsouls2/testsuite/include/
dsIIr4/v22.2b14-dsouls2/testsuite/inherit/
dsIIr4/v22.2b14-dsouls2/testsuite/inherit/master/
dsIIr4/v22.2b14-dsouls2/testsuite/log/
dsIIr4/v22.2b14-dsouls2/testsuite/single/
dsIIr4/v22.2b14-dsouls2/testsuite/single/tests/compiler/
dsIIr4/v22.2b14-dsouls2/testsuite/single/tests/efuns/
dsIIr4/v22.2b14-dsouls2/testsuite/single/tests/operators/
dsIIr4/v22.2b14-dsouls2/testsuite/u/
dsIIr4/v22.2b14-dsouls2/tmp/
dsIIr4/win32/
/*    /lib/meal.c
 *    from the Dead Souls LPC Library
 *    standard food and drink code
 *    created by descartes of Borg 950603
 *    Version: @(#) meal.c 1.3@(#)
 *    Last modified: 97/01/03
 */

#include <lib.h>
#include <function.h>
#include <meal_types.h>
#include <rounds.h>
#include <vendor_types.h>
#include "include/meal.h"

inherit LIB_BAIT_WITH;
inherit LIB_ITEM;

private int MealStrength, MealType;
private string EmptyItem, EmptyName, OtherMessage;
private mixed EmptyShort, EmptyLong, MyMessage;

static void create() {
    item::create();
    MealType = MEAL_ALCOHOL;
    EmptyItem = 0;
    EmptyName = "bottle";
    EmptyShort = "an empty bottle";
    EmptyLong = "This empty bottle once contained some liquid.";
    MyMessage = "You drink your drink.";
    OtherMessage = "$N drinks $P drink.";
    SetVendorType(VT_DRINK);
    AddSave( ({ "MealStrength", "MealType", "BaitStrength" }) );
}

mixed direct_drink_obj() { 
    if( environment() != this_player() ) return "#You don't have that!";
    if( MealType & MEAL_FOOD ) return "Wouldn't you rather eat it?";
    return this_player()->CanDrink(this_object());
}

mixed direct_drink_from_obj() {
    if( MealType & MEAL_FOOD ) return 0;
    if( environment() != this_player() ) return "#You don't have that!";
    return this_player()->CanDrink(this_object());
}

mixed direct_eat_obj() {
    if( environment() != this_player() ) return "#You don't have that!";
    if( !(MealType & MEAL_FOOD) ) return "Wouldn't you rather drink it?";
    return this_player()->CanEat(this_object());
}

static mixed AddSave(mixed *vars) { return item::AddSave(vars); }

string GetShort() { return item::GetShort(); }

int eventDestruct() { return item::eventDestruct(); }

mixed eventDrink(object who) {
    mixed tmp;
    int x;
    object ob;

    if( (tmp = (mixed)who->eventDrink(this_object())) != 1 ) return tmp;
    if( (x = functionp(MyMessage)) && !(x & FP_OWNER_DESTED) ) {
	evaluate(MyMessage, who);
    }
    else {
	string mymsg, othermsg;

	mymsg = replace_string(MyMessage, "$P", "your");
	othermsg = replace_string(OtherMessage, "$P", possessive(who));
	mymsg = replace_string(mymsg, "$N", "you");
	othermsg = replace_string(othermsg, "$N", (string)who->GetName());
	who->eventPrint( capitalize(mymsg) );
	environment(who)->eventPrint( capitalize(othermsg), who );
    }

    ob = new(GetEmptyItem() || LIB_USED_MEAL);
    if( base_name(ob) == LIB_USED_MEAL ) {
	ob->SetKeyName(GetEmptyName());
	ob->SetId( ({ GetEmptyName(), "container", "empty container" }) );
	ob->SetShort(GetEmptyShort());
	ob->SetAdjectives( ({ "empty", "drained" }) );
	ob->SetLong(GetEmptyLong());
	ob->SetBaseCost(1);
	ob->SetMass(10);
	ob->SetDestroyOnSell();
    }
    if( !((int)ob->eventMove(who)) ) {
	who->eventPrint("You drop " + (string)ob->GetShort() + ".");
	environment(who)->eventPrint((string)who->GetName() +
	  " drops " + (string)ob->GetShort() + ".", who);
	ob->eventMove(environment(who));
    }

    if( x = GetPoison() ) {
	if( random((int)who->GetStatLevel("luck")) > 35 )
	    who->eventPrint("That didn't seem to taste quite right.");
	who->AddPoison(x);
    }
    Destruct();
    return 1;
}

mixed eventEat(object who) {
    mixed tmp;
    int x;

    if( (tmp = (mixed)who->eventEat(this_object())) != 1 ) return tmp;
    if( (x = functionp(MyMessage)) && !(x & FP_OWNER_DESTED) ) {
	evaluate(MyMessage, who);
    }
    else {
	string mymsg, othermsg;

	mymsg = replace_string(MyMessage, "$P", "your");
	othermsg = replace_string(OtherMessage, "$P",
	  possessive(who));
	mymsg = replace_string(mymsg, "$N", "you");
	othermsg = replace_string(othermsg, "$N", (string)who->GetName());
	who->eventPrint( capitalize(mymsg) );
	environment(who)->eventPrint( capitalize(othermsg), who );
    }
    if( x = GetPoison() ) {
	if( random((int)who->GetStatLevel("luck")) > 35 )
	    who->eventPrint("You notice a strange aftertaste.");
	who->AddPoison(x);
    }
    Destruct();
    return 1;
}

int eventPoison(object who, object agent, int x) {
    who->eventPrint("You put some poison "
      "in " + add_article(GetShort()) + ".");
    environment(who)->eventPrint( (string)who->GetName()+" puts something "
      "in " + add_article(GetShort()) + ".", who);
    AddPoison(x);
    return 1;
}

string SetEmptyItem(string file) { return (EmptyItem = file); }

string GetEmptyItem() { return EmptyItem; }

string SetEmptyName(string str) { return (EmptyName = str); }

string GetEmptyName() { return EmptyName; }

mixed SetEmptyShort(mixed val) { return (EmptyShort = val); }

mixed GetEmptyShort() { return EmptyShort; }

mixed SetEmptyLong(mixed val) { return (EmptyLong = val); }

mixed GetEmptyLong() { return EmptyLong; }

int SetMealType(int x) {
    int vt = 0;

    if( x & MEAL_FOOD ) {
	vt |= VT_FOOD;
	MyMessage = "You eat your food.";
	OtherMessage = "$N eats $P food.";
    }
    if( x & MEAL_DRINK ) vt |= VT_DRINK;
    SetVendorType(vt);
    return (MealType = x);
}

int GetMealType() { return MealType; }

int SetStrength(int x) { return (MealStrength = x); }

int GetStrength() { return MealStrength; }

varargs void SetMealMessages(mixed array val...) {
    if( !arrayp(val) ) {
	error(sprintf("Bad argument 1 to SetMealMessages(): %O\n", val));
    }
    if( sizeof(val) == 1 ) {
	if( arrayp(val[0]) ) SetMealMessages(val[0]...);
	else if( stringp(val[0]) || functionp(val[0]) ) MyMessage = val[0];
	else error(sprintf("Bad argument 1 to SetMealMessages(): %O\n",
		val[0]));
	return;
    }
    if( !stringp(val[0]) )
	error(sprintf("Bad argument 1 to SetMealMessages(): %O\n", val[0]));
    else if( !stringp(val[1]) ) 
	error(sprintf("Bad argument 2 to SetMealMessages(): %O\n", val[1]));
    MyMessage = val[0];
    OtherMessage = val[1];
}

mixed *GetMealMessages() { return ({ MyMessage, OtherMessage }); }

int GetValue() {
    int x;

    x = GetStrength();
    return (x * (6 + x)) / 10 + 10;
}