1. Mark your actor
This is pretty much self explanatory but when using your skill you have to mark your actor so that you can calculate how much damage he took later on. You can do it in many ways but since you want to apply something like a guard state to that actor I think using the state itself would be fine. Keep in mind that if you want to use the state itself to mark your actor you have to create a new state for this purpose, otherwise you will track down the first actor who guarded.
2. Store your actor's current health
One way of storing damage would be that of calculating the difference between you actor's health when the skill is supposed to retaliate and the health she had when the skill was first cast. First of all let your skill call a common event (or use its damage formula for the same purpose) and store your actor hp (not mhp, just hp) into a variable. If you want to use your damage formula you can just use
Code:
$game_variables[id] = a.hp
If you want to use a common event then you have to point the character who's able to cast this skill and store her hp.
3. Start a timer
You also need a variable to act as a timer to see how many turns you spent charging so that when you are ready you can retaliate. That variable must be set to 0 whenever you cast your skill and should then be increased every turn (using troop events). This means you probably want to use a switch to tell the engine when to increase that variable and when not.
4. When it's time retaliate
When your timer variable reaches the value you want it to you can finally force an action on your actor and retaliate. Your damage will just be calculated as follows
Code:
r = $game_variables[id] - a.hp
The variable you use here is the same one you used when storing your actor's hp.
You can force that action against a single random target or against all enemies, that's up to you depending on how you want the skill to affect your gameplay.
5. Reset counters
After casting your skill do not forget to remove the marking state from your actor and to reset bot your switch, your timer variable and the variable you used to store actor's current hp.