Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weakpoints (Part 2.1): Ignore weakpoints for item DPS calculations #51404

Merged
merged 5 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions data/json/monsters/zed_soldiers.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 9 additions & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<monster *>( 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;
Expand All @@ -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<monster *>( 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;
Expand Down
6 changes: 3 additions & 3 deletions tests/effective_dps_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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" ) );

Expand Down Expand Up @@ -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" ) );

Expand Down