MV How to Combine two specific States into another. (YEP_BuffsStatesCore)

I've been trying to make a system that evolves a state three times upon stacking it:
i.e: Toxin + Toxin= Poison
Poison + Poison = Doom
or
Poison + Toxin = Doom

I found a really handy code for a state stacking and becoming the second state from Robro33, however, getting state 1 and state 2 to still evolve to state 3 is an issue at the moment, the way it is it will eventually still stack up into state 3, but only after an additional application.

Here is the code I've been using

<Custom Turn End Effect>
user._Toxin = user._Toxin +1 || 1;

if(user._Toxin >=2){
user.removeState(Toxin ID);
user.addState(Poison ID);
}
</Custom Turn End Effect>

<Custom Remove Effect>
delete user._Toxin;
</Custom Remove Effect>
Here is the code I've been using
That doesn't appear to have much to do with how you described it working.

That's going to make toxin automatically turn into poison after the target has had it for two turns, it has nothing to do with toxin being applied again.

You'd want to do something like this. In the notes for Toxin:
Code:
<Custom Apply Effect>
if (target.isStateAffected(stateId))
{
    target.addState(42);
    target.removeState(stateId);
}
else if (target.isStateAffected(42))
{
    target.addState(69);
    target.removeState(42);
    target.removeState(stateId);
}
</Custom Apply Effect>
where 42 is the ID for poison and 69 is the ID for doom.

Similarly, in poison:
Code:
<Custom Apply Effect>
if (target.isStateAffected(stateId))
{
    target.addState(69);
    target.removeState(stateId);
}
else if (target.isStateAffected(1183))
{
    target.addState(69);
    target.removeState(1183);
    target.removeState(stateId);
}
</Custom Apply Effect>
where 1183 is the ID for toxin.

Give that a try, see if it does what you want or needs to be adjusted.
It would be necessary to show what you have done in all 3 states

the way it is it will eventually still stack up into state 3, but only after an additional application.
is that the entire content of the notebox for state 1? Im not sure how it could need a second application to hit state 3 if state 2 is similarly written

Its also unclear to me what your end goal is.
the toxin gains a stack only as turns pass, or do skills also add them too?
is your Poison is meant to stack every turn and become doom? or does it have to be applied while also having toxin?
That doesn't appear to have much to do with how you described it working.

That's going to make toxin automatically turn into poison after the target has had it for two turns, it has nothing to do with toxin being applied again.

You'd want to do something like this. In the notes for Toxin:
Code:
<Custom Apply Effect>
if (target.isStateAffected(stateId))
{
    target.addState(42);
    target.removeState(stateId);
}
else if (target.isStateAffected(42))
{
    target.addState(69);
    target.removeState(42);
    target.removeState(stateId);
}
</Custom Apply Effect>
where 42 is the ID for poison and 69 is the ID for doom.

Similarly, in poison:
Code:
<Custom Apply Effect>
if (target.isStateAffected(stateId))
{
    target.addState(69);
    target.removeState(stateId);
}
else if (target.isStateAffected(1183))
{
    target.addState(69);
    target.removeState(1183);
    target.removeState(stateId);
}
</Custom Apply Effect>
where 1183 is the ID for toxin.

Give that a try, see if it does what you want or needs to be adjusted.
This seems to have the effect of causing targets to immediately evolve to the doom state on a single application, I'm not sure why.

It would be necessary to show what you have done in all 3 states


is that the entire content of the notebox for state 1? Im not sure how it could need a second application to hit state 3 if state 2 is similarly written

Its also unclear to me what your end goal is.
the toxin gains a stack only as turns pass, or do skills also add them too?
is your Poison is meant to stack every turn and become doom? or does it have to be applied while also having toxin?
I'm afraid I had simply misconstrued the function of the script, my apologies.
You'll need to show screenshots of the states, the actual notetags you have written in there, explain which states you're testing with, etc.
You'll need to show screenshots of the states, the actual notetags you have written in there, explain which states you're testing with, etc.
The whole note secion for Toxin:

<State Animation: 122>

<DoT Animation: 59>

<Custom Apply Effect>

if (target.isStateAffected(stateId))

{

target.addState(14);

target.removeState(stateId);

}

else if (target.isStateAffected(14))

{

target.addState(15);

target.removeState(14);

target.removeState(stateId);

}

</Custom Apply Effect>

The whole note section for Poison


<State Animation: 123>

<DoT Animation: 59>

<Custom Apply Effect>

if (target.isStateAffected(stateId))

{

target.addState(15);

target.removeState(stateId);

}

else if (target.isStateAffected(13))

{

target.addState(15);

target.removeState(13);

target.removeState(stateId);

}

</Custom Apply Effect>
Ah, because the Custom Apply runs after the state is actually added...I thought I recalled it went first.

Okay, so we modify toxin thusly.

Code:
<Custom Apply Effect>
if (target.hasToxin)
{
   target.addState(14);
   target.removeState(stateId);
}
else if (target.isStateAffected(14))
{
   target.addState(15);
   target.removeState(14);
   target.removeState(stateId);
}
else
    target.hasToxin = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete user.hasToxin;
</Custom Remove Effect>

And poison:
Code:
if (target.hasPoison)
{
   target.addState(15);
   target.removeState(stateId);
}
else if (target.isStateAffected(13))
{
   target.addState(15);
   target.removeState(13);
   target.removeState(stateId);
}
target.hasPoison = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete user.hasPoison;
</Custom Remove Effect>
Ah, because the Custom Apply runs after the state is actually added...I thought I recalled it went first.

Okay, so we modify toxin thusly.

Code:
<Custom Apply Effect>
if (target.hasToxin)
{
   target.addState(14);
   target.removeState(stateId);
}
else if (target.isStateAffected(14))
{
   target.addState(15);
   target.removeState(14);
   target.removeState(stateId);
}
else
    target.hasToxin = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete user.hasToxin;
</Custom Remove Effect>

And poison:
Code:
if (target.hasPoison)
{
   target.addState(15);
   target.removeState(stateId);
}
else if (target.isStateAffected(13))
{
   target.addState(15);
   target.removeState(13);
   target.removeState(stateId);
}
target.hasPoison = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete user.hasPoison;
</Custom Remove Effect>
This is getting closer I feel, however it is now skipping the step 2 state and jumping from Toxin to Doom for some reason on a second application.
This is getting closer I feel, however it is now skipping the step 2 state and jumping from Toxin to Doom for some reason on a second application.
I don't know what that means.

As I said in post #6, you need to be actually saying what you're doing to test, and what you expect to be happening, and how what's actually happening is different.
I don't know what that means.

As I said in post #6, you need to be actually saying what you're doing to test, and what you expect to be happening, and how what's actually happening is different.
I have been applying the toxin status to attacks with a weapon to test this whole thing out, it has a 100% state application rate and the enemies it's targeting do not have any resistances.

My intention, is attack or skill 1, using toxin, will apply only toxin for the first instance, a seperate instance of damage and application should evolve it to the poison state, then if applied again it should evolve into doom.

Additionally I would like it if: Two applications of poison caused the status to evolve to doom.
And: If Poison were applied to Toxin, if it were to evolve to doom.

At the moment, Toxin being applied to Toxin is causing it to evolve to Doom.
Got it, and I see why. The next state is being added before this one is removed, so the check there for having the previous state will be true. Just need to swap those lines of code.

Code:
<Custom Apply Effect>
if (target.hasToxin)
{
   target.removeState(stateId);
   target.addState(14);
}
else if (target.isStateAffected(14))
{
   target.removeState(14);
   target.removeState(stateId);
   target.addState(15);
}
else
    target.hasToxin = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete target.hasToxin;
</Custom Remove Effect>

And poison:
Code:
if (target.hasPoison)
{
   target.removeState(stateId);
   target.addState(15);
}
else if (target.isStateAffected(13))
{
   target.removeState(13);
   target.removeState(stateId);
   target.addState(15);
}
target.hasPoison = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete target.hasPoison;
</Custom Remove Effect>

That should do ya.
Got it, and I see why. The next state is being added before this one is removed, so the check there for having the previous state will be true. Just need to swap those lines of code.

Code:
<Custom Apply Effect>
if (target.hasToxin)
{
   target.removeState(stateId);
   target.addState(14);
}
else if (target.isStateAffected(14))
{
   target.removeState(14);
   target.removeState(stateId);
   target.addState(15);
}
else
    target.hasToxin = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete target.hasToxin;
</Custom Remove Effect>

And poison:
Code:
if (target.hasPoison)
{
   target.removeState(stateId);
   target.addState(15);
}
else if (target.isStateAffected(13))
{
   target.removeState(13);
   target.removeState(stateId);
   target.addState(15);
}
target.hasPoison = true;
</Custom Apply Effect>

<Custom Remove Effect>
delete target.hasPoison;
</Custom Remove Effect>

That should do ya.
That works amazingly, Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-combine-two-specific-states-into-another-yep_buffsstatescore.173590/