I'm working on an RPG game at the moment, and i would like to know how i can add randomness to the game. For exmaple having a x% chanse to load one movieclip into the game when another movieclip is unloaded (Enemy dying and dropping an item) Anyone know how i can do this?
function RNG(chance:Number):Number{ if(Math.random()*100>=chance){ return true }else{ return false } }
//when an enemy dies if(RNG(80)){ dropitem1() //create this function or replace this code, 80% chance of being called }else{ dropitem2 //create this function or replace this code, called if item1 does not drop }