# RMMV[YEP_BuffStatesCore] <Custom Remove Effect> & <Custom Leave Effect>

#### Frostorm

##### []D[][]V[][]D
Is there a way for me to utilize both conditionally? Basically, I want a state to do X if removed, or do Y if turn decayed. What should I put in an "if" statement in order to do this? Is this even possible? I mean, it must be possible since those 2 tags exist, thus there must be a way to differentiate whether a state is removed via turn decay vs other means. If I can find the proper conditional, then I'd only have to use <Custom Remove Effect>.

Edit:
For context, the skill in question is called "Arrow to the Knee" ( ), which causes the target to be immobilized for 1 turn and slowed for 3 turns. Thus, I need to create a state that lasts 1 turn, which then adds another state that lasts 2 more turns when the 1st state turn decays down to 0 turns. However, this should only occur if the 1st state is removed via turn decay and not by some other means. This is what I got so far...

State100:
JavaScript:
``````<letbs> //this makes it so the target cannot move
move_scope: circle(0)
</letbs>
<Custom Apply Effect> //this reduces the target's Speed (LUK) by 1/3 the caster's Dexterity (AGI)
var knee = Math.round(origin.agi / 3);
target._knee = target._knee || 0;
target._knee += knee; //it is also stackable, further reducing Speed when reapplied
target.minusLuk(knee);
</Custom Apply Effect>
<Custom Remove Effect>
target._knee2 = target._knee;
delete target._knee;
</Custom Remove Effect>
<Custom Leave Effect>
target.addState(101); //state 101 is basically just this state w/o the immobilization
</Custom Leave Effect>``````
State101:
JavaScript:
``````<Custom Apply Effect>
target.minusLuk(target._knee2);
</Custom Apply Effect>
<Custom Remove Effect>
delete target._knee2;
</Custom Remove Effect>``````

It's pretty messy, so I'd love to have a conditional that can distinguish whether the state is being removed by turn decay vs other means.

Last edited:

#### eomereolsson

##### Veteran
From looking at the code, it seems to me, that the code inside `<custom remove effect>` will always be executed if the state is removed. The code inside the `<Custom Leave Effect>` will only be executed if additionally `\$gameTemp._customLeaveEffectEval` is true. So if you really want to only use the `<custom remove effect>`, in theory you could do:
Code:
``````<Custom Remove Effect>
if (\$gameTemp._customLeaveEffectEval) {
//do thing if state got removed through decay
}
else {
//do thing if state got removed through sth else than decay
}
</Custom Remove Effect>``````

However I would do something along the lines of:
Code:
``````<Custom Leave Effect>
//do thing if state got removed through decay
</Custom Leave Effect>

<Custom Remove Effect>
if (!\$gameTemp._customLeaveEffectEval) {
//do thing if state got removed through sth else than decay
}
//do thing no matter how state got removed
</Custom Remove Effect>``````
It just seems cleaner to me to actually use both tags for their intended purposes and just exempt stuff from the `<custom remove effect>` that you explicitly don't want to happen if the state decays.

#### Frostorm

##### []D[][]V[][]D
Thank you, that was exactly what I was looking for!

Edit: As a result, I was able to clean up the code a bit!

1st State:
JavaScript:
``````<letbs>
move_scope: circle(0)
</letbs>
<Custom Apply Effect>
var knee = Math.round(origin.agi / 3);
target._knee = target._knee || 0;
target._knee += knee;
target.minusLuk(knee);
</Custom Apply Effect>
<Custom Remove Effect>
if (\$gameTemp._customLeaveEffectEval) {
} else {
delete target._knee;
}
</Custom Remove Effect>``````
2nd State:
JavaScript:
``````<Custom Remove Effect>
delete target._knee;
</Custom Remove Effect>``````

Last edited:

### Latest Profile Posts

At work.
Co: "This bug drove me insane. I tried a lot of things to debug, it just stuck".
Me: "How did you debug it?"
Co: *shows a complicated debugging method using breakpoints and everything*
Me: "What about ... " *casually prints a stack trace in the try/catch exception
Co: "Wait, you can do that??"
Totally original and unique OC
So after completing the Mass Effect Trilogy the first time as a Vanguard, I decided to replay the trilogy as a Soldier. Thus far, I've just finished the Horizon mission in ME2, and I'm already exhausted from ME2's f**k-awful enemy design.
Yeah, now Yes !!!! "boom boom "
"Fire the monsters, guards!!!"

I can't stop buying resource packs I'll never use, or engines for that matter, or free resources as my two terabyte external will attest. I am a digital hoarder I guess. Some people get drunk off the silly juice when they are bored, I just buy shiny digital nonsense I don't need.