I\'m a web-game developer and I got a problem with random numbers. Let\'s say that a player has 20% chance to get a critical hit with his sword. That means, 1 out of 5 hits
Pre-calculate a random critical hit for each player.
// OBJECT //... // OnAttack() //... c_h = c_h -1; if ( c_h == 0 ) { // Yes, critical hit! c_h = random(5) + 1 // for the next time // ... }