From 4627e22133f8cc18a08a1cfdd785b4a88b94d477 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Fri, 13 Dec 2019 01:33:47 -0500 Subject: [PATCH 1/8] main --- data/core/basic.json | 3 ++- data/json/items/comestibles/drink.json | 6 ++++-- src/iuse.cpp | 11 ++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/data/core/basic.json b/data/core/basic.json index a9e3f00242c3d..e8991e16a5082 100644 --- a/data/core/basic.json +++ b/data/core/basic.json @@ -22,6 +22,7 @@ "container": "bottle_plastic", "quench": 50, "ammo_data": { "ammo_type": "water" }, - "flags": [ "EATEN_COLD" ] + "flags": [ "EATEN_COLD", "BLECH_BECAUSE_UNCLEAN" ], + "use_action": "BLECH" } ] diff --git a/data/json/items/comestibles/drink.json b/data/json/items/comestibles/drink.json index a1a9363de8fc8..e3e3de982c868 100644 --- a/data/json/items/comestibles/drink.json +++ b/data/json/items/comestibles/drink.json @@ -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", @@ -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": [ ] } ] diff --git a/src/iuse.cpp b/src/iuse.cpp index 11bcde534917d..cf479bf0a1a9a 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -965,9 +965,18 @@ int iuse::oxygen_bottle( player *p, item *it, bool, const tripoint & ) int iuse::blech( player *p, item *it, bool, const tripoint & ) { + std::string unclean_or_unhealthy; + std::string warning_string; + if( it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { + unclean_or_unhealthy = "unclean"; + } + if( !it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { + unclean_or_unhealthy = "unhealthy"; + } // TODO: Add more effects? if( it->made_of( LIQUID ) ) { - if( !p->query_yn( _( "This looks unhealthy, sure you want to drink it?" ) ) ) { + if( !p->query_yn( string_format( "This looks %s, sure you want to drink it?", + unclean_or_unhealthy ) ) ) { return 0; } } else { //Assume that if a blech consumable isn't a drink, it will be eaten. From 5aa7dc14f33068b7d227eefba063b70e31b033ca Mon Sep 17 00:00:00 2001 From: misterprimus Date: Fri, 13 Dec 2019 01:55:29 -0500 Subject: [PATCH 2/8] Update iuse.cpp --- src/iuse.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index cf479bf0a1a9a..df05c3914cef9 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -980,7 +980,8 @@ int iuse::blech( player *p, item *it, bool, const tripoint & ) return 0; } } else { //Assume that if a blech consumable isn't a drink, it will be eaten. - if( !p->query_yn( _( "This looks unhealthy, sure you want to eat it?" ) ) ) { + if( !p->query_yn( string_format( "This looks %s, sure you want to eat it?", + unclean_or_unhealthy ) ) ) { return 0; } } @@ -998,11 +999,13 @@ int iuse::blech( player *p, item *it, bool, const tripoint & ) p->add_morale( MORALE_FOOD_BAD, it->get_comestible_fun() * multiplier, 60, 1_hours, 30_minutes, false, it->type ); } else { - p->add_msg_if_player( m_bad, _( "Blech, that burns your throat!" ) ); - p->mod_pain( rng( 32, 64 ) ); - p->add_effect( effect_poison, 1_hours ); - p->apply_damage( nullptr, bp_torso, rng( 4, 12 ) ); - p->vomit(); + if( !it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { + p->add_msg_if_player( m_bad, _( "Blech, that burns your throat!" ) ); + p->mod_pain( rng( 32, 64 ) ); + p->add_effect( effect_poison, 1_hours ); + p->apply_damage( nullptr, bp_torso, rng( 4, 12 ) ); + p->vomit(); + } } return it->type->charges_to_use(); } From 611303e005a9e213aa47a8dad8a4a918eb016447 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Fri, 13 Dec 2019 13:17:16 -0500 Subject: [PATCH 3/8] Update src/iuse.cpp Co-Authored-By: Anton Burmistrov --- src/iuse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index df05c3914cef9..b3aa8c318485f 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -971,7 +971,7 @@ int iuse::blech( player *p, item *it, bool, const tripoint & ) unclean_or_unhealthy = "unclean"; } if( !it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { - unclean_or_unhealthy = "unhealthy"; + unclean_or_unhealthy = _( "unhealthy" ); } // TODO: Add more effects? if( it->made_of( LIQUID ) ) { From 0fedb8a22725e49337e3c24b917a4523a5aef289 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Fri, 13 Dec 2019 13:17:27 -0500 Subject: [PATCH 4/8] Update src/iuse.cpp Co-Authored-By: Anton Burmistrov --- src/iuse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index b3aa8c318485f..e1bb819a61b03 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -968,7 +968,7 @@ int iuse::blech( player *p, item *it, bool, const tripoint & ) std::string unclean_or_unhealthy; std::string warning_string; if( it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { - unclean_or_unhealthy = "unclean"; + unclean_or_unhealthy = _( "unclean" ); } if( !it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { unclean_or_unhealthy = _( "unhealthy" ); From e5e39cb13362ddc25512af0fb13103f007139fbd Mon Sep 17 00:00:00 2001 From: misterprimus Date: Fri, 13 Dec 2019 13:20:53 -0500 Subject: [PATCH 5/8] Update iuse.cpp --- src/iuse.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index e1bb819a61b03..74be18e199202 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -966,7 +966,6 @@ int iuse::oxygen_bottle( player *p, item *it, bool, const tripoint & ) int iuse::blech( player *p, item *it, bool, const tripoint & ) { std::string unclean_or_unhealthy; - std::string warning_string; if( it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { unclean_or_unhealthy = _( "unclean" ); } From 99d70419621420c4ad3d3488663af8935b361c35 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Tue, 17 Dec 2019 17:26:25 -0500 Subject: [PATCH 6/8] add blech_because_unclean, revert cpp file --- data/core/basic.json | 4 ++-- data/json/item_actions.json | 5 +++++ doc/JSON_FLAGS.md | 1 + src/item_factory.cpp | 1 + src/iuse.cpp | 25 +++++++------------------ src/iuse.h | 1 + 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/data/core/basic.json b/data/core/basic.json index e8991e16a5082..cb45312e4dc72 100644 --- a/data/core/basic.json +++ b/data/core/basic.json @@ -22,7 +22,7 @@ "container": "bottle_plastic", "quench": 50, "ammo_data": { "ammo_type": "water" }, - "flags": [ "EATEN_COLD", "BLECH_BECAUSE_UNCLEAN" ], - "use_action": "BLECH" + "flags": [ "EATEN_COLD" ], + "use_action": "BLECH_BECAUSE_UNCLEAN" } ] diff --git a/data/json/item_actions.json b/data/json/item_actions.json index e5f96e95a57fe..40eed470a88b3 100644 --- a/data/json/item_actions.json +++ b/data/json/item_actions.json @@ -299,6 +299,11 @@ "id": "BLECH", "name": "Drink" }, + { + "type": "item_action", + "id": "BLECH_BECAUSE_UNCLEAN", + "name": "Drink" + }, { "type": "item_action", "id": "C4", diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index 5dd2e3de82d29..26ec462301b81 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -424,6 +424,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. diff --git a/src/item_factory.cpp b/src/item_factory.cpp index d720899e5014a..44c99f4e0947b 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -602,6 +602,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 ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 74be18e199202..11bcde534917d 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -965,22 +965,13 @@ int iuse::oxygen_bottle( player *p, item *it, bool, const tripoint & ) int iuse::blech( player *p, item *it, bool, const tripoint & ) { - std::string unclean_or_unhealthy; - if( it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { - unclean_or_unhealthy = _( "unclean" ); - } - if( !it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { - unclean_or_unhealthy = _( "unhealthy" ); - } // TODO: Add more effects? if( it->made_of( LIQUID ) ) { - if( !p->query_yn( string_format( "This looks %s, sure you want to drink it?", - unclean_or_unhealthy ) ) ) { + if( !p->query_yn( _( "This looks unhealthy, 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( string_format( "This looks %s, sure you want to eat it?", - unclean_or_unhealthy ) ) ) { + if( !p->query_yn( _( "This looks unhealthy, sure you want to eat it?" ) ) ) { return 0; } } @@ -998,13 +989,11 @@ int iuse::blech( player *p, item *it, bool, const tripoint & ) p->add_morale( MORALE_FOOD_BAD, it->get_comestible_fun() * multiplier, 60, 1_hours, 30_minutes, false, it->type ); } else { - if( !it->has_flag( "BLECH_BECAUSE_UNCLEAN" ) ) { - p->add_msg_if_player( m_bad, _( "Blech, that burns your throat!" ) ); - p->mod_pain( rng( 32, 64 ) ); - p->add_effect( effect_poison, 1_hours ); - p->apply_damage( nullptr, bp_torso, rng( 4, 12 ) ); - p->vomit(); - } + p->add_msg_if_player( m_bad, _( "Blech, that burns your throat!" ) ); + p->mod_pain( rng( 32, 64 ) ); + p->add_effect( effect_poison, 1_hours ); + p->apply_damage( nullptr, bp_torso, rng( 4, 12 ) ); + p->vomit(); } return it->type->charges_to_use(); } diff --git a/src/iuse.h b/src/iuse.h index 51ed23457e19e..f7c0b43231913 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -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 & ); From 1097eddf727d7e0fa133e8c17a17c8ec70830540 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Tue, 17 Dec 2019 17:28:34 -0500 Subject: [PATCH 7/8] Update iuse.cpp --- src/iuse.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/iuse.cpp b/src/iuse.cpp index 11bcde534917d..6cf41a61ab5ae 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -998,6 +998,20 @@ 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( 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 ) ) { From c91a3728d1c0b84b37be77c7e74c6d4c457142b8 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Thu, 19 Dec 2019 16:45:40 -0500 Subject: [PATCH 8/8] Update iuse.cpp --- src/iuse.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 6cf41a61ab5ae..d216a7ccda5c8 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1000,13 +1000,15 @@ int iuse::blech( player *p, item *it, bool, const tripoint & ) int iuse::blech_because_unclean( player *p, item *it, bool, const tripoint & ) { - 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; + 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();