diff --git a/data/json/materials.json b/data/json/materials.json index 824b4fc006753..31815edf29f14 100644 --- a/data/json/materials.json +++ b/data/json/materials.json @@ -218,6 +218,7 @@ "fire_resist": 1, "elec_resist": 2, "chip_resist": 8, + "wind_resist": 90, "repaired_with": "bone", "salvaged_into": "skewer_bone", "dmg_adj": [ "scratched", "cut", "cracked", "shattered" ], @@ -360,6 +361,7 @@ "fire_resist": 2, "elec_resist": 2, "chip_resist": 10, + "wind_resist": 90, "repaired_with": "chitin_piece", "salvaged_into": "chitin_piece", "dmg_adj": [ "scratched", "cut", "cracked", "shattered" ], @@ -429,6 +431,7 @@ "fire_resist": 0, "elec_resist": 2, "chip_resist": 6, + "wind_resist": 70, "repaired_with": "cotton_patchwork", "salvaged_into": "cotton_patchwork", "dmg_adj": [ "ripped", "torn", "shredded", "tattered" ], @@ -1077,6 +1080,7 @@ "fire_resist": 2, "elec_resist": 2, "chip_resist": 10, + "wind_resist": 90, "repaired_with": "leather", "salvaged_into": "leather", "dmg_adj": [ "scratched", "cut", "shredded", "tattered" ], @@ -1187,6 +1191,7 @@ "fire_resist": 20, "elec_resist": 4, "chip_resist": 8, + "wind_resist": 90, "repaired_with": "nomex", "salvaged_into": "nomex", "dmg_adj": [ "ripped", "torn", "shredded", "tattered" ], @@ -1325,6 +1330,7 @@ "fire_resist": 1, "elec_resist": 2, "chip_resist": 6, + "wind_resist": 90, "repaired_with": "plastic_chunk", "salvaged_into": "plastic_chunk", "dmg_adj": [ "scratched", "cut", "cracked", "shattered" ], @@ -1955,6 +1961,7 @@ "fire_resist": 0, "elec_resist": 2, "chip_resist": 6, + "wind_resist": 60, "repaired_with": "felt_patch", "salvaged_into": "felt_patch", "dmg_adj": [ "ripped", "torn", "shredded", "tattered" ], diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index dd92cd48dec61..2b1068e57261b 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -842,6 +842,7 @@ When you sort your inventory by category, these are the categories that are disp | `dmg_adj` | Description added to damaged item in ascending severity. | `dmg_adj` | Adjectives used to describe damage states of a material. | `density` | Affects vehicle collision damage, with denser parts having the advantage over less-dense parts. +| `wind_resist` | Percentage 0-100. How effective this material is at stopping wind from getting through. Higher values are better. If none of the materials an item is made of specify a value, a default of 99 is assumed. | `vitamins` | Vitamins in a material. Usually overridden by item specific values. An integer percentage of ideal daily value. | `specific_heat_liquid` | Specific heat of a material when not frozen (J/(g K)). Default 4.186 - water. | `specific_heat_solid` | Specific heat of a material when frozen (J/(g K)). Default 2.108 - water. diff --git a/src/character.cpp b/src/character.cpp index 1152a5a5a4fde..3b07c7bda0d80 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -4795,18 +4795,7 @@ std::map Character::get_wind_resistance( const std::map materials = made_of_types(); + if( materials.empty() ) { + debugmsg( "Called item::wind_resist on an item (%s) made of nothing!", tname() ); + return 99; + } + + int best = -1; + for( const material_type *mat : materials ) { + cata::optional resistance = mat->wind_resist(); + if( resistance && *resistance > best ) { + best = *resistance; + } + } + + // Default to 99% effective + if( best == -1 ) { + return 99; + } + + return best; +} + std::set item::faults_potential() const { std::set res; diff --git a/src/item.h b/src/item.h index f75765b40a95c..1fc619d3dc078 100644 --- a/src/item.h +++ b/src/item.h @@ -1302,6 +1302,9 @@ class item : public visitable void set_last_temp_check( const time_point &pt ); + /** How resistant clothes made of this material are to wind (0-100) */ + int wind_resist() const; + /** What faults can potentially occur with this item? */ std::set faults_potential() const; diff --git a/src/material.cpp b/src/material.cpp index 132731241f61b..7fadc100dd0af 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -65,6 +65,7 @@ void material_type::load( const JsonObject &jsobj, const std::string & ) mandatory( jsobj, was_loaded, "chip_resist", _chip_resist ); mandatory( jsobj, was_loaded, "density", _density ); + optional( jsobj, was_loaded, "wind_resist", _wind_resist ); optional( jsobj, was_loaded, "specific_heat_liquid", _specific_heat_liquid ); optional( jsobj, was_loaded, "specific_heat_solid", _specific_heat_solid ); optional( jsobj, was_loaded, "latent_heat", _latent_heat ); @@ -119,6 +120,11 @@ void material_type::check() const if( !item::type_is_defined( _repaired_with ) ) { debugmsg( "invalid \"repaired_with\" %s for %s.", _repaired_with.c_str(), id.c_str() ); } + + if( _wind_resist && ( *_wind_resist > 100 || *_wind_resist < 0 ) ) { + debugmsg( "Wind resistance outside of range (100%% to 0%%, is %d%%) for %s.", *_wind_resist, + id.str() ); + } } material_id material_type::ident() const @@ -222,6 +228,11 @@ int material_type::density() const return _density; } +cata::optional material_type::wind_resist() const +{ + return _wind_resist; +} + bool material_type::edible() const { return _edible; diff --git a/src/material.h b/src/material.h index 13cb439dbea4f..77d1913103eb4 100644 --- a/src/material.h +++ b/src/material.h @@ -71,6 +71,8 @@ class material_type int _bullet_resist = 0; int _chip_resist = 0; // Resistance to physical damage of the item itself int _density = 1; // relative to "powder", which is 1 + // How resistant this material is to wind as a percentage - 0 to 100 + cata::optional _wind_resist; float _specific_heat_liquid = 4.186f; float _specific_heat_solid = 2.108f; float _latent_heat = 334.0f; @@ -125,6 +127,7 @@ class material_type float latent_heat() const; float freeze_point() const; int density() const; + cata::optional wind_resist() const; bool edible() const; bool rotting() const; bool soft() const;