Thx for all the infos niente, these are some complex calculations and I hope that they do not create much lag. . There seems to be a mistake in your post. As the elemental dmg is 10 it should be 50*10 / 100. The result is 5 but 50/100 = 0.5. What happens if the NPC has more than 200 resists ?
The post looks fine to me. Potential Damage = 10 Roll = 150 Resist = 100 Multiplier ("remaining roll") = 150 - 100 = 50 Result = Potential Damage * Multiplier / 100 Result = 10 * 50 / 100 (or as you said, 10 * 0.5) = 5 Zero damage is added.
How is it "just like the ratio on a wizard spell" when there is no ratio on a wizard spell? It's almost like it shouldn't be calculated in a ratio, just like a wizard spell isn't calculating a ratio. You're so close, and yet so far.
Where is that correction, it still looks like you're always rolling if the NPC has 200 or less. What is that "very low" threshold where it will always do full damage?