herostun: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Initial write-up.)
 
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 5: Line 5:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
herostun(times, sides)
herostun(times, sides)
</source>
</syntaxhighlight>
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
hero(times, sides)
hero(times, sides)
</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:
|examples=
|examples=
Roll a twenty-sided dice, and return the {{func|herobody}} result as well.
Roll a twenty-sided dice, and return the {{func|herobody}} result as well.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[t: herostun(1, 20)] - [t: herobody(1, 20)
[t: herostun(1, 20)] - [t: herobody(1, 20)
</source>
</syntaxhighlight>
Returns a number that is between {{code|1}} and {{code|20}} for the herostun roll, and a number between {{code|0}} and {{code|2}} for the herobody roll.
Returns a number that is between {{code|1}} and {{code|20}} for the herostun roll, and a number between {{code|0}} and {{code|2}} for the herobody roll.


Roll five ten-sided dice, and return the {{func|herobody}} result as well, using variables.
Roll five ten-sided dice, and return the {{func|herobody}} result as well, using variables.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: DiceTimes = 5]
[h: DiceTimes = 5]
[h: DiceSides = 10]
[h: DiceSides = 10]
[t: herostun(DiceTimes, DiceSides)] - [t: herobody(DiceTimes, DiceSides)]
[t: herostun(DiceTimes, DiceSides)] - [t: herobody(DiceTimes, DiceSides)]
</source>
</syntaxhighlight>
Returns a number than is between {{code|5}} and {{code|50}} for the herostun roll, and a number between {{code|0}} and {{code|10}} for the herobody roll.
Returns a number than is between {{code|5}} and {{code|50}} for the herostun roll, and a number between {{code|0}} and {{code|10}} for the herobody roll.



Latest revision as of 16:18, 15 March 2023

herostun() Function

Generates random numbers to emulate dice rolls; acts like a standard roll() with the difference being that a hidden variable is tracked, which can then be returned using herobody(). This hidden variable is calculated by adding 2 for each dice that is rolled at maximum value, 0 for each dice that is rolled at minimum value, and 1 for each dice that is rolled at neither minimum, nor maximum value.

Usage

herostun(times, sides)
hero(times, sides)

Parameters

  • times - The number of times to roll the dice.
  • sides - The number of sides the dice possess.

Examples

Roll a twenty-sided dice, and return the herobody() result as well.
[t: herostun(1, 20)] - [t: herobody(1, 20)

Returns a number that is between 1 and 20 for the herostun roll, and a number between 0 and 2 for the herobody roll.

Roll five ten-sided dice, and return the herobody() result as well, using variables.

[h: DiceTimes = 5]
[h: DiceSides = 10]
[t: herostun(DiceTimes, DiceSides)] - [t: herobody(DiceTimes, DiceSides)]
Returns a number than is between 5 and 50 for the herostun roll, and a number between 0 and 10 for the herobody roll.

See Also

Used in conjunction with herobody()
For another method of rolling dice, see Dice Expressions.