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

Rolling a variable number of times

For GURPS, I'm wanting to make a macro that will handle everything about an attack. I'm able to make a formula that can calculate the number of hits (like with an automatic weapon), but I want to calculate damage as well without requiring any math on the player's part. Let's say I fire an automatic weapon and land 3 hits, and each hit does 2d6 - 2 damage. I could simply do 3 * (2d6 + 2), but this would result in very "swingy" damage numbers because I'm only rolling two dice. What I want is to roll 2d6 - 2 three times, or roll 6 dice altogether and add 6 so I'd get more of a bell curve. How would I go about this? How do I roll something a variable number of times?
1424986670
Diana P
Pro
Sheet Author
How about [[(?{number of hits?|1}*2)d6+(?{number of hits?|1}*2)]] ?
1424986863

Edited 1424987279
Diana P. said: How about [[(?{number of hits?|1}*2)d6+(?{number of hits?|1}*2)]] ? Not quite. That would require the player to enter the number of hits, which defeats the purpose of having a comprehensive attack macro. The 3 in the example I gave is actually part of a much more complex macro which would be an utter pain in the ass for a player to calculate by hand. I mean, I could use that after I've determined the number of hits, but it'd slow down play considerably compared to the macro I've got going now where the player simply click their target and gets the result. Another thing I neglected to mention is that that "-2" represents an armor formula which is also needlessly complicated (because that's just how GURPS rolls), so some hits might be reduced to a minimum of 0 damage and others might not. I don't think (?) that what you're suggesting allows me to account for some rolls being negated while others aren't.
1424987722
Diana P
Pro
Sheet Author
ah. Sorry, I don't know then. I shall have to bow out and hope that someone much better with macro's than I can help you.
1424992884
Lithl
Pro
Sheet Author
API Scripter
If "number of hits" is being determined by an attack roll and you're trying to incorporate that into a damage roll, what you're looking for isn't possible with a simple macro.
1425021079
The Aaron
Pro
API Scripter
Brian said: If "number of hits" is being determined by an attack roll and you're trying to incorporate that into a damage roll, what you're looking for isn't possible with a simple macro. There is a hack you can use with a few caveats. If you are running the attack and the damage macros as two different commands, and you aren't using the turn order and you are doing this with a token selected, you can store the value as the initiative in the first macro, then reference the initiative in the second macro. [[1d20+3 &{tracker}]] [[ @{tracker|MyChar}d6 + (2*@{tracker|MyChar}) ]] assuming a character named MyChar was selected. Complete hack, but interesting.
I may be misunderstanding the problem, but couldn't you just insert whatever calculation you're using to determine the number of attacks, into the 'number of dice' portion of the damage roll? /roll {CALCULATIONS GO HERE}d6 - 2 From the sound of it, you're trying to design a very similar macro to one I'm currently using, which is: /roll {[[floor({{(@{selected|SPD} - ({@{selected|WGT} - @{selected|STR}, 0}kh1)) - (@{target|SPD} - ({@{target|WGT} - @{target|STR}, 0}kh1)), 4d1}dh1 / 4, 1d0}dl1 + 1)]]d100
1425062586
The Aaron
Pro
API Scripter
Seraph, I think the calculations include a random element which would not be the same for each copy you suggest.
1425064092

Edited 1425064163
The Aaron said: Brian said: If "number of hits" is being determined by an attack roll and you're trying to incorporate that into a damage roll, what you're looking for isn't possible with a simple macro. There is a hack you can use with a few caveats. If you are running the attack and the damage macros as two different commands, and you aren't using the turn order and you are doing this with a token selected, you can store the value as the initiative in the first macro, then reference the initiative in the second macro. [[1d20+3 &{tracker}]] [[ @{tracker|MyChar}d6 + (2*@{tracker|MyChar}) ]] assuming a character named MyChar was selected. Complete hack, but interesting. This actually sorta works, unwieldy as it is. I don't think I'll actually use it because I do want to use the initiative tracker, but it does show that Roll20 is capable of storing variables. It'd be nice to use & to temporarily store information like rolls, or maybe use &- or &+ to modify an attribute (&-{targetted|hp} to automatically subtract from a target's HP). As you said, though, it needs to be in two macros. The tracker doesn't get updated until after the whole macro completes, so the damage formula uses the results from the last roll rather than the latest.
1425065260
The Aaron
Pro
API Scripter
Helmic said: As you said, though, it needs to be in two macros. The tracker doesn't get updated until after the whole macro completes, so the damage formula uses the results from the last roll rather than the latest. Technically, the issue is that the @{tracker|MyChar} is substituted before any of the formulas are evaluated, but it works out to the same thing.