Roll Queries -- Advanced Usage for 4th Edition( Sorry 5e guys, this probably won't help you.) Avoiding duplicate queries for handling crits in 4E The Issue: Many conditional damage bonuses exist, and a lot of them add additional damage in the form of extra dice rolling rather than a straight number. While roll queries are great for this and are often used for just that purpose, an issue arises when there is a critical hit in 4E. Critical hits in 4E maximize all dice rolls that would have been rolled, including the conditional/optional ones. Let's look at a roll query that handles a rogue's sneak attack as an example. In this example, the rogue's basic attack deals 2d4+5 damage. 2d4 + 5 + ?{Use Sneak Attack on the target?|No, 0|Yes, 3d6} Now we use this in the game. The rogue attacks, and as part of the attack, clicks "Yes" when the roll query pops up. Now, the system will roll 2d4+5+3d6. Ok good. But what if the player got a nat 20? At the moment, the game does not have a way detecting a critical hit AND then altering how math is handled. The reason is because all dice are rolled simultaneously, attack-damage together. So by the time it knows that a crit has been rolled, it's too late, the damage has already been rolled as well and cannot be modified further. One thing we can do, is include an extra clause in parentheses or on a new line that gives the figures for critical damage in case we need them, like this: "The target takes [[2d4+5]] damage (or [[13]] damage on a crit)." Ok great. By including the extra clause in parentheses, we can manually calculate in advance what the maximum damage would be, and easily reference the critical damage when we need to. When a crit happens, we just ignore the initial damage roll result it gives and defer to the crit info. However, the fact that we have to manually calculate and input the damage of a critical hit IN ADVANCE , means that we cannot respond to changing damage dice and other such conditional or optional bonuses. Let's replace the simple "2d4+5" in the above example with the full roll query version of sneak attack once more and see what happens with a crit... "The target takes [[2d4 + 5 + ?{Use Sneak Attack on the target?|No, 0|Yes, 3d6}]] damage (or [[13 + ?{Use Sneak Attack on the target?|No, 0|Yes, 3d6}]] damage on a crit)." The player once again choses "yes", and gets a crit. The output might end up like this... "The target takes 21 damage (or 25 damage on a crit)." Doesn't the crit damage seem kinda low? It is. 2d4 maxed becomes 8... then add 5, ... then 3d6 maxed becomes 18, so 8+5+18 should be 31.... so why does it show 25? It's because the system just rolled the 3d6, it didn't maximize them. Okay, so why don't we just manually write "18" in the second roll query above (regarding the critical damage) to read like this? "........(or [[13 + ?{Use Sneak Attack on the target? | No, 0 | Yes, 18 }]] damage on a crit)." Well....while that seems logical, sorry, no. We can't do that. We're using the exact same Question -- "Use Sneak Attack on the target?" --- which means when it asks you about it the first time, it will store that in memory as "3d6" when you answer "yes". Any further repetitions of the EXACT same roll query will default to the result of the first instance of the roll query, so again, "3d6". To put this in other words, the system only cares about the very first response that it got, and associates all future queries (of the same question) with the value tied to that first response. So even if we have something like this: [[13 +?{Use Sneak Attack on the target? | No, 0 | Yes, 3d6 } +?{Use Sneak Attack on the target? | No, 0 | Yes, 1d10 } +?{Use Sneak Attack on the target? | No, 0 | Yes, 18 } +?{Use Sneak Attack on the target? | No, 0 | Yes, -14 } ]] The system won't even look at that 1d10, 18 or -14. If you responded with "yes" on the first one, you wouldn't be asked a second, third or fourth time, and the computer will handle it something like this: 13 + ? (ask player to decide) --> player says yes --> 3d6... (rolling.... [1][5][3].... total = 9) + (repeated question-skip it, copy/paste 9) + (repeated question-skip it, copy/paste 9) + (repeated question-skip it, copy/paste 9) Output = 49 (Small note here, I'm not actually sure if the system stores the result of the first roll or the dice formula for the first roll... it might copy/paste 3d6/3d6/3d6... but in either case it's irrelevant, it won't maximize damage.) SO! This means if we want to handle critical rolls dynamically so that they can fluctuate and adjust to conditional bonus die rolls, we would have to double up and write entirely new questions about criticals that the system will ask us about, and apply separately, from the normal damage rolls like this: "The target takes [[2d4 + 5 + ?{Use Sneak Attack on the target? (for normal damage) |No, 0|Yes, 3d6}]] damage (or [[13 + ?{Use Sneak Attack on the target? (for crit) |No, 0|Yes, 18}]] damage on a crit)." This can get really tedious in game because you get a barrage of DOUBLE the number of pop-up questions that ALL must be answered due to all the redundancy.... Use sneak attack on the target for normal damage? Me: Clicks yes. Use sneak attack on the target for critical damage? Me: Clicks yes. Activate your swords fireburst effect for normal damage? Me: Clicks yes. Activate your swords fireburst effect for critical damage? Me: Clicks yes.... *sighs* Well my friends, there IS a better way. Math can do some sneaky things with 1's and 0's... Any number multiplied by 0 is 0. Any number multiplied by 1 is itself. Using these two facts, order of operations and the mathematical "ceil" function built into the system (ceil is short for ceiling, which means "round up"), we can do this in the critical clause..... +(18*ceil(?{Use Sneak Attack on the target?|No, 0|Yes, 3d6}/18)) Can you see what this does? Take a moment to try and pick it apart. Like onion layers, let's start from the innermost brace/parentheses layer and resolve this from the inside out. First, let's assume the player chose "no". In this case, the roll query resolves to "0", since No = 0. This gives us... +(18*ceil(0/18)) the next inner onion layer is (0/18). This also resolves to 0, bringing us here... +(18*ceil(0)) next we have to do the rounding up operation "ceil(0)", since the system doesn't know what to multiply 18 with yet. 0 rounded up is still 0, since it's already a whole number...giving us... +(18*0) The asterix (*) is read as a multiplication sign by the system, so this just means 18 x 0. This, of course equals 0. So, the final result, when all is said and done, is... +0 This means that if a player responds with "no" the equation will resolve to 0, and nothing will be added. How about if they answer "yes"? Let's do that next. +(18*ceil(?{Use Sneak Attack on the target?|No, 0|Yes, 3d6}/18)) The player chose "yes", so the system will randomly roll 3d6, and get some number between 3~18, it doesn't matter what it rolls, so let's just say it rolled a total of 10. So that gives us... +(18*ceil(10/18)) Next, the division.... 10/18 is 0.5555555....repeating. So now we have.... +(18*ceil(0.55555555)) Next, we do the round up operation for ceil(0.5555555555), so we round that repeating 0.5555555 up to 1, giving us.... +(18*1) 18 x 1 is of course 18, so we have thus arrived at... +18 ...which is the maximized value of 3d6....a crit. The gist is, no matter what the computer rolls on that 3d6, if we divide that result by the maximum possible number it could have been (in this case 18), we will get a decimal that is less than 1, but greater than 0. We then round up to get 1. In doing this, we don't actually care what the computer rolls, we only care that it rolled at all-- because this means we must have selected "yes" on the roll query. If we selected "No", then nothing would have been rolled, and a 0 would result. So "Yes" gives us a 1, and "No" gives us a 0. We then take that 1 or 0, and multiply it by the number that we DO want... the value of a maximized roll. In this case, we want to add 18 more damage to a critical roll that had sneak attack, BUT add nothing (aka, 0) if no sneak attack was made. The important bits of the equation that you need to attach to the ends of your critical damage roll queries are highlighted below. + (18*ceil( ?{Use Sneak Attack on the target?|No, 0|Yes, 3d6} /18)) The number you insert (in this case, 18) must be the maximized value of the dice roll involved, so if it's 2d10, you'd replace those 18's with 20's. If it was 6d8, you'd replace them with 48's. By doing this, you force it to add either a 0 or the maximized value of the dice roll. Other examples using different die formulas: + (48*ceil( ?{Add super-stinky feet damage?|No, 0|Yes, 6d8} /48)) + (12*ceil( ?{Additional pie in the face damage?|No, 0|Yes, 1d12} /12)) NOW, you can use the same roll query wording for both normal AND critical damage, so there are no redundancies, and you only have to answer your roll query ONCE. TADA!