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

[D&D 5e Roll20 Sheet] Help Creating Attack/Damage Templated Macro querying Sharpshooter?

1592534997

Edited 1592536136
Hi Folks!  I'm trying to create an ability in the attributes section of the D&D 5e Roll20 Character Sheet, with the intention that it will be a ranged attack utilizing "selected" attributes and querying if Sharpshooter is in play (-5 Attack for +10 Damage), all while staying within the confines of the Attack & Damage template for the sheet.  The problem is, that I have very little understanding of how much of this would be organized.  I'll lay out some of my thoughts below to show you where I'm at and hopefully you can provide me the pieces I'm missing to make this whole thing work. Before I get too far ahead, I'm also curious if I can add new attributes to that section of the sheet for my Templated Macro to call on, without messing up the sheet?  For example, I'd like to be able to add something that shows I have X fighting style (e.g. Fighting Style: Archery (grants +2 Bonus to Ranged Attack Rolls).  I'm a simple person and would probably just label the attribute something like "Fighting_Style" and place a number there, then apply that to relevant sections.  Later on I'm sure I can get more clever and complicated but if this works that would be super.  Similarly, I might like to add a weapon enhancement modifier (e.g. "RngWpn1Enh" for Ranged Weapon 1 Enhancement).   Speaking of that, how can I make sure that various sheet call outs occur for this macro?  By example, I'm interested in making sure that the ability would still obey the rules of the sheet as determined under settings, where if I want to set it up I can always query for Advantage/Disadvantage, Whisper my rolls, etc.  As well as check to see if there are any Global Modifiers that have been checked and should be applied to the attack or damage.  Is there a particular string I would need to include to make sure such settings were followed herein? In regards working in Sharpshooter, I'm uncertain.  I'll be putting down **Sharpshooter** to indicate I suspect the query would need to be put here or there and that it is asking if Sharpshooter is being used, and if so, it would automatically apply a -5 penalty to the attack roll, in exchange for a +10 modifier to the damage roll (which would not be multiplied on a crit). Assuming that all of the above can be done, my basic calculation without hardly any coding work would look something like this (the attack is using a D&D firearm from Critical Role called the Pepperbox, which critical fumbles / misfires on a roll of 2 or less on a d20 and critically hits on a 20):  @{selected|character_name|wtype}&{template:atkdmg} {{mod= {selected|pb} + {selected|dexterity_mod} + {selected|fighting_style} + {selected|RngWpn1Enh} - [?{Sharpshooter?|No,0|Yes,1} * 5]}} {{rname=Pepperbox}} {{r1=[[@{selected|character_name|d20}cf<2cs>20 + {selected|pb} + {selected|dexterity_mod} + {selected|fighting_style} + {selected|RngWpn1Enh} - [?{Sharpshooter?|No,0|Yes,1} * 5]]]}} {{attack=1}} {{range=80 ft. (320 ft.)}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d10 + {selected|dexterity_mod} + [?{Sharpshooter?|No,0|Yes,1} * 10]]]}} {{dmg1type=Piercing}} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d10[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}} {{spelllevel=}} {{innate=}} {{globalattack=@{selected|character_name|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{selected|character_name|global_damage_mod_type}}} ammo= @{selected|character_name|charname_output} Going through that whole thing, I'm sure there's a LOT that's missing to actually make this thing function correctly (though I'm also curious about things that can be deleted, such as anything referencing spells on a mundane attack). I'm also curious if I can somehow query whether or not Sharpshooters penalty & bonus is being applied once, and just have that come into play purely within this macro, or if I need to "nest" a macro within it?  Well, a macro or something. Thanks in advance to anyone that can help me out with this, I'm really running into a wall here.
1st thing to note, a custom attack macro will not apply any settings of the selected token's sheet (like don't auto roll damage, global damage modifiers, always roll, whisper roll, etc). Those only apply when a roll is being triggered that's on the sheet itself, in the correct section (a custom macro in the Attributes section, for example, will disregard everything selected on the sheet). If the character has the Archery fighting style, why would that not already be accounted for in a bonus on the attack rolls for each of the character's ranged weapons? What I do for Sharpshooter is to make a separate attack entry for it where I can put both the penalty to hit as well as the bonus to damage. You're a Pro subscriber, so maybe there is a solution to your problems with an API script, but I'm not familiar with those. You could look through that forum or ask there.
1592628628

Edited 1592629581
Oosh
Sheet Author
API Scripter
Speaking of that, how can I make sure that various sheet call outs occur for this macro?  By example, I'm interested in making sure that the ability would still obey the rules of the sheet as determined under settings, where if I want to set it up I can always query for Advantage/Disadvantage, Whisper my rolls, etc.  As well as check to see if there are any Global Modifiers that have been checked and should be applied to the attack or damage.  Is there a particular string I would need to include to make sure such settings were followed herein? You can reference these with the wtype and rtype Attributes. If you use selected, like in your example code, it will use the Attribute from the sheet linked to the selected token. I'm assuming this is a Player macro, just for you? I'd probably replace selected with your character name if you don't need to run it for other characters, just so it always runs properly without needing to click your token first. Before I get too far ahead, I'm also curious if I can add new attributes to that section of the sheet for my Templated Macro to call on, without messing up the sheet?  For example, I'd like to be able to add something that shows I have X fighting style (e.g. Fighting Style: Archery (grants +2 Bonus to Ranged Attack Rolls).  I'm a simple person and would probably just label the attribute something like "Fighting_Style" and place a number there, then apply that to relevant sections.  Later on I'm sure I can get more clever and complicated but if this works that would be super.  Similarly, I might like to add a weapon enhancement modifier (e.g. "RngWpn1Enh" for Ranged Weapon 1 Enhancement).  You can absolutely do this without messing up the sheet (provided you don't use an Attribute name in use by the sheet, obviously) but bear in mind these will not be referenced by automatically created macros, like with spells & weapons added with drag & drop. For a simple attack roll or damage bonus, using the inbuilt global fields is best. Sharpshooter is different as it modifies both fields, but Archery style should automatically add itself as a global mod. You can also put queries in the global fields, for example if you spend half your time using a bow you might want to query the Archery fighting style in the Global Attack Mod section, rather than constantly ticking & unticking it: ?{Archery?|Yes,2|No,0} If you did want to store some attack mods as custom Attributes (for example your RngWpn1Enh), as long as they output math you can then reference these instead. I'm not sure what it achieves, but you can do it: store the above code as an Attribute called ArcheryFS and change the global attack mod field to: @{ArcheryFS} The only time I've found this kind of thing useful is for messing around with custom attack roll mods with Advantage/Disadvantage. You must use the global attack mod field here, otherwise you'll get 2 different rolls added to each d20 die. As for the macro, I've just cleaned up the syntax and added [LABELS] but your math was all fine: @{bob|wtype} &{template:atkdmg} @{bob|rtype} cf<2 + @{bob|pb} + @{bob|dexterity_mod} - [[?{Sharpshooter?|No,0|Yes,1}*5]][SS] ]]}}{{mod=[[@{bob|pb}[PB] + @{bob|dexterity_mod}[DEX] - [[?{Sharpshooter?|No,0|Yes,1}*5]][SS]]]}} {{rname=Pepperbox}} {{r1=[[@{bob|d20}cf<2 + @{bob|pb} + @{bob|dexterity_mod} - ?{Sharpshooter?|No,0|Yes,1}*5[SS] ]]}} {{attack=1}} {{range=80 ft. (320 ft.)}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d10 + @{bob|dexterity_mod}[DEX] + [[?{Sharpshooter?|No,0|Yes,1}*10]][SS] ]] }}  {{dmg1type=Piercing}} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d10[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}} {{spelllevel=}} {{innate=}} {{globalattack=@{bob|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{bob|global_damage_mod_type}}} ammo= @{bob|charname_output} Just replace bob with your character name, or make a test character called bob.... I just get sick of having to select a token (and making sure it's the right PC/NPC type) when I'm testing macros. This is a template for auto-rolling damage. If you want the normal attack roll with the damage link the layout is a little different. I've bolded the rtype and wtype Attributes where they're referenced, as you were asking about this. Make sure you use these if you want the macros to follow your sheet settings, it will save having to go through and change them all later. Also, rtype is a weird one, more info at the top of this page .
Thank you both so much for replying, I was honestly feeling extremely frustrated with my inability to just understand what I needed to do, gah!  Especially want to thank you, @Oosh, for the detailed explanation and for providing the great examples that you did!  Using things like this allows me to save it to a word doc so I don't have to keep going back to the forums but can instead compile my own working wiki.