I was looking at the code of how hit chance is calculated in skill.attackEntity. There actor.getDefense is used to calculate toHit. This function halves all defense above 50. Later toHit is “fixed” if shield and shieldwall bonuses should be ignored. In the scenario of defense above 50, this results in the erroneous calculation when removing these effects, resulting in an overall lower defense.
What seems to be a solution is to move shield/shieldwall ignoring calculations in actor.getDefense before doing the defense reduction if above 50.