MV Killing an enemy only with certain elements

After 5 years I finally are about to finish my game. However now there is a problem that I have not found a perfect solution yet and I can't procrastinate it anymore - so I'm asking the first time for help.

I would like to have an enemy that cannot be defeated by any of the following four elements. Below, I list the elements and their corresponding numbers:

Explosion = 10, Technology = 11, Nature = 12, Blood = 14.

Making the enemy immune to other elements is not an option, as it has a skill that reflects any other damage received proportionally. The easiest approach seems to be giving the enemy a state (numbered 145) that makes it invincible and then ignoring/removing this state upon being hit by one of these four elements.

I'm using Yanflys Elementcore plugin.
In the slot for this enemy click on the Traits box top right.
1685887327667.png

The very first option is Element Rate. Click on the little arrow to the right of physical and you will see a drop down list of all your elements. Select one. Then change the 100% to 0%.
Repeat for the other elements.

EDIT
Re-reading your post, I may have misunderstood what you want. Is it that you don't want them to be affected by those elements or that you don't want their HP to drop below 1 if they are hit by one of the elements?

Your proposed solution might not work. State 145 removed by being hit with one of the elements. Next attack is with another of those elements. Now no protection, so it will be defeated with one of the elements that you don't want it to be.
Your proposed solution might not work. State 145 removed by being hit with one of the elements. Next attack is with another of those elements. Now no protection, so it will be defeated with one of the elements that you don't want it to be.

Yes. The enemy is not immune.

I will try to explain what the enemy can fully do. It is a little complicated so bear with me on this:

The enemy can deal back any damage that he takes in % damage back to the opponent. For example if he takes 30% damage because of fire spell, then he will always survive this and deal 30% back to the player. (I already have this working!) After an attack he regenerates always 100% of his HP back.
The ability has a weakness. The 4 elements that I mentioned. The enemy can't repell this type of attacks back. So he will take damage from them. The 4 types of elements are the only way to defeat him.

Currently I am forced to make the enemy "invincible" since a fire attack can deal over 100% and kill him in one shot which is not intended.
So my thought was to find a workaround. The problem that I currently have is that I can't make him invincible since the enemy won't die, but I can't make him not invincible since he can get oneshotted.
So I thought to remove the state when hit by one of the 4 effective elements.
So I thought to remove the state when hit by one of the 4 effective elements.

That won't work because once you remove the state by using the correct element once, any other element can defeat the enemy.

What I would instead suggest is to check if the element is of the correct element AND the damage is equal to or greater than the enemy's remaining HP, and only remove the state if both of those conditions are met. You'll probably need Yanfly's Buff & States core plugin for that, and a Custom React Effect on the invincibility state.
That won't work because once you remove the state by using the correct element once, any other element can defeat the enemy.

What I would instead suggest is to check if the element is of the correct element AND the damage is equal to or greater than the enemy's remaining HP, and only remove the state if both of those conditions are met. You'll probably need Yanfly's Buff & States core plugin for that, and a Custom React Effect on the invincibility state.
That sounds good. How can I do this? I have nearly every Yanfly plugin - Buff and States are one of them. However I'm not that good at writing scripts from the grouns. I can only understand and alter them.
To add the state at the start of the battle, under your troop's battle event, create a page with Conditions: Turn 0 + 0 * X and Span: Battle. Create a new event command, "Change Enemy State" (under the third tab), and add the invincibility state to the enemies.


To remove the state, you can use this code in the notetag of the state (requires Yanfly's buff and states core)
Code:
<Custom React Effect>
if(value >= target.hp)
{
  switch(this.item().damage.elementId)
  {
    case 10:
    case 11:
    case 12:
    case 14:
      target.removeState(145);
    break;
      default:
    break;
  }
}
</Custom React Effect>

What this basically does is that when being hit, before the damage is applied, it will check if the value is greater than or equal to remaining HP, and if so, it will proceed to check the element of the attack/skill. If it is 10, 11, 12, or 14, it will remove state 145; otherwise, nothing happens.
thank you very much. it works!
Moved to: Plugin Support

Original thread: https://forums.rpgmakerweb.com/threads/killing-an-enemy-only-with-certain-elements.158044/