(RMMV) Tie chance to inflict status ailment to a formula

Hello,

It seems easy to create skills that apply status effects at a fixed probability, i.e. 80%, 100%, etc. (luck stat shenanigans notwithstanding). But is there a way to have that chance be calculated by a formula instead? Something like, say:

50 * ((1 / b.mdf) * a.mat) = % chance to add state

That is, have a chance to apply a state in addition to regular damage (calculated by a separate damage formula), not replacing it.

I assume I'm going to have to edit some .js file to accomplish this, unless this is just not natively possible. If that is the case, are there instead any plugins that would allow me to do this?
Sure. Get Yanfly's Skill Core, then you can do something like:
Code:
<After Eval>
if (Math.randomInt(100) <= 50 * 1 / target.mdf * user.mat)
    target.addState(ID);
</After Eval>

randomInt() generates a random number from 0 to the provided maximum value, exclusive. So you'll get 0-99 with <= which should work the same as 1-100 with <.

Replace ID with the ID of your state, no leading zeros.
Sounds good. I'm already using Yanfly's Skill Core, so that will be convenient.

After some cursory testing, it seems to work. Thank you very much for the help.
Great! Please see my slight edited correction above re: randomInt(). I had a brain fart earlier...haven't coded in a week 😛
Don't know if I should make a new thread for this, but I have another question that's very similar to my initial one:

It's possible to make skills that temporarily buff an entity's parameters (i.e. skill that makes ATK go up for five turns). As far as I can tell, the amount by which a parameter increases via that method is tied to certain percentage thresholds. But is it possible to, once more, have that increase be determined by a formula? Something like:

b.[target parameter] * 0.3 * ((1 / b.[target parameter]) * a.luk) = amount added to b's [target parameter]


Alternatively, if I were to instead have a skill apply a state that buffs ATK for a flat 20% while it's on, is it possible to have a formula calculate the amount of turns that state stays applied? Like:

round(3 * ((1 / b.atk) * a.luk)) = amount of turns the state is applied

Sorry for all these inane math questions. My javascript skills are virtually nonexistent.
Don't know if I should make a new thread for this, but I have another question that's very similar to my initial one:

It's possible to make skills that temporarily buff an entity's parameters (i.e. skill that makes ATK go up for five turns). As far as I can tell, the amount by which a parameter increases via that method is tied to certain percentage thresholds. But is it possible to, once more, have that increase be determined by a formula? Something like:

b.[target parameter] * 0.3 * ((1 / b.[target parameter]) * a.luk) = amount added to b's [target parameter]


Alternatively, if I were to instead have a skill apply a state that buffs ATK for a flat 20% while it's on, is it possible to have a formula calculate the amount of turns that state stays applied? Like:

round(3 * ((1 / b.atk) * a.luk)) = amount of turns the state is applied

Sorry for all these inane math questions. My javascript skills are virtually nonexistent.
Base Parameter Control should allow you to do this.
Base Parameter Control should allow you to do this.
Unless you're thinking of something fancier than I am, I don't believe so. The state notetags in Base Parameter Control only allow you to specify a static value (either as a flat value or a percentage).

To use an eval/calculated value, you'd need to use something like Quasi Param Plus or Eli's Dynamic Parameters.
Unless you're thinking of something fancier than I am, I don't believe so. The state notetags in Base Parameter Control only allow you to specify a static value (either as a flat value or a percentage).

To use an eval/calculated value, you'd need to use something like Quasi Param Plus or Eli's Dynamic Parameters.
Does buffrate not allow code input?
Does buffrate not allow code input?
I only see that referenced in the plugin parameters that calculate the actor parameters. It appears to be a reference to the default paramBuffRate(), you can just adjust where it goes in the calculation.

I don't see a way to use that to have a specific state alter a parameter by a dynamically-calculated value. But maybe I'm missing something.
Thanks for talking it through with me and providing me with inspiration. I woke up today and had new ideas.

This isn't perfect at all, in fact it's probably quite inelegant, but what I am doing right now is use Yanfly's skill core, and based on the previous code example, I'm running this:

JavaScript:
<After Eval>
let x = (1 / target.atk) * user.luk;
if (x < 0.4)
    target.addState(11);
else if (x < 0.7)
    target.addState(12);
else if (x < 1.0)
    target.addState(13);
else if (x < 1.4)
    target.addState(14);
else if (x < 1.8)
    target.addState(15);
else if (x < 2.5)
    target.addState(16);
else
    target.addState(17);
</After Eval>
This applies one of seven different instances of a state (increasing in intensity and length) to the target, depending on certain value thresholds WRT the ratio between the user's luck and the target's target parameter. To make sure you can't "double up" (say, by applying a stage 3 buff that puts you below a threshold and then applying a stage 2 buff on top of it), I'm also removing all instances of this state in the skill's setup action.

This isn't exactly what I wanted, and there are a few issues, but it's a close enough and functional approximation. It would be cool if I could somehow tie Yanfly's Base Parameter Control plugin into this and have the calculation based on the target's BASE parameter instead of the total, but I don't know if that is possible, and if it is, I don't know how to do it.
This applies one of seven different instances of a state...It would be cool if I could...have the calculation based on the target's BASE parameter instead of the total, but I don't know if that is possible, and if it is, I don't know how to do it.
Why not simply use one of the two plugins I listed above to do that? Seems like that would be much less convoluted.
Why not simply use one of the two plugins I listed above to do that? Seems like that would be much less convoluted.

Well, the main reason is that I don't really fully... grasp javascript. I can kind of finagle my way through a very basic if clause tree, but I don't know the data structure, or what all the values and entities are called, the whole thing is very mystifying to me, and I basically have no idea where I would even start.

Like, I installed Eli_DynamicParameters and looked into it, but it seemed like you could only apply notetags to weapons, armors, and states, and by putting a template on a state I have no idea how to tell it to take data from the source of that state, instead of just the bearer of it.

The other reason is that I seem to have a plugin conflict with QPlus, which QParams is dependent on. Whenever I activate it, I lose the ability to move around, kind of as if an unchecked Autorun event was executing. I admit I haven't looked into where the conflict is coming from yet.

So uh, yeah, the gist is pretty much that I don't know how to do it.
Then ask for help - you already have the thread going 😛

Kind of the whole point of using plugins is you don't have to know JavaScript. That's why they provide you with notetags and you just follow the format of it to do what you want.

Now, you might need some here because you want to reference one of the caster's parameters in the equation, but that really shouldn't stop you from being able to start on making something even if you have to tweak the formula later.

The other reason is that I seem to have a plugin conflict with QPlus, which QParams is dependent on.
Are you sure? It doesn't say you need QPlus in the plugin thread, nor in the plugin instructions, and I don't see any check for it in the plugin code.

The problem for your specific formula is neither of those plugins appears to provide a reference point for the existing value of the target's parameter.

Quasi isn't around anymore, but perhaps @Eliaquim can suggest how to implement this in his plugin.
Are you sure? It doesn't say you need QPlus in the plugin thread, nor in the plugin instructions, and I don't see any check for it in the plugin code.

It said so on the website, but I suppose that could be an error.
Oh. That's a much newer version than on the forum thread, which is what I had downloaded and looked at.
Hi there!
Don't know if I should make a new thread for this, but I have another question that's very similar to my initial one:

It's possible to make skills that temporarily buff an entity's parameters (i.e. skill that makes ATK go up for five turns). As far as I can tell, the amount by which a parameter increases via that method is tied to certain percentage thresholds. But is it possible to, once more, have that increase be determined by a formula? Something like:

b.[target parameter] * 0.3 * ((1 / b.[target parameter]) * a.luk) = amount added to b's [target parameter]
- This is certainly possible with my Dynamic Parameters. If you managed to apply a state to the battler when using the skill, then you can have a dynamic parameter template into this state to increase its attack using a formula.
Spoiler: Screenshots
Creating the dynamic template, and writing down the formula on the Attack parameter. But instead of "b" and "target", you can just use the "this" keyword to refer to the battler that has this state.
a.png


And here applying the Dynamic Parameter template to the state:
b.PNG


Alternatively, if I were to instead have a skill apply a state that buffs ATK for a flat 20% while it's on, is it possible to have a formula calculate the amount of turns that state stays applied? Like:

round(3 * ((1 / b.atk) * a.luk)) = amount of turns the state is applied

Sorry for all these inane math questions. My javascript skills are virtually nonexistent.
- Now, for that one, I'm not sure. The dynamic parameters are supposed to return a number that will change the parameter chosen. But maybe you can do a hack.

You may not be able to change the amount of turns the state will last on the battler. But, you may be able to remove that state based on a condition.
The thing is, you will need a way to check for the exact moment you want to do that in battle. I am really not familiar with the battle flow code, so maybe other people could help you with that. But here is something that I was thinking about. It's kind of a pseudo-code, don't know if it will work. You can put it on any parameter inside a dynamic template parameter. But just use one.

JavaScript:
if($gameParty.InBattle() && BattleManager.isInTurn()){
    if(BattleManager.actor() === this){
        const chanceRemoveState = Math.randomInt(100)
        if(chanceRemoveState > 50){
            this.removeState(stateId)
        }
    }

    0
}else{
    0
}

My intention on the code above is to check if the game is on a battle, then check if is the actor's turn. If it is, it will have a chance of removing the state from the actor by 50%.
Now, hahaha, this is really a long shot.
But that also gives me some plugin idea, probably for MZ though.

Like, I installed Eli_DynamicParameters and looked into it, but it seemed like you could only apply notetags to weapons, armors, and states, and by putting a template on a state I have no idea how to tell it to take data from the source of that state, instead of just the bearer of it.
On the first answer, you just need to put the template on the state as I have shown, and the plugin will make the rest.
Thanks, Eli!

But instead of "b" and "target", you can just use the "this" keyword to refer to the battler that has this state.
I didn't look at your code at all, so I didn't see that the parameter formulae belonged to the battler.

- Now, for that one, I'm not sure.
The second part of the question kind of got lost in all the discussion of the parameters, but this you could use Yanfly's Buffs & States for.
Code:
<Custom Apply Effect>
target.setStateTurns(stateId, Math.round(3/target.atk*origin.luk));
</Custom Apply Effect>
Creating the dynamic template, and writing down the formula on the Attack parameter. But instead of "b" and "target", you can just use the "this" keyword to refer to the battler that has this state.
View attachment 268978

I hope I'm not misunderstanding, but by applying a template of "((1/this.atk) * a.luk) * 0.3" (for atk) to the state, the next time that attack parameter is referenced (either through attacking in battle or looking at the parameters in the menu), I'm getting a "Range Error: Maximum call stack size exceeded" error and crash. Seems to be happening regardless of parameter size, as it's happening both with really high and really low numbers.

I don't know, could the problem be the "a."? What would be the correct way to reference the actor who inflicted the state?
I worry that my question was so inept, it shut down the entire conversation. I hope that's not the case.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-tie-chance-to-inflict-status-ailment-to-a-formula.158972/