How would I calculate attack hit percentage chance?

I'm having a little trouble with figuring out how to go about calculating hit percentage chance for an attack. So lets say I have an attack, and I want it to hit 90% of the time, and miss the other 10%, how would I do that? Is it simply just:

 
  attackChance % 90; //? 


Im confused on how this is written in code.
Last edited on
Use a random number generator to generate integers from 0 to 9 ie ten integers and assign them to some variable, hit_no, say.

When hit_no = 0, that's a miss, and for any other hit_no it's a hit.
Perfect, thank you, I was making it way more complicated than it needed to be.
Topic archived. No new replies allowed.