From e0855b36aa7eaad1d30efce3852d326c55afac4d Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sat, 22 Feb 2020 18:10:45 +0100 Subject: [PATCH 1/2] Add dark_craftable bool to construction --- src/construction.cpp | 21 +++++++++++++-------- src/construction.h | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/construction.cpp b/src/construction.cpp index 88299c4e1efc4..6926ba65ad141 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -690,15 +690,10 @@ construction_id construction_menu( const bool blueprint ) } if( !blueprint ) { if( player_can_build( g->u, total_inv, constructs[select] ) ) { - if( g->u.fine_detail_vision_mod() > 4 && !g->u.has_trait( trait_DEBUG_HS ) ) { - add_msg( m_info, _( "It is too dark to construct right now." ) ); - } else { - place_construction( constructs[select] ); - uistate.last_construction = constructs[select]; - } + place_construction( constructs[select] ); + uistate.last_construction = constructs[select]; exit = true; } else { - popup( _( "You can't build that!" ) ); draw_grid( w_con, w_list_width + w_list_x0 ); update_info = true; } @@ -738,6 +733,7 @@ bool player_can_build( player &p, const inventory &inv, const std::string &desc bool player_can_build( player &p, const inventory &inv, const construction &con ) { + if( p.has_trait( trait_DEBUG_HS ) ) { return true; } @@ -745,7 +741,15 @@ bool player_can_build( player &p, const inventory &inv, const construction &con if( !p.meets_skill_requirements( con ) ) { return false; } - return con.requirements->can_make_with_inventory( inv, is_crafting_component ); + + const bool can_build = con.requirements->can_make_with_inventory( inv, is_crafting_component ); + if( !can_build ) { + popup( _( "You can't build that!" ) ); + } else if( g->u.fine_detail_vision_mod() > 4 && !con.dark_craftable ) { + popup( _( "It is too dark to construct right now." ) ); + return false; + } + return can_build; } bool can_construct( const std::string &desc ) @@ -1456,6 +1460,7 @@ void load_construction( const JsonObject &jo ) con.vehicle_start = jo.get_bool( "vehicle_start", false ); con.on_display = jo.get_bool( "on_display", true ); + con.dark_craftable = jo.get_bool( "dark_craftable", false ); constructions.push_back( con ); construction_id_map.emplace( con.str_id, con.id ); diff --git a/src/construction.h b/src/construction.h index c9d2767bc5714..49bab027cd766 100644 --- a/src/construction.h +++ b/src/construction.h @@ -102,6 +102,9 @@ struct construction { // make the construction available for selection bool on_display = true; + + //can be build in the dark + bool dark_craftable = false; private: std::string get_time_string() const; }; From 58ad188b454f028c4c67ea2fdb99048e6d2753c2 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sat, 22 Feb 2020 18:11:59 +0100 Subject: [PATCH 2/2] Make spots dark craftable --- data/json/construction.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/json/construction.json b/data/json/construction.json index 5e1f87291525b..12c8cb53b25ec 100644 --- a/data/json/construction.json +++ b/data/json/construction.json @@ -34,6 +34,7 @@ "pre_note": "Mark a spot for crafting. Crafting tasks next to this tile will automatically use this location instead of attempting to craft in your hands, with the usual crafting speed penalty for working on the ground. Does not prevent using a proper workbench, if available. Deconstruct or smash to remove.", "pre_special": "check_empty", "post_flags": [ "keep_items" ], + "dark_craftable": true, "post_terrain": "f_ground_crafting_spot" }, { @@ -3040,6 +3041,7 @@ "pre_note": "Firewood or other flammable materials on a nearby tile marked in this way may be used to automatically refuel fires. This will be done to maintain light during long-running tasks that require it such as crafting or reading, but not (for example) if you are simply waiting nearby.", "pre_special": "check_no_trap", "post_special": "done_mark_firewood", + "dark_craftable": true, "post_flags": [ "keep_items" ] }, { @@ -3052,6 +3054,7 @@ "pre_note": "Mark a spot for target practice. Firing will automatically target the first practice target location found in gun range, if no enemies are around.", "pre_special": "check_no_trap", "post_special": "done_mark_practice_target", + "dark_craftable": true, "post_flags": [ "keep_items" ] }, {