if(prob(80)) //There is an 80% chance that |
The idea would be to use this to determine ranges of item stats and item rarity. Would it work? Is there a less messy way to do this? Thanks for any help.
Am I correct in assuming the following?
The idea would be to use this to determine ranges of item stats and item rarity. Would it work? Is there a less messy way to do this? Thanks for any help. | ||
#2 Aug 12 2012, 11:09 am
|
||
That could work; pick() is a alternative to this however.
But I think I'd personally do something with while().
| ||
Actually, the if-else chain is better. It doesn't stop the rest of the procedure. Of course, he could've put the ifs on the same line as the elses, to save tabs.
| |
Kitsueki wrote:
Wouldn't that allow for multiple selections though? Like, there's an 80% chance that all of the above will be run? I only want to run one of them. Or maybe I'm not clear on what return does cause I never use it. lol NNAAAAHH wrote: That could work; pick() is a alternative to this however. The problem with that, is these if statements I'm referring to actually set the item rarity based on stats, using a simple calculation system I'm working on. So I wouldn't be able to use the rarity to determine the stats because stats come first. | |||
#5 Aug 12 2012, 11:40 am
|
|||
You intend to set the rarity based on the stats? I'd call this stat setting in on proc, and then assign the rarity in that case. 'return' stops the procedure. To be more specific, it forces the procedure to return. If you give it something to return, the result of the procedure will be whatever you return, so this for example..
Would output 1, because true_proc() returns 1, which evaluates the condition to be true. Using return in this case is just a method to stop the procedure so nothing else in it runs. Going with Kaiochao's suggestion, this could be the method to do what you want, I believe.
Hope this helps! | |||
#6 Aug 12 2012, 11:45 am
|
|
Alrighty, thanks! Cheers to about a years worth of coding *sigh*... Makes me wish I had a team.
| |
#7 Aug 12 2012, 2:16 pm
|
||
I would suggest reading this for a quick list of different ways to do probabilities:
http://www.byond.com/forum/?post=899306#comment2833013 I also think the pick() method is the most configurable, although you need a constant number of choices. Also, keep in mind:
| ||
DarkCampainger wrote:
I would suggest reading this for a quick list of different ways to do probabilities: Ok thanks. and yeah that's kinda the idea Wait a minute... I need a calculator... lol So I would need up to E to make items with a decent rarity. Cool. | ||
That would be how I handle that~
Just return if the condition is true after you do what you want within it, then move to the next one, as the next can only run if the first is false.