chance

  • tommig
    31st Mar 2011 Member 0 Permalink
    for an element im working on, i want it so that there is a chance that a certain reaction creates a pariticle, but not every time. what kind of code should i use to reduce the chance of the element being created?
  • PizzaPlatypus
    31st Mar 2011 Member 0 Permalink
    @tommig
    use before where it says the element being created if(rand1>()%5)
    the higher the number that I set as five the less likely it is.
  • Pilihp64
    31st Mar 2011 Developer 0 Permalink
    uhh i think you meant if(1>rand()%5)
  • PizzaPlatypus
    31st Mar 2011 Member 0 Permalink
    @cracker64
    yeah, I forget easily
  • tommig
    31st Mar 2011 Member 0 Permalink
    so, like this?..
    if((r&0xFF)==PT_ACID&& 1>rand()%5)
    part_change_type(i,x,y,PT_HYDR);
  • PizzaPlatypus
    31st Mar 2011 Member 0 Permalink
    @tommig
    or parts[i].type=PT_HYDR
  • tommig
    31st Mar 2011 Member 0 Permalink
    @PizzaPlatypus
    but it's right, yes?
  • PizzaPlatypus
    31st Mar 2011 Member 0 Permalink
    @tommig
    probably best to use parts[i],type=PT_HYDR
  • tommig
    31st Mar 2011 Member 0 Permalink
    something is wrong, because it was making to much hydrogen, so i lowered the percentage, yet it is still making hydrogen whenever acid touches metal.
  • PizzaPlatypus
    31st Mar 2011 Member 0 Permalink
    @tommig
    no, higher percentage makes less.