Jump to content
  • 0

Calculating chances below 1%


Everade

Question


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  192
  • Reputation:   43
  • Joined:  12/13/11
  • Last Seen:  

I'm looking for a way to calculate chances below 1% which i'm able to vary upon an if check.

If i'm not mistaken then .@ temporary variables are not able to store decimals?!

 

So for example:

if( .@legend >= 1 ) { .@chance = 0.18; }else{.@chance = 0.1}

if ( rand(100) < .@chance ) { getitem 512,1; }
Or would it also workout if i simply set rand(1000) < .@chance

while chance is set to 1 for instance.

I guess that would be 0.1% ?
Edited by Everade
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


if ( rand( 10000 ) < 100 ) {

// below 1.00%

}

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

Only whole numbers can be stored so use 10000 for 100% so for example you have chance of 5.67% which will be a value 567 if you want to show values in a mes you convert to % by doing "+567/100+"."+567%100+"

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   11
  • Joined:  12/06/11
  • Last Seen:  

if ( rand( 10000 ) < 100 ) {
   // below 1.00%
}

Thanks though.

Edited by Keysito
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...