示例#1
0
void stomach_contents::absorb_water( player &p, units::volume amount )
{
    if( water < amount ) {
        amount = water;
        water = 0_ml;
    } else {
        water -= amount;
    }
    if( p.get_thirst() < -100 ) {
        return;
    } else if( p.get_thirst() - units::to_milliliter( amount / 5 ) < -100 ) {
        p.set_thirst( -100 );
    }
    p.mod_thirst( -units::to_milliliter( amount ) / 5 );
}
示例#2
0
// Caps both actual nutrition/thirst and stomach capacity
void cap_nutrition_thirst( player &p, int capacity, bool food, bool water )
{
    if( ( food && p.get_hunger() < capacity ) ||
        ( water && p.get_thirst() < capacity ) ) {
        p.add_msg_if_player( _( "You can't finish it all!" ) );
    }

    if( p.get_hunger() < capacity ) {
        p.mod_stomach_food( p.get_hunger() - capacity );
        p.set_hunger( capacity );
    }

    if( p.get_thirst() < capacity ) {
        p.mod_stomach_water( p.get_thirst() - capacity );
        p.set_thirst( capacity );
    }

    add_msg( m_debug, "%s nutrition cap: hunger %d, thirst %d, stomach food %d, stomach water %d",
             p.disp_name().c_str(), p.get_hunger(), p.get_thirst(), p.get_stomach_food(),
             p.get_stomach_water() );
}