Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Radom Variable [SOLVED]

Okay, I'm trying to make a minning/smithing system using common events and I only need to know one thing: How do you set a random variable? You know like you have a/n x% chance to get item y and a/n d% chance to get item w.

The only thing that would make the base stats differ is what kind of pick axe you are using and maybe where you are.
 
Oh, well. I should probably have clicked the button first. Although I naver have used variable's before. So would I creat a variable for each item? Seting the random button for the percentage you would you will find said item?
 
I don't think that you would need to. If you want to check if several different items show up, you can just re-use the variable. If you want to make one roll with several possible results, you definitely only need one variable.
 
Okay, let me explain how this works since I am still confused.

- You have four ores: Copper, Silver, Gold, and Mythril.

- Each item has a certent percentage in which you can find said item. Ex. 70-90% chance to find copper.

How would one go about doing that?
 
ShadowMainZERO":11sct894 said:
Okay, let me explain how this works since I am still confused.

- You have four ores: Copper, Silver, Gold, and Mythril.

- Each item has a certent percentage in which you can find said item. Ex. 70-90% chance to find copper.

How would one go about doing that?
You set a variable to a random number from 1 to 100. Then, you use a conditional branch to see of the variable is within a certain range of values (for a 70% chance to find something, you need the variable to be anywhere from 1 to 70 to get whatever you find.)
 
ShadowMainZERO":308wphr9 said:
Okay, I get that, mostly. The only thing I don't understand is the conditional branch to check the value of the variable. Wouldn't the variable set from,for a 70-80% chance, 70 to 80?

depends what you mean. If you are doing it DnD style, then you generate a random variable and the outcome will be changed depending on what the variable is. E.G., in DnD you roll a die and, if the die if 1-90, you get one thing, and the rest may give you different results depending on the exact number rolled. (Just an example) If you want a straight out 70% chance, then you generate a number from 1 to 100, and any value between 1 and 70 will result in the 70% being true.
 
Seams simple enough. Although, what if I were to use multiple variables in one event how would I make it so I dont get the same one?

I did the first part okay. *sigh* Now, one last thing then I what about using variables to determin how many of an item you have in stock?
 
Sometimes RMXP.org seems to do that.

Anyway, which second question do you mean? If it's "How can the game see that and not let them make 5 copper bars," the answer is "With Conditional Branches."
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top