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

Remove matching dice from two dice pools (hopefully using scriptcard)

Hi, Hope someone can point me in the right direction for this, in my homebrew game I use dice pools of exploding dice for attack and defence (number of attack/defence dice are variable) e.g. Attack = 5d10!s  gives say  1, 2, 5, 6, 6, 8, 10  (the exploding 10 gave the extra 6)    Defence = 3d10!s  gives say 1 , 4, 6, 10  (the exploding 10 produced the 6) the bold numbers need to be removed I want to display the resulting attack dice list as separate values ie. 2, 5, 6, 8, 10  after removing the matching defence dice, note one 6 result remains Hope that makes sense :) Any help appreciated
Hey Norman, I might be able to help you out with a ScriptCard version of this. I have a question about the above example though to get a better understanding. So the 1 and 6 are removed because they each have that roll in common between attack and defense. Is the 10 a special case? Are tens never removed even when their is a 10 in defense?
Hi Joshua, Damn - and I thought I written it out right :) You are indeed correct, the 10s should be removed as well, the 10s are only special in that they explode to give more numbers, so the result of the above example should be 2, 5, 6, 8 Hope that clarifies it Cheers
Here is one way it can be done !script {{ --&NumAtkDice|?{Number of attack dice} --&NumDefDice|?{Number of defend dice} --&DieType|d10 --=AtkRoll|[&NumAtkDice][&DieType]! --=DefRoll|[&NumDefDice][&DieType]! --+Initial Attack Rolls|[$AtkRoll.Text] --+Initial Defend Rolls|[$DefRoll.Text] -->ConvertRollToArray|AtkRollArr;AtkRoll -->ConvertRollToArray|DefRollArr;DefRoll --/|Remove matches from AtkRollArr --%droll|foreach;DefRollArr --~_tmpArrIdx|array;indexof;AtkRollArr;[&droll] --?"[&_tmpArrIdx]" -eq "ArrayError"|ENDMATCHLOOP --~|array;removeat;AtkRollArr;[&_tmpArrIdx] --:ENDMATCHLOOP| --%| --~ResultsList|array;stringify;AtkRollArr;, --+Results|[&ResultsList] --:Done| --X| --/|ScriptCards has a built-in function fromrollvar to turn rolls into arrays --/|However when exploding dice are rolled, it sums the result which is not what we want here --/|So we need our own array parser to keep exploding rolls as separate entries --/|Also the RolledDice roll modifier also provides the sum, so we'll need to parse the exploding results --/|using text parsing --:ConvertRollToArray|ArrayName;RollValue --~|array;define;[%1%] --&_crtaTmpRolls|[$[%2%].Text] --&_crtaTmpRolls|[&_crtaTmpRolls(1,-2)] --~_crtaRInfo|string;split;,;[&_crtaTmpRolls] --%_crtaRIdx|1;[$_crtaRInfoCount] --?"[&_crtaRInfo[&_crtaRIdx]]" -inc "!"|_crtaHandleExploded -->libArray_Push|[%1%];[&_crtaRInfo[&_crtaRIdx]] --^_crtaENDROLLPARSELOOP| --:_crtaHandleExploded| --~_crtaEInfo|string;split;!;[&_crtaRInfo[&_crtaRIdx]] --%_crtaEIdx|1;[$_crtaEInfoCount] -->libArray_Push|[%1%];[&_crtaEInfo[&_crtaEIdx]] --%| --:_crtaENDROLLPARSELOOP| --%| --<| --:libArray_Push|ArrayName;StringValue --~|array;add;[%1%];[%2%] --<| }} Let me know if you have any questions about that.
1754340093

Edited 1754340654
Awesome Joshua, it does exactly what I need :) I've added in my bits to calculate a to-hit number based on range, terrain mods, target armour and now the players can use your results row to assemble groups of dice which exceed the to-hit number to inflict hits. Thank you very much. Norman