Results when States forcibly removed

Hello,

I'm looking for some assistance with a problem that is probably easy to fix but I can't figure out how to work with it. I want to find a way to make certain things happen when a state is forcibly removed but not when it naturally wears off (And it's the type of state that does have to naturally wear off).

If the state naturally wears off, I want nothing to happen. If the state is forcibly removed with a skill, I want a new state to be applied (or even an animation to play when it is removed, but again, not when it wears off). However, I don't want the skill to add the new state unless the old one has already been applied.

I'm usually pretty crafty at making clever combat systems but this simple problem has me stumped.
I think you could use an if then statement in the damage formula of the skill. Check if the state is applied, if so then remove it and add a new state, else do regular damage or whatever
Put this inside the state's note box
<Custom Remove Effect>
target.addState(x);
</Custom Remove Effect>

x is the number of the state you want to be applied

P.S you need yanfly's buffs and states plugin.
Put this inside the state's note box
<Custom Remove Effect>
target.addState(x);
</Custom Remove Effect>

x is the number of the state you want to be applied

P.S you need yanfly's buffs and states plugin.

Thanks for the input. It doesn't work though unfortunately. What you suggested will cause the other state to be added regardless of whether the first state is removed forcibly or naturally. I only want this to occur when it is removed forcibly and never naturally.
I think you could use an if then statement in the damage formula of the skill. Check if the state is applied, if so then remove it and add a new state, else do regular damage or whatever

This is exactly what I was hoping would be built into it. An If/Then statement. I don't know JS though but I'll see if I can cobble something together by looking at the syntax from plugins.
This is exactly what I was hoping would be built into it. An If/Then statement. I don't know JS though but I'll see if I can cobble something together by looking at the syntax from plugins.
I meant the damage formula box of the skill

something like:

b.stateAffected(X) ? b.removeState(X); b.addState(Y); [damage formula here]; : [damage formula here];
I meant the damage formula box of the skill

something like:

b.stateAffected(X) ? b.removeState(X); b.addState(Y); [damage formula here]; : [damage formula here];

Thanks for the formula. It doesn't seem to work for whatever reason. I even checked the Damage Formulas 101 page to make sure, and it's all correct.

b.stateAffected(34) ? b.removeState(34); b.addState(35); a.atk * 5.5 - b.def * 1; : a.atk * 5.5 - b.def * 1;

That's my formula. What is actually happening is it is now causing 0 damage all the time and states are not being changed. I have all the yanfly plugins for states and battles and all that stuff. I'm not sure what's gone wrong.
That’s weird, it returns 0 when something is wrong, so maybe there’s an extra space or typo in it? Idk, seems like it should work
Try HIME conditional states maybe.
That’s weird, it returns 0 when something is wrong, so maybe there’s an extra space or typo in it? Idk, seems like it should work
I actually tried all 3 syntax formats too, all with the same results. So I don't think it's a spacing or typo issue.
I actually tried all 3 syntax formats too, all with the same results. So I don't think it's a spacing or typo issue.

Only thing I can think of is some plugin affecting what's happening in battle. IDK, weird. I know that battle formula works, because I've used it for similar things.

You're not using Lunatic code for a custom battle formula are you? That will overwrite whatever is in the skills battle formula box I think. Also, you may want to check what comments you have in the skills comment box, maybe something is overwriting or clashing somewhere. I hope you figure it out.
Thanks for the input. It doesn't work though unfortunately. What you suggested will cause the other state to be added regardless of whether the first state is removed forcibly or naturally. I only want this to occur when it is removed forcibly and never naturally.
Try this instead:

Code:
<Custom Remove Effect>
if (BattleManager._subject && !$gameTemp._customLeaveEffectEval) target.addState(x);
</Custom Remove Effect>

(Not tested, but it should probably work maybe)
Try this instead:

Code:
<Custom Remove Effect>
if (BattleManager._subject && !$gameTemp._customLeaveEffectEval) target.addState(x);
</Custom Remove Effect>

(Not tested, but it should probably work maybe)

Hey, thanks for the reply. I tried it out. It causes the next state to be added whether it falls off naturally or forcibly.
Oh hmm, well I pulled it from yanfly's tips and tricks things for Unstable Affliction (a state in WoW that blows up in the dispeller's face if removed prematurely) So have a look at that.

Busting my brain figuring this out. Doesn't help that I'm not a programmer, although I seem to be doing well enough deciphering what it means and manipulating it. The answer is definitely in that Unstable Affliction code. I've tried writing my own a few times with varying results, but not the results I want. Sometimes I can make it so that the state evolves with or without forcing it, sometimes the new state is applied to me instead of my target. Sometimes the second state is just never applied at all.

Maybe some context will help. This is what I want to see happen:

I cast an ice spell on a target which has a chance to freeze it causing the Frozen state. If one of my other characters uses one of a few specific Blunt skills like Crushing Blow, it deals bonus critical damage and "shatters" the target, breaking it out of the ice. However, if the target's frozen state wears off without being shattered, I don't want it to do anything at all.

The reason I want it to transition from one state to another is because I want an animation to play upon the Frozen state's removal, however the only way I know how to make states play animations is on application, not its removal. So I created a second state, called Shatter, to activate for a short time when a Frozen target is smacked by Crushing Blow. This will cause the shatter animation upon application. A nice bonus for the Shatter state is that it can last a few turns, rendering the target immune to further freezing to prevent abuse.

Obviously, if the target thaws out on its own, it wouldn't make sense for it to shatter.
Oh, you don't need a special state just for the animation. Instead of fighting with the custom removal effect stuff, get rid of it plus remove any "remove state on damage" settings, then try this:

Code:
<Custom Respond Effect>
target.startAnimation(ANIMATION_ID);
target.removeState(STATE_ID);
</Custom Respond Effect>

Replace ANIMATION_ID with the shatter animation, and STATE_ID with the id of your frozen state. It'll play the shatter animation on the battler, then remove the frozen state. I'm going to assume any special behavior (extra damage, criticals, etc) are handled by the skills you mentioned in their own damage formulas.

Edit: If those specific skills also handle the state removal, then get rid of the target.removeState(...) line as well.

Edit2: Wait, this might not be what you're after now that I think about it, since I'm going to guess that only those specific skills will remove and interact with the frozen state. Back to the drawing board.
Crushing Blow removes Frozen, and the Frozen state has an inherent 200% weakness to Blunt.
So this got me interested, so I actually tested it out in a fairly clean test project. It should work with this on the frozen state and your crushing blow ability removing the frozen effect:

Code:
<Custom Remove Effect>
if (BattleManager._subject && !$gameTemp._customLeaveEffectEval) target.startAnimation(14);
</Custom Remove Effect>

Replace the 14 with your shatter animation's ID. Get rid of your shatter state if its only purpose is to play an animation.

When I let my frozen state run out via turn decay, it didn't animate, but when my crush ability was used, it removed the frozen state prematurely and thus, triggered the animation. If it doesn't work, then there might be something else going on.
I tried using this

if (b.isStateAffected(34)) {a.atk*500} else {a.atk*5}

Just to make sure it was working that way. It works fine. It's only with the inclusion of b.removeState and b.addState that screw with it.
So this got me interested, so I actually tested it out in a fairly clean test project. It should work with this on the frozen state and your crushing blow ability removing the frozen effect:

Code:
<Custom Remove Effect>
if (BattleManager._subject && !$gameTemp._customLeaveEffectEval) target.startAnimation(14);
</Custom Remove Effect>

Replace the 14 with your shatter animation's ID. Get rid of your shatter state if its only purpose is to play an animation.

When I let my frozen state run out via turn decay, it didn't animate, but when my crush ability was used, it removed the frozen state prematurely and thus, triggered the animation. If it doesn't work, then there might be something else going on.

The animation played for me regardless of whether it was turn decay or with Crushing Blow. I have a hunch I know why now though, and if it's true, then it's unfixable. I'm using ATB. There may be something under the hood that is making turn decay not work correctly and instead be replaced by a forced removal when X turns are up. I have noticed that states that disable an enemy never go away because their turn never truly arrives.

Basically, if I've gotten this right, turn decay doesn't exist in my game because my ATB plugin disabled it.

*Edit* Yup... That's it. Disabled ATB and it worked correctly. I imagine the other solutions we came to would also work correctly now. Unfortunately ATB is more important to me than skill combos like Freeze/shatter.

WAIT. What if, in the Crushing Blow notetag, we check to see if the target is afflicted by Frozen. If yes, then play animation 130 (the shatter). That way, the animation doesn't play on the addition nor the removal of the state. Crushing blow can simply remove the frozen state. This way it doesn't matter if it's by turn decay or by removal. Is this possible?

Original thread: https://forums.rpgmakerweb.com/threads/results-when-states-forcibly-removed.120352/