explodingSuccess: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Text replacement - "source>" to "syntaxhighlight>")
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
explodingSuccess(times, sides, target)
explodingSuccess(times, sides, target)
</syntaxhighlight>
</syntaxhighlight>
Line 15: Line 15:
|examples=
|examples=
Roll a twenty-sided dice, and returns {{code|1}} if rolled higher than {{code|30}}.
Roll a twenty-sided dice, and returns {{code|1}} if rolled higher than {{code|30}}.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[t: explodingSuccess(1, 20, 30)]
[t: explodingSuccess(1, 20, 30)]
</syntaxhighlight>
</syntaxhighlight>
Line 21: Line 21:


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

Revision as of 17:39, 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

explodingSuccess(times, sides, target)

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.
[t: explodingSuccess(1, 20, 30)]

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.

[h: DiceTimes = 5]
[h: DiceSides = 10]
[h: DiceTarget = 20]
[t: explodingSuccess(DiceTimes, DiceSides, DiceTarget)]
Returns a number than is between 0 and 5.

See Also

For another method of rolling dice, see Dice Expressions.