Search:
Forum
Beginners
How would I calculate attack hit percent
How would I calculate attack hit percentage chance?
Mar 5, 2021 at 11:00pm UTC
Ch1156
(1811)
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
Mar 5, 2021 at 11:01pm UTC
Mar 5, 2021 at 11:27pm UTC
againtry
(1614)
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.
Mar 6, 2021 at 12:24am UTC
Ch1156
(1811)
Perfect, thank you, I was making it way more complicated than it needed to be.
Registered users can post here.
Sign in or register
to post.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs