Trying to make a trap skill

Hi!


I have a character with a skill called "Black hole", which is a trap that can be set into the selected target for 1 turn [There's a 50% of chance that the trap can be set]. During the turn if the selected enemy attacks the actor who used the skill, the black hole will absorb the attack and explode, causing heavy damage (Based on the actor's attack) to the enemy. If the enemy attacks another actor or does not attack, then the black hole will simply dissappear.


I've created a state for the black hole, but I don't know what to do after that. Is there a way to make the enemy receive damage based on the actor's attack when attempting to attack only the actor who used the skill?
states cannot check for targeting, they are always passive results.


Theoretically you can try to do this by a troop event checking all combinations of enemies, states and targets - but that would be extremely complex.


The only realistic way is to use a script that checks if an actor is attacked and reacts to that - there are some scripts like that, but I don't have links ready and most are more like a "thorn"-barrier, causing damage to all attackers instead of only those with a state.


I've moved this thread to Script Request. Please be sure to post your threads in the correct forum next time. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-a-trap-skill.72544/