How do I make a Trapping Skill like this?

I want to make a skill that traps the target party member in a black hole trap. The skill would stun the party member, decrease their resistance to dark damage, and can only be removed by another party member hitting the affected ally, and if it is removed in this way, the trapped party member is freed and takes no damage from the hit. However, if an enemy hits them, they are freed but still take the normal amount of damage. (plus the amount from the dark resistance down debuff)

I know to make the status stun the party member and give them a dark resistance debuff, but I have no clue how to handle the rest. I can use any plugins needed as long as they are free and compatible with Yanfly's plugins for MV.
What you think about making your actors attack with a different element than enemies, for example the enemies attack using the normal physic damage, what if your actors uses a different element called "actor physic" instead?

This way when the ally is affected by this tramp he could gain a 0% damage for the "actor physic" element.

---

Another way I think it could work is using Yanfly battle core and action sequences to change the normal attack effect bassed on who is party and who is troop AND if the state "trap" is on, for example:

JavaScript:
<Target Action>
perform action
action animation
wait for animation
if target.isEnemy()
    action effect
    death break
else if !target.isStateAffected(123)
    action effect
    death break
end
</Target Action>

Explanation: if target is enemy it will do the damage, if it is an ally and is not affected by the trap it will also do the damage, otherwise (it is an ally and is affected by the trap) then it will not do the damage.
how about making the adding 'blackhole' state will run common event... maybe using this plugin
the plugin can run common event when adding or removing the state...

make when the state 'black hole' inflicted... run the common event that give all party member
state that give 'free from blackhole' skill... which basically skill to free the friend from the blackhole state... it will deal 0 damage in the damage formula... remove 'blackhole' state from the target... then the scope will be one ally...

then also make the state 'black hole' state to also run common event on removal... using the same plugin... that common event will check does any party member still have 'black hole' state... if yes... do nothing... if no then remove the state that give 'free from blackhole' skill from all party member...

to make the enemy also able to free the actor inflicted by 'blackhole' state. just make the state like sleep state example which removed on hit...

hope this help.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-trapping-skill-like-this.133677/