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

I need a roll to get a -4 if a special damage type is used.

I tried this but it doesn't work: -4*(1*@{weapon_damage_type-1}==4)] here is the full code for it. Anyone help please? <th><button type='roll' class="sheet-skillbutton" value="&{template:default} {{name=@{character_name} attacks with @{weapon_name-1} }} [[ ([[{9,11,13,15,17,21,24,27,30}<[[1d10+@{weapon_attack_rating-1}+?{Modifiers|0}-4*(1*@{weapon_damage_type-1}==4)]] ]]+ @{weapon_damage_base-1})*@{weapon_damage_Multiplier-1} ]] {{Roll=$[[0]]}} {{Levels=$[[1]]}} {{Damage=$[[2]]}}"></button>                 <td><input type="text" class="sheet-textbox" style="width:200px" name="attr_weapon_name-1" /></td>                 <th><input type="number" class="sheet-numberbox" name="attr_weapon_RoF-1" /></th>                 <th><input type="number" class="sheet-numberbox" name="attr_weapon_attack_rating-1"  /></th>                 <th class="sheet-lb"><input type="number" class="sheet-numberbox" name="attr_weapon_damage_base-1" /></th>                 <th class="sheet-rb"><input type="number" class="sheet-numberbox" name="attr_weapon_damage_Multiplier-1"                         value="@{weapon_damage_type-1}" disabled="true" /></th>                 <th><input type="number" class="sheet-numberbox" name="attr_weapon_range_Short-1" /></th>                 <th><input type="number" class="sheet-numberbox" name="attr_weapon_range_Medium-1" /></th>                 <th><input type="number" class="sheet-numberbox" name="attr_weapon_range_Long-1" /></th>                 <th><select class="sheet-skill_select" name="attr_weapon_damage_type-1" >                     <option value="2">Bullet</option>                     <option value="1">Non-Bullet</option>   <option value="4">Headshot</option></select></th>
1680952741

Edited 1680953148
GiGs
Pro
Sheet Author
API Scripter
Cam you describe exactly what you want to happen? This {9,11,13,15,17,21,24,27,30} looks like Unisystem progression. What's going on with your roll? By the way, Roll20 roll macros don't do if statements, and it looks like you are trying to build an if statement if the weapon_damage-1 attribute contained 4? There are sometimes ways to fake it, but you might want to look at Custom Roll Parsing. It also looks like you have the weapon_damage_type-1 value set in your select (which doesn't have a -4 option), and displayed in another. You will probably be better off setting that diisplay value with a span rather than in input. Finally you are using tables (th, td, etc). You should know if you ever plan to share this sheet on Roll20, it will be arbitrarily rejected with no appeal. Roll20 do not accept sheets using html tables for layout. You are better off using CSS Grid .
Thanks for taking time to answer. I would like to have a minus four for the roll if attr_weapon_damage_type-1  option value="4">Headshot is selected.  I thought it might work with this: -4*(1*@{weapon_damage_type-1}==4)] but it doesn't seem to work. Iif you have bullet selected it deals double damage, if you select headshot it deals 4 times damage but also makes the roll harder by -4 It is a very old sheet. If I find some time I might try to get rid of the tables. thanks for suggesting CSS Grid.
1681013399

Edited 1681185016
GiGs
Pro
Sheet Author
API Scripter
To be clear, you want a unisystem attack roll that also shows the damage roll, and want to take the head location into account (which has a -4 on attacks but x4 damage?) Bear in mind, some things simply cannot done with basic roll macros (even with reusing rolls), and you may need to use Custom Roll Parsing. Lets find out what you need.
Yes, the damage is working. All the rest of the actions and moves are fine too. This is the last thing. (the -4 to the roll if Headshot is selected)
1681190354
GiGs
Pro
Sheet Author
API Scripter
I can see a way to modify your roll for the -4/x4 effect, but not also taking into account a 0/x1 modifier for normal attacks. I think you'd probably have to abandon your current approach and use Custom Roll Parsing (which can hndle any roll manipulation, but often requires extensive rolltemplate and html modification to fit it).
1681448934
John D.
Pro
Sheet Author
I completely agree with GiGs that CRP is the way to go.  That said, I have abandoned the solution I'm about to describe for CRP because it is far superior  but if you want another approach to consider, this is how I solved a similar problem  before we had CRP : Use checkboxes to trigger options on/off, style them as fake buttons for better player experience!  Use sheet workers to build a roll value string for your roll button each time one of these checkboxes is ticked (on/off) and calculate for all the checkboxes that are on (or off depending on what logic suits your needs) to build a new roll value string that will satisfy the intended roll.  You will need to use a hidden input in your HTML to write this string to, and set the button's value to the name of this hidden input.  Using this method, you can also add/remove/modify roll template variables, or use different roll  templates, etc.  It's very flexible. You could also use a combination of both solutions if that better achieves your goals.
1681450238
GiGs
Pro
Sheet Author
API Scripter
I've used that approach, and it does work. Depending on the roll method, it might even be less work than the CRP method (especially if you are not comfortable with the coding necessary for CRP).
wow thanks a lot. I will try to see if I can make it. Thanks for all the help!