From ecf55406b84c3fd4aefb6541525caac272854413 Mon Sep 17 00:00:00 2001 From: dnworden <59940356+dnworden@users.noreply.github.com> Date: Thu, 16 Dec 2021 01:45:11 -0500 Subject: [PATCH] Lets liquid soap be used to clean clothes (#53161) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make liquid soap a detergent with count 5 As a side effect, it's no longer a comestible and can't be drank, but you probably shouldn't do that anyway. * Add liquid soap to finish washing * Attempting to fix liquid error * Lets liquid soap be used for soapy water crafting * Fixes alphabetical order * Dratted whitespace ruining my style * I think this is what the style checker means now * Makes liquid soap move to the chemical stuff section * Surely this isn't what the astyle was complaining about right? * Wait no it's just something dumb * Changing it back because it still doesn't like the style * Ok this should fix it * Using json linted version * Reduce long lines * Testing an exception * Fixing syntax * Change count to charges * Undo unnecessary check * Change it back to count * ADD LIQUID SOAP TO THE PLACE IT ACTUALLY BELONGS GITHUB * Trust me bro (hopefully this actually works) * Adds checking for unused cleansers * Appeasing astyle * Using allman formatting for astyle * Undoes that because it changed everything * Trying again with the proper astyle * Also format all of iuse with the astyle settings * Reverse some of the changes astyle made * Refactored washing to use only one component vector Hopefully it stops sending errors this way * Nearly missed that one * Update src/activity_item_handling.cpp Co-authored-by: Álvaro Co-authored-by: Álvaro --- data/json/items/chemicals_and_resources.json | 12 +++++------- data/json/recipes/recipe_medsandchemicals.json | 5 ++++- src/activity_item_handling.cpp | 6 +++++- src/iuse.cpp | 7 +++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/data/json/items/chemicals_and_resources.json b/data/json/items/chemicals_and_resources.json index 1d4f0e2949f5c..fd260c0099f0f 100644 --- a/data/json/items/chemicals_and_resources.json +++ b/data/json/items/chemicals_and_resources.json @@ -1745,24 +1745,22 @@ "count": 100 }, { - "type": "COMESTIBLE", + "type": "AMMO", "id": "liquid_soap", "name": { "str_sp": "liquid soap" }, + "category": "chems", "weight": "260 g", "color": "light_cyan", "container": "bottle_bathroom", "sealed": false, - "comestible_type": "DRINK", "symbol": "~", - "quench": -90, - "healthy": -20, "description": "Liquid soap.", "price": 0, "price_postapoc": 0, "volume": "250 ml", "phase": "liquid", - "category": "chems", - "freezing_point": -2, - "fun": -50 + "ammo_type": "components", + "flags": [ "DETERGENT" ], + "count": 5 } ] diff --git a/data/json/recipes/recipe_medsandchemicals.json b/data/json/recipes/recipe_medsandchemicals.json index 5efc8ba4c1dd7..0d59a7b5cdb35 100644 --- a/data/json/recipes/recipe_medsandchemicals.json +++ b/data/json/recipes/recipe_medsandchemicals.json @@ -21,7 +21,10 @@ "time": "1 m", "autolearn": true, "flags": [ "BLIND_HARD" ], - "components": [ [ [ "water_clean", 1 ], [ "water", 1 ] ], [ [ "soap", 1 ], [ "soap_flakes", 15 ], [ "detergent", 1 ] ] ] + "components": [ + [ [ "water_clean", 1 ], [ "water", 1 ] ], + [ [ "soap", 1 ], [ "soap_flakes", 15 ], [ "detergent", 1 ], [ "liquid_soap", 1 ] ] + ] }, { "type": "recipe", diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index c7a02f6ad8d9c..886d9595537b9 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -98,6 +98,7 @@ static const efftype_id effect_incorporeal( "incorporeal" ); static const itype_id itype_battery( "battery" ); static const itype_id itype_detergent( "detergent" ); static const itype_id itype_disassembly( "disassembly" ); +static const itype_id itype_liquid_soap( "liquid_soap" ); static const itype_id itype_log( "log" ); static const itype_id itype_mop( "mop" ); static const itype_id itype_soap( "soap" ); @@ -506,7 +507,9 @@ void activity_handlers::washing_finish( player_activity *act, Character *you ) act->set_to_null(); return; } else if( !crafting_inv.has_charges( itype_soap, required.cleanser ) && - !crafting_inv.has_charges( itype_detergent, required.cleanser ) ) { + !crafting_inv.has_charges( itype_detergent, required.cleanser ) && + !crafting_inv.has_charges( itype_liquid_soap, required.cleanser, + is_liquid_crafting_component ) ) { you->add_msg_if_player( _( "You need %1$i charges of cleansing agent to wash these items." ), required.cleanser ); act->set_to_null(); @@ -527,6 +530,7 @@ void activity_handlers::washing_finish( player_activity *act, Character *you ) std::vector comps1; comps1.emplace_back( itype_soap, required.cleanser ); comps1.emplace_back( itype_detergent, required.cleanser ); + comps1.emplace_back( itype_liquid_soap, required.cleanser ); you->consume_items( comps1 ); you->add_msg_if_player( m_good, _( "You washed your items." ) ); diff --git a/src/iuse.cpp b/src/iuse.cpp index e389adf0e084f..36cc0aa821a8c 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -265,6 +265,7 @@ static const itype_id itype_handrolled_cig( "handrolled_cig" ); static const itype_id itype_heatpack_used( "heatpack_used" ); static const itype_id itype_hygrometer( "hygrometer" ); static const itype_id itype_joint( "joint" ); +static const itype_id itype_liquid_soap( "liquid_soap" ); static const itype_id itype_log( "log" ); static const itype_id itype_mask_h20survivor_on( "mask_h20survivor_on" ); static const itype_id itype_mininuke_act( "mininuke_act" ); @@ -9299,7 +9300,8 @@ cata::optional iuse::wash_items( Character *p, bool soft_items, bool hard_i crafting_inv.charges_of( itype_water_clean, INT_MAX, is_liquid ) ); int available_cleanser = std::max( crafting_inv.charges_of( itype_soap ), - crafting_inv.charges_of( itype_detergent ) ); + std::max( crafting_inv.charges_of( itype_detergent ), + crafting_inv.charges_of( itype_liquid_soap, INT_MAX, is_liquid ) ) ); const inventory_filter_preset preset( [soft_items, hard_items]( const item_location & location ) { return location->has_flag( flag_FILTHY ) && ( ( soft_items && location->is_soft() ) || @@ -9358,7 +9360,8 @@ cata::optional iuse::wash_items( Character *p, bool soft_items, bool hard_i required.water ); return cata::nullopt; } else if( !crafting_inv.has_charges( itype_soap, required.cleanser ) && - !crafting_inv.has_charges( itype_detergent, required.cleanser ) ) { + !crafting_inv.has_charges( itype_detergent, required.cleanser ) && + !crafting_inv.has_charges( itype_liquid_soap, required.cleanser, is_liquid ) ) { p->add_msg_if_player( _( "You need %1$i charges of cleansing agent to wash these items." ), required.cleanser ); return cata::nullopt;