Is it possible to apply a state to an enemy when hit with a certain element

I want to do something similar to a Charged Creeper from Minecraft, adding a state when hit with an element
Looking for code for a notetag that applies state 149 to enemy 95 when hit with element 4.
I have most Yanfly plugins if needed
the regular way to do it would be from the other side:

give all attacks of element 4 the ability to inflict state 149, and have the enemies that should not get state 149 be immune to that state.
although depending on your enemies and elements that might be a lot of work done that way.

another method (that is ideal for single enemy types) is damage coding. Basically checking in the damage formula if the enemy is of the specific ID and if yes, add that state by damage code in the skills.

neither method requires a plugin.
both could get a bit convoluted if skills with normal attack elements that may or may not be that element are in their game.

I have most Yanfly plugins if needed
If you use the buffs and states core and the element core plugins, then the following notetag in a state you give to the enemy would do

Code:
<Custom Respond Effect>
if (this.isDamage() && this.getItemElements().contains(4))
  target.addState(149)
<Custom Respond Effect>
<Custom Element React 4>
enemy.addState(149);
</Custom Element React>



This should work with plugins and for some reason it is not. Its not my plugin order, and the required plugins ARE enabled. It does this all the time, just choosing not to work because it doesnt feel like it.
<Custom Element React 4>
what plugin is that notetag from?
<Custom Respond Effect>
if (this.isDamage() && this.getItemElements().contains(4))
target.addState(149)
<Custom Respond Effect>

just tried this, and it failed

what plugin is that notetag from?
Element Core
Element Core
it is not, and it shouldnt be expected to work if it wasnt mentioned in the plugin's documentation

just tried this, and it failed
to be certain, did you save the project before testing?
if you did, show screenshots of your plugin manager, the state youve put the notetag into, the state youre using it to apply, and how youve added the first state to the enemy (the troop event that applies the state, the enemy database entry where youve placed a passive state notetag, etc.)
Minecraft Creeper is placeholder for real enemy mechanic lol
1756405237515.png
1756405263249.png
1756405253843.png
the following notetag in a state you give to the enemy would do
the state youve put the notetag into
the notetag goes into a state, not the enemy's notebox. you then give the enemy that state

Edit:
also your yanfly plugins arent in the right order. theyre meant to be loaded in the order they appear in on yanfly's website
how does that work?
how does that work?
what part? i thought i was clear, but i am unsure of what part you dont understand
<Custom Respond Effect>

if (this.isDamage() && this.getItemElements().contains(4))

target.addState(149)

<Custom Respond Effect>>


You said this notetag goes into the state? How is it supposed to know when to apply the state to the enemy?
I was looking for a notetag for an enemy, so when the enemy gets hit with a specific element, the state applies and then effects happen. But not to every enemy, only ones with the notetag, that why i cant just put a state on a skill
You said this notetag goes into the state? How is it supposed to know when to apply the state to the enemy?
I was looking for a notetag for an enemy, so when the enemy gets hit with a specific element, the state applies and then effects happen.
you put the notetag into a state, and then you give the state to the enemy during battle. while the enemy has that state on them, the code in the notetag will be run automatically when they get hit. when they get hit, it will check if the attack is electric and if so, will give the target of the attack state 149

But not to every enemy, only ones with the notetag, that why i cant just put a state on a skill
use a troop event to give the specific enemies the state with the notetag in it at the start of the fight or use a passive state plugin and make it a passive. the difference doesnt matter in most cases other than needing a separate plugin for the latter.
@levelzuk

What you failed to understand that there were two different states:

the notetag goes into an invisible processing state, perhaps ID=200 or whatever is unused in your project, and that is the state you add to the specific enemy you want to have that ability.
and then if the enemy with that state is hit with the correct damage element, the state 149 gets added regularly.

the background is that notetags by themselves do nothing, you'll need a plugin to process them.
and as far as I know Yanfly has no plugin that processes enemy notetags the way you want, but the state core allows the trick described above

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-apply-a-state-to-an-enemy-when-hit-with-a-certain-element.179824/