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

max bonus to a formula?

Hi, i've been reading through wiki and trying various things, but am not sure if what I'm trying to do is possible. On my custom sheet, I have scores listed with a die roller next to them. The scores are computed for example as follows:  value="@{Dexterity}+@{bows_pro}". On character sheet, a character with 3 dex and +3 proficiency bonus to bows would see a 6. When they click the die roller, it rolls d20 +6. Great.  Now, unlike 5e d&d i want to allow characters to go above 5 with ability scores by giving them alternative benefits that don't impact bounded. so extra damage but not bonus to hit if you incresae strength above 5. Is there a way for me to set a max to the bonus derived from an ability score in above formula such that if character above had 6 dex, the bonus would still only ready +8, and the die roll would also only roll +8? I believe I see ways to make the macro rolls deal with it, but I also want the score on the sheet to reflect. Any help writing the code would be helpful and greatly appreciated. Thank you 
1587963834
GiGs
Pro
Sheet Author
API Scripter
Try value="{@{Dexterity},5}dh1+@{bows_pro}" dh1 means drop the highest one. You might want to put inline roll brackets around it if you want to reduce the stuff it prints to chat, like value="[[{@{Dexterity},5}dh1]]+@{bows_pro}"
Thanks for your help. It works well for the macro, but for the display it shows a mix of numbers that don't correspond to the bonus to the d20. It just doesn't seem to work for displaying a value, even if the roller calculates it correctly. For example, I see "105" in the box when I do this and have 5 strength
1588142318
GiGs
Pro
Sheet Author
API Scripter
That suggests the attributes are being concatenated - treated as strings, not numbers. This is caused by the way the attributes are added together. We need to see the code for the attributes that contribute t this final attribute. If for instance your strength, dexterity, bow_pro, or other attributes are themselves calculated values, we need to see how they are calculated.
1588146789
Ziechael
Forum Champion
Sheet Author
API Scripter
I've found that trying to use roll syntax doesn't work well in character sheet calculated displays, resulting in the concatenated values as string like GiGs suggest. The value still works when printed to chat or used in an actual roll but is a nasty UX. For the max dex bonus on my Midnight sheet I had to get around this with good ole math: value="(((@{dex-mod} + @{acitemdex}) - abs(@{dex-mod} - @{acitemdex})) / 2)" I think the next step for me is to remove this autocalc field completely however and replace it with a sheet-worker set field... autocalc is a bit clunky and can be a cause of sheet slowdown if overused.
Hey there. Here's how one of my attributes is being calculated, for example strength (by input of player). For strength max, they can update that in their character stats when needed upon leveling (I still do ability damage like in 3.5 d&d).  Strength: <input type="number" align = "center" name="attr_Strength"><input type="number" align = "center" style='width: 35%' name="attr_Strength_max" value="@{STR}" disabled="true">  Here is how a skill value and roll is being done. Below that is the proficiency field.  Bows (DEX)</b> <input type="number"  value="@{Dexterity}+@{bows_pro}" name="attr_bowshit" disabled="true">     <button type="roll" value="@{character_name} rolled [[d20+@{bowshit}]] to hit with bows!" name="roll_Bows(DEX)"></button>                       <div><input type="radio" id="Bows_none"   name="attr_bows_pro" value="0" checked><span></span>              <input type="radio" id="Bows_versed"  name="attr_bows_pro" value="@{Versed}"><span></span>              <input type="radio" id="Bows_proficient" name="attr_bows_pro" value="@{Proficient}"><span></span>              <input type="radio" id="Bows_specialized" name="attr_bows_pro" value="@{Specialized}"><span></span>              <input type="radio" id="Bows_legendary" name="attr_bows_pro" value="@{Legendary}"><span></span> And here is that proficiency level bonus.  Another weird thing I can't get around (I am very inexperienced at coding, this is my first time every using html), is for the proficiency/specialized/legendary input.  Below, for versed/proficient/specialized, the player can manually enter those bonuses. The reference modifier shown for given skill (such as bows) for that proficiency score is great, and the roll works great. But whenever I manually enter a value through a calculation based on character level, or simply enter a number such as "5" and disabling it like I did for specialized below, the result shown for skill modifier reference is still correct (character with three strength and +5 legendary shows a +8 with bows), but the roll itself doesn't include the specialiezd bonus (or other times, when i computed all 4 of them based on character level, the roll would give a bonus that was far higher than it should have been, but again the modfier shown for player reference is always correct). It would be nice to have this autocalculate for rapid NPC generation in my modded system.  Perhaps these issue are related? Thanks again.   Versed: <input type="number" align = "center" style='width: 27%' name="attr_Versed"><br>      Proficient: <input type="number" align = "center" style='width: 20%' name="attr_Proficient" ><br>    Specialized: <input type="number" align = "center" style='width: 16%'name="attr_Specialized"><br>    Legendary: <input type="number" align = "center" style='width: 18%' name="attr_Legendary" value="5" disabled="true"> </h4>
For example:  When bows skill is marked as proficent below, a character with 2 dex and a manually entered proficiency bonus of +1 is show correctly and rolled correcty (you can ignore all the 0s, those are injury mods i've added but work fine and so i've excluded from code above). the first 2 is dex, then the +1 is the proficiency.    BUT, when i go up to legendary with my  manually inputted +5 via code, the score is shown correctly, but the roll is not done correctly: