MV YEP_InstantCast instant once per enemy hit

Hello !
I've been using YEP_InstantCast a lot recently, and figured some interesting ways to make it work, like only once per turn, or if some enemies are affected by a state before acting.
I tried to setup a specific skill this time, tried multiple ways in hope of making it work, but with no success.
What I wanted the skill to do is to have instant property after hitting an enemy affected by a state, once per enemy.

To be more precise :
I have a Seduce state. A character make use of it for some of their skills, where they can work only if the target is inflicted with Seduce. So I wanted a skill to be instant (like giving a free turn) if the target is inflicted with Seduce, and that could happen only once on each enemy so the skill couldn't be spammed.

My attempts always end up with the skill being instant twice before disappearing.
My last one could help figure my question better I think :
The Seduce State has a Custom Apply Effect that applies another state to the target, to check for the skill X to be instant. Let's call it Seduce Instant.
Then the actor has a state applied at each turn to make the skill instant. I'll name it Skill Instant. It has a <Instant Skill : X> notetag to make skill X be instant.
So the actor performs the skill. If the target has the Seduce Instant, it removes it, and instant cast is processed as expected.
The issue is when hitting an enemy that has either Seduce but not the Seduce Instant, or not Seduce at all.
I made the Skill Instant state check with a <Custom Initiate Effect>, if the target isn't inflicted with the Seduce Instant state, the actor will have a Instant Lock state applied to them to prevent the skill to be instant, and removes the Skill Instant state.
But the skill stays instant for the occuring action so it makes the actor act again, then if trying to repeat the skill it doesn't have instant properties.

Maybe I'm missing JS knowledge to find the command in YEP's code to make the skill work as intended, but I post this thread if someone can help me with this, or confirming to me that the system I'm trying to make won't work.
Rather than trying to describe it with words, please post the code that you're using. Use the CODE tags (the </> in the edit bar) to preserve indentations and brackets.

The Instant Cast plugin has a notetag to dynamically evaluate whether the skill should be instant.

Your skill would have the notetags:
Code:
<Instant Eval>
instant = !user.usedInstant && target.isStateAffected(x);
</Instant Eval>

<Before Eval>
user.usedInstant = true;
</Before Eval>

<Passive State: y>

x is the ID of Seduce Instant. y is the ID of another, blank state.

That state has the notetag:
Code:
<Custom Regenerate Effect>
user.usedInstant = false;
</Custom Regenerate Effect>

<Custom Battle Effect>
user.usedInstant = false;
</Custom Battle Effect>
Rather than trying to describe it with words, please post the code that you're using. Use the CODE tags (the </> in the edit bar) to preserve indentations and brackets.
Alright, so for my last attempt these are my codes :
- On Seduce :
Code:
<Custom Apply Effect>
user.addState('Seduce Instant');
</Custom Apply Effect>
- On the skill :
Code:
<Before Eval>
if (!target.isStateAffected('Seduce Instant'))
{
$gameTroop.aliveMembers().forEach(function(member) { return member.removeState('Seduce Instant') })
}else{
user.addState(Instant Lock);
}
</Before Eval>
<After Eval>
target.removeState('Seduce Instant');
</After Eval>
- The Seduce Lock state has <Cancel Instant Skill : 'skill'>
- The Instant Skill state :
Code:
<Custom Initiate Effect>
if(!target.isStateAffected(248))
user.addState(249);
</Custom Initiate Effect>
<Instant Skill: 'skill'>
Code:
<Passive State: y>
I am using Moogle_X_PassiveSkill on my project, would it conflict with YEP_AutoPassiveStates ?
Alright, so for my last attempt these are my codes :
None of that will work. All methods that have to do with states (add, remove, is affected) take the ID of the state, as I showed in my first reply. I don't know where you got that syntax from, but typing in the name of the state won't do anything.

Additionally, even if that were correct, your addState with Instant Lock doesn't have quotation marks so it wouldn't be recognized as a string.

The code I gave you above should work fine.
None of that will work. All methods that have to do with states (add, remove, is affected) take the ID of the state, as I showed in my first reply. I don't know where you got that syntax from, but typing in the name of the state won't do anything.

Additionally, even if that were correct, your addState with Instant Lock doesn't have quotation marks so it wouldn't be recognized as a string.

The code I gave you above should work fine.
No that was just to name them here to be more comprehensive. They've the IDs in my project
Ah. It's best when you're pasting code not to change anything, because we might tell you to fix something that isn't the same as in your actual project 😉

Well, your Before Eval's first condition is weird. You're saying if your target already doesn't have Seduce Instant, remove Seduce Instant from the entire troop. I don't get what that's accomplishing.

Also, forEach() doesn't require any return value.

I suggest you try my setup. Let us know if you still have problems.
Well, your Before Eval's first condition is weird. You're saying if your target already doesn't have Seduce Instant, remove Seduce Instant from the entire troop. I don't get what that's accomplishing.
That was to make sure the Instant cast didn't catch something I could have missed so I cleared all Instant Seduce on all troop if hitting a target that doesn't have it


I suggest you try my setup. Let us know if you still have problems.
It didn't work, the skill never happened to be instant.
I made a seperate skill with your code, had the Seduce state apply the Seduce Instant, and then the blank state with the code, but nothing happens.
Also tried deactivating Moogle_X_PassiveSkill just in case but that didn't change anything.
Where does the AutoPassiveState be placed in YEP's plugins ? Maybe that's causing the issue
If you go to the Yanfly Engine Plugins Web site, all of your plugins in the plugin manager must be in that order.

Also, make sure you're starting a new playtest after you change notetags, and you're not loading a save game.

If all of that doesn't work, please post screenshots of the skill and the two states.
The skill :
Capture Seduce Instant.PNG

EQS Ignore is for Moogle_X_EquipSkillSystem which doesn't affect YEP's plugins so far
The Seduce state :
Capture Seduce State.PNG

its entire notetag :
Code:
<Custom Action Start Effect>
$gameActors.actor(8).addState(232);
</Custom Action Start Effect>

<Custom Action End Effect>
$gameActors.actor(8).removeState(232);
</Custom Action End Effect>

<Custom Apply Effect>
if ($gameActors.actor(5).eqsSkillEquipped($dataSkills[152]))
user.addState(179);
user.addState(248);
</Custom Apply Effect>

<Custom Remove Effect>
if ($gameActors.actor(5).eqsSkillEquipped($dataSkills[152]))
user.removeState(179);
user.removeState(248);
</Custom Remove Effect>

(The actor 8 is the one we're looking at here, actor 5's thing is independant and works on its own)

The Seduce Instant state :
Capture Seduce Instant state.PNG

(Just to note : the state is applied as the enemy has the icon showing)

The passive you asked me to setup :
Capture Seduce Instant passive.PNG

(Just checked by adding an icon, it's showing on the actor so the passive state works correctly)

One thing that I noted, the playtest lags a bit when using the skill, maybe something is off with it ?
There's nothing in the code I put there that would create lag.

Is your Seduce state correct? It applies state 179 if actor 5 has skill 152 equipped, but also always applies 248?

I poked at the code a bit, and it turns out the instant eval actually happens at the end of the skill, so turning on usedInstant in the before eval means that'll never work.

My current thought, because of the weird timings of things, is this: make two versions of the skill. One is instant cast, the other is not.

Use Yanfly Skill Core notetags to control which one the player sees depending on whether they've used it already this turn or not.

If that sounds good, I can help you with the tags for that.
There's nothing in the code I put there that would create lag.

Is your Seduce state correct? It applies state 179 if actor 5 has skill 152 equipped, but also always applies 248?
Yeah, actor 5's state 179 is not related to the instant cast thing (it's about making another instance of damage if the enemy has some states afflicted, Seduce is part of that), it's working correctly and doesn't interfere with anything else.

State 248 was my idea to have a check, to make the skill instant only once on each enemy affected by the Seduce state 😅 Once the instant skill is used, state 248 is removed. One of my attempts was to make an Instant Eval looking like this :

Code:
if ($gameTroop.aliveMembers().some(function(member) { return member.isStateAffected(248) })) {
instant = true;
}
but couldn't make it so it doesn't stay instant as long as an enemy already hit by the skill is hit again
I poked at the code a bit, and it turns out the instant eval actually happens at the end of the skill, so turning on usedInstant in the before eval means that'll never work.

My current thought, because of the weird timings of things, is this: make two versions of the skill. One is instant cast, the other is not.

Use Yanfly Skill Core notetags to control which one the player sees depending on whether they've used it already this turn or not.

If that sounds good, I can help you with the tags for that.
So it would switch to the non-instant one if an enemy is hit a second time with the instant one, right ?
Otherwise, to make it work once per turn I already have a way to use it. And have a way to make it grayed out and unusable if no enemy is inflicted with Seduce 😅
So it would switch to the non-instant one if an enemy is hit a second time with the instant one, right ?
Otherwise, to make it work once per turn I already have a way to use it. And have a way to make it grayed out and unusable if no enemy is inflicted with Seduce
Okay...I'm a little confused by everything in your post. Are you saying you've figured out a solution to your question in this thread?
Okay...I'm a little confused by everything in your post. Are you saying you've figured out a solution to your question in this thread?
Nope, I just mentionned a way I know for an instant skill to work once per turn.
You make a state with an <Instant Skill : x>, and the x skill removes the state. The skill becomes instant only once per turn in this case.

And another thing that uses Instant Eval is to check if enemies are afflicted with a state.
I explained a method I tried to use before making this post, which could disable the skill if no enemy is afflicted with a state.

The above is just things I tried that couldn't make the original intent of the skill, which I'll explain once more : Making a skill instant on an enemy afflicted with a state, but only once per enemy (doing the skill on the same enemy twice would not make it instant on the second use)

Now, back to the last thing you mentionned.
Do you think some code could switch the instant one with the non-instant one with the conditions I wanted ?
You need your actor to get both skills at the same time.

If you're using the built-in learn skills at X level, then that's simple, you just put them both at that level.

If you're using some other system to buy or learn skills, then you'd use Yanfly's Skill Core notetags to teach the second one when you learn the first one.

Once that's done, the first skill has:
Code:
<Instant Cast>

<Before Eval>
user.usedInstant = true;
</Before Eval>

<Custom Show Eval>
visible = !user.usedInstant;
</Custom Show Eval>

The second skill is exactly the same as the first one except for the notetags:
Code:
<Before Eval>
delete user.usedInstant;
</Before Eval>

<Custom Show Eval>
visible = user.usedInstant;
</Custom Show Eval>
Sorry I have some memory issues with my pc, couldn't use it to test your codes.
So far the code in itself works, I'll try to add the whole "enemy affected with state" and "once per enemy" in it to see if I can make it work, I'll just do the "enemy affected with" if it doesn't.

Just one note on YEP_SkillCore, I see the skill is just grayed out when result = false, is there a way to completely hide it ? I checked and the plugin information staples that it should, maybe another plugin messes with this, I'll check that too.

Anyway, thanks for the code, I'll try what I can do with it 🙏
I was wondering if Yanfly's Target Core or SelectionControl could help too, like having a <Custom Target Eval> or a <Select Conditions> checking which enemy had the Seduce Instant state
Alright, I found a workaround : inflict a "Cannot move" state on the actor if the target doesn't have the Seduce Instant state :

Code:
<Before Eval>
if (target.isStateAffected(248))
{
target.removeState(248);
}else{
user.addState(250);
}
</Before Eval>

The state 250 has a "Cannot move" restriction that vanishes on action end. So the whole instant thing is ignored and the actor passes their turn. Careful to remove the state on turn end (or maybe just switch the timing of the state to "Turn end" instead) since Action end removal, at least for me, is clunky and the state isn't remove because it considers the action not ended because of "cannot move".
Tried to remove the state with YEP's Buff and States timings but none of them worked.

So for those looking at similar kind of effects, here is the full code :

You need YEP_BattleEngineCore, YEP_BuffStatesCore, YEP_SkillCore, (YEP_TargetCore and YEP_X_SelectionControl are optionnal)
The state A you want to be affected by the skill needs those effects :

Code:
<Custom Apply Effect>
user.addState(x);
</Custom Apply Effect>

<Custom Remove Effect>
user.removeState(x);
</Custom Remove Effect>

<Custom Turn End Effect>
user.addState(x);
</Custom Turn End Effect>

Where state x is the one checked by the skill :
Code:
<Select Conditions>
// Add this Select Conditions part if you use YEP_TargetCore and YEP_X_SelectionControl
Not User
State: A
</Select Conditions>

<Instant Cast>

<Before Eval>
// Check if the enemy has already been hit with the skill
if (target.isStateAffected(x))
{
target.removeState(x);
}else{
user.addState(y);
// If you don't use the 'Select Conditions', add this part to make the skill inefficient if the target isn't affected by the state A :
if (!target.isStateAffected(A))
value = 0;
}
</Before Eval>

<Custom Show Eval>
// Add this Show Eval part if you want the skill to be hidden if conditions are not met
if ($gameTroop.aliveMembers().some(function(member) { return member.isStateAffected(A) })) {
  visible = true;
} else {
  visible = false;
}
</Custom Show Eval>

State y is the one mentionned above.

Original thread: https://forums.rpgmakerweb.com/threads/yep_instantcast-instant-once-per-enemy-hit.163629/