# Any way to set up a probability?

#### Foxx042

##### Villager
I would like to set up something like stealing a sword but having a probability of getting caught how would i go about doing this?

#### PoptartPresident

##### Veteran
So for anything involving random chance/probability, you will need to do this in your event settings:

Game Progression (1st page) > Control Variables > Random (near the bottom)

Then decide what number range you want to work with. (From x to y)
What will happen is that the game will choose from that number range at random when the event runs, and set that corresponding variable to that randomly picked number.

You can then use Conditional Branches for all the If statements to make things happen or not happen.

Remember the bigger the range you give, the lesser chance things will happen.
For instance, if you have 5 numbers, then there will be a 1/5 chance one of those 5 numbers will be chosen, and so forth. It could be something to keep in mind so you can decide how rare or often you want something to occur randomly.

#### Foxx042

##### Villager
So for anything involving random chance/probability, you will need to do this in your event settings:

Game Progression (1st page) > Control Variables > Random (near the bottom)

Then decide what number range you want to work with. (From x to y)
What will happen is that the game will choose from that number range at random when the event runs, and set that corresponding variable to that randomly picked number.

You can then use Conditional Branches for all the If statements to make things happen or not happen.

Remember the bigger the range you give, the lesser chance things will happen.
For instance, if you have 5 numbers, then there will be a 1/5 chance one of those 5 numbers will be chosen, and so forth. It could be something to keep in mind so you can decide how rare or often you want something to occur randomly.
okay so i would say set a guard up with the variable then the sword with the conditional branches?

#### PoptartPresident

##### Veteran
okay so i would say set a guard up with the variable then the sword with the conditional branches?

So I'm not exactly sure what your game/eventing looks like. The way I explained it was more so a general method for how to set up a probability.

Would you mind posting a screenshot and going into more depth? Depending on how you run the events, it can effect how the event works.

I can't exactly answer your question since I don't know what your game/event looks like for the guard and sword situation.

#### Foxx042

##### Villager
So I'm not exactly sure what your game/eventing looks like. The way I explained it was more so a general method for how to set up a probability.

Would you mind posting a screenshot and going into more depth? Depending on how you run the events, it can effect how the event works.

I can't exactly answer your question since I don't know what your game/event looks like for the guard and sword situation.

So am i getting the set up right or no not at all?

#### PoptartPresident

##### Veteran
Okay, I see what's going on...correct me if I'm wrong but you're making it a choice to steal from the shopkeeper or not?

In that case, everything I described above, put that under the "Yes" branch of your choice.

I'm assuming also that your chosen variable is 0001 (Did I get caught or not?).
So what you will do is under your Yes branch for the choice, Control Variable 0001 such that it goes for Random, and again, choose a range. (I don't know how likely you would like for it to happen, but that's up to you).
You probably don't need IF/Conditional branches right underneath since you already have your guard set to happen if Variable #0001 = 1. So that's fine.

And yeah, when the randomly chosen variable happens to be the value of 1, then that guard event in your 2nd screenshot should become visible.

You do have the right setup, just make sure you put the randomness variable to happen underneath the Yes branch. After all, don't want the guard to activate when you choose not to steal.

#### Foxx042

##### Villager
so the guy under the weapon rack on the right of the screenshot i want to have a probability of him catching you stealing the sword off the rack in the upper right hand corner of the screenshot

#### Foxx042

##### Villager
Okay, I see what's going on...correct me if I'm wrong but you're making it a choice to steal from the shopkeeper or not?

In that case, everything I described above, put that under the "Yes" branch of your choice.

I'm assuming also that your chosen variable is 0001 (Did I get caught or not?).
So what you will do is under your Yes branch for the choice, Control Variable 0001 such that it goes for Random, and again, choose a range. (I don't know how likely you would like for it to happen, but that's up to you).

And yeah, when the randomly chosen variable happens to be the value of 1, then that guard event in your 2nd screenshot should become visible.
no not the shop keeper i mean it is his items but i want the "Thief guard" to have a chance of catching you in the act of stealing

#### PoptartPresident

##### Veteran
Yup.

You have the right setup. Just Control Variable #0001 for Random (range from x to y) under your Yes branch.
What will happen is if the player chooses Yes, then variable #0001 will be given a value that is randomly selected from your x to y range.

Since you have the thief guard set to happen if variable #0001 = 1, then including 1 in your x to y range is what you want. So perhaps set the range from 1 to...(some other ending value depending on how often you want this to occur).

What will happen is, if the variable #0001 is not set to 1 from random chance, then the guard event will not happen. But if it does happen to be set to 1, the thief guard event will appear.

That is when you can event your thief guard to catch the player.

#### Foxx042

##### Villager
Yup.

You have the right setup. Just Control Variable #0001 for Random (range from x to y) under your Yes branch.
What will happen is if the player chooses Yes, then variable #0001 will be given a value that is randomly selected from your x to y range.

Since you have the thief guard set to happen if variable #0001 = 1, then including 1 in your x to y range is what you want. So perhaps set the range from 1 to...(some other ending value depending on how often you want this to occur).

What will happen is, if the variable #0001 is not set to 1 from random chance, then the guard event will not happen. But if it does happen to be set to 1, the thief guard event will appear.

That is when you can event your thief guard to catch the player.
okay so then i just set up the sword in a conditional branch with it asking are you sure you want to steal this and if you choose yes and try and take the event will appear if i have set 1 or greater for the variable? or am i misunderstanding?

#### PoptartPresident

##### Veteran
okay so then i just set up the sword in a conditional branch with it asking are you sure you want to steal this and if you choose yes and try and take the event will appear if i have set 1 or greater for the variable? or am i misunderstanding?

Almost!
I think you are getting mixed up Show Choice and Conditional Branch, and the inequality.

So, on your Steal a Sword event, it will be just like your screenshot where it asks if the player wants to steal the sword or not. (The Show Choice, not Conditional Branch).

If the player chooses Yes, that is when you have Variable #0001 randomly chosen from the range of 0 to (y) through Control Variable.

If it happens that Variable #0001 gets randomly chosen to equal 1 OR HIGHER, then that is when your Thief Guard event should happen, just like in your 2nd screenshot. (This is because you already have the checkbox in the upper left ticked for if #0001 >= 1). That is when you should event your Thief Guard to do something since Variable #0001 is greater than or equal to 1.
If the variable happens to be something below 1, the Thief Guard won't happen.
(Remember, you can include 0 in your range)

If it's still confusing, try imagining the scenario to play out by a 50/50 chance.
In that case, you would want to have Variable #0001 set to randomly pick from the range of 0 to 1.
This way, the variable can only be set to either 0 or 1.
And using the same inequality logic, if #0001 = 0, then the Thief Guard shouldn't happen.
But if it = 1, then the Thief Guard WILL happen because 1 is a value that is greater than OR equal to 1.

This would effectively be a coin toss event, but I don't know if you want it to be an event that can happen 1/2, 1/3, 1/4 chance....etc. That range is up to you to decide.

=================

Also, for that inequality in the checkbox in your 2nd screenshot, it can be tricky to read, but try to read it as:
"Variable #0001 Greater than or Equal to X", (where X is some Number)
This is harcoded this way so that if you want more variety with variable values, it's there for you to cover ranges that aren't counted in sequence like 1, 2 ,3, 4....etc.

This can be greatly beneficial for an instance where you have an event that is going to happen one way if Variable#0004 >= 2....then the next page will have something different happen if Variable#0004 >=5. So that would mean if Variable #0004 would still trigger the page that comes before 5 if the value was 2, 3, or 4. (Aka, it covers values 2-4).

You can use this to make events more likely than others.

Although you already have it setup correctly.
Just something to keep in mind for the future!

Last edited:

#### Foxx042

##### Villager
Ill do that cause that makes alot of sense thank you and thank you for the future tips always helps with me being a beginner and all.

#### PoptartPresident

##### Veteran
Ill do that cause that makes alot of sense thank you and thank you for the future tips always helps with me being a beginner and all.

Yeah no problem!
Probability in RPG Maker can get messy really quickly if you don't use those inequality correctly.

Here's one more example if it helps you in the future:
So let's say your have you Thief Guard Event set to happen if Variable #0001 >= 1.

Let's also say you have created a random range of Variable #0001 so that it will pick from 0-3.
(So 0, 1, 2, and 3 are the four possible values the game will randomly assign Variable #0001).

If Variable#0001 = X scenarios:

0 >= 1? NOT TRUE. Thus, the event will not happen since 0 is not greater than or equal to 1.
1 >= 1? TRUE. So the event will run since 1 >= 1. (1 happens to equal 1 in this case).
2 >= 1? TRUE. So the event will run since 2 >=1. (2 is greater than 1)
3 >=1? TRUE. So the event will run since 3 >=1. (3 is greater than 1).

What this means is that in the range you just picked....that means 3 out of the 4 choices will make the Thief Guard event run.
So that means 3/4 = 0.75....which makes the likelihood of the thief guard catching you 75% if the player decides to steal the sword. That is quite a high chance of that happening, and probably not worth the risk IMO if the guard can harm you.

Everything probability-wise is based on the range you choose, and its relation to the inequality, so keep this in mind since you cannot avoid the inequality.

#### Foxx042

##### Villager
Yeah no problem!
Probability in RPG Maker can get messy really quickly if you don't use those inequality correctly.

Here's one more example if it helps you in the future:
So let's say your have you Thief Guard Event set to happen if Variable #0001 >= 1.

Let's also say you have created a random range of Variable #0001 so that it will pick from 0-3.
(So 0, 1, 2, and 3 are the four possible values the game will randomly assign Variable #0001).

If Variable#0001 = X scenarios:

0 >= 1? NOT TRUE. Thus, the event will not happen since 0 is not greater than or equal to 1.
1 >= 1? TRUE. So the event will run since 1 >= 1. (1 happens to equal 1 in this case).
2 >= 1? TRUE. So the event will run since 2 >=1. (2 is greater than 1)
3 >=1? TRUE. So the event will run since 3 >=1. (3 is greater than 1).

What this means is that in the range you just picked....that means 3 out of the 4 choices will make the Thief Guard event run.
So that means 3/4 = 0.75....which makes the likelihood of the thief guard catching you 75% if the player decides to steal the sword. That is quite a high chance of that happening, and probably not worth the risk IMO if the guard can harm you.

Everything probability-wise is based on the range you choose, and its relation to the inequality, so keep this in mind since you cannot avoid the inequality.
okay thanks a ton it works but i am have another problem anyways you can help me fix it so it works pretty much a 50\50 chance of getting caught but how would i make it where you do get the sword if he doesnt notice cause anything i can think of or do isnt working

#### PoptartPresident

##### Veteran
okay thanks a ton it works but i am have another problem anyways you can help me fix it so it works pretty much a 50\50 chance of getting caught but how would i make it where you do get the sword if he doesnt notice cause anything i can think of or do isnt working

Well that just depends on how you're eventing it.

When the player chooses Yes to steal the sword under the Show Choice....do they obtain the sword weapon, despite whatever happens with the Thief Guard event?

If not, that should just be as simple as putting "Change Weapons" under the Party tab on Events Page 1. And set it to where you get +1 sword when they choose Yes.

I would imagine when the player chooses to steal the sword, they obtain the sword regardless of how the guard reacts. But really how the guard reacts (that is, if they do at all), depends on what you want?

#### Foxx042

##### Villager
Well that just depends on how you're eventing it.

When the player chooses Yes to steal the sword under the Show Choice....do they obtain the sword weapon, despite whatever happens with the Thief Guard event?

If not, that should just be as simple as putting "Change Weapons" under the Party tab on Events Page 1. And set it to where you get +1 sword when they choose Yes.

I would imagine when the player chooses to steal the sword, they obtain the sword regardless of how the guard reacts. But really how the guard reacts (that is, if they do at all), depends on what you want?
I'm trying to get it where it will roll the dice on if the guard notices you stealing the sword if he does not i would like to take and put the item in your inventory if he catches you i want to give choice to either put it back or fight the guard for it

#### ATT_Turan

##### Forewarner of the Black Wind
I'm trying to get it where...
I think what will help you is to just plan out your event. It seems like you're confusing yourself in your head by typing it out using sentences and grammar - do what we call pseudo-code, where you just make a list.

Pretend you're writing instructions for someone, or making a flowchart.

Take the sword
50% chance did the guard notice you?
- yes
-- put the sword back?
-- yes
--- you're done
-- no
--- fight the guard
- no the guard didn't notice you
-- add the weapon to inventory and you're done

So you simply write out a list of instructions like that, then go to RPG Maker and find the event command that corresponds to each line of instructions.

#### Foxx042

##### Villager
I think what will help you is to just plan out your event. It seems like you're confusing yourself in your head by typing it out using sentences and grammar - do what we call pseudo-code, where you just make a list.

Pretend you're writing instructions for someone, or making a flowchart.

Take the sword
50% chance did the guard notice you?
- yes
-- put the sword back?
-- yes
--- you're done
-- no
--- fight the guard
- no the guard didn't notice you
-- add the weapon to inventory and you're done

So you simply write out a list of instructions like that, then go to RPG Maker and find the event command that corresponds to each line of instructions.
No im not confusing myself i think im just missing a step but that would really help though especially noticing where i am messing up but this is exactly what im trying to do

The gaurd is on watch you go to the sword rack and an event is set up to steal the sword but i want the guard to have like a 50\50 chance to notice if he notices i want you to get into an altercation from either putting it back or fighting him to try and take it by force if he doesnt notice you i want you to take the sword like you were initially trying to do anyways ( steal ) the sword of the rack

#### PoptartPresident

##### Veteran
As ATT_Turan described, it would be best for you to list out what you want to happen, then try to make it yourself and test it in-game.

Making events happen is involving a creative thought process, and its easy to get lost in your own words.

But I think the way ATT listed out the main concept is accurate. It sounds like you will need some conditional branches after you take the sword to check if the guard will react to you or not, but how you go about doing that should be something you decide on.

Also, in the future, posting screenshots is always a major help in eventing processes. That way we can physically see possible errors/problems with the eventing logic you take.

#### ATT_Turan

##### Forewarner of the Black Wind
No im not confusing myself i think im just missing a step but that would really help though especially noticing where i am messing up but this is exactly what im trying to do
Okay, but then you proceeded to spend the rest of your post doing exactly what I said you shouldn't do, typing it out in a big sentence-less block of text again. (which, aside from not following my recommendation, is really hard for other people to read)

Look at the example I provided for you.

Is there some line in it you don't understand? Then ask about that specific thing.

### Latest Profile Posts

Now that I have linklists on large trees and cars, is there any theme that would interest you?
Debugging multiplayer issues... I'm having fun, right?

For just starting streaming on the 10th... Definitely not the worst.

Granted I need 333.34 hours a month on average to achieve money. So I don't really expect that, but it sure has helped my game dev go much faster.
Proud on how this map turned out.

I just finally fixed a huge problem that wouldn’t let my game load and would crash it.. I thought that I was gonna have to trash the project and start over lol