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

Changing Target Number in Default Roll Template

So as the title says I'm using the Default roll template to do a Target roll Call of Cthulhu style (roll under target). The thing is the target number changes based on various things such as distance, cover, height etc. This is what I have so far &{template:default} {{name=**Shoot**}} {{attack=[[1d100cs<?{Crit Chance|0}]]<[[@{Bob|Aim} + ?{Weapon Range|Shotgun Short 1-8,20|Shotgun Medium 9-16,0|Shotgun Long 17+,-20|Sniper Short 1-8,-20|Sniper Medium 9-16,0|Sniper Long 17+,0|Everything Else Short 1-8,10|Everything Else Medium 9-16,5|Everything Else Long 17+,0} - ?{Alien Defense|Berserker,20|Chryssalid,10|Cyberdisk,10|Drone,10|Ethereal,40|Floater,0|Heavy Floater,10|Mechtoid,10|Muton,10|Muton Elite,20|Outsider,0|Sectoid,0|Sectoid Cmdr,20|Sectopod,30|Seeker,10|Thin Man,0|Uber Ethereal,40|Zombie,0} - ?{Cover|None,0|Half,20|Full,40} - ?{Penelty|0} + ?{Bonus|0}]] }} {{damage=[[1t[Assault Rifle]]]}} Now the output of this is fine as it lists the number rolled right next to the target number, but I was wondering if there is a way to make it just say success or fail like Call of Cthulhu or World of Darkness since the target number changes.
1602990568

Edited 1602990867
Oosh
Sheet Author
API Scripter
edit - I had to remove the space from the Assault Rifle rollable table. While the blank ASCII character works pasting from notepad, the R20 forums seem to break it and the whole macro fails when pasting from here. You'll need to remove it if you want to run the code below There's a few ways to do this, depending on if you want to display any more detailed information. The simplest way is to remove the [[ ]] from around your 1d100 roll, and wrap that entire calculation in brackets. This means the < operator after crit chance actually acts as an operator (it's currently just punctuation since it's ]]  bookended [[ by rolls, not in one itself): &{template:default} {{name=**Shoot**}} {{attack=[[1d100cs<?{Crit Chance|0}<[[@{Bob|Aim} + ?{Weapon Range|Shotgun Short 1-8,20|Shotgun Medium 9-16,0|Shotgun Long 17+,-20|Sniper Short 1-8,-20|Sniper Medium 9-16,0|Sniper Long 17+,0|Everything Else Short 1-8,10|Everything Else Medium 9-16,5|Everything Else Long 17+,0} - ?{Alien Defense|Berserker,20|Chryssalid,10|Cyberdisk,10|Drone,10|Ethereal,40|Floater,0|Heavy Floater,10|Mechtoid,10|Muton,10|Muton Elite,20|Outsider,0|Sectoid,0|Sectoid Cmdr,20|Sectopod,30|Seeker,10|Thin Man,0|Uber Ethereal,40|Zombie,0} - ?{Cover|None,0|Half,20|Full,40} - ?{Penelty|0} + ?{Bonus|0}]] ]] success}} {{damage=[[1t[AssaultRifle]]]}} This doesn't give you a great deal of information, but it's concise. You can only output a 0 or 1 unfortunately - unless you get a bit tricky. There's two ways you can go with this - make the hit/miss look a bit nicer, or zero the damage on a miss. You can also print out more info on the shot difficulty (I always use more shot info mods on XCOM, but you may want to keep the chat log minimal). Cleaning up the output, you will need to create 2 more rollable tables, 0hits and 1hits (call them exactly that), each with one or more text entries for misses and hits. Then tweak the code a little - we also need to wrap the whole modifiers section and do a "keep highest one" with a zero, as a negative modifier total will break the < operator: &{template:default} {{name=**Shoot**}} {{attack=[[1t[[[{[[1d100cs<?{Crit Chance|0}]],0}k1<[[{[[@{Bob|Aim} + ?{Weapon Range|Shotgun Short 1-8,20|Shotgun Medium 9-16,0|Shotgun Long 17+,-20|Sniper Short 1-8,-20|Sniper Medium 9-16,0|Sniper Long 17+,0|Everything Else Short 1-8,10|Everything Else Medium 9-16,5|Everything Else Long 17+,0} - ?{Alien Defense|Berserker,20|Chryssalid,10|Cyberdisk,10|Drone,10|Ethereal,40|Floater,0|Heavy Floater,10|Mechtoid,10|Muton,10|Muton Elite,20|Outsider,0|Sectoid,0|Sectoid Cmdr,20|Sectopod,30|Seeker,10|Thin Man,0|Uber Ethereal,40|Zombie,0} - ?{Cover|None,0|Half,20|Full,40} - ?{Penelty|0} + ?{Bonus|0}]],0}k1]]]]hits]]] Rolled $[[0]] vs $[[1]]}} {{damage=[[1t[AssaultRifle]]]}} And hopefully you get something like this: You could also add in another {{ row }} to print out the modifiers - this makes the information a little easier to check when an unlikely shot hits or misses: &{template:default} {{name=**Shoot**}} {{attack=[[1t[[[{[[1d100cs<?{Crit Chance|0}]],0}k1<[[{[[@{Bob|Aim} + ?{Weapon Range|Shotgun Short 1-8,20|Shotgun Medium 9-16,0|Shotgun Long 17+,-20|Sniper Short 1-8,-20|Sniper Medium 9-16,0|Sniper Long 17+,0|Everything Else Short 1-8,10|Everything Else Medium 9-16,5|Everything Else Long 17+,0} - ?{Alien Defense|Berserker,20|Chryssalid,10|Cyberdisk,10|Drone,10|Ethereal,40|Floater,0|Heavy Floater,10|Mechtoid,10|Muton,10|Muton Elite,20|Outsider,0|Sectoid,0|Sectoid Cmdr,20|Sectopod,30|Seeker,10|Thin Man,0|Uber Ethereal,40|Zombie,0} - ?{Cover|None,0|Half,20|Full,40} - ?{Penelty|0} + ?{Bonus|0}]],0}k1]]]]hits]]] Rolled $[[0]] vs $[[1]]}} {{Modifiers=Range: ?{Weapon Range} Alien Defence: ?{Alien Defense} Cover: ?{Cover} Other: -?{Penelty}, +?{Bonus}}} {{damage=[[1t[AssaultRifle]]]}} And finally, the damage. There is a way to zero damage on a miss, but it means you can't use the [0hits] [1hits] tables to tidy up the hit/miss, it will only output as 0 and 1. This uses the trick of doing the math outside the template fields, then using $[[0]] calls to grab the bits we want for display. It's incompatible with text from a rolltable since that destroys the calculation and we can no longer operate on it: &{template:default} {{name=**Shoot**}} [[ [[ {[[1d100cs<?{Crit Chance|0}]],0}k1<[[{[[@{Bob|Aim} + ?{Weapon Range|Shotgun Short 1-8,20|Shotgun Medium 9-16,0|Shotgun Long 17+,-20|Sniper Short 1-8,-20|Sniper Medium 9-16,0|Sniper Long 17+,0|Everything Else Short 1-8,10|Everything Else Medium 9-16,5|Everything Else Long 17+,0} - ?{Alien Defense|Berserker,20|Chryssalid,10|Cyberdisk,10|Drone,10|Ethereal,40|Floater,0|Heavy Floater,10|Mechtoid,10|Muton,10|Muton Elite,20|Outsider,0|Sectoid,0|Sectoid Cmdr,20|Sectopod,30|Seeker,10|Thin Man,0|Uber Ethereal,40|Zombie,0} - ?{Cover|None,0|Half,20|Full,40} - ?{Penelty|0} + ?{Bonus|0}]],0}k1]] ]]t[AssaultRifle]]] {{Attack=$[[3]] hits $[[0]] vs $[[1]]}} {{damage=$[[4]]}} So personally, I'd probably go with the second to last one, and replace the damage roll with a couple of buttons: &{template:default} {{name=**Shoot**}} {{attack=[[1t[[[{[[1d100cs<?{Crit Chance|0}]],0}k1<[[{[[@{Bob|Aim} + ?{Weapon Range|Shotgun Short 1-8,20|Shotgun Medium 9-16,0|Shotgun Long 17+,-20|Sniper Short 1-8,-20|Sniper Medium 9-16,0|Sniper Long 17+,0|Everything Else Short 1-8,10|Everything Else Medium 9-16,5|Everything Else Long 17+,0} - ?{Alien Defense|Berserker,20|Chryssalid,10|Cyberdisk,10|Drone,10|Ethereal,40|Floater,0|Heavy Floater,10|Mechtoid,10|Muton,10|Muton Elite,20|Outsider,0|Sectoid,0|Sectoid Cmdr,20|Sectopod,30|Seeker,10|Thin Man,0|Uber Ethereal,40|Zombie,0} - ?{Cover|None,0|Half,20|Full,40} - ?{Penelty|0} + ?{Bonus|0}]],0}k1]]]]hits]]] Rolled $[[0]] vs $[[1]]}} {{Modifiers=Range: ?{Weapon Range} Alien Defence: ?{Alien Defense} Cover: ?{Cover} Other: -?{Penelty}, +?{Bonus}}} {{damage=[Roll Damage](~weapons|assaultRifle) // [Roll Critical](~weapons|assaultRifleCrit)}} This will require setting up some extra macros for damage, in this case on a character sheet called Weapons, which could be as simple as a single table roll. But it does mean you can do the attack roll, then see if it's a hit, crit or miss before you roll damage. Note that currently the only place to check for a crit is in the "Rolled" d100 roll. Also the two damage buttons down the bottom have some CSS styles applied, yours will look a bit different: There is a way to get criticals working with the "Successful Shot" rollable tables but... the post is probably long enough! And it might also mess up some other math.
Wow! Thank you so much. This is fantastic and taught me some new tricks.