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

How do I make a basic attack macro which checks for a hit?

Ok so essentially, I want to know how to make a basic attack macro. I can't figure out if there's any sort of "if" statements, or if there's a way to make one. Basically in my ruleset, attacking works thusly: Roll for attack on targeted enemy (easy part) Attack roll is calculated as /roll d20 + @{melee} If the attack roll is higher than {target|AC}, then I want it to roll damage dice If the attack roll is 8+ higher than {target|AC}, then I want it to roll 2 damage dice How do I make the if statements? Can i make them depend on target ac?
1515543507
vÍnce
Pro
Sheet Author
Macros do not have have a conditional component.  There was a suggestion  If / Then / else capability or at least score checking but it looks like it's been rejected for now. ;-( Might just post everything and ignore the damage that doesn't apply... &{template:default} {{name=Attack}} {{Attack Roll=[[ 1d20 + @{selected|melee} ]] }} {{vs AC=[[ @{target|AC} ]] }} {{Normal Damage=[[ 1d6 ]] }} {{vs AC+8=[[ @{target|AC}+8 ]] }} {{Double Damage=[[ 2d6 ]] }}
Thanks Vince! That's exactly what I need. If it's not too much trouble, would you mind walking me through what each part of the syntax does? I may want to tinker later haha.
1515548977

Edited 1515549048
vÍnce
Pro
Sheet Author
No problem; &{template:default} For this macro I used roll20's default  roll template . Most sheet's have there own roll templates which define how rolls will be handled (including a limited set of logic) as well as the look/layout of the output to chat. The "default" template is available to everyone regardless of the sheet.  {{name=Attack}} Roll templates use a simple {{property=value}} syntax.  this just says use "Attack" in the header of the output.   {{Attack Roll=[[ 1d20 + @{selected|melee} ]] }} Make a new line called "Attack Roll" and perform an inline roll.  [[ do stuff ]] The "selected|" portion states that the macro needs to pull the named attribute value from the selected token.  This would only work for linked tokens.(token is linked to a sheet)    {{vs AC=[[ @{target|AC} ]] }} new line called "vs AC" and pull a target's AC attribute.  You'll have to pick a target token.  Again, this assumes the token is linked to a sheet.  You could pull a value from a token's bar as well if you don't link monster's/npcs to sheets. ie [[ @{target|bar1} ]] {{Normal Damage=[[ 1d6 ]] }} new line called "Normal Damage" and make in inline roll of "1d6".  Of course this could be any amount... {{vs AC+8=[[ @{target|AC}+8 ]] }} new line called "vs AC+8" make an inline roll and pull the AC value of a target token, adding 8 to it.  This sets the double damage target number. {{Double Damage=[[ 2d6 ]] }} new line called "Double Damage" and make the double damage inline roll. This is a basic macro.  It could be made more flexible or complex as needed. ie You could add a query for damage instead of just using [[1d6 ]] example; [[ ?{Number of dice?|1}d?{Sides?|1} + ?{Modifier?|0} ]] Hope this helps.  Cheers
1515555579

Edited 1515555821
Thanks a bunch! I'll be able to implement this for some spells as well now. Also, how do I issue commands in chat? I tried typing #melee for example, but it just goes into chat as plaintext.
1515558399
vÍnce
Pro
Sheet Author
If you created a macro from the sidebar|collection tab and named it "melee", you should be able to type "#melee" in chat and hit enter/return. Entering "#" in chat will bring up a selectable list of your saved macros. If you are trying to call an attribute, all you need is the "@{ attribute name }"  If it's a sheet roll button try %{ button's name } often determined by hovering over a button on a sheet. The  help wiki has info on various commands and dice/roll functions used in chat. How to Roll Dice 3D Dice Dice Reference Macros Text Chat
thanks!