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

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?
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.
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...?
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
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.

Original thread: https://forums.rpgmakerweb.com/threads/rpgvxa-status-likelihood-when-using-a-add_state-x-in-damage-formula.111419/