ID:179059
 
how do you make the game with a code check a percentage lets say 10% or 90%
like how do you make it to where 90% of the time it does something
and the other 10% it does something else
I have looked at the pick() but I can't quite get it to work without errors

please help
and thanks in advance
There are several ways to do this. Here's a simple (and probably inefficient) one.

mob/verb/Randomize()
var/random = rand(1,100)
if(random <= 10) // 10% chance
src << "There is a 10% chance of this happening!"
I usually write my own procs for "checking" random chances. Here's a sample one, for percentile checks, with "scaling" in place for extraordinarily high values.

proc/percent(target as num)
var/ceiling = 100
if (target >= 100) ceiling = target + 1 //always have at least a small chance of failure, diminishing as target increases.
if (rand(1,ceiling) <= target) return 1
else return 0


Then, at the appropriate place in your code, you put:

if (percent(10))

or whatever.
if(prob(90))// 90% chance
do something
else// 10%
do somethingelse