- Joined
- Jul 26, 2008
- Messages
- 1,009
Alright I've been wracking my brain trying to figure out a proper formula to ease my coding problems. It's just general math, so I figured it could be put in this thread for analysis.
The game gets a random integer from 1 to 12.
When this spell is level 1, I want it to have a 50/50 chance of doing one effect or the other.
At level 2, it should split into 1/3 chance of doing 1 effect of two others. So a 100% chance of doing something, but only one of 3 things.
Finally at level 3, it should have a 1 in 4 chance, following the same principles as previous.
I figured 12 goes into 1 2 3 4 and 6, so it'd be the appropriate number to use.
The first part is set up great.
i < 12/1+lvl and i >= 0
At level one it's if the number is 6 or less, at level 2 if it's 4 or less, and level 2 if it's 3 or less.
6/6 = 12
4/4/4 = 12
3/3/3/3 = 12
Just like I want, but I can't figure out the equations for the rest. I can only calculate for the first part of it.
The game gets a random integer from 1 to 12.
When this spell is level 1, I want it to have a 50/50 chance of doing one effect or the other.
At level 2, it should split into 1/3 chance of doing 1 effect of two others. So a 100% chance of doing something, but only one of 3 things.
Finally at level 3, it should have a 1 in 4 chance, following the same principles as previous.
I figured 12 goes into 1 2 3 4 and 6, so it'd be the appropriate number to use.
The first part is set up great.
i < 12/1+lvl and i >= 0
At level one it's if the number is 6 or less, at level 2 if it's 4 or less, and level 2 if it's 3 or less.
6/6 = 12
4/4/4 = 12
3/3/3/3 = 12
Just like I want, but I can't figure out the equations for the rest. I can only calculate for the first part of it.