Is there a way to make enemies only killable by certain spells?

For example, how would I go about making vampires only killable by fire and/or the use of an item such as a "stake" once there HP is at 1 or 0? Is something like this possible?
Wouldn't be better for vampire slaying to do something like this?
If you want to kill a vampire with stake, then in items skill formula type type simply:
b.gainHp(-b.mhp);

Create an item stake to instantly kill only a vampires then type this in skill formula:

Code:
$dataEnemies[b.enemyId()].meta["vampire"] ? b.gainHp(-b.mhp) : any dmg formula

and in enemies tab in database place notetag <vampire> for your vampire-type enemies.

This will check by item if enemy is a vampire-type, if yes, then kill it instantly, if not, do some other damage
Would that formula cause the stake to kill the vampire instantly? Or deal a certain amount of damage? And, how would I go about stopping normal attacks from killing the vampire, give it resistance to knockout under it's traits maybe?
if you put tag <vampire> in enemy database https://prnt.sc/wej7tf then stake will instantly kill that enemy.
Otherwise stake will deal other damage (in place of phrase "any other dmg formula"), but if you wish to prevent a vampire from dying from other attacks then resistance from knockout state is out ot ofptions.
Better would be set a vampire in traits Element rate trait, this will reduce damage recieved by percentage value, so to keep your project more immersive set this trait for all skill types - https://prnt.sc/wejaqu.

Because I'm from poland and vampires are in my game also I'll explain few details how I did. In the image you see I have only 3 skill types:

Zaklęcia - Spells
Fizyczne - Physical
Boskie - Divine

My vampire has high HP regeneration trait, at 25% and element rate of two first skill types at 5% wich means my vampire has resistance to those skill types by 95% (almost invincible). Only divine skills can deal full damage to vampires. Stake with this skill formula I provided post earlier avoids that and kills instantly.

There is also a second way, but do you have installed Yanfly's Auto Passive States plugin?
I have auto passive states, yes. And thanks for the advice, making them highly resistant to everything except fire is actually a good idea, then just have stakes do normal damage so players without fire spells or weapons can use them.

This actually brings another question to mind, making a "turn undead" spell that reduces undead AGI to zero so they act last in turn (I use Olivia's Octopack Battler system). I bet this could be done with the same kind of tagging system that you use with the vampire and stake.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-make-enemies-only-killable-by-certain-spells.131695/