Damage to those who attack someone with a state

Is there any way on having a state that damages someone, but not the one who is under the state , but the one who attacks the one who is under that state?

I don't care if such a state can only work on the actors.
Someone posted an add-on to Yanfly's Lunatic states which does this, here is the link to the code: http://forums.rpgmakerweb.com/index.php?/topic/40477-post-interesting-equipment-you-have-made-here/

Its near the bottom of the thread. We asked someone how they made an equipment which damaged the one who attacked you, and their reply was that script snippet. You would need Yanfly's Luantic States + The add-on to make it work though.

Not sure if it can be done without a script. Maybe someone has a non-scripting solution?
I already have Lunatic states I will check about the addon you say
You can do it in the damage formula.

Though the damage won't be displayed the same way. (It'll just happen.)

You can put:

dam = a.atk * 4 - b.def *2; if b.state?(x); a.hp-= dam/5; end; dam

Where x is the state you use for this.

Edit:  If you have Lunatic States and know how to use it, that would be a good way to go.
I nearly posted something very similar (I'd put the if clause at the beginning), but then decided that this approach won't work.

I think the OP wants the damage to be to whoever attacks this actor/enemy, not that it is a function of a specific skill.  For the damage formula to work, this if clause would have to go into every skill that might be used against that troop, including the default attack.
Right.  I actually scripted my game to do just that for all physical attacks, so yeah you're right.

So, Lunatic States it is!

😀
The problem with lunatic states (and the add-on) is that when I have this

<shock effect>

x = rand(6) + rand(6) + rand(6) + 3

thorn x

</shock effect>

That is the script I have in the section about shock effects.

Code:
when /COMMON SHOCK/i        eval(state.shock_effects[1]) rescue ""
That common shock was only meant to read in one line (there might be a way to change it to eval two lines, but I don't know it, and I foresee many problems if you just add a second line with a [2] instead of the [1]). I think you'll have to use the full add-on posted in that other thread for it to work well.
Paste my entire code snippet above the part where it says "Stop editting past this point"

Then use one of these two notetags:

Code:
   <shock effect: thorn x>   <shock effect: thorn_percent x%>
I must be missing something. 
Because nothing seems to happen...
Ok seems like I solved it. Thanks guys.

Original thread: https://forums.rpgmakerweb.com/threads/damage-to-those-who-attack-someone-with-a-state.40888/