Skip to content

Commit

Permalink
warn player before drinking water not known to be clean (#36065)
Browse files Browse the repository at this point in the history
  • Loading branch information
misterprimus authored and kevingranade committed Dec 22, 2019
1 parent eafe7c2 commit 78e1ce6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion data/core/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"container": "bottle_plastic",
"quench": 50,
"ammo_data": { "ammo_type": "water" },
"flags": [ "EATEN_COLD" ]
"flags": [ "EATEN_COLD" ],
"use_action": "BLECH_BECAUSE_UNCLEAN"
}
]
5 changes: 5 additions & 0 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@
"id": "BLECH",
"name": "Drink"
},
{
"type": "item_action",
"id": "BLECH_BECAUSE_UNCLEAN",
"name": "Drink"
},
{
"type": "item_action",
"id": "C4",
Expand Down
6 changes: 4 additions & 2 deletions data/json/items/comestibles/drink.json
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,8 @@
"name": "clean water",
"name_plural": "clean water",
"description": "Fresh, clean water. Truly the best thing to quench your thirst.",
"color": "light_cyan"
"color": "light_cyan",
"use_action": [ ]
},
{
"id": "water_mineral",
Expand All @@ -948,6 +949,7 @@
"description": "Fancy mineral water, so fancy it makes you feel fancy just holding it.",
"container": "bottle_plastic",
"proportional": { "quench": 1.2 },
"relative": { "fun": 1 }
"relative": { "fun": 1 },
"use_action": [ ]
}
]
1 change: 1 addition & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ Some armor flags, such as `WATCH` and `ALARMCLOCK` are compatible with other ite
- ```BANDAGE``` Stop bleeding.
- ```BIRDFOOD``` Makes a small bird friendly.
- ```BLECH``` Causes vomiting.
- ```BLECH_BECAUSE_UNCLEAN``` Causes warning.
- ```CAFF``` Reduces fatigue.
- ```CATFOOD``` Makes a cat friendly.
- ```CATTLEFODDER``` Makes a large herbivore friendly.
Expand Down
1 change: 1 addition & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ void Item_factory::init()
add_iuse( "AUTOCLAVE", &iuse::autoclave );
add_iuse( "BELL", &iuse::bell );
add_iuse( "BLECH", &iuse::blech );
add_iuse( "BLECH_BECAUSE_UNCLEAN", &iuse::blech_because_unclean );
add_iuse( "BOLTCUTTERS", &iuse::boltcutters );
add_iuse( "C4", &iuse::c4 );
add_iuse( "CABLE_ATTACH", &iuse::cable_attach );
Expand Down
16 changes: 16 additions & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,22 @@ int iuse::blech( player *p, item *it, bool, const tripoint & )
return it->type->charges_to_use();
}

int iuse::blech_because_unclean( player *p, item *it, bool, const tripoint & )
{
if( !p->is_npc() ) {
if( it->made_of( LIQUID ) ) {
if( !p->query_yn( _( "This looks unclean, sure you want to drink it?" ) ) ) {
return 0;
}
} else { //Assume that if a blech consumable isn't a drink, it will be eaten.
if( !p->query_yn( _( "This looks unclean, sure you want to eat it?" ) ) ) {
return 0;
}
}
}
return it->type->charges_to_use();
}

int iuse::plantblech( player *p, item *it, bool, const tripoint &pos )
{
if( p->has_trait( trait_THRESH_PLANT ) ) {
Expand Down
1 change: 1 addition & 0 deletions src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class iuse
int flusleep( player *, item *, bool, const tripoint & );
int inhaler( player *, item *, bool, const tripoint & );
int blech( player *, item *, bool, const tripoint & );
int blech_because_unclean( player *, item *, bool, const tripoint & );
int plantblech( player *, item *, bool, const tripoint & );
int chew( player *, item *, bool, const tripoint & );
int purifier( player *, item *, bool, const tripoint & );
Expand Down

0 comments on commit 78e1ce6

Please sign in to comment.