Combing two states to make a new state

There was a post here before that asked the same question, (https://forums.rpgmakerweb.com/index.php?threads/how-to-combine-states-or-ailments.100640/) however, it was unresolved.

Anyway, I was wondering how wondering how take two states and combine them. For example, your character has "Poison"(lose HP over time) and when they are inflicted with "Paralyzed"(can't act on your turn) they get the "Living in Pain" state(lose HP and can't move).

How would I achieve this?
add a common event to the skill inflicting the paralyze to check for poison, and add living pain.
and then, *in* living pain, negate poison and paralyze.

whenever paralyze is added, paralyze will add *paralyze*.
when adding *paralyze* without adding *living pain*, which is conditioned to the state of *poison*, then *paralyze* will take effect on it's own.
add a common event to the skill inflicting the paralyze to check for poison, and add living pain.
and then, *in* living pain, negate poison and paralyze.

whenever paralyze is added, paralyze will add *paralyze*.
when adding *paralyze* without adding *living pain*, which is conditioned to the state of *poison*, then *paralyze* will take effect on it's own.


It worked, I just have to make it each skill or item that inflicts this calls the common event.
Alternatively, if you have Yanfly's YEP_BuffsStatesCore plugin, you can paste this into your state's notebox:

JavaScript:
<Custom Apply Effect>
// Check if the target is already affected with State 5
if (user.isStateAffected(5)) {
// If so, remove state 4 and state 5 and add the new state 7
user.removeState(4);
user.removeState(5);
user.addState(7);
};
</Custom Apply Effect>

You'd copy this notetag into state 4, since in the if statement we are checking if state 5 is already applied and then remove both of the states. If you wanted to paste this into state 5's notebox instead, you'd just swap out the user.isStateAffected(5) with user.isStateAffected(4) - Effectively just changing the number.

Original thread: https://forums.rpgmakerweb.com/threads/combing-two-states-to-make-a-new-state.123938/