Hello everyone, so I have a little problem with my code. I'am creating a game Moving@ which is rogue-like based, and I followed tutorial of libtcod+c++, so I managed to complete that and continue developing this game, so far it was good, until more items came out. I have an if statement with a lot of else if statements, as I read about spawn rate it's easy to use for example random(1,100)>1 has a chance of one, that is pretty simple but then a lot of if elseif comes out there is one problem. Then one of the if or elseif is correct, if statement starts from the beggining, and not even tried to check, for example I set all the random numbers to random(1,100)>50 which is 50% of spawn but still who is first in elseif statement, that one get's spawned. Here is a code:
if ( rng->getInt(0,100) < 50)
else if (rng->getInt(0,100) < 50)
else if(rng->getInt(0,100) < 50)
else if(rng->getInt(0,100) < 50)
else if(rng->getInt(0,100) < 50)
else if(rng->getInt(0,100) < 50)
else if(rng->getInt(0,100) < 50)
bunch of them
So Please Help Me :)