wound can provide armor penalty for limbs (#89751)

This commit is contained in:
Maleclypse
2026-11-25 22:11:46 -06:00
committed by GitHub
8 changed files with 58 additions and 3 deletions
+1
View File
@@ -56,6 +56,7 @@ Align bleed values to the ones in body_parts.json unless being instructed otherw
},
{ "type": "VITAMIN", "vitamin_id": "redcells", "rate": "1 seconds", "amount": -1 } // if VITAMIN type, `vitamin_id` is used to specify the vitamin that should be modified
],
"armor_penalty": { "bash": 10, "cut": 10 }, // if this bodypart provides `armor`, this wound reduces this armor by this flat amount. Amount is slowly restored the more healed the wound is
"periodic_message": { // used to send messages into log when such wound is presented. Reserve for the most important one
"message": "OH NO YOUR WOUND ON YOUR %s IS BLEEDING CLOSE IT CLOSE IT CLOSE IT!", // argument %s is body part name
"rate": "2 seconds"
+31
View File
@@ -1421,6 +1421,37 @@ void bodypart::set_encumbrance_data( const encumbrance_data &set )
encumb_data = set;
}
float bodypart::get_damage_resistance( const damage_unit &du ) const
{
float ret = id->damage_resistance( du );
if( ret == 0.f ) {
return ret;
}
for( const wound &wd : wounds ) {
ret -= wd.get_armor_penalty( du.type );
}
return std::max( 0.f, ret );
}
float bodypart::get_damage_resistance( const damage_type_id &dt ) const
{
float ret = id->damage_resistance( dt );
if( ret == 0.f ) {
return ret;
}
for( const wound &wd : wounds ) {
ret -= wd.get_armor_penalty( dt );
}
return std::max( 0.f, ret );
}
void bodypart::set_mut_drench( const std::pair<water_tolerance, int> &set )
{
if( set.first < WT_IGNORED || set.first > NUM_WATER_TOLERANCE ) {
+3
View File
@@ -560,6 +560,9 @@ class bodypart
void set_encumbrance_data( const encumbrance_data &set );
float get_damage_resistance( const damage_unit &du ) const;
float get_damage_resistance( const damage_type_id &dt ) const;
void set_mut_drench( const std::pair<water_tolerance, int> &set );
void mod_hp_cur( int mod );
+1 -1
View File
@@ -5123,7 +5123,7 @@ void Character::passive_absorb_hit( const bodypart_id &bp, damage_unit &du ) con
// Thin skin check goes before subdermal armor plates because SUBdermal
if( du.amount > 0.0f ) {
du.amount -= mutation_armor( bp, du );
du.amount -= bp->damage_resistance( du );
du.amount -= get_part( bp )->get_damage_resistance( du );
}
du.amount -= bionic_armor_bonus( bp, du.type ); //Check for passive armor bionics
du.amount -= mabuff_armor_bonus( du.type );
+1 -1
View File
@@ -89,7 +89,7 @@ int Character::get_armor_type( const damage_type_id &dt, bodypart_id bp ) const
ret += prot->second.type_resist( dt );
}
}
return ret + mutation_armor( bp, dt ) + bp->damage_resistance( dt );
return ret + mutation_armor( bp, dt ) + get_part( bp )->get_damage_resistance( dt );
}
std::map<bodypart_id, int> Character::get_all_armor_type( const damage_type_id &dt ) const
+8
View File
@@ -6,6 +6,7 @@
#include <optional>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -249,6 +250,13 @@ void medical_ui::print_debug_wound_info( const Character &you, const bodypart_id
tooltip += "-----\n";
}
if( !wd.type->armor_penalty.empty() ) {
tooltip += "armor penalty applied:\n";
for( const std::pair<const damage_type_id, float> &res : wd.type->armor_penalty ) {
tooltip += string_format( "%s: %.0f\n", res.first.str(), wd.get_armor_penalty( res.first ) );
}
tooltip += "-----\n";
}
ImGui::SetTooltip( "%s", tooltip.c_str() );
}
+6
View File
@@ -44,6 +44,7 @@ void wound_type::load( const JsonObject &jo, const std::string_view & )
optional( jo, was_loaded, "limit", limit, 0 );
optional( jo, was_loaded, "severity", severity, wound_severity::MINOR );
optional( jo, was_loaded, "armor_penalty", armor_penalty );
optional( jo, was_loaded, "mod_values", mod_values );
optional( jo, was_loaded, "periodic_message", periodic_message );
optional( jo, was_loaded, "wound_progression", wound_progression );
@@ -610,6 +611,11 @@ int wound::get_hp_damage() const
return hp_damage * ( 1.f - healing_percentage() );
}
float wound::get_armor_penalty( const damage_type_id &dt ) const
{
return type->armor_penalty.find( dt )->second * ( 1.f - healing_percentage() );
}
wound_update_ret wound::update_wound( const Character *who, const time_duration time_passed )
{
if( healing_time == calendar::INDEFINITELY_LONG_DURATION && !wound_progress_timer ) {
+7 -1
View File
@@ -7,6 +7,7 @@
#include <set>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -181,8 +182,13 @@ class wound_type
// if applied, how much pain it might provide to you
std::pair<int, int> pain_;
std::unordered_map<damage_type_id, float> armor_penalty;
// variety of effects and character modifications that happen when this wound is present
std::vector<wound_mod_values> mod_values;
friend class medical_ui;
friend class wound;
};
enum class wound_update_ret {
@@ -205,7 +211,6 @@ class wound
void serialize( JsonOut &jsout ) const;
void deserialize( const JsonObject &jsin );
// returns the wound healing progress divided by healing time
float healing_percentage() const;
void mod_pain( int mod );
// return how much pain this specific wound gives you, reduced depending on how long the wound presented and character effects.
@@ -218,6 +223,7 @@ class wound
time_duration get_healing_time() const;
float get_healing_progress() const;
int get_hp_damage() const;
float get_armor_penalty( const damage_type_id &dt ) const;
// update the wound healing progress
wound_update_ret update_wound( const Character *who, time_duration time_passed );