Good evening, how do I make a random number with percentage? I want to draw a number between 1 and 5, but it has to have a 50% chance of getting number 2, how do I do that?
RandomInFloatRange(1,5) thats a lot of changes
I know how to do a random draw, just open a random(5)+1 Okay, there will be a number between 1 and 5, but what about the percentage%? is there a way?
Simple rules if 1=0% then 5=100% and 2.5=50% so do a randomInFloatRange(1,5) and if the result is nearly 2.4,2,5 or 2,6 you can consider that as 50% then you just show a message with a condition
if result >2.3
if result <2.7
Set text messsage you got 50%
This might work.
Pick a number between 1 and 9. If it’s greater than 5 then make it 2. You have the normal chance of 1-5 plus 4 additional chances in 6,7,8,9.
R >5 | variable r=2
That would give you a 5/9 which is more like 55%. A true 50% would be a little more complicated. Is that close enough?
The way I’ve done this:
First event: Your conditions here >>> Set a variable to the value of RandomInRange(1,100) Separate event (or subevent): Value of the variable is > 50 >>> set a result variable as 5 Then say you want 20% for 4, 10% for 3, 15% for 2, 5% for 1. You'd have another separate event (or subevent) Value of the variable is <= 50 (no actions) (Subevent 1) Value of variable is >30 >>> Set a result variable as 4 (Subevent 2) Value of variable is >20 >>> Set a result variable as 3 Value of variable is <=30 (Subevent 3) Value of variable is > 5 >>> Set result variable for 2 Value of variable is <= 20 (Subevent 4) Value of variable <= 5 >>> Set result variable for 1
You’re now working with a normal percentage (1-100), and have weighted the results.
Thanks, problem solved