A question about % in formulas

I'm making a skill where it's supposed to go like this

"Skill chooses a random ailment to add to the ally"
I want it to choose one from a pool of ailments and go with that, but im not sure how to do that
I Googled "RPG Maker MV random state":

That should work fine, but it depends on your desired states being in sequential IDs. If they're not, you can do something like:
Code:
b.addState([2, 5, 10, 13, 24, 59][Math.randomInt(6)]); damage formula here

If the skill doesn't do damage, but only applies the state, then you can use the answer higher up in that linked thread using Yanfly's After Eval notetags.
probably don't even need a plugin.
you can use the skill's after effect.

I don't remember how it would retain the battlers from the previous calculation, to access them to add the state, but they should be there somewhere. It only needs the right call.
that way you remove anything not related to the damage formula out of it.
.....you know... *as everyone SHOULD do*, whenever possible.
I don't remember how it would retain the battlers from the previous calculation, to access them to add the state, but they should be there somewhere. It only needs the right call.
As far as I know, MV does not. That's a variable that was added in MZ...to do it this way in MV, you'd have to do the whole rigmarole of making the skill inflict an invisible state on the target, then in the common event check every troop member until you find the state and do it to that battler.

Or use a plugin like Yanfly's Skill Core with a notetag in some part of it, or program the skill via Action Sequences.
@ATT_Turan IDK about MZ but at core level the battlers should be there somewhere, either in the battle manager, or the battle scene, I don't remember which.
the skill effect is processed right after the damage formula, so the objects shouldn't change until the next turn is processed.

IIRC that's a resource that some battle systems tap into for various purposes.
I mean, for rendering a turn order bar they have to pull the list of battlers from somewhere.
There's BattleManager._action._targetIndex but that requires a bit of coding knowledge to know how to use it as an index for the troop array. It also isn't reliably available at all given points of a battler's turn...caethyril gave a pretty thorough dissertation recently on how difficult it is to reliably retrieve the current target, wrote a whole little plugin function for it.

Original thread: https://forums.rpgmakerweb.com/threads/a-question-about-in-formulas.148587/