| 07-04-2004, 09:53 AM | #1 |
iam making a Life of a peasent style map but its sort of different, iam making it so every 2 minutes their is a chance a giant crab monster appears, what i cant figure out is how to make a chance that it wont happen?, so basicly i need a "Random" action |
| 07-04-2004, 12:44 PM | #2 |
Depending on how high % chance for the monster to appear you want you'll have to use Math - Random Number between 1 and 100, if you want a 1% chance that is. Do it like this: Set ChanceOfCrapAppearing = Math - Random Number between 1 and 100 If ChanceOfCrapAppearing = 1 then Create Unit else Do Nothing. This way in 99 out of 100 cases, the monster wont appear. Say you want a 50 % chance of him appearing just use random number between 1 and 2. |
| 07-04-2004, 09:00 PM | #3 |
thanks milkman that helps alot |
| 07-05-2004, 09:52 PM | #4 |
There have been some trouble with using random number with low numbers- the results are not always very random... That's why it is suggested you use a higher number like 100 and if you want a 50-50 chance, just do "if randomNumber smaller than or equal to 50 then create crab..." Of course, using this every 2 minutes, you must be careful: true, if you have, let's say, 25% chance of the crab appearing, that would mean you get, on average, one crab every eight minutes; but that's just the average, with some bad luck you could get 3 crabs in 6 minutes, now if batteling these giant crabs takes longer than that, you could get overrun. Always be careful when using statistics :) |
