Endure state that ends when it is activated

So, in my game I have a skill called "Endure" which allows an actor to survive an attack that would normally kill them at 1 HP. I found another person asking the same question on the forum, and this was the final answer.
Hello!


If you use Yanfly's Buff & State Core, you can use the following notetag in your Endure state:


<Custom React Effect>
if ($gameParty.inBattle() && !this.isCertainHit() && value >= target.hp) {
value = target.hp - 1;
}
</Custom React Effect>


If you wanna endure one hit only, simply check the 'Remove by Damage' box.


You can also use <Action Start: 1> to make it last until that battler's next turn.


Hope that helps!


- Riff

Well, that's all fine and dandy, but they never specified a way to get the state the only be removed if the state is activated. I know that it must involve some sort of If-then code, but I don't know javascript. @Riff or anyone else, if you're out there, please tell me what additional code I should add in order to have the state be automaticly removed when the state activates. Thanks!
I think that you would add the line:
target.removeState(x);
inside the IF branch of the notetag, replacing x with the Endure State's ID.

Obviously don't add any Turn End/Action End remove conditions, although you can add Remove at Battle End if you want..
@Wavelength Okay, though I think I already knew that. There is no "IF" section of the code though, so I will need you to give me the exact code I need to use the "IF" command. I don't know anything about JavaScript and I'm afraid that I'll mess it up and cause errors if I try to guess what I'm supposed to do. I already provided the code, so all you have to do is copy it and then insert the "IF" section at the end of it. Thanks!
Okay, though I think I already knew that. There is no "IF" section of the code though, so I will need you to give me the exact code I need to use the "IF" command.
<Custom React Effect>
if ($gameParty.inBattle() && !this.isCertainHit() && value >= target.hp) {
value = target.hp - 1;
target.removeState(x);
}
</Custom React Effect>

😉
@Wavelength Thanks a lot! You really bring hope to me in such a dark time of both my life and the history of RPG Maker.
Glad it worked for you. 🙂
Your welcome!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/endure-state-that-ends-when-it-is-activated.122457/