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 .
×

Multi attack and total damage not working as intended

1687604082

Edited 1687604183
Hello, I'm trying to build a macro for a deathwatch game that would roll total damage and afterwards split the total damage into its separate rolls via Reuse Rolls functionality, however I seem to be doing something wrong as it doesn't track the rolls how I want them to. I tried working this out myself and scoured multiple forums posts but I lack the knowledge to understand what needs to be corrected  Here's the code  &{template:default}{{name=Executor Heavy Bolter Mk. VIII}}{{Damage Total=?{Number of hits| Two, [[[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] | Three, [[[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] | Four, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Five, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Six, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Seven, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Eight, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Nine, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Ten, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | }}} {{Dmg [[[{?{Number of attacks|2},1}kl1]]](#) = $[[0]]}} {{Dmg [[[{?{Number of attacks|2},2}kl1]]](#) = $[[1]]}} {{Dmg [[[{?{Number of attacks|2},3}kl1]]](#) = $[[2]]}} {{Dmg [[[{?{Number of attacks|2},4}kl1]]](#) = $[[3]]}} {{Dmg [[[{?{Number of attacks|2},5}kl1]]](#) = $[[4]]}} {{Dmg [[[{?{Number of attacks|2},6}kl1]]](#) = $[[5]]}} {{Dmg [[[{?{Number of attacks|2},7}kl1]]](#) = $[[6]]}} {{Dmg [[[{?{Number of attacks|2},8}kl1]]](#) = $[[7]]}} {{Dmg [[[{?{Number of attacks|2},9}kl1]]](#) = $[[8]]}} {{Dmg [[[{?{Number of attacks|2},10}kl1]]](#) = $[[9]]}} This is what rolling for 6 attacks and displaying 6 rolls looks like. The last rolls always seems to be using the roll from "?{Number of attacks|2}"  However using 10 rolls (max) shows the separate instances of damage correctly I have made a functioning version of this idea but it's somewhat clunky and I'd like to improve upon it Here's the original code that I wanted to improve &{template:default}{{name=Executor Heavy Bolter Mk. VIII}}{{Damage Total=?{Number of hits| Two, [[[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] | Three, [[[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] | Four, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Five, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Six, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Seven, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Eight, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Nine, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | Ten, [[[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]+[[{(2d10+1d10)}kh2+15}]]]] | }}} {{Damage = ?{Number of displayed hits|Two, $[[0]] +$[[1]] | Three, $[[0]] + $[[1]] + $[[2]] | Four, $[[0]] + $[[1]] + $[[2]] + $[[3]] | Five, $[[0]] + $[[1]] + $[[2]] + $[[3]] +$[[4]] | Six, $[[0]] + $[[1]] + $[[2]] + $[[3]] + $[[4]] +$[[5]] | Seven, $[[0]] + $[[1]] + $[[2]] + $[[3]] + $[[4]] + $[[5]]+ $[[6]] | Eight, $[[0]] + $[[1]] + $[[2]] + $[[3]] + $[[4]] + $[[5]] + $[[6]] + $[[7]] | Nine, $[[0]] + $[[1]] + $[[2]] + $[[3]] + $[[4]] + $[[5]] + $[[6]] + $[[7]] + $[[8]] | Ten, $[[0]] + $[[1]] + $[[2]] + $[[3]] + $[[4]] + $[[5]] + $[[6]] + $[[7]] + $[[8]] + $[[9]]}}} Any help would be greatly appreciated
1687613976
GiGs
Pro
Sheet Author
API Scripter
I havent done more than glance at your code but it reminded me of an issue with reusing rolls: if you have too many inline rolls, the sequence stops working. Normally $[[7]] reers to the 8th inline roll, but when there are a lot of inline rolls, it might refer to the 10th, 7th, or some other numebr that you have to work out by trial and error. Could this be your issue?
1687614312
GiGs
Pro
Sheet Author
API Scripter
You also can't do this: $[[0]] + $[[1]] + $[[2]] These entities ($[[0]]) are not numbers, they only look like numbers. You cannot perform arithmetic with them.
1687616235

Edited 1687616256
GiGs
Pro
Sheet Author
API Scripter
What you probably want is something like this (nesting more of the template inside the query) &{template:default}{{name=Executor Heavy Bolter Mk. VIII}}{{Damage Total=?{Number of hits| Two, [[[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] }} {{damage=$[[0]] + $[[1]] }} {{Total=$[[2]]  | Three, [[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]] ]] }} {{damage=$[[0]] + $[[1]] + $[[2]] }} {{Total=$[[3]] } }} You need a few more html replacements, but it's doable if tedious. There's another syntax that lets you use the total before the inline rolls: $[[2.computed]] - you can place this before the total. So you could do this &{template:default}{{name=Executor Heavy Bolter Mk. VIII}}{{Damage=?{Number of hits| Two, $[[0.computed]] + $[[1.computed]] }} {{damage Total=[[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] | Three, $[[0.computed]] + $[[1.computed]] + $[[2.computed]] }} {{damage Total=[[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]] ]] } }} All that said, the absolute best thing you good do is look into chat menus, and have a separate button for each number of hits. The coding is far, far simpler.
1687618369
GiGs
Pro
Sheet Author
API Scripter
Also, you'll notice from my exmaple that you can enter spaces in a lot of places, and can use them strategically to make your code a little bit easier to understand.
1687620498

Edited 1687622868
Thank you, I haven't looked into chat menus yet because I wanted to work out the proper functionality first and afterwards try to improve it from there. I spent way too much time figuring how to bring this all together and your solution is much cleaner and simpler and requires less code so thanks for that.  I'm aware I can't do math with  $[[0]] + $[[1]] + $[[2]] They're for displaying separate rolls only Regarding the inline rolls - If I wanted to display the separate damage rolls on separate rows, how exactly can I mix n match the values if their amount is dynamic? ex. if I fix it for 7 attacks, it will most likely break for 8+ attacks
The problem you were originally facing was to do with how template overwriting was working. Since your "Dmg X" template names are calculated using a keep low group roll - when your number of attacks is less than ten the tenth gets lowered to that number and overwrites the correct roll. So the last "Dmg X" always show roll $[[9]] GiGs said: I havent done more than glance at your code but it reminded me of an issue with reusing rolls: if you have too many inline rolls, the sequence stops working. Normally $[[7]] reers to the 8th inline roll, but when there are a lot of inline rolls, it might refer to the 10th, 7th, or some other numebr that you have to work out by trial and error. Could this be your issue? The way rolls get sequenced can be complicated depending on the exact nature of the nested rolls. I've previously documented how roll indices are assigned . Unless you're doing something particularly egregious (such as 15+ levels of nesting with specific circumstances) the sequencing doesn't break. In this instance the sequence is simple/as expected DanD16 said: Regarding the inline rolls - If I wanted to display the separate damage rolls on separate rows, how exactly can I mix n match the values if their amount is dynamic? ex. if I fix it for 7 attacks, it will most likely break for 8+ attacks Your original method can work by reversing the templates (Dmg 10 down to Dmg 1). That way the correct last roll would be shown. To retain the order of 1 up to 10 place a copy of the reversed templates after the existing templates. The existing templates will set the order; the reversed ones ensure the correct rolls are shown.
1687814967

Edited 1687953859
Thank you for the explanation on template overwriting, I'll keep that in mind Your original method can work by reversing the templates (Dmg 10 down to Dmg 1). That way the correct last roll would be shown. To retain the order of 1 up to 10 place a copy of the reversed templates after the existing templates. The existing templates will set the order; the reversed ones ensure the correct rolls are shown. So, if I understood you correctly I simply added a reverse template after my standard one and it worked like this (8 rolls and 8 displayed hits, works for any number of rolls). Thank you for the solution {{Dmg [[[{?{Number of attacks|2},1}kl1]]](#) = $[[0]]}} {{Dmg [[[{?{Number of attacks|2},2}kl1]]](#) = $[[1]]}} {{Dmg [[[{?{Number of attacks|2},3}kl1]]](#) = $[[2]]}} {{Dmg [[[{?{Number of attacks|2},4}kl1]]](#) = $[[3]]}} {{Dmg [[[{?{Number of attacks|2},5}kl1]]](#) = $[[4]]}} {{Dmg [[[{?{Number of attacks|2},6}kl1]]](#) = $[[5]]}} {{Dmg [[[{?{Number of attacks|2},7}kl1]]](#) = $[[6]]}} {{Dmg [[[{?{Number of attacks|2},8}kl1]]](#) = $[[7]]}} {{Dmg [[[{?{Number of attacks|2},9}kl1]]](#) = $[[8]]}} {{Dmg [[[{?{Number of attacks|2},10}kl1]]](#) = $[[9]]}} {{Dmg [[[{?{Number of attacks|2},10}kl1]]](#) = $[[9]]}} {{Dmg [[[{?{Number of attacks|2},9}kl1]]](#) = $[[8]]}} {{Dmg [[[{?{Number of attacks|2},8}kl1]]](#) = $[[7]]}} {{Dmg [[[{?{Number of attacks|2},7}kl1]]](#) = $[[6]]}} {{Dmg [[[{?{Number of attacks|2},6}kl1]]](#) = $[[5]]}} {{Dmg [[[{?{Number of attacks|2},5}kl1]]](#) = $[[4]]}} {{Dmg [[[{?{Number of attacks|2},4}kl1]]](#) = $[[3]]}} {{Dmg [[[{?{Number of attacks|2},3}kl1]]](#) = $[[2]]}} {{Dmg [[[{?{Number of attacks|2},2}kl1]]](#) = $[[1]]}} {{Dmg [[[{?{Number of attacks|2},1}kl1]]](#) = $[[0]]}} However I decided to implement the row functionality into Gigs' version and got this (I rolled for 2, 3 and 4 hits, with 2 and 3 written the same way and 4 lacking the "=" symbol) It works the same way on any amount of hits so I'm leaving only a chunk of the code here. I tried substituting "=" with  =   but that didn't help. Why does "=" not work properly in a query? &{template:default}{{name=Executor Heavy Bolter Mk. VIII}} {{Damage=?{Number of hits| Two, $[[0.computed]]}} {{Damage = $[[1.computed]] }} {{damage Total=[[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]]] | Three, $[[0.computed]]}} {{Damage = $[[1.computed]]}} {{Damage = $[[2.computed]] }} {{damage Total=[[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]] ]] | Four, $[[0.computed]]}} {{Damage $[[1.computed]]}} {{Damage $[[2.computed]]}} {{Damage $[[3.computed]] }} {{damage Total=[[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]] ]] }}} UPD: Turns out the template is very picky about spacing but it still would break if I were to use regular "=" so I replaced "&" with "&amp" and now it works (kinda)  Four, $[[0.computed]]}} {{Damage = $[[1.computed]]}} {{Damage = $[[2.computed]]}} {{Damage = $[[3.computed]]}} {{damage Total=[[ [[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]]+[[{(2d10+1d10)}kh2+15]] ]]