battle formulas
 
Notifications
Clear all

battle formulas

1 Posts
2 Users
0 Reactions
793 Views
0
Topic starter

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.

1 Answer
0
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!

 

Share: