MV YEP Buffs and states help: states that execute effects during certain conditions


Hello!

I'm having trouble figuring out how to get the following states to work. I know how to do these with action sequences easily, but notetags for buffs/states don't work with action sequences and require js. I don't know what the script calls are to simulate these effects.

I'm trying to make a state where the affected enemy explodes upon death, it deals dmg to all enemies based on a variable.

I'm also trying to make a passive state w/ yep passive states for equipment that when that equipped character kills an enemy, a status effect is inflicted to the other enemies.

A passive state for equipment in which that equipped character's damage is increased when you hit an enemy affected by a certain status effect is also something I'm having trouble with. I think the easiest way to get that effect would be to lower the enemy's phys/mag resist by 20% just before the skill hits.

And a passive state on a character for when they fight an enemy and its hp is over 50%, that enemy's phys/mag resist is decreased by 20% right before a skill would hit.

Thank you!
I'm trying to make a state where the affected enemy explodes upon death, it deals dmg to all enemies based on a variable.
Code:
<Custom Respond Effect>
if (target.isDead() || target.hp<=0)
    $gameTroop.aliveMembers().forEach(enemy => enemy.gainHp(0-$gameVariables.value(15));
</Custom Respond Effect>
That will hit all enemies for the value of variable 15. Change the ID to the variable of your choice, do math to it if you like...you didn't say what "based on" the variable means.

when that equipped character kills an enemy, a status effect is inflicted to the other enemies.
I presume that "status effect" means a state, rather than a debuff.
Code:
<Custom Establish Effect>
if (target.isDead() || target.hp<=0)
    $gameTroop.aliveMembers().forEach(enemy => enemy.addState(X));
</Custom Establish Effect>
where X is the ID of your state, no leading zeros.

equipped character's damage is increased when you hit an enemy affected by a certain status effect
Code:
<Custom Confirm Effect>
if (target.isStateAffected(X))
    value=Math.round(damage*1.2);
</Custom Confirm Effect>
again replacing X with the ID of the state.

And a passive state on a character for when they fight an enemy and its hp is over 50%, that enemy's phys/mag resist is decreased by 20% right before a skill would hit.
This is pretty convoluted. You would have to make another state with the state rate Traits on it; apply the state before the hit then remove it again after the damage. Wouldn't it be okay to just multiply the damage like I did above? Or does it have a much different effect on your damage formula?
I'm trying to make a state where the affected enemy explodes upon death, it deals dmg to all enemies based on a variable.

for your first state, im assuming its a passive, yes? if it is, instead of making it a passive, you could make a troop event give that enemy a permanent duration state at the start of battle and give it this notetag:
JavaScript:
<Custom Deselect Effect>
if (target.hp==0){
    target.friendsUnit().aliveMembers().forEach(member => member.gainHp(-[some damage calc involving $gameVariables.value(variable id)));
    target.friendsUnit().aliveMembers().forEach(member => member.startDamagePopup();
    target.removeState(stateId);
}
</Custom Deselect Effect>
Make this passive come with KO resist as a trait so that the state gets to perform the effect before the target dies. If its not a passive, then no need to bother with the troop event.

I'm also trying to make a passive state w/ yep passive states for equipment that when that equipped character kills an enemy, a status effect is inflicted to the other enemies.

your second state can be something like this:
Code:
<Custom Conclude Effect>
if (target.hp == 0 && !target.isStateResist(1)) {
target.friendsUnit().aliveMembers().forEach(member => member.addState(x));
}
</Custom Conclude Effect>
killing a target will cause state x to be applied to all the target's allies if the attacker has that state on

A passive state for equipment in which that equipped character's damage is increased when you hit an enemy affected by a certain status effect is also something I'm having trouble with. I think the easiest way to get that effect would be to lower the enemy's phys/mag resist by 20% just before the skill hits.

the third can be something like this:
Code:
<Custom Confirm Effect>
if (this.isDamage() && target.isStateAffected(x)){
value = value * 1.2;
}
</Custom Confirm Effect>
itll increase damage dealt to the target by 20% instead of changing the enemy's resistances by applying a state before damage calc and removing it after
And a passive state on a character for when they fight an enemy and its hp is over 50%, that enemy's phys/mag resist is decreased by 20% right before a skill would hit.
I suggest doing it similar to no#3

Code:
<Custom Confirm Effect>
if (this.isDamage() && target.hpRate() > 0.5){
value = value * 1.2;
}
</Custom Confirm Effect>
for your first state, im assuming its a passive, yes? if it is, instead of making it a passive, you could make a troop event give that enemy a permanent duration state at the start of battle and give it this notetag:
JavaScript:
<Custom Deselect Effect>
if (target.hp==0){
    target.friendsUnit().aliveMembers().forEach(member => member.gainHp(-[some damage calc involving \v[variable id]));
    target.friendsUnit().aliveMembers().forEach(member => member.startDamagePopup();
    target.removeState(stateId);
}
</Custom Deselect Effect>
Make this passive come with KO resist as a trait so that the state gets to perform the effect before the target dies. If its not a passive, then no need to bother with the troop event.



your second state can be something like this:
Code:
<Custom Conclude Effect>
if (target.hp == 0 && !target.isStateResist(1)) {
target.friendsUnit().aliveMembers().forEach(member => member.addState(x));
}
</Custom Conclude Effect>
killing a target will cause state x to be applied to all the target's allies if the attacker has that state on



the third can be something like this:
Code:
<Custom Confirm Effect>
if (this.isDamage() && target.isStateAffected(x)){
value = value * 1.2;
}
</Custom Confirm Effect>
itll increase damage dealt to the target by 20% instead of changing the enemy's resistances by applying a state before damage calc and removing it after

I suggest doing it similar to no#3

Code:
<Custom Confirm Effect>
if (this.isDamage() && target.hpRate() > 0.5){
value = value * 1.2;
}
</Custom Confirm Effect>
EDIT: I i really should learn to refresh the page before i post
EDIT*2: or not stay up all night and hit reply instead of edit
Yes, multiplying the damage works too, I didn't know we could do that.

Thank you both for the help!
So that much of it is actually listed in the plugin instructions as an example, but I understand you wouldn't know how to check for a state in JavaScript off the top of your head.

You may want to review Yanfly's Tips & Tricks articles, there are a lot of special effects you can accomplish with the code already made.

Good luck with your project!

Original thread: https://forums.rpgmakerweb.com/threads/yep-buffs-and-states-help-states-that-execute-effects-during-certain-conditions.157711/