Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Probability of Success with Events

BlizZaga

Villager
Xy$
0.00
Hi, I need a little help with something. I have a cooking and fishing system in my game and would like to make a factor in success in getting a fish/cooking something. It's just something that's not too important but would add a little bit to my game. What I need to know is how to (when initiating "yes" for fishing or cooking) make it so there's a custom probability of failure or success.

In doing this, I'd like to create and use a system where characters have "traits" that affect the outcome of doing these actions. For example, if "intelligence" or "creativity" and "luck" was a trait, like in say, castlevania games where you have intelligence, luck, constitution (?) etc., it would raise or lower the probability that you would say, catch a bigger or different fish (that was a custom item) or making a dish more nutritious (another custom item) that gave you better health/magic increase.

So, in addition, if you had a certain character in your party that had better levels of these traits, you'd get better items to use for healing yourself (or even increasing characters likability of you), since, I might not use potions as a main item in my game, only food.

I'd like to know how and what to do to accomplish this. I have a basic understanding of variables, but don't know if making probability a factor is possible.
 

Run

Towns Guard
Xy$
0.00
Create two variables.
I called them probability and checkResult.

I set probability to 30, this number is the chance of them performing the action successfully, in this case, a 30% chance.

Use an event to set checkResult to a random number between 1 and 100.

Use a conditional branch event to see if the checkResult variable is less than the probability variable.
If it is, then the action was successful.

I'm unsure of how you're implementing traits, but essentially, you just have to set the probability variable based on those traits.
Lets say we want to give a chance at catching a rare fish.
First, store a value for the trait in a variable, in this example, luck.

If using luck for as a parameter belonging to a class, you can store the characters luck by going event->control variables->select variable to store it in->set->game data->actor->choose actor->choose luck parameter.
If not a parameter, then it's probably already a variable or has some other way to be stored as one.

You can then set the probability to a number based on that luck, for example, I'll assuming luck maxes out at 100, and I'll give them a chance equal to half of their luck. Meaning at max luck, they'll have a 50% chance.

event->control variables->select probability variable->set->luck variable
event->control vairables->select probability variable->Div->constant->2

This lets you set probability based on traits.
Of course this is just a basic approach to it, using scripts/plugins would make it much simpler to manage.
Just wanted to show that it's possible without them.
 

BlizZaga

Villager
Xy$
0.00
Create two variables.
I called them probability and checkResult.

I set probability to 30, this number is the chance of them performing the action successfully, in this case, a 30% chance.

Use an event to set checkResult to a random number between 1 and 100.

Use a conditional branch event to see if the checkResult variable is less than the probability variable.
If it is, then the action was successful.

I'm unsure of how you're implementing traits, but essentially, you just have to set the probability variable based on those traits.
Lets say we want to give a chance at catching a rare fish.
First, store a value for the trait in a variable, in this example, luck.

If using luck for as a parameter belonging to a class, you can store the characters luck by going event->control variables->select variable to store it in->set->game data->actor->choose actor->choose luck parameter.
If not a parameter, then it's probably already a variable or has some other way to be stored as one.

You can then set the probability to a number based on that luck, for example, I'll assuming luck maxes out at 100, and I'll give them a chance equal to half of their luck. Meaning at max luck, they'll have a 50% chance.

event->control variables->select probability variable->set->luck variable
event->control vairables->select probability variable->Div->constant->2

This lets you set probability based on traits.
Of course this is just a basic approach to it, using scripts/plugins would make it much simpler to manage.
Just wanted to show that it's possible without them.
Thanks a lot!
 

Run

Towns Guard
Xy$
0.00
I actually created a Success Checker plugin, it's in resources. It should help make stuff like this simpler.
 
Top