Protection via Counterattacks?

I'm wanting to have a spell which, essentially, conjures a turret to protect somebody. How I want this to work mechanically is to put a state on an ally, and when an enemy attacks the protected hero there's an x% chance the person who cast the spell will make an attack against said enemy.

Alternatively, it could do a certain amount of damage to the person who attacks based on the caster's states?

Is there any plugin which makes this possible?

Original thread: https://forums.rpgmakerweb.com/threads/protection-via-counterattacks.103135/