Skip to content

Commit

Permalink
Rework Character::overmap_sight_range to allow night overmap sight th…
Browse files Browse the repository at this point in the history
…rough mutation (#69991)

* Initial commit

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Documentation updates

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Standing-Storm and github-actions[bot] authored Dec 5, 2023
1 parent 9d390ef commit ea6ca67
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 18 deletions.
17 changes: 16 additions & 1 deletion data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 35 additions & 0 deletions data/mods/Magiclysm/mutations/fantasy_species.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions data/mods/Magiclysm/traits/fantasy_species.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"EATPOISON",
"TUNNEL_FIGHTER",
"NOCTURNAL",
"NOCTURNAL_DAY",
"MOODSWINGS",
"TROGLO2"
]
Expand Down
2 changes: 1 addition & 1 deletion doc/MUTATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 26 additions & 16 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( 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<int>( 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 );
Expand Down

0 comments on commit ea6ca67

Please sign in to comment.