can anyone tell me the best way to randomize something with their being a percentage of it weighted on a side?
for example my game is to shoot some zombies, and i want their being a 40/30/20/10% chance of it spawning a certain type of zombie, here is the code that i have now
local percentage = math.random ( 0, 100 )
if percentage <=40 then
-- spawn weak zombie
else if percentage >40 or percentage <=70 then
-- spawn regular zombie
else if percentage >70 or percentage <=90 then
-- spawn fast zombie
else if percentage >90 then
-- spawn brutal zombie
is this the best way to do it?