diff --git a/data/json/items/comestibles/dairy.json b/data/json/items/comestibles/dairy.json index 3c0426702cec0..daaef63c4e549 100644 --- a/data/json/items/comestibles/dairy.json +++ b/data/json/items/comestibles/dairy.json @@ -7,7 +7,7 @@ "copy-from": "milk", "spoils_in": "12 hours", "price": 19, - "parasites": 11, + "contamination": 5, "description": "This is raw, unhomogenized and unpasteurized milk from a cow. It couldn't be any fresher unless you drank it straight from the cow, which might upset it. Depending on your dietary sensibilities, you might want to pasteurize or even boil this before drinking." }, { diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 71f992451ad33..9c5bd769c43c9 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -1375,6 +1375,8 @@ CBMs can be defined like this: "fun" : 50 // Morale effects when used "freezing_point": 32, // (Optional) Temperature in F at which item freezes, default is water (32F/0C) "cooks_like": "meat_cooked" // (Optional) If the item is used in a recipe, replaces it with its cooks_like +"parasites": 10, // (Optional) Probability of becoming parasitised when eating +"contamination": 5, // (Optional) Probability to get food poisoning from this comestible. Values must be in the [0, 100] range. ``` ### Containers diff --git a/src/consumption.cpp b/src/consumption.cpp index 17299487e695b..dbe39c1fa7a6b 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -949,6 +949,14 @@ bool player::eat( item &food, bool force ) } } + // chance to get food poisoning 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, rng( 6_minutes, ( nutr + 1 ) * 6_minutes ) ); + } + } + if( will_vomit ) { vomit(); } diff --git a/src/item_factory.cpp b/src/item_factory.cpp index fa3cf6b2a2106..1e1bb80649f28 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -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 ); diff --git a/src/itype.h b/src/itype.h index 2cd3bbc2371d6..101fc0e7576f8 100644 --- a/src/itype.h +++ b/src/itype.h @@ -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;