From 02e72daff2b3c911a330613a0fe72429691f919f Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Sun, 28 Jan 2024 03:04:54 -0600 Subject: [PATCH 1/4] feat(balance): allow reading in the dark with full night vision trait, other visual/detection improvements --- src/avatar_action.cpp | 3 ++- src/character.cpp | 9 ++++++++- src/character_functions.cpp | 7 +++++-- src/game.cpp | 5 +++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 0568eb9bae9a..0e620bb48f8e 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -449,7 +449,8 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) } // Invalid move - const bool waste_moves = you.is_blind() || you.has_effect( effect_stunned ); + const bool waste_moves = ( you.is_blind() && you.clairvoyance() < 1 ) || + you.has_effect( effect_stunned ); if( waste_moves || dest_loc.z != you.posz() ) { add_msg( _( "You bump into the %s!" ), m.obstacle_name( dest_loc ) ); // Only lose movement if we're blind diff --git a/src/character.cpp b/src/character.cpp index 21fc9256cd19..bee77ae4e7aa 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -6869,6 +6869,12 @@ bool Character::sees_with_specials( const Creature &critter ) const return true; } + const int dist = rl_dist( pos(), critter.pos() ); + if( dist <= 5 && ( has_active_mutation( trait_ANTENNAE ) || + ( has_active_bionic( bio_ground_sonar ) && !critter.has_flag( MF_FLIES ) ) ) ) { + return true; + } + return false; } @@ -11015,7 +11021,8 @@ bool Character::sees( const Creature &critter ) const { // This handles only the player/npc specific stuff (monsters don't have traits or bionics). const int dist = rl_dist( pos(), critter.pos() ); - if( dist <= 3 && has_active_mutation( trait_ANTENNAE ) ) { + if( dist <= 5 && ( has_active_mutation( trait_ANTENNAE ) || + ( has_active_bionic( bio_ground_sonar ) && !critter.has_flag( MF_FLIES ) ) ) ) { return true; } diff --git a/src/character_functions.cpp b/src/character_functions.cpp index bf61fc4e99d4..664a9f46478d 100644 --- a/src/character_functions.cpp +++ b/src/character_functions.cpp @@ -178,13 +178,16 @@ float fine_detail_vision_mod( const Character &who, const tripoint &p ) !who.has_trait( trait_PER_SLIME_OK ) ) ) { return 11.0; } + // Regular NV trait isn't enough to help at all, while Full Night Vision allows reading at a penalty + float nvbonus = who.mutation_value( "night_vision_range" ) >= 8 ? 4 : 0; // Scale linearly as light level approaches LIGHT_AMBIENT_LIT. // If we're actually a source of light, assume we can direct it where we need it. // Therefore give a hefty bonus relative to ambient light. float own_light = std::max( 1.0f, LIGHT_AMBIENT_LIT - who.active_light() - 2.0f ); - // Same calculation as above, but with a result 3 lower. - float ambient_light = std::max( 1.0f, LIGHT_AMBIENT_LIT - get_map().ambient_light_at( p ) + 1.0f ); + // Same calculation as above, but with a result 3 lower, and night vision is allowed to affect it. + float ambient_light = std::max( 1.0f, + LIGHT_AMBIENT_LIT - get_map().ambient_light_at( p ) - nvbonus + 1.0f ); return std::min( own_light, ambient_light ); } diff --git a/src/game.cpp b/src/game.cpp index 47c2c92b1898..dd97c81cea3c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6005,7 +6005,8 @@ void game::print_items_info( const tripoint &lp, const catacurses::window &w_loo return; } else if( m.has_flag( "CONTAINER", lp ) && !m.could_see_items( lp, u ) ) { mvwprintw( w_look, point( column, ++line ), _( "You cannot see what is inside of it." ) ); - } else if( u.has_effect( effect_blind ) || u.worn_with_flag( flag_BLIND ) ) { + } else if( ( u.has_effect( effect_blind ) || u.worn_with_flag( flag_BLIND ) ) && + u.clairvoyance() < 1 ) { mvwprintz( w_look, point( column, ++line ), c_yellow, _( "There's something there, but you can't see what it is." ) ); return; @@ -9369,7 +9370,7 @@ point game::place_player( const tripoint &dest_loc ) if( !m.has_flag( "SEALED", u.pos() ) ) { if( get_option( "NO_AUTO_PICKUP_ZONES_LIST_ITEMS" ) || !check_zone( zone_type_id( "NO_AUTO_PICKUP" ), u.pos() ) ) { - if( u.is_blind() && !m.i_at( u.pos() ).empty() ) { + if( u.is_blind() && !m.i_at( u.pos() ).empty() && u.clairvoyance() < 1 ) { add_msg( _( "There's something here, but you can't see what it is." ) ); } else if( m.has_items( u.pos() ) ) { std::vector names; From 5970b4fe6fcfa36cb072a34e7bc030b3aa8d3e66 Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Mon, 29 Jan 2024 11:12:39 -0600 Subject: [PATCH 2/4] Update mutations.json --- data/json/mutations/mutations.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index beb594e1c0ba..027d180007c5 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -1269,7 +1269,7 @@ "id": "NIGHTVISION3", "name": { "str": "Full Night Vision" }, "points": 6, - "description": "You can see in pitch blackness as if you were wearing night-vision goggles. Activate to toggle NV-visible areas on or off.", + "description": "You can see in pitch blackness as if you were wearing night-vision goggles, and read in darkness as one can in dim lighting. Activate to toggle NV-visible areas on or off.", "prereqs": [ "NIGHTVISION2" ], "leads_to": [ "INFRARED" ], "cancels": [ "ELFA_NV", "ELFA_FNV", "FEL_NV", "URSINE_EYE" ], From 53ccf97edec6d10923a72727e407bee397763964 Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Mon, 29 Jan 2024 13:10:21 -0600 Subject: [PATCH 3/4] Fix per Jove's feedback Co-Authored-By: joveeater <6675689+joveeater@users.noreply.github.com> --- src/character.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index bee77ae4e7aa..c176dd1399aa 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -6870,12 +6870,8 @@ bool Character::sees_with_specials( const Creature &critter ) const } const int dist = rl_dist( pos(), critter.pos() ); - if( dist <= 5 && ( has_active_mutation( trait_ANTENNAE ) || - ( has_active_bionic( bio_ground_sonar ) && !critter.has_flag( MF_FLIES ) ) ) ) { - return true; - } - - return false; + return ( dist <= 5 && ( has_active_mutation( trait_ANTENNAE ) || + ( has_active_bionic( bio_ground_sonar ) && !critter.has_flag( MF_FLIES ) ) ) ); } detached_ptr Character::pour_into( item &container, detached_ptr &&liquid, int limit ) From a8f7a250cf27ec62fd01860c0204f13c462d877b Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Tue, 30 Jan 2024 15:39:38 -0600 Subject: [PATCH 4/4] Update json_info.md --- doc/src/content/docs/en/mod/json/reference/json_info.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/content/docs/en/mod/json/reference/json_info.md b/doc/src/content/docs/en/mod/json/reference/json_info.md index c2d5a1529768..5bb5288d9908 100644 --- a/doc/src/content/docs/en/mod/json/reference/json_info.md +++ b/doc/src/content/docs/en/mod/json/reference/json_info.md @@ -1245,7 +1245,7 @@ wake up for the first time after 24 hours into the game. ] ], "stealth_modifier" : 0, // Percentage to be subtracted from player's visibility range, capped to 60. Negative values work, but are not very effective due to the way vision ranges are capped -"night_vision_range" : 0.0, // Night range vision. Only the best and the worst value out of all mutations are added. (default: 0.0) +"night_vision_range" : 0.0, // Night range vision. Only the best and the worst value out of all mutations are added. A value of 8 or higher will allow reading in complete darkness as though the player were in dim lighting. (default: 0.0) "active" : true, //When set the mutation is an active mutation that the player needs to activate (default: false) "starts_active" : true, //When true, this 'active' mutation starts active (default: false, requires 'active') "cost" : 8, // Cost to activate this mutation. Needs one of the hunger, thirst, or fatigue values set to true. (default: 0)