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
ID:179059
Feb 22 2002, 2:52 pm
|
|
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. |
mob/verb/Randomize()
var/random = rand(1,100)
if(random <= 10) // 10% chance
src << "There is a 10% chance of this happening!"