Skip to content

Fix mastery, poison length and curse rows in the stats panel - #100

Open
errolgr wants to merge 3 commits into
Project-Diablo-2:mainfrom
errolgr:fix/stats-damage-rows
Open

errolgr wants to merge 3 commits into
Project-Diablo-2:mainfrom
errolgr:fix/stats-damage-rows

Conversation

@errolgr

@errolgr errolgr commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes four rows in the advanced stats panel that showed wrong values:

  • Crushing Blow, Critical Strike multiplier and Projectile Pierce included Two Hand Mastery, Javelin and Spear Mastery and Throwing Mastery bonuses with any weapon, including unarmed.
  • Critical Strike chance never included Claw and Dagger Mastery with Attack, Tiger Strike, Fists of Fire and the other claw skills.
  • Poison Resist "Length" was not clamped to the game's 25%-200% range. In Normal, 100% reduction showed Length: 0%.
  • Curse Resist drew the / in orange; the other resist rows draw it in white.

Problem

Masteries. On the server, a passive mastery stat sits on the mastery's item-type layer (passiveitype in Skills.txt), so it only counts with a matching weapon. The client's stat list has the same stats at layer 0 whatever is equipped. In game, with a hand axe, large axe, javelin or no weapon, GetUnitStat(…, 0) always returned item_crushingblow 29, skill_pierce 41 and item_crit_multiplier 29 at mastery level 20. GetMasteryStat is meant to take a non-matching mastery's bonus back out, but its fallback branch only did that for pierce, and the pierce call in StatsDisplay.cpp was commented out. (c795e3f changed the fallback from "always subtract" to "pierce only"; the client data above shows crushing blow, efficiency and the crit multiplier need the same treatment.)

Claw and Dagger Mastery's crit chance was only counted when the right skill's item type is hand-to-hand (h2h), i.e. Dragon Claw and Weapon Block. Attack is weap and PD2's claw skills are asm, so it was missing almost always.

Poison length. The game adds the difficulty penalty to "Poison Length Reduced by", clamps the result to -100..75 and scales the length by (100 - that)%. The panel printed 100 - penalty - reduction without the clamp.

Changes

File Change
BH/D2Helpers.cpp GetMasteryStat: when the weapon doesn't match the mastery's item type, subtract crushing blow, crushing blow efficiency, crit multiplier and pierce (all four are in the client's stats). Count Claw and Dagger Mastery crit for melee weapon skills (same test as One Hand Mastery) and for asm skills
BH/Constants.h ITEM_TYPE_ASSASSIN_MASTERY (91, asm)
BH/Drawing/Stats/StatsDisplay.cpp Use the Throwing Mastery pierce correction again; clamp the poison length; white / in the curse row

One Hand Mastery and Throwing Mastery crit chance were already correct, and stay as they are.

Testing

In game (PD2 Season 13 client, single player): an Assassin with Two Hand, Throwing, Javelin and Spear, and Claw and Dagger Mastery at level 20. I checked 6 weapon/skill cases × 3 rows, plus the resist and leech rows. Expected values come from PD2's Skills.txt (level 20: 2HM crushing blow 29, efficiency +25; Throwing Mastery pierce 41; JSM crit multiplier +29; Claw and Dagger Mastery crit 25).

Result
Before (current main; the shipped PD2 BH.dll draws the same lines) 17 of 29 checked lines wrong
After (this PR) 29/29 correct
Case Row Before After
Hand axe Crushing Blow 29 / 125% 0 / 100%
Hand axe Critical Strike 0 / 75 / 229% 0 / 75 / 200%
Hand axe Projectile Pierce 41 0
Large axe (2H) Crushing Blow 29 / 125% 29 / 125%
Javelin Critical Strike / Pierce 0 / 75 / 229% / 41 0 / 75 / 229% / 41
Javelin Crushing Blow 29 / 125% 0 / 100%
Katar, Attack or Tiger Strike Critical Strike 0 / 75 / 229% 25 / 75 / 200%
100% poison length reduction (Normal) Poison Resist Length: 0% Length: 25%

Screenshots

Hand axe

Before After
before after

Katar, Attack

Before After
before after

Resist rows: 100% poison length reduction, 90% curse resistance, 80% reduced curse duration

Before After
before after

Unit tests for the poison length (13 cases, Normal/Nightmare/Hell) and the resist-row colors run StatsDisplay.cpp against a fake engine. They fail on main and pass here. A clang-cl build of this branch launched cleanly 10/10 times in the PD2 client and 10/10 in vanilla 1.13c.

Full evidence (all cases, derivations, full-frame screenshots, and the reported issues that turned out not to be bugs): PR-EVIDENCE.md

The client's stat list carries the passive stats of Two Hand Mastery
(crushing blow, crushing blow efficiency), Javelin and Spear Mastery
(critical strike multiplier) and Throwing Mastery (pierce) whatever
weapon is equipped. GetMasteryStat only took the pierce bonus back out
when the weapon does not match, and the pierce call itself was commented
out, so the panel showed e.g. 2HM crushing blow with a one-handed axe or
unarmed, the JSM multiplier with a bow, and Throwing Mastery pierce with
any weapon. Remove all four when the weapon does not match the
mastery's passive item type, and use the pierce correction again.

Claw and Dagger Mastery's critical strike was only counted when the
right skill's item type is hand-to-hand (Dragon Claw, Weapon Block).
Attack ("weap") and PD2's claw skills ("asm": Tiger Strike, Fists of
Fire, ...) never matched, so it was missing for nearly every skill.
Count it for melee weapon skills, like One Hand Mastery, and for "asm"
skills.
The game clamps a player's poison length reduction, after the difficulty
penalty, to -100..75 (Hell: 175% reduction reaches the 75% cap), so
poison lasts between 25% and 200% of its base length. The panel printed
100 - penalty - reduction unclamped, e.g. 0% for 100% reduction in
Normal or -25% for 225% in Hell. Apply the same clamp.
@errolgr
errolgr marked this pull request as ready for review October 5, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant