- Code: Select all
void chance(int percent)
{
i = round(rand(100));
if(i <= percent)
{
p = i;
}
}
then where ever your action is
- Code: Select all
chance(25);
if(i == P)
{
//do stuff
}
i guess this works, but it isn't really 25% it's kinda if the number is less then the number you picked out of a random number ranged from 0 - 100.....there has to be a better way to do this, or should i just go back to the good 'ol fashioned way?