battle formulas

1 reply · 3698 views

lstriker 0 likes received

hi, am trying to make a combat style base on dices (DnD) but i dont know how to make the random code variable.

exaple: Damage= U.atack + random (1,20) -T.pdef

sorry my english not native.

Answers

The Ramen Dutchman 1 likes received
u.atk + Math.random()*20 - t.pdef

The formulas render JavaScript

If you want a random number in JavaScript, you use Math.random()

it will give any number between 0 and 0.99... For example: 0, 0.71, 0.16, 0.22, etc...

For a d20, use Math.random()*20

This is because Math.random() gives a number between 0 and 1, so *20 means it will be between 0 and 19.99

RPG Paper Maker already round it for you, so 19.5 becomes 20!

I hope it helps, if not just ask here!

Back to Questions