Apply state to attacker if the target is hit with a skill of a certain element

Hello everybody. What I'm trying to do is the following: apply X state to any battler (actor or enemy) when they hit their enemy with a skill of X element. How can I make this possible? I know that Yanfly's buffs and states core is required, but don't know how the notetags would go apart from maybe putting <Custom Respond Effect></Custom Respond Effect> in the notetag.

This is the link to the plugin just in case. Thanks a lot for reading!

Well...you would have to clarify. On the face of things, that's backward. A notetag in a state can only have anything to do with a state...and there is no state until you apply it. And you are asking how to apply it.

It sounds like you'd use Yanfly's Skill Core, go to each skill of the appropriate element and put
Code:
<Post-Damage Eval>
user.addState(X);
</Post-Damage Eval>

If there's other way you want it to work, you'll need to elaborate.
Well...you would have to clarify. On the face of things, that's backward. A notetag in a state can only have anything to do with a state...and there is no state until you apply it. And you are asking how to apply it.

It sounds like you'd use Yanfly's Skill Core, go to each skill of the appropriate element and put
Code:
<Post-Damage Eval>
user.addState(X);
</Post-Damage Eval>

If there's other way you want it to work, you'll need to elaborate.
Yeah, sorry. I tend to not properly explain the context of what I want. Basically all actors and enemies have a passive state related to their elemental immunity. What these states (are supposed to) do is apply a negative state (like a stun) to any of their enemies when they use a skill of an element that they're immune to against them. So what I want is to know how to do that. It's not necessary to know how to detect the immunity as every battler will have a specific state for their immunity. I just need to know how to detect that a skill with a specific element is used. Thanks for your reply!
to any of their enemies when they use a skill of an element that they're immune to against them.
Just to put it out there - this is the kind of thing that's confusing, you're using they/them to refer to two different things 😉 But I believe I understand what you're getting at.

As you have, give each battler a passive state representing their element.

Then give those states:
Code:
<Custom Respond Effect>
if (this.isSkill() && this.item().damage.elementId == 2)
    user.addState(69);
</Custom Respond Effect>

Replace the 2 with the ID of the element type they are immune 2. Replace 69 with the ID of the state to inflict on the attacker.
Just to put it out there - this is the kind of thing that's confusing, you're using they/them to refer to two different things 😉 But I believe I understand what you're getting at.

As you have, give each battler a passive state representing their element.

Then give those states:
Code:
<Custom Respond Effect>
if (this.isSkill() && this.item().damage.elementId == 2)
    user.addState(69);
</Custom Respond Effect>

Replace the 2 with the ID of the element type they are immune 2. Replace 69 with the ID of the state to inflict on the attacker.
Oh, thanks for the advice. Yeah, as you can see I really struggle to make myself understood. It doesn't help that I'm not that good with English neither. Anyway, the notetag seems to be working perfectly fine. Thanks a lot, again. You've always helping me and others! When I finish my project I'll make sure to give you a copy. Have a nice day!

Original thread: https://forums.rpgmakerweb.com/threads/apply-state-to-attacker-if-the-target-is-hit-with-a-skill-of-a-certain-element.165349/