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

2024 Shilleagh damage formula help request

Is there an existing formula for me to insert into a macro that can calculate the new Shilleagh die?  Thank you!! :) The weapon begins with a d8 damage die. The weapon’s damage die changes when you reach levels 5 (d10), 11 (d12), and 17 (2d6)
1705101668

Edited 1705101713
There's probably a better way to do this, but you can create a weapon attack called 'Shillelagh' with this in the Damage field: [[1 * {0,17}<@{selected|level} ]]d[[8 + 2 * {5, 11}<@{selected|level} - 6 * {17,21}<@{selected|level}]] And if you want to check the math, you can select the character's token and run this macro: &{template:npcaction} {{rname=@{selected|token_name}}} {{name=Level @{selected|level}}} {{description=[[1 * {0,17}<@{selected|level} ]]d[[8 + 2 * {5, 11}<@{selected|level} - 6 * {17,21}<@{selected|level}]]}}
1705102582
Gauss
Forum Champion
Jarren said: There's probably a better way to do this, but you can create a weapon attack called 'Shillelagh' with this in the Damage field: [[1 * {0,17}<@{selected|level} ]]d[[8 + 2 * {5, 11}<@{selected|level} - 6 * {17,21}<@{selected|level}]] And if you want to check the math, you can select the character's token and run this macro: &{template:npcaction} {{rname=@{selected|token_name}}} {{name=Level @{selected|level}}} {{description=[[1 * {0,17}<@{selected|level} ]]d[[8 + 2 * {5, 11}<@{selected|level} - 6 * {17,21}<@{selected|level}]]}} I don't think there is a better way to do it, that was the approach I was taking, though yours is much cleaner than mine would have been. Nice job :)
Gauss said: I don't think there is a better way to do it, that was the approach I was taking, though yours is much cleaner than mine would have been. Nice job :) I just always assume RainbowEncoder will come along and post some bit of code that makes mine look like it was written on accident by 1,000 monkeys on typewriters. ;P
1705105943
Gauss
Forum Champion
Jarren said: Gauss said: I don't think there is a better way to do it, that was the approach I was taking, though yours is much cleaner than mine would have been. Nice job :) I just always assume RainbowEncoder will come along and post some bit of code that makes mine look like it was written on accident by 1,000 monkeys on typewriters. ;P Except nobody but RainbowEncoder will understand it. :D
Since I've been in other threads with you Barry and I know you use ScriptCards at least occasionally I am going to offer an alternative. While the macro Jarren posted is really cool, I just feel like I should mention that ScriptCards has conditionals and so for things you want to build with ScriptCards you have options like using a subroutine to get the dice to roll by level, like so: --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| So in a contrived example to illustrate it in action, here's a loop that passes in numbers to simulate levels: !script {{ --%level|1;19;3 -->GetshillelaghDice|[&level];SD --+Level [&level]|would roll [&SD] --%| --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| }} which looks like: Or a simple but more realistic type example: !script {{ --#sourceToken|@{selected|token_id} -->GetshillelaghDice|[*S:level];ShillelaghDice --=Damage|[&ShillelaghDice] --+Rolled [&ShillelaghDice]|for [$Damage] Damage at level [*S:level] --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| }} Just wanted to let you know that since you use ScriptCards in your games you don't have to rely on doing all the math in a single line in your macros even though Jarren's method above is pretty cool and I didn't think it was possible in that way. 
Jarren said: Gauss said: I don't think there is a better way to do it, that was the approach I was taking, though yours is much cleaner than mine would have been. Nice job :) I just always assume RainbowEncoder will come along and post some bit of code that makes mine look like it was written on accident by 1,000 monkeys on typewriters. ;P To be honest mine would be quite similar. Although I really should do a write up for sequence encoding since it's not currently documented. 
Thank you EVERYONE!  Barry
Joshua N. said: Since I've been in other threads with you Barry and I know you use ScriptCards at least occasionally I am going to offer an alternative. While the macro Jarren posted is really cool, I just feel like I should mention that ScriptCards has conditionals and so for things you want to build with ScriptCards you have options like using a subroutine to get the dice to roll by level, like so: --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| So in a contrived example to illustrate it in action, here's a loop that passes in numbers to simulate levels: !script {{ --%level|1;19;3 -->GetshillelaghDice|[&level];SD --+Level [&level]|would roll [&SD] --%| --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| }} which looks like: Or a simple but more realistic type example: !script {{ --#sourceToken|@{selected|token_id} -->GetshillelaghDice|[*S:level];ShillelaghDice --=Damage|[&ShillelaghDice] --+Rolled [&ShillelaghDice]|for [$Damage] Damage at level [*S:level] --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| }} Just wanted to let you know that since you use ScriptCards in your games you don't have to rely on doing all the math in a single line in your macros even though Jarren's method above is pretty cool and I didn't think it was possible in that way.  Joshua, I am wishing to use your last solution and also add the variable [ &DamageAbilityMod] to the dice roll, and auto apply damage on a hit. The first request I am not sure where to insert the variable and the last request I have copied/pasted code from another !Script at the end, but its not working... Would you be able to take a look at this?  !script {{     --#title|Shilleagh attack     --#rightsub|Range : 5 feet     --#sourceToken|@{selected|token_id}     --#targetToken|@{target|token_id}     --/|VARIABLES TO SET     --&TargetACAttribute|AC     --&DamageAbilityMod|wisdom_mod     --&SpellAttackBonus|spell_attack_bonus     --&AutoApplyDamage|true     --&HPBar|1     --=Atk|?{Attack|Standard,1d20|Advantage,2d20kh1|Standard,1d20|Disadvantage,2d20kl1} + [*S:[&SpellAttackBonus]] [Ability + pb]      --/|Output the static Atk roll variable with the target's AC value     --+Attack|[$Atk] vs AC [*T:[&TargetACAttribute]] --#sourceToken|@{selected|token_id} -->GetshillelaghDice|[*S:level];ShillelaghDice --=Damage|[&ShillelaghDice] --+Rolled [&ShillelaghDice]|for [$Damage] ``force`` Damage at level [*S:level] --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet     --&[%2%]|1d8     --?[%1%] -lt 5|<     --&[%2%]|1d10     --?[%1%] -lt 11|<     --&[%2%]|1d12     --?[%1%] -lt 17|<     --&[%2%]|2d6 --?"[&AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&HPBar]_value:-=[$Damage] --<| }}
So I think this is what you are going for: !script {{ --/|VARIABLES TO SET --&TargetACAttribute|AC --&DamageAbilityMod|wisdom_mod --&SpellAttackBonus|spell_attack_bonus --&AutoApplyDamage|true --&HPBar|1 --#title|Shilleagh attack --#rightsub|Range : 5 feet --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --=Atk|?{Attack|Standard,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} + [*S:[&SpellAttackBonus]] [Ability + pb] --/|Output the static Atk roll variable with the target's AC value --+Attack|[$Atk] vs AC [*T:[&TargetACAttribute]] --/|Do not roll damage on a miss --?[$Atk] -lt [*T:[&TargetACAttribute]]|Done -->GetshillelaghDice|[*S:level];ShillelaghDice --=Damage|[&ShillelaghDice] + [*S:[&DamageAbilityMod]] [MOD] --+Rolled [&ShillelaghDice]|for [$Damage] ``force`` Damage at level [*S:level] --?"[&AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&HPBar]_value:-=[$Damage] --:Done| --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| }} So if you want to add the wisdom_mod to the damage roll, you can add it to the Roll variable similar to how you add  [*S:[&SpellAttackBonus]] to the Atk Roll variable. So  --=Damage|[&ShillelaghDice] + [*S:[&DamageAbilityMod]] [MOD] will add the wisdom_mod of the selected source token to the damage roll.  Then for the auto-apply damage, you would want that in the main section of the scriptcard above the --X since the  GetshillelaghDice gosub will just set the String variable  ShillelaghDice and return to the main script so that the Damage roll can be made. I made a couple other tweaks. I removed one of the Standard options in the Atk query since there were 2. I also removed a redundant --#sourceToken line since there were 2. But the main change was adding a conditional to not roll damage if the Atk roll was less than the target's AC otherwise the auto-apply damage would take place regardless. One thing you might want to confirm in your game is to make sure the AC attribute is what you want to check since for the D&D 5e sheet by Roll20 NPCs have both an AC which seems unused and npc_ac which is used. For example: &{template:default} {{name=@{selected|character_name}}} {{AC=@{selected|AC}}} {{NPC AC=@{selected|npc_ac}}} Just something to confirm in your game but that ScriptCard there should do the attack roll and if the atk roll is higher than the target's AC attribute, roll damage and apply it to the target's bar1. You might also want to check on some  examples of ScriptCards attacks  that will also check for natural 1's and natural 20's for critical misses and critical hits. Just some possible enhancements you can add to your ScriptCards.
Thank you for all of your help! You are appreciated :))
I plan to look though the link you gave me. Thank you once again Joshua! Since you brought it up... I've been manually changing ac on the npcs journals to the correct number, but would love the time saving technique you suggested. How do I apply:  &{template:default} {{name=@{selected|character_name}}} {{AC=@{selected|AC}}} {{NPC AC=@{selected|npc_ac}}} to the above script?  Lastly, my end goal is for the script to detect 1s and 20s and on natural rolls (such as the use of cf<1cs>20), and on a 20, apply regular damage plus max dice damage. I'll try to figure out how to do that, unless you MIGHT have the time to help with that LAST request.... :) Thanks again
So here is one option you can use: !script {{ --/|VARIABLES TO SET --&TargetACAttribute|npc_ac --&DamageAbilityMod|wisdom_mod --&SpellAttackBonus|spell_attack_bonus --&AutoApplyDamage|true --&HPBar|1 --#title|Shilleagh attack --#rightsub|Range : 5 feet --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --=Atk|?{Attack|Standard,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} + [*S:[&SpellAttackBonus]] [Ability + pb] --/|Output the static Atk roll variable with the target's AC value --+Attack|[$Atk] vs AC [*T:[&TargetACAttribute]] --/|Do not roll damage on a natural 1 or if the attack roll is less than the target's ac --?[$Atk.Base] -eq 1 -or [$Atk] -lt [*T:[&TargetACAttribute]]|Done -->GetshillelaghDice|[*S:level];ShillelaghDice --?[$Atk.Base] -eq 20|[ --=Damage|[&ShillelaghDice] + [*S:[&DamageAbilityMod]] [MOD] --=CritDmg|[&ShillelaghDice(replace,d,m)] --=TotalDmg|[$Damage] + [$CritDmg] [CRIT] --+CRITICAL HIT|[$Damage] + [$CritDmg] for [$TotalDmg] total ``force`` damage --]|[ --=TotalDamage|[&ShillelaghDice] + [*S:[&DamageAbilityMod]] [MOD] --+Rolled [&ShillelaghDice]|for [$TotalDamage] ``force`` Damage at level [*S:level] --]| --?"[&AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&HPBar]_value:-=[$TotalDamage] --:Done| --X| --:GetshillelaghDice|CharacterLevel;StringVariableToSet --&[%2%]|1d8 --?[%1%] -lt 5|< --&[%2%]|1d10 --?[%1%] -lt 11|< --&[%2%]|1d12 --?[%1%] -lt 17|< --&[%2%]|2d6 --<| }} So  ScriptCards Roll Modifiers  can be used to check for lots of things in the roll including what the roll was before any additional modifiers with .Base. So changing the target AC check to also check for natural 1's could go like this: --?[$Atk.Base] -eq 1 -or [$Atk] -lt [*T:[&TargetACAttribute]]|Done That line will check if the Base of the Atk roll variable is a 1 and if so then jump to the Done label of the script. If the Base of the Atk roll variable is not a 1 then it will compare the total of the Atk roll variable to the target's armor class attribute set at the top of the scriptcard. The .Base roll modifier can also be used to check for natural 20's. So: --?[$Atk.Base] -eq 20|[ --=Damage|[&ShillelaghDice] + [*S:[&DamageAbilityMod]] [MOD] --=CritDmg|[&ShillelaghDice(replace,d,m)] --=TotalDmg|[$Damage] + [$CritDmg] [CRIT] --+CRITICAL HIT|[$Damage] + [$CritDmg] for [$TotalDmg] total ``force`` damage --]|[ --=TotalDamage|[&ShillelaghDice] + [*S:[&DamageAbilityMod]] [MOD] --+Rolled [&ShillelaghDice]|for [$TotalDamage] ``force`` Damage at level [*S:level] --]| If the Atk roll modifier's base roll was a 20, it will roll damage as normal but also roll CritDmg. --=CritDmg|[&ShillelaghDice(replace,d,m)] That line will take the returned String variable set, which for example is 1d10 and replace the d with an m. So the CritDmg roll variable line would look like: --CritDmg|1m10 As per the wiki, roll variables can use an m to roll max XmY 3m8 Roll a Y-sided die X times, but always use this highest number on the die. Ex: 3m8 will always roll 24. If the Atk roll was not a natural 20, then roll damage as before. As for the npc_ac, the easiest thing to do is to change the TargetAC variable at the top of the script: --&TargetACAttribute|npc_ac If this ScriptCard is meant for a PC or PCs attacking NPCs and your game is using the D&D 5e sheet by Roll20, then that's pretty much the easiest thing to do. If you want the ScriptCard to be more versatile, you can check if the Target is an npc. Again using attributes for the D&D 5e sheet by Roll20, that can be done with something like: --?[*T:npc] -eq 1|JumpToNPCSection|JumpToPCSection Where that would look at the target for an attribute named npc and check if it is set to 1, if so then jump to the label JumpToNPCSection and if the target doesn't have an attribute npc equal to 1, then jump to the label JumpToPCSection. Or in this case you could set a variable: --?[*T:npc] -eq 1|&TargetACAttribute;npc_ac|&TargetACAttribute;ac --/|Output the static Atk roll variable with the target's AC value --+Attack|[$Atk] vs AC [*T:[&TargetACAttribute]] That would check if the target had an attribute named npc equal to 1, which for D&D 5e sheets by Roll20 is the case and set the String variable TargetACAttribute to npc_ac and if the target does not have an attribute named npc equal to 1, then it will set the String variable TargetACAttribute to ac. This is done before the comparison of the attack roll to the target's armor class.
Joshua, I've worked to set up the following Longsword attack to duplicate the critical hit damage method you have in the Shilleagh macro, but I don't see how to set it up yet. When you have a moment - How do I set that up in the following Longsword attack in place of the current one? !scriptcard  {{   --#title|Longsword   --#leftsub|Melee Attack   --#sourceToken|@{selected|token_id}   --#targetToken|@{target|token_id}   --#emoteText|@{selected|token_name} attacks @{target|token_name}   --=TargetAC|@{target|npc_ac}   --?[$TargetAC.Total] -gt 0|DoneWithAC   --=TargetAC|@{target|ac}   --:DoneWithAC|   --=AttackRoll|1d20 + @{selected|strength_mod} [STR] + @{selected|pb} [PROF]   --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC [$TargetAC].   --?[$AttackRoll.Base] -eq 20|Crit   --?[$AttackRoll.Base] -eq 1|Fumble   --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit   --+Miss|The attack missed.   --^Final|     --:Fumble|   --+Fumble!|The attack went horribly wrong.   --^Final|     --:Hit|   --=Damage|1d8 + @{selected|strength_mod} [STR]   --+Hit!|The attack hit @{target|token_name} for [$Damage] ``slashing`` damage.   --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Damage]   --^Final|     --:Crit|   --=Damage|1d8 + @{selected|strength_mod} [STR] + 8d1 [CRIT]   --+Critical Hit!|The attack hit @{target|token_name} for [$Damage] ``slashing`` damage.   --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Damage]     --:Final| }}
So in the damage roll in the Crit section it has this: --:Crit| --=Damage|1d8 + @{selected|strength_mod} [STR] + 8d1 [CRIT] So that has 8d1 as the Crit damage for 1d8 which is another way of doing max damage if you know the weapon die size. Note that the longsword ScriptCard you pasted uses the AlterBars Mod  to change the HP on the target token. You probably want to update that to use ScriptCards object modification directly like you have in the other ScriptCard unless you already have AlterBars installed in your game. 
But how do I get the Longsword !Script above to produce a critical like this: Thank you SO much
You could alter the Crit label to look something like the critical section of the other scriptcard. Something like: --:Crit| --=Damage|1d8 + @{selected|strength_mod} [STR] --=CritDmg|1m8 [CRIT] --=TotalDmg|[$Damage] + [$CritDmg] [CRIT] --+CRITICAL HIT|[$Damage] + [$CritDmg] for [$TotalDmg] total ``slashing`` damage --@alter|_target|@{target|token_id} _bar|1 _amount|-[$TotalDmg] It breaks things apart in a similar way as the other ScriptCard so you can see the Damage, CritDmg, and TotalDmg rolls individually there in the --+ output line. 1d8 plus strength_mod and then max damage for the crit.
Thank you Joshua. :))