diff --git a/data/json/monsters/zed_soldiers.json b/data/json/monsters/zed_soldiers.json index 4f8e8aecff678..e5547d448589a 100644 --- a/data/json/monsters/zed_soldiers.json +++ b/data/json/monsters/zed_soldiers.json @@ -35,6 +35,13 @@ "fungalize_into": "mon_zombie_fungus", "flags": [ "SEES", "HEARS", "SMELLS", "WARM", "BASHES", "GROUP_BASH", "POISON", "NO_BREATHE", "REVIVES", "PUSH_MON", "FILTHY" ] }, + { + "id": "mon_zombie_soldier_no_weakpoints", + "type": "MONSTER", + "name": { "str": "zombie soldier test only" }, + "description": "This zombie soldier is for testing purposes only.", + "copy-from": "mon_zombie_soldier" + }, { "id": "mon_zombie_soldier_blackops_1", "type": "MONSTER", diff --git a/src/item.cpp b/src/item.cpp index 9b25c2bb95905..763dac35128ee 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1650,7 +1650,11 @@ double item::effective_dps( const Character &guy, Creature &mon ) const guy.roll_all_damage( crit, base_damage, true, *this ); damage_instance dealt_damage = base_damage; // TODO: Modify DPS calculation to consider weakpoints. - temp_mon->absorb_hit( nullptr, bodypart_id( "torso" ), dealt_damage ); + resistances r = resistances( *static_cast( temp_mon ) ); + for( damage_unit &dmg_unit : dealt_damage.damage_units ) { + dmg_unit.amount -= std::min( r.get_effective_resist( dmg_unit ), dmg_unit.amount ); + } + dealt_damage_instance dealt_dams; for( const damage_unit &dmg_unit : dealt_damage.damage_units ) { int cur_damage = 0; @@ -1674,7 +1678,10 @@ double item::effective_dps( const Character &guy, Creature &mon ) const dmg_unit.damage_multiplier *= 0.66; } // TODO: Modify DPS calculation to consider weakpoints. - temp_rs_mon->absorb_hit( nullptr, bodypart_id( "torso" ), dealt_rs_damage ); + resistances rs_r = resistances( *static_cast( temp_rs_mon ) ); + for( damage_unit &dmg_unit : dealt_rs_damage.damage_units ) { + dmg_unit.amount -= std::min( rs_r.get_effective_resist( dmg_unit ), dmg_unit.amount ); + } dealt_damage_instance rs_dealt_dams; for( const damage_unit &dmg_unit : dealt_rs_damage.damage_units ) { int cur_damage = 0; diff --git a/tests/effective_dps_test.cpp b/tests/effective_dps_test.cpp index 59c725849abae..3486999b0573b 100644 --- a/tests/effective_dps_test.cpp +++ b/tests/effective_dps_test.cpp @@ -123,7 +123,7 @@ TEST_CASE( "effective damage per second", "[effective][dps]" ) } SECTION( "against an armored target" ) { - monster soldier( mtype_id( "mon_zombie_soldier" ) ); + monster soldier( mtype_id( "mon_zombie_soldier_no_weakpoints" ) ); CHECK( clumsy_sword.effective_dps( dummy, soldier ) == Approx( 8.0f ).epsilon( 0.15f ) ); CHECK( good_sword.effective_dps( dummy, soldier ) == Approx( 15.0f ).epsilon( 0.15f ) ); @@ -166,7 +166,7 @@ TEST_CASE( "effective vs actual damage per second", "[actual][dps][!mayfail]" ) avatar &dummy = get_avatar(); clear_character( dummy ); - monster soldier( mtype_id( "mon_zombie_soldier" ) ); + monster soldier( mtype_id( "mon_zombie_soldier_no_weakpoints" ) ); monster smoker( mtype_id( "mon_zombie_smoker" ) ); monster survivor( mtype_id( "mon_zombie_survivor" ) ); @@ -198,7 +198,7 @@ TEST_CASE( "accuracy increases success", "[accuracy][dps]" ) avatar &dummy = get_avatar(); clear_character( dummy ); - monster soldier( mtype_id( "mon_zombie_soldier" ) ); + monster soldier( mtype_id( "mon_zombie_soldier_no_weakpoints" ) ); monster smoker( mtype_id( "mon_zombie_smoker" ) ); monster survivor( mtype_id( "mon_zombie_survivor" ) );