Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account
This post has been closed. You can still view previous posts, but you can't post any new replies.

D&D 3.5 Masterwork Weapon Macro/Math Help

I'm trying to concoct a macro formula to put in a character sheet that will apply the greater of two values: either the masterwork bonus of a weapon (which will be either +1 or 0) or its enhancement bonus (which can be any number from -6 to +6). That above part is easy; the difficult wrinkle is I would like for a negative enhancement bonus to trump the masterwork bonus. This is for those cursed magical weapons that may have a magical -2 to hit - you don't get the masterwork bonus to hit. Short of a sheetworker or the API is this possible? I am sure it involves the abs() function somehow, but I have not been able to come up with something that works in all cases. Thanks in advance for any advice.
1469246783

Edited 1469246966
Silvyre
Forum Champion
This should work: {@{e}, @{m}}kh1 * ceil((@{e} + 1) / 100) + @{e} * (1 - ceil((@{e} + 1) / 100) ) ceil((@{e} + 1) / 100) equals 0 if @{e} < 0. Otherwise, it equals 1.
Thanks very much for the math brilliance, Silvyre. It works exactly as I wanted. And clearly, I was barking up the wrong tree with abs().... d'oh!