How to make a skill that reacts to state

Hello everyone, I hope you all are having a good day.

The title of the thread maybe a little bit confusing, I am way bad at explaining stuffs but I hope you all understand even just a little, if not I'm really sorry for my terrible explanation skills

I would like to make a skill that, upon detection of a certain state (let's say for example the enemy has Poison), it will remove it and change it with something else (a Mega Poison if you will).
If also possible, the same skill would change another state, for example Burning, it will remove that and change it into maybe a Mega Burning effect along with the Poison to Mega Poison shenanigan.

There's also this one skill that I would like to make and it's that the skill would inflict extra damage if an enemy has a certain state, let's say for example the enemy has a Burning state, the skill would remove that state and the skill would then deal extra damage.

I am fine, and also kinda preferable for me, if such trait is only achievable through Plugins, with Yanfly's ideally, but any else would be really okay.

I sincerely apologize in advance if I posted on the wrong board/wrong topic, and would be thankful if I am redirected to the correct one.

Thank you in advance!

EDIT: Changed Status Effect into State to maybe make things less confusing and more inline with RPG Maker MV terminologies and whatnot, hopefully I didn't made it worse though...
You can have the skill inflict an invisible state on the enemy, then link it to a common event that scans every enemy whether they're inflicted with the invisible state, and then whether they're inflicted with poison (as in the example), and if so remove it and inflict the new status. Then afterwards, wipe the invisible status from the enemy.

You should also be able to use the damage formula to get something like it done, but I'm not good enough with those to give an answer for that.
in this case the common event state method isnt needed. still often a good method though.
damage formula can do an if statement check.
if (b.isStateAffected(X)) b.removeState(X) b.addState(Y); formula
X
is poison state, Y is mega poison state, replace formula with the normal damage formula.

however damage formula's adding states ignore state resistance rates but since MV damage formulas have no size limit you could make a whole thing checking .isStateResist(n) and and could make a fake state rate using if Math.randomInt(100) < n
(i like using < (less then) for these so n = the apply rate instead of > (greater then) making n = fail rate)

for the extra damage skill would basicly be the same thing
if (b.isStateAffected(X)) formulaA : formulaB
formulaA is the boosted damage formula while formulaB is the normal damage formula


note that damage formulas while they can do ALOT in MV, they are also easy to break.
broken formulas appear as if they do nothing. so when making skills with long formulas its usually a good idea to make it piece by piece and battle test just to make sure each section works correctly before adding more to the formula. i usualy start off just having a flat damage number, if does no damage then means formula is flawed. then just change the flat damage into actual damage formula when got the rest of it working correctly.
If you have access to Yanfly's Buffs & States Core plugin, this kind of effect will be really easy to do with that too.
damage formula can do an if statement check.

Here is something I saw recently that's made me stop suggesting this:

@Shaz
wow, that explains issue had while back.
fk... there goes my weekend, gonna have to overhaul some crap now... /cry
Here is something I saw recently that's made me stop suggesting this:

The problem is that not using the damage formula for mechanics is it makes several things significantly more difficult to pull off. Like what if I want to add a state on the user and the target at once? What if I want to check what the skill did afterwards in the linked common event? Then there's a lot of convenience by putting stuff in the damage formula, rather than eventing a bunch of branches.
Personally, I never ran into problem with mechanics in my damage formulas, and I'm using a number of them. The article states it may cause issues if you're enable auto combat? Like, I don't even have that in my game.
Telling people to use plugins for something that technically works in the engine but gets screwed up by how weirdly the code of the program runs isn't really ideal.
Adding to Milenins solution, you can technically do this even without a common event:
- Make the invisible state block (state rate 0%) super poison
- Make regular poison "state resist" the invisible state
- Optional: Make super poison "state resist" regular poison (to automatically replace it)
- In your skills effects, first add the invisible state (1000%), then add super poison (if the invisible state goes through, then the target is not poisoned and the subsequent super poison is blocked)

Downside would be that it is technically possible to evade the invisible state even at 1000% application chance if the LUK difference between the user and the target is above 900.


Tiamat-86s solution is still applicable though, most of the time you can add the extra effects to the notebox instead of the damage formula if you are using Yanflys Skill Core Plugin for example:
Code:
<after eval>
if (b.result().isHit()) {
   // Extra effects from the damage formula
}
</after eval>
Edit: The sanitized code reads => if (b.result().isHit()) {

For the increased damage if a state is present, you can use something like
b.isStateAffected(StateID) ? (High Damage Formula) : (Regular Formula)
(as Tiamat-86 has suggested), and remove the state through your skills effects (skill effects are done after the damage is already calculated)

Edit 2, OT: Generally I would agree with Shaz/Yanfly that one should avoid this the damage formula if possible, not least to open up the option to utilize the formula to gage a skills effect not only for AI purposes, but also things like an automatic damage preview in the skills description for example.
It also requires one to utilize the damage formula in the first place, even if the skill is not supposed to do damage.
Definitely see Milenins point of course, I would have loved to see something like a "Script..." skill effect option.
The article states it may cause issues if you're enable auto combat? Like, I don't even have that in my game.

Yeah, but it's good to know about the issue. YOU might not be using auto battle, but if someone asks for help, do you check whether THEY are using auto battle before suggesting putting it into the damage formula?

Just something I never knew about before, and thought it was interesting, and that I should be careful about what I put into the damage formula and what I suggest to others as well.
If you have access to Yanfly's Buffs & States Core plugin, this kind of effect will be really easy to do with that too.
I do have access and do currently use that plugin for my current project (along with extended DoT), however I am quite bad at trying to make a code for the lunatic mode's custom apply effects where I see the concept for that ability would work unfortunately...
Here is something I saw recently that's made me stop suggesting this:

Very interesting... while I do not use Auto Battle, I would probably imagine how stuff could go wrong considering I use a couple of plugins for my current project that I'm working on
Adding to Milenins solution, you can technically do this even without a common event:
- Make the invisible state block (state rate 0%) super poison
- Make regular poison "state resist" the invisible state
- Optional: Make super poison "state resist" regular poison (to automatically replace it)
- In your skills effects, first add the invisible state (1000%), then add super poison (if the invisible state goes through, then the target is not poisoned and the subsequent super poison is blocked)

Downside would be that it is technically possible to evade the invisible state even at 1000% application chance if the LUK difference between the user and the target is above 900.


Tiamat-86s solution is still applicable though, most of the time you can add the extra effects to the notebox instead of the damage formula if you are using Yanflys Skill Core Plugin for example:
Code:
<after eval>
if (b.result().i****()) {
   // Extra effects from the damage formula
}
</after eval>
Edit: The sanitized code reads => if (b.result().isHit()) {

For the increased damage if a state is present, you can use something like
b.isStateAffected(StateID) ? (High Damage Formula) : (Regular Formula)
(as Tiamat-86 has suggested), and remove the state through your skills effects (skill effects are done after the damage is already calculated)

Edit 2, OT: Generally I would agree with Shaz/Yanfly that one should avoid this the damage formula if possible, not least to open up the option to utilize the formula to gage a skills effect not only for AI purposes, but also things like an automatic damage preview in the skills description for example.
It also requires one to utilize the damage formula in the first place, even if the skill is not supposed to do damage.
Definitely see Milenins point of course, I would have loved to see something like a "Script..." skill effect option.
I'll try this soon and will probably send you a private message (IF you don't mind that is, I'm all good with posting the results here in this thread) about the results/if I have any further questions.

Thank you all again for responding to this thread with ideas and solutions!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-skill-that-reacts-to-state.133348/