Skip to content

Commit

Permalink
feat(balance): add support for clothing mods being modified by item v…
Browse files Browse the repository at this point in the history
…olume, convert pocket mod to use that instead of thickness (#5687)

* feat(balance): add support for clothing mods being modified by item volume, convert pocket mod to use that instead of thickness

* Update clothing_mods.json

* aaaaaaaaa
  • Loading branch information
chaosvolt authored Nov 8, 2024
1 parent fc25c59 commit eddd7f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions data/json/clothing_mods.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"implement_prompt": "Add pockets",
"destroy_prompt": "Remove pockets",
"mod_value": [
{ "type": "encumbrance", "value": 2, "proportion": [ "coverage" ] },
{ "type": "storage", "value": 3, "round_up": true, "proportion": [ "thickness", "coverage" ] }
{ "type": "encumbrance", "value": 1, "round_up": true, "proportion": [ "volume", "coverage" ] },
{ "type": "storage", "value": 1, "round_up": true, "proportion": [ "volume" ] }
]
}
]
5 changes: 3 additions & 2 deletions doc/src/content/docs/en/mod/json/reference/json_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -3433,8 +3433,9 @@ The following actions are available as defined in trapfunc.cpp:
"value": 1, // value of effect.
"round_up": false // (optional) round up value of effect. defaults to false.
"proportion": [ // (optional) value of effect propotions to clothing's parameter.
"thickness", // "thickness" and "coverage" is available.
"coverage"
"thickness", // Add value for every layer of "material_thickness" the item has.
"volume", // Add value for every liter of baseline volume the item has.
"coverage" // Reduce value by percentage of average coverage the item has.
]
}
]
Expand Down
6 changes: 6 additions & 0 deletions src/clothing_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ void clothing_mod::load( const JsonObject &jo, const std::string & )
const std::string &str = entry.get_string();
if( str == "thickness" ) {
mv.thickness_propotion = true;
} else if( str == "volume" ) {
mv.volume_propotion = true;
} else if( str == "coverage" ) {
mv.coverage_propotion = true;
} else {
Expand All @@ -97,13 +99,17 @@ float clothing_mod::get_mod_val( const clothing_mod_type &type, const item &it )
{
const int thickness = it.get_thickness();
const int coverage = it.get_avg_coverage();
const int vol = it.base_volume() / 1_liter;
float result = 0.0f;
for( const mod_value &mv : mod_values ) {
if( mv.type == type ) {
float tmp = mv.value;
if( mv.thickness_propotion ) {
tmp *= thickness;
}
if( mv.volume_propotion ) {
tmp *= vol;
}
if( mv.coverage_propotion ) {
tmp *= coverage / 100.0f;
}
Expand Down
1 change: 1 addition & 0 deletions src/clothing_mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct mod_value {
float value = 0.0f;
bool round_up = false;
bool thickness_propotion = false;
bool volume_propotion = false;
bool coverage_propotion = false;
};

Expand Down

0 comments on commit eddd7f2

Please sign in to comment.