diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 4bd0b65a608f2..99d9cf8fd5d99 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -1407,7 +1407,22 @@ "description": "You're an excellent navigator and your ability to recognize distant landmarks is unmatched. Your sight radius on the overmap extends beyond the normal range.", "category": [ "BIRD", "MOUSE", "CEPHALOPOD" ], "cancels": [ "UNOBSERVANT" ], - "overmap_sight": 5 + "overmap_sight": 5, + "triggers": [ [ { "condition": { "not": "is_day" }, "msg_on": { "text": "", "rating": "good" } } ] ], + "transform": { "target": "EAGLEEYED_NIGHT", "msg_transform": "", "active": false, "moves": 0 } + }, + { + "type": "mutation", + "id": "EAGLEEYED_NIGHT", + "//": "Indistinguishable to player, version without overmap_sight so it doesn't work at night.", + "name": { "str": "Scout" }, + "points": 1, + "description": "You're an excellent navigator and your ability to recognize distant landmarks is unmatched. Your sight radius on the overmap extends beyond the normal range.", + "category": [ "BIRD", "MOUSE", "CEPHALOPOD" ], + "cancels": [ "UNOBSERVANT" ], + "valid": false, + "triggers": [ [ { "condition": "is_day", "msg_on": { "text": "", "rating": "good" } } ] ], + "transform": { "target": "EAGLEEYED_NIGHT", "msg_transform": "", "active": false, "moves": 0 } }, { "type": "mutation", diff --git a/data/mods/Magiclysm/mutations/fantasy_species.json b/data/mods/Magiclysm/mutations/fantasy_species.json index 0861c936e5028..d9aa71fa43d76 100644 --- a/data/mods/Magiclysm/mutations/fantasy_species.json +++ b/data/mods/Magiclysm/mutations/fantasy_species.json @@ -517,6 +517,41 @@ { "condition": "is_day", "values": [ { "value": "SLEEPY", "add": 50 } ] } ] }, + { + "type": "mutation", + "id": "NOCTURNAL_DAY", + "name": { "str": "Nocturnal OverMap Day Vision" }, + "//": "Invisible to player, sets overmap vision", + "points": 0, + "ugliness": 0, + "visibility": 0, + "description": "This adjusts goblin overmap sight so their vision is not as far during the day.", + "mixed_effect": true, + "valid": false, + "player_display": false, + "overmap_sight": -2, + "category": [ "SPECIES_GOBLIN" ], + "threshreq": [ "THRESH_SPECIES_GOBLIN" ], + "triggers": [ [ { "condition": { "not": "is_day" }, "msg_on": { "text": "", "rating": "good" } } ] ], + "transform": { "target": "NOCTURNAL_NIGHT", "msg_transform": "", "active": false, "moves": 0 } + }, + { + "type": "mutation", + "id": "NOCTURNAL_NIGHT", + "name": { "str": "Nocturnal OverMap Night Vision" }, + "points": 0, + "ugliness": 0, + "visibility": 0, + "description": "This adjusts goblin overmap sight so their vision is farther at night.", + "mixed_effect": true, + "valid": false, + "player_display": false, + "overmap_sight": 6, + "category": [ "SPECIES_GOBLIN" ], + "threshreq": [ "THRESH_SPECIES_GOBLIN" ], + "triggers": [ [ { "condition": "is_day", "msg_on": { "text": "", "rating": "good" } } ] ], + "transform": { "target": "NOCTURNAL_DAY", "msg_transform": "", "active": false, "moves": 0 } + }, { "type": "mutation", "id": "GOBLIN_TEETH", diff --git a/data/mods/Magiclysm/traits/fantasy_species.json b/data/mods/Magiclysm/traits/fantasy_species.json index 6a0c6b76f3452..9ab4b27ef94bd 100644 --- a/data/mods/Magiclysm/traits/fantasy_species.json +++ b/data/mods/Magiclysm/traits/fantasy_species.json @@ -76,6 +76,7 @@ "EATPOISON", "TUNNEL_FIGHTER", "NOCTURNAL", + "NOCTURNAL_DAY", "MOODSWINGS", "TROGLO2" ] diff --git a/doc/MUTATIONS.md b/doc/MUTATIONS.md index de4f13df281f9..42c3a91cfb9d0 100644 --- a/doc/MUTATIONS.md +++ b/doc/MUTATIONS.md @@ -205,7 +205,7 @@ Note that **all new traits that can be obtained through mutation must be purifia "integrated_armor": [ "integrated_fur" ], // this item is worn on your character forever, until you get rid of this mutation "noise_modifier": 0.4, // changes how much noise you produce while walking, `0.5` halves it, `2` doubles it "obtain_cost_multiplier": 1.1, // modifier for pulling an item from a container and storing it back, as a handling penalty - "overmap_sight": -10, // adjusts sight range on the overmap. Positives make it farther, negatives make it closer + "overmap_sight": -10, // adjusts sight range on the overmap. Positives make it farther, negatives make it closer. This will allow the character to see futher on the overmap at night if the mutation is active at all times "ranged_mutation": { // activation of the mutation allow you to shoot a fake gun "type": "pseudo_shotgun", // fake gun that is used to shoot "message": "SUDDEN SHOTGUN!." // message that would be printed when you use it diff --git a/src/character.cpp b/src/character.cpp index 65de6c4c852bf..b2f9363e8c678 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1285,30 +1285,40 @@ int Character::overmap_sight_range( float light_level ) const { int sight = sight_range( light_level ); if( sight < SEEX ) { - return 0; + sight = 0; } if( sight <= SEEX * 4 ) { - return sight / ( SEEX / 2 ); + sight /= ( SEEX / 2 ); } - sight = 6; - // The higher your perception, the farther you can see. - sight += static_cast( get_per() / 2 ); - // The higher up you are, the farther you can see. - sight += std::max( 0, posz() ) * 2; + if( sight > 0 ) { + sight = 6; + } // Mutations like Scout and Topographagnosia affect how far you can see. sight += mutation_value( "overmap_sight" ); float multiplier = mutation_value( "overmap_multiplier" ); - // Binoculars double your sight range. - // When adding checks here, also call game::update_overmap_seen at the place they first become true - const bool has_optic = cache_has_item_with( flag_ZOOM ) || - has_flag( json_flag_ENHANCED_VISION ) || - ( is_mounted() && mounted_creature->has_flag( mon_flag_MECH_RECON_VISION ) ) || - get_map().veh_at( pos() ).avail_part_with_feature( "ENHANCED_VISION" ).has_value(); - - if( has_optic ) { - multiplier += 1; + // If sight is change due to overmap_sight, process the rest of the modifiers, otherwise skip them + if( sight > 0 ) { + // The higher your perception, the farther you can see. + sight += static_cast( get_per() / 2 ); + // The higher up you are, the farther you can see. + sight += std::max( 0, posz() ) * 2; + + // Binoculars double your sight range. + // When adding checks here, also call game::update_overmap_seen at the place they first become true + const bool has_optic = cache_has_item_with( flag_ZOOM ) || + has_flag( json_flag_ENHANCED_VISION ) || + ( is_mounted() && mounted_creature->has_flag( mon_flag_MECH_RECON_VISION ) ) || + get_map().veh_at( pos() ).avail_part_with_feature( "ENHANCED_VISION" ).has_value(); + + if( has_optic ) { + multiplier += 1; + } + } + + if( sight == 0 ) { + return 0; } sight = std::round( sight * multiplier );