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 .
Advertisement Create a free account Compendium in Game, Join Today

Macro Help: Percent damage (D&D 5e)

1600215815
Jeean
Plus
Not savvy with writing macros but I know it can't be too hard to get one that helps me deal a percentage of a player's MAX HP.  (ex: select player token -> click macro -> input 1dX (1d20 for example) -> result of 15 deals 15% of selected tokens MAX HP [output calculated number]) I'm not sure if the 'hp' attribute in their sheet can be used for max HP as their health declines. I need the value for their maximum hit points, multiplied by the dice roll as a percentage (decimal), then the result output to chat.    Maybe something like this? /roll 1d?/100*(selected|maxhp) 
1600216823
You're pretty close: you need @{selected|hp|max}. /roll round(1d20/100*@{selected|hp|max}) I added the round function so that you would get an integer result. If you want a variable dice size you could use one of these: /roll round(1d?{Dice Size}/100*@{selected|hp|max}) /roll round(1d?{Dice Size|4|6|8|10|12|20}/100*@{selected|hp|max}) The 'hp' attribute is the current hp of the token. So that could be used as well if desired.
1600217693
Jeean
Plus
Fantastic! You're my hero I'm so excited to hit my players for 75% of their max HP >:)  Can this also be used with the 'floor' command ? I don't want my players taking 1% of their 1d100 damage  ex: 1d100 with a floor of 25% = 25-100% of their max hp  or 1d20 with a floor of 10 = 10-20% of their max hp Ideally the popup would ask for min and max range? This sounds like a much bigger ask... /roll round(1d?{Min|? - Max|?}/100*@{selected|hp|max})
1600225001

Edited 1600225561
You can do something like this: /w gm &{template:default} {{name=Attack on @{target|t1|token_name}, @{target|t1|hp|max} health pool}} [[ floor([[ {[[1d?{Max damage|100%,100|75%,75|50%,50|25%,25}]],?{Minimum|10%,10|25%,25}}kh1 ]]/100*@{target|t1|hp|max}) ]] {{Initial Roll = $[[0]]%}} {{Adjusted Roll = $[[1]]%}} {{Damage = $[[2]]HP}} This changes it to a @{target} call so you don't have to remember to select the right token before you run it (you'd probably have an NPC selected if you're rolling their damage). Note the two different ways of doing minimum and maximum - the max is as you had it, it changes the actual roll so that you still have an even spread of damage - 1d75 / 100 has an even chance of doing anywhere from 1% - 75% damage. The keep highest 1 operator is instead bumping the roll up to 10% if it's below 10. So you'd have a higher chance of getting hit for 10% damage than anything else: rolls from 1-10% all do 10%, rolls from 11%-75% do what they say. I thought I'd do that to see which one you wanted to use - but you probably want them to match. For a flat distribution (like the max you currently have) the math for a 10% minimum & 75% maximum makes it something like 1d(75 - 10) + 10 or 1d(?{Max} - ?{Min}) + ?{Min} This rolls 1d65 and gives an even spread of 10%-75% rolls. Figured I'd give you the option though, since maybe you want to leave the full 1d100 roll in, making your maximum cap much more likely to be hit - if you set it at 50% on a 1d100 roll, for example, a player has a 50% chance of taking 50% damage, making damage less swingy. It entirely depends on how you want it to work, and what the HP pools are like. 5e tends to favour more predictable damage, other games not so much. Edit - also changed from round to floor, I just realised. 5e habit, you may prefer Round
1600225873
Jeean said: Fantastic! You're my hero I'm so excited to hit my players for 75% of their max HP >:)  Can this also be used with the 'floor' command ? I don't want my players taking 1% of their 1d100 damage  ex: 1d100 with a floor of 25% = 25-100% of their max hp  or 1d20 with a floor of 10 = 10-20% of their max hp Ideally the popup would ask for min and max range? This sounds like a much bigger ask... /roll round(1d?{Min|? - Max|?}/100*@{selected|hp|max}) Also just to clarify - the 'floor' command simply means that the roll will always round down, and the 'ceil' command always rounds up.   E.g. a result of 23. 4 will 'round' down to 23, 'floor' to 23, and 'ceil' to 24. But a result of 23. 6 will 'round' up to 24, 'floor' to 23, and 'ceil' to 24.  Oosh is the macro master!  
1600230629
Jeean
Plus
I was cruising around the google trying to educate myself and maybe solve the extra work myself - then BAM here it is for free ; ;  I'm so grateful! Now I can run some West March missions with a wide swing in level ranges (5-18) and punish them all equally.  5 max hp? you're hit for 75% = 4  150 max hp? you're also hit for 75% = 113 Incredible and you guys are so helpful - thank you very much! I hope other DMs can enjoy destroying their players with scaling math >:)