Thorn Damage, but by Skill or State

Hi RPG Maker Script people! I had an idea for something I want to implement, but since I am unfamiliar with RPG Maker's scripting stuff, I thought this would be the next step.

The idea is similar to Tsukihime's thorn mail (http://www.rpgmakervxace.net/topic/7525-thorn-mail/), but instead of applying to armor, instead it would be a state that the user would have for a set amount of turns. 

For example, the idea I have is something called Fire Guard, where your defense increases and your opponents' physical attacks do damage to you, but then also hurt them (because you're surrounded in fire).

The defense increase is pretty self explanatory, but a script to do thorns-esque damage with a skill or state would be most appreciated. Thanks in advance.
I wrote a Code Snippet for Yanfly's Lunatic States that covers this. Find it at my Dropbox.

Original thread: https://forums.rpgmakerweb.com/threads/thorn-damage-but-by-skill-or-state.42330/