How come when I run this script, it sometimes returns nothing?
//START RANDOMIZE 1
srand((double)microtime()*1000000);
$seed = rand(1000000,9999999);
srand((double)microtime()*$seed);
$rpgrand = rand (1,100);
//END RANDOMIZE 1 (supposedly this is a double randomize and increase the "randomness" of the action. I suspect the error is here)
if($rpgatttype=="0"){
if($rpgrand <= $rpgmagattprob) {
$rpgactionresult = "0";
$perchance = "80";
} elseif($rpgrand <= $rpgmagdefprob && $rpgrand>$rpgmagattprob) {
$rpgactionresult = "1";
$perchance = "90";
} elseif($rpgrand <= $rpgphyattprob && $rpgrand>$rpgmagdefprob) {
$rpgactionresult = "2";
$perchance = "50";
} elseif($rpgrand > $rpgphyattprob) {
$rpgactionresult = "3";
$perchance = "50";
}
} elseif($rpgatttype=="1"){
if($rpgrand <= $rpgmagattprob) {
$rpgactionresult = "0";
$perchance = "50";
} elseif($rpgrand <= $rpgmagdefprob && $rpgrand>$rpgmagattprob) {
$rpgactionresult = "1";
$perchance = "50";
} elseif($rpgrand <= $rpgphyattprob && $rpgrand>$rpgmagdefprob) {
$rpgactionresult = "2";
$perchance = "20";
} elseif($rpgrand > $rpgphyattprob) {
$rpgactionresult = "3";
$perchance = "20";
}
//START RANDOMIZE 2
srand((double)microtime()*1000000);
$seed = rand(1000000,9999999);
srand((double)microtime()*$seed);
$rpgrand = rand (1,100);
//END RANDOMIZE 2
//THE FOLLOWING PART DOESN'T RETURN ANYTHING SOMETIMES...JUST IMAGINE I HAVE THE SAME VARIABLE DEFINED IN EACH "IF" AND IT SET LIKE 0 FOR THE FIRST, 2 FOR THE SECOND, AND SO ON
if($rpgrand<=$perchance && $attackerrpgenergyc<=$attackerrpglimitsa && ($rpgactionresult=="0" || $rpgactionresult=="2")){
//do stuff you don't need to know about
} elseif($rpgrand<=$perchance && ($rpgactionresult=="1" || $rpgactionresult=="3") && $attackerrpgenergyc>$attackerrpglimitsa){
//do stuff you don't need to know about
} elseif($rpgrand>$perchance && $attackedrpgenergyc<=$attackedrpglimitsa){
//do stuff you don't need to know about
} elseif($rpgrand>$perchance && $attackedrpgenergyc>$attackedrpglimitsa){
//do stuff you don't need to know about
}