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

[Macro] Show image on critical hit

Hello! I have successfully created a macro that shows a random gif from a list of tinyURLs I've made when I attack. Now I would like to show it only when my character lands a critical hit. I've been messing around for a long time but I can't think if there are any clever ways to wrangle roll20 code to only show images or perform macros when a critical success is achieved. The workaround is of course to have a separate macro that I use when I roll a critical success, but that's not very fun.
1589333132
GiGs
Pro
Sheet Author
API Scripter
Your workaround is the only way to do this. Roll20 dice macros cant show different content on a critical hit or other conditional circumstances. Character sheets can sometimes show stuff conditionally, but they are using tricks only available to the character sheet design code. Likewise you can do it with the API (a pro subscriber feature). But the macros available at the free level cant do this.
1589357359
Oosh
Sheet Author
API Scripter
Which character sheet are you using? I'm only familiar with 5e, but it has different damage rolls for crits and non-crits. So you can't (AFAIK) get it to display an image when the 20 lands, but you can get it to display the image when you click on the attack roll to roll damage. Is something like this what you're talking about? This image displays only when critical damage is rolled, not standard damage.
andrew p. said: Which character sheet are you using? I'm only familiar with 5e, but it has different damage rolls for crits and non-crits. So you can't (AFAIK) get it to display an image when the 20 lands, but you can get it to display the image when you click on the attack roll to roll damage. Is something like this what you're talking about? This image displays only when critical damage is rolled, not standard damage. Haha well I just responded to your other thread without realizing it was you. I'm using 5e character sheets I think (not my campaign). Yes that seems to be precisely what I'm looking to do. I'm not sure how to write code that says "if crit then start damage die macro which happens to have an image in it too"
1589960787
GiGs
Pro
Sheet Author
API Scripter
You cant get roll20 to do anything on a conditional (like when a crit lands). All you you can do is output something every time. Andrew was suggesting having a button that the players can click - that launches a macro to roll damage, or roll a critical hit, or whatever. And you include the gif with that macro. 
1589961418

Edited 1589961430
Ziechael
Forum Champion
Sheet Author
API Scripter
If it is a sheet using a template (like the 5e OGL sheet) then you can do this by inserting the desired image in the crit output for an attack. It will require a set of macros for each weapon based on the standard ones but edited and added as abilities on the sheet. I talk about it a bit in this post , but hopefully in all that you can see how you can point an attack to a bespoke crit output which could contain your image as per the attack.
I am using the 5e OGL sheet I have found out. :) You are my idol, I will sift through all the code and try to pick apart things and see if I can't understand them eventually.
1589963795
Ziechael
Forum Champion
Sheet Author
API Scripter
It's a lot to sift through, for your example though you can ignore all the html replaced stuff and query complexity. All you'll need to take from it is how to call a specific bespoke version of a weapons attack without using the sheet (which you already know if you've got an image into the attack output), then from that how to modify it to make a bespoke call to the crit output (you should be ok to leave the damage one as default). Then all you need is that bespoke crit output (effectively a carbon copy of the sheet one but with your image inserted) as an ability. Bosh... job done, smiles all round... just the interminable wait for a crit to occur naturally! (Please note this is theoretical as I haven't tested it but can't see a reason why it wouldn't work lol)
1589976470

Edited 1589976570
Oosh
Sheet Author
API Scripter
If it saves you a bit of time, here is an Eldritch Blast attack taken straight from the character sheet. Presumably you've figured this out already, but just in case you haven't: to pinch a premade macro from the sheet, click on your attack from the Attacks & Spellcasting section of the character sheet to roll the attack, then click your cursor into the chat bar then push the UP arrow on the keyboard. It'll pull all the macro text up so you can CTRL-A select all, then copy/paste it into Notepad or somewhere for easier editing. The macro: @{Bob|wtype}&{template:atk} {{mod=+8}} {{rname=[Eldritch Blast](~-M0VCruGHgPSwql3Zu-Q|repeating_attack_-M0KUP7ddx64Jw5aPWcJ_attack_dmg)}} {{rnamec=[Eldritch Blast](~-M0VCruGHgPSwql3Zu-Q|repeating_attack_-M0KUP7ddx64Jw5aPWcJ_attack_crit)}} {{r1=[[@{Bob|d20} + 5[CHA] + 3[PROF]]]}} @{Bob|rtype} + 5[CHA] + 3[PROF]]]}} {{range=120 feet}} {{desc=}} {{spelllevel=cantrip}} {{innate=}} {{globalattack=@{Bob|global_attack_mod}}} @{Bob|charname_output} Basically all you need to do is point {{rname}} (normal damage roll) or {{rnamec}} (critical damage roll) to your own damage macros, exactly like Ziechael's macro he linked. And you can also change those long strings to your character name, in this example Bob, or just get rid of it if all the macros are on the same sheet. So you would have something simple like {{ rnamec=[Eldritch Blast](~EBCrit) }} . We then need an Ability macro (on the character sheet, not in the collection) called EBCrit, since we've pointed the attack roll to it. From memory, easiest way to pinch a linked damage macro from the chat bar, is click the cog on (in this example) Eldritch Blast in the Attacks & Spellcasting section from before, untick the "Attack" box so it just outputs a damage template, then you should be able to copy the code out. Trying to do it from Attack roll macro >> linked damage roll will probably just get you the repeating field name. So the damage macro will look something like this: @{Bob|wtype}&{template:dmg} {{rname=Eldritch Blast AC}} 0 {{range=120 feet}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d10]]}} {{dmg1type=Force}} 0 {{dmg2=[[0]]}} {{dmg2type=}} 0 {{desc=}}   {{spelllevel=cantrip}} {{innate=}} {{globaldamage=[[0]]}} {{globaldamagetype=@{Bob|global_damage_mod_type}}} ammo= @{Bob|charname_output} The {{ desc= }} section is where you probably want your GIF. If it's an infinite loop GIF, your work is done. If it's a finite number of loops and stops, you will probably want to use that trick from the other thread you posted in to get it to animate when it's posted again (because of course you're going to roll 2 crits in a row if it isn't set up to refresh the animation). Hope this helps! I found pinching the macros from the chat bar was the easiest way to figure stuff out. Also this page is handy for template properties. Speaking of pinching macros, Ziechael's sneaky booming blade creation surely has bits I require...
You guys have really helped me out so much!!!! I'm well on my way with a lot of new tips in my pocket, thank you very much. I've hit a hiccup and I'm curious how you guys deal with it... The 5e atk template automatically rolls two attack die, and the problem is that either of these trigger the crit condition. If I'm rolling without advantage and using my left attack die roll but my second roll is a crit, the crit damage is displayed instead of normal. My workaround would be to nullify the right die completely (make it empty or a 1 always) and to use a query for advantage on the left die. Here's my main attack so far: ! ?{Advantage|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} @{Fraug Ustor Belltoller|wtype}&amp;{template:atk} {{mod=+6}} {{rname=[Bellhammer](~-M7ABuNAJdIj-YbaaLUh|repeating_attack_-M7ktX-lKYhQnIG3iEYv|belldamage)}} {{rnamec=[Bellhammer (c](~-M7ABuNAJdIj-YbaaLUh|repeating_attack_-M7ktX-lKYhQnIG3iEYv|bellcrit)}} {{r1= [[?{Advantage}cs&gt;20 + 6]] }} @{Fraug Ustor Belltoller|rtype}cs&gt;21]]}} {{range=}} {{desc=}} {{spelllevel=}} {{innate=}} {{globalattack=@{Fraug Ustor Belltoller|global_attack_mod}}} ammo= @{Fraug Ustor Belltoller|charname_output} This works swimmingly. I've set the crit on the right atk to 21 so it doesn't proc crit damage but I'm still left with an ugly useless number @{Fraug Ustor Belltoller|rtype}cs&gt;21]]}} I actually found a way to add a little icon in it's place, that's by removing the above line and replacing it with {{r2=%{Fraug Ustor Belltoller|atk2img} }} with atk2img being this ability [[ [img](<a href="https://i.imgur.com/DjMdc34.png" rel="nofollow">https://i.imgur.com/DjMdc34.png</a>) This unfortunately breaks the script and removes the clickable attack name which bring up the resulting damage rolls. Is there any way to edit the second attack roll contents without breaking the script?
Also thanks to the template properties page you posted Andrew, I can actually read Ziechael's trickiness and I'm planning on using this workaround for 1st slot smite, 2nd slot smite, etc and critical smite. Also I think it's probably time I copied my character sheet from DND Beyond over so I don't have to update code when I level up haha.
1590026246
Oosh
Sheet Author
API Scripter
OK, so it looks like you're using both @{rtype} and {{r2=}} ... there's a description of what @{rtype} does on the templates wiki page. If you'd like to use query for advantage on your rolls (looks like you do since you put your own query at the top), you can set this on your character sheet settings page. Personally I always use advantage query as a player, I hate seeing a nat 20 come up on the right when I don't have advantage (irrational, I know). If you do this, @{rtype} will essentially do that advantage query automatically for you on all d20 rolls, followed by {{r2=xd20 If you'd prefer to use the {{r2=}} field instead of the automated @{rtype}, it needs to be a rollable number for certain other fields to display properly. I'm unsure if it would work or not, but you can try: {{r2=[[1d0 + [img](image link)]]}} or the rtype version would be: @{Fraug Ustor Belltoller|rtype} + [img](image link)]]}} Note that the {rtype} version will only display the r2 roll if you have advantage/disadvantage/always roll advantage set on your character sheet - a normal roll will just do the r1 field. {@rtype} confused the hell out of me at first! You can actually find the string on your character's Attributes page if you're ever confused about exactly what it's doing to your macros.
I'm happy to say I've cracked it and got everything working as intended. I may even have a little trick for you guys to use! So the baked in advantage query is cooler than mine, it's nice to show both rolls to the whole party. I'm still proud I got an advantage roll query nested into a roll template that I didn't know existed 24hrs ago on my own. I've now got two macros (to cut down on query clicking) one for standard attack and one for GWM attacks. These both branch depending on a critical, and also query you at the damage stage if you want to apply smite damage at varying spell slots. Here's the standard attack: @{Fraug Ustor Belltoller|wtype}&amp;{template:atk} {{mod=+7}} {{rname=[Bellhammer](~-M7ABuNAJdIj-YbaaLUh|repeating_attack_-M7ktX-lKYhQnIG3iEYv|belldamage)}} {{rnamec=[Bellhammer (Critical!)](~-M7ABuNAJdIj-YbaaLUh|repeating_attack_-M7ktX-lKYhQnIG3iEYv|bellcrit)}} {{r1=[[@{Fraug Ustor Belltoller|d20}cs&gt;20 + @{Fraug Ustor Belltoller|strength_mod}[STR] + 1[MOD] + @{Fraug Ustor Belltoller|pb}[PROF]]]}} @{Fraug Ustor Belltoller|rtype}cs&gt;20 + @{Fraug Ustor Belltoller|strength_mod}[STR] + 1[MOD] + @{Fraug Ustor Belltoller|pb}[PROF]]]}} {{range= [img](<a href="https://i.imgur.com/zBp2PFM.png" rel="nofollow">https://i.imgur.com/zBp2PFM.png</a>) }} {{desc=}} {{spelllevel=}} {{innate=}} {{globalattack=@{Fraug Ustor Belltoller|global_attack_mod}}} ammo= @{Fraug Ustor Belltoller|charname_output} where belldamage gives us this: (ro&lt;2 for GWF) &amp;{template:dmg} {{range=}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[2d8ro&lt;2 +3]]}} {{dmg1type=bludgeoning }} {{damage=1?{Smite?|None,&amp;#125;&amp;#125; {{charname=&amp;#125;&amp;#125; {{saveattr=&amp;#125;&amp;#125;|1st,&amp;#125;&amp;#125; {{dmg2flag=1&amp;#125;&amp;#125; {{dmg2=[[2d8]]&amp;#125;&amp;#125; {{dmg2type=radiant (lvl 1)&amp;#125;&amp;#125; {{charname=&amp;#125;&amp;#125; {{saveattr=&amp;#125;&amp;#125;|2nd,&amp;#125;&amp;#125; {{dmg2flag=1&amp;#125;&amp;#125; {{dmg2=[[3d8]]&amp;#125;&amp;#125; {{dmg2type=radiant (lvl 2)&amp;#125;&amp;#125; {{charname=&amp;#125;&amp;#125; {{saveattr=&amp;#125;&amp;#125;} and bellcrit gives us &amp;{template:dmg} {{range=}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[4d8ro&lt;2 +3]]}} {{dmg1type=bludgeoning }} {{damage=1?{Smite?|None,&amp;#125;&amp;#125; {{charname=&amp;#125;&amp;#125; {{saveattr=&amp;#125;&amp;#125;|1st,&amp;#125;&amp;#125; {{dmg2flag=1&amp;#125;&amp;#125; {{dmg2=[[4d8]]&amp;#125;&amp;#125; {{dmg2type=radiant (lvl 1)&amp;#125;&amp;#125; {{charname=&amp;#125;&amp;#125; {{saveattr=&amp;#125;&amp;#125;|2nd,&amp;#125;&amp;#125; {{dmg2flag=1&amp;#125;&amp;#125; {{dmg2=[[6d8]]&amp;#125;&amp;#125; {{dmg2type=radiant (lvl 2)&amp;#125;&amp;#125; {{charname=&amp;#125;&amp;#125; {{saveattr=&amp;#125;&amp;#125;} {{desc=[[ [img](<a href="https://tinyurl.com/epicpooper[[" rel="nofollow">https://tinyurl.com/epicpooper[[</a> 1d9 ]]#.gif)}} resulting in something that looks like this (random gif from a set of 9) The trick I was talking about is adding in a weapon image into {{range=}}. Seems to position it perfectly, a good spot for a long rectangular image. Couldn't done it without you guys, I now understand about 96% of what I'm doing here. Thank you so much for all your help!
1590053319
Ziechael
Forum Champion
Sheet Author
API Scripter
And so the student has become the master... we have nothing left to teach you young padawan. Looks great too, by the way, makes the crits that little bit more special :D
1590059376
Oosh
Sheet Author
API Scripter
Crikey, that thing hits like a bus! That {{range}} pic is a great idea, too.
1590073870
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You should post this in the&nbsp; Stupid Tricks &nbsp;thread.
Crikey, that thing hits like a bus! It's a +1 Maul except 2d8 instead of 2d6. It comes with the flaw that it can be heard miles away and must be wielded by a half-giant or larger. The radiant damage is just from the "Smite?" query (which also benefits from doubled damage die on a crit, so +6d8 @ lvl 2 spell slot) Thanks again guys. Will do, Keith!