math.random error !?

random1 = ( 1+ Math.randomInt($gameVariables.value( 42 ));
random2 = ( Math.randomInt($gameVariables.value( 42 ));
sum = random1 + random2;
$gameVariables.setValue(43, sum);


Hi what wrong with this script ?


i generate one number base on variable 42.


i generate seconde number based on variable 42


i generate SUM , random 1 + random2


i injecte the SUM in gamevariable 43


??
You missed another " ) "

Code:
random1 = ( 1+ Math.randomInt($gameVariables.value( 42 )));
random2 = ( Math.randomInt($gameVariables.value( 42 )));
You missed another " ) "



random1 = ( 1+ Math.randomInt($gameVariables.value( 42 )));
random2 = ( Math.randomInt($gameVariables.value( 42 )));

???? heu no lol !
You missed another " ) "



random1 = ( 1+ Math.randomInt($gameVariables.value( 42 )));
random2 = ( Math.randomInt($gameVariables.value( 42 )));

its TRUE !! strange for me.


Have question.


The VAR 42 = 1


So a suppose receve number between 1 and 2.


Why a receve all time 1 ?
When you want get random 1 it will always give you 0
When you want get random 1 it will always give you 0

ok tank you
random Int ranges from 0 to (X - 1)


so randonInt 12 will be from 0 ot 11.
random Int ranges from 0 to (X - 1)


so randonInt 12 will be from 0 ot 11.

ok tanks i understand.


I use this for generate random ennemie LV based on Heroes LV.


But i do conditional , if heroes are LV 1, i simply do variable ramdom 1 to 2


After example if Heroes are LV 10


Ennemie lv can be


Ramdom 1 to 10 + ramdom 0 to 10.


So betwenn 1 to 20

Original thread: https://forums.rpgmakerweb.com/threads/math-random-error.60573/