explodingSuccess: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Text replacement - "<source" to "<syntaxhighlight")
(Fixed the description of the return value to state that it is a formatted string rather than a single number)
Line 2: Line 2:
|name=explodingSuccess
|name=explodingSuccess
|description=
|description=
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.
Generates random numbers to emulate dice rolls; any dice that are rolled at maximum value are rolled again with the new roll added to the old. Returns a formatted string containing the result of each roll and the number of rolls that were at least the target number.


|usage=
|usage=
Line 11: Line 11:
{{param|times|The number of times to roll the dice.}}
{{param|times|The number of times to roll the dice.}}
{{param|sides|The number of sides the dice possess.}}
{{param|sides|The number of sides the dice possess.}}
{{param|target|The number that a dice needs to be equal to or higher to be considered a success(added to the count returned).}}
{{param|target|The number that a dice needs to be equal to or higher to be considered a success (added to the count returned).}}


|examples=
|examples=
Roll a twenty-sided dice, and returns {{code|1}} if rolled higher than {{code|30}}.
Roll a twenty-sided dice, and return one success if rolled higher than {{code|30}}.
<syntaxhighlight lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[t: explodingSuccess(1, 20, 30)]
[t: explodingSuccess(1, 20, 30)]
</syntaxhighlight>
</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 a string similar to {{code|Dice: 35, Successes: 1}} or {{code|Dice: 8, Successes: 0}}. The success count will either be 0 or 1, with 1 only returned if the twenty-sided die rolls {{code|20}} and then is rerolled(exploded) with a result equal to or higher than {{code|10}}.


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.
Line 27: Line 27:
[t: explodingSuccess(DiceTimes, DiceSides, DiceTarget)]
[t: explodingSuccess(DiceTimes, DiceSides, DiceTarget)]
</syntaxhighlight>
</syntaxhighlight>
Returns a number than is between {{code|0}} and {{code|5}}.
Returns a string similar to {{code|Dice: 25, 14, 35, 2, 15, Successes: 4}}, where the successes will be between {{code|0}} and {{code|5}}.


|also=
|also=

Revision as of 18:39, 1 August 2023

explodingSuccess() Function

Generates random numbers to emulate dice rolls; any dice that are rolled at maximum value are rolled again with the new roll added to the old. Returns a formatted string containing the result of each roll and the number of rolls that were at least the target number.

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 return one success if rolled higher than 30.
[t: explodingSuccess(1, 20, 30)]

Returns a string similar to Dice: 35, Successes: 1 or Dice: 8, Successes: 0. The success count will either be 0 or 1, with 1 only returned if the twenty-sided die 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 string similar to Dice: 25, 14, 35, 2, 15, Successes: 4, where the successes will be between 0 and 5.

See Also

For another method of rolling dice, see Dice Expressions.