MZ How to make that you can't use this skill unless enemy have "X" state ID

I'm using VISUAL Stella skillstate core and I want accomplish this.

I want to make certain skill can't be used unless enemy have like poison state. I'm no JS expert. Would anyone mind helping me to accomplish this.
You can mostly do this within the damage formula. This is a very helpful guide. It would make it so that a skill only does damage (and other things that can be done within the damage formula) if the target has x state, whichever state you want.
You can mostly do this within the damage formula.
The problem with that idea - it doesn't stop the enemy from using the skill, it just stops/changes the damage being dealt.

And if there are other effects attached to the skill, such as applying states, a common event, it can't prevent any of those from within the damage formula.

I want to make certain skill can't be used unless enemy have like poison state.
One solution for you is to use VisuStella's Battle Core. It has the JS Targets notetag. So you could do:
Code:
<JS Targets>
targets=$gameParty.aliveMembers().filter(member => member.isStateAffected(X));
</JS Targets>
where X is the ID of your poison state.

If you want to get a bit more sophisticated, you could see if Yanfly's Battle A.I. Core is compatible with FOSSIL, as it lets you get much more in detail with what enemies do under which conditions.
How about enemies? I want the skills for actor unable to target the enemy unless enemy have state like poison
How about enemies? I want the skills for actor unable to target the enemy unless enemy have state like poison
Just replace $gameParty with user.opponentsUnit() and then it works for actors and enemies.
Somehow it still targets even enemy without the state
Are you testing in a new game? Using the editor's Battle Test or loading a save game may not work correctly.

Otherwise, post screenshots of your skill in the database.
1664838226153.png

1664838250157.png
1664838275208.png
For future reference, that's pretty hard to read. I appreciate you wanted to show what the entire line of code says, but chopping up these tiny segments instead of just posting an actual screenshot makes it impossible to see if there's some other setting in the skill that might be affecting it.

And you have the Battle Core plugin installed? I don't know what else to say...someone else more familiar with the plugin might have a better idea.
For future reference, that's pretty hard to read. I appreciate you wanted to show what the entire line of code says, but chopping up these tiny segments instead of just posting an actual screenshot makes it impossible to see if there's some other setting in the skill that might be affecting it.

And you have the Battle Core plugin installed? I don't know what else to say...someone else more familiar with the plugin might have a better idea. Am I doing something wrong @Arthran, @Trihan?
yes I have it installed.

<JS Targets>
targets=user.opponentsUnit().filter(member => member.isStateAffected(4));
</JS Targets>
<BTB BP Cost: 2>
targets=user.opponentsUnit().filter(member => member.isStateAffected(4));
This is incorrect - you took away the aliveMembers() portion.

It should read targets=user.opponentsUnit().aliveMembers().filter(member => member.isStateAffected(4));
targets=user.opponentsUnit().aliveMembers().filter(member => member.isStateAffected(4));
Thanks it worked now

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/how-to-make-that-you-cant-use-this-skill-unless-enemy-have-x-state-id.151735/