Eating

From IvanWiki
Revision as of 06:39, 12 August 2014 by 4zb4 (talk | contribs) (Some of this is probably wrong, I'm trying to get my head around the spoil code and I cannot brain today.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Spoiler Warning: This page contains spoilers which may affect your IVAN experience negatively


Eating is the act of (e)ating any kind of food available in the game. Eating anything provides nourishment, changing your "fullness" status for better or worse. Eating certain types of food can also bestow various effects upon the player.

For a food item to be edible, it must be tagged with a compatible ConsumeType in materials.dat for whatever is doing the eating (e.g. humans can eat CT_FRUIT, CT_MEAT, CT_PROCESSED and CT_LIQUID but not CT_BONE like canines can.)
Currently, only liquids and organic materials have a nutrition value that dictates how filling they are.

The amount of nutrition one receives upon eating a food item is determined by the item's edible volume and its nutritional value divided by its spoil level.
That is to say a food item will fill up the player more if it is high is volume and/or nutritional value, and will fill you up less if it is spoiled.

material* organic::EatEffect(character* Eater, long Amount)
{
  Amount = Volume > Amount ? Amount : Volume;
  GetMotherEntity()->SpecialEatEffect(Eater, Amount);
  Effect(Eater, TORSO_INDEX, Amount);
  Eater->ReceiveNutrition(GetNutritionValue() * Amount * 20 / (1000 * (GetSpoilLevel() + 1)));

  if(IsInfectedByLeprosy() && Amount && !RAND_N(25000 / Amount))
    Eater->GainIntrinsic(LEPROSY);

  if(GetSpoilLevel() > 0)
  {
    Eater->BeginTemporaryState(CONFUSED, int(Amount * GetSpoilLevel() * sqrt(GetNutritionValue()) / 1000));

    if(GetBodyFlags() & CAN_HAVE_PARASITE
       && !(RAND() % (250 / GetSpoilLevel())))
      Eater->GainIntrinsic(PARASITIZED);
  }

  if(GetSpoilLevel() > 4)
    Eater->BeginTemporaryState(POISONED, int(Amount * (GetSpoilLevel() - 4) * sqrt(GetNutritionValue()) / 1000));

  if(Volume != Amount)
  {
    EditVolume(-Amount);
    return 0;
  }
  else
    return MotherEntity->RemoveMaterial(this);
}

Spoiling

Every organic material in the game rots away at a steady pace influenced by its SpoilModifier. Initially, every food item has a small grace period before it can start spoiling. After this the game will start checking against its spoil modifier in order to add to the item's spoil level. The higher the item's SpoilModifier, the slower it will rot. When an item reaches the maximum spoil level, it will rot away to nothing.

Eating a spoiled item comes with some risks - particularly with meats. Firstly, spoiled food is less nutritious. Second and much more important is that any food that has even a single level of spoiling can inflict confusion upon the eater for a period influenced by its volume and spoil level divided by its nutritional value. In addition, if the item can contain parasites (e.g. most meats) there is a chance that the eater will also gain a tapeworm or broad tapeworm which will inflict damage over time and can only be removed via vomiting.
Finally, if the item's spoil level is beyond 4 it will instantly poison the eater for a period influenced by its volume, spoil level and nutritional value.

void organic::Be(ulong Flags)
{
  if(SpoilCheckCounter++ >= 50)
  {
    if(MotherEntity->AllowSpoil())
    {
      if(Flags & HASTE)
	SpoilCounter += 125;
      else if(Flags & SLOW)
	SpoilCounter += 5;
      else
	SpoilCounter += 25;

      if(SpoilCounter < GetSpoilModifier())
      {
	if(SpoilCounter << 1 >= GetSpoilModifier())
	{
	  int NewSpoilLevel = ((SpoilCounter << 4) / GetSpoilModifier()) - 7;

	  if(NewSpoilLevel != SpoilLevel)
	  {
	    SpoilLevel = NewSpoilLevel;
	    MotherEntity->SignalSpoilLevelChange(this);
	  }
	}
      }
      else
      {
	SpoilLevel = 8;
	MotherEntity->SignalSpoil(this);
      }
    }

    SpoilCheckCounter = 0;
  }
}


Special Effects

//(work in progress)

Some food items possess special properties and grant various effects when eaten.