/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@hom.net
MUD++ development mailing list mudpp@van.ml.org
------------------------------------------------------------------------------
char_act.cc
*/
#include "config.h"
#include "string.h"
#include "llist.h"
#include "index.h"
#include "hash.h"
#include "room.h"
#include "bit.h"
#include "affect.h"
#include "char.h"
#include "global.h"
// This isn't finished, need to check liquid types and container
// amount, drink triggers, poison, etc. -Fusion
bool Char::quaff( Object * obj )
{
String str;
int diff;
if( obj->isLiquidContainer() )
{
ObjLiquidContainer * drinkC = (ObjLiquidContainer *) obj;
if( getThirst() >= MAX_DRINK )
{
out( "You are too full to drink.\n\r" );
return false;
}
if( drinkC->getAmount() <= 0 )
{
out( "There is nothing left to drink." );
return false;
}
if ( drinkC->TgUsed( this, NULL ) )
return false;
diff = MAX_DRINK - thirst;
diff = min( diff, drinkC->getAmount() );
drinkC->setAmount( drinkC->getAmount() - diff );
out( "You drink.\n\r" );
str << getShort() << " drinks from " << drinkC->getShort() << ".\n\r";
in_room->outAllCharExcept( str, this, 0 );
thirst += diff;
if( thirst == MAX_DRINK )
out( "You are no longer thirsty.\n\r" );
return true;
}
else if( obj->isPotion() )
{
if ( obj->TgUsed( this, NULL ) )
return false;
out( "You work the seal off " );
out( obj->getShort() );
out( "\n\rYou quaff " );
out( obj->getShort() );
out( "\n\r" );
str << getShort() << " works the seal off " << obj->getShort()
<< ".\n\r" << getShort() << " quaffs " << obj->getShort()
<< ".\n\r";
in_room->outAllCharExcept( str, this, 0 );
// potion should affect thirst also, add another value later
obj->cast( this );
obj->extract();
obj->fordelete();
return true;
}
return false;
}
// Make a config option MAX_HUNGER
bool Char::eat( Object * obj )
{
String str;
int diff;
Affect * aff;
int pois;
ObjFood * food;
if ( !obj->isFood() )
{
// we will add sword-eating wizards later
out( "You can't eat this!.\n\r");
return false;
}
if( getHunger() >= MAX_FOOD )
{
out( "You are too full to eat.\n\r" );
return false;
}
food = (ObjFood*) obj;
if( food->TgUsed(this,NULL) )
return false;
// add poison code
if( food->affectedBy( AFF_POISON ) )
{
aff = food->getAffect( AFF_POISON );
pois = aff->getLevel();
}
else pois = 0;
diff = MAX_FOOD - hunger;
diff = min( diff, food->getFoodWorth() );
hunger += diff;
if( diff == food->getFoodWorth() )
{
str << "You eat " << food->getShort() << ".\n\r";
out( str );
str.clr();
str << getShort() << " eats " << food->getShort() << ".\n\r";
food->extract();
food->fordelete();
}
else
{
str << "You take a bite of " << food->getShort() << ".\n\r";
out( str );
str.clr();
str << getShort() << " takes a bite of " << food->getShort() << ".\n\r";
food->setFoodWorth( food->getFoodWorth() - diff );
}
in_room->outAllCharExcept( str, this, 0 );
if( hunger == MAX_FOOD )
out( "You are full.\n\r" );
if( pois )
{
if( pois < POISON_MEDIUM )
out( "You feel a little sick.\n\r" );
else if( pois < POISON_SERIOUS )
out( "You choke and gag as a pain grips your bowels!!\n\r" );
else
{
out( "You feel a sharp pain in your bowels as your world goes black!\n\r" );
die( 0 );
}
}
return true;
}