Skip to content

Commit

Permalink
Add nightvision limb score (#52409)
Browse files Browse the repository at this point in the history
* Nightvision score, limb score documentation

Co-authored-by: Venera3 <Venera3@users.noreply.github.com>
Co-authored-by: NetSysFire <59517351+NetSysFire@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 26, 2021
1 parent a1ce232 commit 03abd4f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions data/json/body_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"hit_difficulty": 1.15,
"limb_type": "sensor",
"vision_score": 1.0,
"nightvision_score": 1.0,
"side": "both",
"legacy_id": "EYES",
"stylish_bonus": 2,
Expand Down
17 changes: 15 additions & 2 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,23 @@ For information about tools with option to export ASCII art in format ready to b
| squeamish_penalty | (_optional_) Mood effect of wearing filthy clothing on this part. (default: `0`)
| stat_hp_mods | (_optional_) Values modifying hp_max of this part following this formula: `hp_max += int_mod*int_max + dex_mod*dex_max + str_mod*str_max + per_mod*per_max + health_mod*get_healthy()` with X_max being the unmodified value of the X stat and get_healthy() being the hidden health stat of the character.
| bionic_slots | (_optional_) How many bionic slots does this part have.
| is_limb | (_optional_) Is this bodypart a limb. (default: `false`)
| smash_message | (_optional_) The message displayed when using that part to smash something.
| is_limb | (_optional_) Is this bodypart a limb and capable of breaking. (default: `false`)
| smash_message | (_optional_) The message displayed when using that part to smash something.
| smash_efficiency | (_optional_) Modifier applied to your smashing strength when using this part to smash terrain or furniture unarmed. (default: `0.5`)
# Limb scores
Limb scores act as the basis of calculating the effect of limb encumbrance and damage on the abilities of characters. They are all optional floats.
| manipulator_score | Modifies aim speed, reload speed, thrown attack speed, ranged dispersion and crafting speed.
| manipulator_max | The upper limit of manipulator score the limb can contribute to.
| lifting_score | Modifies melee attack stamina cost on arm-type limbs, a sum above 0.5 qualifies for wielding two-handed weapons and similar checks.
| blocking_score | If the sum of blocking scores on arm-type limbs is above 1 the character can use arm blocks provided they have a relevant martial art. Blocking score below 1 prevents using any martial arts and reduces damage to 10% (used as a surrogate for broken arms)
| breathing_score | Modifies stamina recovery speed and shout volume.
| vision_score | Modifies ranged dispersion.
| nightvision_score | Modifies night vision range (multiplier on the calculated range).
| balance_score | Modifies thrown attack speed, movement cost and melee attack rolls.
| movement_speed_score | Modifies movement cost.
| swim_score | Modifies swim speed.
```C++
{
"id": "torso",
Expand Down
6 changes: 6 additions & 0 deletions src/bodypart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void body_part_type::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "swim_score", swim_score );

optional( jo, was_loaded, "vision_score", vision_score );
optional( jo, was_loaded, "nightvision_score", nightvision_score );

mandatory( jo, was_loaded, "side", part_side );
}
Expand Down Expand Up @@ -517,6 +518,11 @@ float bodypart::get_vision_score() const
return encumb_adjusted_limb_value( wound_adjusted_limb_value( id->vision_score ) );
}

float bodypart::get_nightvision_score() const
{
return encumb_adjusted_limb_value( wound_adjusted_limb_value( id->nightvision_score ) );
}

float bodypart::get_movement_speed_score() const
{
return encumb_adjusted_limb_value( wound_adjusted_limb_value( id->movement_speed_score ) );
Expand Down
3 changes: 3 additions & 0 deletions src/bodypart.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ struct body_part_type {
float breathing_score = 0.0f;
// how well you can see things. affects things like throwing dispersion. cumulative
float vision_score = 0.0f;
// how well you can see in the dark
float nightvision_score = 0.0f;
float movement_speed_score = 0.0f;
float balance_score = 0.0f;
float swim_score = 0.0f;
Expand Down Expand Up @@ -328,6 +330,7 @@ class bodypart
float get_lifting_score() const;
float get_breathing_score() const;
float get_vision_score() const;
float get_nightvision_score() const;
float get_movement_speed_score() const;
float get_balance_score() const;
float get_swim_score( double swim_skill = 0.0 ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ float Character::get_vision_threshold( float light_level ) const
}

// Clamp range to 1+, so that we can always see where we are
range = std::max( 1.0f, range * vision_score() );
range = std::max( 1.0f, range * nightvision_score() );

return std::min( static_cast<float>( LIGHT_AMBIENT_LOW ),
threshold_for_range( range ) * dimming_from_light );
Expand Down
1 change: 1 addition & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ class Character : public Creature, public visitable
float breathing_score() const;
float swim_score() const;
float vision_score() const;
float nightvision_score() const;
float movement_speed_score() const;
float balance_score() const;
bool has_min_manipulators() const;
Expand Down
9 changes: 9 additions & 0 deletions src/character_modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ float Character::vision_score() const
return std::max( 0.0f, total );
}

float Character::nightvision_score() const
{
float total = 0.0f;
for( const std::pair<const bodypart_str_id, bodypart> &id : body ) {
total += id.second.get_nightvision_score();
}
return std::max( 0.0f, total );
}

float Character::movement_speed_score() const
{
float total = 0.0f;
Expand Down

0 comments on commit 03abd4f

Please sign in to comment.