Skip to content

Question about Randomness

Would this be a 15% chance for thie script to fire?
void main()
{
    // Add the randomness
    if(Random(100) >= 15)

{
ExecuteScript("script_here", OBJECT_SELF);
}
}

Comments

  • ForSeriousForSerious Member Posts: 466
    Close: if(Random(99) <= 15).
    Random can come out as 0 and you put greater than instead of less than.
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited October 2023
    ForSerious wrote: »
    Close: if(Random(99) <= 15).
    Random can come out as 0 and you put greater than instead of less than.

    Wouldn't it still just be: if (Random(100) < 15) ?
    Or: if (Random(100)+1 <= 15)
  • ProlericProleric Member Posts: 1,316
    @NeverwinterWights Either of your solutions will work as they give a 15% chance.

    The OP gives an 85% chance.

    @ForSerious if(Random(99) <= 15) gives a probability of 16/99 which is roughly 16.2%
  • TheTinmanTheTinman Member Posts: 74
    Just noticed my miss type. My bad.
    Would this also be a way to write it?
    d100()<=15
    
  • ForSeriousForSerious Member Posts: 466
    I knew I should have checked my math! Hehe, yeah there's a lot of ways to do it. d100 is fine too.
Sign In or Register to comment.