0 votes
by (310 points)
Just thought I'd ask if anyone had a thought on how to implements Ability Scores, Modifiers, and Dice Rolls based upon those stats and modifiers.

1 Answer

+3 votes
by (8.9k points)
selected by
 
Best answer

To create a character called Hellfox:

<<set $hellfox to {}>>

To roll Hellfox's DEX:

<<set $hellfox.dex to random (3,18)>>

To calculate Hellfox's DEX modifier:

<<if $hellfox.dex lte 1>>
  <<set $hellfox.dexmod to -5>>
  <<elseif $hellfox.dex == 2 or $hellfox.dex == 3>>
  <<set $hellfox.dexmod to -4>>
  <<elseif $hellfox.dex == 4 or $hellfox.dex == 5>>
  <<set $hellfox.dexmod to -3>>
  <<elseif $hellfox.dex == 6 or $hellfox.dex == 7>>
  <<set $hellfox.dexmod to -2>>
  <<elseif $hellfox.dex == 8 or $hellfox.dex == 9>>
  <<set $hellfox.dexmod to -1>>
  <<elseif $hellfox.dex == 10 or $hellfox.dex == 11>>
  <<set $hellfox.dexmod to 0>>
  <<elseif $hellfox.dex == 12 or $hellfox.dex == 13>>
  <<set $hellfox.dexmod to 1>>
  <<elseif $hellfox.dex == 14 or $hellfox.dex == 15>>
  <<set $hellfox.dexmod to 2>>
  <<elseif $hellfox.dex == 16 or $hellfox.dex == 17>>
  <<set $hellfox.dexmod to 3>>
  <<elseif $hellfox.dex == 18>>
  <<set $hellfox.dexmod to 4>>
<</if>>

To work out Hellfox's base Armor Class:

<<set $hellfox.ac to 10 + $hellfox.dexmod>>

To make a DEX check for Hellfox:

<<if random (1,20) lte $hellfox.dex>>
  <<print ":)">>
  <<else>>
  <<print ":(">>
<</if>>

 

by (63.1k points)
edited by

Please note that the distribution of 3 six-sided dice is not really reflected by just generating a random number in the 3 to 18 range. It might be better to actually use three random functions of 1 to 6 and add them together to simulate that bell-shaped distribution you get with the dice, giving players a much higher chance of a middling score.

<<set $score to random(1, 6) + random(1, 6) + random(1, 6)>>

Also, you can calculate modifiers like this: 

<<set $modifier to Math.floor(($score - 10) / 2)>>

...instead of checking each value individually. 

by (8.9k points)
I knew there'd be a more efficient way of doing that.  Thanks  :-)
by (310 points)
edited by
in Harlowe, that ends up reading:

(set: $str to (random: 1,6) + (random: 1,6) + (random: 1, 6))
(set: $strMod to ($str-10)/2)

I'm not sure how to get it to round down for the modifier, though. (Edit: I found the rounding thing in harlowe, but it rounds 0.5 up, so yeah.)
...