Skip to content

Commit

Permalink
contamination entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Dec 3, 2019
1 parent 72e0e40 commit 9c5d811
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,14 @@ bool player::eat( item &food, bool force )
}
}

// chance to get foodpoisoning from bacterial contamination
if( !will_vomit && !has_bionic( bio_digestion ) ) {
const int contamination = food.get_comestible()->contamination;
if( rng( 1, 100 ) <= contamination ) {
add_effect( effect_foodpoison, 1_days * contamination / 100.0 );
}
}

if( will_vomit ) {
vomit();
}
Expand Down
1 change: 1 addition & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@ void Item_factory::load( islot_comestible &slot, JsonObject &jo, const std::stri
assign( jo, "stim", slot.stim, strict );
assign( jo, "healthy", slot.healthy, strict );
assign( jo, "parasites", slot.parasites, strict, 0 );
assign( jo, "contamination", slot.contamination, strict, 0, 100 );
assign( jo, "freezing_point", slot.freeze_point, strict );
assign( jo, "spoils_in", slot.spoils, strict, 1_hours );
assign( jo, "cooks_like", slot.cooks_like, strict );
Expand Down
3 changes: 3 additions & 0 deletions src/itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ struct islot_comestible {
/** chance (odds) of becoming parasitised when eating (zero if never occurs) */
int parasites = 0;

/** probability [0, 100] to get food poisoning from this comestible */
int contamination = 0;

/** freezing point in degrees Fahrenheit, below this temperature item can freeze */
int freeze_point = temperatures::freezing;

Expand Down

0 comments on commit 9c5d811

Please sign in to comment.