Here's a tweaked version of the function from my earlier answer that should work for any number (≥ 2) of ordinary dice, with the player choosing two of them:
function: stunt points for DICE:s and STUNT_DIE:n vs TARGET:n {
if {1,2}@DICE + STUNT_DIE < TARGET { result: 0 } \ miss \
\ it's a hit; can we choose a pair that will give us stunts? \
if 1@DICE = STUNT_DIE { result: STUNT_DIE }
if DICE = STUNT_DIE & 1@DICE + 2 * STUNT_DIE >= TARGET { result: STUNT_DIE }
loop I over {1..#DICE-1} {
if I@DICE = (I+1)@DICE & 2 * I@DICE + STUNT_DIE >= TARGET { result: STUNT_DIE }
}
result: 0 \ hit but no pair \
}
The first line in the function (checking if the roll is a miss) is the same as in my old code, except that I'm explicitly summing only the highest two ordinary dice rolled using {1,2}@DICE
: if those plus the stunt die don't meet the target, then no combination will. Conversely, if they do, then we'll at least get a hit, but we might or might not get any stunts.
(Replacing the result: 0
on the first line with result: d{}
will make the code calculate the distribution of stunt points conditioned on the roll being a successful hit, i.e. as if all misses were rerolled until they hit. You could also change this line to e.g. return -1 to distinguish misses from hits with no stunts.)
Next, I'm checking if the player might be able to choose two dice out of however many they rolled that will given them a hit with stunts. Here, there are three possibilities, which the code checks for in this order:
If the highest ordinary die matches the stunt die, then simply choosing the highest two ordinary dice will give a hit with stunts. (We know it will, because we just checked that at the start of the function.)
Otherwise, if any ordinary die matches the stunt die and if that die plus the stunt die plus the highest roll will meet the target, then the player can choose those and get stunts.
(In the code, DICE = STUNT_DIE
compares a sequence with a number, returning true if any value in the sequence matches the number. We don't actually need to know the index of the matching die in the sequence, if any, since we know its value anyway — it's equal to the stunt die!)
Finally, we loop over the dice and check if any two consecutive dice in the (automatically sorted) sequence have the same value, and if so, whether that value twice plus the stunt die is enough for a hit. If so, the player can choose that pair and get stunts.
(Since we know the sequence is sorted in descending order, and since this is the last possibility checked for, we could actually abort the loop early and return 0 from the function as soon as we find that 2 * I@DICE + STUNT_DIE < TARGET
, as no smaller pair can possibly give a hit either. Implementing that minor optimization is left as an exercise for the reader. :)
Finally, if none of those checks succeeds, the function returns 0 indicating that the player could not get any stunts but still rolled a successful hit (choosing e.g. their top two ordinary dice plus the stunt die).
When called with 2d6 as DICE
, this function is a drop-in replacement for the one in my earlier answer, and indeed gives the same results.
What about for more dice? As we can see, as the number of dice to choose from increases, the probability of getting stunts increases.

In general, higher stunt counts are more likely than lower ones, which makes intuitive sense: the higher you roll on the stunt die, the more likely you are to hit and to be able to choose a hitting combo that includes two identical dice. However, the specific shape of the curve varies depending on the target difficulty: DC 10 above, for example, gives fairly smooth looking plots, but DC 11 seems to favor odd numbers of stunts, leading to a more staircase-like graph:

Notably, for five or more normal dice and DC 11, the probability of getting a hit with stunts is actually slightly lower if you roll a 4 on the stunt die than if you roll a 3. (Of course you still get more stunts if you do get any, and your overall hit probability is higher too, so a higher roll on the stunt die is still better.)