This same technique is used to pull random text for battles. In this example, enemy(2) will generate an enemy that is level 2, randomly selected from the pool of eligible candidates.
function enemy($nmeLvl){
$getEnemies = mysql_query('SELECT * FROM enemies WHERE nmeLvl = "'.$nmeLvl.'"');
while($enemy = mysql_fetch_assoc($getEnemies)){
$enemies[] = $enemy['nmeName'];
}
$nmeName = array_rand(array_flip($enemies), 1);
return $nmeName;
}
No comments:
Post a Comment