Skip to content

Commit

Permalink
Weakpoints (Part 2.1): Ignore weakpoints for item DPS calculations (#…
Browse files Browse the repository at this point in the history
…51404)

* Ignore weakpoints for item DPS calculations

* Increase epsilon between actual and expected DPS

* Fix bug with rapid strike calculation

* set effective_dps_test to use a test soldier

* Update zed_soldiers.json

Co-authored-by: I-am-Erk <[email protected]>
  • Loading branch information
Joshua-Chin and I-am-Erk authored Sep 6, 2021
1 parent 0ab1dd9 commit 142b56a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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

0 comments on commit 142b56a

Please sign in to comment.