explodingSuccess: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page ExplodingSuccess to explodingSuccess: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 7: Line 7:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
explodingSuccess(times, sides, target)
explodingSuccess(times, sides, target)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|times|The number of times to roll the dice.}}
{{param|times|The number of times to roll the dice.}}
Line 17: Line 17:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[t: explodingSuccess(1, 20, 30)]
[t: explodingSuccess(1, 20, 30)]
</source>
</syntaxhighlight>
Returns {{code|0}} or {{code|1}}; {{code|1}} is only returned if the twenty-sided dice rolls {{code|20}} and then is rerolled(exploded) with a result equal to or higher than {{code|10}}.
Returns {{code|0}} or {{code|1}}; {{code|1}} is only returned if the twenty-sided dice rolls {{code|20}} and then is rerolled(exploded) with a result equal to or higher than {{code|10}}.


Line 26: Line 26:
[h: DiceTarget = 20]
[h: DiceTarget = 20]
[t: explodingSuccess(DiceTimes, DiceSides, DiceTarget)]
[t: explodingSuccess(DiceTimes, DiceSides, DiceTarget)]
</source>
</syntaxhighlight>
Returns a number than is between {{code|0}} and {{code|5}}.
Returns a number than is between {{code|0}} and {{code|5}}.



Revision as of 17:05, 14 March 2023

explodingSuccess() Function

Generates random numbers to emulate dice rolls; returns the count of dice rolls that are above a certain number, while each individual dice rolled at maximum value will be rerolled with the new roll added to the old. There is no limit to the number of time that that an individual dice rolled can be rerolled by this function, but the odds of each individual number decreases as the total increases past the number of sides.

Usage

<source lang="mtmacro" line> explodingSuccess(times, sides, target) </syntaxhighlight> Parameters

  • times - The number of times to roll the dice.
  • sides - The number of sides the dice possess.
  • target - The number that a dice needs to be equal to or higher to be considered a success(added to the count returned).

Examples

Roll a twenty-sided dice, and returns 1 if rolled higher than 30.

<source lang="mtmacro" line> [t: explodingSuccess(1, 20, 30)] </syntaxhighlight> Returns 0 or 1; 1 is only returned if the twenty-sided dice rolls 20 and then is rerolled(exploded) with a result equal to or higher than 10.

Roll five ten-sided dice, and returns the number of dice that rolled higher than twenty, using variables. <source lang="mtmacro" line> [h: DiceTimes = 5] [h: DiceSides = 10] [h: DiceTarget = 20] [t: explodingSuccess(DiceTimes, DiceSides, DiceTarget)] </syntaxhighlight>

Returns a number than is between 0 and 5.

See Also

For another method of rolling dice, see Dice Expressions.