[RPGVXA] Status likelihood when using a.add_state(x) in damage formula?

FirestormNeos

Veteran
Veteran
Joined
Jul 23, 2019
Messages
178
Reaction score
128
First Language
English
Primarily Uses
RMMV
When using a.add_state(statenumber) to a skill, how do i specify the chance of it happening?

I have a playable class in the project I'm working on where almost every skill you use has a low chance (somewhere between 1-10%, I haven't decided that part yet) of granting you a status buff that basically functions like a berserk. Since this includes attacks, I'll be needing to use a.add_state(insertstatenumberhere) for those skills. However, I don't know how to do that, if that's even possible to do without scripts/plugins.

Anyone got any ideas for this?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
When using a.add_state(statenumber) to a skill, how do i specify the chance of it happening?
You do not. At least not within that method. The method you mentioned applies a state, it does not perform calculations for you. Any particular chance to add the state has to be calculated before using that method.

Here is an example
Code:
chance = rand(100)
a.add_state(your_state_id) if (chance >= percentage_of_being_applied)
The code above stores a random number from 0 to 100 into a variable, then only adds the state if that number is greater than or equal to a certain value (percentage_of_being_applied). Keep in mind that in this case, percentage_of_being_applied is an integer. If there is a 65% chance of the state being applied, its value is going to be 65. If you want to use floating point numbers (0.65 in my example), you have to use rand without passing any parameter to it. To learn more about rand in ruby you can check the documentation.

Here is an example with a floating point value
Code:
chance = rand
a.add_state(your_state_id) if (chance >= chance_of_being_applied)
In this case chance_of_being_applied has to be a float value. In this case you could even use "greater than" rather than "greater than or equal to" as there is little or no difference between the two options.
 

FirestormNeos

Veteran
Veteran
Joined
Jul 23, 2019
Messages
178
Reaction score
128
First Language
English
Primarily Uses
RMMV
You do not. At least not within that method. The method you mentioned applies a state, it does not perform calculations for you. Any particular chance to add the state has to be calculated before using that method.

Here is an example
Code:
chance = rand(100)
a.add_state(your_state_id) if (chance >= percentage_of_being_applied)
The code above stores a random number from 0 to 100 into a variable, then only adds the state if that number is greater than or equal to a certain value (percentage_of_being_applied). Keep in mind that in this case, percentage_of_being_applied is an integer. If there is a 65% chance of the state being applied, its value is going to be 65. If you want to use floating point numbers (0.65 in my example), you have to use rand without passing any parameter to it. To learn more about rand in ruby you can check the documentation.

Here is an example with a floating point value
Code:
chance = rand
a.add_state(your_state_id) if (chance >= chance_of_being_applied)
In this case chance_of_being_applied has to be a float value. In this case you could even use "greater than" rather than "greater than or equal to" as there is little or no difference between the two options.
Thank you for replying so quickly! So can all of this go into the damage formula of the appropriate skill using semi-colons for line-breaks, or...?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Yes, it can, provided that you use semicolons as line breaks. Since VX Ace formula box is quite small, I recommend using variables with shorter names and removing unnecessary spaces (example below). I also recommend using the floating point version of the rand method, this will effectively save 3 characters (the method itself takes 5 less characters, but then you need a floating point value later, which requires a leading "0.").

In this example I am using state 7 with a percentage of 65%, change them to fit your needs.
Code:
r=rand; a.add_state(7) if (r>=0.65); formula_goes_here
 

FirestormNeos

Veteran
Veteran
Joined
Jul 23, 2019
Messages
178
Reaction score
128
First Language
English
Primarily Uses
RMMV
Yes, it can, provided that you use semicolons as line breaks. Since VX Ace formula box is quite small, I recommend using variables with shorter names and removing unnecessary spaces (example below). I also recommend using the floating point version of the rand method, this will effectively save 3 characters (the method itself takes 5 less characters, but then you need a floating point value later, which requires a leading "0.").

In this example I am using state 7 with a percentage of 65%, change them to fit your needs.
Code:
r=rand; a.add_state(7) if (r>=0.65); formula_goes_here
Thank you, finally figured out what was keeping the state from being applied. The skills now work pretty much perfectly.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,035
Messages
1,018,459
Members
137,821
Latest member
Capterson
Top